Skip to content

Commit

Permalink
rename typescript language support libs (digital-asset#4180)
Browse files Browse the repository at this point in the history
We rename the typescript packages of the language support as follows:
  @digitalasset/daml-json-types -> @daml/types
  @digitalasset/daml-ledger-fetch -> @daml/ledger

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
Robin Krom authored Jan 23, 2020
1 parent 9d8e8d4 commit a3de2fb
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 43 deletions.
11 changes: 3 additions & 8 deletions language-support/ts/codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ generate the TypeScript interface. `daml2ts` will generate interfaces for
all DALFs in that DAR. The output will be written into the directory `DIR`
you specify via the `-o` option.

The `@digitalasset/daml-json-types` package referenced by the generated
code has not yet been published. You can find it in the
[`tests/ts/daml-json-types`](https://github.com/digital-asset/daml/tree/master/language-support/ts/codegen/tests/ts/daml-json-types)
directory.

Currently, the generated interfaces are tailored towards the
[`ledger.ts`](https://github.com/digital-asset/davl/blob/master/ui/src/ledger/ledger.ts)
module of DAVL.
Expand All @@ -40,9 +35,9 @@ trinity of shell scripts, all in parallel and each in its own terminal:
- `./tests/watch-yarn`: Build all the TypeScript libraries in dependency
order and run the TypeScript compiler in watch mode on the TypeScript
generated by `./tests/watch-daml2ts.sh`. This script does not recompile
any changes made to the TypeScript libraries `daml-json-types` or
`damnl-ledger-fetch`. Changes to these libraries must be manually
recompiled using `yarn build` in the respective directoties. (You can also
any changes made to the TypeScript libraries `@daml/types` or
`@daml/ledger`. Changes to these libraries must be manually
recompiled using `yarn build` in the respective directories. (You can also
use `yarn build:watch` to run the TypeScript compiler in watch mode.)

All these steps only check that everything compiles. They do _not_ run any
Expand Down
2 changes: 1 addition & 1 deletion language-support/ts/codegen/src/TsCodeGenMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ genModule curPkgId mod
,"/* eslint-disable @typescript-eslint/camelcase */"
,"/* eslint-disable @typescript-eslint/no-use-before-define */"
,"import * as jtv from '@mojotech/json-type-validation';"
,"import * as daml from '@digitalasset/daml-json-types';"
,"import * as daml from '@daml/types';"
]
imports =
["import * as " <> modNameStr <> " from '" <> pkgRootPath <> "/" <> pkgRefStr <> T.intercalate "/" (unModuleName modName) <> "';"
Expand Down
10 changes: 5 additions & 5 deletions language-support/ts/codegen/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ daml_compile(
# - Causes 'daml2ts-test.dar' to be produced (from the sources under 'ts/daml');
# - Invokes 'daml2ts' on that dar to produce typescript bindings in' ts/generated/src/daml';
# - Invokes 'yarn install' in 'ts' to install dependencies;
# - Invokes 'yarn build' then 'yarn lint' on each of the 'daml-json-types', 'daml-ledger-fetch' and 'generated' packages;
# - Invokes 'yarn build' then 'yarn lint' on each of the '@daml/types', '@daml/ledger' and 'generated' packages;
# - Invokes 'yarn test' from the 'ts/generated' directory.
# That last step causes 'ts/generated/src/tests/__tests__/test.ts' to be executed which:
# - Spins up a sandbox running the 'daml2ts-test.dar';
Expand All @@ -37,8 +37,8 @@ sh_test(
"$(location //ledger-service/http-json:http-json-binary_deploy.jar)",
"$(location :daml2ts-test.dar)",
"$(location ts/package.json)",
"$(location //language-support/ts/daml-json-types:npm_package)",
"$(location //language-support/ts/daml-ledger-fetch:npm_package)",
"$(location //language-support/ts/daml-types:npm_package)",
"$(location //language-support/ts/daml-ledger:npm_package)",
sdk_version,
],
data = [
Expand All @@ -48,8 +48,8 @@ sh_test(
"//ledger/sandbox:sandbox-binary_deploy.jar",
"//ledger-service/http-json:http-json-binary_deploy.jar",
":daml2ts-test.dar",
"//language-support/ts/daml-json-types:npm_package",
"//language-support/ts/daml-ledger-fetch:npm_package",
"//language-support/ts/daml-types:npm_package",
"//language-support/ts/daml-ledger:npm_package",
"//:VERSION",
] + glob(
["ts/**"],
Expand Down
16 changes: 8 additions & 8 deletions language-support/ts/codegen/tests/build-and-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ JSON_API=$(rlocation "$TEST_WORKSPACE/$5")
DAR=$(rlocation "$TEST_WORKSPACE/$6")
PACKAGE_JSON=$(rlocation "$TEST_WORKSPACE/$7")
TS_DIR=$(dirname $PACKAGE_JSON)
DAML_JSON_TYPES=$(rlocation "$TEST_WORKSPACE/$8")
DAML_LEDGER_FETCH=$(rlocation "$TEST_WORKSPACE/$9")
DAML_TYPES=$(rlocation "$TEST_WORKSPACE/$8")
DAML_LEDGER=$(rlocation "$TEST_WORKSPACE/$9")
VERSION="${10}"

TMP_DIR=$(mktemp -d)
TMP_DAML_JSON_TYPES=$TMP_DIR/daml-json-types
TMP_DAML_LEDGER_FETCH=$TMP_DIR/daml-ledger-fetch
TMP_DAML_TYPES=$TMP_DIR/daml-types
TMP_DAML_LEDGER=$TMP_DIR/daml-ledger
cleanup() {
cd /
rm -rf $TMP_DIR
}
trap cleanup EXIT
echo "TMP_DIR = $TMP_DIR"
mkdir -p $TMP_DAML_JSON_TYPES
mkdir -p $TMP_DAML_LEDGER_FETCH
mkdir -p $TMP_DAML_TYPES
mkdir -p $TMP_DAML_LEDGER

cp -rL $TS_DIR/* $TMP_DIR
cp -rL $DAML_JSON_TYPES/* $TMP_DAML_JSON_TYPES
cp -rL $DAML_LEDGER_FETCH/* $TMP_DAML_LEDGER_FETCH
cp -rL $DAML_TYPES/* $TMP_DAML_TYPES
cp -rL $DAML_LEDGER/* $TMP_DAML_LEDGER

cd $TMP_DIR

Expand Down
4 changes: 2 additions & 2 deletions language-support/ts/codegen/tests/ts/generated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "Generated by daml2ts",
"license": "Apache-2.0",
"dependencies": {
"@digitalasset/daml-json-types": "0.0.0-SDKVERSION",
"@digitalasset/daml-ledger-fetch": "0.0.0-SDKVERSION"
"@daml/types": "0.0.0-SDKVERSION",
"@daml/ledger": "0.0.0-SDKVERSION"
},
"scripts": {
"build": "tsc --build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { ChildProcess, spawn } from 'child_process';
import waitOn from 'wait-on';
import { encode } from 'jwt-simple';
import Ledger, { CreateEvent, ArchiveEvent } from '@digitalasset/daml-ledger-fetch';
import Ledger, { CreateEvent, ArchiveEvent } from '@daml/ledger';
import * as Main from '../daml/daml-tests/Main';
import * as LibMod from '../daml/daml-tests/Lib/Mod';

Expand Down
4 changes: 2 additions & 2 deletions language-support/ts/codegen/tests/ts/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"workspaces": [
"daml-json-types",
"daml-ledger-fetch",
"daml-types",
"daml-ledger",
"generated"
]
}
4 changes: 2 additions & 2 deletions language-support/ts/codegen/tests/watch-yarn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

pushd $DIR/ts
yarn install
yarn workspace "@digitalasset/daml-json-types" run build
yarn workspace "@digitalasset/daml-ledger-fetch" run build
yarn workspace "@daml/daml-types" run build
yarn workspace "@daml/daml-ledger" run build
yarn workspace generated run build:watch
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ load("//language-support/ts:eslint.bzl", "eslint_test")
load("@sdk_version//:sdk_version.bzl", "sdk_version")

ts_library(
name = "daml-ledger-fetch",
name = "daml-ledger",
srcs = glob(["**/*.ts"]),
data = [
":LICENSE",
":package.json",
],
module_name = "@digitalasset/daml-ledger-fetch",
module_name = "@daml/ledger",
node_modules = "@language_support_ts_deps//:node_modules",
tsconfig = ":tsconfig.json",
visibility = ["//visibility:public"],
deps = [
"//language-support/ts/daml-json-types",
"//language-support/ts/daml-types",
"@language_support_ts_deps//@mojotech/json-type-validation",
"@language_support_ts_deps//cross-fetch",
],
Expand Down Expand Up @@ -49,7 +49,7 @@ pkg_npm(
substitutions = {"0.0.0-SDKVERSION": sdk_version},
visibility = ["//visibility:public"],
deps = [
"daml-ledger-fetch",
"daml-ledger",
":license",
],
) if not is_windows else None
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2020 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { Choice, ContractId, List, Party, Template, Text, lookupTemplate } from '@digitalasset/daml-json-types';
import { Choice, ContractId, List, Party, Template, Text, lookupTemplate } from '@daml/types';
import * as jtv from '@mojotech/json-type-validation';
import fetch from 'cross-fetch';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"private": true,
"name": "@digitalasset/daml-ledger-fetch",
"name": "@daml/ledger",
"version": "0.0.0-SDKVERSION",
"description": "Wrappers around DAML's JSON API.",
"main": "index.js",
"types": "index.d.ts",
"license": "Apache-2.0",
"dependencies": {
"@digitalasset/daml-json-types": "0.0.0-SDKVERSION",
"@daml/types": "0.0.0-SDKVERSION",
"@mojotech/json-type-validation": "^3.1.0",
"cross-fetch": "^3.0.4"
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load("//language-support/ts:jest.bzl", "jest_test")
load("@sdk_version//:sdk_version.bzl", "sdk_version")

ts_library(
name = "daml-json-types",
name = "daml-types",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.test.ts"],
Expand All @@ -20,7 +20,7 @@ ts_library(
":LICENSE",
":package.json",
],
module_name = "@digitalasset/daml-json-types",
module_name = "@daml/types",
node_modules = "@language_support_ts_deps//:node_modules",
tsconfig = ":tsconfig.json",
visibility = ["//visibility:public"],
Expand Down Expand Up @@ -55,7 +55,7 @@ pkg_npm(
substitutions = {"0.0.0-SDKVERSION": sdk_version},
visibility = ["//visibility:public"],
deps = [
"daml-json-types",
"daml-types",
":license",
],
) if not is_windows else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { Optional, Text } from './index';

describe('daml-json-types', () => {
describe('@daml/types', () => {
it('optional', () => {
const dict = Optional(Text);
expect(dict.decoder().run(null).ok).toBe(true);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "@digitalasset/daml-json-types",
"name": "@daml/types",
"version": "0.0.0-SDKVERSION",
"description": "Types used by the DAML JSON API.",
"main": "index.js",
Expand Down
4 changes: 2 additions & 2 deletions language-support/ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"workspaces": [
"daml-json-types",
"daml-ledger-fetch"
"daml-types",
"daml-fetch"
]
}

0 comments on commit a3de2fb

Please sign in to comment.