# orchard-suite-oa-applications

OA Applications (modules) that runs on the suite framework.
Read more about how modules work here:
https://www.notion.so/Modules-support-7d610b897a6b42808fdd6a27531f5ffc

## Prerequisites

-   Follow this guide to get your environment set up to work with private packages.
    https://www.notion.so/Javascript-Package-Management-Setup-9553d5d491c94835aa787fdf0fc4838d
-   Install nodejs version manager (nvm). https://github.com/nvm-sh/nvm#installing-and-updating

## Setup

```bash
# use supported node version 24
nvm use

# init environment config
cp .env.shadow .env

# install dependencies
corepack enable pnpm # if you don't have corepack enabled

# install packages
pnpm install
```

## Running modules

By default running `pnpm start` will merge all routes for all modules and render the last module that called `initApplicationModule`.

To specify which module to load, we use the `MODULE` environment variable. This variable is mapped in the frontend.json file to the suite app configuration option `module`.
Internally suite-frontend will use that option to filter out routes not matching the module name.

For local development, authentication is handled using a dedicated dev Auth0 user via the Password Grant flow, which fetches a JWT programmatically to satisfy graphql-router’s authorization requirements.
Export DEV AWS credentials to access secrets

```shell
export AWS_ACCESS_KEY_ID=your-access-key-id
export AWS_SECRET_ACCESS_KEY=your-secret-access-key
export AWS_SESSION_TOKEN=your-session-token
```

## Available Scripts

### `pnpm test`
Run unit tests and formatting and lint. Run this before creating a PR.

### `pnpm test:unit`
Run only the unit test cases.

### `pnpm lint`
Run to check the lint issues for all files.

### `pnpm format:check`
Run to check the formatting issues for all files.

### `pnpm lint:fix`
Run to fix the lint issues for all files.

## Embedding modules in OA

Include your app in a OA php page by inserting the following:

```php
include_once('../includes/suite_oa_application.inc');

embedSuiteModule('release-scheduler', array(
    // add any module arguments you might need here
    // e.g
    'releaseId' => $release_id,
    'editMode' => false
));
```

**Note** that the suite module will render at the place you add the embedSuiteModule call.
