@distrohelena/canton-typescript-sdk 0.1.36 → 0.1.38
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 +143 -34
- package/dist/cjs/core/types/requests/{submit-command-request.js → submit-commands-request.js} +10 -6
- package/dist/cjs/index.js +10 -8
- package/dist/cjs/query/canonical/in-memory-query-evaluator.js +291 -0
- package/dist/cjs/query/canonical/public-identity.js +41 -0
- package/dist/cjs/query/canonical/query-ast.js +2 -0
- package/dist/cjs/query/canonical/query-dataset.js +351 -0
- package/dist/cjs/query/canonical/query-normalizer.js +657 -0
- package/dist/cjs/query/canonical/query-schema.js +86 -0
- package/dist/cjs/query/canton-manager.js +14 -5
- package/dist/cjs/query/errors/query-snapshot-incomplete-error.js +19 -0
- package/dist/cjs/query/grpc/grpc-contract-cache.js +484 -0
- package/dist/cjs/query/grpc/grpc-package-relation-reader.js +218 -0
- package/dist/cjs/query/grpc/grpc-query-client.js +249 -0
- package/dist/cjs/query/grpc/grpc-query-snapshot-reader.js +238 -0
- package/dist/cjs/query/grpc/grpc-query-value-mapper.js +204 -0
- package/dist/cjs/query/grpc/grpc-relation-mapper.js +794 -0
- package/dist/cjs/query/pqs/pqs-query-client.js +151 -582
- package/dist/cjs/query/pqs/pqs-relational-sql-compiler.js +138 -95
- package/dist/cjs/query/pqs/pqs-result-shape.js +28 -0
- package/dist/cjs/query/pqs/pqs-schema-profile.js +49 -48
- package/dist/cjs/query/pqs/pqs-sql-compiler.js +343 -289
- package/dist/cjs/query/pqs/pqs-sql-syntax.js +10 -0
- package/dist/cjs/services/command/command-service-client.js +16 -3
- package/dist/cjs/services/commands/command-payload-builder.js +1 -1
- package/dist/cjs/services/commands/command-submission-pipeline.js +21 -6
- package/dist/cjs/testing/runtime/declarative-action-executor.js +3 -3
- package/dist/cjs/transports/grpc/grpc-transport.js +2 -2
- package/dist/cjs/transports/grpc/mappers/commands-mapper.js +6 -6
- package/dist/cjs/transports/grpc/mappers/interactive-command-mapper.js +1 -1
- package/dist/cjs/transports/json/json-transport.js +1 -1
- package/dist/cjs/transports/json/mappers/commands-mapper.js +3 -3
- package/dist/core/transports/transport.interface.d.ts +4 -4
- package/dist/core/types/prepared-command-submission.d.ts +3 -3
- package/dist/core/types/requests/{submit-command-request.d.ts → submit-commands-request.d.ts} +8 -4
- package/dist/core/types/requests/{submit-command-request.js → submit-commands-request.js} +8 -4
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -1
- package/dist/query/canonical/in-memory-query-evaluator.d.ts +22 -0
- package/dist/query/canonical/in-memory-query-evaluator.js +287 -0
- package/dist/query/canonical/public-identity.d.ts +14 -0
- package/dist/query/canonical/public-identity.js +35 -0
- package/dist/query/canonical/query-ast.d.ts +104 -0
- package/dist/query/canonical/query-ast.js +1 -0
- package/dist/query/canonical/query-dataset.d.ts +63 -0
- package/dist/query/canonical/query-dataset.js +343 -0
- package/dist/query/canonical/query-normalizer.d.ts +10 -0
- package/dist/query/canonical/query-normalizer.js +648 -0
- package/dist/query/canonical/query-schema.d.ts +25 -0
- package/dist/query/canonical/query-schema.js +83 -0
- package/dist/query/canton-manager.js +14 -5
- package/dist/query/errors/query-snapshot-incomplete-error.d.ts +14 -0
- package/dist/query/errors/query-snapshot-incomplete-error.js +15 -0
- package/dist/query/grpc/grpc-contract-cache.d.ts +27 -0
- package/dist/query/grpc/grpc-contract-cache.js +479 -0
- package/dist/query/grpc/grpc-package-relation-reader.d.ts +43 -0
- package/dist/query/grpc/grpc-package-relation-reader.js +213 -0
- package/dist/query/grpc/grpc-query-client.d.ts +42 -0
- package/dist/query/grpc/grpc-query-client.js +245 -0
- package/dist/query/grpc/grpc-query-snapshot-reader.d.ts +33 -0
- package/dist/query/grpc/grpc-query-snapshot-reader.js +233 -0
- package/dist/query/grpc/grpc-query-value-mapper.d.ts +15 -0
- package/dist/query/grpc/grpc-query-value-mapper.js +195 -0
- package/dist/query/grpc/grpc-relation-mapper.d.ts +67 -0
- package/dist/query/grpc/grpc-relation-mapper.js +789 -0
- package/dist/query/model-types.d.ts +2 -0
- package/dist/query/pqs/pqs-query-client.d.ts +10 -20
- package/dist/query/pqs/pqs-query-client.js +154 -585
- package/dist/query/pqs/pqs-relational-sql-compiler.d.ts +9 -17
- package/dist/query/pqs/pqs-relational-sql-compiler.js +136 -95
- package/dist/query/pqs/pqs-result-shape.d.ts +25 -0
- package/dist/query/pqs/pqs-result-shape.js +25 -0
- package/dist/query/pqs/pqs-schema-profile.js +49 -48
- package/dist/query/pqs/pqs-sql-compiler.d.ts +18 -3
- package/dist/query/pqs/pqs-sql-compiler.js +337 -288
- package/dist/query/pqs/pqs-sql-syntax.d.ts +2 -0
- package/dist/query/pqs/pqs-sql-syntax.js +6 -0
- package/dist/query/query-client.d.ts +16 -0
- package/dist/services/command/command-service-client.d.ts +9 -4
- package/dist/services/command/command-service-client.js +16 -3
- package/dist/services/command-submission/command-submission-service-client.d.ts +2 -2
- package/dist/services/commands/command-payload-builder.d.ts +2 -2
- package/dist/services/commands/command-payload-builder.js +1 -1
- package/dist/services/commands/command-submission-pipeline.d.ts +5 -4
- package/dist/services/commands/command-submission-pipeline.js +21 -6
- package/dist/testing/runtime/declarative-action-executor.js +3 -3
- package/dist/transports/grpc/grpc-transport.d.ts +4 -4
- package/dist/transports/grpc/grpc-transport.js +3 -3
- package/dist/transports/grpc/mappers/commands-mapper.d.ts +3 -3
- package/dist/transports/grpc/mappers/commands-mapper.js +4 -4
- package/dist/transports/grpc/mappers/interactive-command-mapper.d.ts +3 -3
- package/dist/transports/grpc/mappers/interactive-command-mapper.js +1 -1
- package/dist/transports/json/json-transport.d.ts +2 -2
- package/dist/transports/json/json-transport.js +2 -2
- package/dist/transports/json/mappers/commands-mapper.d.ts +2 -2
- package/dist/transports/json/mappers/commands-mapper.js +2 -2
- package/node/start-local-splice-0.6.12.sh +6 -0
- package/node/start-local-splice-0.6.13.sh +6 -0
- package/node/start-local-splice-0.6.14.sh +6 -0
- package/node/start-local-splice-0.7.0.sh +6 -0
- package/node/stop-local-splice-0.6.12.sh +6 -0
- package/node/stop-local-splice-0.6.13.sh +6 -0
- package/node/stop-local-splice-0.6.14.sh +6 -0
- package/node/stop-local-splice-0.7.0.sh +6 -0
- package/node/test-start-local-splice-0.6.12.sh +28 -0
- package/node/test-start-local-splice-0.6.13.sh +28 -0
- package/node/test-start-local-splice-0.6.14.sh +28 -0
- package/node/test-start-local-splice-0.7.0.sh +28 -0
- package/node/test-stop-local-splice-0.6.12.sh +28 -0
- package/node/test-stop-local-splice-0.6.13.sh +28 -0
- package/node/test-stop-local-splice-0.6.14.sh +28 -0
- package/node/test-stop-local-splice-0.7.0.sh +28 -0
- package/package.json +29 -4
- package/dist/cjs/query/grpc/grpc-contract-query-client.js +0 -178
- package/dist/query/grpc/grpc-contract-query-client.d.ts +0 -33
- package/dist/query/grpc/grpc-contract-query-client.js +0 -174
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
STOP_SCRIPT="$REPO_ROOT/node/stop-local-splice-0.6.12.sh"
|
|
6
|
+
|
|
7
|
+
[[ -x "$STOP_SCRIPT" ]]
|
|
8
|
+
|
|
9
|
+
tmpdir="$(mktemp -d)"
|
|
10
|
+
trap 'rm -rf "$tmpdir"' EXIT
|
|
11
|
+
|
|
12
|
+
stub="$tmpdir/stub-stop-local.sh"
|
|
13
|
+
cat > "$stub" <<'EOF'
|
|
14
|
+
#!/usr/bin/env bash
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
printf 'IMAGE_TAG=%s\n' "${IMAGE_TAG:-}"
|
|
17
|
+
printf 'args=%s\n' "$*"
|
|
18
|
+
EOF
|
|
19
|
+
chmod +x "$stub"
|
|
20
|
+
|
|
21
|
+
default_output="$(STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT" one two)"
|
|
22
|
+
grep -Fqx 'IMAGE_TAG=0.6.12' <<<"$default_output"
|
|
23
|
+
grep -Fqx 'args=one two' <<<"$default_output"
|
|
24
|
+
|
|
25
|
+
override_output="$(IMAGE_TAG=custom-tag STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT")"
|
|
26
|
+
grep -Fqx 'IMAGE_TAG=custom-tag' <<<"$override_output"
|
|
27
|
+
|
|
28
|
+
echo "test-stop-local-splice-0.6.12.sh: all cases passed"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
STOP_SCRIPT="$REPO_ROOT/node/stop-local-splice-0.6.13.sh"
|
|
6
|
+
|
|
7
|
+
[[ -x "$STOP_SCRIPT" ]]
|
|
8
|
+
|
|
9
|
+
tmpdir="$(mktemp -d)"
|
|
10
|
+
trap 'rm -rf "$tmpdir"' EXIT
|
|
11
|
+
|
|
12
|
+
stub="$tmpdir/stub-stop-local.sh"
|
|
13
|
+
cat > "$stub" <<'EOF'
|
|
14
|
+
#!/usr/bin/env bash
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
printf 'IMAGE_TAG=%s\n' "${IMAGE_TAG:-}"
|
|
17
|
+
printf 'args=%s\n' "$*"
|
|
18
|
+
EOF
|
|
19
|
+
chmod +x "$stub"
|
|
20
|
+
|
|
21
|
+
default_output="$(STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT" one two)"
|
|
22
|
+
grep -Fqx 'IMAGE_TAG=0.6.13' <<<"$default_output"
|
|
23
|
+
grep -Fqx 'args=one two' <<<"$default_output"
|
|
24
|
+
|
|
25
|
+
override_output="$(IMAGE_TAG=custom-tag STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT")"
|
|
26
|
+
grep -Fqx 'IMAGE_TAG=custom-tag' <<<"$override_output"
|
|
27
|
+
|
|
28
|
+
echo "test-stop-local-splice-0.6.13.sh: all cases passed"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
STOP_SCRIPT="$REPO_ROOT/node/stop-local-splice-0.6.14.sh"
|
|
6
|
+
|
|
7
|
+
[[ -x "$STOP_SCRIPT" ]]
|
|
8
|
+
|
|
9
|
+
tmpdir="$(mktemp -d)"
|
|
10
|
+
trap 'rm -rf "$tmpdir"' EXIT
|
|
11
|
+
|
|
12
|
+
stub="$tmpdir/stub-stop-local.sh"
|
|
13
|
+
cat > "$stub" <<'EOF'
|
|
14
|
+
#!/usr/bin/env bash
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
printf 'IMAGE_TAG=%s\n' "${IMAGE_TAG:-}"
|
|
17
|
+
printf 'args=%s\n' "$*"
|
|
18
|
+
EOF
|
|
19
|
+
chmod +x "$stub"
|
|
20
|
+
|
|
21
|
+
default_output="$(STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT" one two)"
|
|
22
|
+
grep -Fqx 'IMAGE_TAG=0.6.14' <<<"$default_output"
|
|
23
|
+
grep -Fqx 'args=one two' <<<"$default_output"
|
|
24
|
+
|
|
25
|
+
override_output="$(IMAGE_TAG=custom-tag STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT")"
|
|
26
|
+
grep -Fqx 'IMAGE_TAG=custom-tag' <<<"$override_output"
|
|
27
|
+
|
|
28
|
+
echo "test-stop-local-splice-0.6.14.sh: all cases passed"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
STOP_SCRIPT="$REPO_ROOT/node/stop-local-splice-0.7.0.sh"
|
|
6
|
+
|
|
7
|
+
[[ -x "$STOP_SCRIPT" ]]
|
|
8
|
+
|
|
9
|
+
tmpdir="$(mktemp -d)"
|
|
10
|
+
trap 'rm -rf "$tmpdir"' EXIT
|
|
11
|
+
|
|
12
|
+
stub="$tmpdir/stub-stop-local.sh"
|
|
13
|
+
cat > "$stub" <<'EOF'
|
|
14
|
+
#!/usr/bin/env bash
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
printf 'IMAGE_TAG=%s\n' "${IMAGE_TAG:-}"
|
|
17
|
+
printf 'args=%s\n' "$*"
|
|
18
|
+
EOF
|
|
19
|
+
chmod +x "$stub"
|
|
20
|
+
|
|
21
|
+
default_output="$(STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT" one two)"
|
|
22
|
+
grep -Fqx 'IMAGE_TAG=0.7.0' <<<"$default_output"
|
|
23
|
+
grep -Fqx 'args=one two' <<<"$default_output"
|
|
24
|
+
|
|
25
|
+
override_output="$(IMAGE_TAG=custom-tag STOP_LOCAL_SCRIPT="$stub" "$STOP_SCRIPT")"
|
|
26
|
+
grep -Fqx 'IMAGE_TAG=custom-tag' <<<"$override_output"
|
|
27
|
+
|
|
28
|
+
echo "test-stop-local-splice-0.7.0.sh: all cases passed"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distrohelena/canton-typescript-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,15 @@
|
|
|
15
15
|
"canton-localnet-start": "node/start-local.sh",
|
|
16
16
|
"canton-localnet-stop": "node/stop-local.sh",
|
|
17
17
|
"canton-localnet-participant-358-start": "node/start-local-participant-358.sh",
|
|
18
|
-
"canton-localnet-participant-358-stop": "node/stop-local-participant-358.sh"
|
|
18
|
+
"canton-localnet-participant-358-stop": "node/stop-local-participant-358.sh",
|
|
19
|
+
"canton-localnet-splice-0.7.0-start": "node/start-local-splice-0.7.0.sh",
|
|
20
|
+
"canton-localnet-splice-0.7.0-stop": "node/stop-local-splice-0.7.0.sh",
|
|
21
|
+
"canton-localnet-splice-0.6.14-start": "node/start-local-splice-0.6.14.sh",
|
|
22
|
+
"canton-localnet-splice-0.6.14-stop": "node/stop-local-splice-0.6.14.sh",
|
|
23
|
+
"canton-localnet-splice-0.6.13-start": "node/start-local-splice-0.6.13.sh",
|
|
24
|
+
"canton-localnet-splice-0.6.13-stop": "node/stop-local-splice-0.6.13.sh",
|
|
25
|
+
"canton-localnet-splice-0.6.12-start": "node/start-local-splice-0.6.12.sh",
|
|
26
|
+
"canton-localnet-splice-0.6.12-stop": "node/stop-local-splice-0.6.12.sh"
|
|
19
27
|
},
|
|
20
28
|
"keywords": [
|
|
21
29
|
"canton",
|
|
@@ -102,19 +110,36 @@
|
|
|
102
110
|
"example:workflow:contract-lifecycle-audit": "npm run build && node --loader ts-node/esm examples/95-contract-lifecycle-audit.ts",
|
|
103
111
|
"example:workflow:update-lookup-reconciliation": "npm run build && node --loader ts-node/esm examples/96-update-lookup-reconciliation.ts",
|
|
104
112
|
"example:workflow:pruning-preflight": "npm run build && node --loader ts-node/esm examples/97-pruning-preflight.ts",
|
|
113
|
+
"example:workflow:participant-local": "npm run build && node --loader ts-node/esm examples/98-participant-local-command-submission.ts",
|
|
105
114
|
"lint": "eslint . --max-warnings=0",
|
|
106
115
|
"lint:fix": "eslint . --fix --max-warnings=0",
|
|
107
116
|
"start:local-ledger": "bash node/start-local.sh",
|
|
108
117
|
"stop:local-ledger": "bash node/stop-local.sh",
|
|
109
118
|
"start:local-participant-358": "bash node/start-local-participant-358.sh",
|
|
110
119
|
"stop:local-participant-358": "bash node/stop-local-participant-358.sh",
|
|
120
|
+
"start:local-ledger-splice-0.7.0": "bash node/start-local-splice-0.7.0.sh",
|
|
121
|
+
"stop:local-ledger-splice-0.7.0": "bash node/stop-local-splice-0.7.0.sh",
|
|
122
|
+
"start:local-ledger-splice-0.6.14": "bash node/start-local-splice-0.6.14.sh",
|
|
123
|
+
"stop:local-ledger-splice-0.6.14": "bash node/stop-local-splice-0.6.14.sh",
|
|
124
|
+
"start:local-ledger-splice-0.6.13": "bash node/start-local-splice-0.6.13.sh",
|
|
125
|
+
"stop:local-ledger-splice-0.6.13": "bash node/stop-local-splice-0.6.13.sh",
|
|
126
|
+
"start:local-ledger-splice-0.6.12": "bash node/start-local-splice-0.6.12.sh",
|
|
127
|
+
"stop:local-ledger-splice-0.6.12": "bash node/stop-local-splice-0.6.12.sh",
|
|
111
128
|
"test:start-local-script": "bash node/test-start-local.sh",
|
|
112
129
|
"test:stop-local-script": "bash node/test-stop-local.sh",
|
|
113
130
|
"test:participant-358-sidecar-script": "bash node/test-participant-358-sidecar.sh",
|
|
114
131
|
"test:participant-358-sidecar-smoke": "bash node/test-participant-358-sidecar-smoke.sh",
|
|
115
|
-
"test": "
|
|
132
|
+
"test:start-local-splice-0.7.0-script": "bash node/test-start-local-splice-0.7.0.sh",
|
|
133
|
+
"test:stop-local-splice-0.7.0-script": "bash node/test-stop-local-splice-0.7.0.sh",
|
|
134
|
+
"test:start-local-splice-0.6.14-script": "bash node/test-start-local-splice-0.6.14.sh",
|
|
135
|
+
"test:stop-local-splice-0.6.14-script": "bash node/test-stop-local-splice-0.6.14.sh",
|
|
136
|
+
"test:start-local-splice-0.6.13-script": "bash node/test-start-local-splice-0.6.13.sh",
|
|
137
|
+
"test:stop-local-splice-0.6.13-script": "bash node/test-stop-local-splice-0.6.13.sh",
|
|
138
|
+
"test:start-local-splice-0.6.12-script": "bash node/test-start-local-splice-0.6.12.sh",
|
|
139
|
+
"test:stop-local-splice-0.6.12-script": "bash node/test-stop-local-splice-0.6.12.sh",
|
|
140
|
+
"test": "vitest run --exclude 'tests/live/**' --maxWorkers=1 --testTimeout=15000",
|
|
116
141
|
"test:property": "vitest run tests/property --maxWorkers=1 --testTimeout=15000",
|
|
117
|
-
"test:live": "vitest run tests/live --maxWorkers=1 --testTimeout=15000",
|
|
142
|
+
"test:live": "vitest run --dir tests/live --maxWorkers=1 --testTimeout=15000",
|
|
118
143
|
"test:live:fuzz": "vitest run tests/live/specs/live-stateful-fuzzing.test.ts --maxWorkers=1 --testTimeout=300000",
|
|
119
144
|
"test:unit": "vitest run tests/unit",
|
|
120
145
|
"verify:pack": "node ./scripts/verify-npm-pack.mjs"
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GrpcContractQueryClient = void 0;
|
|
4
|
-
const contracts_mapper_js_1 = require("../../transports/grpc/mappers/contracts-mapper.js");
|
|
5
|
-
const query_capability_error_js_1 = require("../errors/query-capability-error.js");
|
|
6
|
-
const query_source_js_1 = require("../query-source.js");
|
|
7
|
-
class GrpcContractQueryClient {
|
|
8
|
-
stateService;
|
|
9
|
-
cache;
|
|
10
|
-
cacheTtlMs;
|
|
11
|
-
cacheScope;
|
|
12
|
-
source = query_source_js_1.QuerySource.grpc;
|
|
13
|
-
contracts = {
|
|
14
|
-
findMany: (args = {}) => this.findManyAsync(args).then((rows) => rows),
|
|
15
|
-
findUnique: (args) => {
|
|
16
|
-
if (args.select !== undefined || args.include !== undefined) {
|
|
17
|
-
return Promise.reject(new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, "contracts.findUnique"));
|
|
18
|
-
}
|
|
19
|
-
return this.findManyAsync({ where: { contractId: { equals: args.where.contractId } } }).then((rows) => rows[0]);
|
|
20
|
-
},
|
|
21
|
-
count: async (args = {}) => (await this.findManyAsync(args)).length,
|
|
22
|
-
aggregate: async () => {
|
|
23
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, "contracts.aggregate");
|
|
24
|
-
},
|
|
25
|
-
groupBy: async () => {
|
|
26
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, "contracts.groupBy");
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
contractTypes = this.unsupported("contractTypes");
|
|
30
|
-
events = this.unsupported("events");
|
|
31
|
-
exercises = this.unsupported("exercises");
|
|
32
|
-
exerciseTypes = this.unsupported("exerciseTypes");
|
|
33
|
-
packages = this.unsupported("packages");
|
|
34
|
-
transactions = this.unsupported("transactions");
|
|
35
|
-
watermark = this.unsupported("watermark");
|
|
36
|
-
constructor(stateService, cache, cacheTtlMs, cacheScope) {
|
|
37
|
-
this.stateService = stateService;
|
|
38
|
-
this.cache = cache;
|
|
39
|
-
this.cacheTtlMs = cacheTtlMs;
|
|
40
|
-
this.cacheScope = cacheScope;
|
|
41
|
-
}
|
|
42
|
-
async $queryRaw(_sql, _values = []) {
|
|
43
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, "query.$queryRaw");
|
|
44
|
-
}
|
|
45
|
-
async findManyAsync(args) {
|
|
46
|
-
if (hasUnsupportedFilter(args.where) ||
|
|
47
|
-
args.where?.active === false ||
|
|
48
|
-
args.where?.packageId !== undefined ||
|
|
49
|
-
args.where?.witnesses !== undefined ||
|
|
50
|
-
args.where?.contractId?.in !== undefined ||
|
|
51
|
-
args.where?.contractId?.is !== undefined ||
|
|
52
|
-
args.where?.contractId?.isNot !== undefined ||
|
|
53
|
-
args.where?.templateId !== undefined) {
|
|
54
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, "contracts.findMany");
|
|
55
|
-
}
|
|
56
|
-
const findArgs = args;
|
|
57
|
-
if (findArgs.select !== undefined || findArgs.include !== undefined || findArgs.orderBy !== undefined || findArgs.skip !== undefined || findArgs.take !== undefined) {
|
|
58
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, "contracts.findMany");
|
|
59
|
-
}
|
|
60
|
-
const snapshot = await this.readSnapshotAsync(args.parties);
|
|
61
|
-
let rows = snapshot.filter((row) => args.where?.contractId?.equals === undefined
|
|
62
|
-
? true
|
|
63
|
-
: row.contractId === args.where.contractId.equals);
|
|
64
|
-
if (args.where?.payload !== undefined) {
|
|
65
|
-
rows = rows.filter((row) => matchesPayload(row.payload, args.where.payload));
|
|
66
|
-
}
|
|
67
|
-
return rows;
|
|
68
|
-
}
|
|
69
|
-
unsupported(operation) {
|
|
70
|
-
return {
|
|
71
|
-
findMany: async () => {
|
|
72
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, `${operation}.findMany`);
|
|
73
|
-
},
|
|
74
|
-
findUnique: async () => {
|
|
75
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, `${operation}.findUnique`);
|
|
76
|
-
},
|
|
77
|
-
count: async () => {
|
|
78
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, `${operation}.count`);
|
|
79
|
-
},
|
|
80
|
-
aggregate: async () => {
|
|
81
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, `${operation}.aggregate`);
|
|
82
|
-
},
|
|
83
|
-
groupBy: async () => {
|
|
84
|
-
throw new query_capability_error_js_1.QueryCapabilityError(query_source_js_1.QuerySource.grpc, `${operation}.groupBy`);
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async readSnapshotAsync(parties) {
|
|
89
|
-
const key = `${this.cacheScope}:${parties?.join(",") ?? "*"}`;
|
|
90
|
-
const cached = this.cache === undefined ? undefined : await this.cache.getAsync(key);
|
|
91
|
-
if (cached !== undefined) {
|
|
92
|
-
return cached;
|
|
93
|
-
}
|
|
94
|
-
const rows = [];
|
|
95
|
-
let pageToken;
|
|
96
|
-
let activeAtOffset;
|
|
97
|
-
do {
|
|
98
|
-
const response = await this.stateService.getActiveContractsPageAsync((0, contracts_mapper_js_1.mapGrpcQueryContractsRequest)(parties === undefined
|
|
99
|
-
? { allParties: true, activeAtOffset, pageToken }
|
|
100
|
-
: { parties, activeAtOffset, pageToken }));
|
|
101
|
-
activeAtOffset ??= response.activeAtOffset;
|
|
102
|
-
pageToken = response.nextPageToken;
|
|
103
|
-
rows.push(...response.activeContracts.map((response) => mapGrpcContract(response.contractEntry.oneofKind === "activeContract"
|
|
104
|
-
? response.contractEntry.activeContract
|
|
105
|
-
: response)));
|
|
106
|
-
} while (pageToken !== undefined && pageToken.length > 0);
|
|
107
|
-
if (this.cache !== undefined && this.cacheTtlMs !== undefined) {
|
|
108
|
-
await this.cache.setAsync(key, rows, this.cacheTtlMs);
|
|
109
|
-
}
|
|
110
|
-
return rows;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.GrpcContractQueryClient = GrpcContractQueryClient;
|
|
114
|
-
function hasUnsupportedFilter(where) {
|
|
115
|
-
if (where === undefined) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
else if ("and" in where || "or" in where || "not" in where || "createdEventOffset" in where || "createdAt" in where || "archivedEventOffset" in where || "archivedAt" in where) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
for (const field of ["contractId", "templateId"]) {
|
|
122
|
-
const filter = where[field];
|
|
123
|
-
if (filter !== undefined && Object.keys(filter).some((key) => key !== "equals")) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
function mapGrpcContract(value) {
|
|
130
|
-
const row = value;
|
|
131
|
-
const template = row.templateId;
|
|
132
|
-
return {
|
|
133
|
-
contractId: row.contractId ?? "",
|
|
134
|
-
templateId: { packageId: template?.packageId ?? "", moduleName: template?.moduleName ?? "", entityName: template?.entityName ?? "" },
|
|
135
|
-
packageId: null,
|
|
136
|
-
payload: row.payload,
|
|
137
|
-
witnesses: [],
|
|
138
|
-
createdEventOffset: "",
|
|
139
|
-
createdAt: null,
|
|
140
|
-
archivedEventOffset: null,
|
|
141
|
-
archivedAt: null,
|
|
142
|
-
active: true,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function matchesPayload(value, filter) {
|
|
146
|
-
const match = filter.match;
|
|
147
|
-
if (match === undefined) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
const visit = (current, node) => Object.entries(node).every(([key, child]) => {
|
|
151
|
-
const next = current !== null && typeof current === "object" ? current[key] : undefined;
|
|
152
|
-
const predicate = child;
|
|
153
|
-
if (Object.keys(predicate).some((name) => ["equals", "lt", "lte", "gt", "gte", "like", "ilike"].includes(name))) {
|
|
154
|
-
return compare(String(next ?? ""), predicate);
|
|
155
|
-
}
|
|
156
|
-
return visit(next, predicate);
|
|
157
|
-
});
|
|
158
|
-
return visit(value, match);
|
|
159
|
-
}
|
|
160
|
-
function compare(value, filter) {
|
|
161
|
-
if (filter.equals !== undefined) {
|
|
162
|
-
return value === filter.equals;
|
|
163
|
-
}
|
|
164
|
-
else if (filter.like !== undefined || filter.ilike !== undefined) {
|
|
165
|
-
const pattern = String(filter.like ?? filter.ilike).replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replaceAll("%", ".*").replaceAll("_", ".");
|
|
166
|
-
return new RegExp(`^${pattern}$`, filter.ilike === undefined ? "" : "i").test(value);
|
|
167
|
-
}
|
|
168
|
-
else if (filter.lt !== undefined) {
|
|
169
|
-
return value < String(filter.lt);
|
|
170
|
-
}
|
|
171
|
-
else if (filter.lte !== undefined) {
|
|
172
|
-
return value <= String(filter.lte);
|
|
173
|
-
}
|
|
174
|
-
else if (filter.gt !== undefined) {
|
|
175
|
-
return value > String(filter.gt);
|
|
176
|
-
}
|
|
177
|
-
return value >= String(filter.gte);
|
|
178
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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, JsonProjectionResult } 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: <TArgs extends ContractFindManyArgs>(args?: TArgs) => Promise<readonly (ContractRow & import("../model-types.js").ContractRelationRow & JsonProjectionResult<TArgs>)[]>;
|
|
15
|
-
findUnique: <TArgs extends ContractFindUniqueArgs>(args: TArgs) => Promise<(ContractRow & import("../model-types.js").ContractRelationRow & JsonProjectionResult<TArgs>) | undefined>;
|
|
16
|
-
count: (args?: ContractCountArgs) => Promise<number>;
|
|
17
|
-
aggregate: () => Promise<never>;
|
|
18
|
-
groupBy: () => Promise<never>;
|
|
19
|
-
};
|
|
20
|
-
readonly contractTypes: QueryClient["contractTypes"];
|
|
21
|
-
readonly events: QueryClient["events"];
|
|
22
|
-
readonly exercises: QueryClient["exercises"];
|
|
23
|
-
readonly exerciseTypes: QueryClient["exerciseTypes"];
|
|
24
|
-
readonly packages: QueryClient["packages"];
|
|
25
|
-
readonly transactions: QueryClient["transactions"];
|
|
26
|
-
readonly watermark: QueryClient["watermark"];
|
|
27
|
-
constructor(stateService: ActiveContractsReader, cache: QueryCacheStore | undefined, cacheTtlMs: number | undefined, cacheScope: string);
|
|
28
|
-
$queryRaw<TRow>(_sql: string, _values?: readonly unknown[]): Promise<readonly TRow[]>;
|
|
29
|
-
private findManyAsync;
|
|
30
|
-
private unsupported;
|
|
31
|
-
private readSnapshotAsync;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { mapGrpcQueryContractsRequest } from "../../transports/grpc/mappers/contracts-mapper.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).then((rows) => rows),
|
|
12
|
-
findUnique: (args) => {
|
|
13
|
-
if (args.select !== undefined || args.include !== 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
|
-
groupBy: async () => {
|
|
23
|
-
throw new QueryCapabilityError(QuerySource.grpc, "contracts.groupBy");
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
contractTypes = this.unsupported("contractTypes");
|
|
27
|
-
events = this.unsupported("events");
|
|
28
|
-
exercises = this.unsupported("exercises");
|
|
29
|
-
exerciseTypes = this.unsupported("exerciseTypes");
|
|
30
|
-
packages = this.unsupported("packages");
|
|
31
|
-
transactions = this.unsupported("transactions");
|
|
32
|
-
watermark = this.unsupported("watermark");
|
|
33
|
-
constructor(stateService, cache, cacheTtlMs, cacheScope) {
|
|
34
|
-
this.stateService = stateService;
|
|
35
|
-
this.cache = cache;
|
|
36
|
-
this.cacheTtlMs = cacheTtlMs;
|
|
37
|
-
this.cacheScope = cacheScope;
|
|
38
|
-
}
|
|
39
|
-
async $queryRaw(_sql, _values = []) {
|
|
40
|
-
throw new QueryCapabilityError(QuerySource.grpc, "query.$queryRaw");
|
|
41
|
-
}
|
|
42
|
-
async findManyAsync(args) {
|
|
43
|
-
if (hasUnsupportedFilter(args.where) ||
|
|
44
|
-
args.where?.active === false ||
|
|
45
|
-
args.where?.packageId !== undefined ||
|
|
46
|
-
args.where?.witnesses !== undefined ||
|
|
47
|
-
args.where?.contractId?.in !== undefined ||
|
|
48
|
-
args.where?.contractId?.is !== undefined ||
|
|
49
|
-
args.where?.contractId?.isNot !== undefined ||
|
|
50
|
-
args.where?.templateId !== undefined) {
|
|
51
|
-
throw new QueryCapabilityError(QuerySource.grpc, "contracts.findMany");
|
|
52
|
-
}
|
|
53
|
-
const findArgs = args;
|
|
54
|
-
if (findArgs.select !== undefined || findArgs.include !== undefined || findArgs.orderBy !== undefined || findArgs.skip !== undefined || findArgs.take !== undefined) {
|
|
55
|
-
throw new QueryCapabilityError(QuerySource.grpc, "contracts.findMany");
|
|
56
|
-
}
|
|
57
|
-
const snapshot = await this.readSnapshotAsync(args.parties);
|
|
58
|
-
let rows = snapshot.filter((row) => args.where?.contractId?.equals === undefined
|
|
59
|
-
? true
|
|
60
|
-
: row.contractId === args.where.contractId.equals);
|
|
61
|
-
if (args.where?.payload !== undefined) {
|
|
62
|
-
rows = rows.filter((row) => matchesPayload(row.payload, args.where.payload));
|
|
63
|
-
}
|
|
64
|
-
return rows;
|
|
65
|
-
}
|
|
66
|
-
unsupported(operation) {
|
|
67
|
-
return {
|
|
68
|
-
findMany: async () => {
|
|
69
|
-
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.findMany`);
|
|
70
|
-
},
|
|
71
|
-
findUnique: async () => {
|
|
72
|
-
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.findUnique`);
|
|
73
|
-
},
|
|
74
|
-
count: async () => {
|
|
75
|
-
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.count`);
|
|
76
|
-
},
|
|
77
|
-
aggregate: async () => {
|
|
78
|
-
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.aggregate`);
|
|
79
|
-
},
|
|
80
|
-
groupBy: async () => {
|
|
81
|
-
throw new QueryCapabilityError(QuerySource.grpc, `${operation}.groupBy`);
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
async readSnapshotAsync(parties) {
|
|
86
|
-
const key = `${this.cacheScope}:${parties?.join(",") ?? "*"}`;
|
|
87
|
-
const cached = this.cache === undefined ? undefined : await this.cache.getAsync(key);
|
|
88
|
-
if (cached !== undefined) {
|
|
89
|
-
return cached;
|
|
90
|
-
}
|
|
91
|
-
const rows = [];
|
|
92
|
-
let pageToken;
|
|
93
|
-
let activeAtOffset;
|
|
94
|
-
do {
|
|
95
|
-
const response = await this.stateService.getActiveContractsPageAsync(mapGrpcQueryContractsRequest(parties === undefined
|
|
96
|
-
? { allParties: true, activeAtOffset, pageToken }
|
|
97
|
-
: { parties, activeAtOffset, pageToken }));
|
|
98
|
-
activeAtOffset ??= response.activeAtOffset;
|
|
99
|
-
pageToken = response.nextPageToken;
|
|
100
|
-
rows.push(...response.activeContracts.map((response) => mapGrpcContract(response.contractEntry.oneofKind === "activeContract"
|
|
101
|
-
? response.contractEntry.activeContract
|
|
102
|
-
: response)));
|
|
103
|
-
} while (pageToken !== undefined && pageToken.length > 0);
|
|
104
|
-
if (this.cache !== undefined && this.cacheTtlMs !== undefined) {
|
|
105
|
-
await this.cache.setAsync(key, rows, this.cacheTtlMs);
|
|
106
|
-
}
|
|
107
|
-
return rows;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function hasUnsupportedFilter(where) {
|
|
111
|
-
if (where === undefined) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
else if ("and" in where || "or" in where || "not" in where || "createdEventOffset" in where || "createdAt" in where || "archivedEventOffset" in where || "archivedAt" in where) {
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
for (const field of ["contractId", "templateId"]) {
|
|
118
|
-
const filter = where[field];
|
|
119
|
-
if (filter !== undefined && Object.keys(filter).some((key) => key !== "equals")) {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
function mapGrpcContract(value) {
|
|
126
|
-
const row = value;
|
|
127
|
-
const template = row.templateId;
|
|
128
|
-
return {
|
|
129
|
-
contractId: row.contractId ?? "",
|
|
130
|
-
templateId: { packageId: template?.packageId ?? "", moduleName: template?.moduleName ?? "", entityName: template?.entityName ?? "" },
|
|
131
|
-
packageId: null,
|
|
132
|
-
payload: row.payload,
|
|
133
|
-
witnesses: [],
|
|
134
|
-
createdEventOffset: "",
|
|
135
|
-
createdAt: null,
|
|
136
|
-
archivedEventOffset: null,
|
|
137
|
-
archivedAt: null,
|
|
138
|
-
active: true,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function matchesPayload(value, filter) {
|
|
142
|
-
const match = filter.match;
|
|
143
|
-
if (match === undefined) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
const visit = (current, node) => Object.entries(node).every(([key, child]) => {
|
|
147
|
-
const next = current !== null && typeof current === "object" ? current[key] : undefined;
|
|
148
|
-
const predicate = child;
|
|
149
|
-
if (Object.keys(predicate).some((name) => ["equals", "lt", "lte", "gt", "gte", "like", "ilike"].includes(name))) {
|
|
150
|
-
return compare(String(next ?? ""), predicate);
|
|
151
|
-
}
|
|
152
|
-
return visit(next, predicate);
|
|
153
|
-
});
|
|
154
|
-
return visit(value, match);
|
|
155
|
-
}
|
|
156
|
-
function compare(value, filter) {
|
|
157
|
-
if (filter.equals !== undefined) {
|
|
158
|
-
return value === filter.equals;
|
|
159
|
-
}
|
|
160
|
-
else if (filter.like !== undefined || filter.ilike !== undefined) {
|
|
161
|
-
const pattern = String(filter.like ?? filter.ilike).replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replaceAll("%", ".*").replaceAll("_", ".");
|
|
162
|
-
return new RegExp(`^${pattern}$`, filter.ilike === undefined ? "" : "i").test(value);
|
|
163
|
-
}
|
|
164
|
-
else if (filter.lt !== undefined) {
|
|
165
|
-
return value < String(filter.lt);
|
|
166
|
-
}
|
|
167
|
-
else if (filter.lte !== undefined) {
|
|
168
|
-
return value <= String(filter.lte);
|
|
169
|
-
}
|
|
170
|
-
else if (filter.gt !== undefined) {
|
|
171
|
-
return value > String(filter.gt);
|
|
172
|
-
}
|
|
173
|
-
return value >= String(filter.gte);
|
|
174
|
-
}
|