diff --git a/docs/developer-docs/6.x/infrastructure/ci-cd.ai.txt b/docs/developer-docs/6.x/infrastructure/ci-cd.ai.txt new file mode 100644 index 000000000..d1a8f9bf8 --- /dev/null +++ b/docs/developer-docs/6.x/infrastructure/ci-cd.ai.txt @@ -0,0 +1,56 @@ +AI Context: CI/CD (ci-cd.mdx) + +## Source of Information + +1. `docs/developer-docs/5.x/core-development-concepts/ci-cd/introduction.mdx` — overview and phases +2. `docs/developer-docs/5.x/core-development-concepts/ci-cd/environments.mdx` — shared/isolated environments, AWS accounts +3. `docs/developer-docs/5.x/core-development-concepts/ci-cd/version-control.mdx` — GitHub flow, branching +4. `docs/developer-docs/5.x/core-development-concepts/ci-cd/cloud-infrastructure-state-files.mdx` — Pulumi backends +5. `docs/developer-docs/5.x/core-development-concepts/ci-cd/workflows.mdx` — merging strategies, release cycle + +## Key Documentation Decisions + +1. Six v5 articles collapsed into one — target audience is experienced AWS/DevOps engineers who don't need CI/CD explained +2. Removed: what is CI/CD, CI/CD phases diagram, what is Git/GitHub, what is Pulumi (assumed knowledge) +3. Removed: references to v5 scaffold (`yarn webiny scaffold`) — not relevant in v6 +4. Removed: "Can I bring additional tools?" FAQ — too basic +5. Removed: testing article content — not in scope for this article +6. Kept: environment table, AWS accounts recommendation, branching strategy, Pulumi state backend options, deployment flow, hot fix pattern +7. GitHub Actions is a separate article (`github-actions.mdx`) +8. Staging merge strategy: kept the recommended "PR against staging, then sync back to dev" approach +9. No version references anywhere + +## Understanding + +### Environment structure +- 3 shared long-lived: dev, staging, prod +- Isolated: per developer, per developer AWS account +- Each shared env: own AWS account, own S3 bucket for Pulumi state + +### Pulumi state backends +- Local `.pulumi` folder: developer environments only, not in VCS +- S3: recommended for shared envs; one bucket per env/account; set via `WEBINY_PULUMI_BACKEND=s3://...` +- Pulumi Service: managed option with locking/history; set via `WEBINY_PULUMI_BACKEND=https://api.pulumi.com` + `PULUMI_ACCESS_TOKEN` +- When using Pulumi Service: remove `PULUMI_SECRETS_PROVIDER` and `PULUMI_CONFIG_PASSPHRASE` + +### Deployment flow +feature branch → PR → dev → PR → staging → PR → prod + +### Hot fix flow +PR directly to prod → merge prod → staging → dev + +### Staging merge strategy (recommended) +Fix bugs found in staging by PRing against staging (not dev). At end of cycle, merge staging back to dev. + +## Related Documents + +- `infrastructure/github-actions.mdx` — GitHub Actions workflow setup +- `infrastructure/deploy-webiny-project-cf-template.mdx` — IAM permissions for CI/CD +- `infrastructure/deployment-modes.mdx` — dev vs prod infrastructure differences + +## Tone Guidelines + +- Assumes experienced AWS/DevOps audience — no hand-holding on basic concepts +- Prescriptive: "the recommended setup is..." not "you could consider..." +- Table-driven where possible for environment/backend comparison +- FAQ section for edge cases only diff --git a/docs/developer-docs/6.x/infrastructure/ci-cd.mdx b/docs/developer-docs/6.x/infrastructure/ci-cd.mdx new file mode 100644 index 000000000..8a4c64743 --- /dev/null +++ b/docs/developer-docs/6.x/infrastructure/ci-cd.mdx @@ -0,0 +1,131 @@ +--- +id: infra6cicd +title: CI/CD +description: Best practices for structuring environments, branches, Pulumi state, and deployment workflows for a Webiny project. +--- + +import { Alert } from "@/components/Alert"; + + + +- How to organize environments and AWS accounts +- How to structure Git branches to mirror environments +- How to store Pulumi state files for shared environments +- How deployments flow from `dev` → `staging` → `prod` + + + +## Overview + +This article covers the recommended CI/CD setup for a Webiny project. It assumes you are already familiar with CI/CD concepts and focuses on the decisions that are specific to Webiny — environments, branching, Pulumi state management, and deployment workflow. + +## Environments + +### Shared Environments + +The recommended minimum is three long-lived shared environments: + +| Environment | Purpose | +| ----------- | ------------------------------------------------------------ | +| `dev` | Integration target for all feature branches; may be unstable | +| `staging` | Production-like environment for release candidate testing | +| `prod` | Live system used by real users; must remain stable | + +Each push to a shared branch should automatically trigger a deployment into its respective environment. + +### Isolated Environments + +Developers deploy their own short-lived isolated environments for local development and testing. These are deployed from a developer's machine and destroyed when no longer needed. Each developer should use their own AWS account to avoid interfering with shared environments. + +### AWS Accounts + +The recommended setup is one AWS account per environment — one for `dev`, one for `staging`, one for `prod`, and one per developer for isolated work. [AWS Organizations](https://aws.amazon.com/organizations/) makes managing multiple accounts easier. + +Using separate accounts means AWS credentials, Pulumi state buckets, and permissions are fully isolated between environments. + +**Consider a dedicated account for ephemeral environments.** If you run ephemeral PR environments in the same AWS account as your long-lived `dev` environment, the account may accumulate orphaned resources over time. Tools like [aws-nuke](https://github.com/ekristen/aws-nuke) can clean these up, but they cannot safely run against an account that also holds a live environment. By routing all ephemeral environments into a dedicated fourth account — separate from `dev`, `staging`, and `prod` — you can safely run aws-nuke or similar tools against that account on a schedule without risking your long-lived environments. + +## Branching Strategy + +Mirror your environments with long-lived Git branches: `dev`, `staging`, and `prod`. Protect all three against direct pushes — all changes should go through pull requests. + +Set `dev` as the default branch. All feature branches are created from `dev` and pull requests target `dev`. + +Short-lived branches follow this flow: + +``` +feature/my-change → (PR) → dev → (PR) → staging → (PR) → prod +``` + +### Hot Fixes + +If a critical bug needs an immediate fix in production, a PR can be raised directly against `prod`. Once merged, sync the fix back down: merge `prod` → `staging` → `dev`. + +## Pulumi State Files + +Webiny uses [Pulumi](https://www.pulumi.com/) for infrastructure deployments. Pulumi records the state of all deployed resources in state files — these must not be lost. + +### Local File System (default) + +By default, state files are stored in `.pulumi` folders within the project. This is suitable for individual developer environments only. The `.pulumi` folder is not checked into version control. + +### Amazon S3 (recommended for shared environments) + +For `dev`, `staging`, and `prod`, store state files in an S3 bucket within the same AWS account used for that environment. Create the bucket manually before the first deployment, then set: + +```bash +WEBINY_PULUMI_BACKEND=s3://your-bucket-name +``` + +Since each environment uses its own AWS account, you end up with one S3 bucket per environment. + +### Pulumi Service + +Alternatively, use the [Pulumi Service](https://www.pulumi.com/product/pulumi-cloud/) for managed state storage with built-in locking, history, and secret encryption: + +```bash +WEBINY_PULUMI_BACKEND=https://api.pulumi.com +PULUMI_ACCESS_TOKEN=pul-xyzabc123 +``` + +When using Pulumi Service, remove `PULUMI_SECRETS_PROVIDER` and `PULUMI_CONFIG_PASSPHRASE` — the service provides its own secrets handling. + + + +Do not lose your `PULUMI_CONFIG_PASSPHRASE` when using the passphrase secrets provider. Without it, you cannot redeploy or destroy existing infrastructure. + + + +## Deployment Workflow + +### 1. Feature development + +A developer branches from `dev`, makes changes, and opens a PR back to `dev`. Tests run against a short-lived ephemeral environment. On approval, the branch is merged and the `dev` environment is redeployed. + +### 2. Release to staging + +When `dev` is ready for a release, open a PR from `dev` → `staging`. Once merged, `staging` is redeployed. QA and stakeholders test the release candidate. + +If bugs are found in `staging`, raise fixes as PRs against `staging` directly (not `dev`). At the end of the release cycle, merge `staging` back into `dev` to keep them in sync. + +### 3. Release to production + +Once `staging` is approved, open a PR from `staging` → `prod`. Once merged, `prod` is redeployed and the release is live. + +## GitHub Actions + +Everything outlined in this article is implemented in the ready-made GitHub Actions workflow files Webiny provides. See [GitHub Actions](/{version}/infrastructure/github-actions) for the full setup guide — workflow files, OIDC authentication, and required repository secrets. + +## FAQ + +### Can I have more than three shared environments? + +Yes. Add additional long-lived branches and environments as needed — a common addition is a `uat` environment between `staging` and `prod`. + +### Are environment names fixed? + +No. `dev`, `staging`, and `prod` are conventions, not hard-coded values. Use whatever naming your organization follows. + +### What happens if two deployments are triggered simultaneously? + +Pulumi locks state during a deployment. The second deployment will be rejected with an error until the first completes. diff --git a/docs/developer-docs/6.x/infrastructure/deploy-webiny-project-cf-template.ai.txt b/docs/developer-docs/6.x/infrastructure/deploy-webiny-project-cf-template.ai.txt new file mode 100644 index 000000000..3d1cd13d5 --- /dev/null +++ b/docs/developer-docs/6.x/infrastructure/deploy-webiny-project-cf-template.ai.txt @@ -0,0 +1,40 @@ +AI Context: "Deploy Webiny Project" AWS CloudFormation Template (deploy-webiny-project-cf-template.mdx) + +## Source of Information + +1. `docs/developer-docs/5.x/infrastructure/aws/configure-aws-credentials.mdx` lines 116-149 — the "Deploy Webiny Project" section extracted from the v5 credentials article + +## Key Documentation Decisions + +1. This is a standalone article scoped only to the CloudFormation template — credential setup is out of scope +2. Kept short: the template does one thing (provisions least-privilege IAM groups), one click to launch it +3. Removed the commented-out screenshots from v5 (outdated, explicitly commented out in source) +4. ExternalLink component not used — standard markdown links are sufficient for external URLs +5. Prerequisite (IAM user with programmatic access) noted via Alert rather than linking back to a credential setup article + +## Understanding + +### What the template does + +- Provisions three IAM user groups with least-privilege permissions scoped to what Webiny deployment requires +- Links the groups to a preexisting IAM user of the deployer's choosing +- Alternative to granting full AdministratorAccess + +### Launch URL + +https://console.aws.amazon.com/cloudformation/home?#/stacks/create/review?templateURL=https://webiny-public.s3.us-east-2.amazonaws.com/cloudformation/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE.yaml&stackName=DeployWebinyProject + +### Template source + +- GitHub: https://github.com/webiny/webiny-js/blob/next/docs/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE.yaml +- S3: https://webiny-public.s3.us-east-2.amazonaws.com/cloudformation/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE.yaml + +## Related Documents + +- `infrastructure/introduction.mdx` — infrastructure overview +- `infrastructure/deployment-modes.mdx` — deployment modes + +## Tone Guidelines + +- Practical and brief — this is a how-to with a single action +- No step-by-step AWS console walkthrough (out of scope) diff --git a/docs/developer-docs/6.x/infrastructure/deploy-webiny-project-cf-template.mdx b/docs/developer-docs/6.x/infrastructure/deploy-webiny-project-cf-template.mdx new file mode 100644 index 000000000..9b7585d59 --- /dev/null +++ b/docs/developer-docs/6.x/infrastructure/deploy-webiny-project-cf-template.mdx @@ -0,0 +1,28 @@ +--- +id: infra6cft1 +title: AWS CloudFormation Template +description: Use the official AWS CloudFormation template to deploy Webiny with a least-privilege IAM role. +--- + +import { Alert } from "@/components/Alert"; + + + +- What the "Deploy Webiny Project" CloudFormation template is +- How to deploy it into your AWS account + + + +## Overview + +The **Deploy Webiny Project** AWS CloudFormation template is the recommended way to set up the IAM permissions needed to deploy Webiny. It creates an IAM role with three attached managed policies that follow the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege). + +You can inspect the full template before deploying: [view on GitHub](https://github.com/webiny/webiny-js/blob/next/docs/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE_V6.yaml). + +## Deploying the Template + +Before deploying, create an IAM role in your AWS account that will be used for Webiny deployments. The template does not create the role itself — it attaches the required managed policies to a role you provide. + +Once the role exists, click the link below to open the AWS CloudFormation console with the template pre-loaded. When prompted, enter the name of the IAM role you created: + +[Launch "Deploy Webiny Project" stack](https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://webiny-public.s3.us-east-2.amazonaws.com/cloudformation/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE_V6.yaml&stackName=DeployWebinyProject) diff --git a/docs/developer-docs/6.x/infrastructure/github-actions.ai.txt b/docs/developer-docs/6.x/infrastructure/github-actions.ai.txt new file mode 100644 index 000000000..3933db1ab --- /dev/null +++ b/docs/developer-docs/6.x/infrastructure/github-actions.ai.txt @@ -0,0 +1,75 @@ +AI Context: GitHub Actions (github-actions.mdx) + +## Source of Information + +1. `~/dev/wby-next4/docs/gh-actions-workflows/pushDev.yml` — dev push workflow +2. `~/dev/wby-next4/docs/gh-actions-workflows/pushStaging.yml` — staging push workflow +3. `~/dev/wby-next4/docs/gh-actions-workflows/pushProd.yml` — prod push workflow +4. `~/dev/wby-next4/docs/gh-actions-workflows/pullRequest.yml` — PR workflow (ephemeral env) +5. `~/dev/wby-next4/docs/gh-actions-workflows/pullRequestClosed.yml` — PR closed (destroy env) +6. `docs/developer-docs/5.x/core-development-concepts/ci-cd/setup.mdx` — v5 reference + +## Key Documentation Decisions + +1. No scaffold — users copy workflow files manually from GitHub +2. OIDC authentication is the central new concept vs v5; no static AWS_ACCESS_KEY_ID/SECRET in these workflows +3. `AWS_ROLE_ARN` replaces `AWS_ACCESS_KEY_ID` + `AWS_SECRET_ACCESS_KEY` +4. Pull request environments documented as a first-class feature (not mentioned in previous version) +5. `WEBINY_PROJECT_ID` and `WEBINY_PROJECT_API_KEY` are new secrets not in v5 docs +6. `DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS` is separate from `DEV_WEBINY_PULUMI_BACKEND` +7. OpenSearch secrets documented as conditional (only for DynamoDB + OpenSearch setup) +8. `concurrency` setting documented — prevents parallel deploys to same environment + +## Understanding + +### Workflow files (5 total) + +- pushDev.yml — triggered on push to `dev`; format + lint + `yarn webiny deploy --env dev` +- pushStaging.yml — triggered on push to `staging`; format + lint + deploy staging +- pushProd.yml — triggered on push to `prod`; format + lint + deploy prod +- pullRequest.yml — triggered on PR to `dev`; static analysis job + deploy job (deploys core + api + admin to `pr{number}` env) +- pullRequestClosed.yml — triggered on PR closed to `dev`; destroys `pr{number}` env + +### OIDC authentication + +- `permissions: id-token: write` enables OIDC token generation +- `aws-actions/configure-aws-credentials@v4` with `role-to-assume: ${{ secrets.DEV_AWS_ROLE_ARN }}` +- No static AWS credentials stored — short-lived token assumed per run +- Requires IAM role in each AWS account that trusts the GitHub OIDC provider + +### Full secrets list + +AWS: +- DEV/STAGING/PROD_AWS_ROLE_ARN +- DEV/STAGING/PROD_AWS_REGION + +Pulumi: +- DEV/STAGING/PROD_PULUMI_SECRETS_PROVIDER +- DEV/STAGING/PROD_PULUMI_CONFIG_PASSPHRASE +- DEV/STAGING/PROD_WEBINY_PULUMI_BACKEND +- DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS (PR environments only) + +Webiny: +- DEV/STAGING/PROD_WEBINY_PROJECT_ID +- DEV/STAGING/PROD_WEBINY_PROJECT_API_KEY + +OpenSearch (conditional): +- DEV_OPENSEARCH_DOMAIN_NAME +- OPENSEARCH_INDEX_PREFIX is set inline as `pr${{ github.event.pull_request.number }}` — not a secret + +### PR environment naming + +Env name: `pr{number}` e.g. `pr42` +Set via: `--env pr${{ github.event.pull_request.number }}` +Destroyed via: `yarn webiny destroy --env pr{number} --confirm-destroy-env pr{number} --debug` + +## Related Documents + +- `infrastructure/ci-cd.mdx` — environment strategy, Pulumi backend guidance +- `infrastructure/deploy-webiny-project-cf-template.mdx` — IAM role permissions + +## Tone Guidelines + +- Setup guide — action-oriented, not conceptual +- Secrets lists as code blocks for easy copy-paste +- OIDC section should explain why (no static credentials) not just how diff --git a/docs/developer-docs/6.x/infrastructure/github-actions.mdx b/docs/developer-docs/6.x/infrastructure/github-actions.mdx new file mode 100644 index 000000000..dca948483 --- /dev/null +++ b/docs/developer-docs/6.x/infrastructure/github-actions.mdx @@ -0,0 +1,189 @@ +--- +id: infra6ghac +title: GitHub Actions +description: Set up GitHub Actions workflows to automatically deploy your Webiny project across dev, staging, and prod environments. +--- + +import { Alert } from "@/components/Alert"; + + + +- What workflow files to add to your repository +- How OIDC authentication works with these workflows +- What repository secrets need to be configured +- How pull request environments work + + + +## Overview + +Webiny provides ready-made GitHub Actions workflow files that automatically deploy your project when code is pushed to the `dev`, `staging`, or `prod` branches, and spin up ephemeral environments for pull requests. + +The workflow files are available at [github.com/webiny/webiny-js/tree/next/docs/gh-actions-workflows](https://github.com/webiny/webiny-js/tree/next/docs/gh-actions-workflows). Copy them into your repository under `.github/workflows/`. + +## Workflow Files + +| File | Trigger | What it does | +| ----------------------- | --------------------------------- | ------------------------------------------------------------------- | +| `pushDev.yml` | Push to `dev` | Runs formatting/lint checks, deploys to `dev` environment | +| `pushStaging.yml` | Push to `staging` | Runs formatting/lint checks, deploys to `staging` environment | +| `pushProd.yml` | Push to `prod` | Runs formatting/lint checks, deploys to `prod` environment | +| `pullRequest.yml` | PR opened/updated targeting `dev` | Runs static analysis, deploys to ephemeral `pr{number}` environment | +| `pullRequestClosed.yml` | PR closed targeting `dev` | Destroys the ephemeral `pr{number}` environment | + +Each push workflow uses `concurrency` to ensure only one deployment per environment runs at a time — if a new push arrives while a deployment is in progress, the in-progress run is cancelled. + +The `--env` value passed to `yarn webiny deploy` matters. `pushProd.yml` uses `--env prod`, which triggers [production deployment mode](/{version}/infrastructure/deployment-modes) with a more robust cloud infrastructure setup. By default, `staging` does not use production mode — if you want `staging` to also deploy with production infrastructure, see the [Deployment Modes](/{version}/infrastructure/deployment-modes) article. + +## AWS Authentication (OIDC) + +The workflows authenticate to AWS using **OpenID Connect (OIDC)** via the `aws-actions/configure-aws-credentials` action. This means no static `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` credentials are stored as secrets — instead, each workflow assumes an IAM role using a short-lived token: + +```yaml +permissions: + id-token: write + contents: read + +steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.DEV_AWS_ROLE_ARN }} + aws-region: ${{ secrets.DEV_AWS_REGION }} +``` + +Each AWS account needs an IAM role that trusts the GitHub OIDC provider. The [AWS CloudFormation Template](/{version}/infrastructure/deploy-webiny-project-cf-template) is designed to be used together with this article: you pre-create an IAM role in each AWS account, then deploy the CloudFormation template which attaches the required deployment policies to that role. Use the role ARN as the `*_AWS_ROLE_ARN` secret for the corresponding environment. + +For instructions on setting up the GitHub OIDC provider in your AWS account, refer to the [GitHub documentation on configuring OIDC in AWS](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services). + +## Repository Secrets + +Navigate to your repository **Settings → Secrets and variables → Actions** and add the following secrets. Each secret is defined three times — once per environment — using the environment prefix. + +### AWS Role and Region + +```bash +DEV_AWS_ROLE_ARN # ARN of the IAM role to assume in the dev AWS account +DEV_AWS_REGION + +STAGING_AWS_ROLE_ARN +STAGING_AWS_REGION + +PROD_AWS_ROLE_ARN +PROD_AWS_REGION +``` + +### Pulumi State Backend + +Set the Pulumi backend for each environment. Typically an S3 URI within that environment's AWS account: + +```bash +DEV_WEBINY_PULUMI_BACKEND +STAGING_WEBINY_PULUMI_BACKEND +PROD_WEBINY_PULUMI_BACKEND +``` + +Pull request environments use their own backend so state doesn't mix with `dev`: + +```bash +DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS +``` + +See [CI/CD](/{version}/infrastructure/ci-cd#pulumi-state-files) for guidance on choosing a backend. + +### Pulumi Secrets Provider + +These are **optional**. Pulumi supports encrypting sensitive values stored in state files using a passphrase-based secrets provider. If you set `PULUMI_SECRETS_PROVIDER` to `passphrase`, any secrets you explicitly mark in your Pulumi code will be encrypted in the state file using `PULUMI_CONFIG_PASSPHRASE`. See [Managing Secrets with Pulumi](https://www.pulumi.com/blog/managing-secrets-with-pulumi/) for a full explanation of how Pulumi secrets work. + +Webiny itself does not store any sensitive data in Pulumi state files, so in most cases these can be left unset. They are worth configuring for `staging` and `prod` if your own infrastructure code stores secrets in state. + +```bash +DEV_PULUMI_SECRETS_PROVIDER # e.g. "passphrase" — optional +DEV_PULUMI_CONFIG_PASSPHRASE # random string — optional + +STAGING_PULUMI_SECRETS_PROVIDER +STAGING_PULUMI_CONFIG_PASSPHRASE + +PROD_PULUMI_SECRETS_PROVIDER +PROD_PULUMI_CONFIG_PASSPHRASE +``` + + + +If you do configure a `PULUMI_CONFIG_PASSPHRASE`, do not lose it. Without it you cannot redeploy or destroy the infrastructure for that environment. + + + +### Webiny Project + +These secrets are required if you have upgraded to the Business or Enterprise tier. They identify your project to the Webiny platform during deployment. See [Upgrade to Business](/{version}/get-started/upgrade) for details. + +```bash +DEV_WEBINY_PROJECT_ID +DEV_WEBINY_PROJECT_API_KEY + +STAGING_WEBINY_PROJECT_ID +STAGING_WEBINY_PROJECT_API_KEY + +PROD_WEBINY_PROJECT_ID +PROD_WEBINY_PROJECT_API_KEY +``` + +### OpenSearch (if applicable) + +Only used by the PR workflows (`pullRequest.yml` and `pullRequestClosed.yml`), and only when using the DynamoDB + OpenSearch database setup. The push workflows do not reference OpenSearch secrets — each of those environments provisions its own dedicated OpenSearch domain. + +PR environments are typically pointed at a shared OpenSearch domain from the `dev` AWS account. This avoids provisioning a dedicated domain per PR (which would be slow and expensive). See [Using a Shared OpenSearch Domain](/{version}/infrastructure/extensions/opensearch#using-a-shared-open-search-domain) for how to configure your project to use a shared domain. + +```bash +DEV_OPENSEARCH_DOMAIN_NAME # name of the shared OpenSearch domain in the dev AWS account +``` + +`OPENSEARCH_INDEX_PREFIX` is not a secret — the PR workflows set it inline as `pr${{ github.event.pull_request.number }}` so each PR environment gets its own index namespace within the shared domain. + +## Pull Request Environments + +When a pull request is opened or updated against `dev`, the `pullRequest.yml` workflow runs two jobs: + +1. **`build-test-static`** — runs formatting and lint checks (no AWS credentials required) +2. **`deploy`** — deploys a full ephemeral environment named `pr{number}` (e.g. `pr42`) using the `dev` AWS account credentials + +The deploy job requires `pull-requests: write` permission so it can post deployment status comments on the PR. It deploys each application separately: + +```yaml +- name: Deploy core + run: yarn webiny deploy core --env pr${{ github.event.pull_request.number }} + +- name: Deploy API + run: yarn webiny deploy api --env pr${{ github.event.pull_request.number }} + +- name: Deploy Admin + run: yarn webiny deploy admin --env pr${{ github.event.pull_request.number }} +``` + +This gives you a live environment to test changes before merging. The environment uses a separate Pulumi state backend (`DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS`) to keep PR state isolated from the `dev` environment. + + + +The PR workflows use the `dev` AWS account credentials by default. If you want to keep ephemeral environments completely separate from your long-lived `dev` environment — for example, to be able to run cleanup tools like [aws-nuke](https://github.com/ekristen/aws-nuke) against the ephemeral account without affecting `dev` — use a dedicated fourth AWS account for PR environments and set the `DEV_AWS_ROLE_ARN` / `DEV_AWS_REGION` secrets for that account. See [CI/CD](/{version}/infrastructure/ci-cd#aws-accounts) for more on this pattern. + + + +When the PR is closed (merged or abandoned), `pullRequestClosed.yml` automatically destroys the ephemeral environment: + +```yaml +- name: Destroy + run: yarn webiny destroy --env pr${{ github.event.pull_request.number }} --confirm-destroy-env pr${{ github.event.pull_request.number }} --debug +``` + +The `--confirm-destroy-env` flag is required as a safety measure — it must match the `--env` value to confirm you intend to destroy that environment. + +## Deployment Triggers + +Once secrets are configured: + +- Push to `dev` → deploys to the `dev` environment +- Push to `staging` → deploys to the `staging` environment +- Push to `prod` → deploys to the `prod` environment + +The `staging` and `prod` environments will not deploy until you first push code into those branches. To initialize all three environments after setup, merge `dev` → `staging` → `prod`. diff --git a/docs/developer-docs/6.x/navigation.tsx b/docs/developer-docs/6.x/navigation.tsx index c86f0662e..52fa4ec23 100644 --- a/docs/developer-docs/6.x/navigation.tsx +++ b/docs/developer-docs/6.x/navigation.tsx @@ -126,13 +126,19 @@ export const Navigation = ({ children }: { children: React.ReactNode }) => { - + + + + { - this.buildParam.key: string(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BuildParam] -}); -``` - ### `BuildParams` **Abstraction** — imported from `webiny/admin` @@ -152,25 +133,6 @@ namespace BuildParams { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { BuildParams } from "webiny/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private buildParams: BuildParams.Interface) {} - - public async execute(/* ... */): Promise { - this.buildParams.get(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BuildParams] -}); -``` - ### `createHasPermission` **Function** — imported from `webiny/admin` @@ -234,22 +196,3 @@ namespace NetworkErrorEventHandler { type Interface = IEventHandler; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { NetworkErrorEventHandler } from "webiny/admin"; - -class MyHandler implements NetworkErrorEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: NetworkErrorEventHandler.Event): Promise { - // implementation - } -} - -export default NetworkErrorEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/admin/build-params.mdx b/docs/developer-docs/6.x/reference/admin/build-params.mdx index c0ea63ccf..1ec993269 100644 --- a/docs/developer-docs/6.x/reference/admin/build-params.mdx +++ b/docs/developer-docs/6.x/reference/admin/build-params.mdx @@ -50,25 +50,6 @@ namespace BuildParam { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { BuildParam } from "webiny/admin/build-params"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private buildParam: BuildParam.Interface) {} - - public async execute(/* ... */): Promise { - this.buildParam.key: string(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BuildParam] -}); -``` - ## `BuildParams` **Abstraction** — imported from `webiny/admin/build-params` @@ -92,22 +73,3 @@ namespace BuildParams { type Interface = IBuildParams; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { BuildParams } from "webiny/admin/build-params"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private buildParams: BuildParams.Interface) {} - - public async execute(/* ... */): Promise { - this.buildParams.get(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BuildParams] -}); -``` diff --git a/docs/developer-docs/6.x/reference/admin/form.mdx b/docs/developer-docs/6.x/reference/admin/form.mdx index 11160ea49..3d99cbd05 100644 --- a/docs/developer-docs/6.x/reference/admin/form.mdx +++ b/docs/developer-docs/6.x/reference/admin/form.mdx @@ -127,21 +127,25 @@ import { Validation } from "webiny/admin/form"; ```typescript class Validation { - __validators:; - constructor(); - setValidator(name: string, callable: Validator): this; - getValidator(name: string): Validator; - async validate( - value: any, - validators: string, - options: ValidateOptions =; - validateSync( - value: any, - validators: string, - options: ValidateOptions =; - create(validators: string); - createSync(validators: string); - __parseValidateProperty(validators: string): ParsedValidators; + __validators: { + [key: string]: Validator; + }; + constructor(); + setValidator(name: string, callable: Validator): this; + getValidator(name: string): Validator; + async validate( + value: any, + validators: string, + options: ValidateOptions = {} + ): Promise; + validateSync( + value: any, + validators: string, + options: ValidateOptions = {} + ): boolean | ValidationError; + create(validators: string); + createSync(validators: string); + __parseValidateProperty(validators: string): ParsedValidators; } ``` diff --git a/docs/developer-docs/6.x/reference/admin/graphql-client.mdx b/docs/developer-docs/6.x/reference/admin/graphql-client.mdx index c7494f3d6..af342a846 100644 --- a/docs/developer-docs/6.x/reference/admin/graphql-client.mdx +++ b/docs/developer-docs/6.x/reference/admin/graphql-client.mdx @@ -45,22 +45,3 @@ namespace GraphQLClient { type Request = GraphQLRequest; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { GraphQLClient } from "webiny/admin/graphql-client"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private graphQLClient: GraphQLClient.Interface) {} - - public async execute(/* ... */): Promise { - await this.graphQLClient.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GraphQLClient] -}); -``` diff --git a/docs/developer-docs/6.x/reference/admin/router.mdx b/docs/developer-docs/6.x/reference/admin/router.mdx index 231cc1977..2762bf5e2 100644 --- a/docs/developer-docs/6.x/reference/admin/router.mdx +++ b/docs/developer-docs/6.x/reference/admin/router.mdx @@ -48,9 +48,15 @@ export class Route : undefined; constructor(route: RouteParams); - get name(); - get path(); - get params(): TParams extends RouteParamsDefinition ? RouteParamsInfer : undefined; + get name() { + return this.route.name; + } + get path() { + return this.route.path; + } + get params(): TParams extends RouteParamsDefinition ? RouteParamsInfer : undefined { + return this.schema; + } private coerceParams>(shape: T); } ``` diff --git a/docs/developer-docs/6.x/reference/admin/security.mdx b/docs/developer-docs/6.x/reference/admin/security.mdx index 33835881d..325e17f0e 100644 --- a/docs/developer-docs/6.x/reference/admin/security.mdx +++ b/docs/developer-docs/6.x/reference/admin/security.mdx @@ -98,25 +98,6 @@ namespace AuthenticationContext { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AuthenticationContext } from "webiny/admin/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private authenticationContext: AuthenticationContext.Interface) {} - - public async execute(/* ... */): Promise { - this.authenticationContext.clear(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AuthenticationContext] -}); -``` - ### `AuthenticationErrorEventHandler` **Event Handler Abstraction** — imported from `webiny/admin/security` @@ -142,25 +123,6 @@ namespace AuthenticationErrorEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { AuthenticationErrorEventHandler } from "webiny/admin/security"; - -class MyHandler implements AuthenticationErrorEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: AuthenticationErrorEventHandler.Event): Promise { - // implementation - } -} - -export default AuthenticationErrorEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `IdentityContext` **Abstraction** — imported from `webiny/admin/security` @@ -187,25 +149,6 @@ namespace IdentityContext { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { IdentityContext } from "webiny/admin/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private identityContext: IdentityContext.Interface) {} - - public async execute(/* ... */): Promise { - this.identityContext.getIdentity(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [IdentityContext] -}); -``` - ### `LogInUseCase` **Use Case Abstraction** — imported from `webiny/admin/security` @@ -231,25 +174,6 @@ namespace LogInUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { LogInUseCase } from "webiny/admin/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private logInUseCase: LogInUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.logInUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [LogInUseCase] -}); -``` - ### `LogOutUseCase` **Use Case Abstraction** — imported from `webiny/admin/security` @@ -273,22 +197,3 @@ namespace LogOutUseCase { type Interface = ILogOutUseCase; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { LogOutUseCase } from "webiny/admin/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private logOutUseCase: LogOutUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.logOutUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [LogOutUseCase] -}); -``` diff --git a/docs/developer-docs/6.x/reference/admin/ui.mdx b/docs/developer-docs/6.x/reference/admin/ui.mdx index b15da94de..cb9f95f8b 100644 --- a/docs/developer-docs/6.x/reference/admin/ui.mdx +++ b/docs/developer-docs/6.x/reference/admin/ui.mdx @@ -506,18 +506,67 @@ import { DynamicFieldset } from "webiny/admin/ui"; ```typescript class DynamicFieldset extends React.Component { - static defaultProps: Partial =; + static defaultProps: Partial = { + value: [] + }; header: React.ReactNode = null; footer: React.ReactNode = null; rows: React.ReactNode = null; empty: React.ReactNode = null; - actions =; - removeData = (index: number) =>; - addData = (index = -1) =>; - renderHeader = (cb: () => React.ReactNode): React.ReactNode =>; - renderFooter = (cb: () => React.ReactNode): React.ReactNode =>; - renderRow = (cb: ChildrenRenderPropRowCallable): React.ReactNode =>; - renderEmpty = (cb: () => React.ReactNode): React.ReactNode =>; + actions = { + add: + (index = -1) => + () => + this.addData(index), + remove: + (index = -1) => + () => + this.removeData(index) + }; + removeData = (index: number) => { + const { value, onChange } = this.props; + if (!value) { + return; + } + onChange([...value.slice(0, index), ...value.slice(index + 1)]); + }; + addData = (index = -1) => { + const { onChange, onAdd } = this.props; + let value = this.props.value; + if (!value) { + value = []; + } + + const newValue = typeof onAdd === "function" ? onAdd() : {}; + + if (index < 0) { + onChange([...value, newValue]); + } else { + onChange([...value.slice(0, index + 1), newValue, ...value.slice(index + 1)]); + } + }; + renderHeader = (cb: () => React.ReactNode): React.ReactNode => { + this.header = cb(); + return null; + }; + renderFooter = (cb: () => React.ReactNode): React.ReactNode => { + this.footer = cb(); + return null; + }; + renderRow = (cb: ChildrenRenderPropRowCallable): React.ReactNode => { + const { value } = this.props; + if (!value) { + return null; + } + this.rows = value.map((record, index) => { + return
{cb({ data: record, index })}
; + }); + return null; + }; + renderEmpty = (cb: () => React.ReactNode): React.ReactNode => { + this.empty = cb(); + return null; + }; public renderComponent(): React.ReactNode; public override render(); } @@ -1261,13 +1310,16 @@ import { TimeAgo } from "webiny/admin/ui"; ```typescript export default class TimeAgo extends React.PureComponent { - static defaultProps:; - dom: HTMLTimeElement; - componentDidMount(): void; - componentDidUpdate(): void; - renderTimeAgo(): void; - componentWillUnmount(): void; - render(): JSX.Element; + static defaultProps: { + live: boolean; + className: string; + }; + dom: HTMLTimeElement; + componentDidMount(): void; + componentDidUpdate(): void; + renderTimeAgo(): void; + componentWillUnmount(): void; + render(): JSX.Element; } ``` diff --git a/docs/developer-docs/6.x/reference/api/build-params.mdx b/docs/developer-docs/6.x/reference/api/build-params.mdx index 3c1dad99e..610d8b272 100644 --- a/docs/developer-docs/6.x/reference/api/build-params.mdx +++ b/docs/developer-docs/6.x/reference/api/build-params.mdx @@ -50,25 +50,6 @@ namespace BuildParam { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { BuildParam } from "webiny/api/build-params"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private buildParam: BuildParam.Interface) {} - - public async execute(/* ... */): Promise { - this.buildParam.key: string(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BuildParam] -}); -``` - ## `BuildParams` **Abstraction** — imported from `webiny/api/build-params` @@ -92,22 +73,3 @@ namespace BuildParams { type Interface = IBuildParams; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { BuildParams } from "webiny/api/build-params"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private buildParams: BuildParams.Interface) {} - - public async execute(/* ... */): Promise { - this.buildParams.get(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BuildParams] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/cms/entry.mdx b/docs/developer-docs/6.x/reference/api/cms/entry.mdx index 3ba4b93bc..609cc2677 100644 --- a/docs/developer-docs/6.x/reference/api/cms/entry.mdx +++ b/docs/developer-docs/6.x/reference/api/cms/entry.mdx @@ -164,6 +164,8 @@ import { CreateEntryRevisionFromUseCase } from "webiny/api/cms/entry"; **Interface `CreateEntryRevisionFromUseCase.Interface`:** +CreateEntryRevisionFrom Use Case - Creates a new revision from an existing entry. + ```typescript interface CreateEntryRevisionFromUseCase.Interface { execute( @@ -187,27 +189,6 @@ namespace CreateEntryRevisionFromUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateEntryRevisionFromUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private createEntryRevisionFromUseCase: CreateEntryRevisionFromUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.createEntryRevisionFromUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateEntryRevisionFromUseCase] -}); -``` - ### `CreateEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -218,6 +199,8 @@ import { CreateEntryUseCase } from "webiny/api/cms/entry"; **Interface `CreateEntryUseCase.Interface`:** +CreateEntry Use Case + ```typescript interface CreateEntryUseCase.Interface { execute( @@ -240,25 +223,6 @@ namespace CreateEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createEntryUseCase: CreateEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateEntryUseCase] -}); -``` - ### `DeleteEntryRevisionUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -269,6 +233,9 @@ import { DeleteEntryRevisionUseCase } from "webiny/api/cms/entry"; **Interface `DeleteEntryRevisionUseCase.Interface`:** +DeleteEntryRevision Use Case - Deletes a specific revision of an entry. +Handles special cases like deleting the latest revision. + ```typescript interface DeleteEntryRevisionUseCase.Interface { execute(model: CmsModel, revisionId: string): Promise>; @@ -285,25 +252,6 @@ namespace DeleteEntryRevisionUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteEntryRevisionUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteEntryRevisionUseCase: DeleteEntryRevisionUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteEntryRevisionUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteEntryRevisionUseCase] -}); -``` - ### `DeleteEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -314,6 +262,9 @@ import { DeleteEntryUseCase } from "webiny/api/cms/entry"; **Interface `DeleteEntryUseCase.Interface`:** +DeleteEntry Use Case - Permanently deletes an entry from the database. +This is a hard delete that removes all traces of the entry. + ```typescript interface DeleteEntryUseCase.Interface { execute( @@ -335,25 +286,6 @@ namespace DeleteEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteEntryUseCase: DeleteEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteEntryUseCase] -}); -``` - ### `DeleteMultipleEntriesUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -384,27 +316,6 @@ namespace DeleteMultipleEntriesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteMultipleEntriesUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private deleteMultipleEntriesUseCase: DeleteMultipleEntriesUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.deleteMultipleEntriesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteMultipleEntriesUseCase] -}); -``` - ### `GetEntriesByIdsUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -415,6 +326,9 @@ import { GetEntriesByIdsUseCase } from "webiny/api/cms/entry"; **Interface `GetEntriesByIdsUseCase.Interface`:** +GetEntriesByIds Use Case - Fetches multiple entries by their exact revision IDs. +Returns array of entries (excludes deleted entries via decorator). + ```typescript interface GetEntriesByIdsUseCase.Interface { execute( @@ -434,25 +348,6 @@ namespace GetEntriesByIdsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetEntriesByIdsUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getEntriesByIdsUseCase: GetEntriesByIdsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getEntriesByIdsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetEntriesByIdsUseCase] -}); -``` - ### `GetEntryByIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -463,6 +358,9 @@ import { GetEntryByIdUseCase } from "webiny/api/cms/entry"; **Interface `GetEntryByIdUseCase.Interface`:** +GetEntryById Use Case - Fetches a single entry by its exact revision ID. +Returns entry or fails with EntryNotFoundError if not found or deleted. + ```typescript interface GetEntryByIdUseCase.Interface { execute( @@ -482,25 +380,6 @@ namespace GetEntryByIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetEntryByIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getEntryByIdUseCase: GetEntryByIdUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getEntryByIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetEntryByIdUseCase] -}); -``` - ### `GetEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -511,6 +390,9 @@ import { GetEntryUseCase } from "webiny/api/cms/entry"; **Interface `GetEntryUseCase.Interface`:** +GetEntry Use Case - Gets a single entry by query parameters (where + sort). +Uses list operation with limit 1 and returns first result or NotFoundError. + ```typescript interface GetEntryUseCase.Interface { execute( @@ -531,25 +413,6 @@ namespace GetEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getEntryUseCase: GetEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetEntryUseCase] -}); -``` - ### `GetLatestDeletedRevisionByEntryIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -560,6 +423,9 @@ import { GetLatestDeletedRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; **Interface `GetLatestDeletedRevisionByEntryIdUseCase.Interface`:** +Base internal use case - returns entry regardless of deleted state. +This is used internally by the three public variations. + ```typescript interface GetLatestDeletedRevisionByEntryIdUseCase.Interface { execute( @@ -580,27 +446,6 @@ namespace GetLatestDeletedRevisionByEntryIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetLatestDeletedRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getLatestDeletedRevisionByEntryIdUseCase: GetLatestDeletedRevisionByEntryIdUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getLatestDeletedRevisionByEntryIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetLatestDeletedRevisionByEntryIdUseCase] -}); -``` - ### `GetLatestEntriesByIdsUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -611,6 +456,9 @@ import { GetLatestEntriesByIdsUseCase } from "webiny/api/cms/entry"; **Interface `GetLatestEntriesByIdsUseCase.Interface`:** +GetLatestEntriesByIds Use Case - Fetches latest revisions by entry IDs. +Returns array of latest entries (excludes deleted entries via decorator). + ```typescript interface GetLatestEntriesByIdsUseCase.Interface { execute( @@ -630,27 +478,6 @@ namespace GetLatestEntriesByIdsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetLatestEntriesByIdsUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getLatestEntriesByIdsUseCase: GetLatestEntriesByIdsUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getLatestEntriesByIdsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetLatestEntriesByIdsUseCase] -}); -``` - ### `GetLatestRevisionByEntryIdBaseUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -661,6 +488,9 @@ import { GetLatestRevisionByEntryIdBaseUseCase } from "webiny/api/cms/entry"; **Interface `GetLatestRevisionByEntryIdBaseUseCase.Interface`:** +Base internal use case - returns entry regardless of deleted state. +This is used internally by the three public variations. + ```typescript interface GetLatestRevisionByEntryIdBaseUseCase.Interface { execute( @@ -681,27 +511,6 @@ namespace GetLatestRevisionByEntryIdBaseUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetLatestRevisionByEntryIdBaseUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getLatestRevisionByEntryIdBaseUseCase: GetLatestRevisionByEntryIdBaseUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getLatestRevisionByEntryIdBaseUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetLatestRevisionByEntryIdBaseUseCase] -}); -``` - ### `GetLatestRevisionByEntryIdIncludingDeletedUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -712,6 +521,9 @@ import { GetLatestRevisionByEntryIdIncludingDeletedUseCase } from "webiny/api/cm **Interface `GetLatestRevisionByEntryIdIncludingDeletedUseCase.Interface`:** +Base internal use case - returns entry regardless of deleted state. +This is used internally by the three public variations. + ```typescript interface GetLatestRevisionByEntryIdIncludingDeletedUseCase.Interface { execute( @@ -732,27 +544,6 @@ namespace GetLatestRevisionByEntryIdIncludingDeletedUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetLatestRevisionByEntryIdIncludingDeletedUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getLatestRevisionByEntryIdIncludingDeletedUseCase: GetLatestRevisionByEntryIdIncludingDeletedUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getLatestRevisionByEntryIdIncludingDeletedUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetLatestRevisionByEntryIdIncludingDeletedUseCase] -}); -``` - ### `GetLatestRevisionByEntryIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -763,6 +554,9 @@ import { GetLatestRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; **Interface `GetLatestRevisionByEntryIdUseCase.Interface`:** +Base internal use case - returns entry regardless of deleted state. +This is used internally by the three public variations. + ```typescript interface GetLatestRevisionByEntryIdUseCase.Interface { execute( @@ -783,27 +577,6 @@ namespace GetLatestRevisionByEntryIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetLatestRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getLatestRevisionByEntryIdUseCase: GetLatestRevisionByEntryIdUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getLatestRevisionByEntryIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetLatestRevisionByEntryIdUseCase] -}); -``` - ### `GetPreviousRevisionByEntryIdBaseUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -814,6 +587,9 @@ import { GetPreviousRevisionByEntryIdBaseUseCase } from "webiny/api/cms/entry"; **Interface `GetPreviousRevisionByEntryIdBaseUseCase.Interface`:** +Base internal use case - returns entry regardless of deleted state. +This is used internally by the public variation. + ```typescript interface GetPreviousRevisionByEntryIdBaseUseCase.Interface { execute( @@ -834,27 +610,6 @@ namespace GetPreviousRevisionByEntryIdBaseUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPreviousRevisionByEntryIdBaseUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getPreviousRevisionByEntryIdBaseUseCase: GetPreviousRevisionByEntryIdBaseUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getPreviousRevisionByEntryIdBaseUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPreviousRevisionByEntryIdBaseUseCase] -}); -``` - ### `GetPreviousRevisionByEntryIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -865,6 +620,9 @@ import { GetPreviousRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; **Interface `GetPreviousRevisionByEntryIdUseCase.Interface`:** +Base internal use case - returns entry regardless of deleted state. +This is used internally by the public variation. + ```typescript interface GetPreviousRevisionByEntryIdUseCase.Interface { execute( @@ -885,27 +643,6 @@ namespace GetPreviousRevisionByEntryIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPreviousRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getPreviousRevisionByEntryIdUseCase: GetPreviousRevisionByEntryIdUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getPreviousRevisionByEntryIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPreviousRevisionByEntryIdUseCase] -}); -``` - ### `GetPublishedEntriesByIdsUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -916,6 +653,9 @@ import { GetPublishedEntriesByIdsUseCase } from "webiny/api/cms/entry"; **Interface `GetPublishedEntriesByIdsUseCase.Interface`:** +GetPublishedEntriesByIds Use Case - Fetches published revisions by entry IDs. +Returns array of published entries (excludes deleted entries via decorator). + ```typescript interface GetPublishedEntriesByIdsUseCase.Interface { execute( @@ -935,27 +675,6 @@ namespace GetPublishedEntriesByIdsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPublishedEntriesByIdsUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getPublishedEntriesByIdsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPublishedEntriesByIdsUseCase] -}); -``` - ### `GetPublishedRevisionByEntryIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -966,6 +685,8 @@ import { GetPublishedRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; **Interface `GetPublishedRevisionByEntryIdUseCase.Interface`:** +GetPublishedRevisionByEntryId Use Case + ```typescript interface GetPublishedRevisionByEntryIdUseCase.Interface { execute( @@ -985,27 +706,6 @@ namespace GetPublishedRevisionByEntryIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPublishedRevisionByEntryIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getPublishedRevisionByEntryIdUseCase: GetPublishedRevisionByEntryIdUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getPublishedRevisionByEntryIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPublishedRevisionByEntryIdUseCase] -}); -``` - ### `GetRevisionByIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1016,6 +716,9 @@ import { GetRevisionByIdUseCase } from "webiny/api/cms/entry"; **Interface `GetRevisionByIdUseCase.Interface`:** +GetRevisionById Use Case - Fetches a specific entry revision by ID. +Returns the entry or fails with EntryNotFoundError if not found or deleted. + ```typescript interface GetRevisionByIdUseCase.Interface { execute( @@ -1035,25 +738,6 @@ namespace GetRevisionByIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetRevisionByIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getRevisionByIdUseCase: GetRevisionByIdUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getRevisionByIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetRevisionByIdUseCase] -}); -``` - ### `GetRevisionsByEntryIdUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1064,6 +748,9 @@ import { GetRevisionsByEntryIdUseCase } from "webiny/api/cms/entry"; **Interface `GetRevisionsByEntryIdUseCase.Interface`:** +GetRevisionsByEntryId Use Case - Fetches all revisions for a given entry ID. +Returns array of entry revisions. + ```typescript interface GetRevisionsByEntryIdUseCase.Interface { execute( @@ -1083,27 +770,6 @@ namespace GetRevisionsByEntryIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetRevisionsByEntryIdUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private getRevisionsByEntryIdUseCase: GetRevisionsByEntryIdUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.getRevisionsByEntryIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetRevisionsByEntryIdUseCase] -}); -``` - ### `GetSingletonEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1114,6 +780,10 @@ import { GetSingletonEntryUseCase } from "webiny/api/cms/entry"; **Interface `GetSingletonEntryUseCase.Interface`:** +GetSingletonEntry Use Case + +Gets the singleton entry for a model, creating it if it doesn't exist. + ```typescript interface GetSingletonEntryUseCase.Interface { execute( @@ -1132,25 +802,6 @@ namespace GetSingletonEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetSingletonEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getSingletonEntryUseCase: GetSingletonEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getSingletonEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetSingletonEntryUseCase] -}); -``` - ### `ListDeletedEntriesUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1161,6 +812,8 @@ import { ListDeletedEntriesUseCase } from "webiny/api/cms/entry"; **Interface `ListDeletedEntriesUseCase.Interface`:** +ListDeletedEntries Use Case - Lists deleted entries (manage API). + ```typescript interface ListDeletedEntriesUseCase.Interface { execute( @@ -1181,25 +834,6 @@ namespace ListDeletedEntriesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListDeletedEntriesUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listDeletedEntriesUseCase: ListDeletedEntriesUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listDeletedEntriesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListDeletedEntriesUseCase] -}); -``` - ### `ListEntriesUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1210,6 +844,9 @@ import { ListEntriesUseCase } from "webiny/api/cms/entry"; **Interface `ListEntriesUseCase.Interface`:** +Base ListEntries Use Case - Internal base use case for listing entries. +Used by specific variants (Latest, Published, Deleted). + ```typescript interface ListEntriesUseCase.Interface { execute( @@ -1230,25 +867,6 @@ namespace ListEntriesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListEntriesUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listEntriesUseCase: ListEntriesUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listEntriesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListEntriesUseCase] -}); -``` - ### `ListLatestEntriesUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1259,6 +877,8 @@ import { ListLatestEntriesUseCase } from "webiny/api/cms/entry"; **Interface `ListLatestEntriesUseCase.Interface`:** +ListLatestEntries Use Case - Lists latest entries (manage API). + ```typescript interface ListLatestEntriesUseCase.Interface { execute( @@ -1279,25 +899,6 @@ namespace ListLatestEntriesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListLatestEntriesUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listLatestEntriesUseCase: ListLatestEntriesUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listLatestEntriesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListLatestEntriesUseCase] -}); -``` - ### `ListPublishedEntriesUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1308,6 +909,8 @@ import { ListPublishedEntriesUseCase } from "webiny/api/cms/entry"; **Interface `ListPublishedEntriesUseCase.Interface`:** +ListPublishedEntries Use Case - Lists published entries (read API). + ```typescript interface ListPublishedEntriesUseCase.Interface { execute( @@ -1328,25 +931,6 @@ namespace ListPublishedEntriesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListPublishedEntriesUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listPublishedEntriesUseCase: ListPublishedEntriesUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listPublishedEntriesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListPublishedEntriesUseCase] -}); -``` - ### `MoveEntryToBinUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1357,6 +941,9 @@ import { MoveEntryToBinUseCase } from "webiny/api/cms/entry"; **Interface `MoveEntryToBinUseCase.Interface`:** +MoveEntryToBin Use Case - Soft deletes an entry by marking it as deleted. +This moves the entry to the bin (trash) instead of permanently deleting it. + ```typescript interface MoveEntryToBinUseCase.Interface { execute(model: CmsModel, id: string): Promise>; @@ -1372,25 +959,6 @@ namespace MoveEntryToBinUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { MoveEntryToBinUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private moveEntryToBinUseCase: MoveEntryToBinUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.moveEntryToBinUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [MoveEntryToBinUseCase] -}); -``` - ### `MoveEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1401,6 +969,8 @@ import { MoveEntryUseCase } from "webiny/api/cms/entry"; **Interface `MoveEntryUseCase.Interface`:** +MoveEntry Use Case - Moves an entry to a different folder. + ```typescript interface MoveEntryUseCase.Interface { execute( @@ -1421,25 +991,6 @@ namespace MoveEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { MoveEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private moveEntryUseCase: MoveEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.moveEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [MoveEntryUseCase] -}); -``` - ### `PublishEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1450,6 +1001,8 @@ import { PublishEntryUseCase } from "webiny/api/cms/entry"; **Interface `PublishEntryUseCase.Interface`:** +PublishEntry Use Case - Publishes an entry revision. + ```typescript interface PublishEntryUseCase.Interface { execute( @@ -1469,25 +1022,6 @@ namespace PublishEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { PublishEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private publishEntryUseCase: PublishEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.publishEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [PublishEntryUseCase] -}); -``` - ### `RepublishEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1498,6 +1032,9 @@ import { RepublishEntryUseCase } from "webiny/api/cms/entry"; **Interface `RepublishEntryUseCase.Interface`:** +RepublishEntry Use Case - Republishes an already published entry. +This updates the entry and publishes it again. + ```typescript interface RepublishEntryUseCase.Interface { execute( @@ -1517,25 +1054,6 @@ namespace RepublishEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { RepublishEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private republishEntryUseCase: RepublishEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.republishEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [RepublishEntryUseCase] -}); -``` - ### `RestoreEntryFromBinUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1546,6 +1064,9 @@ import { RestoreEntryFromBinUseCase } from "webiny/api/cms/entry"; **Interface `RestoreEntryFromBinUseCase.Interface`:** +RestoreEntryFromBin Use Case - Restores a soft-deleted entry from the bin. +This clears the wbyDeleted flag and restores the entry to its original folder. + ```typescript interface RestoreEntryFromBinUseCase.Interface { execute( @@ -1565,25 +1086,6 @@ namespace RestoreEntryFromBinUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { RestoreEntryFromBinUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private restoreEntryFromBinUseCase: RestoreEntryFromBinUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.restoreEntryFromBinUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [RestoreEntryFromBinUseCase] -}); -``` - ### `UnpublishEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1594,6 +1096,8 @@ import { UnpublishEntryUseCase } from "webiny/api/cms/entry"; **Interface `UnpublishEntryUseCase.Interface`:** +UnpublishEntry Use Case + ```typescript interface UnpublishEntryUseCase.Interface { execute( @@ -1613,25 +1117,6 @@ namespace UnpublishEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UnpublishEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private unpublishEntryUseCase: UnpublishEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.unpublishEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UnpublishEntryUseCase] -}); -``` - ### `UpdateEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1642,6 +1127,8 @@ import { UpdateEntryUseCase } from "webiny/api/cms/entry"; **Interface `UpdateEntryUseCase.Interface`:** +UpdateEntry Use Case + ```typescript interface UpdateEntryUseCase.Interface { execute( @@ -1667,25 +1154,6 @@ namespace UpdateEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateEntryUseCase: UpdateEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateEntryUseCase] -}); -``` - ### `UpdateSingletonEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1696,6 +1164,10 @@ import { UpdateSingletonEntryUseCase } from "webiny/api/cms/entry"; **Interface `UpdateSingletonEntryUseCase.Interface`:** +UpdateSingletonEntry Use Case + +Updates the singleton entry for a model. + ```typescript interface UpdateSingletonEntryUseCase.Interface { execute( @@ -1718,25 +1190,6 @@ namespace UpdateSingletonEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateSingletonEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateSingletonEntryUseCase: UpdateSingletonEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateSingletonEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateSingletonEntryUseCase] -}); -``` - ### `ValidateEntryUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/entry` @@ -1768,25 +1221,6 @@ namespace ValidateEntryUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ValidateEntryUseCase } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private validateEntryUseCase: ValidateEntryUseCase.Interface) {} - - public async execute(/* ... */): Promise { - this.validateEntryUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ValidateEntryUseCase] -}); -``` - ## Event Handlers ### `EntryAfterCreateEventHandler` @@ -1824,25 +1258,6 @@ namespace EntryAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterCreateEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterCreateEventHandler.Event): Promise { - const { entry, input, model } = event.payload; - } -} - -export default EntryAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -1868,25 +1283,6 @@ namespace EntryAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterDeleteEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default EntryAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterDeleteMultipleEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -1912,25 +1308,6 @@ namespace EntryAfterDeleteMultipleEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterDeleteMultipleEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterDeleteMultipleEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterDeleteMultipleEventHandler.Event): Promise { - // implementation - } -} - -export default EntryAfterDeleteMultipleEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterMoveEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -1956,25 +1333,6 @@ namespace EntryAfterMoveEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterMoveEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterMoveEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterMoveEventHandler.Event): Promise { - // implementation - } -} - -export default EntryAfterMoveEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterPublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2000,25 +1358,6 @@ namespace EntryAfterPublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterPublishEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterPublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterPublishEventHandler.Event): Promise { - // implementation - } -} - -export default EntryAfterPublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterRepublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2044,25 +1383,6 @@ namespace EntryAfterRepublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterRepublishEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterRepublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterRepublishEventHandler.Event): Promise { - // implementation - } -} - -export default EntryAfterRepublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterRestoreFromBinEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2088,25 +1408,6 @@ namespace EntryAfterRestoreFromBinEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterRestoreFromBinEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterRestoreFromBinEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterRestoreFromBinEventHandler.Event): Promise { - // implementation - } -} - -export default EntryAfterRestoreFromBinEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterUnpublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2142,25 +1443,6 @@ namespace EntryAfterUnpublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterUnpublishEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterUnpublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterUnpublishEventHandler.Event): Promise { - const { entry, storageEntry, model } = event.payload; - } -} - -export default EntryAfterUnpublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2197,25 +1479,6 @@ namespace EntryAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryAfterUpdateEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryAfterUpdateEventHandler.Event): Promise { - const { entry, original, input, model } = event.payload; - } -} - -export default EntryAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2251,25 +1514,6 @@ namespace EntryBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeCreateEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeCreateEventHandler.Event): Promise { - const { entry, input, model } = event.payload; - } -} - -export default EntryBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2295,25 +1539,6 @@ namespace EntryBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeDeleteEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default EntryBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeDeleteMultipleEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2339,25 +1564,6 @@ namespace EntryBeforeDeleteMultipleEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeDeleteMultipleEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeDeleteMultipleEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeDeleteMultipleEventHandler.Event): Promise { - // implementation - } -} - -export default EntryBeforeDeleteMultipleEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeMoveEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2383,25 +1589,6 @@ namespace EntryBeforeMoveEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeMoveEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeMoveEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeMoveEventHandler.Event): Promise { - // implementation - } -} - -export default EntryBeforeMoveEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforePublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2427,25 +1614,6 @@ namespace EntryBeforePublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforePublishEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforePublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforePublishEventHandler.Event): Promise { - // implementation - } -} - -export default EntryBeforePublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeRepublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2471,25 +1639,6 @@ namespace EntryBeforeRepublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeRepublishEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeRepublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeRepublishEventHandler.Event): Promise { - // implementation - } -} - -export default EntryBeforeRepublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeRestoreFromBinEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2515,25 +1664,6 @@ namespace EntryBeforeRestoreFromBinEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeRestoreFromBinEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeRestoreFromBinEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeRestoreFromBinEventHandler.Event): Promise { - // implementation - } -} - -export default EntryBeforeRestoreFromBinEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeUnpublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2568,25 +1698,6 @@ namespace EntryBeforeUnpublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeUnpublishEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeUnpublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeUnpublishEventHandler.Event): Promise { - const { entry, model } = event.payload; - } -} - -export default EntryBeforeUnpublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2623,25 +1734,6 @@ namespace EntryBeforeUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryBeforeUpdateEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryBeforeUpdateEventHandler.Event): Promise { - const { entry, original, input, model } = event.payload; - } -} - -export default EntryBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryRevisionAfterCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2667,25 +1759,6 @@ namespace EntryRevisionAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryRevisionAfterCreateEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryRevisionAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryRevisionAfterCreateEventHandler.Event): Promise { - // implementation - } -} - -export default EntryRevisionAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryRevisionAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2711,25 +1784,6 @@ namespace EntryRevisionAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryRevisionAfterDeleteEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryRevisionAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryRevisionAfterDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default EntryRevisionAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryRevisionBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2755,25 +1809,6 @@ namespace EntryRevisionBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryRevisionBeforeCreateEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryRevisionBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryRevisionBeforeCreateEventHandler.Event): Promise { - // implementation - } -} - -export default EntryRevisionBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `EntryRevisionBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/entry` @@ -2799,25 +1834,6 @@ namespace EntryRevisionBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { EntryRevisionBeforeDeleteEventHandler } from "webiny/api/cms/entry"; - -class MyHandler implements EntryRevisionBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: EntryRevisionBeforeDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default EntryRevisionBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ## Services ### `CmsSortMapper` @@ -2845,25 +1861,6 @@ namespace CmsSortMapper { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CmsSortMapper } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private cmsSortMapper: CmsSortMapper.Interface) {} - - public async execute(/* ... */): Promise { - this.cmsSortMapper.map(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CmsSortMapper] -}); -``` - ### `CmsWhereMapper` **Abstraction** — imported from `webiny/api/cms/entry` @@ -2889,25 +1886,6 @@ namespace CmsWhereMapper { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CmsWhereMapper } from "webiny/api/cms/entry"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private cmsWhereMapper: CmsWhereMapper.Interface) {} - - public async execute(/* ... */): Promise { - this.cmsWhereMapper.map(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CmsWhereMapper] -}); -``` - ## Types & Classes ### `CmsEntry` @@ -2963,8 +1941,12 @@ export class EntryId { static create(); static from(value: string); toString(); - get id(); - get version(); + get id() { + return this._id; + }; + get version() { + return this._version; + }; incrementVersion(); decrementVersion(); setVersion(version: number); diff --git a/docs/developer-docs/6.x/reference/api/cms/group.mdx b/docs/developer-docs/6.x/reference/api/cms/group.mdx index 2f74c063e..6dfdaec1f 100644 --- a/docs/developer-docs/6.x/reference/api/cms/group.mdx +++ b/docs/developer-docs/6.x/reference/api/cms/group.mdx @@ -70,6 +70,8 @@ import { CreateGroupUseCase } from "webiny/api/cms/group"; **Interface `CreateGroupUseCase.Interface`:** +CreateGroup Use Case + ```typescript interface CreateGroupUseCase.Interface { execute(input: CmsGroupCreateInput): Promise>; @@ -87,25 +89,6 @@ namespace CreateGroupUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateGroupUseCase } from "webiny/api/cms/group"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createGroupUseCase: CreateGroupUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createGroupUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateGroupUseCase] -}); -``` - ### `DeleteGroupUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/group` @@ -116,6 +99,8 @@ import { DeleteGroupUseCase } from "webiny/api/cms/group"; **Interface `DeleteGroupUseCase.Interface`:** +DeleteGroup Use Case + ```typescript interface DeleteGroupUseCase.Interface { execute(groupId: string): Promise>; @@ -132,25 +117,6 @@ namespace DeleteGroupUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteGroupUseCase } from "webiny/api/cms/group"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteGroupUseCase: DeleteGroupUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteGroupUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteGroupUseCase] -}); -``` - ### `GetGroupUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/group` @@ -161,6 +127,8 @@ import { GetGroupUseCase } from "webiny/api/cms/group"; **Interface `GetGroupUseCase.Interface`:** +GetGroup Use Case + ```typescript interface GetGroupUseCase.Interface { execute(groupId: string): Promise>; @@ -177,25 +145,6 @@ namespace GetGroupUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetGroupUseCase } from "webiny/api/cms/group"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getGroupUseCase: GetGroupUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getGroupUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetGroupUseCase] -}); -``` - ### `ListGroupsUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/group` @@ -206,6 +155,8 @@ import { ListGroupsUseCase } from "webiny/api/cms/group"; **Interface `ListGroupsUseCase.Interface`:** +ListGroups Use Case + ```typescript interface ListGroupsUseCase.Interface { execute(): Promise>; @@ -222,25 +173,6 @@ namespace ListGroupsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListGroupsUseCase } from "webiny/api/cms/group"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listGroupsUseCase: ListGroupsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listGroupsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListGroupsUseCase] -}); -``` - ### `UpdateGroupUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/group` @@ -251,6 +183,8 @@ import { UpdateGroupUseCase } from "webiny/api/cms/group"; **Interface `UpdateGroupUseCase.Interface`:** +UpdateGroup Use Case + ```typescript interface UpdateGroupUseCase.Interface { execute(groupId: string, input: CmsGroupUpdateInput): Promise>; @@ -268,25 +202,6 @@ namespace UpdateGroupUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateGroupUseCase } from "webiny/api/cms/group"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateGroupUseCase: UpdateGroupUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateGroupUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateGroupUseCase] -}); -``` - ## Event Handlers ### `GroupAfterCreateEventHandler` @@ -322,25 +237,6 @@ namespace GroupAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { GroupAfterCreateEventHandler } from "webiny/api/cms/group"; - -class MyHandler implements GroupAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: GroupAfterCreateEventHandler.Event): Promise { - const { group } = event.payload; - } -} - -export default GroupAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `GroupAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/group` @@ -374,25 +270,6 @@ namespace GroupAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { GroupAfterDeleteEventHandler } from "webiny/api/cms/group"; - -class MyHandler implements GroupAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: GroupAfterDeleteEventHandler.Event): Promise { - const { group } = event.payload; - } -} - -export default GroupAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `GroupAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/group` @@ -427,25 +304,6 @@ namespace GroupAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { GroupAfterUpdateEventHandler } from "webiny/api/cms/group"; - -class MyHandler implements GroupAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: GroupAfterUpdateEventHandler.Event): Promise { - const { original, group } = event.payload; - } -} - -export default GroupAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `GroupBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/group` @@ -479,25 +337,6 @@ namespace GroupBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { GroupBeforeCreateEventHandler } from "webiny/api/cms/group"; - -class MyHandler implements GroupBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: GroupBeforeCreateEventHandler.Event): Promise { - const { group } = event.payload; - } -} - -export default GroupBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `GroupBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/group` @@ -531,25 +370,6 @@ namespace GroupBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { GroupBeforeDeleteEventHandler } from "webiny/api/cms/group"; - -class MyHandler implements GroupBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: GroupBeforeDeleteEventHandler.Event): Promise { - const { group } = event.payload; - } -} - -export default GroupBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `GroupBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/group` @@ -584,25 +404,6 @@ namespace GroupBeforeUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { GroupBeforeUpdateEventHandler } from "webiny/api/cms/group"; - -class MyHandler implements GroupBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: GroupBeforeUpdateEventHandler.Event): Promise { - const { original, group } = event.payload; - } -} - -export default GroupBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ## Services ### `ModelGroupFactory` @@ -631,25 +432,6 @@ namespace ModelGroupFactory { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ModelGroupFactory } from "webiny/api/cms/group"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private modelGroupFactory: ModelGroupFactory.Interface) {} - - public async execute(/* ... */): Promise { - await this.modelGroupFactory.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ModelGroupFactory] -}); -``` - ## Types & Classes ### `CmsGroup` diff --git a/docs/developer-docs/6.x/reference/api/cms/model.mdx b/docs/developer-docs/6.x/reference/api/cms/model.mdx index 643087f04..c2c078a20 100644 --- a/docs/developer-docs/6.x/reference/api/cms/model.mdx +++ b/docs/developer-docs/6.x/reference/api/cms/model.mdx @@ -82,6 +82,8 @@ import { CreateModelFromUseCase } from "webiny/api/cms/model"; **Interface `CreateModelFromUseCase.Interface`:** +CreateModelFrom Use Case (Clone/Copy Model) + ```typescript interface CreateModelFromUseCase.Interface { execute( @@ -102,25 +104,6 @@ namespace CreateModelFromUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateModelFromUseCase } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createModelFromUseCase: CreateModelFromUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createModelFromUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateModelFromUseCase] -}); -``` - ### `CreateModelUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/model` @@ -131,6 +114,8 @@ import { CreateModelUseCase } from "webiny/api/cms/model"; **Interface `CreateModelUseCase.Interface`:** +CreateModel Use Case + ```typescript interface CreateModelUseCase.Interface { execute(input: CmsModelCreateInput): Promise>; @@ -148,25 +133,6 @@ namespace CreateModelUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateModelUseCase } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createModelUseCase: CreateModelUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createModelUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateModelUseCase] -}); -``` - ### `DeleteModelUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/model` @@ -177,6 +143,8 @@ import { DeleteModelUseCase } from "webiny/api/cms/model"; **Interface `DeleteModelUseCase.Interface`:** +DeleteModel Use Case + ```typescript interface DeleteModelUseCase.Interface { execute(modelId: string): Promise>; @@ -193,25 +161,6 @@ namespace DeleteModelUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteModelUseCase } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteModelUseCase: DeleteModelUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteModelUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteModelUseCase] -}); -``` - ### `GetModelUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/model` @@ -222,6 +171,8 @@ import { GetModelUseCase } from "webiny/api/cms/model"; **Interface `GetModelUseCase.Interface`:** +GetModel Use Case + ```typescript interface GetModelUseCase.Interface { execute(modelId: string): Promise>; @@ -238,25 +189,6 @@ namespace GetModelUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetModelUseCase } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getModelUseCase: GetModelUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getModelUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetModelUseCase] -}); -``` - ### `ListModelsUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/model` @@ -267,6 +199,8 @@ import { ListModelsUseCase } from "webiny/api/cms/model"; **Interface `ListModelsUseCase.Interface`:** +ListModels Use Case + ```typescript interface ListModelsUseCase.Interface { execute(params?: ICmsModelListParams): Promise>; @@ -284,25 +218,6 @@ namespace ListModelsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListModelsUseCase } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listModelsUseCase: ListModelsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listModelsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListModelsUseCase] -}); -``` - ### `UpdateModelUseCase` **Use Case Abstraction** — imported from `webiny/api/cms/model` @@ -313,6 +228,8 @@ import { UpdateModelUseCase } from "webiny/api/cms/model"; **Interface `UpdateModelUseCase.Interface`:** +UpdateModel Use Case + ```typescript interface UpdateModelUseCase.Interface { execute(modelId: string, input: CmsModelUpdateInput): Promise>; @@ -330,25 +247,6 @@ namespace UpdateModelUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateModelUseCase } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateModelUseCase: UpdateModelUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateModelUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateModelUseCase] -}); -``` - ## Event Handlers ### `ModelAfterCreateEventHandler` @@ -384,25 +282,6 @@ namespace ModelAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelAfterCreateEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelAfterCreateEventHandler.Event): Promise { - const { model } = event.payload; - } -} - -export default ModelAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelAfterCreateFromEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -437,25 +316,6 @@ namespace ModelAfterCreateFromEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelAfterCreateFromEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelAfterCreateFromEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelAfterCreateFromEventHandler.Event): Promise { - const { model, original } = event.payload; - } -} - -export default ModelAfterCreateFromEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -489,25 +349,6 @@ namespace ModelAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelAfterDeleteEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelAfterDeleteEventHandler.Event): Promise { - const { model } = event.payload; - } -} - -export default ModelAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -542,25 +383,6 @@ namespace ModelAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelAfterUpdateEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelAfterUpdateEventHandler.Event): Promise { - const { model, original } = event.payload; - } -} - -export default ModelAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -595,25 +417,6 @@ namespace ModelBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelBeforeCreateEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelBeforeCreateEventHandler.Event): Promise { - const { model, input } = event.payload; - } -} - -export default ModelBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelBeforeCreateFromEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -649,25 +452,6 @@ namespace ModelBeforeCreateFromEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelBeforeCreateFromEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelBeforeCreateFromEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelBeforeCreateFromEventHandler.Event): Promise { - const { model, original, input } = event.payload; - } -} - -export default ModelBeforeCreateFromEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -701,25 +485,6 @@ namespace ModelBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelBeforeDeleteEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelBeforeDeleteEventHandler.Event): Promise { - const { model } = event.payload; - } -} - -export default ModelBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ModelBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/cms/model` @@ -755,25 +520,6 @@ namespace ModelBeforeUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ModelBeforeUpdateEventHandler } from "webiny/api/cms/model"; - -class MyHandler implements ModelBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ModelBeforeUpdateEventHandler.Event): Promise { - const { model, original, input } = event.payload; - } -} - -export default ModelBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ## Services ### `FieldType` @@ -786,33 +532,19 @@ import { FieldType } from "webiny/api/cms/model"; **Interface `FieldType.Interface`:** +Field Type Factory - creates a field builder instance + ```typescript interface FieldType.Interface { - // Unique identifier for this field type readonly type: string; - // Create a new field builder instance create(registry: IFieldBuilderRegistry): BaseFieldBuilder; } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { FieldType } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private fieldType: FieldType.Interface) {} - - public async execute(/* ... */): Promise { - this.fieldType.create(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [FieldType] -}); -``` +| Method | Description | +| ------------------------- | ------------------------------------- | +| `readonly type: string()` | Unique identifier for this field type | +| `create()` | Create a new field builder instance | ### `ModelFactory` @@ -841,25 +573,6 @@ namespace ModelFactory { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ModelFactory } from "webiny/api/cms/model"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private modelFactory: ModelFactory.Interface) {} - - public async execute(/* ... */): Promise { - await this.modelFactory.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ModelFactory] -}); -``` - ## Types & Classes ### `CmsModel` @@ -970,17 +683,17 @@ import { LayoutBuilder } from "webiny/api/cms/model"; ```typescript export class LayoutBuilder { - private layout: string[][]; - private modifiers: LayoutModifier[] = []; - constructor(existingLayout: string[][] = []); - setLayout(layout: string[][]): this; - addModifier(modifier: LayoutModifier): this; - addField(field: string, position:; - addRow(fields: string[]): this; - insertRow(fields: string[], position:; - getSnapshot():; - build(): string[][]; - private findFieldPosition(field: string):; + private layout: string[][]; + private modifiers: LayoutModifier[] = []; + constructor(existingLayout: string[][] = []); + setLayout(layout: string[][]): this; + addModifier(modifier: LayoutModifier): this; + addField(field: string, position: { after: string } | { before: string }): this; + addRow(fields: string[]): this; + insertRow(fields: string[], position: { after: string } | { before: string }): this; + getSnapshot(): { layout: string[][]; modifiers: LayoutModifier[] }; + build(): string[][]; + private findFieldPosition(field: string): { rowIndex: number; colIndex: number } | null; } ``` diff --git a/docs/developer-docs/6.x/reference/api/graphql.mdx b/docs/developer-docs/6.x/reference/api/graphql.mdx index 9387d9691..483dfaf07 100644 --- a/docs/developer-docs/6.x/reference/api/graphql.mdx +++ b/docs/developer-docs/6.x/reference/api/graphql.mdx @@ -47,6 +47,8 @@ import { GraphQLSchemaFactory } from "webiny/api/graphql"; **Interface `GraphQLSchemaFactory.Interface`:** +GraphQLSchemaFactory + ```typescript interface GraphQLSchemaFactory.Interface { execute(builder: GraphQLSchemaBuilder.Interface): Promise; @@ -63,25 +65,24 @@ namespace GraphQLSchemaFactory { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GraphQLSchemaFactory } from "webiny/api/graphql"; +**`SchemaBuilder` — `GraphQLSchemaBuilder.Interface`:** -class MyImpl implements MyUseCase.Interface { - public constructor(private graphQLSchemaFactory: GraphQLSchemaFactory.Interface) {} +Interface for building GraphQL schemas by adding type definitions and resolvers. - public async execute(/* ... */): Promise { - await this.graphQLSchemaFactory.execute(/* ... */); - } +```typescript +interface GraphQLSchemaBuilder.Interface { + addTypeDefs(typeDefs: TypeDefs): this; + addResolver(config: ResolverConfig): this; + build(): IGraphQLSchema; } - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GraphQLSchemaFactory] -}); ``` +| Method | Description | +| ------------------------------------------- | -------------------------------------------------- | +| `addTypeDefs()` | Add GraphQL type definitions to the schema. | +| `addResolver()` | Add a GraphQL resolver with optional dependencies. | +| `build()` | Build and return the GraphQL schema. | + ## Types & Classes ### `ErrorResponse` @@ -94,9 +95,14 @@ import { ErrorResponse } from "webiny/api/graphql"; ```typescript export class ErrorResponse { - public readonly data: null; - public readonly error:; - constructor(params: ErrorResponseParams); + public readonly data: null; + public readonly error: { + code: string; + message: string; + data: any; + stack: string | null; + }; + constructor(params: ErrorResponseParams); } ``` @@ -110,10 +116,15 @@ import { ListErrorResponse } from "webiny/api/graphql"; ```typescript export class ListErrorResponse { - public readonly data: null; - public readonly meta: null; - public readonly error:; - constructor(params: ErrorResponseParams); + public readonly data: null; + public readonly meta: null; + public readonly error: { + code: string; + message: string; + data: any; + stack: string | null; + }; + constructor(params: ErrorResponseParams); } ``` @@ -144,7 +155,7 @@ import { NotAuthorizedResponse } from "webiny/api/graphql"; ```typescript export class NotAuthorizedResponse extends ErrorResponse { - constructor(; + constructor({ message, code, data }: Partial = {}); } ``` diff --git a/docs/developer-docs/6.x/reference/api/key-value-store.mdx b/docs/developer-docs/6.x/reference/api/key-value-store.mdx index ed1e87c39..177f40768 100644 --- a/docs/developer-docs/6.x/reference/api/key-value-store.mdx +++ b/docs/developer-docs/6.x/reference/api/key-value-store.mdx @@ -63,25 +63,6 @@ namespace GlobalKeyValueStore { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GlobalKeyValueStore } from "webiny/api/key-value-store"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private globalKeyValueStore: GlobalKeyValueStore.Interface) {} - - public async execute(/* ... */): Promise { - await this.globalKeyValueStore.get(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GlobalKeyValueStore] -}); -``` - ## `KeyValueStore` **Abstraction** — imported from `webiny/api/key-value-store` @@ -109,22 +90,3 @@ namespace KeyValueStore { type Error = KeyValueStoreRepository.Error; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { KeyValueStore } from "webiny/api/key-value-store"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private keyValueStore: KeyValueStore.Interface) {} - - public async execute(/* ... */): Promise { - await this.keyValueStore.get(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [KeyValueStore] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/logger.mdx b/docs/developer-docs/6.x/reference/api/logger.mdx index ab14dd4ff..7dc8a0e09 100644 --- a/docs/developer-docs/6.x/reference/api/logger.mdx +++ b/docs/developer-docs/6.x/reference/api/logger.mdx @@ -42,6 +42,16 @@ interface Logger.Interface { } ``` +| Method | Description | +| --------- | ---------------------------------------------------------------------------------- | +| `trace()` | Log a trace-level message with optional additional arguments. | +| `debug()` | Log a debug-level message with optional additional arguments. | +| `info()` | Log an info-level message with optional additional arguments. | +| `warn()` | Log a warning-level message with optional additional arguments. | +| `error()` | Log an error-level message with optional additional arguments. | +| `fatal()` | Log a fatal-level message with optional additional arguments. | +| `log()` | Log a generic message (defaults to info level) with optional additional arguments. | + **Types:** ```typescript @@ -50,21 +60,62 @@ namespace Logger { } ``` -**Usage:** +## Examples + +### Basic Usage + +Simple logger injection and usage: -```typescript extensions/MyImpl.ts +```typescript +import { ApiKeyAfterUpdateEventHandler } from "webiny/api/security/api-key"; import { Logger } from "webiny/api/logger"; -class MyImpl implements MyUseCase.Interface { - public constructor(private logger: Logger.Interface) {} +class MyApiKeyAfterUpdateImpl implements ApiKeyAfterUpdateEventHandler.Interface { + constructor(private logger: Logger.Interface) {} - public async execute(/* ... */): Promise { - this.logger.info(/* ... */); + async handle() { + this.logger.debug("An API key was updated!"); + this.logger.info("Processing update..."); } } -export default MyUseCase.createImplementation({ - implementation: MyImpl, +const MyApiKeyAfterUpdate = ApiKeyAfterUpdateEventHandler.createImplementation({ + implementation: MyApiKeyAfterUpdateImpl, dependencies: [Logger] }); + +export default MyApiKeyAfterUpdate; +``` + +### Logging Errors + +Logging error messages when something goes wrong: + +```typescript +import { ApiKeyAfterUpdateEventHandler } from "webiny/api/security/api-key"; +import { Logger } from "webiny/api/logger"; + +class MyApiKeyAfterUpdateImpl implements ApiKeyAfterUpdateEventHandler.Interface { + constructor(private logger: Logger.Interface) {} + + async handle() { + try { + // Some operation that might fail + await this.processApiKey(); + } catch (error) { + this.logger.error("An error occurred while processing API key:", error); + } + } + + private async processApiKey() { + // Implementation + } +} + +const MyApiKeyAfterUpdate = ApiKeyAfterUpdateEventHandler.createImplementation({ + implementation: MyApiKeyAfterUpdateImpl, + dependencies: [Logger] +}); + +export default MyApiKeyAfterUpdate; ``` diff --git a/docs/developer-docs/6.x/reference/api/security.mdx b/docs/developer-docs/6.x/reference/api/security.mdx index 8d4a7e8cf..aae1e9912 100644 --- a/docs/developer-docs/6.x/reference/api/security.mdx +++ b/docs/developer-docs/6.x/reference/api/security.mdx @@ -64,25 +64,6 @@ namespace ApiKeyFactory { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiKeyFactory } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiKeyFactory: ApiKeyFactory.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiKeyFactory.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiKeyFactory] -}); -``` - ### `Authenticator` **Abstraction** — imported from `webiny/api/security` @@ -107,25 +88,6 @@ namespace Authenticator { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { Authenticator } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private authenticator: Authenticator.Interface) {} - - public async execute(/* ... */): Promise { - await this.authenticator.authenticate(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [Authenticator] -}); -``` - ### `Authorizer` **Abstraction** — imported from `webiny/api/security` @@ -150,25 +112,6 @@ namespace Authorizer { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { Authorizer } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private authorizer: Authorizer.Interface) {} - - public async execute(/* ... */): Promise { - await this.authorizer.authorize(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [Authorizer] -}); -``` - ### `IdentityContext` **Abstraction** — imported from `webiny/api/security` @@ -205,25 +148,6 @@ namespace IdentityContext { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { IdentityContext } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private identityContext: IdentityContext.Interface) {} - - public async execute(/* ... */): Promise { - this.identityContext.getIdentity(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [IdentityContext] -}); -``` - ### `IdentityProvider` **Abstraction** — imported from `webiny/api/security` @@ -251,25 +175,6 @@ namespace IdentityProvider { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { IdentityProvider } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private identityProvider: IdentityProvider.Interface) {} - - public async execute(/* ... */): Promise { - this.identityProvider.isApplicable(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [IdentityProvider] -}); -``` - ### `JwtIdentityProvider` **Abstraction** — imported from `webiny/api/security` @@ -299,25 +204,6 @@ namespace JwtIdentityProvider { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { JwtIdentityProvider } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private jwtIdentityProvider: JwtIdentityProvider.Interface) {} - - public async execute(/* ... */): Promise { - this.jwtIdentityProvider.isApplicable(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [JwtIdentityProvider] -}); -``` - ### `OidcIdentityProvider` **Abstraction** — imported from `webiny/api/security` @@ -349,25 +235,6 @@ namespace OidcIdentityProvider { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { OidcIdentityProvider } from "webiny/api/security"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private oidcIdentityProvider: OidcIdentityProvider.Interface) {} - - public async execute(/* ... */): Promise { - this.oidcIdentityProvider.issuer: string(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [OidcIdentityProvider] -}); -``` - ## Types & Classes ### `ApiToken` @@ -380,6 +247,6 @@ import { ApiToken } from "webiny/api/security"; ```typescript export class ApiToken { - static validate(token: string): `wat_$; + static validate(token: string): `wat_${string}`; } ``` diff --git a/docs/developer-docs/6.x/reference/api/security/api-key.mdx b/docs/developer-docs/6.x/reference/api/security/api-key.mdx index 000b2ed95..53c171d92 100644 --- a/docs/developer-docs/6.x/reference/api/security/api-key.mdx +++ b/docs/developer-docs/6.x/reference/api/security/api-key.mdx @@ -77,25 +77,6 @@ namespace CreateApiKeyUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateApiKeyUseCase } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createApiKeyUseCase: CreateApiKeyUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createApiKeyUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateApiKeyUseCase] -}); -``` - ### `DeleteApiKeyUseCase` **Use Case Abstraction** — imported from `webiny/api/security/api-key` @@ -121,25 +102,6 @@ namespace DeleteApiKeyUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteApiKeyUseCase } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteApiKeyUseCase: DeleteApiKeyUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteApiKeyUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteApiKeyUseCase] -}); -``` - ### `GetApiKeyByTokenUseCase` **Use Case Abstraction** — imported from `webiny/api/security/api-key` @@ -165,25 +127,6 @@ namespace GetApiKeyByTokenUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetApiKeyByTokenUseCase } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getApiKeyByTokenUseCase: GetApiKeyByTokenUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getApiKeyByTokenUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetApiKeyByTokenUseCase] -}); -``` - ### `GetApiKeyUseCase` **Use Case Abstraction** — imported from `webiny/api/security/api-key` @@ -209,25 +152,6 @@ namespace GetApiKeyUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetApiKeyUseCase } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getApiKeyUseCase: GetApiKeyUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getApiKeyUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetApiKeyUseCase] -}); -``` - ### `ListApiKeysUseCase` **Use Case Abstraction** — imported from `webiny/api/security/api-key` @@ -253,25 +177,6 @@ namespace ListApiKeysUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListApiKeysUseCase } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listApiKeysUseCase: ListApiKeysUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listApiKeysUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListApiKeysUseCase] -}); -``` - ### `UpdateApiKeyUseCase` **Use Case Abstraction** — imported from `webiny/api/security/api-key` @@ -297,25 +202,6 @@ namespace UpdateApiKeyUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateApiKeyUseCase } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateApiKeyUseCase: UpdateApiKeyUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateApiKeyUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateApiKeyUseCase] -}); -``` - ## Event Handlers ### `ApiKeyAfterCreateEventHandler` @@ -343,25 +229,6 @@ namespace ApiKeyAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ApiKeyAfterCreateEventHandler } from "webiny/api/security/api-key"; - -class MyHandler implements ApiKeyAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ApiKeyAfterCreateEventHandler.Event): Promise { - // implementation - } -} - -export default ApiKeyAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ApiKeyAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/api-key` @@ -387,25 +254,6 @@ namespace ApiKeyAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ApiKeyAfterDeleteEventHandler } from "webiny/api/security/api-key"; - -class MyHandler implements ApiKeyAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ApiKeyAfterDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default ApiKeyAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ApiKeyAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/api-key` @@ -431,25 +279,6 @@ namespace ApiKeyAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ApiKeyAfterUpdateEventHandler } from "webiny/api/security/api-key"; - -class MyHandler implements ApiKeyAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ApiKeyAfterUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default ApiKeyAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ApiKeyBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/api-key` @@ -475,25 +304,6 @@ namespace ApiKeyBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ApiKeyBeforeCreateEventHandler } from "webiny/api/security/api-key"; - -class MyHandler implements ApiKeyBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ApiKeyBeforeCreateEventHandler.Event): Promise { - // implementation - } -} - -export default ApiKeyBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ApiKeyBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/api-key` @@ -519,25 +329,6 @@ namespace ApiKeyBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ApiKeyBeforeDeleteEventHandler } from "webiny/api/security/api-key"; - -class MyHandler implements ApiKeyBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ApiKeyBeforeDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default ApiKeyBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `ApiKeyBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/api-key` @@ -563,25 +354,6 @@ namespace ApiKeyBeforeUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { ApiKeyBeforeUpdateEventHandler } from "webiny/api/security/api-key"; - -class MyHandler implements ApiKeyBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: ApiKeyBeforeUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default ApiKeyBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ## Services ### `ApiKeyFactory` @@ -609,22 +381,3 @@ namespace ApiKeyFactory { type ApiKey = CodeApiKey; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiKeyFactory } from "webiny/api/security/api-key"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiKeyFactory: ApiKeyFactory.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiKeyFactory.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiKeyFactory] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/security/authentication.mdx b/docs/developer-docs/6.x/reference/api/security/authentication.mdx index c1b0708d0..e44c716ce 100644 --- a/docs/developer-docs/6.x/reference/api/security/authentication.mdx +++ b/docs/developer-docs/6.x/reference/api/security/authentication.mdx @@ -50,25 +50,6 @@ namespace AfterAuthenticationEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { AfterAuthenticationEventHandler } from "webiny/api/security/authentication"; - -class MyHandler implements AfterAuthenticationEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: AfterAuthenticationEventHandler.Event): Promise { - // implementation - } -} - -export default AfterAuthenticationEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ## `BeforeAuthenticationEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/authentication` @@ -93,22 +74,3 @@ namespace BeforeAuthenticationEventHandler { type Event = BeforeAuthenticationEvent; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { BeforeAuthenticationEventHandler } from "webiny/api/security/authentication"; - -class MyHandler implements BeforeAuthenticationEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: BeforeAuthenticationEventHandler.Event): Promise { - // implementation - } -} - -export default BeforeAuthenticationEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/security/role.mdx b/docs/developer-docs/6.x/reference/api/security/role.mdx index bf40f8438..1f41d9d73 100644 --- a/docs/developer-docs/6.x/reference/api/security/role.mdx +++ b/docs/developer-docs/6.x/reference/api/security/role.mdx @@ -71,25 +71,6 @@ namespace CreateRoleUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateRoleUseCase } from "webiny/api/security/role"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createRoleUseCase: CreateRoleUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createRoleUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateRoleUseCase] -}); -``` - ### `DeleteRoleUseCase` **Use Case Abstraction** — imported from `webiny/api/security/role` @@ -115,25 +96,6 @@ namespace DeleteRoleUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteRoleUseCase } from "webiny/api/security/role"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteRoleUseCase: DeleteRoleUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteRoleUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteRoleUseCase] -}); -``` - ### `GetRoleUseCase` **Use Case Abstraction** — imported from `webiny/api/security/role` @@ -159,25 +121,6 @@ namespace GetRoleUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetRoleUseCase } from "webiny/api/security/role"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getRoleUseCase: GetRoleUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getRoleUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetRoleUseCase] -}); -``` - ### `ListRolesUseCase` **Use Case Abstraction** — imported from `webiny/api/security/role` @@ -203,25 +146,6 @@ namespace ListRolesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListRolesUseCase } from "webiny/api/security/role"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listRolesUseCase: ListRolesUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listRolesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListRolesUseCase] -}); -``` - ### `UpdateRoleUseCase` **Use Case Abstraction** — imported from `webiny/api/security/role` @@ -250,25 +174,6 @@ namespace UpdateRoleUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateRoleUseCase } from "webiny/api/security/role"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateRoleUseCase: UpdateRoleUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateRoleUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateRoleUseCase] -}); -``` - ## Event Handlers ### `RoleAfterCreateEventHandler` @@ -296,25 +201,6 @@ namespace RoleAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RoleAfterCreateEventHandler } from "webiny/api/security/role"; - -class MyHandler implements RoleAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RoleAfterCreateEventHandler.Event): Promise { - // implementation - } -} - -export default RoleAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RoleAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/role` @@ -340,25 +226,6 @@ namespace RoleAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RoleAfterDeleteEventHandler } from "webiny/api/security/role"; - -class MyHandler implements RoleAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RoleAfterDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default RoleAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RoleAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/role` @@ -384,25 +251,6 @@ namespace RoleAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RoleAfterUpdateEventHandler } from "webiny/api/security/role"; - -class MyHandler implements RoleAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RoleAfterUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default RoleAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RoleBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/role` @@ -428,25 +276,6 @@ namespace RoleBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RoleBeforeCreateEventHandler } from "webiny/api/security/role"; - -class MyHandler implements RoleBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RoleBeforeCreateEventHandler.Event): Promise { - // implementation - } -} - -export default RoleBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RoleBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/role` @@ -472,25 +301,6 @@ namespace RoleBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RoleBeforeDeleteEventHandler } from "webiny/api/security/role"; - -class MyHandler implements RoleBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RoleBeforeDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default RoleBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RoleBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/role` @@ -515,22 +325,3 @@ namespace RoleBeforeUpdateEventHandler { type Event = RoleBeforeUpdateEvent; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { RoleBeforeUpdateEventHandler } from "webiny/api/security/role"; - -class MyHandler implements RoleBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RoleBeforeUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default RoleBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/security/user.mdx b/docs/developer-docs/6.x/reference/api/security/user.mdx index 4cbeb68db..b1f82f182 100644 --- a/docs/developer-docs/6.x/reference/api/security/user.mdx +++ b/docs/developer-docs/6.x/reference/api/security/user.mdx @@ -73,25 +73,6 @@ namespace CreateUserUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateUserUseCase } from "webiny/api/security/user"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createUserUseCase: CreateUserUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createUserUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateUserUseCase] -}); -``` - ### `DeleteUserUseCase` **Use Case Abstraction** — imported from `webiny/api/security/user` @@ -117,25 +98,6 @@ namespace DeleteUserUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteUserUseCase } from "webiny/api/security/user"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteUserUseCase: DeleteUserUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteUserUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteUserUseCase] -}); -``` - ### `GetUserUseCase` **Use Case Abstraction** — imported from `webiny/api/security/user` @@ -161,25 +123,6 @@ namespace GetUserUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetUserUseCase } from "webiny/api/security/user"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getUserUseCase: GetUserUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getUserUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetUserUseCase] -}); -``` - ### `ListUsersUseCase` **Use Case Abstraction** — imported from `webiny/api/security/user` @@ -205,25 +148,6 @@ namespace ListUsersUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListUsersUseCase } from "webiny/api/security/user"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listUsersUseCase: ListUsersUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listUsersUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListUsersUseCase] -}); -``` - ### `ListUserTeamsUseCase` **Use Case Abstraction** — imported from `webiny/api/security/user` @@ -249,25 +173,6 @@ namespace ListUserTeamsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListUserTeamsUseCase } from "webiny/api/security/user"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listUserTeamsUseCase: ListUserTeamsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listUserTeamsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListUserTeamsUseCase] -}); -``` - ### `UpdateUserUseCase` **Use Case Abstraction** — imported from `webiny/api/security/user` @@ -293,25 +198,6 @@ namespace UpdateUserUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateUserUseCase } from "webiny/api/security/user"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateUserUseCase: UpdateUserUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateUserUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateUserUseCase] -}); -``` - ## Event Handlers ### `UserAfterCreateEventHandler` @@ -339,25 +225,6 @@ namespace UserAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { UserAfterCreateEventHandler } from "webiny/api/security/user"; - -class MyHandler implements UserAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: UserAfterCreateEventHandler.Event): Promise { - // implementation - } -} - -export default UserAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `UserAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/user` @@ -383,25 +250,6 @@ namespace UserAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { UserAfterDeleteEventHandler } from "webiny/api/security/user"; - -class MyHandler implements UserAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: UserAfterDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default UserAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `UserAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/user` @@ -427,25 +275,6 @@ namespace UserAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { UserAfterUpdateEventHandler } from "webiny/api/security/user"; - -class MyHandler implements UserAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: UserAfterUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default UserAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `UserBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/user` @@ -471,25 +300,6 @@ namespace UserBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { UserBeforeCreateEventHandler } from "webiny/api/security/user"; - -class MyHandler implements UserBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: UserBeforeCreateEventHandler.Event): Promise { - // implementation - } -} - -export default UserBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `UserBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/user` @@ -515,25 +325,6 @@ namespace UserBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { UserBeforeDeleteEventHandler } from "webiny/api/security/user"; - -class MyHandler implements UserBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: UserBeforeDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default UserBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `UserBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/security/user` @@ -558,22 +349,3 @@ namespace UserBeforeUpdateEventHandler { type Event = UserBeforeUpdateEvent; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { UserBeforeUpdateEventHandler } from "webiny/api/security/user"; - -class MyHandler implements UserBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: UserBeforeUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default UserBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/system.mdx b/docs/developer-docs/6.x/reference/api/system.mdx index 33e85b322..00d6dbb44 100644 --- a/docs/developer-docs/6.x/reference/api/system.mdx +++ b/docs/developer-docs/6.x/reference/api/system.mdx @@ -41,6 +41,8 @@ import { InstallSystemUseCase } from "webiny/api/system"; **Interface `InstallSystemUseCase.Interface`:** +Use Case Abstraction + ```typescript interface InstallSystemUseCase.Interface { execute( @@ -58,24 +60,14 @@ namespace InstallSystemUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { InstallSystemUseCase } from "webiny/api/system"; +**`Input` — `AppInstallationData[]`:** -class MyImpl implements MyUseCase.Interface { - public constructor(private installSystemUseCase: InstallSystemUseCase.Interface) {} +Types - public async execute(/* ... */): Promise { - await this.installSystemUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [InstallSystemUseCase] -}); -``` +| Field | Type | Required | Description | +| ------ | --------------------- | -------- | ----------- | +| `app` | `string` | yes | — | +| `data` | `Record` | yes | — | ## Event Handlers @@ -103,22 +95,3 @@ namespace SystemInstalledEventHandler { type Event = DomainEvent; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { SystemInstalledEventHandler } from "webiny/api/system"; - -class MyHandler implements SystemInstalledEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: SystemInstalledEventHandler.Event): Promise { - // implementation - } -} - -export default SystemInstalledEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/tasks.mdx b/docs/developer-docs/6.x/reference/api/tasks.mdx index f117da051..74f1f27c4 100644 --- a/docs/developer-docs/6.x/reference/api/tasks.mdx +++ b/docs/developer-docs/6.x/reference/api/tasks.mdx @@ -35,6 +35,8 @@ import { TaskDefinition } from "webiny/api/tasks"; **Interface `TaskDefinition.Interface`:** +Core TaskDefinition - minimal interface + ```typescript interface TaskDefinition.Interface { id: string; @@ -43,23 +45,36 @@ interface TaskDefinition.Interface { maxIterations?: number; databaseLogs?: boolean; isPrivate?: boolean; - // Core run method - receives ONLY input params - // All runtime dependencies (logging, state management, etc.) come from TaskController run(params: ITaskRunParams): Promise>; - // Optional lifecycle hooks - receive task data, no context onBeforeTrigger?(params: ITaskBeforeTriggerParams): Promise; onDone?(params: ITaskLifecycleHook): Promise; onError?(params: ITaskLifecycleHook): Promise; onAbort?(params: ITaskLifecycleHook): Promise; onMaxIterations?(params: ITaskLifecycleHook): Promise; - // Create a validation schema for the task input. - // This will be used to validate the input before the task is triggered. createInputValidation?( params: ITaskCreateInputValidationParams ): GenericRecord | zod.Schema; } ``` +| Method | Description | +| ----------------------------------------------------------------------------------- | -------------------------------------------------------- | +| `id: string()` | — | +| `title: string()` | — | +| `description?: string()` | — | +| `maxIterations?: number()` | — | +| `databaseLogs?: boolean()` | — | +| `isPrivate?: boolean()` | — | +| `run()` | Core run method - receives ONLY input params | +| All runtime dependencies (logging, state management, etc.) come from TaskController | +| `onBeforeTrigger?()` | Optional lifecycle hooks - receive task data, no context | +| `onDone?()` | — | +| `onError?()` | — | +| `onAbort?()` | — | +| `onMaxIterations?()` | — | +| `createInputValidation?()` | Create a validation schema for the task input. | +| This will be used to validate the input before the task is triggered. | + **Types:** ```typescript @@ -82,25 +97,6 @@ namespace TaskDefinition { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { TaskDefinition } from "webiny/api/tasks"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private taskDefinition: TaskDefinition.Interface) {} - - public async execute(/* ... */): Promise { - this.taskDefinition.id: string(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [TaskDefinition] -}); -``` - ## `TaskService` **Abstraction** — imported from `webiny/api/tasks` @@ -139,22 +135,3 @@ namespace TaskService { type Task = ITask; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { TaskService } from "webiny/api/tasks"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private taskService: TaskService.Interface) {} - - public async execute(/* ... */): Promise { - await this.taskService.trigger:(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [TaskService] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/tenancy.mdx b/docs/developer-docs/6.x/reference/api/tenancy.mdx index 3057751d7..e1bbda4c3 100644 --- a/docs/developer-docs/6.x/reference/api/tenancy.mdx +++ b/docs/developer-docs/6.x/reference/api/tenancy.mdx @@ -69,6 +69,8 @@ import { CreateTenantRepository } from "webiny/api/tenancy"; **Interface `CreateTenantRepository.Interface`:** +Repository + ```typescript interface CreateTenantRepository.Interface { create(tenant: Tenant): Promise; @@ -83,25 +85,6 @@ namespace CreateTenantRepository { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateTenantRepository } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createTenantRepository: CreateTenantRepository.Interface) {} - - public async execute(/* ... */): Promise { - await this.createTenantRepository.create(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateTenantRepository] -}); -``` - ### `CreateTenantUseCase` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -112,6 +95,8 @@ import { CreateTenantUseCase } from "webiny/api/tenancy"; **Interface `CreateTenantUseCase.Interface`:** +Use Case + ```typescript interface CreateTenantUseCase.Interface { execute( @@ -129,25 +114,6 @@ namespace CreateTenantUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateTenantUseCase } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createTenantUseCase: CreateTenantUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createTenantUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateTenantUseCase] -}); -``` - ### `DeleteTenantRepository` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -172,25 +138,6 @@ namespace DeleteTenantRepository { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteTenantRepository } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteTenantRepository: DeleteTenantRepository.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteTenantRepository.delete(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteTenantRepository] -}); -``` - ### `DeleteTenantUseCase` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -215,25 +162,6 @@ namespace DeleteTenantUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteTenantUseCase } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteTenantUseCase: DeleteTenantUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteTenantUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteTenantUseCase] -}); -``` - ### `GetTenantByIdUseCase` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -260,25 +188,6 @@ namespace GetTenantByIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetTenantByIdUseCase } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getTenantByIdUseCase: GetTenantByIdUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getTenantByIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetTenantByIdUseCase] -}); -``` - ### `InstallTenantUseCase` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -289,6 +198,8 @@ import { InstallTenantUseCase } from "webiny/api/tenancy"; **Interface `InstallTenantUseCase.Interface`:** +Use Case Abstraction + ```typescript interface InstallTenantUseCase.Interface { execute( @@ -307,25 +218,6 @@ namespace InstallTenantUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { InstallTenantUseCase } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private installTenantUseCase: InstallTenantUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.installTenantUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [InstallTenantUseCase] -}); -``` - ### `UpdateTenantRepository` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -350,25 +242,6 @@ namespace UpdateTenantRepository { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateTenantRepository } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateTenantRepository: UpdateTenantRepository.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateTenantRepository.update(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateTenantRepository] -}); -``` - ### `UpdateTenantUseCase` **Use Case Abstraction** — imported from `webiny/api/tenancy` @@ -393,25 +266,6 @@ namespace UpdateTenantUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateTenantUseCase } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateTenantUseCase: UpdateTenantUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateTenantUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateTenantUseCase] -}); -``` - ## Event Handlers ### `TenantAfterCreateEventHandler` @@ -439,25 +293,6 @@ namespace TenantAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantAfterCreateEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantAfterCreateEventHandler.Event): Promise { - // implementation - } -} - -export default TenantAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `TenantAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/tenancy` @@ -483,25 +318,6 @@ namespace TenantAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantAfterDeleteEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantAfterDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default TenantAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `TenantAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/tenancy` @@ -527,25 +343,6 @@ namespace TenantAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantAfterUpdateEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantAfterUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default TenantAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `TenantBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/tenancy` @@ -571,25 +368,6 @@ namespace TenantBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantBeforeCreateEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantBeforeCreateEventHandler.Event): Promise { - // implementation - } -} - -export default TenantBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `TenantBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/tenancy` @@ -615,25 +393,6 @@ namespace TenantBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantBeforeDeleteEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantBeforeDeleteEventHandler.Event): Promise { - // implementation - } -} - -export default TenantBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `TenantBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/tenancy` @@ -659,25 +418,6 @@ namespace TenantBeforeUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantBeforeUpdateEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantBeforeUpdateEventHandler.Event): Promise { - // implementation - } -} - -export default TenantBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `TenantInstalledEventHandler` **Event Handler Abstraction** — imported from `webiny/api/tenancy` @@ -703,25 +443,6 @@ namespace TenantInstalledEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { TenantInstalledEventHandler } from "webiny/api/tenancy"; - -class MyHandler implements TenantInstalledEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: TenantInstalledEventHandler.Event): Promise { - // implementation - } -} - -export default TenantInstalledEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ## Services ### `AppInstaller` @@ -734,20 +455,28 @@ import { AppInstaller } from "webiny/api/tenancy"; **Interface `AppInstaller.Interface`:** +App Installer Abstraction + ```typescript interface AppInstaller.Interface { readonly alwaysRun?: boolean; readonly appName: string; readonly dependsOn: string[]; - // Perform the installation - // If this succeeds, uninstall() MUST be able to revert it install(tenant: Tenant, data: TData): Promise; - // Revert the installation - // Called if any subsequent installer fails uninstall(tenant: Tenant): Promise; } ``` +| Method | Description | +| ------------------------------------------------------- | ------------------------ | +| `readonly alwaysRun?: boolean()` | — | +| `readonly appName: string()` | — | +| `readonly dependsOn: string[]()` | — | +| `install()` | Perform the installation | +| If this succeeds, uninstall() MUST be able to revert it | +| `uninstall()` | Revert the installation | +| Called if any subsequent installer fails | + **Types:** ```typescript @@ -756,25 +485,6 @@ namespace AppInstaller { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AppInstaller } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private appInstaller: AppInstaller.Interface) {} - - public async execute(/* ... */): Promise { - this.appInstaller.readonly alwaysRun?: boolean(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AppInstaller] -}); -``` - ### `TenantContext` **Abstraction** — imported from `webiny/api/tenancy` @@ -805,22 +515,3 @@ namespace TenantContext { type Interface = ITenantContext; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { TenantContext } from "webiny/api/tenancy"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private tenantContext: TenantContext.Interface) {} - - public async execute(/* ... */): Promise { - this.tenantContext.setTenant(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [TenantContext] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/tenant-manager.mdx b/docs/developer-docs/6.x/reference/api/tenant-manager.mdx index a0a619a12..dbb1acfb5 100644 --- a/docs/developer-docs/6.x/reference/api/tenant-manager.mdx +++ b/docs/developer-docs/6.x/reference/api/tenant-manager.mdx @@ -53,25 +53,6 @@ namespace TenantModelExtension { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { TenantModelExtension } from "webiny/api/tenant-manager"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private tenantModelExtension: TenantModelExtension.Interface) {} - - public async execute(/* ... */): Promise { - this.tenantModelExtension.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [TenantModelExtension] -}); -``` - ## Types & Classes ### `TenantExtensions` diff --git a/docs/developer-docs/6.x/reference/api/website-builder/nextjs.mdx b/docs/developer-docs/6.x/reference/api/website-builder/nextjs.mdx index 4286cd219..5a01f6d6b 100644 --- a/docs/developer-docs/6.x/reference/api/website-builder/nextjs.mdx +++ b/docs/developer-docs/6.x/reference/api/website-builder/nextjs.mdx @@ -44,22 +44,3 @@ namespace NextjsConfig { type Return = Promise; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { NextjsConfig } from "webiny/api/website-builder/nextjs"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private nextjsConfig: NextjsConfig.Interface) {} - - public async execute(/* ... */): Promise { - await this.nextjsConfig.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [NextjsConfig] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/website-builder/page.mdx b/docs/developer-docs/6.x/reference/api/website-builder/page.mdx index f78c7cc0b..dfbdd4207 100644 --- a/docs/developer-docs/6.x/reference/api/website-builder/page.mdx +++ b/docs/developer-docs/6.x/reference/api/website-builder/page.mdx @@ -97,27 +97,6 @@ namespace CreatePageRevisionFromUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreatePageRevisionFromUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private createPageRevisionFromUseCase: CreatePageRevisionFromUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.createPageRevisionFromUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreatePageRevisionFromUseCase] -}); -``` - ### `CreatePageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -146,25 +125,6 @@ namespace CreatePageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreatePageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createPageUseCase: CreatePageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createPageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreatePageUseCase] -}); -``` - ### `DeletePageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -192,25 +152,6 @@ namespace DeletePageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeletePageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deletePageUseCase: DeletePageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deletePageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeletePageUseCase] -}); -``` - ### `DuplicatePageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -239,25 +180,6 @@ namespace DuplicatePageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DuplicatePageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private duplicatePageUseCase: DuplicatePageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.duplicatePageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DuplicatePageUseCase] -}); -``` - ### `GetPageByIdUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -268,6 +190,8 @@ import { GetPageByIdUseCase } from "webiny/api/website-builder/page"; **Interface `GetPageByIdUseCase.Interface`:** +GetPageById use case interface + ```typescript interface GetPageByIdUseCase.Interface { execute(id: string): Promise>; @@ -285,25 +209,6 @@ namespace GetPageByIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPageByIdUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getPageByIdUseCase: GetPageByIdUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getPageByIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPageByIdUseCase] -}); -``` - ### `GetPageByPathUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -314,6 +219,8 @@ import { GetPageByPathUseCase } from "webiny/api/website-builder/page"; **Interface `GetPageByPathUseCase.Interface`:** +GetPageByPath use case interface + ```typescript interface GetPageByPathUseCase.Interface { execute(path: string): Promise>; @@ -331,25 +238,6 @@ namespace GetPageByPathUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPageByPathUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getPageByPathUseCase: GetPageByPathUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getPageByPathUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPageByPathUseCase] -}); -``` - ### `GetPageRevisionsUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -360,6 +248,8 @@ import { GetPageRevisionsUseCase } from "webiny/api/website-builder/page"; **Interface `GetPageRevisionsUseCase.Interface`:** +GetPageRevisions use case interface + ```typescript interface GetPageRevisionsUseCase.Interface { execute(entryId: string): Promise>; @@ -377,25 +267,6 @@ namespace GetPageRevisionsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetPageRevisionsUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getPageRevisionsUseCase: GetPageRevisionsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getPageRevisionsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetPageRevisionsUseCase] -}); -``` - ### `ListPagesUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -406,6 +277,8 @@ import { ListPagesUseCase } from "webiny/api/website-builder/page"; **Interface `ListPagesUseCase.Interface`:** +ListPages use case interface + ```typescript interface ListPagesUseCase.Interface { execute(params: IListPagesParams): Promise>; @@ -423,25 +296,6 @@ namespace ListPagesUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListPagesUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listPagesUseCase: ListPagesUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listPagesUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListPagesUseCase] -}); -``` - ### `MovePageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -470,25 +324,6 @@ namespace MovePageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { MovePageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private movePageUseCase: MovePageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.movePageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [MovePageUseCase] -}); -``` - ### `PublishPageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -517,25 +352,6 @@ namespace PublishPageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { PublishPageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private publishPageUseCase: PublishPageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.publishPageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [PublishPageUseCase] -}); -``` - ### `UnpublishPageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -564,25 +380,6 @@ namespace UnpublishPageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UnpublishPageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private unpublishPageUseCase: UnpublishPageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.unpublishPageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UnpublishPageUseCase] -}); -``` - ### `UpdatePageUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/page` @@ -611,25 +408,6 @@ namespace UpdatePageUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdatePageUseCase } from "webiny/api/website-builder/page"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updatePageUseCase: UpdatePageUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updatePageUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdatePageUseCase] -}); -``` - ## Event Handlers ### `PageAfterCreateEventHandler` @@ -666,25 +444,6 @@ namespace PageAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterCreateEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterCreateEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterCreateRevisionFromEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -719,25 +478,6 @@ namespace PageAfterCreateRevisionFromEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterCreateRevisionFromEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterCreateRevisionFromEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterCreateRevisionFromEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageAfterCreateRevisionFromEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -772,25 +512,6 @@ namespace PageAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterDeleteEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterDeleteEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterDuplicateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -826,25 +547,6 @@ namespace PageAfterDuplicateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterDuplicateEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterDuplicateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterDuplicateEventHandler.Event): Promise { - const { original, page } = event.payload; - } -} - -export default PageAfterDuplicateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterMoveEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -881,25 +583,6 @@ namespace PageAfterMoveEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterMoveEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterMoveEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterMoveEventHandler.Event): Promise { - const { original, input, page } = event.payload; - } -} - -export default PageAfterMoveEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterPublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -934,25 +617,6 @@ namespace PageAfterPublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterPublishEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterPublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterPublishEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageAfterPublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterUnpublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -987,25 +651,6 @@ namespace PageAfterUnpublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterUnpublishEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterUnpublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterUnpublishEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageAfterUnpublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1045,25 +690,6 @@ namespace PageAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageAfterUpdateEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageAfterUpdateEventHandler.Event): Promise { - const { original, input, page } = event.payload; - } -} - -export default PageAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1098,25 +724,6 @@ namespace PageBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeCreateEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeCreateEventHandler.Event): Promise { - const { input } = event.payload; - } -} - -export default PageBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeCreateRevisionFromEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1151,25 +758,6 @@ namespace PageBeforeCreateRevisionFromEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeCreateRevisionFromEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeCreateRevisionFromEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeCreateRevisionFromEventHandler.Event): Promise { - const { params } = event.payload; - } -} - -export default PageBeforeCreateRevisionFromEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1204,25 +792,6 @@ namespace PageBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeDeleteEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeDeleteEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeDuplicateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1257,25 +826,6 @@ namespace PageBeforeDuplicateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeDuplicateEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeDuplicateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeDuplicateEventHandler.Event): Promise { - const { original } = event.payload; - } -} - -export default PageBeforeDuplicateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeMoveEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1311,25 +861,6 @@ namespace PageBeforeMoveEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeMoveEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeMoveEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeMoveEventHandler.Event): Promise { - const { original, input } = event.payload; - } -} - -export default PageBeforeMoveEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforePublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1364,25 +895,6 @@ namespace PageBeforePublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforePublishEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforePublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforePublishEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageBeforePublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeUnpublishEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1417,25 +929,6 @@ namespace PageBeforeUnpublishEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeUnpublishEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeUnpublishEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeUnpublishEventHandler.Event): Promise { - const { page } = event.payload; - } -} - -export default PageBeforeUnpublishEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `PageBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/page` @@ -1473,22 +966,3 @@ namespace PageBeforeUpdateEventHandler { type Page = WbPage; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { PageBeforeUpdateEventHandler } from "webiny/api/website-builder/page"; - -class MyHandler implements PageBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: PageBeforeUpdateEventHandler.Event): Promise { - const { original, input } = event.payload; - } -} - -export default PageBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/api/website-builder/redirect.mdx b/docs/developer-docs/6.x/reference/api/website-builder/redirect.mdx index c39fe8a26..24f7ea5be 100644 --- a/docs/developer-docs/6.x/reference/api/website-builder/redirect.mdx +++ b/docs/developer-docs/6.x/reference/api/website-builder/redirect.mdx @@ -79,25 +79,6 @@ namespace CreateRedirectUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CreateRedirectUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private createRedirectUseCase: CreateRedirectUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.createRedirectUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CreateRedirectUseCase] -}); -``` - ### `DeleteRedirectUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -125,25 +106,6 @@ namespace DeleteRedirectUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { DeleteRedirectUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private deleteRedirectUseCase: DeleteRedirectUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.deleteRedirectUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [DeleteRedirectUseCase] -}); -``` - ### `GetActiveRedirectsUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -154,6 +116,8 @@ import { GetActiveRedirectsUseCase } from "webiny/api/website-builder/redirect"; **Interface `GetActiveRedirectsUseCase.Interface`:** +GetActiveRedirects use case interface + ```typescript interface GetActiveRedirectsUseCase.Interface { execute(): Promise>; @@ -171,25 +135,6 @@ namespace GetActiveRedirectsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetActiveRedirectsUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getActiveRedirectsUseCase: GetActiveRedirectsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getActiveRedirectsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetActiveRedirectsUseCase] -}); -``` - ### `GetRedirectByIdUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -200,6 +145,8 @@ import { GetRedirectByIdUseCase } from "webiny/api/website-builder/redirect"; **Interface `GetRedirectByIdUseCase.Interface`:** +GetRedirectById use case interface + ```typescript interface GetRedirectByIdUseCase.Interface { execute(id: string): Promise>; @@ -217,25 +164,6 @@ namespace GetRedirectByIdUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetRedirectByIdUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getRedirectByIdUseCase: GetRedirectByIdUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.getRedirectByIdUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetRedirectByIdUseCase] -}); -``` - ### `InvalidateRedirectsCacheUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -262,27 +190,6 @@ namespace InvalidateRedirectsCacheUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { InvalidateRedirectsCacheUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor( - private invalidateRedirectsCacheUseCase: InvalidateRedirectsCacheUseCase.Interface - ) {} - - public async execute(/* ... */): Promise { - await this.invalidateRedirectsCacheUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [InvalidateRedirectsCacheUseCase] -}); -``` - ### `ListRedirectsUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -311,25 +218,6 @@ namespace ListRedirectsUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ListRedirectsUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private listRedirectsUseCase: ListRedirectsUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.listRedirectsUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ListRedirectsUseCase] -}); -``` - ### `MoveRedirectUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -358,25 +246,6 @@ namespace MoveRedirectUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { MoveRedirectUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private moveRedirectUseCase: MoveRedirectUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.moveRedirectUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [MoveRedirectUseCase] -}); -``` - ### `UpdateRedirectUseCase` **Use Case Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -405,25 +274,6 @@ namespace UpdateRedirectUseCase { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { UpdateRedirectUseCase } from "webiny/api/website-builder/redirect"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private updateRedirectUseCase: UpdateRedirectUseCase.Interface) {} - - public async execute(/* ... */): Promise { - await this.updateRedirectUseCase.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [UpdateRedirectUseCase] -}); -``` - ## Event Handlers ### `RedirectAfterCreateEventHandler` @@ -460,25 +310,6 @@ namespace RedirectAfterCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectAfterCreateEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectAfterCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectAfterCreateEventHandler.Event): Promise { - const { redirect } = event.payload; - } -} - -export default RedirectAfterCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectAfterDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -513,25 +344,6 @@ namespace RedirectAfterDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectAfterDeleteEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectAfterDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectAfterDeleteEventHandler.Event): Promise { - const { redirect } = event.payload; - } -} - -export default RedirectAfterDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectAfterMoveEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -568,25 +380,6 @@ namespace RedirectAfterMoveEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectAfterMoveEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectAfterMoveEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectAfterMoveEventHandler.Event): Promise { - const { original, input, redirect } = event.payload; - } -} - -export default RedirectAfterMoveEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectAfterUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -626,25 +419,6 @@ namespace RedirectAfterUpdateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectAfterUpdateEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectAfterUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectAfterUpdateEventHandler.Event): Promise { - const { original, input, redirect } = event.payload; - } -} - -export default RedirectAfterUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectBeforeCreateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -679,25 +453,6 @@ namespace RedirectBeforeCreateEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectBeforeCreateEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectBeforeCreateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectBeforeCreateEventHandler.Event): Promise { - const { input } = event.payload; - } -} - -export default RedirectBeforeCreateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectBeforeDeleteEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -732,25 +487,6 @@ namespace RedirectBeforeDeleteEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectBeforeDeleteEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectBeforeDeleteEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectBeforeDeleteEventHandler.Event): Promise { - const { redirect } = event.payload; - } -} - -export default RedirectBeforeDeleteEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectBeforeMoveEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -786,25 +522,6 @@ namespace RedirectBeforeMoveEventHandler { } ``` -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectBeforeMoveEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectBeforeMoveEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectBeforeMoveEventHandler.Event): Promise { - const { original, input } = event.payload; - } -} - -export default RedirectBeforeMoveEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` - ### `RedirectBeforeUpdateEventHandler` **Event Handler Abstraction** — imported from `webiny/api/website-builder/redirect` @@ -842,22 +559,3 @@ namespace RedirectBeforeUpdateEventHandler { type Redirect = WbRedirect; } ``` - -**Usage:** - -```typescript extensions/MyHandler.ts -import { RedirectBeforeUpdateEventHandler } from "webiny/api/website-builder/redirect"; - -class MyHandler implements RedirectBeforeUpdateEventHandler.Interface { - public constructor(/* inject dependencies here */) {} - - public async handle(event: RedirectBeforeUpdateEventHandler.Event): Promise { - const { original, input } = event.payload; - } -} - -export default RedirectBeforeUpdateEventHandler.createImplementation({ - implementation: MyHandler, - dependencies: [] -}); -``` diff --git a/docs/developer-docs/6.x/reference/cli/command.mdx b/docs/developer-docs/6.x/reference/cli/command.mdx index 111b264e2..3c3df8e89 100644 --- a/docs/developer-docs/6.x/reference/cli/command.mdx +++ b/docs/developer-docs/6.x/reference/cli/command.mdx @@ -38,20 +38,3 @@ namespace CliCommandFactory { type CommandDefinition = ICliCommandDefinition; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { CliCommandFactory } from "webiny/cli/command"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private cliCommandFactory: CliCommandFactory.Interface) {} - - public async execute(/* ... */): Promise {} -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CliCommandFactory] -}); -``` diff --git a/docs/developer-docs/6.x/reference/cli/overview.mdx b/docs/developer-docs/6.x/reference/cli/overview.mdx index dba8e26b1..25b435229 100644 --- a/docs/developer-docs/6.x/reference/cli/overview.mdx +++ b/docs/developer-docs/6.x/reference/cli/overview.mdx @@ -55,25 +55,6 @@ namespace Logger { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { Logger } from "webiny/cli/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private logger: Logger.Interface) {} - - public async execute(/* ... */): Promise { - this.logger.info(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [Logger] -}); -``` - ## `Ui` **Abstraction** — imported from `webiny/cli/index` @@ -105,22 +86,3 @@ namespace Ui { type Interface = IUiService; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { Ui } from "webiny/cli/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private ui: Ui.Interface) {} - - public async execute(/* ... */): Promise { - this.ui.info(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [Ui] -}); -``` diff --git a/docs/developer-docs/6.x/reference/infra/admin.mdx b/docs/developer-docs/6.x/reference/infra/admin.mdx index b1a450ab6..52b6ce44a 100644 --- a/docs/developer-docs/6.x/reference/infra/admin.mdx +++ b/docs/developer-docs/6.x/reference/infra/admin.mdx @@ -55,25 +55,6 @@ namespace AdminAfterBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminAfterBuildHook } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminAfterBuildHook: AdminAfterBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.adminAfterBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminAfterBuildHook] -}); -``` - ## `AdminAfterDeployHook` **Abstraction** — imported from `webiny/infra/admin` @@ -99,25 +80,6 @@ namespace AdminAfterDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminAfterDeployHook } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminAfterDeployHook: AdminAfterDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.adminAfterDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminAfterDeployHook] -}); -``` - ## `AdminBeforeBuildHook` **Abstraction** — imported from `webiny/infra/admin` @@ -143,25 +105,6 @@ namespace AdminBeforeBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminBeforeBuildHook } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminBeforeBuildHook: AdminBeforeBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.adminBeforeBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminBeforeBuildHook] -}); -``` - ## `AdminBeforeDeployHook` **Abstraction** — imported from `webiny/infra/admin` @@ -187,25 +130,6 @@ namespace AdminBeforeDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminBeforeDeployHook } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminBeforeDeployHook: AdminBeforeDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.adminBeforeDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminBeforeDeployHook] -}); -``` - ## `AdminBeforeWatchHook` **Abstraction** — imported from `webiny/infra/admin` @@ -231,25 +155,6 @@ namespace AdminBeforeWatchHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminBeforeWatchHook } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminBeforeWatchHook: AdminBeforeWatchHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.adminBeforeWatchHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminBeforeWatchHook] -}); -``` - ## `AdminPulumi` **Abstraction** — imported from `webiny/infra/admin` @@ -267,23 +172,6 @@ namespace AdminPulumi { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminPulumi } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminPulumi: AdminPulumi.Interface) {} - - public async execute(/* ... */): Promise {} -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminPulumi] -}); -``` - ## `GetAdminStackOutput` **Abstraction** — imported from `webiny/infra/admin` @@ -308,22 +196,3 @@ namespace GetAdminStackOutput { type Output = IAdminStackOutput; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetAdminStackOutput } from "webiny/infra/admin"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getAdminStackOutput: GetAdminStackOutput.Interface) {} - - public async execute(/* ... */): Promise { - await this.getAdminStackOutput.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetAdminStackOutput] -}); -``` diff --git a/docs/developer-docs/6.x/reference/infra/api.mdx b/docs/developer-docs/6.x/reference/infra/api.mdx index 3bf0545b9..cb9614e18 100644 --- a/docs/developer-docs/6.x/reference/infra/api.mdx +++ b/docs/developer-docs/6.x/reference/infra/api.mdx @@ -55,25 +55,6 @@ namespace ApiAfterBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiAfterBuildHook } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiAfterBuildHook: ApiAfterBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiAfterBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiAfterBuildHook] -}); -``` - ## `ApiAfterDeployHook` **Abstraction** — imported from `webiny/infra/api` @@ -99,25 +80,6 @@ namespace ApiAfterDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiAfterDeployHook } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiAfterDeployHook: ApiAfterDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiAfterDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiAfterDeployHook] -}); -``` - ## `ApiBeforeBuildHook` **Abstraction** — imported from `webiny/infra/api` @@ -143,25 +105,6 @@ namespace ApiBeforeBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiBeforeBuildHook } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiBeforeBuildHook: ApiBeforeBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiBeforeBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiBeforeBuildHook] -}); -``` - ## `ApiBeforeDeployHook` **Abstraction** — imported from `webiny/infra/api` @@ -187,25 +130,6 @@ namespace ApiBeforeDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiBeforeDeployHook } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiBeforeDeployHook: ApiBeforeDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiBeforeDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiBeforeDeployHook] -}); -``` - ## `ApiBeforeWatchHook` **Abstraction** — imported from `webiny/infra/api` @@ -231,25 +155,6 @@ namespace ApiBeforeWatchHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiBeforeWatchHook } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiBeforeWatchHook: ApiBeforeWatchHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiBeforeWatchHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiBeforeWatchHook] -}); -``` - ## `ApiPulumi` **Abstraction** — imported from `webiny/infra/api` @@ -267,23 +172,6 @@ namespace ApiPulumi { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiPulumi } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiPulumi: ApiPulumi.Interface) {} - - public async execute(/* ... */): Promise {} -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiPulumi] -}); -``` - ## `GetApiStackOutput` **Abstraction** — imported from `webiny/infra/api` @@ -308,22 +196,3 @@ namespace GetApiStackOutput { type Output = IApiStackOutput; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetApiStackOutput } from "webiny/infra/api"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getApiStackOutput: GetApiStackOutput.Interface) {} - - public async execute(/* ... */): Promise { - await this.getApiStackOutput.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetApiStackOutput] -}); -``` diff --git a/docs/developer-docs/6.x/reference/infra/core.mdx b/docs/developer-docs/6.x/reference/infra/core.mdx index 29bcd455a..1951f6482 100644 --- a/docs/developer-docs/6.x/reference/infra/core.mdx +++ b/docs/developer-docs/6.x/reference/infra/core.mdx @@ -54,25 +54,6 @@ namespace CoreAfterBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CoreAfterBuildHook } from "webiny/infra/core"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private coreAfterBuildHook: CoreAfterBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.coreAfterBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CoreAfterBuildHook] -}); -``` - ## `CoreAfterDeployHook` **Abstraction** — imported from `webiny/infra/core` @@ -98,25 +79,6 @@ namespace CoreAfterDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CoreAfterDeployHook } from "webiny/infra/core"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private coreAfterDeployHook: CoreAfterDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.coreAfterDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CoreAfterDeployHook] -}); -``` - ## `CoreBeforeBuildHook` **Abstraction** — imported from `webiny/infra/core` @@ -142,25 +104,6 @@ namespace CoreBeforeBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CoreBeforeBuildHook } from "webiny/infra/core"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private coreBeforeBuildHook: CoreBeforeBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.coreBeforeBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CoreBeforeBuildHook] -}); -``` - ## `CoreBeforeDeployHook` **Abstraction** — imported from `webiny/infra/core` @@ -186,25 +129,6 @@ namespace CoreBeforeDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CoreBeforeDeployHook } from "webiny/infra/core"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private coreBeforeDeployHook: CoreBeforeDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.coreBeforeDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CoreBeforeDeployHook] -}); -``` - ## `CorePulumi` **Abstraction** — imported from `webiny/infra/core` @@ -222,23 +146,6 @@ namespace CorePulumi { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CorePulumi } from "webiny/infra/core"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private corePulumi: CorePulumi.Interface) {} - - public async execute(/* ... */): Promise {} -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CorePulumi] -}); -``` - ## `GetCoreStackOutput` **Abstraction** — imported from `webiny/infra/core` @@ -263,22 +170,3 @@ namespace GetCoreStackOutput { type Output = ICoreStackOutput; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { GetCoreStackOutput } from "webiny/infra/core"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private getCoreStackOutput: GetCoreStackOutput.Interface) {} - - public async execute(/* ... */): Promise { - await this.getCoreStackOutput.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [GetCoreStackOutput] -}); -``` diff --git a/docs/developer-docs/6.x/reference/infra/overview.mdx b/docs/developer-docs/6.x/reference/infra/overview.mdx index 33b1bff02..88e6188e1 100644 --- a/docs/developer-docs/6.x/reference/infra/overview.mdx +++ b/docs/developer-docs/6.x/reference/infra/overview.mdx @@ -61,25 +61,6 @@ namespace AdminStackOutput { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AdminStackOutput } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private adminStackOutput: AdminStackOutput.Interface) {} - - public async execute(/* ... */): Promise { - await this.adminStackOutput.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AdminStackOutput] -}); -``` - ## `AfterBuildHook` **Abstraction** — imported from `webiny/infra/index` @@ -105,25 +86,6 @@ namespace AfterBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AfterBuildHook } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private afterBuildHook: AfterBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.afterBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AfterBuildHook] -}); -``` - ## `AfterDeployHook` **Abstraction** — imported from `webiny/infra/index` @@ -149,25 +111,6 @@ namespace AfterDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { AfterDeployHook } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private afterDeployHook: AfterDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.afterDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [AfterDeployHook] -}); -``` - ## `ApiGqlClient` **Abstraction** — imported from `webiny/infra/index` @@ -200,25 +143,6 @@ namespace ApiGqlClient { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiGqlClient } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiGqlClient: ApiGqlClient.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiGqlClient.query(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiGqlClient] -}); -``` - ## `ApiStackOutput` **Abstraction** — imported from `webiny/infra/index` @@ -244,25 +168,6 @@ namespace ApiStackOutput { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { ApiStackOutput } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private apiStackOutput: ApiStackOutput.Interface) {} - - public async execute(/* ... */): Promise { - await this.apiStackOutput.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [ApiStackOutput] -}); -``` - ## `BeforeBuildHook` **Abstraction** — imported from `webiny/infra/index` @@ -288,25 +193,6 @@ namespace BeforeBuildHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { BeforeBuildHook } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private beforeBuildHook: BeforeBuildHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.beforeBuildHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BeforeBuildHook] -}); -``` - ## `BeforeDeployHook` **Abstraction** — imported from `webiny/infra/index` @@ -332,25 +218,6 @@ namespace BeforeDeployHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { BeforeDeployHook } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private beforeDeployHook: BeforeDeployHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.beforeDeployHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BeforeDeployHook] -}); -``` - ## `BeforeWatchHook` **Abstraction** — imported from `webiny/infra/index` @@ -376,25 +243,6 @@ namespace BeforeWatchHook { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { BeforeWatchHook } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private beforeWatchHook: BeforeWatchHook.Interface) {} - - public async execute(/* ... */): Promise { - await this.beforeWatchHook.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [BeforeWatchHook] -}); -``` - ## `CoreStackOutput` **Abstraction** — imported from `webiny/infra/index` @@ -420,25 +268,6 @@ namespace CoreStackOutput { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { CoreStackOutput } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private coreStackOutput: CoreStackOutput.Interface) {} - - public async execute(/* ... */): Promise { - await this.coreStackOutput.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [CoreStackOutput] -}); -``` - ## `EnvVar` **Constant** — imported from `webiny/infra/index` @@ -485,25 +314,6 @@ namespace InvokeLambdaFunction { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { InvokeLambdaFunction } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private invokeLambdaFunction: InvokeLambdaFunction.Interface) {} - - public async execute(/* ... */): Promise { - await this.invokeLambdaFunction.execute(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [InvokeLambdaFunction] -}); -``` - ## `Logger` **Abstraction** — imported from `webiny/infra/index` @@ -534,25 +344,6 @@ namespace Logger { } ``` -**Usage:** - -```typescript extensions/MyImpl.ts -import { Logger } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private logger: Logger.Interface) {} - - public async execute(/* ... */): Promise { - this.logger.info(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [Logger] -}); -``` - ## `Ui` **Abstraction** — imported from `webiny/infra/index` @@ -584,22 +375,3 @@ namespace Ui { type Interface = IUiService; } ``` - -**Usage:** - -```typescript extensions/MyImpl.ts -import { Ui } from "webiny/infra/index"; - -class MyImpl implements MyUseCase.Interface { - public constructor(private ui: Ui.Interface) {} - - public async execute(/* ... */): Promise { - this.ui.info(/* ... */); - } -} - -export default MyUseCase.createImplementation({ - implementation: MyImpl, - dependencies: [Ui] -}); -``` diff --git a/img.png b/img.png new file mode 100644 index 000000000..156de82f2 Binary files /dev/null and b/img.png differ diff --git a/img_1.png b/img_1.png new file mode 100644 index 000000000..d916a09b4 Binary files /dev/null and b/img_1.png differ diff --git a/img_2.png b/img_2.png new file mode 100644 index 000000000..a09333915 Binary files /dev/null and b/img_2.png differ diff --git a/scripts/generate-reference.ts b/scripts/generate-reference.ts index daaaea29d..20c31b86f 100644 --- a/scripts/generate-reference.ts +++ b/scripts/generate-reference.ts @@ -52,11 +52,26 @@ interface InterfaceMember { jsDoc: string; } +interface ResolvedTypeFields { + /** The interface/type name that was resolved (e.g. "AppInstallationData") */ + typeName: string; + /** Whether it was an array (e.g. InstallSystemInput = AppInstallationData[]) */ + isArray: boolean; + /** JSDoc on the resolved interface */ + jsDoc: string; + /** The fields of the resolved object interface */ + fields: EventPayloadField[]; +} + interface NamespaceMember { /** e.g. "Interface" */ name: string; /** e.g. "ICreateEntryUseCase" or "Promise>" */ value: string; + /** Resolved fields if the type alias points to a plain object interface */ + resolvedFields?: ResolvedTypeFields; + /** Resolved interface members if the type alias points to a method interface (e.g. Foo.Interface) */ + resolvedMembers?: { members: InterfaceMember[]; jsDoc: string }; } interface EventPayloadField { @@ -93,6 +108,8 @@ interface ExtractedSymbol { abstractionKind?: AbstractionKind; /** The resolved Interface members (from IFoo that createAbstraction wraps) */ interfaceMembers?: InterfaceMember[]; + /** JSDoc on the IFoo interface itself (description paragraph) */ + interfaceJsDoc?: string; /** Resolved namespace type members: Interface, Input, Return, Error, Event, etc. */ namespaceTypes?: NamespaceMember[]; /** For eventHandler: the payload fields of the event */ @@ -103,6 +120,17 @@ interface ExtractedSymbol { eventPayloadName?: string; } +interface Example { + /** H2 heading text, e.g. "Basic Usage" */ + title: string; + /** Optional prose paragraph between the heading and the first code block */ + description: string; + /** Raw code block content (without fences) */ + code: string; + /** Language tag from the code fence, e.g. "typescript" */ + lang: string; +} + interface EntryPointDoc { /** e.g. "webiny/api/cms/entry" */ importPath: string; @@ -114,6 +142,8 @@ interface EntryPointDoc { description: string; /** All symbols exported from this entry point */ symbols: ExtractedSymbol[]; + /** Examples parsed from a co-located *.examples.md file, if present */ + examples?: Example[]; } // --------------------------------------------------------------------------- @@ -335,6 +365,12 @@ function extractJsDoc(node: Node): string { .join("\n"); } +/** Returns true if a node has an @internal JSDoc tag */ +function isInternalNode(node: Node): boolean { + const jsDocNodes = node.getChildrenOfKind(SyntaxKind.JSDoc); + return jsDocNodes.some(jd => jd.getText().includes("@internal")); +} + function cleanDeclarationText(text: string): string { return text .replace(/\{[\s\S]*\}/g, match => { @@ -360,16 +396,21 @@ function getIsolatedProject(): Project { /** * Search a source file (and any files it re-exports from) for an interface by name. - * Returns the interface members, or [] if not found. + * Returns the interface members and interface-level JSDoc, or empty if not found. */ +interface InterfaceResult { + members: InterfaceMember[]; + jsDoc: string; +} + function extractInterfaceMembers( sf: SourceFile, interfaceName: string, pkgMap?: Map, visited = new Set() -): InterfaceMember[] { +): InterfaceResult { const filePath = sf.getFilePath(); - if (visited.has(filePath)) return []; + if (visited.has(filePath)) return { members: [], jsDoc: "" }; visited.add(filePath); // Search all interfaces in this file @@ -380,23 +421,32 @@ function extractInterfaceMembers( const iface = allIfaces.find(i => i.getName() === interfaceName); if (iface) { - return iface.getMembers().map(m => ({ - signature: m.getText().trim().replace(/;$/, ""), - jsDoc: extractJsDoc(m) - })); + return { + members: iface + .getMembers() + .filter(m => !isInternalNode(m)) + .map(m => ({ + signature: m.getText().trim().replace(/;$/, ""), + jsDoc: extractJsDoc(m) + })), + jsDoc: extractJsDoc(iface) + }; } - // Raw text fallback for this file + // Raw text fallback for this file (no JSDoc available here) const src = sf.getFullText(); const rawMatch = src.match( new RegExp(`interface\\s+${interfaceName}\\s*(?:<[^{]*>)?\\s*\\{([^}]+)\\}`) ); if (rawMatch) { - return rawMatch[1] - .split("\n") - .map(l => l.trim()) - .filter(l => l && !l.startsWith("//") && l !== "{" && l !== "}") - .map(l => ({ signature: l.replace(/;$/, ""), jsDoc: "" })); + return { + members: rawMatch[1] + .split("\n") + .map(l => l.trim()) + .filter(l => l && !l.startsWith("//") && l !== "{" && l !== "}") + .map(l => ({ signature: l.replace(/;$/, ""), jsDoc: "" })), + jsDoc: "" + }; } // Follow re-exports into sibling files (handles index.ts -> abstractions.ts pattern) @@ -407,7 +457,6 @@ function extractInterfaceMembers( let resolvedPath: string | null = null; if (modSpec.startsWith(".")) { - // Relative import — resolve relative to this file's directory const dir = sf.getDirectoryPath(); resolvedPath = join(dir, modSpec.replace(/\.js$/, ".ts")); } else { @@ -419,14 +468,14 @@ function extractInterfaceMembers( try { const siblingSf = sf.getProject().addSourceFileAtPath(resolvedPath); const result = extractInterfaceMembers(siblingSf, interfaceName, pkgMap, visited); - if (result.length > 0) return result; + if (result.members.length > 0) return result; } catch { continue; } } } - return []; + return { members: [], jsDoc: "" }; } /** Extract fields from an interface declaration as EventPayloadField[] */ @@ -463,6 +512,220 @@ function extractPayloadFields(sf: SourceFile, interfaceName: string): EventPaylo .filter((f): f is EventPayloadField => f !== null); } +/** + * Resolve a module specifier to an absolute .ts file path. + * Handles: relative ("./" "../"), @webiny/* aliases, and "~/*" (local src alias). + */ +function resolveModuleSpecifier( + sf: SourceFile, + modSpec: string, + pkgMap: Map +): string | null { + if (modSpec.startsWith(".")) { + return join(sf.getDirectoryPath(), modSpec.replace(/\.js$/, ".ts")); + } + if (modSpec.startsWith("~/")) { + // "~/" maps to the "src/" root of the current package. + // Walk up from the current file to find the "src" directory boundary. + const parts = sf.getFilePath().split("/"); + const srcIdx = parts.lastIndexOf("src"); + if (srcIdx !== -1) { + const srcRoot = parts.slice(0, srcIdx + 1).join("/"); + return join(srcRoot, modSpec.slice(2).replace(/\.js$/, ".ts")); + } + return null; + } + return resolveWebinyImport(modSpec, pkgMap); +} + +/** + * Resolve a "Namespace.Interface" type reference to interface members. + * e.g. "GraphQLSchemaBuilder.Interface" → finds GraphQLSchemaBuilder's IGraphQLSchemaBuilder interface. + */ +function resolveNamespaceDotInterface( + sf: SourceFile, + typeText: string, + pkgMap: Map +): { members: InterfaceMember[]; jsDoc: string } | null { + // Only handle Foo.Interface pattern + const m = typeText.match(/^(\w+)\.Interface$/); + if (!m) return null; + const abstractionName = m[1]; + + // Find where abstractionName is imported from + for (const decl of sf.getImportDeclarations()) { + const named = decl.getNamedImports().find(n => n.getName() === abstractionName); + if (!named) continue; + const modSpec = decl.getModuleSpecifierValue(); + const resolvedPath = resolveModuleSpecifier(sf, modSpec, pkgMap); + if (!resolvedPath || !existsSync(resolvedPath)) continue; + try { + const targetSf = sf.getProject().addSourceFileAtPath(resolvedPath); + // In the target file, find createAbstraction for this name and extract IFoo + const exported = targetSf.getExportedDeclarations(); + const decls = exported.get(abstractionName); + if (!decls) continue; + const varDecl = decls.find(d => Node.isVariableDeclaration(d)); + if (!varDecl || !Node.isVariableDeclaration(varDecl)) continue; + const genericArg = getCreateAbstractionGeneric(varDecl); + if (!genericArg) continue; + const nodeSf = varDecl.getSourceFile(); + return extractInterfaceMembers(nodeSf, genericArg, pkgMap).members.length > 0 + ? extractInterfaceMembers(nodeSf, genericArg, pkgMap) + : null; + } catch { + continue; + } + } + return null; +} + +/** + * Given a type alias name (e.g. "InstallSystemInput") in a source file, resolves it to + * an object interface and returns its fields. Only resolves simple aliases: + * type Foo = SomeInterface → fields of SomeInterface + * type Foo = SomeInterface[] → fields of SomeInterface (isArray=true) + * Skips generics, unions, Promise<...>, primitives, etc. + * Follows re-exports into sibling files. + */ +function resolveTypeToFields( + sf: SourceFile, + typeName: string, + pkgMap: Map, + visited = new Set() +): ResolvedTypeFields | null { + const filePath = sf.getFilePath(); + if (visited.has(filePath)) return null; + visited.add(filePath); + + // Find the type alias in this file + const typeAlias = sf.getTypeAliases().find(t => t.getName() === typeName); + if (typeAlias) { + const typeNode = typeAlias.getTypeNode(); + if (!typeNode) return null; + const typeText = typeNode.getText().trim(); + + // Skip anything with generics, unions, intersections, Promise, or primitives + if ( + typeText.includes("<") || + typeText.includes("|") || + typeText.includes("&") || + typeText === "string" || + typeText === "number" || + typeText === "boolean" || + typeText === "any" || + typeText === "void" || + typeText === "unknown" + ) { + return null; + } + + // Array alias: type Foo = Bar[] + const arrayMatch = typeText.match(/^(\w+)\[\]$/); + if (arrayMatch) { + const innerName = arrayMatch[1]; + const inner = resolveInterfaceFields(sf, innerName, pkgMap); + if (!inner) return null; + return { typeName: innerName, isArray: true, jsDoc: inner.jsDoc, fields: inner.fields }; + } + + // Direct alias: type Foo = Bar + if (/^\w+$/.test(typeText)) { + const inner = resolveInterfaceFields(sf, typeText, pkgMap); + if (!inner) return null; + return { typeName: typeText, isArray: false, jsDoc: inner.jsDoc, fields: inner.fields }; + } + + return null; + } + + // Follow re-exports + for (const decl of sf.getExportDeclarations()) { + const modSpec = decl.getModuleSpecifierValue(); + if (!modSpec) continue; + const resolvedPath = resolveModuleSpecifier(sf, modSpec, pkgMap); + if (!resolvedPath || !existsSync(resolvedPath)) continue; + try { + const siblingSf = sf.getProject().addSourceFileAtPath(resolvedPath); + const result = resolveTypeToFields(siblingSf, typeName, pkgMap, visited); + if (result) return result; + } catch { + continue; + } + } + + return null; +} + +/** + * Find an interface by name in a source file (or via imports) and return its fields + JSDoc. + */ +function resolveInterfaceFields( + sf: SourceFile, + interfaceName: string, + pkgMap: Map, + visited = new Set() +): { fields: EventPayloadField[]; jsDoc: string } | null { + const filePath = sf.getFilePath(); + if (visited.has(filePath)) return null; + visited.add(filePath); + + // Look for the interface in this file + const allIfaces = [ + ...sf.getInterfaces(), + ...sf.getStatements().filter(Node.isInterfaceDeclaration) + ].filter(Node.isInterfaceDeclaration); + + const iface = allIfaces.find(i => i.getName() === interfaceName); + if (iface) { + const fields = iface + .getProperties() + .filter(p => !isInternalNode(p)) + .map(p => ({ + name: p.getName(), + typeText: p.getTypeNode()?.getText() ?? "unknown", + optional: p.hasQuestionToken() + })); + return { fields, jsDoc: extractJsDoc(iface) }; + } + + // Follow named imports + for (const decl of sf.getImportDeclarations()) { + const named = decl.getNamedImports().find(n => n.getName() === interfaceName); + if (!named) continue; + const modSpec = decl.getModuleSpecifierValue(); + const resolvedPath = resolveModuleSpecifier(sf, modSpec, pkgMap); + if (!resolvedPath || !existsSync(resolvedPath)) continue; + try { + const siblingSf = sf.getProject().addSourceFileAtPath(resolvedPath); + const result = resolveInterfaceFields(siblingSf, interfaceName, pkgMap, visited); + if (result) return result; + } catch { + continue; + } + } + + // Follow re-exports (export * from "..." or export { X } from "...") + for (const decl of sf.getExportDeclarations()) { + const namedExports = decl.getNamedExports(); + // Only follow if it's export * or exports our interface name + if (namedExports.length > 0 && !namedExports.some(n => n.getName() === interfaceName)) continue; + const modSpec = decl.getModuleSpecifierValue(); + if (!modSpec) continue; + const resolvedPath = resolveModuleSpecifier(sf, modSpec, pkgMap); + if (!resolvedPath || !existsSync(resolvedPath)) continue; + try { + const siblingSf = sf.getProject().addSourceFileAtPath(resolvedPath); + const result = resolveInterfaceFields(siblingSf, interfaceName, pkgMap, visited); + if (result) return result; + } catch { + continue; + } + } + + return null; +} + /** Extract namespace type members as NamespaceMember[] */ function extractNamespaceTypes(sf: SourceFile, namespaceName: string): NamespaceMember[] { const allModules = sf.getModules(); @@ -609,8 +872,28 @@ function extractSymbol(sf: SourceFile, name: string): ExtractedSymbol | null { const members = node .getMembers() .map(m => { + // Properties (public readonly foo: Bar) — no body, use full text + if (Node.isPropertyDeclaration(m)) { + return m.getText().trim().replace(/;?$/, ";"); + } + // Constructors and methods — strip the implementation body + if (Node.isConstructorDeclaration(m) || Node.isMethodDeclaration(m)) { + const body = m.getBody ? m.getBody() : null; + if (body) { + const bodyStart = body.getStart(); + const nodeStart = m.getStart(); + const sig = m + .getText() + .substring(0, bodyStart - nodeStart) + .trim(); + return sig + ";"; + } + // No body (overload or abstract) — use full text + return m.getText().trim().replace(/;?$/, ";"); + } + // Fallback for other member kinds const txt = m.getText().trim(); - return txt.replace(/\{[\s\S]*$/, "").trim() + (txt.includes("{") ? ";" : ""); + return txt.replace(/;?$/, ";"); }) .filter(Boolean); @@ -682,6 +965,7 @@ function extractSymbol(sf: SourceFile, name: string): ExtractedSymbol | null { const eventPayloadFields: EventPayloadField[] = []; let eventTypeName: string | undefined; let eventPayloadName: string | undefined; + let interfaceJsDoc: string | undefined; if (abstractionKind === "eventHandler") { // IEventHandler or IEventHandler> @@ -707,9 +991,13 @@ function extractSymbol(sf: SourceFile, name: string): ExtractedSymbol | null { jsDoc: "" }); } else { - // useCase or service — resolve the IFoo interface, following re-exports - const resolved = extractInterfaceMembers(sf, genericArg, PKG_MAP); - interfaceMembers.push(...resolved); + // useCase or service — resolve the IFoo interface. + // Start from the file where createAbstraction is actually defined + // (which may be a deep source file, not the barrel re-exporting it). + const nodeSf = node.getSourceFile(); + const resolved = extractInterfaceMembers(nodeSf, genericArg, PKG_MAP); + interfaceMembers.push(...resolved.members); + if (resolved.jsDoc) interfaceJsDoc = resolved.jsDoc; } // Extract namespace types — first try the co-located nsDecl, then search by name @@ -731,6 +1019,38 @@ function extractSymbol(sf: SourceFile, name: string): ExtractedSymbol | null { })() : extractNamespaceTypes(sf, name); + // For each namespace type, try to resolve its fields or members + const nodeSfForTypes = node.getSourceFile(); + namespaceTypes = namespaceTypes.map(t => { + // Skip Interface — it just aliases the abstraction itself + if (t.name === "Interface") return t; + const val = t.value.trim(); + + // Foo.Interface pattern → resolve as method interface + if (/^\w+\.Interface$/.test(val)) { + try { + const resolved = resolveNamespaceDotInterface(nodeSfForTypes, val, PKG_MAP); + if (resolved && resolved.members.length > 0) + return { ...t, resolvedMembers: resolved }; + } catch { + /* ignore */ + } + return t; + } + + // Simple identifier → try to resolve as plain object fields + if (/^\w+$/.test(val)) { + try { + const resolved = resolveTypeToFields(nodeSfForTypes, val, PKG_MAP); + if (resolved && resolved.fields.length > 0) return { ...t, resolvedFields: resolved }; + } catch { + /* ignore */ + } + } + + return t; + }); + return { name, kind: "abstraction", @@ -741,6 +1061,7 @@ function extractSymbol(sf: SourceFile, name: string): ExtractedSymbol | null { sourceFile: sf.getFilePath(), abstractionKind, interfaceMembers, + interfaceJsDoc, namespaceTypes, eventPayloadFields, eventTypeName, @@ -1086,23 +1407,35 @@ function renderSymbolSection( // Abstraction: rich rendering // ------------------------------------------------------------------------- if (sym.kind === "abstraction") { - // Interface section + // Interface section — description, code block for signatures, table for descriptions if (sym.interfaceMembers && sym.interfaceMembers.length > 0) { lines.push(`**Interface \`${sym.name}.Interface\`:**`); lines.push(""); + if (sym.interfaceJsDoc) { + lines.push(sym.interfaceJsDoc); + lines.push(""); + } + // Full signatures in a code block lines.push("```typescript"); lines.push(`interface ${sym.name}.Interface {`); for (const m of sym.interfaceMembers) { - if (m.jsDoc) { - for (const docLine of m.jsDoc.split("\n")) { - lines.push(` // ${docLine}`); - } - } lines.push(` ${m.signature};`); } lines.push("}"); lines.push("```"); lines.push(""); + // Description table — only rendered if any member has JSDoc + const hasAnyJsDoc = sym.interfaceMembers.some(m => m.jsDoc); + if (hasAnyJsDoc) { + lines.push("| Method | Description |"); + lines.push("| ------ | ----------- |"); + for (const m of sym.interfaceMembers) { + const methodName = m.signature.split("(")[0].trim(); + const desc = m.jsDoc ? m.jsDoc.replace(/\|/g, "\\|") : "—"; + lines.push(`| \`${methodName}()\` | ${desc} |`); + } + lines.push(""); + } } // Event payload section @@ -1135,17 +1468,52 @@ function renderSymbolSection( lines.push("}"); lines.push("```"); lines.push(""); - } - // Usage snippet - const usage = renderUsageSnippet(sym, importPath); - if (usage) { - lines.push(`**Usage:**`); - lines.push(""); - lines.push(`\`\`\`typescript ${usage.file}`); - lines.push(usage.body); - lines.push("```"); - lines.push(""); + // For each resolved type, emit a field table or method table + for (const t of sym.namespaceTypes) { + if (t.resolvedFields && t.resolvedFields.fields.length > 0) { + const { typeName, isArray, jsDoc, fields } = t.resolvedFields; + const label = isArray ? `${typeName}[]` : typeName; + lines.push(`**\`${t.name}\` — \`${label}\`:**`); + lines.push(""); + if (jsDoc) { + lines.push(jsDoc); + lines.push(""); + } + lines.push("| Field | Type | Required | Description |"); + lines.push("| ----- | ---- | -------- | ----------- |"); + for (const f of fields) { + const req = f.optional ? "no" : "yes"; + lines.push(`| \`${f.name}\` | \`${f.typeText.replace(/\|/g, "\\|")}\` | ${req} | — |`); + } + lines.push(""); + } else if (t.resolvedMembers && t.resolvedMembers.members.length > 0) { + const { members, jsDoc } = t.resolvedMembers; + lines.push(`**\`${t.name}\` — \`${t.value}\`:**`); + lines.push(""); + if (jsDoc) { + lines.push(jsDoc); + lines.push(""); + } + lines.push("```typescript"); + lines.push(`interface ${t.value} {`); + for (const m of members) lines.push(` ${m.signature};`); + lines.push("}"); + lines.push("```"); + lines.push(""); + const hasJsDoc = members.some(m => m.jsDoc); + if (hasJsDoc) { + lines.push("| Method | Description |"); + lines.push("| ------ | ----------- |"); + for (const m of members) { + const methodName = m.signature.split("(")[0].trim(); + const desc = m.jsDoc ? m.jsDoc.replace(/\|/g, "\\|") : "—"; + lines.push(`| \`${methodName}()\` | ${desc} |`); + } + lines.push(""); + } + } + } } return lines.join("\n"); @@ -1719,6 +2087,24 @@ function renderMdx(doc: EntryPointDoc, id: string): string { } } + // Examples section — appended at the bottom if a *.examples.md file was found + if (doc.examples && doc.examples.length > 0) { + lines.push("## Examples"); + lines.push(""); + for (const ex of doc.examples) { + lines.push(`### ${ex.title}`); + lines.push(""); + if (ex.description) { + lines.push(ex.description); + lines.push(""); + } + lines.push(`\`\`\`${ex.lang}`); + lines.push(ex.code); + lines.push("```"); + lines.push(""); + } + } + return lines.join("\n"); } @@ -1988,6 +2374,77 @@ function rewriteNavigation(entryPoints: EntryPointDoc[]): void { console.log(` [nav] Updated navigation.tsx Reference group`); } +// --------------------------------------------------------------------------- +// Examples: find and parse *.examples.md co-located with export barrels +// --------------------------------------------------------------------------- + +/** + * Parse a *.examples.md file into Example objects. + * Each H2 heading starts a new example. The text between the heading and + * the first code fence is the description; the first code fence is the code. + */ +function parseExamplesFile(filePath: string): Example[] { + const src = readFileSync(filePath, "utf-8"); + const examples: Example[] = []; + + // Split on H2 headings (## ...) + const sections = src.split(/^## /m).slice(1); // drop everything before first ## + + for (const section of sections) { + const lines = section.split("\n"); + const title = lines[0].trim(); + const rest = lines.slice(1).join("\n"); + + // Extract first code fence + const fenceMatch = rest.match(/```(\w*)\n([\s\S]*?)```/); + if (!fenceMatch) continue; + + const lang = fenceMatch[1] || "typescript"; + const code = fenceMatch[2].trimEnd(); + + // Everything before the code fence (trimmed) is the description + const description = rest.slice(0, rest.indexOf("```")).trim(); + + examples.push({ title, description, code, lang }); + } + + return examples; +} + +/** + * Walk the re-export chain from a webiny barrel file looking for a sibling + * *.examples.md file. Returns the parsed examples, or undefined if not found. + * + * Convention: examples files live next to either: + * a) The webiny barrel itself (webiny/src/api/logger.ts → logger.examples.md), or + * b) A mirror "exports/" barrel in any @webiny/* package that matches the same + * relative path (e.g. api-core/src/exports/api/logger.examples.md for api/logger) + */ +function findExamples( + barrelSrc: string, + relPath: string, + pkgMap: Map, + project: import("ts-morph").Project +): Example[] | undefined { + // 1. Check co-located with the webiny barrel + const sibling = barrelSrc.replace(/\.ts$/, ".examples.md"); + if (existsSync(sibling)) { + const examples = parseExamplesFile(sibling); + if (examples.length > 0) return examples; + } + + // 2. Check in every @webiny/* package's src/exports/.examples.md + for (const srcDir of Array.from(pkgMap.values())) { + const candidate = join(srcDir, "exports", relPath + ".examples.md"); + if (existsSync(candidate)) { + const examples = parseExamplesFile(candidate); + if (examples.length > 0) return examples; + } + } + + return undefined; +} + // --------------------------------------------------------------------------- // Main // --------------------------------------------------------------------------- @@ -2084,12 +2541,15 @@ async function main(): Promise { } } + const examples = findExamples(barrelSrc, relPath, pkgMap, project); + const doc: EntryPointDoc = { importPath: `webiny/${relPath}`, relPath, title: toTitle(relPath), description: toDescription(relPath), - symbols: mergeNamespaceSymbols(symbols) + symbols: mergeNamespaceSymbols(symbols), + ...(examples ? { examples } : {}) }; docs.push(doc);