Commit Graph

325 Commits

Author SHA1 Message Date
Robin Krom
81b8897fc8
added a package.json to work with yarn workspaces (#4147)
* added a package.json to work with yarn workspaces

This adds a package.json files on top of our typescript libraries so
that we can develop locally via yarn workspaces. The package.json that
describes the bazel managed dependencies is moved into a subfolder.

CHANGELOG_BEGIN
CHANGELOG_END

* updated bazelignore

* SDK_VERSION -> SDKVERSION
2020-01-21 22:23:51 +01:00
Robin Krom
ad9325275a
language: put sdk versions into package.json (#4122)
* language: put sdk versions into package.json

The typescript library versions of our support libraries are now given
by the sdk version.

CHANGELOG_BEGIN
CHANGELOG_END

* removed local field

* better placeholders

* consistent SDK_VERSION

* sed sdkversion in test script
2020-01-21 15:41:40 +01:00
Martin Huschenbett
3d2131fdbd
Remove pseudo* functions from daml-ledger-fetch (#4130)
Since the JSON API supports `fetchByKey` and `exerciseByKey` now, we don't
need the `pseudo*` versions of these functions anymore.

CHANGELOG_BEGIN
CHANGELOG_END
2020-01-21 15:25:40 +01:00
Andreas Herrmann
e005d4c03b Define and use eslint_test Bazel macro (#4124)
* Define eslint test case

* Define eslint_test macro

* Eslint test for daml-ledger-fetch

* Fix lint issues

* Deduplicate eslint on language-support/ts

* Use eslint --parser-options to define tsconfigRootDiro

Allows to avoid hard-coding the Bazel package path into the package.json
file. Instead derives the package root from the location of the
tsconfig.json file.

* document eslint

* pass kwargs to _eslint_test

* Add copyright header

CHANGELOG_BEGIN
CHANGELOG_END

* Exclude daml-json-types tests from lint

Otherwise eslint complains about mismatching config in `tsconfig.json`.
The test files are excluded from the project in `tsconfig.json`.

* Fix linter warning in daml-json-types

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-21 13:39:54 +00:00
Robin Krom
7494019302
language: added licenses for ts libraries (#4117)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-21 13:29:20 +01:00
Martin Huschenbett
b0ade660b8 daml2ts: Fix validation of nested optionals (#4128)
Currently, the validator for `Optional (Optional _)` would allow the value
`[null]`, which is not the JSON encoding for any value of this type.

This PR fixes the issue. Since it detects companion objects for the
`Optional` by means of their JavaScript class, we can also drop the
`isOptional` property from the `Serializable` interface.

CHANGELOG_BEGIN
CHANGELOG_END
2020-01-20 23:29:08 +00:00
Martin Huschenbett
92a3628cf2
daml2ts: Add tests for daml-json-types (#4120)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-20 22:24:09 +01:00
Robin Krom
704d576ecd Bazelify daml json types (#4110)
* language: bazel rules for daml-json-types/daml-ledger-fetch

This moves the daml-json-types/daml-ledger-fetch libraries out of the
tests directory and builds them with bazel. We'll rename these libraries
in a follow up PR.

CHANGELOG_BEGIN
CHANGELOG_END

* Update deps.bzl

Co-Authored-By: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>

* updated package.json

* rename nodejs patch

* update yarn.lock

* update @bazel/bazel dependency

* wrong typescript version in toplevel package.json

Co-authored-by: Andreas Herrmann <42969706+aherrmann-da@users.noreply.github.com>
2020-01-20 15:02:33 +00:00
Martin Huschenbett
092973e48d
daml2ts: Isolate tests better (#4111)
* daml2ts: Isolate tests better

Currently, the `sh_test` for `daml2ts` copies too many files into the
temporary directory where the test is run. This can cause issues with
stale files from development experiments being copied into the test.

This PR addresses the issue by exluding some directories which only
contain generated files.

CHANGELOG_BEGIN
CHANGELOG_END

* Exclude `node_modules` from buildifier check

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-20 14:48:21 +01:00
Shayne Fletcher
9478a5f60a Support nested optionals (#4106)
* First cut at generalized type

changelog_begin
changelog_end

* Update code gen and test

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-20 10:25:10 +01:00
Leonid Shlyapnikov
c8c55c4408
Exercise by key (#4049)
* Implement exercise by key

ExerciseCommand got a new required element: `reference` of polymorphic type.

* Add test case: exercise Archive by contractKey

* Add test case for ExerciseCommand JSON protocol

* flatten contract reference in ExerciseCommand JSON protocol

* formatting

* Update exercise by key

* Update documentation

CHANGELOG_BEGIN

- [JSON API - Experimental] Support Exercise by Key. See #4009.

CHANGELOG_END

* Address code review comments
2020-01-18 09:06:52 -05:00
Stephen Compall
0520fdfa84
in query argument, rename %templates to templateIds, and nest query under 'query' field (#4082)
* in query argument, rename %templates to templateIds, and nest query under 'query' field

CHANGELOG_BEGIN
- [JSON API - Experimental] In 'search' endpoint arguments, %templates is now templateIds.
  Additionally, all contract query fields must occur under 'query'.
  See `issue #3450 <https://github.com/digital-asset/daml/issues/3450>`__.
CHANGELOG_END

* fix other old query format usages
2020-01-17 14:34:27 -05:00
Shayne Fletcher
6e79687be9
Add 'isOptional' to 'Serializable<>' (#4079)
changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-17 07:25:00 -05:00
Shayne Fletcher
09dd123c64
Basic numeric type support : first cut (#4059)
* Basic numeric type support : first cut

changelog_begin
changelog_end

* Post-review fixups

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-16 12:53:31 -05:00
Shayne Fletcher
1542e4c29b daml2ts : sum-of-product rewrite (#4047)
* Wip

* Checkpoint

* It works!

* Refactor

changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
2020-01-14 21:37:21 +00:00
Samir Talwar
5aa33cf7e9 bindings-rxjava: Attempt to fix the flakiness in BotTest. (#3931)
* bindings-rxjava: Fix warnings and tidy up code in BotTest.

* bindings-rxjava: Complete BotTest.TestFlowable properly.

This avoids a stack trace in the logs.

* bindings-rxjava: Use `should have size` in BotTest.

Better error messages when it fails.

* bindings-rxjava: Use `Eventually` to wait, rather than `Thread.sleep`.

This should hopefully fix the flakiness in this test.
2020-01-13 08:46:31 +00:00
Shayne Fletcher
c261fcda62 Test parameteric sum of product (#4018)
```
CHANGELOG_BEGIN
CHANGELOG_END
```
2020-01-10 21:54:32 +00:00
nickchapman-da
006aa9b608
Type checking DAML-LF type synonyms (#3959)
* CHANGELOG_BEGIN
Type-check type synonyms.
CHANGELOG_END

* placate HLint

* comments

* Add an example that requires the check in kindOf

* check types containing syn-apps are well formed even when there is no expression of that type

* show type mismatch error after synonyms are expanded

* typeOf calls expandTypeSynonyms; track vars bound by TForall during expansion

* test interaction of syn-expansion and free-vars; add one bigger testcase

* extend bigger example with pointed typeclass, having functor as a super class

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-01-10 17:51:51 +00:00
Martin Huschenbett
719d1b4b42 daml2ts: Add support for exerciseByKey (#4010)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-10 15:13:29 +00:00
Martin Huschenbett
f7d8f101df
daml2ts: Make the integration tests tighter (#4007)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-10 15:39:27 +01:00
Martin Huschenbett
d2fd744b1f daml2ts: Test that templates in non-top-level modules work (#4006)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-10 10:43:30 +00:00
Leonid Shlyapnikov
93216a0d71
Template ID to JsString JSON serialization (#3991)
* test cases: domain.TemplateId JSON serialization to JsString

* JSON protocol updated

* Fixing json-api test cases

* test cases: domain.TemplateId JSON serialization to JsString

* JSON protocol updated

* Fixing json-api test cases

* Adapt daml2ts and support libraries

* Update documentation

CHANGELOG_BEGIN

[JSON API - Experimental]
- Use JSON string to encode template IDs. Use colon (``:``) to separate parts of the ID.
  The request format, with optional package ID:
  - "<module>:<entity>"
  - "<package ID>:<module>:<entity>"
  The response always contains fully qualified template ID in the format:
  - "<package ID>:<module>:<entity>"
  See #3647.

CHANGELOG_END

* Minor documentation formatting changes.

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2020-01-09 14:43:41 -05:00
Moritz Kiefer
c5b11aa229 Fix DAML module filename in java codegen tests (#4003)
A mismatch between the module and the filename is already a warning
and will become an error in the future.

changelog_begin
changelog_end
2020-01-09 16:52:11 +00:00
Shayne Fletcher
e0685a327b Implement sums of products (#3992)
```
CHANGELOG_BEGIN
CHANGELOG_END
```
2020-01-09 12:59:32 +00:00
Martin Huschenbett
1d07d82962 daml2ts: Lift type annotation for variant decoders to jtv.oneOf (#3994)
Currently, the generated decoder for, say, `Either` looks like
```ts
() => jtv.oneOf(
  jtv.object<Either<a, b>>(...),
  jtv.object<Either<a, b>>(...),
)
```
After this PR, the generated code will look like
```ts
() => jtv.oneOf<Either<a, b>>(
  jtv.object(...),
  jtv.object(...),
)
```
That saves us a few type annotations but nothing major.

CHANGELOG_BEGIN
CHANGELOG_END
2020-01-09 12:22:45 +00:00
Martin Huschenbett
20ad5263d4 daml2ts: Support lookupByKey (#3987)
* daml2ts: Support lookupByKey

We'll add `fetchByKey` and `exerciseByKey` in a separate PR. We'll remove
the `pseudo*` methods in another PR after that one.

CHANGELOG_BEGIN
CHANGELOG_END

* daml2ts: make `lookupByKey` inaccessible for templates without key
2020-01-09 10:51:44 +00:00
Leonid Shlyapnikov
e75b98351c Aligning DB contract table with domain.ActiveContract class (#3989)
* Aligning DB contract table with domain.ActiveContract class

adding key,signatories, observers and agreement_text to DB contract table
removing witnessParties

Reading signatories and observers from contracts table

Updating doc, removing witnessParties

Address code review comments, thanks @S11001001

CHANGELOG_BEGIN

[JSON API - Experimental]
- Align ``contract`` table with ``domain.ActiveContract`` class.
  The database schema has changed, if using ``--query-store-jdbc-config``,
  you must rebuild the database by adding ``,createSchema=true``. See #3754.
- ``witnessParties`` field is removed from all JSON responses.

CHANGELOG_END

* Fix TypeScript domain models

remove witnessParties and workflowId fields. workflowId has be removed
from JSON output a while ago.
2020-01-08 20:39:57 +00:00
Shayne Fletcher
7ed91c1f6d
Daml2ts variant support (#3988)
* Sketch out code generation required for variants

* More testing

* Checkpoint

* Checkpoint.

* Add serialization for variants.

```
CHANGELOG_BEGIN
CHANGELOG_END
```
2020-01-08 13:11:18 -05:00
Martin Huschenbett
1f817ecbe8 daml2ts: Use master version of damlc in watch-damlc.sh (#3979)
So far, we've used the version of damlc installed with the SDK on the
devs machine. This lead to hard to debug version mismatches. This PR
changes `watch-damlc.sh` to use `bazel run //:damlc` instead.

CHANGELOG_BEGIN
CHANGELOG_END
2020-01-08 13:08:24 +00:00
Leonid Shlyapnikov
2c154f2299 Rename argument to payload in domain.ActiveContract (#3971)
CHANGELOG_BEGIN

[JSON API - Experimental] Rename ``argument`` in active contract to ``payload``. See #3826.

CHANGELOG_END
2020-01-08 13:59:27 +01:00
Shayne Fletcher
9c30a7096b Revert "Better handling of recursive return types (#3968)" (#3972)
This reverts commit 17a5abf25a.
```
CHANGELOG_BEGIN
CHANGELOG_END
```
2020-01-08 11:48:48 +01:00
Shayne Fletcher
17a5abf25a
Better handling of recursive return types (#3968)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-07 13:58:51 -05:00
Moritz Kiefer
a8b4a84b08
Move most of the remaining serializable types to stable LF packages (#3964)
* Move most of the remaining serializable types to stable LF packages

The only serializable types left in DAML stdlib after this PR are the
following:

- DA.Upgrade:MetaEquiv
- DA.Random:Minstd
- DA.Next.Set:Set
- DA.Next.Map:Map
- DA.Generics:MetaSel0
- DA.Generics:MetaData0
- DA.Generics:DecidedStrictness
- DA.Generics:SourceStrictness
- DA.Generics:SourceUnpackedness
- DA.Generics:Associativity
- DA.Generics:Infix0
- DA.Generics:Fixity
- DA.Generics:K1
- DA.Generics:Par1
- DA.Generics:U1
- DA.Internal.Prelude:Optional

Ignoring the Generics stuff which isn’t very urgent imho and the
Upgrade stuff which is probably going to change significantly anyway,
this leaves us with the weird Random module, the wrappers around
TextMap which will go away anyway and DA.Internal.Prelude:Optional
which shouldn’t exist in the first place (I’ll address that in a
separate PR).

CHANGELOG_BEGIN

- [DAML Compiler] Move more types from daml-stdlib to standalone LF
packages. The module names for the types have also changed
slightly. This only matters over the Ledger API when you specify the
module name explicitly. In DAML you should continue to use the
existing module names.

  - The types from ``DA.Semigroup` are now in a separate package under
  ``DA.Semigroup.Types``
  - The types from ``DA.Monoid` are now in a separate package under
  ``DA.Monoid.Types``
  - The types from ``DA.Time` are now in a separate package under
  ``DA.Time.Types``
  - The types from ``DA.Validation` are now in a separate package
  under ``DA.Validation.Types``
  - The types from ``DA.Logic` are now in a separate package under
  ``DA.Logic.Types``
  - The types from `DA.Date` are now in a separate package under
  `DA.Date.Types`.
  - The `Down` type from `DA.Internal.Prelude` is now in a separate
  package under `DA.Internal.Down`.

CHANGELOG_end

* Fix serializability of RelTime

* fix daml-docs

* Fix tests
2020-01-07 18:25:23 +01:00
Martin Huschenbett
8cb70df0fa
daml2ts: Enforce that template types are records at the type level (#3960)
The DAML-LF spec says that templates types must be records. Let's enforce
this property in the generated TypeScript on the type level as well.
2020-01-07 14:32:49 +01:00
Martin Huschenbett
f09433e8da daml2ts: Slightly prettify output (#3957) 2020-01-07 10:22:32 +00:00
Andreas Herrmann
f33e79c787
Remove unused dependencies to da_scala_library (#3938)
* Inline all scala_library dependencies

* Run //:buildifier-fix

* TMP scala_library_suite --> scala_library

* da_scala_library: Enable unused dependency checker

* scala_library: Enable unused dependency checker

* //daml-lf/data:data

* //daml-lf/engine:engine

* //ledger-api/rs-grpc-akka:rs-grpc-akka

* //ledger/participant-state:participant-state

* //ledger/ledger-api-client:ledger-api-client

* //scala-protoc-plugins/scala-logging:scala-logging-lib

* //ledger/ledger-api-scala-logging:ledger-api-scala-logging

* //ledger/ledger-api-common:ledger-api-common

* //ledger-service/utils:utils

* //ledger-service/jwt:jwt

* //ledger/ledger-api-auth:ledger-api-auth

* //extractor:extractor

* //daml-assistant/scala-daml-project-config:scala-daml-project-config

* //language-support/codegen-common:codegen-common

* //language-support/scala/codegen:codegen

* //language-support/codegen-main:codegen-main-lib

* //ledger-service/db-backend:db-backend

* //ledger-service/http-json:http-json

* //daml-lf/scenario-interpreter:scenario-interpreter

* //ledger/sandbox:sandbox

* //navigator/backend:navigator-library

* //daml-assistant/daml-sdk:sdk-lib

* //daml-lf/data-scalacheck:data-scalacheck

* //daml-script/test:test-lib

* //ledger/ledger-api-common:ledger-api-common-scala-tests-lib

* //ledger/test-common:test-common

* //ledger/sandbox:sandbox-scala-tests-lib

* //extractor:extractor-scala-tests-lib

* //language-support/java/bindings:bindings-java-tests-lib

* //language-support/java/bindings-rxjava:bindings-java-tests-lib

* //language-support/scala/bindings-akka-testing:bindings-akka-testing

* //language-support/scala/codegen-testing:codegen-testing

* //language-support/scala/codegen-sample-app:daml-lf-codegen-sample-app

* //language-support/scala/codegen-sample-app:daml-lf-codegen-sample-app-testing

* //language-support/scala/codegen-testing:codegen-testing-testing

* //ledger-api/sample-service:sample-service

* //ledger-api/rs-grpc-akka:rs-grpc-akka-tests-lib

* //ledger/ledger-api-test-tool:ledger-api-test-tool-lib

* //ledger/ledger-api-test-tool:ledger-api-test-tool-tests

* //ledger/participant-state/kvutils:kvutils

* //ledger/sandbox:ledger-api-server

* //ledger/sandbox-perf:sandbox-perf-lib

* //navigator/backend:navigator-tests-library

* UNDO scala_library_suite --> scala_library

This reverts commit ab3eb1ae23139e2ec431ab4551fbb0371e0354e1.

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-06 18:14:21 +01:00
Andreas Herrmann
43bbfeaee6
Remove unused dependencies to da_scala_binary (#3937)
* Inline all scala_binary dependencies

* Run //:buildifier-fix

* da_scala_binary: Enable unused dependency checker

* //compiler/scenario-service/server:scenario-service-raw

* //language-support/scala/codegen:codegen-main

* //daml-lf/encoder:encoder_binary

* //daml-lf/repl:repl

* //language-support/codegen-main:codegen-main

* //language-support/scala/examples:quickstart-scala-bin

* //ledger-api/rs-grpc-akka:rs-grpc-akka-perf

* //ledger-service/jwt:jwt-bin

* //ledger/api-server-damlonx/reference-v2:reference-v2

* //ledger/api-server-damlonx/reference-v2:ephemeral-postgres-reference-server

* //ledger/ledger-api-auth:ledger-api-auth-bin

* //ledger/ledger-api-test-tool:ledger-api-test-tool

* //ledger/participant-state/kvutils/tools:integrity-check

* //navigator/integration-test:navigatortest-jar

* Run //:buildifier-fix

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-06 13:58:56 +01:00
Moritz Kiefer
42c586f8d4
Bump ghcide (#3943)
* Bump ghcide

* Fix ghcide build

* Include bugfix for Windows
2020-01-04 07:51:51 +01:00
Gary Verhaegen
878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
Andreas Herrmann
9fbb787062 Remove unused dependencies to da_scala_test(_suite) (#3925)
* Remove unused scala.bzl imports

* override_targets org.scalatest.scalatest_2.12

Otherwise, rules_scala implicitly adds a different version to scala_test
than other packages transitively depending on scalatest. This causes
unused dependency checker to raise an error.

* Handle rules_scala scalatest in pom_file.bzl

* Inline all scala_test dependencies

So that `unused_dependency_checker = "error"` can be applied to them.

* Run //:buildifier-fix

* TMP scala_test_suite --> scala_test

* da_scala_test: Enable unused dependency checker

* //navigator/backend:navigator-scala-tests

* //ledger/sandbox:sandbox-scala-tests

* //ledger/participant-state/kvutils:kvutils-tests

* //ledger/participant-state:participant-state-tests

* //ledger/ledger-api-scala-logging:ledger-api-scala-logging-test

* //ledger/ledger-api-common:ledger-api-common-scala-tests

* //ledger/ledger-api-client:ledger-api-client-tests

* //ledger/ledger-api-auth:ledger-api-auth-scala-tests

* //ledger-service/lf-value-json:tests

* //ledger-service/jwt:tests

* //ledger-service/http-json:tests

* //ledger-api/rs-grpc-akka:rs-grpc-akka-tests

* //language-support/scala/codegen-sample-app:tests

* //language-support/scala/codegen-sample-app:ScalaCodeGenIT

* //language-support/scala/codegen:tests

* //language-support/scala/bindings-akka:tests

* //language-support/java/codegen:test

* //language-support/java/codegen:ledger-tests

* //language-support/java/bindings-rxjava:bindings-java-tests

* //language-support/codegen-common:test

* //extractor:extractor-scala-tests

* //daml-lf/scenario-interpreter:scenario-interpreter_tests

* //daml-lf/language:language-test

* //daml-lf/interface:tests

* //daml-lf/engine:tests

* //daml-lf/encoder:tests

* //daml-lf/archive:daml_lf_archive_reader_tests

* //daml-assistant/scala-daml-project-config:scala-daml-project-config-tests

* UNDO scala_test_suite --> scala_test

This reverts commit 13ed47ba725e944533ca1157a070cb8dc30569ac.

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2019-12-30 13:49:59 +00:00
Rohan Jacob-Rao
6c480cf9ae
Fix typos in daml2ts readme (#3927) 2019-12-27 11:10:32 -05:00
Leonid Shlyapnikov
f22d52a2ff Change variant JSON encoding, so it is easier to pattern match on it in TypeScript (#3882)
* Change variant json encoding,

adding integration test

* Add DamlLfTypeLookup dependencies

* Add MetadataReader

* Add test WIP

* Add serialize test cases

* Add serialize test cases, WIP

* Test for variant encoding decoding

* Solving merge conflicts

* Updating roundtrip test

* Minor cleanup

* Addressing code review comments

Add JsonVariant custom matcher

* Update specification

* Update link

* Add test case, WIP

* Add proper template key resolution

* Got rid of choice record ID resolution, resolving choice type and key type

* Fixing logging

* Add Contract Key decoding tests

* cleanup

* cleanup

* Update JSON variant encoding tests

* Add more contract key JSON decoding tests

* Fix variant JSON encoding

* Change value predicate to support new variant encoding

* Change value predicate to support new variant encoding

* Add lookup by contract key test case

where contract key contains variant and record

Add `requiredResource` to bazel utils

CHANGELOG_BEGIN

- [JSON API - Experimental] Change variant JSON encoding. The new format is ``{ tag: data-constructor, value: argument }``.
  For example, if we have: ``data Foo = Bar Int | Baz``, these are all valid JSON encodings for values of type Foo:
  - ``{"tag": "Bar", "value": 42}``
  - ``{"tag": "Baz", "value": {}}``
  See #3622

- [JSON API - Experimental] Fix ``/contracts/lookup` find by contract key.

- [JSON API - Experimental] Fix ``/command/exercise`` to support any LF type as a choice argument.
  See #3390

CHANGELOG_END

* minor cleanup

* Fix copy/paste

* Renaming

* Got rid of DAML LF identifier resolution

resolving DAML LF Type based on command type

* Address code review comments, thanks @S11001001

* Address code review comments, thanks @S11001001

Do not include any error handling here; this partial function should
only match the successful case, JsonVariant.

* Address code review comments, thanks @S11001001

comment

* Address code review comments, thanks @S11001001

using `JsonVariant` for variant encoding/decoding

* Address code review comments, thanks @S11001001

replace `find` and `map` chain with collectFirst

* Update docs/source/json-api/lf-value-specification.rst

Co-Authored-By: Stephen Compall <stephen.compall@daml.com>

Co-authored-by: Stephen Compall <scompall@nocandysw.com>
2019-12-24 20:55:44 +00:00
Samir Talwar
1794d8a2fd Sandbox: Manage resources and close them properly on failure. (#3871)
* sandbox: Create a monadic `ResourceOwner` to manage resources.

* sandbox: Rewrite `ResourceOwner` to be async.

* sandbox: Make sure failed resources are closed immediately.

* sandbox: Better naming in `Open`.

* sandbox: Rename `Open` to `Resource`, and open/close to acquire/release.

* sandbox: Convert `() => AutoCloseable` into `ResourceOwner`.

* sandbox: Refactor the LedgerApiServer in terms of resources.

* sandbox: Explicitly convert `() => AutoCloseable` to `ResourceOwner`.

Explicit > Implicit, right?

* sandbox: Create helpers for converting things to ResourceOwners.

Because I tried to start using them and there was so much code being
written at once.

* sandbox: Simplify construction of JdbcLedgerDao.

* sandbox: Releasing resources should be idempotent.

In that we should only do it once.

* sandbox: Fix the ResetService by closing the API services _first_.

They need to be shut down before the gRPC server.

* sandbox: Don't try and shut down PostgreSQL twice in tests.

* sandbox: Actually run the assertions in ResourceOwnerSpec.

Facepalm.

* sandbox: Test `Resource.sequence` more rigorously.

* sandbox: Move the helpers around `Resource` into `Resource.apply`.

* sandbox: Convert LedgerApiServer resource owners to classes.

* sandbox: Make `ResourceOwner` a monad too, delegating to `Resource`.

* sandbox: Turn `LedgerApiServer` into a ResourceOwner.

* sandbox: Simplify the public signature of `Resource.apply`.

* sandbox: Use ResourceOwners to simplify DB resource management.

This is one hell of a change. Sorry.

* sandbox: Try not to nest `Await.result` calls.

Causes issues when running in a `DirectExecutionContext`.

* sandbox: Turn index subscriptions into resources.

* sandbox: Fix warnings in RecoveringIndexerSpec.

* sandbox: Always release before recovering the indexer.

* sandbox: Add `flatten` and `transformWith` to `Resource`.

* sandbox: If releasing twice in parallel, the second should wait.

* sandbox: If the indexer recovers, clean up the old subscription.

* sandbox: Convert StandaloneIndexerServer into a resource owner.

* sandbox: Convert StandaloneApiServer into a resource owner.

* reference-v2: Rewrite ReferenceServer in terms of resources.

CHANGELOG_BEGIN

- [Reference v2] On an exception, shut down everything and crash.
  Previously, the server would stay in a half-running state.

CHANGELOG_END

* sandbox: Rewrite SandboxServer in terms of resources.

* sandbox: Write the port file in a Future.

* sandbox: JdbcIndexer no longer needs to manage the actorSystem.

* sandbox: Shut down the LedgerApiServer when closing the Sandbox.

* sandbox: Rename `Resource.pure` to `Resource.successful`.

* sandbox: Rename `Resource.sequence_` to `sequenceIgnoringValues`.

* sandbox: Delete `CloseableResource`.

It's only used in once place. Just inline it.

* sandbox: `LedgerDao` no longer needs to be closeable.

* sandbox: Delete implicit materializers where they're not used.

* http-json: Wait for the Sandbox to start in tests.

* sandbox: Convert `scheduleHeartbeats` into a ResourceOwner.

* reference-v2: Explain why we steal ownership of the actor system.

* sandbox: Document why we only release resources once.

* sandbox: Add clues to ResourceOwnerSpec.

* http-json: Fix HttpServiceTestFixture to pass auth service through.

* codegen-sample-app: In ScalaCodeGenIT, wait for the server to  start.
2019-12-22 15:05:55 +00:00
Martin Huschenbett
f725137795 daml2ts: Do some maintenance tasks in daml-ledger-fetch (#3922)
Fix a few todos. Remove a few useless lambdas. Use newer syntax.
2019-12-20 18:44:17 +00:00
Martin Huschenbett
02d72e3a55 daml2ts: Clean up yarn.lock for support libraries (#3921) 2019-12-20 17:08:56 +00:00
Shayne Fletcher
11681c6aa3
Add 'R' to 'Choice<T,C,R>' defn (#3895)
* 'Choice<T,C,R>' defn

* Speculative. Account for the absence of tuples

* Finalize the exercise decoding and add a test

* Shorter version of bazel bootstrap (recommended by AH)

* argDecoder => argumentDecoder

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/daml-ledger-fetch/src/index.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/daml-ledger-fetch/src/index.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/daml-ledger-fetch/src/index.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/daml-ledger-fetch/src/index.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/daml-ledger-fetch/src/index.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/generated/src/__tests__/test.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Update language-support/ts/codegen/tests/ts/generated/src/__tests__/test.ts

Co-Authored-By: Martin Huschenbett <martin.huschenbett@posteo.me>

* Remove spurious return

* argDecoder => argumentDecoder

* Note to self : don't accept suggestions, implement them yourself

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2019-12-20 08:48:23 -05:00
Brian Healey
9f13a2fb10 Upgrade to Akka 2.6.1, akka-http 10.1.11 and Scala 2.12.10 (#3903)
* Upgrade to Akka 2.6.1, akka-http 10.1.11 and Scala 2.12.10

Akka 2.6.1 Upgrade Changes
- Materializer in place of ActorMaterializer
- Source.future instead of Source.fromFuture
- The Scheduler.schedule method has been deprecated in favor of selecting scheduleWithFixedDelay or scheduleAtFixedRate
- onDownstreamFinish(cause: Throwable)
- ActorAttributes.supervisionStrategy(...) in place of ActorMaterializerSettings.withSupervisionStrategy

See https://doc.akka.io/docs/akka/current/project/migration-guide-2.5.x-2.6.x.html

* Akka 2.6.1 Upgrade Changes
- onDownstreamFinish(cause: Throwable)

See https://doc.akka.io/docs/akka/current/project/migration-guide-2.5.x-2.6.x.html

* code review: remove unnecessary supervision strategy
2019-12-19 18:00:59 +00:00
Moritz Kiefer
c48b0ee289 Move Any wrappers and Archive to stable packages (#3890)
* Move Any wrappers and Archive to stable packages

There are no actual API or functionality changes in this PR but the
logic for locating the stable packages has slightly changed since the
Any wrappers package only makes sense for LF 1.7. To address this, we
simply filter out stable packages for newer LF versions since it
doesn’t make sense to depend on those anyway.

CHANGELOG_BEGIN

- [DAML Compiler] Move ``Archive`` type to a separate DALF.

CHANGELOG_END

* More comments

* Fix java codegen tests

* fix more tests

* Force cache reset on Windows

* Revert "Force cache reset on Windows"

This reverts commit 9f2b7d70b2.
2019-12-19 01:26:38 +00:00
Martin Huschenbett
00f23ef7d5
Rename Contract type to CreateEvent and move it to daml-ledger-fetch (#3869)
What was called `Contract` until now is actually a create event. Hence the
renaming. We'll most likely get a `Contract` type in DAML as well and this
renaming will avoid a name conflict. Also, create events are not part of
DAML-LF values and hence not generated by `daml2ts`. Thus, there's not need
to have them in `daml-json-types`. Instead, they should be in a future
`daml-json-api-types` package which captures the types used by the JSON API.
2019-12-17 15:05:32 +01:00
Martin Huschenbett
6d83a7bf47
Move daml-json-types to TypeScript 3.7.3 (#3856)
This should have happened in a previous PR, but I missed it.
2019-12-17 08:47:41 +01:00