diff --git a/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/NameCollision.hs b/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/NameCollision.hs index affcd5fa9b2..298f03fb462 100644 --- a/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/NameCollision.hs +++ b/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/NameCollision.hs @@ -153,7 +153,7 @@ addName name (NCState nameMap) in Left $ if all isVirtual badNames || isVirtual name then diag { _severity = Just DsWarning - , _message = _message diag <> " This breaks `daml codegen ts` and will become an error in a future SDK version." + , _message = _message diag <> " This breaks `daml codegen js` and will become an error in a future SDK version." } else diag where diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs index b9ef4ee8e7e..42c6c2176e8 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs @@ -64,7 +64,7 @@ data Command | LedgerNavigator { flags :: LedgerFlags, remainingArguments :: [String] } | Codegen { lang :: Lang, remainingArguments :: [String] } -data Lang = Java | Scala | TypeScript +data Lang = Java | Scala | JavaScript commandParser :: Parser Command commandParser = subparser $ fold @@ -187,13 +187,13 @@ commandParser = subparser $ fold [ subparser $ fold [ command "java" $ info codegenJavaCmd forwardOptions , command "scala" $ info codegenScalaCmd forwardOptions - , command "ts" $ info codegenTypeScriptCmd forwardOptions + , command "js" $ info codegenJavaScriptCmd forwardOptions ] ] codegenJavaCmd = Codegen Java <$> many (argument str (metavar "ARG")) codegenScalaCmd = Codegen Scala <$> many (argument str (metavar "ARG")) - codegenTypeScriptCmd = Codegen TypeScript <$> many (argument str (metavar "ARG")) + codegenJavaScriptCmd = Codegen JavaScript <$> many (argument str (metavar "ARG")) ledgerCmdInfo = mconcat [ forwardOptions @@ -345,7 +345,7 @@ runCommand = \case LedgerNavigator {..} -> runLedgerNavigator flags remainingArguments Codegen {..} -> case lang of - TypeScript -> + JavaScript -> runDaml2js remainingArguments Java -> runJar diff --git a/daml-assistant/exe/DA/Daml/Assistant.hs b/daml-assistant/exe/DA/Daml/Assistant.hs index 66f12b30d21..f8ba6da267d 100644 --- a/daml-assistant/exe/DA/Daml/Assistant.hs +++ b/daml-assistant/exe/DA/Daml/Assistant.hs @@ -353,7 +353,7 @@ argWhitelist = S.fromList , "navigator", "server", "console", "dump-graphql-schema", "create-config", "static", "simulated", "wallclock" , "extractor", "prettyprint", "postgresql" , "ledger", "list-parties", "allocate-parties", "upload-dar", "fetch-dar" - , "codegen", "java", "scala", "ts" + , "codegen", "java", "scala", "js" , "deploy" , "json-api" , "trigger", "list" diff --git a/daml-assistant/integration-tests/BUILD.bazel b/daml-assistant/integration-tests/BUILD.bazel index 7d70fb74f8b..f53626b9143 100644 --- a/daml-assistant/integration-tests/BUILD.bazel +++ b/daml-assistant/integration-tests/BUILD.bazel @@ -80,7 +80,7 @@ da_haskell_test( srcs = glob(["src/**/*.hs"]), args = [ "$(location //:yarn)", - # The TS codegen test which needs this next arg is not + # The JS codegen test which needs this next arg is not # run on Windows but we need to pass something on Windows # to make the test harness happy. If it should be misued, # hopefully "daml-types-not-available" will end up in the diff --git a/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs b/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs index aea41fd52e8..6dc6ac3b668 100644 --- a/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs +++ b/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs @@ -523,9 +523,9 @@ codegenTests codegenDir damlTypes = testGroup "daml codegen" ( [ codegenTestFor "java" Nothing , codegenTestFor "scala" (Just "com.cookiemonster.nomnomnom") ] ++ - -- The 'daml-types' NPM package is not available on Windows which + -- The '@daml/types' NPM package is not available on Windows which -- is required by 'daml2js'. - [ codegenTestFor "ts" Nothing | not isWindows ] + [ codegenTestFor "js" Nothing | not isWindows ] ) where codegenTestFor :: String -> Maybe String -> TestTree @@ -539,7 +539,7 @@ codegenTests codegenDir damlTypes = testGroup "daml codegen" ( callCommandSilent "daml build" let darFile = projectDir ".daml/dist/proj-" ++ lang ++ "-0.0.1.dar" outDir = projectDir "generated" lang - when (lang == "ts") $ do + when (lang == "js") $ do -- This section makes -- 'daml-types@0.0.0-SDKVERSION' available -- to yarn. @@ -576,7 +576,7 @@ createDamlAppTests = testGroup "create-daml-app" [gettingStartedGuideTest | not let cdaDir = tmpDir "create-daml-app" withCurrentDirectory cdaDir $ do callCommandSilent "daml build" - callCommandSilent "daml codegen ts -o daml.js .daml/dist/create-daml-app-0.1.0.dar" + callCommandSilent "daml codegen js -o daml.js .daml/dist/create-daml-app-0.1.0.dar" doesFileExist (cdaDir "ui" "build" "index.html") >>= assertBool "ui/build/index.html does not yet exist" . not withCurrentDirectory (cdaDir "ui") $ do diff --git a/docs/source/app-dev/app-arch.rst b/docs/source/app-dev/app-arch.rst index 7e6268f74c5..cba1c2d465d 100644 --- a/docs/source/app-dev/app-arch.rst +++ b/docs/source/app-dev/app-arch.rst @@ -85,7 +85,7 @@ corresponding typescript data definitions for the data types declared in the dep .. code-block:: bash - daml codegen ts .daml/dist/ -o daml.js + daml codegen js .daml/dist/ -o daml.js This command will generate a typescript library for each DALF in you DAR. In ``create-daml-app``, ``ui/package.json`` refers to these libraries via the diff --git a/docs/source/daml2js/index.rst b/docs/source/daml2js/index.rst index a564e0421a2..364ce8a5aad 100644 --- a/docs/source/daml2js/index.rst +++ b/docs/source/daml2js/index.rst @@ -21,7 +21,7 @@ Usage ``daml2js`` is invoked via the DAML SDK assistant. -In outline, the command to generate JavaScript and TypeScript typings from DAML is ``daml codegen ts DAR -o OUTDIR`` where ``DAR`` is the path to a DAR file (generated via ``daml build``) and ``OUTDIR`` is a directory where you want the JavaScript to be written. +In outline, the command to generate JavaScript and TypeScript typings from DAML is ``daml codegen js DAR -o OUTDIR`` where ``DAR`` is the path to a DAR file (generated via ``daml build``) and ``OUTDIR`` is a directory where you want the JavaScript to be written. Here's a complete example that generates TypeScript from a project produced from the standard "skeleton" template. @@ -31,7 +31,7 @@ Here's a complete example that generates TypeScript from a project produced from daml new my-proj skeleton # Create a new project based off the skeleton template cd my-proj # Enter the newly created project directory daml build # Compile the project's DAML files into a DAR - daml codegen ts .daml/dist/my-proj-0.0.1.dar -o daml2js # Generate script bindings from the DAR + daml codegen js .daml/dist/my-proj-0.0.1.dar -o daml2js # Generate script bindings from the DAR - On execution of these commands: diff --git a/docs/source/getting-started/app-architecture.rst b/docs/source/getting-started/app-architecture.rst index eed60aba2cc..9451298a85b 100644 --- a/docs/source/getting-started/app-architecture.rst +++ b/docs/source/getting-started/app-architecture.rst @@ -89,11 +89,11 @@ In order to build an application on top of DAML, we need a way to refer to our D We do this using a DAML to TypeScript code generation tool in the DAML SDK. To run code generation, we first need to compile the DAML model to an archive format (a ``.dar`` file). -The ``daml codegen ts`` command then takes this file as argument to produce a number of TypeScript packages in the output folder. +The ``daml codegen js`` command then takes this file as argument to produce a number of TypeScript packages in the output folder. :: daml build - daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js + daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js Now we have a TypeScript interface (types and companion objects) to our DAML model, which we'll use in our UI code next. @@ -135,7 +135,7 @@ It uses DAML React hooks to query and update ledger state. The ``useParty`` hook simply returns the current user as stored in the ``DamlLedger`` context. A more interesting example is the ``allUsers`` line. This uses the ``useStreamQuery`` hook to get all ``User`` contracts on the ledger. -(``User.User`` here is an object generated by ``daml codegen ts`` - it stores metadata of the ``User`` template defined in ``User.daml``.) +(``User.User`` here is an object generated by ``daml codegen js`` - it stores metadata of the ``User`` template defined in ``User.daml``.) Note however that this query preserves privacy: only users that follow the current user have their contracts revealed. This behaviour is due to the observers on the ``User`` contract being exactly in the list of users that the current user is following. diff --git a/docs/source/getting-started/first-feature.rst b/docs/source/getting-started/first-feature.rst index 29c3a8dfed8..ac465838297 100644 --- a/docs/source/getting-started/first-feature.rst +++ b/docs/source/getting-started/first-feature.rst @@ -74,7 +74,7 @@ Since we have changed our DAML code, we also need to rerun the TypeScript code g Open a new terminal and run the following commands:: daml build - daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js + daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js The result is an up-to-date TypeScript interface to our DAML model, in particular to the new ``Message`` template and ``SendMessage`` choice. diff --git a/docs/source/getting-started/index.rst b/docs/source/getting-started/index.rst index 924005e811a..485bb4150e8 100644 --- a/docs/source/getting-started/index.rst +++ b/docs/source/getting-started/index.rst @@ -70,7 +70,7 @@ Once the DAR file is created you will see this message in terminal ``Created .da Any commands starting with ``daml`` are using the :doc:`DAML Assistant `, a command line tool in the DAML SDK for building and running DAML apps. In order to connect the UI code to this DAML, we need to run a code generation step:: - daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js + daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js Now, changing to the ``ui`` folder, use Yarn to install the project dependencies and build the app:: diff --git a/templates/README.txt b/templates/README.txt index 9c2f733fd47..a27038e1489 100644 --- a/templates/README.txt +++ b/templates/README.txt @@ -49,7 +49,7 @@ using `daml-head` instead of `daml`. Specifically, you should run the following in the root directory: ``` daml-head build -daml-head codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js +daml-head codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js daml-head start ``` diff --git a/templates/create-daml-app/README.md b/templates/create-daml-app/README.md index e242fea8a2b..0a500425798 100644 --- a/templates/create-daml-app/README.md +++ b/templates/create-daml-app/README.md @@ -31,7 +31,7 @@ First, we need to generate TypeScript code bindings for the compiled DAML model. At the root of the repository, run ``` daml build -daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js +daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js ``` The latter command generates TypeScript packages in the `daml.js` directory. @@ -87,7 +87,7 @@ DAR `create-daml-app.dar` you have just created. To upload the UI, create a ZIP file containing all your UI assets by executing ``` daml build -daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js +daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js (cd ui && yarn build && zip -r ../create-daml-app-ui.zip build) ``` at the root of the repository. Afterwards, select the "UI Assets" tab of your