├── .circleci └── config.yml ├── .dockerignore ├── .eslintignore ├── .eslintrc.js ├── .github ├── ISSUE_TEMPLATE │ ├── ---bug-report.md │ ├── ---feature-request.md │ └── --question.md ├── labeler.yml ├── release-drafter.yml ├── release-issue-template.md └── workflows │ ├── fossa.yml │ ├── labeler.yml │ ├── linting.yml │ └── release-drafter.yml ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .vale.ini ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASING.md ├── bin ├── create-local-dependencies.sh ├── docker-login-public-gcr.sh └── update-runtime-versions.sh ├── build ├── header.txt └── license.json ├── codegen ├── .gitignore ├── .scalafmt.conf ├── README.md ├── build.sbt ├── core │ └── src │ │ ├── main │ │ └── scala │ │ │ └── io │ │ │ └── kalix │ │ │ └── codegen │ │ │ ├── DescriptorSet.scala │ │ │ ├── ModelBuilder.scala │ │ │ └── Packaging.scala │ │ └── test │ │ ├── resources │ │ └── test-files │ │ │ ├── codegen-annotation │ │ │ ├── descriptor-sets │ │ │ │ ├── action-shoppingcart-named.desc │ │ │ │ ├── action-shoppingcart.desc │ │ │ │ ├── event-sourced-shoppingcart-unnamed.desc │ │ │ │ ├── event-sourced-shoppingcart.desc │ │ │ │ ├── replicated-shoppingcart-unnamed.desc │ │ │ │ ├── replicated-shoppingcart.desc │ │ │ │ ├── value-shoppingcart-unnamed.desc │ │ │ │ ├── value-shoppingcart.desc │ │ │ │ ├── view-shoppingcart-named.desc │ │ │ │ └── view-shoppingcart.desc │ │ │ ├── generate-from-samples.sh │ │ │ └── protos │ │ │ │ ├── action-named │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ └── shoppingcart_controller_api.proto │ │ │ │ ├── action │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ └── shoppingcart_controller_api.proto │ │ │ │ ├── event-sourced-entity-unnamed │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── shoppingcart_api.proto │ │ │ │ ├── event-sourced-entity │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── shoppingcart_api.proto │ │ │ │ ├── replicated-entity-unnamed │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── shoppingcart_api.proto │ │ │ │ ├── replicated-entity │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── shoppingcart_api.proto │ │ │ │ ├── value-entity-unnamed │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── shoppingcart_api.proto │ │ │ │ ├── value-entity │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── shoppingcart_api.proto │ │ │ │ ├── view-named │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── shoppingcart │ │ │ │ │ ├── domain │ │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ │ └── view │ │ │ │ │ └── shopping_cart_view_model.proto │ │ │ │ └── view │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── shoppingcart │ │ │ │ ├── domain │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ └── view │ │ │ │ └── shopping_cart_view_model.proto │ │ │ ├── descriptor-sets │ │ │ └── hello-1.0-SNAPSHOT.protobin │ │ │ └── service-annotation │ │ │ ├── descriptor-sets │ │ │ ├── action-shoppingcart.desc │ │ │ ├── event-sourced-shoppingcart.desc │ │ │ ├── replicated-shoppingcart.desc │ │ │ ├── value-shoppingcart.desc │ │ │ └── view-shoppingcart.desc │ │ │ ├── generate-from-samples.sh │ │ │ └── protos │ │ │ ├── action │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── shoppingcart │ │ │ │ └── shoppingcart_controller_api.proto │ │ │ ├── event-sourced-entity │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── shoppingcart │ │ │ │ ├── domain │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ ├── shoppingcart_api.proto │ │ │ │ └── view │ │ │ │ └── shopping_cart_view_model.proto │ │ │ ├── replicated-entity │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── shoppingcart │ │ │ │ ├── domain │ │ │ │ └── shoppingcart_domain.proto │ │ │ │ └── shoppingcart_api.proto │ │ │ ├── shoppingcart │ │ │ ├── domain │ │ │ │ └── shoppingcart_domain.proto │ │ │ ├── shoppingcart_api.proto │ │ │ └── shoppingcart_controller_api.proto │ │ │ └── value-entity │ │ │ └── com │ │ │ └── example │ │ │ └── shoppingcart │ │ │ ├── domain │ │ │ └── shoppingcart_domain.proto │ │ │ └── shoppingcart_api.proto │ │ └── scala │ │ └── io │ │ └── kalix │ │ └── codegen │ │ ├── DescriptorSetSuite.scala │ │ └── ModelBuilderSuite.scala ├── js-gen-cli │ ├── README.md │ └── src │ │ ├── it │ │ ├── resources │ │ │ ├── Dockerfile │ │ │ ├── application.conf │ │ │ ├── logback-test.xml │ │ │ ├── proto │ │ │ │ ├── action-service.proto │ │ │ │ └── value-entity-domain.proto │ │ │ └── scripts │ │ │ │ ├── disable-download-cli.js │ │ │ │ ├── entrypoint.sh │ │ │ │ ├── setup-entity.sh │ │ │ │ ├── setup.sh │ │ │ │ ├── start-entity.sh │ │ │ │ └── stop-entity.sh │ │ └── scala │ │ │ └── io │ │ │ └── kalix │ │ │ └── codegen │ │ │ └── js │ │ │ └── JsCodegenIntegrationSuite.scala │ │ └── main │ │ ├── resources │ │ ├── jni-config.json │ │ ├── proxy-config.json │ │ ├── reflect-config.json │ │ └── resource-config.json │ │ └── scala │ │ └── io │ │ ├── kalix │ │ └── codegen │ │ │ └── js │ │ │ └── Cli.scala │ │ └── netty │ │ └── channel │ │ └── socket │ │ └── nio │ │ └── NioServerSocketChannel.scala ├── js-gen │ └── src │ │ ├── main │ │ └── scala │ │ │ └── io │ │ │ └── kalix │ │ │ └── codegen │ │ │ └── js │ │ │ ├── ActionServiceSourceGenerator.scala │ │ │ ├── EntityServiceSourceGenerator.scala │ │ │ ├── SourceGenerator.scala │ │ │ └── ViewServiceSourceGenerator.scala │ │ └── test │ │ └── scala │ │ └── io │ │ └── kalix │ │ └── codegen │ │ └── js │ │ ├── ActionServiceSourceGeneratorSuite.scala │ │ ├── EntityServiceSourceGeneratorSuite.scala │ │ ├── SourceGeneratorSuite.scala │ │ ├── TestData.scala │ │ └── ViewServiceSourceGeneratorSuite.scala ├── project │ ├── build.properties │ ├── metals.sbt │ └── plugins.sbt └── set-version.sh ├── docs ├── .examplesignore ├── .gitignore ├── Makefile ├── README.md ├── bin │ ├── bundle.sh │ ├── deploy.sh │ └── version.sh ├── config │ └── validate-links.json ├── dev │ ├── antora.yml │ └── src │ │ ├── antora.yml │ │ └── modules │ │ └── ROOT │ │ ├── images │ │ └── new-tab.svg │ │ └── partials │ │ ├── grpc │ │ └── using-acls.adoc │ │ └── include.adoc └── src │ ├── antora.yml │ └── modules │ ├── developing │ └── pages │ │ └── development-process-js.adoc │ └── javascript │ ├── examples │ ├── action │ │ ├── service.proto │ │ └── src │ │ │ ├── action.js │ │ │ └── action.ts │ ├── domain.proto │ ├── eventing-shopping-cart │ │ └── proto │ │ │ ├── cart │ │ │ └── shopping_cart_analytics.proto │ │ │ └── product │ │ │ └── to_product_popularity.proto │ ├── shoppingcart.proto │ ├── test │ │ ├── eventsourced │ │ │ ├── shoppingcart.js │ │ │ └── shoppingcart.ts │ │ └── gettingstarted │ │ │ ├── index.js │ │ │ ├── index.ts │ │ │ └── shoppingcart.js │ └── value-entity │ │ ├── domain.proto │ │ ├── shoppingcart.proto │ │ └── src │ │ ├── shoppingcart.js │ │ └── shoppingcart.ts │ ├── nav.adoc │ ├── pages │ ├── access-control.adoc │ ├── actions-publishing-subscribing.adoc │ ├── actions.adoc │ ├── api.adoc │ ├── call-another-service.adoc │ ├── developer-tools.adoc │ ├── eventsourced.adoc │ ├── forwarding.adoc │ ├── index.adoc │ ├── kickstart.adoc │ ├── proto.adoc │ ├── quickstart │ │ ├── cr-value-entity-javascript.adoc │ │ ├── cr-value-entity-typescript.adoc │ │ ├── sc-eventsourced-entity-javascript.adoc │ │ └── sc-eventsourced-entity-typescript.adoc │ ├── replicated-entity-crdt.adoc │ ├── running-locally.adoc │ ├── serialization.adoc │ ├── value-entity.adoc │ └── views.adoc │ └── partials │ ├── actions.adoc │ ├── eventsourced.adoc │ ├── forwarding-effects.adoc │ ├── forwarding.adoc │ ├── json.adoc │ ├── pubsub-note.adoc │ ├── serialization.adoc │ └── topic-eventing-cloudevent.adoc ├── npm-js ├── README.md ├── create-kalix-entity │ ├── .gitignore │ ├── .nvmrc │ ├── README.md │ ├── create-kalix-entity.js │ ├── package-lock.json │ ├── package.json │ └── template │ │ ├── base-common │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── README.md │ │ └── docker-compose.yml │ │ ├── base-js │ │ ├── Dockerfile │ │ ├── jsconfig.json │ │ └── package.json │ │ ├── base-ts │ │ ├── Dockerfile │ │ ├── package.json │ │ └── tsconfig.json │ │ ├── basic │ │ └── README.md │ │ ├── event-sourced-entity │ │ └── proto │ │ │ ├── counter_api.proto │ │ │ └── counter_domain.proto │ │ └── value-entity │ │ └── proto │ │ ├── counter_api.proto │ │ └── counter_domain.proto └── kalix-scripts │ ├── .gitignore │ ├── .nvmrc │ ├── README.md │ ├── bin │ ├── download-codegen.js │ └── kalix-scripts.js │ ├── package-lock.json │ └── package.json ├── package-lock.json ├── package.json ├── samples ├── .gitignore ├── bin │ └── update.sh ├── js │ ├── js-customer-registry-quickstart │ │ ├── .bundleignore │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── integration-test │ │ │ └── customer.test.js │ │ ├── jsconfig.json │ │ ├── package.json │ │ ├── proto │ │ │ ├── customer_api.proto │ │ │ ├── customer_domain.proto │ │ │ └── kalix_policy.proto │ │ ├── src │ │ │ ├── customer.js │ │ │ └── index.js │ │ └── test │ │ │ └── customer.test.js │ ├── js-customer-registry │ │ ├── .bundleignore │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── customer-event-sourced-entity.js │ │ ├── customer-event-sourced-view.js │ │ ├── customer-value-entity-view.js │ │ ├── customer-value-entity.js │ │ ├── customer_api.proto │ │ ├── customer_domain.proto │ │ ├── customer_view.proto │ │ ├── docker-compose.yml │ │ ├── index.js │ │ ├── integration-test │ │ │ └── customer-registry-test.js │ │ ├── kalix_policy.proto │ │ ├── package-lock.json │ │ └── package.json │ ├── js-doc-snippets │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── .nvmrc │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── jsconfig.json │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── proto │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── counter_api.proto │ │ │ │ ├── delegating_service.proto │ │ │ │ ├── json │ │ │ │ └── json_api.proto │ │ │ │ └── kalix_policy.proto │ │ └── src │ │ │ ├── delegatingservice.js │ │ │ ├── index.js │ │ │ └── myservice.js │ ├── js-eventsourced-shopping-cart │ │ ├── .bundleignore │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── RELEASING.md │ │ ├── docker-compose.yml │ │ ├── integration-test │ │ │ └── shoppingcart.integration-test.js │ │ ├── jsconfig.json │ │ ├── package.json │ │ ├── proto │ │ │ ├── shoppingcart_api.proto │ │ │ └── shoppingcart_domain.proto │ │ ├── src │ │ │ ├── index.js │ │ │ └── shoppingcart.js │ │ └── test │ │ │ └── shoppingcart.test.js │ ├── js-replicated-entity-example │ │ ├── .gitignore │ │ ├── .npmrc │ │ ├── .nvmrc │ │ ├── Dockerfile │ │ ├── docker-compose.yml │ │ ├── index.js │ │ ├── package.json │ │ ├── replicated-entity-example.js │ │ └── replicated_entity_example.proto │ ├── js-replicated-entity-shopping-cart │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── .nvmrc │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── RELEASING.md │ │ ├── docker-compose.yml │ │ ├── integration-test │ │ │ └── shoppingcart.integration-test.js │ │ ├── jsconfig.json │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── proto │ │ │ ├── shoppingcart_api.proto │ │ │ └── shoppingcart_domain.proto │ │ └── src │ │ │ ├── index.js │ │ │ └── shoppingcart.js │ ├── js-shopping-cart-quickstart │ │ ├── .bundleignore │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── integration-test │ │ │ └── shoppingcart.test.js │ │ ├── jsconfig.json │ │ ├── package.json │ │ ├── proto │ │ │ ├── kalix_policy.proto │ │ │ ├── shopping_cart_api.proto │ │ │ └── shopping_cart_domain.proto │ │ ├── src │ │ │ ├── index.js │ │ │ └── shoppingcart.js │ │ └── test │ │ │ └── shoppingcart.test.js │ ├── js-valueentity-shopping-cart │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── .nvmrc │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── RELEASING.md │ │ ├── docker-compose.yml │ │ ├── integration-test │ │ │ └── shoppingcart.integration-test.js │ │ ├── jsconfig.json │ │ ├── package.json │ │ ├── proto │ │ │ ├── shoppingcart_api.proto │ │ │ └── shoppingcart_domain.proto │ │ ├── src │ │ │ ├── index.js │ │ │ └── shoppingcart.js │ │ └── test │ │ │ └── shoppingcart.test.js │ ├── js-views-example │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── docker-compose.yml │ │ ├── index.js │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── user-email-count.js │ │ ├── users-by-email.js │ │ ├── users.js │ │ └── users.proto │ └── valueentity-counter │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── integration-test │ │ └── counter.test.js │ │ ├── jsconfig.json │ │ ├── package.json │ │ ├── proto │ │ ├── counter_api.proto │ │ └── counter_domain.proto │ │ ├── src │ │ ├── counter.js │ │ └── index.js │ │ └── test │ │ └── counter.test.js └── ts │ ├── ts-customer-registry-quickstart │ ├── .bundleignore │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── integration-test │ │ └── customer.test.ts │ ├── package.json │ ├── proto │ │ ├── customer_api.proto │ │ ├── customer_domain.proto │ │ └── kalix_policy.proto │ ├── src │ │ ├── customer.ts │ │ └── index.ts │ ├── test │ │ └── customer.test.ts │ └── tsconfig.json │ ├── ts-customer-registry │ ├── .bundleignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .prettierrc.json │ ├── Dockerfile │ ├── README.md │ ├── customer_api.proto │ ├── customer_domain.proto │ ├── customer_view.proto │ ├── docker-compose.yml │ ├── integration-test │ │ └── customer-registry-test.ts │ ├── kalix_policy.proto │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── customer-event-sourced-entity.ts │ │ ├── customer-event-sourced-view.ts │ │ ├── customer-value-entity-view.ts │ │ ├── customer-value-entity.ts │ │ └── index.ts │ └── tsconfig.json │ ├── ts-eventsourced-shopping-cart │ ├── .bundleignore │ ├── .dockerignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .prettierrc.json │ ├── Dockerfile │ ├── README.md │ ├── RELEASING.md │ ├── docker-compose.yml │ ├── integration-test │ │ └── shoppingcart.integration-test.ts │ ├── package-lock.json │ ├── package.json │ ├── proto │ │ ├── shoppingcart_api.proto │ │ └── shoppingcart_domain.proto │ ├── src │ │ ├── index.ts │ │ └── shoppingcart.ts │ ├── test │ │ └── shoppingcart.test.ts │ └── tsconfig.json │ ├── ts-replicated-entity-example │ ├── .eslintrc.json │ ├── .gitignore │ ├── .npmrc │ ├── .nvmrc │ ├── .prettierrc.json │ ├── Dockerfile │ ├── docker-compose.yml │ ├── package-lock.json │ ├── package.json │ ├── replicated_entity_example.proto │ ├── src │ │ ├── index.ts │ │ └── replicated-entity-example.ts │ └── tsconfig.json │ ├── ts-replicated-entity-shopping-cart │ ├── .dockerignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .nvmrc │ ├── .prettierrc.json │ ├── Dockerfile │ ├── README.md │ ├── RELEASING.md │ ├── docker-compose.yml │ ├── integration-test │ │ └── shoppingcart.integration-test.ts │ ├── package-lock.json │ ├── package.json │ ├── proto │ │ ├── shoppingcart_api.proto │ │ └── shoppingcart_domain.proto │ ├── src │ │ ├── index.ts │ │ └── shoppingcart.ts │ └── tsconfig.json │ ├── ts-shopping-cart-quickstart │ ├── .bundleignore │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── integration-test │ │ └── shoppingcart.test.ts │ ├── package.json │ ├── proto │ │ ├── kalix_policy.proto │ │ ├── shopping_cart_api.proto │ │ └── shopping_cart_domain.proto │ ├── src │ │ ├── index.ts │ │ └── shoppingcart.ts │ ├── test │ │ └── shoppingcart.test.ts │ └── tsconfig.json │ ├── ts-valueentity-counter │ ├── .dockerignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .prettierrc.json │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── integration-test │ │ └── counter.test.ts │ ├── package-lock.json │ ├── package.json │ ├── proto │ │ ├── counter_api.proto │ │ └── counter_domain.proto │ ├── src │ │ ├── counter.ts │ │ └── index.ts │ ├── test │ │ └── counter.test.ts │ └── tsconfig.json │ ├── ts-valueentity-shopping-cart │ ├── .dockerignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .nvmrc │ ├── .prettierrc.json │ ├── Dockerfile │ ├── README.md │ ├── RELEASING.md │ ├── docker-compose.yml │ ├── integration-test │ │ └── shoppingcart.integration-test.ts │ ├── package-lock.json │ ├── package.json │ ├── proto │ │ ├── shoppingcart_api.proto │ │ └── shoppingcart_domain.proto │ ├── src │ │ ├── index.ts │ │ └── shoppingcart.ts │ ├── test │ │ └── shoppingcart.test.ts │ └── tsconfig.json │ └── ts-views-example │ ├── .eslintrc.json │ ├── .gitignore │ ├── .prettierrc.json │ ├── Dockerfile │ ├── docker-compose.yml │ ├── package-lock.json │ ├── package.json │ ├── src │ ├── index.ts │ ├── user-email-count.ts │ ├── users-by-email.ts │ └── users.ts │ ├── tsconfig.json │ └── users.proto ├── sdk ├── .gitignore ├── .mocharc.json ├── .npmrc ├── .nvmrc ├── README.md ├── bin │ ├── compile-descriptor.js │ ├── download-protoc.js │ ├── prepare.sh │ ├── test-compile-proto.sh │ └── version.sh ├── config.json ├── package-lock.json ├── package.json ├── src │ ├── action-support.ts │ ├── action.ts │ ├── cloudevent.ts │ ├── command-helper.ts │ ├── command.ts │ ├── context-failure.ts │ ├── effect-serializer.ts │ ├── effect.ts │ ├── event-sourced-entity-support.ts │ ├── event-sourced-entity.ts │ ├── grpc-status.ts │ ├── grpc-util.ts │ ├── index.ts │ ├── jwt-claims.ts │ ├── kalix.ts │ ├── metadata.ts │ ├── package-info.ts │ ├── protobuf-any.ts │ ├── protobuf-helper.ts │ ├── replicated-data │ │ ├── counter-map.ts │ │ ├── counter.ts │ │ ├── index.ts │ │ ├── iterators.ts │ │ ├── map.ts │ │ ├── multi-map.ts │ │ ├── register-map.ts │ │ ├── register.ts │ │ ├── set.ts │ │ └── vote.ts │ ├── replicated-entity-support.ts │ ├── replicated-entity.ts │ ├── reply.ts │ ├── serializable.ts │ ├── settings.ts │ ├── tsconfig.json │ ├── value-entity-support.ts │ ├── value-entity.ts │ ├── view-support.ts │ └── view.ts ├── test │ ├── action-handler.test.ts │ ├── context-failure.test.ts │ ├── effect-serializer.test.ts │ ├── example.proto │ ├── kalix.test.ts │ ├── metadata.test.ts │ ├── package-info.test.ts │ ├── package.test.json │ ├── protobuf-any.test.ts │ ├── replicated-data │ │ ├── counter-map.test.ts │ │ ├── counter.test.ts │ │ ├── map.test.ts │ │ ├── multi-map.test.ts │ │ ├── register-map.test.ts │ │ ├── register.test.ts │ │ ├── set.test.ts │ │ └── vote.test.ts │ ├── replicated-entity-handler.test.ts │ ├── reply.test.ts │ └── tsconfig.json ├── tsconfig.build.json ├── tsconfig.json ├── typedoc.json └── types │ ├── protocol │ ├── actions.ts │ ├── any.ts │ ├── commands.ts │ ├── discovery.ts │ ├── event-sourced-entities.ts │ ├── replicated-entities.ts │ ├── value-entities.ts │ └── views.ts │ └── tsconfig.json ├── styles ├── Lightbend │ ├── AMPM.yml │ ├── Accessibility.yml │ ├── Acronyms.yml │ ├── Adverbs.yml │ ├── Auto.yml │ ├── Avoid.yml │ ├── ComplexWords.yml │ ├── Contractions.yml │ ├── Dashes.yml │ ├── DateFormat.yml │ ├── DateNumbers.yml │ ├── DateOrder.yml │ ├── Ellipses.yml │ ├── FirstPerson.yml │ ├── Foreign.yml │ ├── Gender.yml │ ├── GenderBias.yml │ ├── GeneralURL.yml │ ├── HeadingAcronyms.yml │ ├── HeadingColons.yml │ ├── HeadingPunctuation.yml │ ├── Headings.yml │ ├── Hyphens.yml │ ├── Ordinal.yml │ ├── OxfordComma.yml │ ├── Passive.yml │ ├── Percentages.yml │ ├── Quotes.yml │ ├── RangeFormat.yml │ ├── RangeTime.yml │ ├── Ranges.yml │ ├── Readability.yml │ ├── Semicolon.yml │ ├── SentenceLength.yml │ ├── Spacing.yml │ ├── Suspended.yml │ ├── Terms.yml │ ├── URLFormat.yml │ ├── Units.yml │ ├── Vocab.yml │ ├── We.yml │ ├── Wordiness.yml │ └── meta.json ├── Microsoft │ ├── AMPM.yml │ ├── Accessibility.yml │ ├── Acronyms.yml │ ├── Adverbs.yml │ ├── Auto.yml │ ├── Avoid.yml │ ├── ComplexWords.yml │ ├── Contractions.yml │ ├── Dashes.yml │ ├── DateFormat.yml │ ├── DateNumbers.yml │ ├── DateOrder.yml │ ├── Ellipses.yml │ ├── FirstPerson.yml │ ├── Foreign.yml │ ├── Gender.yml │ ├── GenderBias.yml │ ├── GeneralURL.yml │ ├── HeadingAcronyms.yml │ ├── HeadingColons.yml │ ├── HeadingPunctuation.yml │ ├── Headings.yml │ ├── Hyphens.yml │ ├── Negative.yml │ ├── Ordinal.yml │ ├── OxfordComma.yml │ ├── Passive.yml │ ├── Percentages.yml │ ├── Quotes.yml │ ├── RangeFormat.yml │ ├── RangeTime.yml │ ├── Ranges.yml │ ├── Semicolon.yml │ ├── SentenceLength.yml │ ├── Spacing.yml │ ├── Suspended.yml │ ├── Terms.yml │ ├── URLFormat.yml │ ├── Units.yml │ ├── Vocab.yml │ ├── We.yml │ ├── Wordiness.yml │ └── meta.json ├── config │ └── vocabularies │ │ └── Base │ │ ├── accept.txt │ │ └── reject.txt └── write-good │ ├── Cliches.yml │ ├── E-Prime.yml │ ├── Illusions.yml │ ├── Passive.yml │ ├── README.md │ ├── So.yml │ ├── ThereIs.yml │ ├── TooWordy.yml │ ├── Weasel.yml │ └── meta.json ├── tck ├── .gitignore ├── .npmrc ├── .nvmrc ├── Dockerfile ├── README.md ├── bin │ └── tck-protocol.sh ├── index.ts ├── package.json ├── run.ts ├── src │ ├── action.ts │ ├── event-sourced-entity.ts │ ├── eventing.ts │ ├── replicated-entity.ts │ ├── value-entity.ts │ └── view.ts └── tsconfig.json └── testkit ├── .gitignore ├── .mocharc.json ├── .nvmrc ├── README.md ├── example ├── proto │ └── example.proto ├── src │ ├── action-with-acl.ts │ ├── action.ts │ ├── event-sourced-entity.ts │ └── value-entity.ts └── types │ ├── action.d.ts │ ├── event-sourced-entity.d.ts │ └── value-entity.d.ts ├── integration-test └── integration-testkit.test.ts ├── package-lock.json ├── package.json ├── src ├── index.ts ├── integration-testkit.ts ├── mock-command.ts ├── mock-event-sourced-entity.ts └── mock-value-entity.ts ├── test ├── mock-event-sourced-entity.test.ts └── mock-value-entity.test.ts └── tsconfig.json /.dockerignore: -------------------------------------------------------------------------------- 1 | **/Dockerfile 2 | **/node_modules 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41B Bug report" 3 | about: Create a report to help us improve 4 | labels: kalix-runtime, javascript-sdk, bug 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F389 Feature request" 3 | about: Suggest an idea for this project 4 | labels: kalix-runtime, javascript-sdk 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/--question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "❓ Question" 3 | about: Please use https://discuss.kalix.io for questions 4 | 5 | --- 6 | 7 | Please use https://discuss.kalix.io for questions instead of posting them to the issue tracker. 8 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/labeler 2 | 3 | kalix-runtime: 4 | - '**/*' 5 | 6 | javascript-sdk: 7 | - sdk/**/*.js 8 | - codegen/js-gen/**/* 9 | - samples/js/**/* 10 | 11 | typescript-sdk: 12 | - sdk/**/*.ts 13 | - samples/ts/**/* 14 | 15 | Documentation: 16 | - docs/**/* 17 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # Config for https://github.com/release-drafter/release-drafter 2 | name-template: 'v$NEXT_PATCH_VERSION' 3 | tag-template: 'v$NEXT_PATCH_VERSION' 4 | categories: 5 | - title: '🚀 Features' 6 | labels: 7 | - 'Feature' 8 | - title: 'Documentation' 9 | labels: 10 | - 'Documentation' 11 | - 'Samples' 12 | - title: 'TCK' 13 | labels: 14 | - 'tck' 15 | 16 | change-template: '- $TITLE #$NUMBER by @$AUTHOR' 17 | template: | 18 | # :mega: Kalix Javascript/Typescript SDK $NEXT_PATCH_VERSION 19 | 20 | ## Changes 21 | 22 | $CHANGES 23 | 24 | ## :bow: Credits 25 | Special thanks to the following contributors who helped with this release: $CONTRIBUTORS 26 | 27 | autolabeler: 28 | - label: 'Documentation' 29 | files: 30 | - 'docs/**' 31 | - label: 'Samples' 32 | files: 33 | - 'samples/**' 34 | - label: 'tck' 35 | files: 36 | - 'tck/**' 37 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/labeler 2 | 3 | name: "Pull Request Labeler" 4 | on: 5 | - pull_request_target 6 | 7 | jobs: 8 | triage: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: read 12 | pull-requests: write 13 | steps: 14 | # https://github.com/actions/labeler/releases 15 | # v4.0.3 16 | - uses: actions/labeler@ba790c862c380240c6d5e7427be5ace9a05c754b 17 | with: 18 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 19 | -------------------------------------------------------------------------------- /.github/workflows/linting.yml: -------------------------------------------------------------------------------- 1 | name: Linting 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | tags-ignore: [ v.* ] 9 | 10 | jobs: 11 | prose: 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - name: Checkout 15 | # https://github.com/actions/checkout/releases 16 | # v3.5.0 17 | uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 18 | 19 | # https://vale.sh 20 | - name: Vale 21 | # https://github.com/errata-ai/vale-action/releases 22 | # v2.0.1 23 | uses: errata-ai/vale-action@c4213d4de3d5f718b8497bd86161531c78992084 24 | with: 25 | version: 3.0.5 26 | files: '["docs/dev", "docs/src", "samples"]' 27 | fail_on_error: true 28 | filter_mode: nofilter 29 | env: 30 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 31 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | # pull_request event is required only for autolabeler 9 | pull_request: 10 | # Only following types are handled by the action, but one can default to all as well 11 | types: [opened, reopened, synchronize] 12 | 13 | jobs: 14 | update_release_draft: 15 | runs-on: ubuntu-latest 16 | steps: 17 | # We use this fork as slight security improvement 18 | - uses: raboof/release-drafter@v5 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | .idea 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | package-lock.json 3 | jsdoc.json 4 | /sdk/apidocs/**/*.* 5 | /sdk/dist/**/*.* 6 | /sdk/proto/**/*.* 7 | /sdk/test/proto/**/*.* 8 | /sdk/types/dist/**/*.* 9 | /sdk/types/generated/**/*.* 10 | /tck/dist/**/*.* 11 | /tck/generated/**/*.* 12 | /tck/proto/**/*.* 13 | /testkit/dist/**/*.* 14 | /testkit/example/generated/**/*.* 15 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "singleQuote": true, 4 | "tabWidth": 2, 5 | "semi": true, 6 | "trailingComma": "all" 7 | } 8 | -------------------------------------------------------------------------------- /.vale.ini: -------------------------------------------------------------------------------- 1 | StylesPath = styles 2 | 3 | MinAlertLevel = error 4 | Vocab = Base 5 | 6 | Packages = Microsoft, write-good 7 | 8 | [*.{md,adoc}] 9 | BasedOnStyles = Vale, Lightbend, write-good 10 | 11 | # Override the alert level of certain styles 12 | Lightbend.Contractions = suggestion 13 | Lightbend.Avoid = warning 14 | write-good.So = suggestion 15 | write-good.ThereIs = suggestion 16 | Lightbend.Foreign = warning 17 | Lightbend.HeadingColons = warning 18 | Lightbend.RangeFormat = suggestion 19 | Lightbend.URLFormat = suggestion 20 | Lightbend.Auto = warning 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kalix JavaScript SDK 2 | 3 | Source code for the [@kalix-io/kalix-javascript-sdk](https://www.npmjs.com/package/@kalix-io/kalix-javascript-sdk) package. 4 | 5 | For more information see the documentation for [implementing Kalix services in JavaScript](https://docs.kalix.io/javascript/). 6 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # Releasing Kalix JavaScript SDK 2 | 3 | Create a release issue (using the [GitHub CLI](https://cli.github.com/)) 4 | 5 | ``` 6 | gh issue create --title 'Release Kalix JavaScript SDK' --label kalix-runtime --body-file .github/release-issue-template.md -w 7 | ```` 8 | 9 | and follow the instructions. 10 | 11 | 12 | ## Publishing documentation hotfixes 13 | 14 | Docs will be published automatically on release. Docs can also be published manually for hotfixes. 15 | 16 | The version used in the docs will be the nearest tag. If all doc changes since the last release should be published, run (in the `docs` dir, or with `-C docs`): 17 | 18 | ``` 19 | make deploy 20 | ``` 21 | 22 | If only some doc changes are needed, branch from the last release tag, cherry-pick the needed doc changes, and then run `make deploy`. 23 | 24 | This will publish the doc sources to the `docs/current` branch. They will be included automatically in the next build for the main docs. A build for the main docs can also be triggered by re-running the last docs build in CircleCI (on the `master` branch for dev docs, on the `current` branch for prod docs). 25 | -------------------------------------------------------------------------------- /bin/docker-login-public-gcr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This script configures docker to be able to push to Google Container Registry. 4 | # It uses the service account associated with PUBLIC_GCR_SERVICE_KEY. 5 | 6 | set -euo pipefail 7 | 8 | echo "$KALIX_PUBLIC_GCR_SERVICE_KEY" | docker login -u _json_key --password-stdin https://gcr.io 9 | -------------------------------------------------------------------------------- /build/header.txt: -------------------------------------------------------------------------------- 1 | Copyright 2021-2023 Lightbend Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /build/license.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignoreFile": "sdk/.gitignore", 3 | "ignore": [ 4 | "build", 5 | "codegen", 6 | "docs", 7 | "**/.*", 8 | "**/bin", 9 | "**/template", 10 | "**/Dockerfile", 11 | "**/*.md", 12 | "**/*.yml", 13 | "samples/*/*/lib/generated", 14 | "sdk/test/*.desc", 15 | "styles/config/vocabularies/Base", 16 | "tck/generated", 17 | "testkit/integration-test/proto.*" 18 | ], 19 | "license": "build/header.txt", 20 | "licenseFormats": { 21 | "js": { 22 | "prepend": "/*", 23 | "append": " */", 24 | "eachLine": { 25 | "prepend": " * " 26 | } 27 | }, 28 | "ts": { 29 | "prepend": "/*", 30 | "append": " */", 31 | "eachLine": { 32 | "prepend": " * " 33 | } 34 | }, 35 | "jsdoc": { 36 | "prepend": "/*", 37 | "append": " */", 38 | "eachLine": { 39 | "prepend": " * " 40 | } 41 | }, 42 | "proto": { 43 | "eachLine": { 44 | "prepend": "// " 45 | } 46 | } 47 | }, 48 | "trailingWhitespace": "TRIM" 49 | } 50 | -------------------------------------------------------------------------------- /codegen/.gitignore: -------------------------------------------------------------------------------- 1 | # sbt 2 | lib_managed 3 | project/project 4 | target 5 | .bsp 6 | 7 | # Worksheets (Eclipse or IntelliJ) 8 | *.sc 9 | 10 | # Eclipse 11 | .cache* 12 | .classpath 13 | .project 14 | .scala_dependencies 15 | .settings 16 | .target 17 | .worksheet 18 | 19 | # IntelliJ 20 | .idea 21 | 22 | # ENSIME 23 | .ensime 24 | .ensime_lucene 25 | .ensime_cache 26 | 27 | # Mac 28 | .DS_Store 29 | 30 | # Akka 31 | ddata* 32 | journal 33 | snapshots 34 | 35 | # Log files 36 | *.log 37 | 38 | # jenv 39 | .java-version 40 | 41 | # Metals 42 | .metals 43 | .bloop 44 | .vscode 45 | version.sbt 46 | -------------------------------------------------------------------------------- /codegen/.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = 3.0.3 2 | 3 | style = defaultWithAlign 4 | 5 | docstrings.style = Asterisk 6 | indentOperator.preset = spray 7 | maxColumn = 120 8 | rewrite.rules = [RedundantParens, SortImports, AvoidInfix] 9 | unindentTopLevelOperators = true 10 | align.tokens = [{code = "=>", owner = "Case"}] 11 | align.openParenDefnSite = false 12 | align.openParenCallSite = false 13 | optIn.configStyleArguments = false 14 | danglingParentheses.preset = false 15 | spaces.inImportCurlyBraces = true 16 | newlines.afterCurlyLambda = preserve 17 | rewrite.neverInfix.excludeFilters = [ 18 | and 19 | min 20 | max 21 | until 22 | to 23 | by 24 | eq 25 | ne 26 | "should.*" 27 | "contain.*" 28 | "must.*" 29 | in 30 | ignore 31 | be 32 | taggedAs 33 | thrownBy 34 | synchronized 35 | have 36 | when 37 | size 38 | only 39 | noneOf 40 | oneElementOf 41 | noElementsOf 42 | atLeastOneElementOf 43 | atMostOneElementOf 44 | allElementsOf 45 | inOrderElementsOf 46 | theSameElementsAs 47 | ] 48 | -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/action-shoppingcart-named.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/action-shoppingcart-named.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/action-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/action-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/event-sourced-shoppingcart-unnamed.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/event-sourced-shoppingcart-unnamed.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/event-sourced-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/event-sourced-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/replicated-shoppingcart-unnamed.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/replicated-shoppingcart-unnamed.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/replicated-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/replicated-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/value-shoppingcart-unnamed.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/value-shoppingcart-unnamed.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/value-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/value-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/view-shoppingcart-named.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/view-shoppingcart-named.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/view-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/codegen-annotation/descriptor-sets/view-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/protos/replicated-entity-unnamed/com/example/shoppingcart/domain/shoppingcart_domain.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package com.example.shoppingcart.domain; 18 | 19 | option java_outer_classname = "ShoppingCartDomain"; 20 | 21 | message Product { 22 | string id = 1; 23 | string name = 2; 24 | } 25 | -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/codegen-annotation/protos/replicated-entity/com/example/shoppingcart/domain/shoppingcart_domain.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package com.example.shoppingcart.domain; 18 | 19 | option java_outer_classname = "ShoppingCartDomain"; 20 | 21 | message Product { 22 | string id = 1; 23 | string name = 2; 24 | } 25 | -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/descriptor-sets/hello-1.0-SNAPSHOT.protobin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/descriptor-sets/hello-1.0-SNAPSHOT.protobin -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/action-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/action-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/event-sourced-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/event-sourced-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/replicated-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/replicated-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/value-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/value-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/view-shoppingcart.desc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/codegen/core/src/test/resources/test-files/service-annotation/descriptor-sets/view-shoppingcart.desc -------------------------------------------------------------------------------- /codegen/core/src/test/scala/io/kalix/codegen/DescriptorSetSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Lightbend Inc. 2021 3 | * 4 | */ 5 | 6 | package io.kalix.codegen 7 | 8 | import java.nio.file.Paths 9 | 10 | class DescriptorSetSuite extends munit.FunSuite { 11 | 12 | test("reading") { 13 | val testFilesPath = Paths.get(getClass.getClassLoader.getResource("test-files").toURI) 14 | val descriptorFile = testFilesPath.resolve("descriptor-sets/hello-1.0-SNAPSHOT.protobin").toFile 15 | val result = DescriptorSet 16 | .fileDescriptors(descriptorFile) 17 | .flatMap(x => x.map(_.head.getServices.get(0).getFullName)) 18 | assertEquals(result, Right("com.lightbend.MyServiceEntity")) 19 | } 20 | 21 | test("failed to open") { 22 | val result = DescriptorSet 23 | .fileDescriptors(Paths.get(".").toFile) 24 | assert(result.isLeft) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16.1-buster 2 | 3 | WORKDIR /home 4 | ADD ./kalix-npm-js kalix-npm-js 5 | ADD ./kalix-codegen-js kalix-codegen-js 6 | ADD ./scripts scripts 7 | 8 | # Configure and install tooling 9 | RUN ./scripts/setup.sh 10 | 11 | CMD ./scripts/entrypoint.sh 12 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/application.conf: -------------------------------------------------------------------------------- 1 | kalix-npm-js { 2 | # By default, we assume the kalix npm-js project is checked out next to this repository 3 | path = "../kalix-npm-js" 4 | } 5 | 6 | kalix-proxy { 7 | image = "gcr.io/kalix-public/kalix-runtime:1.1.33" 8 | } 9 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/proto/action-service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "kalix/annotations.proto"; 4 | import "google/api/annotations.proto"; 5 | 6 | package com.example; 7 | 8 | option java_outer_classname = "MyAction"; 9 | 10 | message MyRequest { 11 | int32 value = 1; 12 | } 13 | 14 | message Response { 15 | int32 value = 1; 16 | } 17 | 18 | service MyActionService { 19 | option (kalix.service) = { 20 | type : SERVICE_TYPE_ACTION 21 | }; 22 | 23 | rpc SingleMethod(MyRequest) returns (Response); 24 | rpc StreamedMethod(MyRequest) returns (stream Response); 25 | } 26 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/proto/value-entity-domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example.domain; 4 | 5 | import "kalix/annotations.proto"; 6 | 7 | option java_outer_classname = "MyEntityDomain"; 8 | 9 | option (kalix.file).value_entity = { 10 | name: "MyEntity" 11 | entity_type: "my-entity-persistence" 12 | state: "MyState" 13 | }; 14 | 15 | message MyState { 16 | int32 value = 1; 17 | } 18 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/scripts/disable-download-cli.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const package = require(path.resolve(process.argv[2])); 3 | package.scripts.install = undefined; 4 | console.log(JSON.stringify(package, null, 2)); 5 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/scripts/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | echo "Codegen container is running!" 6 | echo "This process will continue to run until killed." 7 | echo "Use Docker exec or equivalent methods to test the codegen library." 8 | tail -f /dev/null 9 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/scripts/setup-entity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | pushd $1 6 | 7 | npm link @kalix-io/kalix-scripts 8 | npm install 9 | npm run build 10 | 11 | popd 12 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | # Set up and install our npm-js tooling 6 | pushd kalix-npm-js 7 | 8 | pushd kalix-scripts 9 | # Disable download of codegen CLI, and manually add our version 10 | mv package.json original-package.json 11 | node /home/scripts/disable-download-cli.js original-package.json > package.json 12 | cp /home/kalix-codegen-js bin/kalix-codegen-js.bin 13 | 14 | # Use npm link to make this available within the container 15 | npm install 16 | npm link 17 | popd 18 | 19 | pushd create-kalix-entity 20 | # Install create-kalix-entity globally within the container 21 | npm install 22 | npm pack 23 | npm i -g lightbend-create-kalix-entity-1.0.0.tgz 24 | popd 25 | 26 | popd 27 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/scripts/start-entity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | pushd $1 6 | node src/index.js > entity-logs.txt 2>&1 & 7 | echo $! > .kalix-pid 8 | 9 | popd 10 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/it/resources/scripts/stop-entity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | PID_FILE=$1/.kalix-pid 6 | 7 | if [ -f "$PID_FILE" ]; then 8 | kill $(cat "$PID_FILE") 9 | rm "$PID_FILE" 10 | fi -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/main/resources/jni-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name":"java.lang.ClassLoader", 4 | "methods":[ 5 | {"name":"getPlatformClassLoader","parameterTypes":[] }, 6 | {"name":"loadClass","parameterTypes":["java.lang.String"] } 7 | ] 8 | }, 9 | { 10 | "name":"java.lang.ClassNotFoundException" 11 | }, 12 | { 13 | "name":"java.lang.NoSuchMethodError" 14 | }, 15 | { 16 | "name":"java.lang.String" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/main/resources/proxy-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | ] 3 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/main/resources/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources":[], 3 | "bundles":[] 4 | } 5 | -------------------------------------------------------------------------------- /codegen/js-gen-cli/src/main/scala/io/netty/channel/socket/nio/NioServerSocketChannel.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Lightbend Inc. 2021 3 | * 4 | */ 5 | 6 | package io.netty.channel.socket.nio 7 | 8 | /** 9 | * Dummy class for gRPC reflection and native image building - which isn't being used. 10 | */ 11 | class NioServerSocketChannel {} 12 | -------------------------------------------------------------------------------- /codegen/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version = 1.8.2 2 | -------------------------------------------------------------------------------- /codegen/project/metals.sbt: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT! This file is auto-generated. 2 | // This file enables sbt-bloop to create bloop config files. 3 | 4 | addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.8-19-4d9f966b") 5 | -------------------------------------------------------------------------------- /codegen/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") 2 | addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.7.0") 3 | addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.5") 4 | addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.0") 5 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") 6 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") 7 | 8 | addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") 9 | 10 | libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.13" 11 | -------------------------------------------------------------------------------- /codegen/set-version.sh: -------------------------------------------------------------------------------- 1 | echo "ThisBuild / version := \"$(../sdk/bin/version.sh)\"" > version.sbt 2 | -------------------------------------------------------------------------------- /docs/.examplesignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | Dockerfile 3 | node_modules 4 | *.desc 5 | *.json 6 | *.md 7 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | /.cache/ 2 | /.deploy/ 3 | /build/ 4 | /dev/build/ 5 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # JavaScript SDK docs 2 | 3 | 4 | ## Building docs 5 | 6 | To build the docs, run `make` in the `docs` directory: 7 | 8 | ``` 9 | make 10 | ``` 11 | 12 | Dynamically-generated and managed sources will be created in `build/src/managed`. 13 | 14 | 15 | ## Deploying docs 16 | 17 | Docs are automatically published on releases. To deploy the docs manually run: 18 | 19 | ``` 20 | make deploy 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/bin/version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Version for docs, based on nearest git tag. 4 | # This is always a tagged/released version, not a dynamic version. 5 | 6 | readonly prefix="v" 7 | readonly tag=$(git describe --tags --abbrev=0 --match "$prefix[0-9]*" 2> /dev/null) 8 | [ -n "$tag" ] && echo "${tag#$prefix}" || echo "0.0.0" 9 | -------------------------------------------------------------------------------- /docs/config/validate-links.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignorePatterns": [ 3 | { "pattern": "^http://127.0.0.1:8080" }, 4 | { "pattern": "^https://www.npmjs.com/org/kalix-io", "why": "npmjs having a bad day 2022-06-07" } 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /docs/dev/antora.yml: -------------------------------------------------------------------------------- 1 | site: 2 | title: "Kalix Documentation" 3 | 4 | content: 5 | sources: 6 | - url: .. 7 | branches: [HEAD] 8 | start_paths: [docs/src, docs/build/src/managed, docs/dev/src] 9 | 10 | ui: 11 | bundle: 12 | url: https://lightbend.github.io/antora-supplemental-ui-lightbend-theme/default_ui/ui-bundle-1023155878.zip 13 | snapshot: true 14 | 15 | runtime: 16 | fetch: true 17 | 18 | asciidoc: 19 | attributes: 20 | review: '' 21 | todo: '' 22 | page-pagination: '' 23 | page-toctitle: 'On This Page' 24 | 25 | output: 26 | clean: true 27 | -------------------------------------------------------------------------------- /docs/dev/src/antora.yml: -------------------------------------------------------------------------------- 1 | name: "" 2 | version: master 3 | 4 | nav: 5 | - modules/javascript/nav.adoc 6 | -------------------------------------------------------------------------------- /docs/dev/src/modules/ROOT/images/new-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/dev/src/modules/ROOT/partials/grpc/using-acls.adoc: -------------------------------------------------------------------------------- 1 | // this is just a placeholder so we can compile sdk docs here 2 | // the real file can be found in kalix-docs repo -------------------------------------------------------------------------------- /docs/dev/src/modules/ROOT/partials/include.adoc: -------------------------------------------------------------------------------- 1 | :tab-icon: image:ROOT:new-tab.svg[width=12] 2 | :minimum_docker_version: 20.10.14 -------------------------------------------------------------------------------- /docs/src/antora.yml: -------------------------------------------------------------------------------- 1 | name: "" 2 | version: master 3 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/examples/domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example.shoppingcart.domain; 4 | 5 | message LineItem { 6 | string productId = 1; 7 | string name = 2; 8 | int32 quantity = 3; 9 | } 10 | 11 | message ItemAdded { 12 | LineItem item = 1; 13 | } 14 | 15 | message ItemRemoved { 16 | string productId = 1; 17 | } 18 | 19 | message CheckedOut {} 20 | 21 | message Cart { 22 | repeated LineItem items = 1; 23 | bool checkedout = 2; 24 | } 25 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/examples/shoppingcart.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/empty.proto"; 4 | import "kalix/annotations.proto"; 5 | 6 | package example.shoppingcart; 7 | 8 | service ShoppingCartService { 9 | rpc AddItem(AddLineItem) returns (google.protobuf.Empty); 10 | rpc RemoveItem(RemoveLineItem) returns (google.protobuf.Empty); 11 | rpc GetCart(GetShoppingCart) returns (Cart); 12 | } 13 | 14 | message AddLineItem { 15 | string user_id = 1 [(kalix.field).entity_key = true]; 16 | string product_id = 2; 17 | string name = 3; 18 | int32 quantity = 4; 19 | } 20 | 21 | message RemoveLineItem { 22 | string user_id = 1 [(kalix.field).entity_key = true]; 23 | string product_id = 2; 24 | } 25 | 26 | message GetShoppingCart { 27 | string user_id = 1 [(kalix.field).entity_key = true]; 28 | } 29 | 30 | message LineItem { 31 | string product_id = 1; 32 | string name = 2; 33 | int32 quantity = 3; 34 | } 35 | 36 | message Cart { 37 | repeated LineItem items = 1; 38 | } 39 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/examples/test/gettingstarted/index.js: -------------------------------------------------------------------------------- 1 | 2 | const should = require('chai').should(); 3 | 4 | describe("The Kalix class", () => { 5 | 6 | it("should allow creating and starting a server", () => { 7 | 8 | // tag::start[] 9 | const Kalix = require("@lightbend/kalix-javascript-sdk").Kalix; 10 | 11 | const server = new Kalix(); 12 | server.addComponent(require("./shoppingcart")); 13 | 14 | server.start(); 15 | // end::start[] 16 | 17 | server.shutdown(); 18 | }); 19 | 20 | it("should allow using a custom descriptor name", () => { 21 | const Kalix = require("@lightbend/kalix-javascript-sdk").Kalix; 22 | 23 | // tag::custom-desc[] 24 | const server = new Kalix({ 25 | descriptorSetPath: "my-descriptor.desc" 26 | }); 27 | // end::custom-desc[] 28 | 29 | }) 30 | }); 31 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/examples/test/gettingstarted/index.ts: -------------------------------------------------------------------------------- 1 | // tag::start[] 2 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 3 | import shoppingcartEntity from "./shoppingcart"; 4 | 5 | new Kalix().addComponent(shoppingcartEntity).start(); 6 | // end::start[] 7 | 8 | 9 | // tag::custom-desc[] 10 | new Kalix({ descriptorSetPath: "my-descriptor.desc" }); 11 | // end::custom-desc[] 12 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/examples/test/gettingstarted/shoppingcart.js: -------------------------------------------------------------------------------- 1 | const EventSourcedEntity = require("@kalix-io/kalix-javascript-sdk").EventSourcedEntity; 2 | const entity = new EventSourcedEntity("shoppingcart.proto", "example.ShoppingCartService"); 3 | entity.setInitial(() => {}); 4 | entity.setBehavior(() => { 5 | return { 6 | commandHandlers: {}, 7 | eventHandlers: {} 8 | }; 9 | }); 10 | module.exports = entity; 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/examples/value-entity/domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example.shoppingcart.domain; 4 | 5 | message LineItem { 6 | string productId = 1; 7 | string name = 2; 8 | int32 quantity = 3; 9 | } 10 | 11 | message Cart { 12 | repeated LineItem items = 1; 13 | } 14 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/nav.adoc: -------------------------------------------------------------------------------- 1 | ** xref:javascript:index.adoc[] 2 | *** xref:javascript:developer-tools.adoc[] 3 | *** xref:developing:development-process-js.adoc[] 4 | *** xref:javascript:kickstart.adoc[] 5 | *** xref:javascript:proto.adoc[] 6 | *** xref:javascript:running-locally.adoc[Running a service locally] 7 | *** xref:javascript:value-entity.adoc[Implementing Value Entities] 8 | *** xref:javascript:eventsourced.adoc[Implementing Event Sourced Entities] 9 | *** xref:javascript:replicated-entity.adoc[Implementing Replicated Entities] 10 | *** xref:javascript:views.adoc[Implementing Views] 11 | *** xref:javascript:actions.adoc[Implementing Actions] 12 | *** xref:javascript:forwarding.adoc[Forwarding and effects] 13 | *** xref:javascript:actions-publishing-subscribing.adoc[Publishing and Subscribing] 14 | *** xref:javascript:serialization.adoc[Handling Serialization] 15 | *** xref:javascript:call-another-service.adoc[Calling other services] 16 | *** xref:access-control.adoc[Access Control Lists (ACLs)] 17 | *** xref:javascript:api.adoc[JavaScript API docs] 18 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/pages/actions.adoc: -------------------------------------------------------------------------------- 1 | = Actions 2 | :page-supergroup-javascript-typescript: Language 3 | 4 | include::ROOT:partial$include.adoc[] 5 | include::partial$actions.adoc[] 6 | 7 | == Implementing Actions 8 | 9 | The following example shows a `.proto` file for an action: 10 | 11 | [source,proto] 12 | ---- 13 | include::example$action/service.proto[] 14 | ---- 15 | 16 | The following shows the implementation: 17 | 18 | [.tabset] 19 | JavaScript:: 20 | + 21 | [source,javascript] 22 | ---- 23 | include::example$action/src/action.js[] 24 | ---- 25 | 26 | TypeScript:: 27 | + 28 | [source,typescript] 29 | ---- 30 | include::example$action/src/action.ts[] 31 | ---- 32 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/pages/api.adoc: -------------------------------------------------------------------------------- 1 | = JavaScript API docs 2 | 3 | include::ROOT:partial$include.adoc[] 4 | 5 | The JavaScript API docs can be found link:{attachmentsdir}/api/index.html[here{tab-icon}, window="new"]. 6 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/pages/forwarding.adoc: -------------------------------------------------------------------------------- 1 | = Forwarding and effects in JavaScript 2 | 3 | include::ROOT:partial$include.adoc[] 4 | include::partial$forwarding.adoc[] 5 | 6 | ifdef::todo[TODO: add more complete examples.] 7 | 8 | == Forwarding a command 9 | 10 | ifdef::todo[TODO: update to use replies.forward instead of context.forward, with examples] 11 | 12 | The link:{attachmentsdir}/api/interfaces/CommandContext.html[`CommandContext`{tab-icon}, window="new"] can call the method link:{attachmentsdir}/api/interfaces/CommandContext.html#forward[`forward`{tab-icon}, window="new"] to forward the command to another entity service call. 13 | 14 | include::partial$forwarding-effects.adoc[] 15 | 16 | == Emitting an effect 17 | 18 | ifdef::todo[TODO: update to use Reply.addEffect instead of context.effect, with examples] 19 | 20 | The link:{attachmentsdir}/api/interfaces/CommandContext.html[`CommandContext`{tab-icon}, window="new"] for each entity type implements link:{attachmentsdir}/api/interfaces/EffectContext.html[`EffectContext`{tab-icon}, window="new"], which is able to emit an effect after processing the command by invoking the method link:{attachmentsdir}/api/interfaces/EffectContext.html#effect[`effect`{tab-icon}, window="new"] 21 | -------------------------------------------------------------------------------- /docs/src/modules/javascript/partials/pubsub-note.adoc: -------------------------------------------------------------------------------- 1 | [NOTE] 2 | ==== 3 | In the Protobuf descriptors, only topic names are referenced and no additional details about how to connect to the topics are needed. When deploying the application there must be a broker configuration in the Kalix project, with credentials and details on how connect to the broker. For details about configuring a broker see https://docs.kalix.io/projects/message-brokers.html[Configure message brokers] 4 | ==== -------------------------------------------------------------------------------- /docs/src/modules/javascript/partials/serialization.adoc: -------------------------------------------------------------------------------- 1 | 2 | include::ROOT:partial$include.adoc[] 3 | 4 | You do not need to handle serialization for messages. Kalix functions serve gRPC interfaces, and the input and output messages are `protobuf` messages that get serialized to the `protobuf` format. However, for objects to be persisted such as Event Sourced https://docs.kalix.io/reference/glossary.html#event[_events_] and https://docs.kalix.io/reference/glossary.html#snapshot[_snapshots_] you have a choice. 5 | 6 | By default, Kalix will automatically detect if an emitted event or snapshot is a `protobuf` and handle them correctly, so we recommend using the default behavior. However, if you have specific requirements, you also can choose between primitive type and JSON (JavaScript Object Notation) serialization. 7 | -------------------------------------------------------------------------------- /npm-js/README.md: -------------------------------------------------------------------------------- 1 | # kalix-npm-js 2 | 3 | This repository provides the `create-kalix-entity` tool to support Kalix development with the npm/JavaScript toolchain. 4 | 5 | Please navigate to each project's README to comprehend what is provided in detail. 6 | 7 | ## create-kalix-entity 8 | 9 | This command-line tool is used to initialise a new Kalix entity codebase. 10 | 11 | See this project's [README](create-kalix-entity/README.md) for more information. 12 | 13 | ## kalix-scripts 14 | 15 | This npm module provides the default `build`, `package` and `deploy` scripts for a Kalix codebase in a single managed package. 16 | 17 | See this project's [README](kalix-scripts/README.md) for more information. 18 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /kalix-*.tgz 3 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@kalix-io/create-kalix-entity", 3 | "version": "0.0.0", 4 | "description": "Create a Kalix entity codebase with a single command.", 5 | "main": "", 6 | "repository": "https://github.com/lightbend/kalix-javascript-sdk", 7 | "author": "Lightbend Inc", 8 | "license": "Copyright (c) Lightbend Inc. 2021", 9 | "engines": { 10 | "node": "~18", 11 | "npm": ">=6.0.0" 12 | }, 13 | "dependencies": { 14 | "mustache": "^4.1.0", 15 | "scaffold-generator": "^3.0.4", 16 | "yargs": "^17.0.1" 17 | }, 18 | "bin": { 19 | "create-kalix-entity": "create-kalix-entity.js" 20 | }, 21 | "scripts": { 22 | "prepublishOnly": "npm version --no-git-tag-version $(../../sdk/bin/version.sh)" 23 | }, 24 | "publishConfig": { 25 | "@kalix-io:registry": "https://registry.npmjs.org" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-common/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /dist 4 | /lib/generated 5 | /node_modules 6 | /README.md 7 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-common/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /lib/generated 3 | /node_modules 4 | /user-function.desc 5 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-common/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_FUNCTION_HOST: ${USER_FUNCTION_HOST:-host.docker.internal} 12 | USER_FUNCTION_PORT: ${USER_FUNCTION_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-js/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{name}}", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "{{sdkVersion}}" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "{{scriptsVersion}}", 14 | "@kalix-io/testkit": "{{testkitVersion}}", 15 | "chai": "^4.3.6", 16 | "mocha": "^10.0.0" 17 | }, 18 | "config": { 19 | "dockerImage": "my-docker-repo/{{name}}", 20 | "sourceDir": "./src", 21 | "testSourceDir": "./test", 22 | "protoSourceDir": "./proto", 23 | "generatedSourceDir": "./lib/generated", 24 | "compileDescriptorArgs": [] 25 | }, 26 | "scripts": { 27 | "start": "node src/index.js", 28 | "test": "mocha ./test", 29 | "build": "kalix-scripts build", 30 | "package": "kalix-scripts package", 31 | "deploy": "kalix-scripts deploy" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{name}}", 3 | "version": "0.0.1", 4 | "engines": { 5 | "node": "~18", 6 | "npm": ">=6.0.0" 7 | }, 8 | "dependencies": { 9 | "@kalix-io/kalix-javascript-sdk": "{{sdkVersion}}" 10 | }, 11 | "devDependencies": { 12 | "@kalix-io/kalix-scripts": "{{scriptsVersion}}", 13 | "@kalix-io/testkit": "{{testkitVersion}}", 14 | "@types/chai": "^4.3.1", 15 | "@types/mocha": "^9.1.1", 16 | "@types/node": "^18.16.0", 17 | "chai": "^4.3.6", 18 | "mocha": "^10.0.0", 19 | "ts-mocha": "^10.0.0", 20 | "typescript": "^4.7.4" 21 | }, 22 | "config": { 23 | "typescript": true, 24 | "dockerImage": "my-docker-repo/{{name}}", 25 | "sourceDir": "./src", 26 | "testSourceDir": "./test", 27 | "protoSourceDir": "./proto", 28 | "generatedSourceDir": "./lib/generated", 29 | "compileDescriptorArgs": [] 30 | }, 31 | "scripts": { 32 | "start": "node dist/src/index.js", 33 | "test": "ts-mocha test/**/*.test.ts", 34 | "build": "kalix-scripts build && tsc", 35 | "package": "kalix-scripts package", 36 | "deploy": "kalix-scripts deploy" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/base-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "strictFunctionTypes": true, 6 | "target": "es6", 7 | "module": "commonJS" 8 | }, 9 | "include": ["./src/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/basic/README.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/event-sourced-entity/proto/counter_domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example.domain; 4 | 5 | message CounterState { 6 | int32 value = 1; 7 | } 8 | 9 | message ValueIncreased { 10 | int32 value = 1; 11 | } 12 | 13 | message ValueDecreased { 14 | int32 value = 1; 15 | } 16 | 17 | message ValueReset {} 18 | -------------------------------------------------------------------------------- /npm-js/create-kalix-entity/template/value-entity/proto/counter_domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example.domain; 4 | 5 | message CounterState { 6 | int32 value = 1; 7 | } 8 | -------------------------------------------------------------------------------- /npm-js/kalix-scripts/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /kalix-*.tgz 3 | *.bin 4 | -------------------------------------------------------------------------------- /npm-js/kalix-scripts/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /npm-js/kalix-scripts/README.md: -------------------------------------------------------------------------------- 1 | # kalix-scripts 2 | 3 | This package includes scripts and configuration used by the [`create-kalix-entity` tool](../create-kalix-entity). 4 | 5 | Configuration is pulled from the `config` section of your project's `package.json`, and the command will fail if any required configuration is not present. For example: 6 | 7 | ```json 8 | { 9 | ... 10 | "config": { 11 | "dockerImage": "my-docker-repo/my-image", 12 | "sourceDir": "./src", 13 | "testSourceDir": "./test", 14 | "protoSourceDir": "./proto", 15 | "generatedSourceDir": "./lib/generated", 16 | "compileDescriptorArgs": [] 17 | }, 18 | ... 19 | } 20 | ``` 21 | 22 | ## Install 23 | 24 | On install, this downloads the latest version of the JavaScript [codegen CLI](../../codegen) 25 | 26 | ## Scripts 27 | 28 | ### Build 29 | 30 | - Builds Protobuf descriptor file 31 | - Runs Kalix JS codegen 32 | 33 | ### Package 34 | 35 | - Builds Docker image of the service 36 | 37 | ### Deploy 38 | 39 | - Deploys Docker image to specified repository 40 | - Invokes Kalix deploy via `kalix` CLI 41 | -------------------------------------------------------------------------------- /npm-js/kalix-scripts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@kalix-io/kalix-scripts", 3 | "version": "0.0.0", 4 | "description": "Create a Kalix entity codebase with a single command.", 5 | "main": "kalix-scripts.js", 6 | "repository": "https://github.com/lightbend/kalix-javascript-sdk", 7 | "author": "Lightbend Inc", 8 | "license": "Copyright (c) Lightbend Inc. 2021", 9 | "engines": { 10 | "node": "~18", 11 | "npm": ">=6.0.0" 12 | }, 13 | "dependencies": { 14 | "axios": "^0.27.2", 15 | "cross-spawn": "^7.0.3", 16 | "protobufjs": "6.11.4" 17 | }, 18 | "bin": { 19 | "kalix-scripts": "./bin/kalix-scripts.js" 20 | }, 21 | "scripts": { 22 | "install": "node bin/download-codegen.js", 23 | "prepublishOnly": "npm version --no-git-tag-version $(../../sdk/bin/version.sh)" 24 | }, 25 | "publishConfig": { 26 | "@kalix-io:registry": "https://registry.npmjs.org" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kalix-javascript-sdk", 3 | "devDependencies": { 4 | "@typescript-eslint/eslint-plugin": "^5.4.0", 5 | "@typescript-eslint/parser": "^5.4.0", 6 | "eslint": "^8.33.0", 7 | "eslint-config-prettier": "^8.3.0", 8 | "eslint-plugin-prettier": "^3.4.0", 9 | "license-check-and-add": "^4.0.2", 10 | "prettier": "^2.3.1", 11 | "typescript": "^4.9.5" 12 | }, 13 | "scripts": { 14 | "license-check": "license-check-and-add check -f build/license.json", 15 | "license-add": "license-check-and-add add -f build/license.json", 16 | "prettier-format": "prettier --config .prettierrc 'sdk/**/*.{js,ts}' 'testkit/**/*.{js,ts}' 'tck/**/*.{js,ts}' 'npm-js/**/*.{js,ts}' --write", 17 | "prettier-check": "prettier --config .prettierrc 'sdk/**/*.{js,ts}' 'testkit/**/*.{js,ts}' 'tck/**/*.{js,ts}' 'npm-js/**/*.{js,ts}' --check", 18 | "lint-fix": "eslint sdk/ --ext .ts --fix", 19 | "lint-check": "eslint sdk/ --ext .ts" 20 | }, 21 | "eslintConfig": { 22 | "env": { 23 | "node": true, 24 | "mocha": true 25 | } 26 | }, 27 | "dependencies": { 28 | "test": "^3.3.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/.gitignore: -------------------------------------------------------------------------------- 1 | .npm 2 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/.bundleignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | lib 3 | node_modules 4 | package-lock.json 5 | user-function.desc 6 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/.dockerignore: -------------------------------------------------------------------------------- 1 | /README.md 2 | /docker-compose.yml 3 | /lib/generated 4 | /node_modules 5 | /user-function.desc 6 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/.gitignore: -------------------------------------------------------------------------------- 1 | /lib/generated 2 | /node_modules 3 | /user-function.desc 4 | # test quickstarts without lock file 5 | /package-lock.json 6 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "customer-registry", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "^1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "^1.1.0", 14 | "@kalix-io/testkit": "^1.1.0", 15 | "chai": "^4.3.6", 16 | "mocha": "^10.0.0" 17 | }, 18 | "config": { 19 | "dockerImage": "my-docker-repo/customer-registry", 20 | "sourceDir": "./src", 21 | "testSourceDir": "./test", 22 | "integrationTestSourceDir": "./integration-test", 23 | "protoSourceDir": "./proto", 24 | "generatedSourceDir": "./lib/generated", 25 | "compileDescriptorArgs": [] 26 | }, 27 | "scripts": { 28 | "start": "node src/index.js", 29 | "test": "mocha ./test", 30 | "integration-test": "mocha ./integration-test", 31 | "build": "kalix-scripts build", 32 | "package": "kalix-scripts package", 33 | "deploy": "kalix-scripts deploy" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/proto/customer_domain.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // tag::declarations[] 16 | syntax = "proto3"; 17 | 18 | package customer.domain; 19 | // end::declarations[] 20 | 21 | // tag::domain[] 22 | message CustomerState { 23 | string customer_id = 1; 24 | string email = 2; 25 | string name = 3; 26 | Address address = 4; 27 | } 28 | 29 | message Address { 30 | string street = 1; 31 | string city = 2; 32 | } 33 | // end::domain[] 34 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/proto/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Default access control for all components of this Kalix Service 16 | 17 | syntax = "proto3"; 18 | 19 | package com.example; 20 | 21 | import "kalix/annotations.proto"; 22 | 23 | // only allow access from other services in the same project by default 24 | option (kalix.file).acl = { 25 | allow: { service: "*" } 26 | }; 27 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry-quickstart/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import generatedComponents from "../lib/generated/index.js"; 19 | 20 | const server = new Kalix(); 21 | 22 | // This generatedComponents array contains all generated Actions, Views or Entities, 23 | // and is kept up-to-date with any changes in your protobuf definitions. 24 | // If you prefer, you may remove this line and manually register these components. 25 | generatedComponents.forEach((component) => { 26 | server.addComponent(component); 27 | }); 28 | 29 | server.start(); 30 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry/.bundleignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | user-function.desc 4 | .* 5 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | WORKDIR /home/node 3 | RUN apt-get update && apt-get install -y curl unzip 4 | COPY sdk sdk 5 | RUN cd sdk && npm ci && npm run prepare 6 | RUN cd sdk && npm prune --production 7 | COPY samples/js/js-customer-registry/package*.json samples/js/js-customer-registry/ 8 | RUN cd samples/js/js-customer-registry && npm ci 9 | COPY samples/js/js-customer-registry samples/js/js-customer-registry 10 | RUN cd samples/js/js-customer-registry && npm run build 11 | RUN cd samples/js/js-customer-registry && npm prune --production 12 | 13 | FROM node:18-bookworm-slim 14 | COPY --from=builder --chown=node /home/node /home/node 15 | WORKDIR /home/node/samples/js/js-customer-registry 16 | USER node 17 | ENV NODE_ENV production 18 | EXPOSE 8080 19 | CMD ["node", "index.js"] 20 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry/customer-value-entity-view.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // tag::register[] 18 | const View = require("@kalix-io/kalix-javascript-sdk").View; 19 | 20 | const view = new View( 21 | ["customer_view.proto", "customer_domain.proto"], 22 | "customer.view.CustomersResponseByName", 23 | { 24 | viewId: "response-by-name" 25 | } 26 | ); 27 | 28 | module.exports = view; 29 | // end::register[] 30 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-customer-registry/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This is the default ACLs for all components of this Kalix Service 16 | syntax = "proto3"; 17 | 18 | package com.example; 19 | 20 | import "kalix/annotations.proto"; 21 | 22 | // only allow access from other services in the same project by default 23 | option (kalix.file).acl = { 24 | allow: { service: "*" } 25 | }; -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.ts -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/README.md: -------------------------------------------------------------------------------- 1 | # Misc documentation snippets 2 | 3 | This project is only for documentation purposes. It is only compiled. 4 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-doc-snippets", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "1.1.0", 14 | "@kalix-io/testkit": "1.1.0", 15 | "chai": "^4.3.6", 16 | "jsdoc": "^3.6.10", 17 | "mocha": "^10.0.0", 18 | "uglify-js": "^3.16.1" 19 | }, 20 | "config": { 21 | "dockerImage": "gcr.io/kalix-public/samples-js-doc-snippets", 22 | "sourceDir": "./src", 23 | "testSourceDir": "./test", 24 | "protoSourceDir": "./proto", 25 | "generatedSourceDir": "./lib/generated", 26 | "compileDescriptorArgs": [] 27 | }, 28 | "scripts": { 29 | "start": "node src/index.js", 30 | "test": "mocha ./test", 31 | "integration-test": "mocha ./integration-test", 32 | "test-all": "npm run test && npm run integration-test", 33 | "build": "kalix-scripts build", 34 | "package": "kalix-scripts package", 35 | "deploy": "kalix-scripts deploy" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/proto/com/example/counter_api.proto: -------------------------------------------------------------------------------- 1 | // This is the public API of other service, 2 | // tag::other-service-api[] 3 | syntax = "proto3"; 4 | 5 | package com.example; 6 | 7 | import "google/protobuf/empty.proto"; 8 | 9 | message IncreaseValue { 10 | string counter_id = 1; 11 | int32 value = 2; 12 | } 13 | 14 | message DecreaseValue { 15 | string counter_id = 1; 16 | int32 value = 2; 17 | } 18 | 19 | message ResetValue { 20 | string counter_id = 1; 21 | } 22 | 23 | message GetCounter { 24 | string counter_id = 1; 25 | } 26 | 27 | message CurrentCounter { 28 | int32 value = 1; 29 | } 30 | 31 | service CounterService { 32 | rpc Increase (IncreaseValue) returns (google.protobuf.Empty); 33 | rpc Decrease (DecreaseValue) returns (google.protobuf.Empty); 34 | rpc Reset (ResetValue) returns (google.protobuf.Empty); 35 | rpc GetCurrentCounter (GetCounter) returns (CurrentCounter); 36 | } 37 | // end::other-service-api[] 38 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/proto/com/example/delegating_service.proto: -------------------------------------------------------------------------------- 1 | // The public API of our service 2 | syntax = "proto3"; 3 | 4 | package com.example; 5 | 6 | // tag::service[] 7 | import "kalix/annotations.proto"; 8 | 9 | message Request { 10 | string counter_id = 1; 11 | } 12 | 13 | message Result { 14 | int32 value = 1; 15 | } 16 | 17 | service DelegatingService { 18 | option (kalix.service) = { 19 | type : SERVICE_TYPE_ACTION 20 | }; 21 | 22 | rpc AddAndReturn(Request) returns (Result); 23 | } 24 | // end::service[] 25 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/proto/com/example/json/json_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package com.example.json; 3 | 4 | // tag::service[] 5 | import "google/protobuf/any.proto"; 6 | import "google/protobuf/empty.proto"; 7 | import "kalix/annotations.proto"; 8 | 9 | message KeyValue { 10 | string key = 1; 11 | int32 value = 2; 12 | } 13 | 14 | service MyService { 15 | option (kalix.codegen) = { 16 | action: {} 17 | }; 18 | 19 | rpc Consume(google.protobuf.Any) returns (google.protobuf.Empty) { 20 | option (kalix.method).eventing.in = { 21 | topic: "notifications" 22 | }; 23 | } 24 | 25 | rpc Produce(KeyValue) returns (google.protobuf.Any) { // <1> 26 | option (kalix.method).eventing.out = { // <2> 27 | topic: "notifications" // <3> 28 | }; 29 | } 30 | 31 | } 32 | // end::service[] 33 | -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/proto/com/example/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // This is the default ACLs for all components of this Kalix Service 2 | // tag::default[] 3 | syntax = "proto3"; 4 | 5 | package com.example; 6 | 7 | import "kalix/annotations.proto"; // <1> 8 | 9 | option (kalix.file).acl = { 10 | allow: { service: "*" } // <2> 11 | }; 12 | // end::default[] -------------------------------------------------------------------------------- /samples/js/js-doc-snippets/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import generatedComponents from "../lib/generated/index.js"; 19 | 20 | const server = new Kalix(); 21 | 22 | generatedComponents.forEach((component) => { 23 | server.addComponent(component); 24 | }); 25 | 26 | server.start(); 27 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/.bundleignore: -------------------------------------------------------------------------------- 1 | lib/generated 2 | node_modules 3 | package-lock.json 4 | user-function.desc 5 | .* 6 | 7 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.ts -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | The samples are published as Docker images to `grc.io/kalix-public`. 4 | 5 | To publish the images, ensure that you have the right permissions and configure `gcloud` to connect 6 | 7 | ```shell 8 | # needs to be done if not logged in 9 | gcloud auth login 10 | # needs to be done once 11 | gcloud auth configure-docker 12 | ``` 13 | 14 | ```shell 15 | # build the docker image 16 | npm run package 17 | ``` 18 | 19 | ```shell 20 | # push it to docker registry 21 | docker push gcr.io/kalix-public/samples-js-event-sourced-entity-shopping-cart:0.0.1 22 | ``` 23 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-eventsourced-shopping-cart", 3 | "version": "0.0.2", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "1.1.0", 14 | "@kalix-io/testkit": "1.1.0", 15 | "chai": "^4.3.6", 16 | "jsdoc": "^3.6.10", 17 | "mocha": "^10.0.0", 18 | "uglify-js": "^3.16.1" 19 | }, 20 | "config": { 21 | "dockerImage": "gcr.io/kalix-public/samples-js-event-sourced-shopping-cart", 22 | "sourceDir": "./src", 23 | "testSourceDir": "./test", 24 | "protoSourceDir": "./proto", 25 | "generatedSourceDir": "./lib/generated", 26 | "compileDescriptorArgs": [] 27 | }, 28 | "scripts": { 29 | "start": "node src/index.js", 30 | "test": "mocha ./test", 31 | "integration-test": "mocha ./integration-test", 32 | "test-all": "npm run test && npm run integration-test", 33 | "build": "kalix-scripts build", 34 | "package": "kalix-scripts package", 35 | "deploy": "kalix-scripts deploy" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/js/js-eventsourced-shopping-cart/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::imports[] 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import generatedComponents from "../lib/generated/index.js"; 19 | // end::imports[] 20 | // tag::server[] 21 | const server = new Kalix(); 22 | 23 | generatedComponents.forEach((component) => { 24 | server.addComponent(component); 25 | }); 26 | 27 | server.start(); 28 | // end::server[] -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-example/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-example/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-example/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | WORKDIR /home/node 3 | RUN apt-get update && apt-get install -y curl unzip 4 | COPY sdk sdk 5 | RUN cd sdk && npm ci && npm run prepare 6 | RUN cd sdk && npm prune --production 7 | COPY samples/js/js-replicated-entity-example/package*.json samples/js/js-replicated-entity-example/ 8 | RUN cd samples/js/js-replicated-entity-example && npm ci 9 | COPY samples/js/js-replicated-entity-example samples/js/js-replicated-entity-example 10 | RUN cd samples/js/js-replicated-entity-example && npm run build 11 | RUN cd samples/js/js-replicated-entity-example && npm prune --production 12 | 13 | FROM node:18-bookworm-slim 14 | COPY --from=builder --chown=node /home/node /home/node 15 | WORKDIR /home/node/samples/js/js-replicated-entity-example 16 | USER node 17 | ENV NODE_ENV production 18 | EXPOSE 8080 19 | CMD ["node", "index.js"] 20 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-example/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const Kalix = require("@kalix-io/kalix-javascript-sdk").Kalix; 18 | 19 | const server = new Kalix(); 20 | 21 | server.addComponent(require("./replicated-entity-example")); 22 | 23 | server.start(); 24 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.ts 6 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | The samples are published as Docker images to `grc.io/kalix-public`. 4 | 5 | To publish the images, ensure that you have the right permissions and configure `gcloud` to connect 6 | 7 | ```shell 8 | # needs to be done if not logged in 9 | gcloud auth login 10 | # needs to be done once 11 | gcloud auth configure-docker 12 | ``` 13 | 14 | ```shell 15 | # build the docker image 16 | npm run package 17 | ``` 18 | 19 | ```shell 20 | # push it to docker registry 21 | docker push gcr.io/kalix-public/samples-js-replicated-entity-shopping-cart:0.0.1 22 | ``` 23 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-replicated-entity-shopping-cart", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "1.1.0", 14 | "@kalix-io/testkit": "1.1.0", 15 | "chai": "^4.3.6", 16 | "chai-as-promised": "^7.1.1", 17 | "jsdoc": "^3.6.10", 18 | "mocha": "^10.0.0", 19 | "uglify-js": "^3.16.1" 20 | }, 21 | "config": { 22 | "dockerImage": "gcr.io/kalix-public/samples-js-replicated-entity-shopping-cart", 23 | "sourceDir": "./src", 24 | "testSourceDir": "./test", 25 | "protoSourceDir": "./proto", 26 | "generatedSourceDir": "./lib/generated", 27 | "compileDescriptorArgs": [] 28 | }, 29 | "scripts": { 30 | "start": "node src/index.js", 31 | "test": "mocha ./test", 32 | "integration-test": "mocha ./integration-test", 33 | "build": "kalix-scripts build", 34 | "package": "kalix-scripts package", 35 | "deploy": "kalix-scripts deploy" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/js/js-replicated-entity-shopping-cart/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // tag::register[] 18 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 19 | import shoppingcart from "./shoppingcart.js"; 20 | 21 | new Kalix() // <1> 22 | .addComponent(shoppingcart) // <2> 23 | .start(); // <3> 24 | // end::register[] 25 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/.bundleignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | lib 3 | node_modules 4 | package-lock.json 5 | user-function.desc 6 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/.dockerignore: -------------------------------------------------------------------------------- 1 | /README.md 2 | /docker-compose.yml 3 | /lib/generated 4 | /node_modules 5 | /user-function.desc 6 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/.gitignore: -------------------------------------------------------------------------------- 1 | /lib/generated 2 | /node_modules 3 | /user-function.desc 4 | # test quickstarts without lock file 5 | /package-lock.json 6 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shopping-cart", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "^1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "^1.1.0", 14 | "@kalix-io/testkit": "^1.1.0", 15 | "chai": "^4.3.6", 16 | "mocha": "^10.0.0" 17 | }, 18 | "config": { 19 | "dockerImage": "my-docker-repo/shopping-cart", 20 | "sourceDir": "./src", 21 | "testSourceDir": "./test", 22 | "integrationTestSourceDir": "./integration-test", 23 | "protoSourceDir": "./proto", 24 | "generatedSourceDir": "./lib/generated", 25 | "compileDescriptorArgs": [] 26 | }, 27 | "scripts": { 28 | "start": "node src/index.js", 29 | "test": "mocha ./test", 30 | "integration-test": "mocha ./integration-test", 31 | "build": "kalix-scripts build", 32 | "package": "kalix-scripts package", 33 | "deploy": "kalix-scripts deploy" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/proto/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Default access control for all components of this Kalix Service 16 | 17 | syntax = "proto3"; 18 | 19 | package com.example; 20 | 21 | import "kalix/annotations.proto"; 22 | 23 | // only allow access from other services in the same project by default 24 | option (kalix.file).acl = { 25 | allow: { service: "*" } 26 | }; 27 | -------------------------------------------------------------------------------- /samples/js/js-shopping-cart-quickstart/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import generatedComponents from "../lib/generated/index.js"; 19 | 20 | const server = new Kalix(); 21 | 22 | // This generatedComponents array contains all generated Actions, Views or Entities, 23 | // and is kept up-to-date with any changes in your protobuf definitions. 24 | // If you prefer, you may remove this line and manually register these components. 25 | generatedComponents.forEach((component) => { 26 | server.addComponent(component); 27 | }); 28 | 29 | server.start(); 30 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.ts -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | The samples are published as Docker images to `grc.io/kalix-public`. 4 | 5 | To publish the images, ensure that you have the right permissions and configure `gcloud` to connect 6 | 7 | ```shell 8 | # needs to be done if not logged in 9 | gcloud auth login 10 | # needs to be done once 11 | gcloud auth configure-docker 12 | ``` 13 | 14 | ```shell 15 | # build the docker image 16 | npm run package 17 | ``` 18 | 19 | ```shell 20 | # push it to docker registry 21 | docker push gcr.io/kalix-public/samples-js-value-entity-shopping-cart:0.0.1 22 | ``` 23 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-valueentity-shopping-cart", 3 | "version": "0.0.4", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "1.1.0", 14 | "@kalix-io/testkit": "1.1.0", 15 | "chai": "^4.3.6", 16 | "jsdoc": "^3.6.10", 17 | "mocha": "^10.0.0", 18 | "uglify-js": "^3.16.1" 19 | }, 20 | "config": { 21 | "dockerImage": "gcr.io/kalix-public/samples-js-value-entity-shopping-cart", 22 | "sourceDir": "./src", 23 | "testSourceDir": "./test", 24 | "protoSourceDir": "./proto", 25 | "generatedSourceDir": "./lib/generated", 26 | "compileDescriptorArgs": [] 27 | }, 28 | "scripts": { 29 | "start": "node src/index.js", 30 | "test": "mocha ./test", 31 | "integration-test": "mocha ./integration-test", 32 | "build": "kalix-scripts build", 33 | "package": "kalix-scripts package", 34 | "deploy": "kalix-scripts deploy" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/proto/shoppingcart_domain.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // These are the messages that get persisted - the current state (Cart). 16 | 17 | // tag::proto_syntax[] 18 | syntax = "proto3"; 19 | // end::proto_syntax[] 20 | 21 | package com.example.shoppingcart.domain; 22 | 23 | // tag::proto_messages[] 24 | message LineItem { 25 | string productId = 1; 26 | string name = 2; 27 | int32 quantity = 3; 28 | } 29 | 30 | // The shopping cart state. 31 | message Cart { 32 | repeated LineItem items = 1; 33 | } 34 | // end::proto_messages[] 35 | -------------------------------------------------------------------------------- /samples/js/js-valueentity-shopping-cart/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import generatedComponents from "../lib/generated/index.js"; 19 | 20 | const server = new Kalix(); 21 | 22 | generatedComponents.forEach((component) => { 23 | server.addComponent(component); 24 | }); 25 | 26 | server.start(); 27 | -------------------------------------------------------------------------------- /samples/js/js-views-example/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | -------------------------------------------------------------------------------- /samples/js/js-views-example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | WORKDIR /home/node 3 | RUN apt-get update && apt-get install -y curl unzip 4 | COPY sdk sdk 5 | RUN cd sdk && npm ci && npm run prepare 6 | RUN cd sdk && npm prune --production 7 | COPY samples/js/js-views-example/package*.json samples/js/js-views-example/ 8 | RUN cd samples/js/js-views-example && npm ci 9 | COPY samples/js/js-views-example samples/js/js-views-example 10 | RUN cd samples/js/js-views-example && npm run build 11 | RUN cd samples/js/js-views-example && npm prune --production 12 | 13 | FROM node:18-bookworm-slim 14 | COPY --from=builder --chown=node /home/node /home/node 15 | WORKDIR /home/node/samples/js/js-views-example 16 | USER node 17 | ENV NODE_ENV production 18 | EXPOSE 8080 19 | CMD ["node", "index.js"] 20 | -------------------------------------------------------------------------------- /samples/js/js-views-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/js-views-example/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const Kalix = require("@kalix-io/kalix-javascript-sdk").Kalix; 18 | 19 | const server = new Kalix(); 20 | server.addComponent(require("./users")); 21 | server.addComponent(require("./users-by-email")); 22 | server.addComponent(require("./user-email-count")); 23 | 24 | server.start(); 25 | -------------------------------------------------------------------------------- /samples/js/js-views-example/users-by-email.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const View = require("@kalix-io/kalix-javascript-sdk").View; 18 | 19 | const entity = new View( 20 | ["users.proto"], 21 | "example.users.UsersByEmail", 22 | { 23 | viewId: "users-by-email" 24 | } 25 | ); 26 | 27 | module.exports = entity; 28 | -------------------------------------------------------------------------------- /samples/js/valueentity-counter/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.ts -------------------------------------------------------------------------------- /samples/js/valueentity-counter/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /samples/js/valueentity-counter/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/js/valueentity-counter/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonJS", 4 | "target": "es6", 5 | "checkJs": true 6 | }, 7 | "strict": true, 8 | "exclude": ["lib/generated/proto.js"], 9 | "include": ["src/**/*", "lib/**/*", "test/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/js/valueentity-counter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "valueentity-counter", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "engines": { 6 | "node": "~18", 7 | "npm": ">=6.0.0" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "1.1.0" 11 | }, 12 | "devDependencies": { 13 | "@kalix-io/kalix-scripts": "1.1.0", 14 | "@kalix-io/testkit": "1.1.0", 15 | "chai": "^4.3.6", 16 | "jsdoc": "^3.6.10", 17 | "mocha": "^10.0.0", 18 | "uglify-js": "^3.16.1" 19 | }, 20 | "config": { 21 | "dockerImage": "my-docker-repo/valueentity-counter", 22 | "sourceDir": "./src", 23 | "testSourceDir": "./test", 24 | "protoSourceDir": "./proto", 25 | "generatedSourceDir": "./lib/generated", 26 | "compileDescriptorArgs": [] 27 | }, 28 | "scripts": { 29 | "start": "node src/index.js", 30 | "test": "mocha ./test", 31 | "integration-test": "mocha ./integration-test", 32 | "build": "kalix-scripts build", 33 | "package": "kalix-scripts package", 34 | "deploy": "kalix-scripts deploy" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /samples/js/valueentity-counter/proto/counter_domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example.domain; // <1> 4 | 5 | message CounterState { // <2> 6 | int32 value = 1; 7 | } 8 | -------------------------------------------------------------------------------- /samples/js/valueentity-counter/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // tag::starting[] 18 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 19 | import generatedComponents from "../lib/generated/index.js"; 20 | 21 | const server = new Kalix(); 22 | 23 | generatedComponents.forEach((component) => { 24 | server.addComponent(component); 25 | }); 26 | 27 | server.start(); 28 | // end::starting[] 29 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/.bundleignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | dist 3 | lib 4 | node_modules 5 | package-lock.json 6 | user-function.desc 7 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/.dockerignore: -------------------------------------------------------------------------------- 1 | /README.md 2 | /dist 3 | /docker-compose.yml 4 | /lib/generated 5 | /node_modules 6 | /user-function.desc 7 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /lib/generated 3 | /node_modules 4 | /user-function.desc 5 | # test quickstarts without lock file 6 | /package-lock.json 7 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/proto/customer_domain.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // tag::declarations[] 16 | syntax = "proto3"; 17 | 18 | package customer.domain; 19 | // end::declarations[] 20 | 21 | // tag::domain[] 22 | message CustomerState { 23 | string customer_id = 1; 24 | string email = 2; 25 | string name = 3; 26 | Address address = 4; 27 | } 28 | 29 | message Address { 30 | string street = 1; 31 | string city = 2; 32 | } 33 | // end::domain[] 34 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/proto/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Default access control for all components of this Kalix Service 16 | 17 | syntax = "proto3"; 18 | 19 | package com.example; 20 | 21 | import "kalix/annotations.proto"; 22 | 23 | // only allow access from other services in the same project by default 24 | option (kalix.file).acl = { 25 | allow: { service: "*" } 26 | }; 27 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry-quickstart/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "strictFunctionTypes": true, 6 | "target": "es6", 7 | "module": "commonJS" 8 | }, 9 | "include": ["./src/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/.bundleignore: -------------------------------------------------------------------------------- 1 | dist 2 | lib/generated 3 | node_modules 4 | package-lock.json 5 | user-function.desc 6 | .* 7 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | dist/ 4 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "arrowParens": "avoid" 4 | } 5 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | WORKDIR /home/node 3 | RUN apt-get update && apt-get install -y curl unzip 4 | COPY samples/ts/ts-customer-registry/package*.json samples/ts/ts-customer-registry/ 5 | RUN cd samples/ts/ts-customer-registry && npm ci 6 | COPY samples/ts/ts-customer-registry samples/ts/ts-customer-registry 7 | RUN cd samples/ts/ts-customer-registry && npm run build 8 | RUN cd samples/ts/ts-customer-registry && npm prune --production 9 | 10 | FROM node:18-bookworm-slim 11 | COPY --from=builder --chown=node /home/node /home/node 12 | WORKDIR /home/node/samples/ts/ts-customer-registry 13 | USER node 14 | ENV NODE_ENV production 15 | EXPOSE 8080 16 | CMD ["node", "dist/index.js"] 17 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This is the default ACLs for all components of this Kalix Service 16 | syntax = "proto3"; 17 | 18 | package com.example; 19 | 20 | import "kalix/annotations.proto"; 21 | 22 | // only allow access from other services in the same project by default 23 | option (kalix.file).acl = { 24 | allow: { service: "*" } 25 | }; -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/src/customer-value-entity-view.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // tag::register[] 18 | import { View } from "@kalix-io/kalix-javascript-sdk"; 19 | 20 | const view: View = new View( 21 | ["customer_view.proto", "customer_domain.proto"], 22 | "customer.view.CustomersResponseByName", 23 | { 24 | viewId: "response-by-name" 25 | } 26 | ); 27 | 28 | export default view; 29 | // end::register[] 30 | -------------------------------------------------------------------------------- /samples/ts/ts-customer-registry/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "target": "es6", 6 | "module": "commonJS" 7 | }, 8 | "include": ["./src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/.bundleignore: -------------------------------------------------------------------------------- 1 | dist 2 | lib/generated 3 | node_modules 4 | package-lock.json 5 | user-function.desc 6 | .* 7 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.js -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | dist/ 4 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "arrowParens": "avoid" 4 | } 5 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | The samples are published as Docker images to `grc.io/kalix-public`. 4 | 5 | To publish the images, ensure that you have the right permissions and configure `gcloud` to connect 6 | 7 | ```shell 8 | # needs to be done if not logged in 9 | gcloud auth login 10 | # needs to be done once 11 | gcloud auth configure-docker 12 | ``` 13 | 14 | ```shell 15 | # build the docker image 16 | npm run package 17 | ``` 18 | 19 | ```shell 20 | # push it to docker registry 21 | docker push gcr.io/kalix-public/samples-ts-event-sourced-entity-shopping-cart:0.0.1 22 | ``` 23 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import shoppingcartEntity from "./shoppingcart"; 19 | 20 | new Kalix().addComponent(shoppingcartEntity).start(); 21 | -------------------------------------------------------------------------------- /samples/ts/ts-eventsourced-shopping-cart/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "strictFunctionTypes": true, 6 | "target": "es6", 7 | "module": "commonJS" 8 | }, 9 | "include": ["./src/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | dist/ 4 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "arrowParens": "avoid" 4 | } 5 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | WORKDIR /home/node 3 | RUN apt-get update && apt-get install -y curl unzip 4 | COPY samples/ts/ts-replicated-entity-example/package*.json samples/ts/ts-replicated-entity-example/ 5 | RUN cd samples/ts/ts-replicated-entity-example && npm ci 6 | COPY samples/ts/ts-replicated-entity-example samples/ts/ts-replicated-entity-example 7 | RUN cd samples/ts/ts-replicated-entity-example && npm run build 8 | RUN cd samples/ts/ts-replicated-entity-example && npm prune --production 9 | 10 | FROM node:18-bookworm-slim 11 | COPY --from=builder --chown=node /home/node /home/node 12 | WORKDIR /home/node/samples/ts/ts-replicated-entity-example 13 | USER node 14 | ENV NODE_ENV production 15 | EXPOSE 8080 16 | CMD ["node", "dist/index.js"] 17 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import replicatedEntity from "./replicated-entity-example"; 19 | 20 | new Kalix().addComponent(replicatedEntity).start(); 21 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "target": "es6", 6 | "module": "commonJS" 7 | }, 8 | "include": ["./src/**/*"] 9 | } -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.js 6 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/generated/ 3 | user-function.desc 4 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "arrowParens": "avoid" 4 | } 5 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | The samples are published as Docker images to `grc.io/kalix-public`. 4 | 5 | To publish the images, ensure that you have the right permissions and configure `gcloud` to connect 6 | 7 | ```shell 8 | # needs to be done if not logged in 9 | gcloud auth login 10 | # needs to be done once 11 | gcloud auth configure-docker 12 | ``` 13 | 14 | ```shell 15 | # build the docker image 16 | npm run package 17 | ``` 18 | 19 | ```shell 20 | # push it to docker registry 21 | docker push gcr.io/kalix-public/samples-ts-replicated-entity-shopping-cart:0.0.1 22 | ``` 23 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // tag::register[] 18 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 19 | import shoppingcart from "./shoppingcart.js"; 20 | 21 | new Kalix() // <1> 22 | .addComponent(shoppingcart) // <2> 23 | .start(); // <3> 24 | // end::register[] 25 | -------------------------------------------------------------------------------- /samples/ts/ts-replicated-entity-shopping-cart/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "target": "es6", 6 | "module": "commonJS" 7 | }, 8 | "include": ["./src/**/*"] 9 | } -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/.bundleignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | dist 3 | lib 4 | node_modules 5 | package-lock.json 6 | user-function.desc 7 | -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/.dockerignore: -------------------------------------------------------------------------------- 1 | /README.md 2 | /dist 3 | /docker-compose.yml 4 | /lib/generated 5 | /node_modules 6 | /user-function.desc 7 | -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /lib/generated 3 | /node_modules 4 | /user-function.desc 5 | # test quickstarts without lock file 6 | /package-lock.json 7 | -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/proto/kalix_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Default access control for all components of this Kalix Service 16 | 17 | syntax = "proto3"; 18 | 19 | package com.example; 20 | 21 | import "kalix/annotations.proto"; 22 | 23 | // only allow access from other services in the same project by default 24 | option (kalix.file).acl = { 25 | allow: { service: "*" } 26 | }; 27 | -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import generatedComponents from "../lib/generated/index"; 19 | 20 | const server = new Kalix(); 21 | 22 | // This generatedComponents array contains all generated Actions, Views or Entities, 23 | // and is kept up-to-date with any changes in your protobuf definitions. 24 | // If you prefer, you may remove this line and manually register these components. 25 | generatedComponents.forEach((component) => { 26 | server.addComponent(component); 27 | }); 28 | 29 | server.start(); 30 | -------------------------------------------------------------------------------- /samples/ts/ts-shopping-cart-quickstart/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "strictFunctionTypes": true, 6 | "target": "es6", 7 | "module": "commonJS" 8 | }, 9 | "include": ["./src/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.js -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | dist/ 4 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "trailingComma": "none", 4 | "arrowParens": "avoid" 5 | } 6 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/proto/counter_domain.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example.domain; // <1> 4 | 5 | message CounterState { // <7> 6 | int32 value = 1; 7 | } 8 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // tag::starting[] 18 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 19 | import counterEntity from "./counter"; 20 | 21 | new Kalix().addComponent(counterEntity).start(); 22 | // end::starting[] 23 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-counter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "strictFunctionTypes": true, 6 | "target": "es6", 7 | "module": "commonJS" 8 | }, 9 | "include": ["./src/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/.dockerignore: -------------------------------------------------------------------------------- 1 | /user-function.desc 2 | /docker-compose.yml 3 | /node_modules 4 | /README.md 5 | **/*.js -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | dist/ 4 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "trailingComma": "none", 4 | "arrowParens": "avoid" 5 | } 6 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | The samples are published as Docker images to `grc.io/kalix-public`. 4 | 5 | To publish the images, ensure that you have the right permissions and configure `gcloud` to connect 6 | 7 | ```shell 8 | # needs to be done if not logged in 9 | gcloud auth login 10 | # needs to be done once 11 | gcloud auth configure-docker 12 | ``` 13 | 14 | ```shell 15 | # build the docker image 16 | npm run package 17 | ``` 18 | 19 | ```shell 20 | # push it to docker registry 21 | docker push gcr.io/kalix-public/samples-ts-value-entity-shopping-cart:0.0.1 22 | ``` 23 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/proto/shoppingcart_domain.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Lightbend Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // These are the messages that get persisted - the current state (Cart). 16 | 17 | // tag::proto_syntax[] 18 | syntax = "proto3"; 19 | // end::proto_syntax[] 20 | 21 | package com.example.shoppingcart.domain; 22 | 23 | // tag::proto_messages[] 24 | message LineItem { 25 | string productId = 1; 26 | string name = 2; 27 | int32 quantity = 3; 28 | } 29 | 30 | // The shopping cart state. 31 | message Cart { 32 | repeated LineItem items = 1; 33 | } 34 | // end::proto_messages[] 35 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import shoppingcartEntity from "./shoppingcart"; 19 | 20 | new Kalix().addComponent(shoppingcartEntity).start(); 21 | -------------------------------------------------------------------------------- /samples/ts/ts-valueentity-shopping-cart/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "strictFunctionTypes": true, 6 | "target": "es6", 7 | "module": "commonJS" 8 | }, 9 | "include": ["./src/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "ignorePatterns": ["/lib", "/dist", "/node_modules"], 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/eslint-recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/ban-ts-comment": 0, 14 | "@typescript-eslint/no-unused-vars": 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/.gitignore: -------------------------------------------------------------------------------- 1 | user-function.desc 2 | lib/generated 3 | dist/ 4 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "arrowParens": "avoid" 4 | } 5 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | WORKDIR /home/node 3 | RUN apt-get update && apt-get install -y curl unzip 4 | COPY samples/ts/ts-views-example/package*.json samples/ts/ts-views-example/ 5 | RUN cd samples/ts/ts-views-example && npm ci 6 | COPY samples/ts/ts-views-example samples/ts/ts-views-example 7 | RUN cd samples/ts/ts-views-example && npm run build 8 | RUN cd samples/ts/ts-views-example && npm prune --production 9 | 10 | FROM node:18-bookworm-slim 11 | COPY --from=builder --chown=node /home/node /home/node 12 | WORKDIR /home/node/samples/ts/ts-views-example 13 | USER node 14 | ENV NODE_ENV production 15 | EXPOSE 8080 16 | CMD ["node", "dist/index.js"] 17 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | kalix-runtime: 4 | image: gcr.io/kalix-public/kalix-runtime:1.1.33 5 | command: -Dconfig.resource=dev-mode.conf -Dlogback.configurationFile=logback-dev-mode.xml -Dkalix.proxy.eventing.support=google-pubsub-emulator 6 | ports: 7 | - "9000:9000" 8 | extra_hosts: 9 | - "host.docker.internal:host-gateway" 10 | environment: 11 | USER_SERVICE_HOST: ${USER_SERVICE_HOST:-host.docker.internal} 12 | USER_SERVICE_PORT: ${USER_SERVICE_PORT:-8080} 13 | PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator 14 | # Comment to enable ACL check in dev-mode 15 | # see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls 16 | ACL_ENABLED: 'false' 17 | # Uncomment to disable the JWT dev secret 18 | # JWT_DEV_SECRET: "false" 19 | # Uncomment to set the JWT dev secret issuer 20 | # JWT_DEV_SECRET_ISSUER: "my-issuer" 21 | gcloud-pubsub-emulator: 22 | image: gcr.io/google.com/cloudsdktool/cloud-sdk:341.0.0 23 | command: gcloud beta emulators pubsub start --project=test --host-port=0.0.0.0:8085 24 | ports: 25 | - 8085:8085 26 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Kalix } from "@kalix-io/kalix-javascript-sdk"; 18 | import usersEntity from "./users"; 19 | import usersByMailView from "./users-by-email"; 20 | import usersMailCountView from "./user-email-count"; 21 | 22 | new Kalix() 23 | .addComponent(usersEntity) 24 | .addComponent(usersByMailView) 25 | .addComponent(usersMailCountView) 26 | .start(); 27 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/src/users-by-email.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { View } from "@kalix-io/kalix-javascript-sdk"; 18 | 19 | const view: View = new View(["users.proto"], "example.users.UsersByEmail", { 20 | viewId: "users-by-email" 21 | }); 22 | 23 | export default view; 24 | -------------------------------------------------------------------------------- /samples/ts/ts-views-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "strict": true, 5 | "target": "es6", 6 | "module": "commonJS" 7 | }, 8 | "include": ["./src/**/*"] 9 | } -------------------------------------------------------------------------------- /sdk/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | proto 3 | protoc 4 | apidocs 5 | generated 6 | *.tgz 7 | *.tsbuildinfo 8 | -------------------------------------------------------------------------------- /sdk/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": ["js", "ts"], 3 | "require": "ts-node/register" 4 | } 5 | -------------------------------------------------------------------------------- /sdk/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /sdk/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /sdk/README.md: -------------------------------------------------------------------------------- 1 | # Kalix JavaScript SDK 2 | 3 | This package provides support for writing Kalix services with JavaScript and Node.js. 4 | 5 | For more information see https://docs.kalix.io/javascript/. 6 | -------------------------------------------------------------------------------- /sdk/bin/test-compile-proto.sh: -------------------------------------------------------------------------------- 1 | # Generate and compile test protos and descriptors 2 | 3 | proto-loader-gen-types \ 4 | --grpcLib=@grpc/grpc-js \ 5 | --defaults \ 6 | --includeDirs=proto \ 7 | --includeDirs=test \ 8 | --outDir=test/generated/proto \ 9 | example.proto 10 | 11 | pbjs -t static-module -w commonjs \ 12 | -o test/generated/protobuf.js \ 13 | test/*.proto 14 | 15 | pbts \ 16 | -o test/generated/protobuf.d.ts \ 17 | test/generated/protobuf.js 18 | 19 | bin/compile-descriptor.js \ 20 | test/example.proto \ 21 | --descriptor_set_out=test/generated/user-function.desc 22 | -------------------------------------------------------------------------------- /sdk/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "frameworkVersion": "1.1.33" 3 | } 4 | -------------------------------------------------------------------------------- /sdk/src/effect.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as grpc from '@grpc/grpc-js'; 18 | 19 | /** 20 | * Service method to call for an effect (forward or side effect). 21 | * 22 | * @public 23 | */ 24 | export type EffectMethod = 25 | | grpc.MethodDefinition 26 | | protobuf.Method 27 | | protobuf.ReflectionObject 28 | | null; 29 | -------------------------------------------------------------------------------- /sdk/src/grpc-status.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * The GRPC status codes. 19 | * 20 | * @public 21 | */ 22 | export enum GrpcStatus { 23 | Ok = 0, 24 | Cancelled = 1, 25 | Unknown = 2, 26 | InvalidArgument = 3, 27 | DeadlineExceeded = 4, 28 | NotFound = 5, 29 | AlreadyExists = 6, 30 | PermissionDenied = 7, 31 | ResourceExhausted = 8, 32 | FailedPrecondition = 9, 33 | Aborted = 10, 34 | OutOfRange = 11, 35 | Unimplemented = 12, 36 | Internal = 13, 37 | Unavailable = 14, 38 | DataLoss = 15, 39 | Unauthenticated = 16, 40 | } 41 | -------------------------------------------------------------------------------- /sdk/src/package-info.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import * as pkg from '../package.json'; 17 | 18 | /** @internal */ 19 | export class PackageInfo { 20 | readonly name: string; 21 | readonly version: string; 22 | 23 | constructor() { 24 | this.name = pkg.name || 'unknown'; 25 | this.version = pkg.version || '0.0.0.0'; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sdk/src/serializable.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Any type that has a `type` property on it can be serialized as JSON, with the value of the type 19 | * property describing the type of the value. 20 | * 21 | * @public 22 | */ 23 | export interface TypedJson { 24 | /** 25 | * The type of the object. 26 | */ 27 | type: string; 28 | } 29 | 30 | /** 31 | * A type that is serializable. 32 | * 33 | * @public 34 | */ 35 | export type Serializable = 36 | | protobuf.Message 37 | | TypedJson 38 | | object 39 | | string 40 | | number 41 | | boolean 42 | | Long 43 | | Buffer; 44 | -------------------------------------------------------------------------------- /sdk/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "composite": false, 5 | "declaration": true, 6 | "stripInternal": true, 7 | "sourceMap": true, 8 | "rootDir": ".", 9 | "outDir": "../dist" 10 | }, 11 | "references": [ 12 | { "path": ".." }, 13 | { "path": "../types" } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /sdk/test/context-failure.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { expect } from 'chai'; 18 | import { ContextFailure } from '../src/context-failure'; 19 | 20 | describe('ContextFailure', () => { 21 | it('should create a stack', () => { 22 | const cf = new ContextFailure('my-msg'); 23 | 24 | expect(cf.stack).to.contain('ContextFailure: my-msg\n'); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /sdk/test/package-info.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { expect } from 'chai'; 18 | import { PackageInfo } from '../src/package-info'; 19 | 20 | describe('PackageInfo', () => { 21 | it('should extract informations from package.json', () => { 22 | const pi = new PackageInfo(); 23 | expect(pi.name).to.be.equal('@kalix-io/kalix-javascript-sdk'); 24 | expect(pi.version).to.be.equal('0.0.0'); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /sdk/test/package.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "some-name", 3 | "version": "some-version" 4 | } 5 | -------------------------------------------------------------------------------- /sdk/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "noEmit": true 5 | }, 6 | "references": [ 7 | {"path": "../src"} 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /sdk/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "allowJs": false, 8 | "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, 9 | "strictNullChecks": true /* Enable strict null checks. */, 10 | "strictFunctionTypes": true /* Enable strict checking of function types. */, 11 | // "noUnusedLocals": true /* Report errors on unused locals. */, 12 | // "noUnusedParameters": true /* Report errors on unused parameters. */, 13 | "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, 14 | "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, 15 | "resolveJsonModule": true, 16 | "importHelpers": true, 17 | "skipLibCheck": true, 18 | "esModuleInterop": true, 19 | "experimentalDecorators": true, 20 | "lib": ["ES6"] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "rootDir": ".", 5 | "outDir": ".", // = rootDir -> don't emit 6 | "resolveJsonModule": true 7 | }, 8 | "files": ["config.json", "package.json"] 9 | } 10 | -------------------------------------------------------------------------------- /sdk/typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://typedoc.org/schema.json", 3 | "entryPoints": ["src/index.ts"], 4 | "tsconfig": "src/tsconfig.json", 5 | "excludeInternal": true, 6 | "excludePrivate": true, 7 | "readme": "none", 8 | "sort": ["source-order"], 9 | "validation": { 10 | "notExported": true, 11 | "invalidLink": true, 12 | "notDocumented": false 13 | }, 14 | "treatWarningsAsErrors": true, 15 | "out": "apidocs" 16 | } 17 | -------------------------------------------------------------------------------- /sdk/types/protocol/any.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // re-export types generated by proto-loader-gen-types to be namespaced together 18 | // use `__Output` types for incoming messages, which will have defaults applied 19 | 20 | export { Any__Output as AnyIn } from '../generated/proto/google/protobuf/Any'; 21 | export { Any as AnyOut } from '../generated/proto/google/protobuf/Any'; 22 | -------------------------------------------------------------------------------- /sdk/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "rootDir": ".", 5 | "outDir": "dist" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /styles/Lightbend/AMPM.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: Use 'AM' or 'PM' (preceded by a space). 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/date-time-terms 4 | level: error 5 | nonword: true 6 | tokens: 7 | - '\d{1,2}[AP]M' 8 | - '\d{1,2} ?[ap]m' 9 | - '\d{1,2} ?[aApP]\.[mM]\.' 10 | -------------------------------------------------------------------------------- /styles/Lightbend/Accessibility.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use language (such as '%s') that defines people by their disability." 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/accessibility-terms 4 | level: suggestion 5 | ignorecase: true 6 | tokens: 7 | - a victim of 8 | - able-bodied 9 | - affected by 10 | - an epileptic 11 | - crippled 12 | - disabled 13 | - dumb 14 | - handicapped 15 | - handicaps 16 | - healthy 17 | - lame 18 | - maimed 19 | - missing a limb 20 | - mute 21 | - normal 22 | - sight-impaired 23 | - stricken with 24 | - suffers from 25 | - vision-impaired 26 | -------------------------------------------------------------------------------- /styles/Lightbend/Acronyms.yml: -------------------------------------------------------------------------------- 1 | extends: conditional 2 | message: "'%s' has no definition." 3 | link: https://docs.microsoft.com/en-us/style-guide/acronyms 4 | level: suggestion 5 | ignorecase: false 6 | # Ensures that the existence of 'first' implies the existence of 'second'. 7 | first: '\b([A-Z]{3,5})\b' 8 | second: '(?:\b[A-Z][a-z]+ )+\(([A-Z]{3,5})\)' 9 | # ... with the exception of these: 10 | exceptions: 11 | - CA 12 | - API 13 | - ASP 14 | - CLI 15 | - CPU 16 | - CSS 17 | - CSV 18 | - DEBUG 19 | - DOM 20 | - DPI 21 | - FAQ 22 | - GCC 23 | - GDB 24 | - GET 25 | - GPU 26 | - GTK 27 | - GUI 28 | - HTML 29 | - HTTP 30 | - HTTPS 31 | - IDE 32 | - JAR 33 | - JSON 34 | - JSX 35 | - LESS 36 | - LLDB 37 | - NET 38 | - NOTE 39 | - NVDA 40 | - OSS 41 | - PATH 42 | - PDF 43 | - PHP 44 | - POST 45 | - RAM 46 | - REPL 47 | - RSA 48 | - SCM 49 | - SCSS 50 | - SDK 51 | - SQL 52 | - SSH 53 | - SSL 54 | - SVG 55 | - TBD 56 | - TCP 57 | - TODO 58 | - URI 59 | - URL 60 | - USB 61 | - UTF 62 | - XML 63 | - XSS 64 | - YAML 65 | - ZIP 66 | -------------------------------------------------------------------------------- /styles/Lightbend/Auto.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "In general, don't hyphenate '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/a/auto 4 | ignorecase: true 5 | level: error 6 | action: 7 | name: convert 8 | params: 9 | - simple 10 | tokens: 11 | - 'auto-\w+' 12 | -------------------------------------------------------------------------------- /styles/Lightbend/Avoid.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use '%s'. See the A-Z word list for details." 3 | # See the A-Z word list 4 | link: https://docs.microsoft.com/en-us/style-guide 5 | ignorecase: true 6 | level: error 7 | tokens: 8 | - abortion 9 | - and so on 10 | - app(?:lication)?s? (?:developer|program) 11 | - app(?:lication)? file 12 | - backbone 13 | - backend 14 | - contiguous selection 15 | -------------------------------------------------------------------------------- /styles/Lightbend/Contractions.yml: -------------------------------------------------------------------------------- 1 | extends: substitution 2 | message: "Use '%s' instead of '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/word-choice/use-contractions 4 | level: error 5 | ignorecase: true 6 | action: 7 | name: replace 8 | swap: 9 | are not: aren't 10 | cannot: can't 11 | could not: couldn't 12 | did not: didn't 13 | do not: don't 14 | does not: doesn't 15 | has not: hasn't 16 | have not: haven't 17 | how is: how's 18 | is not: isn't 19 | it is: it's 20 | should not: shouldn't 21 | that is: that's 22 | they are: they're 23 | was not: wasn't 24 | we are: we're 25 | we have: we've 26 | were not: weren't 27 | what is: what's 28 | when is: when's 29 | where is: where's 30 | will not: won't 31 | -------------------------------------------------------------------------------- /styles/Lightbend/Dashes.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Remove the spaces around '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/emes 4 | ignorecase: true 5 | nonword: true 6 | level: error 7 | action: 8 | name: edit 9 | params: 10 | - remove 11 | - ' ' 12 | tokens: 13 | - '[—–]\s|\s[—–]' 14 | -------------------------------------------------------------------------------- /styles/Lightbend/DateFormat.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: Use 'July 31, 2016' format, not '%s'. 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/date-time-terms 4 | ignorecase: true 5 | level: error 6 | nonword: true 7 | tokens: 8 | - '\d{1,2} (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?) \d{4}' 9 | -------------------------------------------------------------------------------- /styles/Lightbend/DateNumbers.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use ordinal numbers for dates." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates 4 | level: error 5 | nonword: true 6 | ignorecase: true 7 | raw: 8 | - \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?)\b\s* 9 | tokens: 10 | - first 11 | - second 12 | - third 13 | - fourth 14 | - fifth 15 | - sixth 16 | - seventh 17 | - eighth 18 | - ninth 19 | - tenth 20 | - eleventh 21 | - twelfth 22 | - thirteenth 23 | - fourteenth 24 | - fifteenth 25 | - sixteenth 26 | - seventeenth 27 | - eighteenth 28 | - nineteenth 29 | - twentieth 30 | - twenty-first 31 | - twenty-second 32 | - twenty-third 33 | - twenty-fourth 34 | - twenty-fifth 35 | - twenty-sixth 36 | - twenty-seventh 37 | - twenty-eighth 38 | - twenty-ninth 39 | - thirtieth 40 | - thirty-first 41 | -------------------------------------------------------------------------------- /styles/Lightbend/DateOrder.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Always spell out the name of the month." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates 4 | ignorecase: true 5 | level: error 6 | nonword: true 7 | tokens: 8 | - '\b\d{1,2}/\d{1,2}/(?:\d{4}|\d{2})\b' 9 | -------------------------------------------------------------------------------- /styles/Lightbend/Ellipses.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "In general, don't use an ellipsis." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/ellipses 4 | nonword: true 5 | level: warning 6 | action: 7 | name: remove 8 | tokens: 9 | - '\.\.\.' 10 | -------------------------------------------------------------------------------- /styles/Lightbend/FirstPerson.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use first person (such as '%s') sparingly." 3 | link: https://docs.microsoft.com/en-us/style-guide/grammar/person 4 | ignorecase: true 5 | level: warning 6 | nonword: true 7 | tokens: 8 | - (?:^|\s)I\s 9 | - (?:^|\s)I,\s 10 | - \bI'd\b 11 | - \bI'll\b 12 | - \bI'm\b 13 | - \bI've\b 14 | - \bme\b 15 | - \bmy\b 16 | - \bmine\b 17 | -------------------------------------------------------------------------------- /styles/Lightbend/Foreign.yml: -------------------------------------------------------------------------------- 1 | extends: substitution 2 | message: "Use '%s' instead of '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/word-choice/use-us-spelling-avoid-non-english-words 4 | ignorecase: true 5 | level: error 6 | nonword: true 7 | action: 8 | name: replace 9 | swap: 10 | '\b(?:eg|e\.g\.)[\s,]': for example 11 | '\b(?:ie|i\.e\.)[\s,]': that is 12 | 13 | -------------------------------------------------------------------------------- /styles/Lightbend/Gender.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use '%s'." 3 | link: https://github.com/MicrosoftDocs/microsoft-style-guide/blob/master/styleguide/grammar/nouns-pronouns.md#pronouns-and-gender 4 | level: error 5 | ignorecase: true 6 | tokens: 7 | - he/she 8 | - s/he 9 | -------------------------------------------------------------------------------- /styles/Lightbend/GeneralURL.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "For a general audience, use 'address' rather than 'URL'." 3 | link: https://docs.microsoft.com/en-us/style-guide/urls-web-addresses 4 | level: warning 5 | action: 6 | name: replace 7 | params: 8 | - URL 9 | - address 10 | tokens: 11 | - URL 12 | -------------------------------------------------------------------------------- /styles/Lightbend/HeadingAcronyms.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Avoid using acronyms in a title or heading." 3 | link: https://docs.microsoft.com/en-us/style-guide/acronyms#be-careful-with-acronyms-in-titles-and-headings 4 | level: warning 5 | scope: heading 6 | tokens: 7 | - '[A-Z]{2,4}' 8 | -------------------------------------------------------------------------------- /styles/Lightbend/HeadingColons.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Capitalize '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/colons 4 | nonword: true 5 | level: error 6 | scope: heading 7 | tokens: 8 | - ':\s[a-z]' 9 | -------------------------------------------------------------------------------- /styles/Lightbend/HeadingPunctuation.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use end punctuation in headings." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/periods 4 | nonword: true 5 | level: warning 6 | scope: heading 7 | action: 8 | name: edit 9 | params: 10 | - remove 11 | - '.?!' 12 | tokens: 13 | - '[a-z][.?!](?:\s|$)' 14 | -------------------------------------------------------------------------------- /styles/Lightbend/Headings.yml: -------------------------------------------------------------------------------- 1 | extends: capitalization 2 | message: "'%s' should use sentence-style capitalization." 3 | link: https://docs.microsoft.com/en-us/style-guide/capitalization 4 | level: suggestion 5 | scope: heading 6 | match: $sentence 7 | indicators: 8 | - ':' 9 | exceptions: 10 | - Azure 11 | - CLI 12 | - Code 13 | - Cosmos 14 | - Docker 15 | - Emmet 16 | - I 17 | - Kubernetes 18 | - Linux 19 | - macOS 20 | - Marketplace 21 | - MongoDB 22 | - REPL 23 | - Studio 24 | - TypeScript 25 | - URLs 26 | - Visual 27 | - VS 28 | - Windows 29 | -------------------------------------------------------------------------------- /styles/Lightbend/Hyphens.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "'%s' doesn't need a hyphen." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/hyphens 4 | level: warning 5 | ignorecase: false 6 | nonword: true 7 | action: 8 | name: edit 9 | params: 10 | - replace 11 | - '-' 12 | - ' ' 13 | tokens: 14 | - '\s[^\s-]+ly-' 15 | -------------------------------------------------------------------------------- /styles/Lightbend/Ordinal.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't add -ly to an ordinal number." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | level: error 5 | action: 6 | name: edit 7 | params: 8 | - trim 9 | - ly 10 | tokens: 11 | - firstly 12 | - secondly 13 | - thirdly 14 | -------------------------------------------------------------------------------- /styles/Lightbend/OxfordComma.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use the Oxford comma in '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/commas 4 | scope: sentence 5 | level: suggestion 6 | nonword: true 7 | tokens: 8 | - '(?:[^\s,]+,){1,} \w+ (?:and|or) \w+[.?!]' 9 | -------------------------------------------------------------------------------- /styles/Lightbend/Percentages.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use a numeral plus the units." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | tokens: 7 | - '\b[a-zA-z]+\spercent\b' 8 | -------------------------------------------------------------------------------- /styles/Lightbend/Quotes.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: 'Punctuation should be inside the quotes.' 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/quotation-marks 4 | level: error 5 | nonword: true 6 | tokens: 7 | - '["“][^"”“]+["”][.,]' 8 | -------------------------------------------------------------------------------- /styles/Lightbend/RangeFormat.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use an en dash in a range of numbers." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | action: 7 | name: edit 8 | params: 9 | - replace 10 | - '-' 11 | - '–' 12 | tokens: 13 | - '\b\d+\s?[-]\s?\d+\b' 14 | -------------------------------------------------------------------------------- /styles/Lightbend/RangeTime.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use 'to' instead of a dash in '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | action: 7 | name: edit 8 | params: 9 | - replace 10 | - '[-–]' 11 | - 'to' 12 | tokens: 13 | - '\b(?:AM|PM)\s?[-–]\s?.+(?:AM|PM)\b' 14 | -------------------------------------------------------------------------------- /styles/Lightbend/Ranges.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "In most cases, use 'from' or 'through' to describe a range of numbers." 3 | link: 'https://docs.microsoft.com/en-us/style-guide/numbers' 4 | nonword: true 5 | level: warning 6 | tokens: 7 | - '\b\d+\s?[-–]\s?\d+\b' 8 | -------------------------------------------------------------------------------- /styles/Lightbend/Readability.yml: -------------------------------------------------------------------------------- 1 | extends: readability 2 | message: "Grade level (%s) too high!" 3 | link: https://docs.errata.ai/vale/styles#readability 4 | level: warning 5 | grade: 10 6 | metrics: 7 | - Flesch-Kincaid 8 | - Gunning Fog 9 | - Coleman-Liau 10 | - SMOG 11 | - Automated Readability -------------------------------------------------------------------------------- /styles/Lightbend/Semicolon.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Try to simplify this sentence." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/semicolons 4 | nonword: true 5 | scope: sentence 6 | level: suggestion 7 | tokens: 8 | - ';' 9 | -------------------------------------------------------------------------------- /styles/Lightbend/SentenceLength.yml: -------------------------------------------------------------------------------- 1 | extends: occurrence 2 | message: "Try to keep sentences short (< 30 words)." 3 | scope: sentence 4 | level: suggestion 5 | max: 30 6 | token: \b(\w+)\b 7 | 8 | -------------------------------------------------------------------------------- /styles/Lightbend/Spacing.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "'%s' should have one or two spaces." 3 | level: error 4 | nonword: true 5 | tokens: 6 | - '[a-z][.?!] {3,}[A-Z]' 7 | - '[a-z][.?!][A-Z]' 8 | -------------------------------------------------------------------------------- /styles/Lightbend/Suspended.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use '%s' unless space is limited." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/hyphens 4 | ignorecase: true 5 | level: warning 6 | tokens: 7 | - '\w+- and \w+-' 8 | -------------------------------------------------------------------------------- /styles/Lightbend/URLFormat.yml: -------------------------------------------------------------------------------- 1 | extends: substitution 2 | message: "Use '%s' instead of '%s'." 3 | ignorecase: true 4 | level: error 5 | action: 6 | name: replace 7 | swap: 8 | URL for: URL of 9 | an URL: a URL 10 | 11 | -------------------------------------------------------------------------------- /styles/Lightbend/Units.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't spell out the number in '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/units-of-measure-terms 4 | level: error 5 | raw: 6 | - '[a-zA-Z]+\s' 7 | tokens: 8 | - '(?:centi|milli)?meters' 9 | - '(?:kilo)?grams' 10 | - '(?:kilo)?meters' 11 | - '(?:mega)?pixels' 12 | - cm 13 | - inches 14 | - lb 15 | - miles 16 | - pounds 17 | -------------------------------------------------------------------------------- /styles/Lightbend/Vocab.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Verify your use of '%s' with the A-Z word list." 3 | link: 'https://docs.microsoft.com/en-us/style-guide' 4 | level: suggestion 5 | ignorecase: true 6 | tokens: 7 | - above 8 | - accessible 9 | - actionable 10 | - against 11 | - alarm 12 | - alert 13 | - alias 14 | - allows? 15 | - and/or 16 | - as well as 17 | - assure 18 | - author 19 | - avg 20 | - beta 21 | - ensure 22 | - he 23 | - insure 24 | - sample 25 | - she 26 | -------------------------------------------------------------------------------- /styles/Lightbend/We.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Try to avoid using first-person plural like '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/grammar/person#avoid-first-person-plural 4 | level: warning 5 | ignorecase: true 6 | tokens: 7 | - we 8 | - we'(?:ve|re) 9 | - ours? 10 | - us 11 | - let's 12 | -------------------------------------------------------------------------------- /styles/Lightbend/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "feed": "https://github.com/errata-ai/Microsoft/releases.atom", 3 | "vale_version": ">=1.0.0" 4 | } 5 | -------------------------------------------------------------------------------- /styles/Microsoft/AMPM.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: Use 'AM' or 'PM' (preceded by a space). 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/date-time-terms 4 | level: error 5 | nonword: true 6 | tokens: 7 | - '\d{1,2}[AP]M' 8 | - '\d{1,2} ?[ap]m' 9 | - '\d{1,2} ?[aApP]\.[mM]\.' 10 | -------------------------------------------------------------------------------- /styles/Microsoft/Accessibility.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use language (such as '%s') that defines people by their disability." 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/accessibility-terms 4 | level: suggestion 5 | ignorecase: true 6 | tokens: 7 | - a victim of 8 | - able-bodied 9 | - affected by 10 | - an epileptic 11 | - crippled 12 | - disabled 13 | - dumb 14 | - handicapped 15 | - handicaps 16 | - healthy 17 | - lame 18 | - maimed 19 | - missing a limb 20 | - mute 21 | - normal 22 | - sight-impaired 23 | - stricken with 24 | - suffers from 25 | - vision-impaired 26 | -------------------------------------------------------------------------------- /styles/Microsoft/Acronyms.yml: -------------------------------------------------------------------------------- 1 | extends: conditional 2 | message: "'%s' has no definition." 3 | link: https://docs.microsoft.com/en-us/style-guide/acronyms 4 | level: suggestion 5 | ignorecase: false 6 | # Ensures that the existence of 'first' implies the existence of 'second'. 7 | first: '\b([A-Z]{3,5})\b' 8 | second: '(?:\b[A-Z][a-z]+ )+\(([A-Z]{3,5})\)' 9 | # ... with the exception of these: 10 | exceptions: 11 | - API 12 | - ASP 13 | - CLI 14 | - CPU 15 | - CSS 16 | - CSV 17 | - DEBUG 18 | - DOM 19 | - DPI 20 | - FAQ 21 | - GCC 22 | - GDB 23 | - GET 24 | - GPU 25 | - GTK 26 | - GUI 27 | - HTML 28 | - HTTP 29 | - HTTPS 30 | - IDE 31 | - JAR 32 | - JSON 33 | - JSX 34 | - LESS 35 | - LLDB 36 | - NET 37 | - NOTE 38 | - NVDA 39 | - OSS 40 | - PATH 41 | - PDF 42 | - PHP 43 | - POST 44 | - RAM 45 | - REPL 46 | - RSA 47 | - SCM 48 | - SCSS 49 | - SDK 50 | - SQL 51 | - SSH 52 | - SSL 53 | - SVG 54 | - TBD 55 | - TCP 56 | - TODO 57 | - URI 58 | - URL 59 | - USB 60 | - UTF 61 | - XML 62 | - XSS 63 | - YAML 64 | - ZIP 65 | -------------------------------------------------------------------------------- /styles/Microsoft/Auto.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "In general, don't hyphenate '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/a/auto 4 | ignorecase: true 5 | level: error 6 | action: 7 | name: convert 8 | params: 9 | - simple 10 | tokens: 11 | - 'auto-\w+' 12 | -------------------------------------------------------------------------------- /styles/Microsoft/Avoid.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use '%s'. See the A-Z word list for details." 3 | # See the A-Z word list 4 | link: https://docs.microsoft.com/en-us/style-guide 5 | ignorecase: true 6 | level: error 7 | tokens: 8 | - abortion 9 | - and so on 10 | - app(?:lication)?s? (?:developer|program) 11 | - app(?:lication)? file 12 | - backbone 13 | - backend 14 | - contiguous selection 15 | -------------------------------------------------------------------------------- /styles/Microsoft/Contractions.yml: -------------------------------------------------------------------------------- 1 | extends: substitution 2 | message: "Use '%s' instead of '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/word-choice/use-contractions 4 | level: error 5 | ignorecase: true 6 | action: 7 | name: replace 8 | swap: 9 | are not: aren't 10 | cannot: can't 11 | could not: couldn't 12 | did not: didn't 13 | do not: don't 14 | does not: doesn't 15 | has not: hasn't 16 | have not: haven't 17 | how is: how's 18 | is not: isn't 19 | 20 | 'it is(?!\.)': it's 21 | 'it''s(?=\.)': it is 22 | 23 | should not: shouldn't 24 | 25 | 'that is(?!\.)': that's 26 | 'that''s(?=\.)': that is 27 | 28 | 'they are(?!\.)': they're 29 | 'they''re(?=\.)': they are 30 | 31 | was not: wasn't 32 | 33 | 'we are(?!\.)': we're 34 | 'we''re(?=\.)': we are 35 | 36 | 'we have(?!\.)': we've 37 | 'we''ve(?=\.)': we have 38 | 39 | were not: weren't 40 | 41 | 'what is(?!\.)': what's 42 | 'what''s(?=\.)': what is 43 | 44 | 'when is(?!\.)': when's 45 | 'when''s(?=\.)': when is 46 | 47 | 'where is(?!\.)': where's 48 | 'where''s(?=\.)': where is 49 | 50 | will not: won't 51 | -------------------------------------------------------------------------------- /styles/Microsoft/Dashes.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Remove the spaces around '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/emes 4 | ignorecase: true 5 | nonword: true 6 | level: error 7 | action: 8 | name: edit 9 | params: 10 | - remove 11 | - ' ' 12 | tokens: 13 | - '[—–]\s|\s[—–]' 14 | -------------------------------------------------------------------------------- /styles/Microsoft/DateFormat.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: Use 'July 31, 2016' format, not '%s'. 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/date-time-terms 4 | ignorecase: true 5 | level: error 6 | nonword: true 7 | tokens: 8 | - '\d{1,2} (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?) \d{4}' 9 | -------------------------------------------------------------------------------- /styles/Microsoft/DateNumbers.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use ordinal numbers for dates." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates 4 | level: error 5 | nonword: true 6 | ignorecase: true 7 | raw: 8 | - \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?)\b\s* 9 | tokens: 10 | - first 11 | - second 12 | - third 13 | - fourth 14 | - fifth 15 | - sixth 16 | - seventh 17 | - eighth 18 | - ninth 19 | - tenth 20 | - eleventh 21 | - twelfth 22 | - thirteenth 23 | - fourteenth 24 | - fifteenth 25 | - sixteenth 26 | - seventeenth 27 | - eighteenth 28 | - nineteenth 29 | - twentieth 30 | - twenty-first 31 | - twenty-second 32 | - twenty-third 33 | - twenty-fourth 34 | - twenty-fifth 35 | - twenty-sixth 36 | - twenty-seventh 37 | - twenty-eighth 38 | - twenty-ninth 39 | - thirtieth 40 | - thirty-first 41 | -------------------------------------------------------------------------------- /styles/Microsoft/DateOrder.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Always spell out the name of the month." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates 4 | ignorecase: true 5 | level: error 6 | nonword: true 7 | tokens: 8 | - '\b\d{1,2}/\d{1,2}/(?:\d{4}|\d{2})\b' 9 | -------------------------------------------------------------------------------- /styles/Microsoft/Ellipses.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "In general, don't use an ellipsis." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/ellipses 4 | nonword: true 5 | level: warning 6 | action: 7 | name: remove 8 | tokens: 9 | - '\.\.\.' 10 | -------------------------------------------------------------------------------- /styles/Microsoft/FirstPerson.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use first person (such as '%s') sparingly." 3 | link: https://docs.microsoft.com/en-us/style-guide/grammar/person 4 | ignorecase: true 5 | level: warning 6 | nonword: true 7 | tokens: 8 | - (?:^|\s)I\s 9 | - (?:^|\s)I,\s 10 | - \bI'd\b 11 | - \bI'll\b 12 | - \bI'm\b 13 | - \bI've\b 14 | - \bme\b 15 | - \bmy\b 16 | - \bmine\b 17 | -------------------------------------------------------------------------------- /styles/Microsoft/Foreign.yml: -------------------------------------------------------------------------------- 1 | extends: substitution 2 | message: "Use '%s' instead of '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/word-choice/use-us-spelling-avoid-non-english-words 4 | ignorecase: true 5 | level: error 6 | nonword: true 7 | action: 8 | name: replace 9 | swap: 10 | '\b(?:eg|e\.g\.)[\s,]': for example 11 | '\b(?:ie|i\.e\.)[\s,]': that is 12 | 13 | -------------------------------------------------------------------------------- /styles/Microsoft/Gender.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use '%s'." 3 | link: https://github.com/MicrosoftDocs/microsoft-style-guide/blob/master/styleguide/grammar/nouns-pronouns.md#pronouns-and-gender 4 | level: error 5 | ignorecase: true 6 | tokens: 7 | - he/she 8 | - s/he 9 | -------------------------------------------------------------------------------- /styles/Microsoft/GeneralURL.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "For a general audience, use 'address' rather than 'URL'." 3 | link: https://docs.microsoft.com/en-us/style-guide/urls-web-addresses 4 | level: warning 5 | action: 6 | name: replace 7 | params: 8 | - URL 9 | - address 10 | tokens: 11 | - URL 12 | -------------------------------------------------------------------------------- /styles/Microsoft/HeadingAcronyms.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Avoid using acronyms in a title or heading." 3 | link: https://docs.microsoft.com/en-us/style-guide/acronyms#be-careful-with-acronyms-in-titles-and-headings 4 | level: warning 5 | scope: heading 6 | tokens: 7 | - '[A-Z]{2,4}' 8 | -------------------------------------------------------------------------------- /styles/Microsoft/HeadingColons.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Capitalize '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/colons 4 | nonword: true 5 | level: error 6 | scope: heading 7 | tokens: 8 | - ':\s[a-z]' 9 | -------------------------------------------------------------------------------- /styles/Microsoft/HeadingPunctuation.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use end punctuation in headings." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/periods 4 | nonword: true 5 | level: warning 6 | scope: heading 7 | action: 8 | name: edit 9 | params: 10 | - remove 11 | - '.?!' 12 | tokens: 13 | - '[a-z][.?!](?:\s|$)' 14 | -------------------------------------------------------------------------------- /styles/Microsoft/Headings.yml: -------------------------------------------------------------------------------- 1 | extends: capitalization 2 | message: "'%s' should use sentence-style capitalization." 3 | link: https://docs.microsoft.com/en-us/style-guide/capitalization 4 | level: suggestion 5 | scope: heading 6 | match: $sentence 7 | indicators: 8 | - ':' 9 | exceptions: 10 | - Azure 11 | - CLI 12 | - Code 13 | - Cosmos 14 | - Docker 15 | - Emmet 16 | - I 17 | - Kubernetes 18 | - Linux 19 | - macOS 20 | - Marketplace 21 | - MongoDB 22 | - REPL 23 | - Studio 24 | - TypeScript 25 | - URLs 26 | - Visual 27 | - VS 28 | - Windows 29 | -------------------------------------------------------------------------------- /styles/Microsoft/Hyphens.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "'%s' doesn't need a hyphen." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/hyphens 4 | level: warning 5 | ignorecase: false 6 | nonword: true 7 | action: 8 | name: edit 9 | params: 10 | - replace 11 | - '-' 12 | - ' ' 13 | tokens: 14 | - '\s[^\s-]+ly-' 15 | -------------------------------------------------------------------------------- /styles/Microsoft/Negative.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Form a negative number with an en dash, not a hyphen." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | action: 7 | name: edit 8 | params: 9 | - replace 10 | - '-' 11 | - '–' 12 | tokens: 13 | - '\s-\d+\s' 14 | -------------------------------------------------------------------------------- /styles/Microsoft/Ordinal.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't add -ly to an ordinal number." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | level: error 5 | action: 6 | name: edit 7 | params: 8 | - trim 9 | - ly 10 | tokens: 11 | - firstly 12 | - secondly 13 | - thirdly 14 | -------------------------------------------------------------------------------- /styles/Microsoft/OxfordComma.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use the Oxford comma in '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/commas 4 | scope: sentence 5 | level: suggestion 6 | nonword: true 7 | tokens: 8 | - '(?:[^\s,]+,){1,} \w+ (?:and|or) \w+[.?!]' 9 | -------------------------------------------------------------------------------- /styles/Microsoft/Percentages.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use a numeral plus the units." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | tokens: 7 | - '\b[a-zA-z]+\spercent\b' 8 | -------------------------------------------------------------------------------- /styles/Microsoft/Quotes.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: 'Punctuation should be inside the quotes.' 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/quotation-marks 4 | level: error 5 | nonword: true 6 | tokens: 7 | - '["“][^"”“]+["”][.,]' 8 | -------------------------------------------------------------------------------- /styles/Microsoft/RangeFormat.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use an en dash in a range of numbers." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | action: 7 | name: edit 8 | params: 9 | - replace 10 | - '-' 11 | - '–' 12 | tokens: 13 | - '\b\d+\s?[-]\s?\d+\b' 14 | -------------------------------------------------------------------------------- /styles/Microsoft/RangeTime.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Use 'to' instead of a dash in '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/numbers 4 | nonword: true 5 | level: error 6 | action: 7 | name: edit 8 | params: 9 | - replace 10 | - '[-–]' 11 | - 'to' 12 | tokens: 13 | - '\b(?:AM|PM)\s?[-–]\s?.+(?:AM|PM)\b' 14 | -------------------------------------------------------------------------------- /styles/Microsoft/Ranges.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "In most cases, use 'from' or 'through' to describe a range of numbers." 3 | link: 'https://docs.microsoft.com/en-us/style-guide/numbers' 4 | nonword: true 5 | level: warning 6 | tokens: 7 | - '\b\d+\s?[-–]\s?\d+\b' 8 | -------------------------------------------------------------------------------- /styles/Microsoft/Semicolon.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Try to simplify this sentence." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/semicolons 4 | nonword: true 5 | scope: sentence 6 | level: suggestion 7 | tokens: 8 | - ';' 9 | -------------------------------------------------------------------------------- /styles/Microsoft/SentenceLength.yml: -------------------------------------------------------------------------------- 1 | extends: occurrence 2 | message: "Try to keep sentences short (< 30 words)." 3 | scope: sentence 4 | level: suggestion 5 | max: 30 6 | token: \b(\w+)\b 7 | 8 | -------------------------------------------------------------------------------- /styles/Microsoft/Spacing.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "'%s' should have one space." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/periods 4 | level: error 5 | nonword: true 6 | tokens: 7 | - '[a-z][.?!] {2,}[A-Z]' 8 | - '[a-z][.?!][A-Z]' 9 | -------------------------------------------------------------------------------- /styles/Microsoft/Suspended.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't use '%s' unless space is limited." 3 | link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/hyphens 4 | ignorecase: true 5 | level: warning 6 | tokens: 7 | - '\w+- and \w+-' 8 | -------------------------------------------------------------------------------- /styles/Microsoft/URLFormat.yml: -------------------------------------------------------------------------------- 1 | extends: substitution 2 | message: "Use '%s' instead of '%s'." 3 | ignorecase: true 4 | level: error 5 | action: 6 | name: replace 7 | swap: 8 | URL for: URL of 9 | an URL: a URL 10 | 11 | -------------------------------------------------------------------------------- /styles/Microsoft/Units.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't spell out the number in '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/units-of-measure-terms 4 | level: error 5 | raw: 6 | - '[a-zA-Z]+\s' 7 | tokens: 8 | - '(?:centi|milli)?meters' 9 | - '(?:kilo)?grams' 10 | - '(?:kilo)?meters' 11 | - '(?:mega)?pixels' 12 | - cm 13 | - inches 14 | - lb 15 | - miles 16 | - pounds 17 | -------------------------------------------------------------------------------- /styles/Microsoft/Vocab.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Verify your use of '%s' with the A-Z word list." 3 | link: 'https://docs.microsoft.com/en-us/style-guide' 4 | level: suggestion 5 | ignorecase: true 6 | tokens: 7 | - above 8 | - accessible 9 | - actionable 10 | - against 11 | - alarm 12 | - alert 13 | - alias 14 | - allows? 15 | - and/or 16 | - as well as 17 | - assure 18 | - author 19 | - avg 20 | - beta 21 | - ensure 22 | - he 23 | - insure 24 | - sample 25 | - she 26 | -------------------------------------------------------------------------------- /styles/Microsoft/We.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Try to avoid using first-person plural like '%s'." 3 | link: https://docs.microsoft.com/en-us/style-guide/grammar/person#avoid-first-person-plural 4 | level: warning 5 | ignorecase: true 6 | tokens: 7 | - we 8 | - we'(?:ve|re) 9 | - ours? 10 | - us 11 | - let's 12 | -------------------------------------------------------------------------------- /styles/Microsoft/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "feed": "https://github.com/errata-ai/Microsoft/releases.atom", 3 | "vale_version": ">=1.0.0" 4 | } 5 | -------------------------------------------------------------------------------- /styles/config/vocabularies/Base/reject.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightbend/kalix-javascript-sdk/5071e9a1a03b4b280ce4f5859d184d183c83c0d9/styles/config/vocabularies/Base/reject.txt -------------------------------------------------------------------------------- /styles/write-good/E-Prime.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Try to avoid using '%s'." 3 | ignorecase: true 4 | level: suggestion 5 | tokens: 6 | - am 7 | - are 8 | - aren't 9 | - be 10 | - been 11 | - being 12 | - he's 13 | - here's 14 | - here's 15 | - how's 16 | - i'm 17 | - is 18 | - isn't 19 | - it's 20 | - she's 21 | - that's 22 | - there's 23 | - they're 24 | - was 25 | - wasn't 26 | - we're 27 | - were 28 | - weren't 29 | - what's 30 | - where's 31 | - who's 32 | - you're 33 | -------------------------------------------------------------------------------- /styles/write-good/Illusions.yml: -------------------------------------------------------------------------------- 1 | extends: repetition 2 | message: "'%s' is repeated!" 3 | level: warning 4 | alpha: true 5 | action: 6 | name: edit 7 | params: 8 | - truncate 9 | - " " 10 | tokens: 11 | - '[^\s]+' 12 | -------------------------------------------------------------------------------- /styles/write-good/So.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't start a sentence with '%s'." 3 | level: error 4 | raw: 5 | - '(?:[;-]\s)so[\s,]|\bSo[\s,]' 6 | -------------------------------------------------------------------------------- /styles/write-good/ThereIs.yml: -------------------------------------------------------------------------------- 1 | extends: existence 2 | message: "Don't start a sentence with '%s'." 3 | ignorecase: false 4 | level: error 5 | raw: 6 | - '(?:[;-]\s)There\s(is|are)|\bThere\s(is|are)\b' 7 | -------------------------------------------------------------------------------- /styles/write-good/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "feed": "https://github.com/errata-ai/write-good/releases.atom", 3 | "vale_version": ">=1.0.0" 4 | } 5 | -------------------------------------------------------------------------------- /tck/.gitignore: -------------------------------------------------------------------------------- 1 | /dist/ 2 | /generated/ 3 | /node_modules/ 4 | /proto/ 5 | /package-lock.json 6 | /user-function.desc 7 | -------------------------------------------------------------------------------- /tck/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /tck/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /tck/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-bookworm-slim AS builder 2 | RUN apt-get update && apt-get install -y curl unzip 3 | WORKDIR /home/node 4 | USER node 5 | COPY --chown=node sdk sdk 6 | RUN cd sdk && npm ci 7 | RUN cd sdk && npm pack 8 | COPY --chown=node tck/package.json tck/ 9 | COPY --chown=node tck/bin tck/bin 10 | RUN cd tck && npm install 11 | COPY --chown=node tck tck 12 | RUN cd tck && npm run build 13 | RUN cd tck && npm prune --production 14 | 15 | FROM node:18-bookworm-slim 16 | COPY --from=builder --chown=node /home/node /home/node 17 | WORKDIR /home/node/tck 18 | USER node 19 | ENV HOST 0.0.0.0 20 | ENV NODE_ENV production 21 | ENV DEBUG kalix* 22 | EXPOSE 8080 23 | CMD ["node", "dist/index.js"] 24 | -------------------------------------------------------------------------------- /tck/README.md: -------------------------------------------------------------------------------- 1 | # Kalix TCK implementation for JavaScript SDK 2 | 3 | First install dependencies: 4 | 5 | ``` 6 | npm install 7 | ``` 8 | 9 | Run the TCK (against the Kalix TCK docker image): 10 | 11 | ``` 12 | npm run tck 13 | ``` 14 | -------------------------------------------------------------------------------- /tck/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kalix-tck-javascript-sdk", 3 | "version": "0.0.0", 4 | "description": "Kalix TCK implementation for JavaScript SDK", 5 | "engineStrict": true, 6 | "engines": { 7 | "node": "~18" 8 | }, 9 | "dependencies": { 10 | "@kalix-io/kalix-javascript-sdk": "file:../sdk/kalix-io-kalix-javascript-sdk-0.0.0.tgz" 11 | }, 12 | "devDependencies": { 13 | "protobufjs": "6.11.4", 14 | "testcontainers": "7.10.0", 15 | "typescript": "4.3.4" 16 | }, 17 | "scripts": { 18 | "clean": "rimraf ./proto ./generated ./dist", 19 | "protocol": "bin/tck-protocol.sh", 20 | "postinstall": "npm run protocol", 21 | "compile": "tsc", 22 | "build": "npm run compile && cp -r generated dist", 23 | "start": "node dist/index.js", 24 | "tck": "(cd ../sdk && npm pack) && npm install ../sdk/kalix-io-kalix-javascript-sdk-0.0.0.tgz && npm run build && node dist/run.js", 25 | "docker-build": "docker build -f Dockerfile -t gcr.io/kalix-public/kalix-tck-javascript-sdk:$(../sdk/bin/version.sh) ..", 26 | "docker-push": "docker push gcr.io/kalix-public/kalix-tck-javascript-sdk:$(../sdk/bin/version.sh)" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tck/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "strict": true, 6 | "strictFunctionTypes": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "outDir": "dist" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testkit/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | example/generated 3 | *.tgz 4 | -------------------------------------------------------------------------------- /testkit/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": ["ts"], 3 | "require": "ts-node/register" 4 | } 5 | -------------------------------------------------------------------------------- /testkit/.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /testkit/README.md: -------------------------------------------------------------------------------- 1 | # Kalix Testkit 2 | 3 | This package provides support for testing Kalix services. 4 | 5 | For more information see https://docs.kalix.io/javascript/. 6 | -------------------------------------------------------------------------------- /testkit/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2023 Lightbend Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { MockCommandContext } from './mock-command'; 18 | export { MockEventSourcedEntity } from './mock-event-sourced-entity'; 19 | export { MockValueEntity } from './mock-value-entity'; 20 | export { IntegrationTestkit } from './integration-testkit'; 21 | -------------------------------------------------------------------------------- /testkit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "declaration": true, 7 | "composite": false, 8 | "strict": true, 9 | "allowJs": false, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "strictFunctionTypes": true, 13 | "noUnusedLocals": true, 14 | "noUnusedParameters": true, 15 | "noImplicitReturns": true, 16 | "noFallthroughCasesInSwitch": true, 17 | "skipLibCheck": true, 18 | "esModuleInterop": true, 19 | "sourceMap": true, 20 | "stripInternal": true, 21 | "rootDir": "./src", 22 | "outDir": "./dist", 23 | "lib": ["ES6"] 24 | }, 25 | "include": ["src/**/*"], 26 | "exclude": ["node_modules"] 27 | } 28 | --------------------------------------------------------------------------------