@distrohelena/canton-typescript-sdk 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +333 -1
- package/dist/client/canton-client-options.d.ts +3 -0
- package/dist/client/canton-client-options.js +2 -0
- package/dist/client/service-registry.js +3 -2
- package/dist/core/errors/grpc-transport-error.d.ts +14 -0
- package/dist/core/errors/grpc-transport-error.js +76 -0
- package/dist/core/signing/command-signer.interface.d.ts +2 -0
- package/dist/core/transports/transport.interface.d.ts +2 -2
- package/dist/core/types/canton-hash-purpose.d.ts +2 -1
- package/dist/core/types/canton-hash-purpose.js +1 -0
- package/dist/core/types/daml-numeric.d.ts +6 -0
- package/dist/core/types/daml-numeric.js +14 -0
- package/dist/core/types/daml-party.d.ts +6 -0
- package/dist/core/types/daml-party.js +14 -0
- package/dist/core/types/disclosed-contract.d.ts +13 -0
- package/dist/core/types/disclosed-contract.js +15 -0
- package/dist/core/types/requests/create-decentralized-party-request.d.ts +41 -0
- package/dist/core/types/requests/create-decentralized-party-request.js +82 -0
- package/dist/core/types/requests/create-external-party-request.d.ts +42 -0
- package/dist/core/types/requests/create-external-party-request.js +47 -0
- package/dist/core/types/requests/finalize-decentralized-party-request.d.ts +39 -0
- package/dist/core/types/requests/finalize-decentralized-party-request.js +42 -0
- package/dist/core/types/requests/get-active-contracts-page-request.d.ts +15 -2
- package/dist/core/types/requests/get-active-contracts-page-request.js +4 -0
- package/dist/core/types/requests/submit-command-request.d.ts +5 -0
- package/dist/core/types/requests/submit-command-request.js +4 -0
- package/dist/core/types/topology/topology-signature-format.d.ts +2 -1
- package/dist/core/types/topology/topology-signature-format.js +1 -0
- package/dist/daml-lf/container/dar-archive-entry.d.ts +8 -0
- package/dist/daml-lf/container/dar-archive-entry.js +8 -0
- package/dist/daml-lf/container/dar-archive-loader.js +14 -0
- package/dist/daml-lf/container/dar-archive.d.ts +6 -0
- package/dist/daml-lf/container/dar-archive.js +4 -0
- package/dist/daml-lf/container/dar-source-bundle-loader.d.ts +5 -0
- package/dist/daml-lf/container/dar-source-bundle-loader.js +33 -0
- package/dist/daml-lf/container/dar-source-bundle.d.ts +45 -0
- package/dist/daml-lf/container/dar-source-bundle.js +11 -0
- package/dist/daml-lf/container/dar-source-file-entry.d.ts +8 -0
- package/dist/daml-lf/container/dar-source-file-entry.js +8 -0
- package/dist/daml-lf/daml-lf-compilation.d.ts +12 -0
- package/dist/daml-lf/daml-lf-compilation.js +35 -0
- package/dist/daml-lf/index.d.ts +11 -0
- package/dist/daml-lf/index.js +10 -0
- package/dist/daml-lf/interpreter/daml-lf-builtin-dispatch.d.ts +43 -0
- package/dist/daml-lf/interpreter/daml-lf-builtin-dispatch.js +933 -0
- package/dist/daml-lf/interpreter/daml-lf-evaluator.d.ts +95 -0
- package/dist/daml-lf/interpreter/daml-lf-evaluator.js +1131 -0
- package/dist/daml-lf/interpreter/daml-lf-interpreter-scaffold.d.ts +3 -0
- package/dist/daml-lf/interpreter/daml-lf-interpreter-scaffold.js +6 -1
- package/dist/daml-lf/interpreter/daml-lf-lexical-scope.d.ts +13 -0
- package/dist/daml-lf/interpreter/daml-lf-lexical-scope.js +46 -0
- package/dist/daml-lf/interpreter/daml-lf-runtime-frame.d.ts +16 -0
- package/dist/daml-lf/interpreter/daml-lf-runtime-frame.js +15 -0
- package/dist/daml-lf/interpreter/daml-lf-runtime-value.d.ts +21 -0
- package/dist/daml-lf/interpreter/daml-lf-runtime-value.js +4 -1
- package/dist/daml-lf/interpreter/daml-lf-step-kind.d.ts +7 -0
- package/dist/daml-lf/interpreter/daml-lf-step-kind.js +8 -0
- package/dist/daml-lf/interpreter/daml-lf-trace-sink.interface.d.ts +30 -0
- package/dist/daml-lf/interpreter/daml-lf-trace-sink.interface.js +1 -0
- package/dist/daml-lf/model/daml-lf-builtin-type.d.ts +3 -0
- package/dist/daml-lf/model/daml-lf-builtin-type.js +3 -0
- package/dist/daml-lf/model/daml-lf-choice.d.ts +5 -0
- package/dist/daml-lf/model/daml-lf-choice.js +4 -0
- package/dist/daml-lf/model/daml-lf-expression-path.d.ts +2 -0
- package/dist/daml-lf/model/daml-lf-expression-path.js +81 -0
- package/dist/daml-lf/model/daml-lf-expression.d.ts +146 -0
- package/dist/daml-lf/model/daml-lf-expression.js +71 -0
- package/dist/daml-lf/model/daml-lf-template.d.ts +2 -0
- package/dist/daml-lf/model/daml-lf-template.js +2 -0
- package/dist/daml-lf/model/daml-lf-type.d.ts +2 -0
- package/dist/daml-lf/model/daml-lf-type.js +4 -0
- package/dist/daml-lf/model/lf-2-model-mapper.d.ts +5 -0
- package/dist/daml-lf/model/lf-2-model-mapper.js +445 -12
- package/dist/debugger/errors/replay-determinism.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-determinism.exception.js +3 -0
- package/dist/debugger/errors/replay-missing-package.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-missing-package.exception.js +3 -0
- package/dist/debugger/errors/replay-missing-source.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-missing-source.exception.js +3 -0
- package/dist/debugger/errors/replay-source-map.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-source-map.exception.js +3 -0
- package/dist/debugger/errors/replay-state-hydration.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-state-hydration.exception.js +3 -0
- package/dist/debugger/errors/replay-unsupported-lf-construct.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-unsupported-lf-construct.exception.js +3 -0
- package/dist/debugger/errors/replay-unsupported-update.exception.d.ts +3 -0
- package/dist/debugger/errors/replay-unsupported-update.exception.js +3 -0
- package/dist/debugger/index.d.ts +31 -0
- package/dist/debugger/index.js +31 -0
- package/dist/debugger/ledger-replay-debugger-client.d.ts +31 -0
- package/dist/debugger/ledger-replay-debugger-client.js +53 -0
- package/dist/debugger/replay/ledger-replay-environment-builder.d.ts +95 -0
- package/dist/debugger/replay/ledger-replay-environment-builder.js +249 -0
- package/dist/debugger/replay/ledger-replay-session-loader.d.ts +78 -0
- package/dist/debugger/replay/ledger-replay-session-loader.js +565 -0
- package/dist/debugger/replay/replay-artifact-resolver.d.ts +30 -0
- package/dist/debugger/replay/replay-artifact-resolver.js +210 -0
- package/dist/debugger/replay/replay-determinism-validator.d.ts +12 -0
- package/dist/debugger/replay/replay-determinism-validator.js +161 -0
- package/dist/debugger/replay/replay-entrypoint-definition-resolver.d.ts +40 -0
- package/dist/debugger/replay/replay-entrypoint-definition-resolver.js +337 -0
- package/dist/debugger/replay/replay-entrypoint.d.ts +22 -0
- package/dist/debugger/replay/replay-entrypoint.js +14 -0
- package/dist/debugger/replay/replay-ledger-value-normalizer.d.ts +7 -0
- package/dist/debugger/replay/replay-ledger-value-normalizer.js +194 -0
- package/dist/debugger/replay/replay-update-loader.d.ts +24 -0
- package/dist/debugger/replay/replay-update-loader.js +94 -0
- package/dist/debugger/replay/replay-update-visibility-validator.d.ts +19 -0
- package/dist/debugger/replay/replay-update-visibility-validator.js +19 -0
- package/dist/debugger/session/in-memory-replay-session-store.d.ts +27 -0
- package/dist/debugger/session/in-memory-replay-session-store.js +109 -0
- package/dist/debugger/session/replay-phase.d.ts +7 -0
- package/dist/debugger/session/replay-phase.js +8 -0
- package/dist/debugger/session/replay-scope.d.ts +10 -0
- package/dist/debugger/session/replay-scope.js +10 -0
- package/dist/debugger/session/replay-session-metadata.d.ts +10 -0
- package/dist/debugger/session/replay-session-metadata.js +10 -0
- package/dist/debugger/session/replay-session-request.d.ts +6 -0
- package/dist/debugger/session/replay-session-request.js +10 -0
- package/dist/debugger/session/replay-session.d.ts +12 -0
- package/dist/debugger/session/replay-session.js +10 -0
- package/dist/debugger/session/replay-source-location.d.ts +17 -0
- package/dist/debugger/session/replay-source-location.js +16 -0
- package/dist/debugger/session/replay-stack-frame.d.ts +8 -0
- package/dist/debugger/session/replay-stack-frame.js +8 -0
- package/dist/debugger/session/replay-state-delta.d.ts +29 -0
- package/dist/debugger/session/replay-state-delta.js +24 -0
- package/dist/debugger/session/replay-step-advance-result.d.ts +24 -0
- package/dist/debugger/session/replay-step-advance-result.js +16 -0
- package/dist/debugger/session/replay-step.d.ts +30 -0
- package/dist/debugger/session/replay-step.js +24 -0
- package/dist/debugger/session/replay-value-preview.d.ts +8 -0
- package/dist/debugger/session/replay-value-preview.js +15 -0
- package/dist/debugger/source/daml-source-mapper.d.ts +12 -0
- package/dist/debugger/source/daml-source-mapper.js +21 -0
- package/dist/debugger/source/dar-source-map-metadata.d.ts +26 -0
- package/dist/debugger/source/dar-source-map-metadata.js +10 -0
- package/dist/debugger/source/source-coverage-validator.d.ts +8 -0
- package/dist/debugger/source/source-coverage-validator.js +16 -0
- package/dist/debugger/source/source-indexed-compilation.d.ts +45 -0
- package/dist/debugger/source/source-indexed-compilation.js +110 -0
- package/dist/debugger/source/source-mapping-precision.d.ts +5 -0
- package/dist/debugger/source/source-mapping-precision.js +4 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +13 -0
- package/dist/query/cache/memory-query-cache.d.ts +9 -0
- package/dist/query/cache/memory-query-cache.js +24 -0
- package/dist/query/cache/query-cache-store.d.ts +5 -0
- package/dist/query/cache/query-cache-store.js +1 -0
- package/dist/query/canton-manager-options.d.ts +17 -0
- package/dist/query/canton-manager-options.js +1 -0
- package/dist/query/canton-manager.d.ts +11 -0
- package/dist/query/canton-manager.js +42 -0
- package/dist/query/errors/pqs-query-error.d.ts +10 -0
- package/dist/query/errors/pqs-query-error.js +11 -0
- package/dist/query/errors/pqs-schema-profile-error.d.ts +3 -0
- package/dist/query/errors/pqs-schema-profile-error.js +3 -0
- package/dist/query/errors/query-capability-error.d.ts +7 -0
- package/dist/query/errors/query-capability-error.js +10 -0
- package/dist/query/grpc/grpc-contract-query-client.d.ts +32 -0
- package/dist/query/grpc/grpc-contract-query-client.js +126 -0
- package/dist/query/model-types.d.ts +258 -0
- package/dist/query/model-types.js +14 -0
- package/dist/query/pqs/pqs-pool.d.ts +13 -0
- package/dist/query/pqs/pqs-pool.js +18 -0
- package/dist/query/pqs/pqs-query-client.d.ts +49 -0
- package/dist/query/pqs/pqs-query-client.js +324 -0
- package/dist/query/pqs/pqs-schema-profile.d.ts +25 -0
- package/dist/query/pqs/pqs-schema-profile.js +120 -0
- package/dist/query/pqs/pqs-sql-compiler.d.ts +7 -0
- package/dist/query/pqs/pqs-sql-compiler.js +132 -0
- package/dist/query/pqs/read-only-sql.d.ts +1 -0
- package/dist/query/pqs/read-only-sql.js +35 -0
- package/dist/query/query-client.d.ts +61 -0
- package/dist/query/query-client.js +1 -0
- package/dist/query/query-source.d.ts +4 -0
- package/dist/query/query-source.js +5 -0
- package/dist/services/command/command-service-client.d.ts +2 -2
- package/dist/services/commands/command-submission-pipeline.d.ts +2 -2
- package/dist/services/party-management/decentralized-party-lifecycle.d.ts +6 -0
- package/dist/services/party-management/decentralized-party-lifecycle.js +82 -0
- package/dist/services/party-management/party-management-service-client.d.ts +16 -1
- package/dist/services/party-management/party-management-service-client.js +142 -1
- package/dist/services/topology-manager-write/topology-signed-transaction-assembler.js +4 -0
- package/dist/testing/campaign/campaign-artifact.d.ts +20 -0
- package/dist/testing/campaign/campaign-artifact.js +147 -0
- package/dist/testing/campaign/campaign-definition.d.ts +9 -0
- package/dist/testing/campaign/campaign-definition.js +78 -0
- package/dist/testing/campaign/campaign-metrics.d.ts +32 -0
- package/dist/testing/campaign/campaign-metrics.js +26 -0
- package/dist/testing/campaign/campaign-model.d.ts +11 -0
- package/dist/testing/campaign/campaign-model.js +21 -0
- package/dist/testing/campaign/campaign-runner.d.ts +99 -0
- package/dist/testing/campaign/campaign-runner.js +194 -0
- package/dist/testing/campaign/campaign-scheduler.d.ts +40 -0
- package/dist/testing/campaign/campaign-scheduler.js +75 -0
- package/dist/testing/campaign/campaign-types.d.ts +52 -0
- package/dist/testing/campaign/campaign-types.js +11 -0
- package/dist/testing/daml/daml-action-arbitrary.d.ts +13 -0
- package/dist/testing/daml/daml-action-arbitrary.js +24 -0
- package/dist/testing/daml/daml-choice-action-arbitrary.d.ts +18 -0
- package/dist/testing/daml/daml-choice-action-arbitrary.js +27 -0
- package/dist/testing/daml/daml-create-action-arbitrary.d.ts +19 -0
- package/dist/testing/daml/daml-create-action-arbitrary.js +34 -0
- package/dist/testing/daml/daml-testing-catalog.d.ts +38 -0
- package/dist/testing/daml/daml-testing-catalog.js +40 -0
- package/dist/testing/daml/daml-value-arbitrary.d.ts +8 -0
- package/dist/testing/daml/daml-value-arbitrary.js +43 -0
- package/dist/testing/daml/declarative-campaign-arbitrary.d.ts +15 -0
- package/dist/testing/daml/declarative-campaign-arbitrary.js +30 -0
- package/dist/testing/errors/invariant-campaign-failure.d.ts +24 -0
- package/dist/testing/errors/invariant-campaign-failure.js +37 -0
- package/dist/testing/errors/testing-configuration-error.d.ts +3 -0
- package/dist/testing/errors/testing-configuration-error.js +6 -0
- package/dist/testing/handlers/handler.d.ts +19 -0
- package/dist/testing/handlers/handler.js +31 -0
- package/dist/testing/index.d.ts +22 -0
- package/dist/testing/index.js +22 -0
- package/dist/testing/runtime/campaign-isolation.d.ts +14 -0
- package/dist/testing/runtime/campaign-isolation.js +23 -0
- package/dist/testing/runtime/canton-test-runtime.d.ts +58 -0
- package/dist/testing/runtime/canton-test-runtime.js +138 -0
- package/dist/testing/runtime/declarative-action-executor.d.ts +16 -0
- package/dist/testing/runtime/declarative-action-executor.js +41 -0
- package/dist/testing/targets/target.d.ts +49 -0
- package/dist/testing/targets/target.js +121 -0
- package/dist/transports/grpc/grpc-channel-factory.js +31 -1
- package/dist/transports/grpc/grpc-transport.d.ts +2 -2
- package/dist/transports/grpc/grpc-transport.js +11 -8
- package/dist/transports/grpc/mappers/commands-mapper.js +23 -2
- package/dist/transports/grpc/mappers/contracts-mapper.d.ts +3 -1
- package/dist/transports/grpc/mappers/contracts-mapper.js +16 -3
- package/dist/transports/grpc/mappers/interactive-command-mapper.d.ts +4 -1
- package/dist/transports/grpc/mappers/interactive-command-mapper.js +3 -8
- package/dist/transports/grpc/mappers/topology-manager-write-mapper.js +59 -1
- package/dist/transports/json/mappers/commands-mapper.js +20 -6
- package/node/.generated/start-local/additional-config.extra-participants.conf +37 -0
- package/node/.generated/start-local/additional-config.extra-validators.conf +35 -0
- package/node/.generated/start-local/compose-extra-participants.yaml +147 -0
- package/node/.generated/start-local/extra-participants.env +30 -0
- package/node/es256-jwt.mjs +177 -0
- package/node/start-local.sh +886 -0
- package/node/stop-local.sh +200 -0
- package/node/test-start-local.sh +354 -0
- package/node/test-stop-local.sh +112 -0
- package/package.json +21 -2
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { GetActiveContractsPageRequest } from "../../core/types/requests/get-active-contracts-page-request.js";
|
|
2
|
+
import { QueryCapabilityError } from "../errors/query-capability-error.js";
|
|
3
|
+
import { QuerySource } from "../query-source.js";
|
|
4
|
+
export class GrpcContractQueryClient {
|
|
5
|
+
stateService;
|
|
6
|
+
cache;
|
|
7
|
+
cacheTtlMs;
|
|
8
|
+
cacheScope;
|
|
9
|
+
source = QuerySource.grpc;
|
|
10
|
+
contracts = {
|
|
11
|
+
findMany: (args = {}) => this.findManyAsync(args),
|
|
12
|
+
findUnique: (args) => {
|
|
13
|
+
if (args.select !== undefined) {
|
|
14
|
+
return Promise.reject(new QueryCapabilityError(QuerySource.grpc, "contracts.findUnique"));
|
|
15
|
+
}
|
|
16
|
+
return this.findManyAsync({ where: { contractId: { equals: args.where.contractId } } }).then((rows) => rows[0]);
|
|
17
|
+
},
|
|
18
|
+
count: async (args = {}) => (await this.findManyAsync(args)).length,
|
|
19
|
+
aggregate: async () => {
|
|
20
|
+
throw new QueryCapabilityError(QuerySource.grpc, "contracts.aggregate");
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
contractTypes = this.unsupported("contractTypes");
|
|
24
|
+
events = this.unsupported("events");
|
|
25
|
+
exercises = this.unsupported("exercises");
|
|
26
|
+
exerciseTypes = this.unsupported("exerciseTypes");
|
|
27
|
+
packages = this.unsupported("packages");
|
|
28
|
+
transactions = this.unsupported("transactions");
|
|
29
|
+
watermark = this.unsupported("watermark");
|
|
30
|
+
constructor(stateService, cache, cacheTtlMs, cacheScope) {
|
|
31
|
+
this.stateService = stateService;
|
|
32
|
+
this.cache = cache;
|
|
33
|
+
this.cacheTtlMs = cacheTtlMs;
|
|
34
|
+
this.cacheScope = cacheScope;
|
|
35
|
+
}
|
|
36
|
+
async $queryRaw(_sql, _values = []) {
|
|
37
|
+
throw new QueryCapabilityError(QuerySource.grpc, "query.$queryRaw");
|
|
38
|
+
}
|
|
39
|
+
async findManyAsync(args) {
|
|
40
|
+
if (hasUnsupportedFilter(args.where) ||
|
|
41
|
+
args.where?.active === false ||
|
|
42
|
+
args.where?.packageId !== undefined ||
|
|
43
|
+
args.where?.witnesses !== undefined ||
|
|
44
|
+
args.where?.contractId?.in !== undefined ||
|
|
45
|
+
args.where?.contractId?.is !== undefined ||
|
|
46
|
+
args.where?.contractId?.isNot !== undefined ||
|
|
47
|
+
args.where?.templateId !== undefined) {
|
|
48
|
+
throw new QueryCapabilityError(QuerySource.grpc, "contracts.findMany");
|
|
49
|
+
}
|
|
50
|
+
const findArgs = args;
|
|
51
|
+
if (findArgs.select !== undefined || findArgs.orderBy !== undefined || findArgs.skip !== undefined || findArgs.take !== undefined) {
|
|
52
|
+
throw new QueryCapabilityError(QuerySource.grpc, "contracts.findMany");
|
|
53
|
+
}
|
|
54
|
+
const snapshot = await this.readSnapshotAsync(args.parties);
|
|
55
|
+
let rows = snapshot.filter((row) => args.where?.contractId?.equals === undefined
|
|
56
|
+
? true
|
|
57
|
+
: row.contractId === args.where.contractId.equals);
|
|
58
|
+
return rows;
|
|
59
|
+
}
|
|
60
|
+
unsupported(operation) {
|
|
61
|
+
return {
|
|
62
|
+
findMany: async () => {
|
|
63
|
+
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.findMany`);
|
|
64
|
+
},
|
|
65
|
+
findUnique: async () => {
|
|
66
|
+
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.findUnique`);
|
|
67
|
+
},
|
|
68
|
+
count: async () => {
|
|
69
|
+
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.count`);
|
|
70
|
+
},
|
|
71
|
+
aggregate: async () => {
|
|
72
|
+
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.aggregate`);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async readSnapshotAsync(parties) {
|
|
77
|
+
const key = `${this.cacheScope}:${parties?.join(",") ?? "*"}`;
|
|
78
|
+
const cached = this.cache === undefined ? undefined : await this.cache.getAsync(key);
|
|
79
|
+
if (cached !== undefined) {
|
|
80
|
+
return cached;
|
|
81
|
+
}
|
|
82
|
+
const rows = [];
|
|
83
|
+
let pageToken;
|
|
84
|
+
let activeAtOffset;
|
|
85
|
+
do {
|
|
86
|
+
const response = await this.stateService.getActiveContractsPageAsync(new GetActiveContractsPageRequest(parties === undefined
|
|
87
|
+
? { allParties: true, activeAtOffset, pageToken }
|
|
88
|
+
: { parties, activeAtOffset, pageToken }));
|
|
89
|
+
activeAtOffset ??= response.activeAtOffset;
|
|
90
|
+
pageToken = response.nextPageToken;
|
|
91
|
+
rows.push(...response.contracts.map(mapGrpcContract));
|
|
92
|
+
} while (pageToken !== undefined && pageToken.length > 0);
|
|
93
|
+
if (this.cache !== undefined && this.cacheTtlMs !== undefined) {
|
|
94
|
+
await this.cache.setAsync(key, rows, this.cacheTtlMs);
|
|
95
|
+
}
|
|
96
|
+
return rows;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function hasUnsupportedFilter(where) {
|
|
100
|
+
if (where === undefined)
|
|
101
|
+
return false;
|
|
102
|
+
if ("and" in where || "or" in where || "not" in where || "payload" in where || "createdEventOffset" in where || "createdAt" in where || "archivedEventOffset" in where || "archivedAt" in where)
|
|
103
|
+
return true;
|
|
104
|
+
for (const field of ["contractId", "templateId"]) {
|
|
105
|
+
const filter = where[field];
|
|
106
|
+
if (filter !== undefined && Object.keys(filter).some((key) => key !== "equals"))
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
function mapGrpcContract(value) {
|
|
112
|
+
const row = value;
|
|
113
|
+
const template = row.templateId;
|
|
114
|
+
return {
|
|
115
|
+
contractId: row.contractId ?? "",
|
|
116
|
+
templateId: { packageId: template?.packageId ?? "", moduleName: template?.moduleName ?? "", entityName: template?.entityName ?? "" },
|
|
117
|
+
packageId: null,
|
|
118
|
+
payload: undefined,
|
|
119
|
+
witnesses: [],
|
|
120
|
+
createdEventOffset: "",
|
|
121
|
+
createdAt: null,
|
|
122
|
+
archivedEventOffset: null,
|
|
123
|
+
archivedAt: null,
|
|
124
|
+
active: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
export type QueryOrder = "asc" | "desc";
|
|
2
|
+
export interface ScalarFilter<T> {
|
|
3
|
+
readonly equals?: T;
|
|
4
|
+
readonly in?: readonly T[];
|
|
5
|
+
readonly is?: null;
|
|
6
|
+
readonly isNot?: null;
|
|
7
|
+
}
|
|
8
|
+
export interface OrderedFilter<T> extends ScalarFilter<T> {
|
|
9
|
+
readonly lt?: T;
|
|
10
|
+
readonly lte?: T;
|
|
11
|
+
readonly gt?: T;
|
|
12
|
+
readonly gte?: T;
|
|
13
|
+
}
|
|
14
|
+
export interface StringFilter extends OrderedFilter<string> {
|
|
15
|
+
readonly like?: string;
|
|
16
|
+
readonly ilike?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ArrayMembershipFilter {
|
|
19
|
+
readonly has: string;
|
|
20
|
+
}
|
|
21
|
+
export type WhereExpression<TFields> = TFields & {
|
|
22
|
+
readonly and?: readonly WhereExpression<TFields>[];
|
|
23
|
+
readonly or?: readonly WhereExpression<TFields>[];
|
|
24
|
+
readonly not?: WhereExpression<TFields>;
|
|
25
|
+
};
|
|
26
|
+
export type RowWhere<TRow, TOrdered extends keyof TRow = never, TPattern extends keyof TRow = never> = WhereExpression<Partial<{
|
|
27
|
+
readonly [TField in keyof TRow]: TRow[TField] extends readonly string[] ? ScalarFilter<TRow[TField]> | ArrayMembershipFilter : TField extends TPattern ? StringFilter : TField extends TOrdered ? OrderedFilter<TRow[TField]> : ScalarFilter<TRow[TField]>;
|
|
28
|
+
}>>;
|
|
29
|
+
export type RowSelect<TRow> = Partial<Record<keyof TRow, boolean>>;
|
|
30
|
+
export type RowOrderBy<TRow> = Partial<Record<keyof TRow, QueryOrder>>;
|
|
31
|
+
export interface QueryPageArgs {
|
|
32
|
+
readonly skip?: number;
|
|
33
|
+
readonly take?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ContractRow {
|
|
36
|
+
readonly contractId: string;
|
|
37
|
+
readonly templateId: TemplateId;
|
|
38
|
+
readonly packageId: string | null;
|
|
39
|
+
readonly payload: unknown;
|
|
40
|
+
readonly witnesses: readonly string[];
|
|
41
|
+
readonly createdEventOffset: string;
|
|
42
|
+
readonly createdAt: Date | null;
|
|
43
|
+
readonly archivedEventOffset: string | null;
|
|
44
|
+
readonly archivedAt: Date | null;
|
|
45
|
+
readonly active: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface TemplateId {
|
|
48
|
+
readonly packageId: string;
|
|
49
|
+
readonly moduleName: string;
|
|
50
|
+
readonly entityName: string;
|
|
51
|
+
}
|
|
52
|
+
type PayloadValueFilter = {
|
|
53
|
+
readonly equals: string;
|
|
54
|
+
readonly lt?: never;
|
|
55
|
+
readonly lte?: never;
|
|
56
|
+
readonly gt?: never;
|
|
57
|
+
readonly gte?: never;
|
|
58
|
+
readonly like?: never;
|
|
59
|
+
readonly ilike?: never;
|
|
60
|
+
} | {
|
|
61
|
+
readonly lt: string;
|
|
62
|
+
readonly equals?: never;
|
|
63
|
+
readonly lte?: never;
|
|
64
|
+
readonly gt?: never;
|
|
65
|
+
readonly gte?: never;
|
|
66
|
+
readonly like?: never;
|
|
67
|
+
readonly ilike?: never;
|
|
68
|
+
} | {
|
|
69
|
+
readonly lte: string;
|
|
70
|
+
readonly equals?: never;
|
|
71
|
+
readonly lt?: never;
|
|
72
|
+
readonly gt?: never;
|
|
73
|
+
readonly gte?: never;
|
|
74
|
+
readonly like?: never;
|
|
75
|
+
readonly ilike?: never;
|
|
76
|
+
} | {
|
|
77
|
+
readonly gt: string;
|
|
78
|
+
readonly equals?: never;
|
|
79
|
+
readonly lt?: never;
|
|
80
|
+
readonly lte?: never;
|
|
81
|
+
readonly gte?: never;
|
|
82
|
+
readonly like?: never;
|
|
83
|
+
readonly ilike?: never;
|
|
84
|
+
} | {
|
|
85
|
+
readonly gte: string;
|
|
86
|
+
readonly equals?: never;
|
|
87
|
+
readonly lt?: never;
|
|
88
|
+
readonly lte?: never;
|
|
89
|
+
readonly gt?: never;
|
|
90
|
+
readonly like?: never;
|
|
91
|
+
readonly ilike?: never;
|
|
92
|
+
} | {
|
|
93
|
+
readonly like: string;
|
|
94
|
+
readonly equals?: never;
|
|
95
|
+
readonly lt?: never;
|
|
96
|
+
readonly lte?: never;
|
|
97
|
+
readonly gt?: never;
|
|
98
|
+
readonly gte?: never;
|
|
99
|
+
readonly ilike?: never;
|
|
100
|
+
} | {
|
|
101
|
+
readonly ilike: string;
|
|
102
|
+
readonly equals?: never;
|
|
103
|
+
readonly lt?: never;
|
|
104
|
+
readonly lte?: never;
|
|
105
|
+
readonly gt?: never;
|
|
106
|
+
readonly gte?: never;
|
|
107
|
+
readonly like?: never;
|
|
108
|
+
};
|
|
109
|
+
export type ContractPayloadFilter = {
|
|
110
|
+
readonly path: string;
|
|
111
|
+
} & PayloadValueFilter;
|
|
112
|
+
type ContractWhereFields = {
|
|
113
|
+
readonly contractId?: StringFilter;
|
|
114
|
+
readonly templateId?: Partial<{
|
|
115
|
+
readonly packageId: StringFilter;
|
|
116
|
+
readonly moduleName: StringFilter;
|
|
117
|
+
readonly entityName: StringFilter;
|
|
118
|
+
}>;
|
|
119
|
+
readonly packageId?: StringFilter;
|
|
120
|
+
readonly createdEventOffset?: OrderedFilter<string>;
|
|
121
|
+
readonly createdAt?: OrderedFilter<Date | null>;
|
|
122
|
+
readonly archivedEventOffset?: OrderedFilter<string | null>;
|
|
123
|
+
readonly archivedAt?: OrderedFilter<Date | null>;
|
|
124
|
+
readonly active?: boolean | ScalarFilter<boolean>;
|
|
125
|
+
readonly witnesses?: {
|
|
126
|
+
readonly has: string;
|
|
127
|
+
};
|
|
128
|
+
readonly payload?: ContractPayloadFilter;
|
|
129
|
+
};
|
|
130
|
+
export type ContractWhere = WhereExpression<ContractWhereFields>;
|
|
131
|
+
export type ContractOrderField = "contractId" | "createdEventOffset" | "createdAt" | "archivedEventOffset" | "archivedAt";
|
|
132
|
+
export type ContractOrderBy = Partial<Record<ContractOrderField, QueryOrder>>;
|
|
133
|
+
export type ContractSelect = Partial<Record<keyof ContractRow, boolean>>;
|
|
134
|
+
export interface ContractFindManyArgs extends QueryPageArgs {
|
|
135
|
+
readonly parties?: readonly string[];
|
|
136
|
+
readonly where?: ContractWhere;
|
|
137
|
+
readonly orderBy?: ContractOrderBy;
|
|
138
|
+
readonly select?: ContractSelect;
|
|
139
|
+
}
|
|
140
|
+
export interface ContractFindUniqueArgs {
|
|
141
|
+
readonly where: {
|
|
142
|
+
readonly contractId: string;
|
|
143
|
+
};
|
|
144
|
+
readonly select?: ContractSelect;
|
|
145
|
+
}
|
|
146
|
+
export interface ContractCountArgs {
|
|
147
|
+
readonly parties?: readonly string[];
|
|
148
|
+
readonly where?: ContractWhere;
|
|
149
|
+
}
|
|
150
|
+
export interface ContractTypeRow {
|
|
151
|
+
readonly pk: string;
|
|
152
|
+
readonly payloadType: string;
|
|
153
|
+
readonly aliases: readonly string[];
|
|
154
|
+
readonly packageName: string;
|
|
155
|
+
readonly moduleName: string;
|
|
156
|
+
readonly entityName: string;
|
|
157
|
+
readonly templateFqn: string;
|
|
158
|
+
}
|
|
159
|
+
export interface EventRow {
|
|
160
|
+
readonly pk: string;
|
|
161
|
+
readonly txIx: string;
|
|
162
|
+
readonly eventId: string;
|
|
163
|
+
readonly type: string;
|
|
164
|
+
}
|
|
165
|
+
export interface ExerciseRow {
|
|
166
|
+
readonly tpePk: string;
|
|
167
|
+
readonly contractTpePk: string;
|
|
168
|
+
readonly exerciseEventPk: string | null;
|
|
169
|
+
readonly exercisedAtIx: string | null;
|
|
170
|
+
readonly contractId: string;
|
|
171
|
+
readonly argument: unknown;
|
|
172
|
+
readonly result: unknown;
|
|
173
|
+
readonly redactionId: string | null;
|
|
174
|
+
readonly packagePk: string;
|
|
175
|
+
readonly controllers: readonly string[];
|
|
176
|
+
readonly lastDescendantNodeId: number;
|
|
177
|
+
readonly witnesses: readonly string[];
|
|
178
|
+
}
|
|
179
|
+
export interface ExerciseTypeRow {
|
|
180
|
+
readonly pk: string;
|
|
181
|
+
readonly choice: string;
|
|
182
|
+
readonly consuming: boolean;
|
|
183
|
+
readonly aliases: readonly string[];
|
|
184
|
+
readonly packageName: string;
|
|
185
|
+
readonly moduleName: string;
|
|
186
|
+
readonly entityName: string;
|
|
187
|
+
readonly templateFqn: string;
|
|
188
|
+
readonly choiceFqn: string;
|
|
189
|
+
}
|
|
190
|
+
export interface PackageRow {
|
|
191
|
+
readonly pk: string;
|
|
192
|
+
readonly name: string;
|
|
193
|
+
readonly version: string;
|
|
194
|
+
readonly id: string;
|
|
195
|
+
}
|
|
196
|
+
export interface TransactionRow {
|
|
197
|
+
readonly ix: string;
|
|
198
|
+
readonly offset: string;
|
|
199
|
+
readonly transactionId: string | null;
|
|
200
|
+
readonly effectiveAt: Date | null;
|
|
201
|
+
readonly workflowId: string | null;
|
|
202
|
+
readonly domainId: string | null;
|
|
203
|
+
readonly traceContext: unknown;
|
|
204
|
+
readonly externalTransactionHash: Uint8Array | null;
|
|
205
|
+
readonly paidTrafficCost: string | null;
|
|
206
|
+
}
|
|
207
|
+
export interface WatermarkRow {
|
|
208
|
+
readonly singleton: boolean;
|
|
209
|
+
readonly ix: string | null;
|
|
210
|
+
readonly offset: string | null;
|
|
211
|
+
readonly instanceId: string | null;
|
|
212
|
+
}
|
|
213
|
+
export type ContractTypeWhere = RowWhere<ContractTypeRow, "pk", "payloadType" | "packageName" | "moduleName" | "entityName" | "templateFqn">;
|
|
214
|
+
export type ContractTypeSelect = RowSelect<ContractTypeRow>;
|
|
215
|
+
export type ContractTypeOrderBy = RowOrderBy<ContractTypeRow>;
|
|
216
|
+
export type ContractTypeUnique = {
|
|
217
|
+
readonly pk: string;
|
|
218
|
+
};
|
|
219
|
+
export type EventWhere = RowWhere<EventRow, "pk" | "txIx", "eventId" | "type">;
|
|
220
|
+
export type EventSelect = RowSelect<EventRow>;
|
|
221
|
+
export type EventOrderBy = RowOrderBy<EventRow>;
|
|
222
|
+
export type EventUnique = {
|
|
223
|
+
readonly pk: string;
|
|
224
|
+
};
|
|
225
|
+
export type ExerciseWhere = RowWhere<ExerciseRow, "tpePk" | "contractTpePk" | "exerciseEventPk" | "exercisedAtIx" | "packagePk" | "lastDescendantNodeId", "contractId" | "redactionId">;
|
|
226
|
+
export type ExerciseSelect = RowSelect<ExerciseRow>;
|
|
227
|
+
export type ExerciseOrderBy = RowOrderBy<ExerciseRow>;
|
|
228
|
+
export type ExerciseTypeWhere = RowWhere<ExerciseTypeRow, "pk", "choice" | "packageName" | "moduleName" | "entityName" | "templateFqn" | "choiceFqn">;
|
|
229
|
+
export type ExerciseTypeSelect = RowSelect<ExerciseTypeRow>;
|
|
230
|
+
export type ExerciseTypeOrderBy = RowOrderBy<ExerciseTypeRow>;
|
|
231
|
+
export type ExerciseTypeUnique = {
|
|
232
|
+
readonly pk: string;
|
|
233
|
+
};
|
|
234
|
+
export type PackageWhere = RowWhere<PackageRow, "pk", "name" | "version" | "id">;
|
|
235
|
+
export type PackageSelect = RowSelect<PackageRow>;
|
|
236
|
+
export type PackageOrderBy = RowOrderBy<PackageRow>;
|
|
237
|
+
export type PackageUnique = {
|
|
238
|
+
readonly pk: string;
|
|
239
|
+
} | {
|
|
240
|
+
readonly id: string;
|
|
241
|
+
};
|
|
242
|
+
export type TransactionWhere = RowWhere<TransactionRow, "ix" | "offset" | "effectiveAt" | "paidTrafficCost", "transactionId" | "workflowId" | "domainId">;
|
|
243
|
+
export type TransactionSelect = RowSelect<TransactionRow>;
|
|
244
|
+
export type TransactionOrderBy = RowOrderBy<TransactionRow>;
|
|
245
|
+
export type TransactionUnique = {
|
|
246
|
+
readonly ix: string;
|
|
247
|
+
} | {
|
|
248
|
+
readonly offset: string;
|
|
249
|
+
};
|
|
250
|
+
export type WatermarkWhere = RowWhere<WatermarkRow, "ix" | "offset", "instanceId">;
|
|
251
|
+
export type WatermarkSelect = RowSelect<WatermarkRow>;
|
|
252
|
+
export type WatermarkOrderBy = RowOrderBy<WatermarkRow>;
|
|
253
|
+
export type WatermarkUnique = {
|
|
254
|
+
readonly singleton: boolean;
|
|
255
|
+
};
|
|
256
|
+
export declare function assertQueryPageArgs(args: QueryPageArgs): void;
|
|
257
|
+
export declare function assertQueryOrderBy(orderBy: Readonly<Record<string, QueryOrder>>): void;
|
|
258
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function assertQueryPageArgs(args) {
|
|
2
|
+
assertPageValue(args.skip, "skip");
|
|
3
|
+
assertPageValue(args.take, "take");
|
|
4
|
+
}
|
|
5
|
+
export function assertQueryOrderBy(orderBy) {
|
|
6
|
+
if (Object.keys(orderBy).length !== 1) {
|
|
7
|
+
throw new Error("orderBy must specify exactly one field");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function assertPageValue(value, name) {
|
|
11
|
+
if (value !== undefined && (!Number.isInteger(value) || value < 0)) {
|
|
12
|
+
throw new Error(`${name} must be a non-negative integer`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PqsPoolLike {
|
|
2
|
+
query(text: string, values: readonly unknown[]): Promise<{
|
|
3
|
+
readonly rows: readonly Record<string, unknown>[];
|
|
4
|
+
}>;
|
|
5
|
+
end(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare class PqsPool {
|
|
8
|
+
readonly pool: PqsPoolLike;
|
|
9
|
+
private disposed;
|
|
10
|
+
constructor(pool: PqsPoolLike);
|
|
11
|
+
static create(connectionString: string): PqsPool;
|
|
12
|
+
disposeAsync(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Pool } from "pg";
|
|
2
|
+
export class PqsPool {
|
|
3
|
+
pool;
|
|
4
|
+
disposed = false;
|
|
5
|
+
constructor(pool) {
|
|
6
|
+
this.pool = pool;
|
|
7
|
+
}
|
|
8
|
+
static create(connectionString) {
|
|
9
|
+
return new PqsPool(new Pool({ connectionString }));
|
|
10
|
+
}
|
|
11
|
+
async disposeAsync() {
|
|
12
|
+
if (this.disposed) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.disposed = true;
|
|
16
|
+
await this.pool.end();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ContractCountArgs, ContractFindManyArgs, ContractFindUniqueArgs, ContractRow } from "../model-types.js";
|
|
2
|
+
import { QueryClient } from "../query-client.js";
|
|
3
|
+
import { QuerySource } from "../query-source.js";
|
|
4
|
+
import { PqsSchemaProfileV1 } from "./pqs-schema-profile.js";
|
|
5
|
+
export interface PqsQueryExecutor {
|
|
6
|
+
query(text: string, values: readonly unknown[]): Promise<{
|
|
7
|
+
readonly rows: readonly Record<string, unknown>[];
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export declare class PqsQueryClient implements QueryClient {
|
|
11
|
+
private readonly executor;
|
|
12
|
+
private readonly profile;
|
|
13
|
+
private readonly ready;
|
|
14
|
+
readonly source = QuerySource.pqs;
|
|
15
|
+
readonly contracts: {
|
|
16
|
+
findMany: (args?: ContractFindManyArgs) => Promise<readonly ContractRow[]>;
|
|
17
|
+
findUnique: (args: ContractFindUniqueArgs) => Promise<ContractRow>;
|
|
18
|
+
count: (args?: ContractCountArgs) => Promise<number>;
|
|
19
|
+
aggregate: (args: Parameters<QueryClient["contracts"]["aggregate"]>[0]) => Promise<{
|
|
20
|
+
readonly count?: number;
|
|
21
|
+
readonly min?: Readonly<Partial<Record<import("../query-client.js").ContractNumericField, string | null>>>;
|
|
22
|
+
readonly max?: Readonly<Partial<Record<import("../query-client.js").ContractNumericField, string | null>>>;
|
|
23
|
+
readonly sum?: Readonly<Partial<Record<import("../query-client.js").ContractNumericField, string | null>>>;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
readonly contractTypes: QueryClient["contractTypes"];
|
|
27
|
+
readonly events: QueryClient["events"];
|
|
28
|
+
readonly exercises: QueryClient["exercises"];
|
|
29
|
+
readonly exerciseTypes: QueryClient["exerciseTypes"];
|
|
30
|
+
readonly packages: QueryClient["packages"];
|
|
31
|
+
readonly transactions: QueryClient["transactions"];
|
|
32
|
+
readonly watermark: QueryClient["watermark"];
|
|
33
|
+
constructor(executor: PqsQueryExecutor, profile: PqsSchemaProfileV1, ready?: Promise<void>);
|
|
34
|
+
$queryRaw<TRow>(sql: string, values?: readonly unknown[]): Promise<readonly TRow[]>;
|
|
35
|
+
private createPhysicalDelegate;
|
|
36
|
+
private readPhysicalAsync;
|
|
37
|
+
private aggregatePhysicalAsync;
|
|
38
|
+
private compileWhere;
|
|
39
|
+
private selectedFields;
|
|
40
|
+
private compileOrderBy;
|
|
41
|
+
private assertUniqueWhere;
|
|
42
|
+
private assertNumericField;
|
|
43
|
+
private field;
|
|
44
|
+
private assertPage;
|
|
45
|
+
private mapPhysicalRow;
|
|
46
|
+
private findContractsAsync;
|
|
47
|
+
private aggregateContractsAsync;
|
|
48
|
+
private wrap;
|
|
49
|
+
}
|