├── .editorconfig ├── .eslintrc.cjs ├── .gitignore ├── .prettierignore ├── .prettierrc.yaml ├── .semgrepignore ├── .vscode ├── extensions.json └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── THIRD-PARTY-NOTICES.txt ├── common ├── autoinstallers │ ├── commitzen │ │ └── package.json │ └── rush-prettier │ │ └── package.json ├── config │ └── rush │ │ ├── .npmrc │ │ ├── .npmrc-publish │ │ ├── .pnpmfile.cjs │ │ ├── artifactory.json │ │ ├── build-cache.json │ │ ├── command-line.json │ │ ├── common-versions.json │ │ ├── pnpm-config.json │ │ ├── pnpm-lock.yaml │ │ └── repo-state.json ├── git-hooks │ ├── commit-msg.sample │ └── pre-commit └── scripts │ ├── install-run-rush-pnpm.js │ ├── install-run-rush.js │ ├── install-run-rushx.js │ ├── install-run.js │ └── license-checker-monorepo.bash ├── docs ├── images │ ├── 1.list-growers.png │ ├── 2.list-farms.png │ ├── 3.list-fields.png │ ├── 4.view-analysis-ndvi.png │ ├── 5.view-analysis-histogram.png │ ├── agie-conceptual-architecture.drawio │ ├── agie-solution-overview.drawio │ ├── agie-solution-overview.png │ ├── regions-docs-hierarchy-cropseason.png │ ├── regions-docs-hierarchy-farm.png │ ├── regions-docs-hierarchy-field.png │ ├── regions-docs-hierarchy-group.png │ ├── regions-docs-hierarchy-grower.png │ ├── regions-docs-hierarchy-polygon.png │ ├── regions-docs-hierarchy-region.png │ ├── regions-docs-hierarchy-state.png │ └── regions-docs-hierarchy.png └── walkthrough.md ├── infrastructure ├── CHANGELOG.json ├── CHANGELOG.md ├── cdk.json ├── package.json ├── src │ ├── app.ts │ ├── engine │ │ ├── engine.construct.ts │ │ └── engine.stack.ts │ ├── executor │ │ ├── executor.construct.ts │ │ └── executor.stack.ts │ ├── index.ts │ ├── notifications │ │ ├── notifications.construct.ts │ │ └── notifications.stack.ts │ ├── predeploy.ts │ ├── regions │ │ ├── regions.construct.ts │ │ └── regions.stack.ts │ ├── regionsExtension │ │ ├── regionsExtension.construct.ts │ │ └── regionsExtension.stack.ts │ ├── results │ │ ├── results.construct.ts │ │ └── results.stack.ts │ ├── scheduler │ │ ├── scheduler.construct.ts │ │ └── scheduler.stack.ts │ ├── shared │ │ ├── cognito.construct.ts │ │ ├── customResources │ │ │ ├── cognito.CustomResource.ts │ │ │ └── verifiedPermissions.CustomResource.ts │ │ ├── network.construct.ts │ │ ├── shared.stack.ts │ │ ├── verifiedPermissions.construct.ts │ │ ├── verifiedPermissionsConfig │ │ │ ├── engines.admin.cedar │ │ │ ├── engines.contributor.cedar │ │ │ ├── engines.reader.cedar │ │ │ ├── executor.admin.cedar │ │ │ ├── executor.contributor.cedar │ │ │ ├── executor.reader.cedar │ │ │ ├── notifications.admin.cedar │ │ │ ├── notifications.contributor.cedar │ │ │ ├── notifications.reader.cedar │ │ │ ├── regions.admin.cedar │ │ │ ├── regions.contributor.cedar │ │ │ ├── regions.reader.cedar │ │ │ ├── results.admin.cedar │ │ │ ├── results.contributor.cedar │ │ │ ├── results.reader.cedar │ │ │ └── schema.json │ │ └── verifiedPermissionsIdentitySourceCreator.construct.ts │ ├── stacServer │ │ ├── lambdas │ │ │ └── customResource.ts │ │ ├── stacServer.construct.ts │ │ └── stacServer.stack.ts │ ├── ui │ │ ├── ui.construct.ts │ │ ├── ui.stack.ts │ │ └── ui.staticSite.construct.ts │ └── utils │ │ └── util.ts └── tsconfig.json ├── license.header.txt ├── package.json ├── python ├── apps │ ├── satellite-image-processor │ │ ├── Dockerfile │ │ ├── initial_process.py │ │ ├── logger_utils.py │ │ ├── processors │ │ │ ├── base_processors.py │ │ │ ├── cloud_gap_fill_processor.py │ │ │ ├── cloud_removal_processor.py │ │ │ ├── metadata_utils.py │ │ │ ├── ndvi_change_processor.py │ │ │ ├── ndvi_raw_processor.py │ │ │ ├── nitrogen_processor.py │ │ │ ├── tif_image_processor.py │ │ │ └── xarray_utils.py │ │ ├── requirements.txt │ │ └── stac_catalog_processor.py │ └── tiler │ │ └── lambda │ │ ├── Dockerfile │ │ ├── api │ │ ├── __init__.py │ │ ├── backend │ │ │ ├── __init__.py │ │ │ ├── agie_stac_backend.py │ │ │ └── agie_stac_reader.py │ │ ├── errors.py │ │ ├── main.py │ │ ├── routers │ │ │ ├── __init__.py │ │ │ ├── models.py │ │ │ └── stac.py │ │ └── settings.py │ │ ├── handler.py │ │ └── requirements.txt └── notebook │ ├── README.md │ ├── STAC.md │ ├── arcade.ipynb │ └── requirements.txt ├── rush.json ├── scripts └── clean.bash ├── typescript └── packages │ ├── apps │ ├── cli │ │ ├── .env │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── bin │ │ │ ├── dev.cmd │ │ │ ├── dev.js │ │ │ ├── run.cmd │ │ │ └── run.js │ │ ├── package.json │ │ ├── src │ │ │ ├── commands │ │ │ │ ├── auth.ts │ │ │ │ ├── build.ts │ │ │ │ ├── install.ts │ │ │ │ └── remove.ts │ │ │ ├── index.ts │ │ │ ├── types │ │ │ │ ├── agieCommand.ts │ │ │ │ └── deploymentCommand.ts │ │ │ └── utils │ │ │ │ ├── answers.ts │ │ │ │ ├── awsClient.ts │ │ │ │ ├── cloudformation.ts │ │ │ │ ├── help.ts │ │ │ │ ├── shell.ts │ │ │ │ └── ssm.ts │ │ └── tsconfig.json │ ├── engine │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── docs │ │ │ └── swagger.json │ │ ├── package.json │ │ ├── src │ │ │ ├── api │ │ │ │ ├── engines │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── examples.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── update.handler.ts │ │ │ │ └── registrations │ │ │ │ │ ├── examples.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ └── service.ts │ │ │ ├── app.light.ts │ │ │ ├── app.ts │ │ │ ├── common │ │ │ │ ├── errors.ts │ │ │ │ ├── pkUtils.ts │ │ │ │ └── schemas.ts │ │ │ ├── lambda_apiGateway.ts │ │ │ ├── lambda_authorizer.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ ├── localConfigGenerator.ts │ │ │ ├── plugins │ │ │ │ ├── config.ts │ │ │ │ ├── module.awilix.ts │ │ │ │ └── swagger.ts │ │ │ └── server.ts │ │ └── tsconfig.json │ ├── executor │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── docs │ │ │ ├── images │ │ │ │ ├── AGIE HLA-executor-conceptual.png │ │ │ │ ├── AGIE HLA-executor.png │ │ │ │ └── executor-docs.drawio │ │ │ └── swagger.json │ │ ├── package.json │ │ ├── src │ │ │ ├── app.light.ts │ │ │ ├── app.ts │ │ │ ├── common │ │ │ │ ├── errors.ts │ │ │ │ ├── pkUtils.ts │ │ │ │ └── schemas.ts │ │ │ ├── jobs │ │ │ │ ├── model.ts │ │ │ │ └── service.ts │ │ │ ├── lambda_apiGateway.ts │ │ │ ├── lambda_authorizer.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ ├── lambda_sqs.ts │ │ │ ├── localConfigGenerator.ts │ │ │ ├── plugins │ │ │ │ ├── config.ts │ │ │ │ ├── module.awilix.ts │ │ │ │ └── swagger.ts │ │ │ ├── server.ts │ │ │ ├── taskItems │ │ │ │ ├── example.ts │ │ │ │ ├── get.handler.ts │ │ │ │ ├── list.handler.ts │ │ │ │ ├── repository.ts │ │ │ │ ├── schemas.ts │ │ │ │ └── service.ts │ │ │ └── tasks │ │ │ │ ├── create.handler.ts │ │ │ │ ├── examples.ts │ │ │ │ ├── get.handler.ts │ │ │ │ ├── list.handler.ts │ │ │ │ ├── repository.ts │ │ │ │ ├── schemas.ts │ │ │ │ └── service.ts │ │ └── tsconfig.json │ ├── notifications │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── docs │ │ │ ├── images │ │ │ │ ├── AGIE HLA-notifications-conceptual.png │ │ │ │ ├── AGIE HLA-notifications.png │ │ │ │ └── noticiations-docs.drawio │ │ │ ├── notifications.insomnia.json │ │ │ ├── security.md │ │ │ └── swagger.json │ │ ├── package.json │ │ ├── src │ │ │ ├── api │ │ │ │ ├── notifications │ │ │ │ │ └── service.ts │ │ │ │ └── subscriptions │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── example.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ └── service.ts │ │ │ ├── app.light.ts │ │ │ ├── app.ts │ │ │ ├── common │ │ │ │ ├── errors.ts │ │ │ │ ├── pkUtils.ts │ │ │ │ ├── schemas.ts │ │ │ │ ├── snsUtil.ts │ │ │ │ └── types.ts │ │ │ ├── lambda_apiGateway.ts │ │ │ ├── lambda_authorizer.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ ├── localConfigGenerator.ts │ │ │ ├── plugins │ │ │ │ ├── config.ts │ │ │ │ ├── module.awilix.ts │ │ │ │ └── swagger.ts │ │ │ └── server.ts │ │ └── tsconfig.json │ ├── regions-extension │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── docs │ │ │ └── images │ │ │ │ ├── AGIE HLA-regions-extension-conceptual.png │ │ │ │ ├── AGIE HLA-regions-extension.png │ │ │ │ └── regions-extensions-docs.drawio │ │ ├── package.json │ │ ├── src │ │ │ ├── app.light.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ └── plugins │ │ │ │ └── module.awilix.ts │ │ └── tsconfig.json │ ├── regions │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── docs │ │ │ ├── DynamoDB design.md │ │ │ ├── images │ │ │ │ ├── AGIE HLA-regions-conceptual.png │ │ │ │ ├── AGIE HLA-regions.png │ │ │ │ └── regions-docs.drawio │ │ │ ├── security.md │ │ │ └── swagger.json │ │ ├── package.json │ │ ├── src │ │ │ ├── aggregator │ │ │ │ ├── service.spec.ts │ │ │ │ └── service.ts │ │ │ ├── api │ │ │ │ ├── groups │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── example.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── update.handler.ts │ │ │ │ ├── polygonTaskItems │ │ │ │ │ ├── examples.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ └── list.handler.ts │ │ │ │ ├── polygonTasks │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── examples.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── workflows │ │ │ │ │ │ └── processor.ts │ │ │ │ ├── polygons │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── example.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── update.handler.ts │ │ │ │ ├── regionTaskItems │ │ │ │ │ ├── examples.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ └── list.handler.ts │ │ │ │ ├── regionTasks │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── examples.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── workflows │ │ │ │ │ │ └── processor.ts │ │ │ │ ├── regions │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── example.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── update.handler.ts │ │ │ │ ├── repository.common.spec.ts │ │ │ │ ├── repository.common.ts │ │ │ │ ├── service.common.spec.ts │ │ │ │ ├── service.common.ts │ │ │ │ └── states │ │ │ │ │ ├── create.handler.ts │ │ │ │ │ ├── delete.handler.ts │ │ │ │ │ ├── example.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── update.handler.ts │ │ │ ├── app.light.ts │ │ │ ├── app.ts │ │ │ ├── common │ │ │ │ ├── cache.ts │ │ │ │ ├── ddbAttributes.util.ts │ │ │ │ ├── errors.ts │ │ │ │ ├── pkTypes.ts │ │ │ │ ├── schemas.ts │ │ │ │ ├── taskItems │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ └── service.ts │ │ │ │ ├── tasks │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ ├── service.ts │ │ │ │ │ └── workflows.interfaces.ts │ │ │ │ └── types.ts │ │ │ ├── index.ts │ │ │ ├── lambda_apiGateway.ts │ │ │ ├── lambda_authorizer.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ ├── lambda_sqs.ts │ │ │ ├── lambda_tasks_sqs.ts │ │ │ ├── localConfigGenerator.ts │ │ │ ├── plugins │ │ │ │ ├── config.ts │ │ │ │ ├── module.awilix.ts │ │ │ │ └── swagger.ts │ │ │ ├── server.ts │ │ │ └── tags │ │ │ │ └── tags.util.ts │ │ └── tsconfig.json │ ├── results │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── docs │ │ │ ├── images │ │ │ │ ├── AGIE HLA-results-conceptual.png │ │ │ │ ├── AGIE HLA-results.png │ │ │ │ └── results-docs.drawio │ │ │ └── swagger.json │ │ ├── package.json │ │ ├── src │ │ │ ├── api │ │ │ │ └── results │ │ │ │ │ ├── example.ts │ │ │ │ │ ├── get.handler.ts │ │ │ │ │ ├── list.handler.ts │ │ │ │ │ ├── repository.ts │ │ │ │ │ ├── schemas.ts │ │ │ │ │ └── service.ts │ │ │ ├── app.light.ts │ │ │ ├── app.ts │ │ │ ├── common │ │ │ │ ├── errors.ts │ │ │ │ ├── pkUtils.ts │ │ │ │ ├── schemas.ts │ │ │ │ └── types.ts │ │ │ ├── events │ │ │ │ ├── eventProcessor.ts │ │ │ │ └── models.ts │ │ │ ├── lambda_apiGateway.ts │ │ │ ├── lambda_authorizer.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ ├── localConfigGenerator.ts │ │ │ ├── plugins │ │ │ │ ├── config.ts │ │ │ │ ├── module.awilix.ts │ │ │ │ └── swagger.ts │ │ │ ├── server.ts │ │ │ └── utils │ │ │ │ ├── defaultStacRecords.ts │ │ │ │ ├── stacUtil.spec.ts │ │ │ │ └── stacUtil.ts │ │ └── tsconfig.json │ ├── scheduler │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── docs │ │ │ └── images │ │ │ │ ├── AGIE HLA-scheduler-conceptual.png │ │ │ │ ├── AGIE HLA-scheduler.png │ │ │ │ └── scheduler-docs.drawio │ │ ├── package.json │ │ ├── src │ │ │ ├── app.light.ts │ │ │ ├── common │ │ │ │ ├── ddbAttributes.util.ts │ │ │ │ └── pkUtils.ts │ │ │ ├── jobs │ │ │ │ ├── model.ts │ │ │ │ ├── repository.ts │ │ │ │ ├── service.spec.ts │ │ │ │ └── service.ts │ │ │ ├── lambda_eventbridge.ts │ │ │ ├── lambda_eventbridge_scheduler.ts │ │ │ ├── lambda_sqs.ts │ │ │ ├── localConfigGenerator.ts │ │ │ ├── plugins │ │ │ │ └── module.awilix.ts │ │ │ └── schedules │ │ │ │ ├── model.ts │ │ │ │ └── service.ts │ │ └── tsconfig.json │ └── ui │ │ ├── .env.sample │ │ ├── .eslintrc.cjs │ │ ├── .gitignore │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── collections │ │ └── Arcade.json │ │ ├── docs │ │ └── images │ │ │ ├── AGIE HLA-ui-conceptual.png │ │ │ ├── AGIE HLA-ui.png │ │ │ └── ui-docs.drawio │ │ ├── index.html │ │ ├── package.json │ │ ├── public │ │ ├── aws-logo-rgb-rev.svg │ │ ├── aws-logo-rgb.svg │ │ └── logo-white.svg │ │ ├── src │ │ ├── App.tsx │ │ ├── app │ │ │ ├── hooks.ts │ │ │ └── store.ts │ │ ├── hooks │ │ │ ├── useMapAuth.ts │ │ │ ├── useMapBoundingBox.ts │ │ │ └── usePagination.ts │ │ ├── index.css │ │ ├── localConfigGenerator.ts │ │ ├── main.tsx │ │ ├── pages │ │ │ ├── Analysis │ │ │ │ ├── Analysis.css │ │ │ │ ├── Analysis.tsx │ │ │ │ ├── CloudscapeMap.tsx │ │ │ │ ├── ControlPanel.tsx │ │ │ │ ├── FeaturePopup.tsx │ │ │ │ └── Histogram.tsx │ │ │ ├── Crops │ │ │ │ ├── CreateCropModal.tsx │ │ │ │ ├── CropsTable.tsx │ │ │ │ └── EditCropModal.tsx │ │ │ ├── Farms │ │ │ │ ├── CreateFarm.tsx │ │ │ │ ├── DeleteFarmModal.tsx │ │ │ │ ├── EditFarm.tsx │ │ │ │ ├── FarmsTable.tsx │ │ │ │ ├── ListFarms.tsx │ │ │ │ ├── ProcessingStatus.tsx │ │ │ │ └── ViewFarm.tsx │ │ │ ├── Fields │ │ │ │ ├── CreateField.tsx │ │ │ │ ├── DeleteFieldModal.tsx │ │ │ │ ├── FieldsTable.tsx │ │ │ │ ├── ListFields.tsx │ │ │ │ └── ViewField.tsx │ │ │ └── Growers │ │ │ │ ├── CreateGrower.tsx │ │ │ │ ├── DeleteGrowerModal.tsx │ │ │ │ ├── EditGrower.tsx │ │ │ │ ├── ListGrowers.tsx │ │ │ │ └── ViewGrower.tsx │ │ ├── shared │ │ │ ├── Breadcrumbs.tsx │ │ │ ├── Shell.tsx │ │ │ ├── SideNavigation.tsx │ │ │ └── TopNavigation.tsx │ │ ├── slices │ │ │ ├── analysisSlice.ts │ │ │ ├── regionsApiSlice.ts │ │ │ └── tilerApiSlice.ts │ │ └── vite-env.d.ts │ │ ├── tsconfig.json │ │ ├── tsconfig.node.json │ │ ├── upload-to-s3.bash │ │ └── vite.config.ts │ ├── integration-tests │ ├── CHANGELOG.json │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── engine │ │ │ ├── engine-api.spec.ts │ │ │ └── engine.data.ts │ │ ├── executor │ │ │ ├── executor-api.spec.ts │ │ │ └── executor.data.ts │ │ ├── localConfigGenerator.ts │ │ ├── notifications │ │ │ ├── notifications-api.spec.ts │ │ │ └── notifications.data.ts │ │ ├── regions │ │ │ ├── groups-api.spec.ts │ │ │ ├── groups.data.ts │ │ │ ├── polygonTasks-api.spec.ts │ │ │ ├── polygonTasks.data.ts │ │ │ ├── polygons-api.spec.ts │ │ │ ├── polygons.data.ts │ │ │ ├── regionTasks-api.spec.ts │ │ │ ├── regionTasks.data.ts │ │ │ ├── regions-api.spec.ts │ │ │ ├── regions.data.ts │ │ │ ├── states-api.spec.ts │ │ │ └── states.data.ts │ │ ├── scheduler │ │ │ ├── scheduler-api.spec.ts │ │ │ └── scheduler.data.ts │ │ └── utils │ │ │ ├── auth.ts │ │ │ ├── common.utils.ts │ │ │ ├── config.ts │ │ │ ├── generateToken.ts │ │ │ ├── headers.ts │ │ │ ├── regex.ts │ │ │ └── ssm.ts │ ├── tsconfig.json │ └── vitest.config.ts │ ├── libraries │ ├── cdk-common │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── esbuild.ts │ │ ├── package.json │ │ ├── src │ │ │ ├── context │ │ │ │ └── util.ts │ │ │ ├── dynamodb-seeder │ │ │ │ ├── dynamodb-seeder.ts │ │ │ │ ├── lambdas │ │ │ │ │ └── index.ts │ │ │ │ └── seeds.ts │ │ │ ├── environment │ │ │ │ └── util.ts │ │ │ ├── eventBridge │ │ │ │ └── eventbus.construct.ts │ │ │ ├── facts │ │ │ │ ├── fact-tables.ts │ │ │ │ ├── facts.utils.ts │ │ │ │ └── lambdaArchitecture.ts │ │ │ ├── index.ts │ │ │ └── s3 │ │ │ │ └── s3.construct.ts │ │ └── tsconfig.json │ ├── clients │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── package.json │ │ ├── src │ │ │ ├── clients │ │ │ │ ├── engines.client.ts │ │ │ │ ├── engines.models.ts │ │ │ │ ├── regions.client.ts │ │ │ │ ├── regions.models.ts │ │ │ │ ├── results.client.ts │ │ │ │ ├── results.models.ts │ │ │ │ ├── stacServer.client.ts │ │ │ │ └── stacServer.model.ts │ │ │ ├── common │ │ │ │ ├── common.ts │ │ │ │ └── models.ts │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── dynamodb-utils │ │ ├── package.json │ │ ├── src │ │ │ ├── dynamoDb.util.ts │ │ │ ├── index.ts │ │ │ └── pkUtils.util.ts │ │ └── tsconfig.json │ ├── events │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── package.json │ │ ├── src │ │ │ ├── common │ │ │ │ └── models.ts │ │ │ ├── index.ts │ │ │ ├── publisher.ts │ │ │ ├── regions │ │ │ │ └── models.ts │ │ │ └── results │ │ │ │ └── models.ts │ │ └── tsconfig.json │ ├── helpers │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── esbuild.ts │ │ ├── package.json │ │ ├── src │ │ │ ├── auth.ts │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── lambda-invoker │ │ ├── package.json │ │ ├── src │ │ │ ├── index.ts │ │ │ ├── invoker.ts │ │ │ └── models.ts │ │ └── tsconfig.json │ ├── resource-api-base │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ ├── common │ │ │ │ ├── errors.ts │ │ │ │ ├── models.ts │ │ │ │ ├── schemas.ts │ │ │ │ ├── types.ts │ │ │ │ └── utils.ts │ │ │ ├── index.ts │ │ │ ├── plugins │ │ │ │ ├── base.awilix.ts │ │ │ │ └── base.config.ts │ │ │ └── resources │ │ │ │ └── models.ts │ │ └── tsconfig.json │ └── rest-api-authorizer │ │ ├── CHANGELOG.json │ │ ├── CHANGELOG.md │ │ ├── package.json │ │ ├── src │ │ ├── apiAuthorizer.service.spec.ts │ │ ├── apiAuthorizer.service.ts │ │ ├── index.ts │ │ └── plugins │ │ │ ├── authz.ts │ │ │ ├── rest-api-auth.awilix.ts │ │ │ └── scopes.ts │ │ └── tsconfig.json │ └── seeder │ ├── CHANGELOG.json │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ ├── auth.ts │ └── seedData.ts │ └── tsconfig.json └── vitest.workspace.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = tab 8 | insert_final_newline = true 9 | max_line_length = 180 10 | trim_trailing_whitespace = true 11 | 12 | [{*.yml,*.yaml}] 13 | indent_style = space 14 | indent_size = 2 15 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | // This is a workaround for https://github.com/eslint/eslint/issues/3458 15 | require('@rushstack/eslint-config/patch/modern-module-resolution'); 16 | 17 | module.exports = { 18 | extends: ['@rushstack/eslint-config/profile/node', '@rushstack/eslint-config/mixins/tsdoc'], 19 | parserOptions: { tsconfigRootDir: __dirname }, 20 | rules: { 21 | 'no-unused-vars': 'off', 22 | '@typescript-eslint/no-unused-vars': [ 23 | 'warn', 24 | { 25 | argsIgnorePattern: '^_', 26 | varsIgnorePattern: '^_', 27 | caughtErrorsIgnorePattern: '^_', 28 | }, 29 | ], 30 | '@typescript-eslint/naming-convention': [ 31 | 'error', 32 | { 33 | selector: ['variable', 'function'], 34 | format: ['camelCase'], 35 | leadingUnderscore: 'allow', 36 | }, 37 | ], 38 | }, 39 | }; 40 | -------------------------------------------------------------------------------- /.prettierrc.yaml: -------------------------------------------------------------------------------- 1 | # parse .editorconfig 2 | editorconfig: true 3 | 4 | # apply what cannot be set in .editorconfig 5 | semi: true 6 | singleQuote: true 7 | -------------------------------------------------------------------------------- /.semgrepignore: -------------------------------------------------------------------------------- 1 | 2 | # Items added to this file will be ignored by Semgrep. 3 | # 4 | # This file uses .gitignore syntax: 5 | # 6 | # Some parts of .gitignore syntax are not supported, and patterns 7 | # using this syntax will be dropped from the ignore list: 8 | # - Explicit "include syntax", e.g. "!kept/". 9 | # - Multi-character expansion syntax, e.g. "*.py[cod]" 10 | # 11 | # To include ignore patterns from another file, start a line 12 | # with ':include', followed by the path of the file. E.g. 13 | # ":include path/to/other/ignore/file". 14 | # 15 | # To ignore a file with a literal ':' character, escape it with 16 | # a backslash, e.g. "\:foo". 17 | 18 | :include .gitignore 19 | 20 | ./common/scripts/* 21 | 22 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "jbockle.jbockle-format-files", 4 | "dbaeumer.vscode-eslint", 5 | "donjayamanne.git-extension-pack", 6 | "blackmist.linkcheckmd", 7 | "yzhang.markdown-all-in-one", 8 | "shd101wyy.markdown-preview-enhanced", 9 | "darkriszty.markdown-table-prettify", 10 | "davidanson.vscode-markdownlint", 11 | "leizongmin.node-module-intellisense", 12 | "christian-kohler.npm-intellisense", 13 | "42crunch.vscode-openapi", 14 | "esbenp.prettier-vscode", 15 | "mohsen1.prettify-json", 16 | "ms-python.vscode-pylance", 17 | "ms-python.python", 18 | "ms-python.debugpy", 19 | "kevinrose.vsc-python-indent", 20 | "wayou.vscode-todo-highlight", 21 | "gruntfuggly.todo-tree", 22 | "mike-co.import-sorter", 23 | "pmneo.tsimporter", 24 | "vitest.explorer", 25 | "kingwl.vscode-vitest-runner", 26 | "cedar-policy.vscode-cedar" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "editor.codeActionsOnSave": [ 4 | "source.organizeImports", 5 | "source.fixAll" 6 | ], 7 | "editor.defaultFormatter": "esbenp.prettier-vscode", 8 | // "vitest.rootConfig": "./vitest.config.ts", 9 | "vitest.vitestPackagePath": "./common/temp/node_modules/.pnpm/vitest@1.5.2_@types+node@20.12.7_@vitest+ui@1.5.2/node_modules/vitest/package.json", 10 | "vitest.workspaceConfig": "./vitest.workspace.ts", 11 | "formatFiles.excludedFolders": [ 12 | "node_modules", 13 | ".vscode", 14 | ".git", 15 | "dist", 16 | ".chrome", 17 | ".rush", 18 | ".history", 19 | "common/temp", 20 | "cdk.out", 21 | "lib" 22 | ], 23 | "formatFiles.runOrganizeImports": true, 24 | "formatFiles.excludePattern": "*.log,*.tsbuildinfo", 25 | "[shellscript]": { 26 | "editor.defaultFormatter": "foxundermoon.shell-format" 27 | }, 28 | 29 | "files.exclude": { 30 | "**/*.js": true, 31 | "**/*.map": true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | -------------------------------------------------------------------------------- /common/autoinstallers/commitzen/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "commitzen", 3 | "version": "0.0.1", 4 | "private": true, 5 | "dependencies": { 6 | "cz-customizable": "7.0.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /common/autoinstallers/rush-prettier/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rush-prettier", 3 | "version": "0.0.1", 4 | "private": true, 5 | "dependencies": { 6 | "prettier": "^3.0.0", 7 | "pretty-quick": "^3.1.3" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/config/rush/.npmrc: -------------------------------------------------------------------------------- 1 | # Rush uses this file to configure the NPM package registry during installation. It is applicable 2 | # to PNPM, NPM, and Yarn package managers. It is used by operations such as "rush install", 3 | # "rush update", and the "install-run.js" scripts. 4 | # 5 | # NOTE: The "rush publish" command uses .npmrc-publish instead. 6 | # 7 | # Before invoking the package manager, Rush will copy this file to the folder where installation 8 | # is performed. The copied file will omit any config lines that reference environment variables 9 | # that are undefined in that session; this avoids problems that would otherwise result due to 10 | # a missing variable being replaced by an empty string. 11 | # 12 | # * * * SECURITY WARNING * * * 13 | # 14 | # It is NOT recommended to store authentication tokens in a text file on a lab machine, because 15 | # other unrelated processes may be able to read the file. Also, the file may persist indefinitely, 16 | # for example if the machine loses power. A safer practice is to pass the token via an 17 | # environment variable, which can be referenced from .npmrc using ${} expansion. For example: 18 | # 19 | # //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN} // nosemgrep 20 | # 21 | registry=https://registry.npmjs.org/ 22 | always-auth=false 23 | -------------------------------------------------------------------------------- /common/config/rush/.npmrc-publish: -------------------------------------------------------------------------------- 1 | # This config file is very similar to common/config/rush/.npmrc, except that .npmrc-publish 2 | # is used by the "rush publish" command, as publishing often involves different credentials 3 | # and registries than other operations. 4 | # 5 | # Before invoking the package manager, Rush will copy this file to "common/temp/publish-home/.npmrc" 6 | # and then temporarily map that folder as the "home directory" for the current user account. 7 | # This enables the same settings to apply for each project folder that gets published. The copied file 8 | # will omit any config lines that reference environment variables that are undefined in that session; 9 | # this avoids problems that would otherwise result due to a missing variable being replaced by 10 | # an empty string. 11 | # 12 | # * * * SECURITY WARNING * * * 13 | # 14 | # It is NOT recommended to store authentication tokens in a text file on a lab machine, because 15 | # other unrelated processes may be able to read the file. Also, the file may persist indefinitely, 16 | # for example if the machine loses power. A safer practice is to pass the token via an 17 | # environment variable, which can be referenced from .npmrc using ${} expansion. For example: 18 | # 19 | # //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN} // nosemgrep 20 | # 21 | -------------------------------------------------------------------------------- /common/config/rush/repo-state.json: -------------------------------------------------------------------------------- 1 | // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. 2 | { 3 | "preferredVersionsHash": "5942ea7003daf4986cd20d4816fe9be6b39c3670" 4 | } 5 | -------------------------------------------------------------------------------- /common/git-hooks/commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is an example Git hook for use with Rush. To enable this hook, rename this file 4 | # to "commit-msg" and then run "rush install", which will copy it from common/git-hooks 5 | # to the .git/hooks folder. 6 | # 7 | # TO LEARN MORE ABOUT GIT HOOKS 8 | # 9 | # The Git documentation is here: https://git-scm.com/docs/githooks 10 | # Some helpful resources: https://githooks.com 11 | # 12 | # ABOUT THIS EXAMPLE 13 | # 14 | # The commit-msg hook is called by "git commit" with one argument, the name of the file 15 | # that has the commit message. The hook should exit with non-zero status after issuing 16 | # an appropriate message if it wants to stop the commit. The hook is allowed to edit 17 | # the commit message file. 18 | 19 | # This example enforces that commit message should contain a minimum amount of 20 | # description text. 21 | if [ `cat $1 | wc -w` -lt 3 ]; then 22 | echo "" 23 | echo "Invalid commit message: The message must contain at least 3 words." 24 | exit 1 25 | fi 26 | -------------------------------------------------------------------------------- /common/git-hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Called by "git commit" with no arguments. The hook should 3 | # exit with non-zero status after issuing an appropriate message if 4 | # it wants to stop the commit. 5 | 6 | # Invoke the "rush prettier" custom command to reformat files whenever they 7 | # are committed. The command is defined in common/config/rush/command-line.json 8 | # and uses the "rush-prettier" autoinstaller. 9 | node common/scripts/install-run-rush.js prettier || exit $? 10 | -------------------------------------------------------------------------------- /common/scripts/install-run-rushx.js: -------------------------------------------------------------------------------- 1 | // THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED. 2 | // 3 | // This script is intended for usage in an automated build environment where the Rush command may not have 4 | // been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush 5 | // specified in the rush.json configuration file (if not already installed), and then pass a command-line to the 6 | // rushx command. 7 | // 8 | // An example usage would be: 9 | // 10 | // node common/scripts/install-run-rushx.js custom-command 11 | // 12 | // For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ 13 | // 14 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. 15 | // See the @microsoft/rush package's LICENSE file for details. 16 | 17 | /******/ (() => { // webpackBootstrap 18 | /******/ "use strict"; 19 | var __webpack_exports__ = {}; 20 | /*!*************************************************!*\ 21 | !*** ./lib-esnext/scripts/install-run-rushx.js ***! 22 | \*************************************************/ 23 | 24 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. 25 | // See LICENSE in the project root for license information. 26 | require('./install-run-rush'); 27 | //# sourceMappingURL=install-run-rushx.js.map 28 | module.exports = __webpack_exports__; 29 | /******/ })() 30 | ; 31 | //# sourceMappingURL=install-run-rushx.js.map -------------------------------------------------------------------------------- /common/scripts/license-checker-monorepo.bash: -------------------------------------------------------------------------------- 1 | RESULT_FOLDER=./license-checker 2 | 3 | rm -rf "${RESULT_FOLDER}" 4 | mkdir -p "${RESULT_FOLDER}" 5 | root=$PWD 6 | 7 | find . -name package.json -not -path "*node_modules*" -not -path "*components*" > "${RESULT_FOLDER}"/license-checker.txt 8 | 9 | grep -v '^ *#' < "${RESULT_FOLDER}"/license-checker.txt | while IFS= read -r line 10 | do 11 | fullPath=${line#*./} 12 | dirPath=${fullPath%package.json*} 13 | service=$(basename "$dirPath") 14 | if [ -z "$service" ]; then 15 | service="main" 16 | fi 17 | echo "$service" 18 | cd "$root"/"$dirPath" && license-checker --csv --out "$root"/license-checker/"$service".csv 19 | done 20 | 21 | rm "$root"/license-checker/license-checker.txt 22 | 23 | pushd "${RESULT_FOLDER}" 24 | 25 | cat $(ls -t ) > largefile.csv 26 | 27 | sort largefile.csv | sort | uniq -d 28 | 29 | popd 30 | -------------------------------------------------------------------------------- /docs/images/1.list-growers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/1.list-growers.png -------------------------------------------------------------------------------- /docs/images/2.list-farms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/2.list-farms.png -------------------------------------------------------------------------------- /docs/images/3.list-fields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/3.list-fields.png -------------------------------------------------------------------------------- /docs/images/4.view-analysis-ndvi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/4.view-analysis-ndvi.png -------------------------------------------------------------------------------- /docs/images/5.view-analysis-histogram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/5.view-analysis-histogram.png -------------------------------------------------------------------------------- /docs/images/agie-solution-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/agie-solution-overview.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-cropseason.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-cropseason.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-farm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-farm.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-field.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-group.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-grower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-grower.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-polygon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-polygon.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-region.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-region.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy-state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy-state.png -------------------------------------------------------------------------------- /docs/images/regions-docs-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/docs/images/regions-docs-hierarchy.png -------------------------------------------------------------------------------- /infrastructure/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/infrastructure 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.2.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Added new Engine API and related infrastructure components 11 | - Updated Regions API to integrate with new Engine API 12 | - Added new permissions for Engine API in Verified Permissions 13 | - Updated Executor to use new Engine API 14 | 15 | ## 0.1.0 16 | Thu, 31 Oct 2024 05:15:58 GMT 17 | 18 | ### Minor changes 19 | 20 | - Added new ExecutorStack and ExecutorModule with associated constructs and configurations 21 | - Removed ExecutorModule from SchedulerStack and moved it to its own stack 22 | - Added new API methods and permissions for Executor in Verified Permissions 23 | - Updated SchedulerModule to expose table and engineQueue 24 | - Added new SSM parameters for Executor and Scheduler configurations 25 | 26 | -------------------------------------------------------------------------------- /infrastructure/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx tsx src/app.ts", 3 | "watch": { 4 | "include": ["**"], 5 | "exclude": ["README.md", "cdk*.json", "**/*.d.ts", "**/*.js", "tsconfig.json", "package*.json", "yarn.lock", "node_modules", "test", ".history"] 6 | }, 7 | "context": { 8 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, 9 | "@aws-cdk/core:stackRelativeExports": true, 10 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true, 11 | "@aws-cdk/aws-lambda:recognizeVersionProps": true, 12 | "@aws-cdk/aws-lambda:recognizeLayerVersion": true, 13 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, 14 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, 15 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, 16 | "@aws-cdk/core:checkSecretUsage": true, 17 | "@aws-cdk/aws-iam:minimizePolicies": true, 18 | "@aws-cdk/core:validateSnapshotRemovalPolicy": true, 19 | "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, 20 | "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, 21 | "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, 22 | "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, 23 | "@aws-cdk/core:target-partitions": ["aws", "aws-cn"] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /infrastructure/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export { userPoolIdParameter, userPoolClientIdParameter, userPoolDomainParameter } from './shared/cognito.construct.js'; 15 | -------------------------------------------------------------------------------- /infrastructure/src/predeploy.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { getAwsEnvironment } from '@agie/cdk-common'; 15 | import * as fs from 'fs'; 16 | import path from 'path'; 17 | import { fileURLToPath } from 'url'; 18 | 19 | const __filename = fileURLToPath(import.meta.url); 20 | const __dirname = path.dirname(__filename); 21 | 22 | // Caller environment 23 | const callerEnvironment = await getAwsEnvironment(); 24 | 25 | fs.writeFileSync(`${__dirname}/predeploy.json`, JSON.stringify({ callerEnvironment })); 26 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/engines.admin.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListRegistrations", 5 | Agie::Action::"CreateEngine", 6 | Agie::Action::"UpdateEngine", 7 | Agie::Action::"DescribeEngine", 8 | Agie::Action::"ListEngines", 9 | Agie::Action::"DeleteEngine" 10 | ], 11 | resource 12 | ) 13 | when { 14 | principal.custom.role == "admin" 15 | }; 16 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/engines.contributor.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListRegistrations", 5 | Agie::Action::"CreateEngine", 6 | Agie::Action::"UpdateEngine", 7 | Agie::Action::"DescribeEngine", 8 | Agie::Action::"ListEngines" 9 | ], 10 | resource 11 | ) 12 | when { 13 | principal.custom.role == "contributor" 14 | }; 15 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/engines.reader.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListRegistrations", 5 | Agie::Action::"DescribeEngine", 6 | Agie::Action::"ListEngines" 7 | ], 8 | resource 9 | ) 10 | when { 11 | principal.custom.role == "reader" 12 | }; 13 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/executor.admin.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"CreateExecutionTask", 5 | Agie::Action::"DescribeExecutionTask", 6 | Agie::Action::"ListExecutionTasks", 7 | 8 | Agie::Action::"DescribeExecutionTaskItem", 9 | Agie::Action::"ListExecutionTaskItems" 10 | ], 11 | resource 12 | ) 13 | when { 14 | principal.custom.role == "admin" 15 | }; 16 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/executor.contributor.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"CreateExecutionTask", 5 | Agie::Action::"DescribeExecutionTask", 6 | Agie::Action::"ListExecutionTasks", 7 | 8 | Agie::Action::"DescribeExecutionTaskItem", 9 | Agie::Action::"ListExecutionTaskItems" 10 | ], 11 | resource 12 | ) 13 | when { 14 | principal.custom.role == "contributor" 15 | }; 16 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/executor.reader.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"DescribeExecutionTask", 5 | Agie::Action::"ListExecutionTasks", 6 | 7 | Agie::Action::"DescribeExecutionTaskItem", 8 | Agie::Action::"ListExecutionTaskItems" 9 | ], 10 | resource 11 | ) 12 | when { 13 | principal.custom.role == "reader" 14 | }; 15 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/notifications.admin.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"CreateSubscription", 5 | Agie::Action::"ListSubscriptions", 6 | Agie::Action::"DescribeSubscription", 7 | Agie::Action::"DeleteSubscription" 8 | ], 9 | resource 10 | ) 11 | when { 12 | principal.custom.role == "admin" 13 | }; 14 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/notifications.contributor.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"CreateSubscription", 5 | Agie::Action::"ListSubscriptions", 6 | Agie::Action::"DescribeSubscription", 7 | Agie::Action::"DeleteSubscription" 8 | ], 9 | resource 10 | ) 11 | when { 12 | principal.custom.role == "contributor" 13 | }; 14 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/notifications.reader.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"CreateSubscription", 5 | Agie::Action::"ListSubscriptions", 6 | Agie::Action::"DescribeSubscription", 7 | Agie::Action::"DeleteSubscription" 8 | ], 9 | resource 10 | ) 11 | when { 12 | principal.custom.role == "reader" 13 | }; 14 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/regions.contributor.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"CreateGroup", 5 | Agie::Action::"ListGroups", 6 | Agie::Action::"DescribeGroup", 7 | Agie::Action::"UpdateGroup", 8 | 9 | Agie::Action::"CreateRegion", 10 | Agie::Action::"ListRegions", 11 | Agie::Action::"DescribeRegion", 12 | Agie::Action::"UpdateRegion", 13 | 14 | Agie::Action::"CreatePolygon", 15 | Agie::Action::"ListPolygons", 16 | Agie::Action::"DescribePolygon", 17 | Agie::Action::"UpdatePolygon", 18 | 19 | Agie::Action::"CreateState", 20 | Agie::Action::"ListStates", 21 | Agie::Action::"DescribeState", 22 | Agie::Action::"UpdateState", 23 | 24 | Agie::Action::"ListRegionTasks", 25 | Agie::Action::"DescribeRegionTask", 26 | Agie::Action::"CreateRegionTask", 27 | Agie::Action::"ListRegionTaskItems", 28 | Agie::Action::"DescribeRegionTaskItem", 29 | 30 | Agie::Action::"ListPolygonTasks", 31 | Agie::Action::"DescribePolygonTask", 32 | Agie::Action::"CreatePolygonTask", 33 | Agie::Action::"ListPolygonTaskItems", 34 | Agie::Action::"DescribePolygonTaskItem" 35 | ], 36 | resource 37 | ) 38 | when { 39 | principal.custom.role == "contributor" 40 | }; 41 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/regions.reader.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListGroups", 5 | Agie::Action::"DescribeGroup", 6 | 7 | Agie::Action::"ListRegions", 8 | Agie::Action::"DescribeRegion", 9 | 10 | Agie::Action::"ListPolygons", 11 | Agie::Action::"DescribePolygon", 12 | 13 | Agie::Action::"ListStates", 14 | Agie::Action::"DescribeState", 15 | 16 | Agie::Action::"ListRegionTasks", 17 | Agie::Action::"DescribeRegionTask", 18 | Agie::Action::"ListRegionTaskItems", 19 | Agie::Action::"DescribeRegionTaskItem", 20 | 21 | Agie::Action::"ListPolygonTasks", 22 | Agie::Action::"DescribePolygonTask", 23 | Agie::Action::"ListPolygonTaskItems", 24 | Agie::Action::"DescribePolygonTaskItem" 25 | ], 26 | resource 27 | ) 28 | when { 29 | principal.custom.role == "reader" 30 | }; 31 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/results.admin.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListResults", 5 | Agie::Action::"DescribeResult" 6 | ], 7 | resource 8 | ) 9 | when { 10 | principal.custom.role == "admin" 11 | }; 12 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/results.contributor.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListResults", 5 | Agie::Action::"DescribeResult" 6 | ], 7 | resource 8 | ) 9 | when { 10 | principal.custom.role == "contributor" 11 | }; 12 | -------------------------------------------------------------------------------- /infrastructure/src/shared/verifiedPermissionsConfig/results.reader.cedar: -------------------------------------------------------------------------------- 1 | permit ( 2 | principal, 3 | action in [ 4 | Agie::Action::"ListResults", 5 | Agie::Action::"DescribeResult" 6 | ], 7 | resource 8 | ) 9 | when { 10 | principal.custom.role == "reader" 11 | }; 12 | -------------------------------------------------------------------------------- /infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | // overrides of extends 13 | "strict": false, 14 | "exactOptionalPropertyTypes": false 15 | }, 16 | "include": ["src/**/*.ts"], 17 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 18 | } 19 | -------------------------------------------------------------------------------- /license.header.txt: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------------------------------------------------- 2 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | # with the License. A copy of the License is located at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | # and limitations under the License. 12 | #----------------------------------------------------------------------------------------------------------------------- 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie", 3 | "version": "0.0.1", 4 | "description": "", 5 | "author": "Dean Hart ", 6 | "scripts": {}, 7 | "engines": { 8 | "node": ">=20.11.1 < 21", 9 | "pnpm": "=9.0.2" 10 | }, 11 | "private": true, 12 | "devDependencies": {}, 13 | "husky": { 14 | "hooks": { 15 | "pre-commit": "rush lint", 16 | "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true", 17 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use the official Python 3.11 image as the base image 2 | #checkov:skip=CKV_DOCKER_2:This is a backend application 3 | #checkov:skip=CKV_DOCKER_3:This is not required 4 | FROM --platform=linux/amd64 python:3.11.9-alpine 5 | 6 | # Set the working directory 7 | WORKDIR /app 8 | 9 | # Install system dependencies for GDAL 10 | RUN apk add --no-cache gcc 11 | RUN apk add --no-cache gdal 12 | RUN apk add --no-cache gdal-dev 13 | RUN apk add --no-cache build-base 14 | RUN apk add --no-cache zlib 15 | RUN apk add --no-cache proj 16 | RUN apk add --no-cache geos-dev 17 | RUN apk add --no-cache proj-util 18 | RUN apk add --no-cache proj-dev 19 | RUN apk add --no-cache linux-headers 20 | RUN apk add --no-cache bash 21 | 22 | 23 | RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal 24 | RUN export C_INCLUDE_PATH=/usr/include/gdal 25 | RUN export LDFLAGS="-L/usr/local/opt/zlib/lib" 26 | RUN export CPPFLAGS="-I/usr/local/opt/zlib/include" 27 | 28 | # Install Python dependencies 29 | COPY requirements.txt . 30 | RUN pip install --no-cache-dir -r requirements.txt 31 | 32 | # Copy the application code 33 | COPY . . 34 | 35 | # Set the entrypoint 36 | CMD ["python", "initial_process.py"] 37 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/logger_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | import logging 13 | from typing import Optional 14 | 15 | 16 | def get_logger(name: Optional[str] = None) -> logging.Logger: 17 | """ 18 | Returns a logger, with a preconfigured log level. 19 | Use this to get a logger for all log statements in this code 20 | package. 21 | """ 22 | logger = logging.getLogger(name) 23 | logging.basicConfig( 24 | level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s: %(message)s" 25 | ) 26 | return logger 27 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/processors/cloud_gap_fill_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | from processors.base_processors import AbstractProcessor 13 | from processors.xarray_utils import XarrayUtils 14 | from xarray import Dataset 15 | 16 | 17 | class CloudGapFillProcessor(AbstractProcessor): 18 | 19 | def process(self, stac_assets: Dataset) -> Dataset: 20 | if stac_assets.get('ndvi_raw') is None or stac_assets.get('scl_surface') is None: 21 | raise ValueError('ndvi_raw or scl_removed values is missing from Dataset') 22 | 23 | stac_assets["ndvi"] = XarrayUtils.fill_cloud_gap(stac_assets["scl_surface"], stac_assets['ndvi_raw'], self.previous_tif_raster) 24 | return super().process(stac_assets) 25 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/processors/cloud_removal_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | from processors.base_processors import AbstractProcessor 13 | from processors.xarray_utils import XarrayUtils 14 | from xarray import Dataset 15 | 16 | 17 | class CloudRemovalProcessor(AbstractProcessor): 18 | 19 | def process(self, stac_assets: Dataset) -> Dataset: 20 | if stac_assets.get('scl') is None: 21 | raise ValueError('scl value is missing from Dataset') 22 | 23 | stac_assets['scl_surface'] = XarrayUtils.remove_cloud(stac_assets[['scl']]) 24 | return super().process(stac_assets) 25 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/processors/ndvi_change_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | from xarray import Dataset 13 | 14 | from processors.base_processors import AbstractProcessor 15 | from processors.xarray_utils import XarrayUtils 16 | 17 | 18 | class NdviChangeProcessor(AbstractProcessor): 19 | 20 | def process(self, stac_assets: Dataset) -> Dataset: 21 | if stac_assets.get('ndvi') is None: 22 | raise ValueError('Dataset must have ndvi attribute') 23 | 24 | print(self.previous_tif_raster) 25 | 26 | if self.previous_tif_raster is not None: 27 | stac_assets['ndvi_change'] = XarrayUtils.calculate_ndvi_change(stac_assets['ndvi'], self.previous_tif_raster) 28 | 29 | return super().process(stac_assets) 30 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/processors/ndvi_raw_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | from typing import Dict 13 | 14 | from xarray import Dataset 15 | 16 | from processors.base_processors import AbstractProcessor 17 | from processors.xarray_utils import XarrayUtils 18 | 19 | 20 | class NdviRawProcessor(AbstractProcessor): 21 | def process(self, stac_assets: Dataset) -> Dataset: 22 | stac_assets['ndvi_raw'] = XarrayUtils.calculate_ndvi(stac_assets) 23 | return super().process(stac_assets) 24 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/processors/nitrogen_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | from typing import Set, List, Tuple 13 | 14 | import numpy as np 15 | from xarray import Dataset 16 | 17 | from processors.base_processors import AbstractProcessor 18 | from processors.metadata_utils import MetadataUtils 19 | 20 | 21 | class NitrogenProcessor(AbstractProcessor): 22 | def __init__(self, temp_dir: str, yield_target: float, coordinates: List[List[List[Tuple[float, float]]]], previous_tif_raster: np.ndarray): 23 | self.yield_target = yield_target 24 | self.coordinates = coordinates 25 | self.temp_dir = temp_dir 26 | super().__init__(previous_tif_raster) 27 | 28 | def process(self, stac_assets: Dataset) -> Dataset: 29 | MetadataUtils.generate_nitrogen_metadata(self.temp_dir, self.yield_target, self.coordinates) 30 | return super().process(stac_assets) 31 | -------------------------------------------------------------------------------- /python/apps/satellite-image-processor/processors/tif_image_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | import numpy as np 13 | from processors.base_processors import AbstractProcessor 14 | from processors.metadata_utils import MetadataUtils 15 | from xarray import Dataset 16 | 17 | 18 | class TifImageProcessor(AbstractProcessor): 19 | def __init__(self, temp_dir: str, previous_tif_raster: np.ndarray): 20 | self.temp_dir = temp_dir 21 | super().__init__(previous_tif_raster) 22 | 23 | def process(self, stac_assets: Dataset) -> Dataset: 24 | MetadataUtils.generate_tif_files(stac_assets, self.temp_dir, ['red', 'green', 'blue', 'scl', 'nir08', 'ndvi', 'ndvi_raw', 'scl_surface', 'ndvi_change']) 25 | return super().process(stac_assets) 26 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PYTHON_VERSION=3.11 2 | #checkov:skip=CKV_DOCKER_2:This is a backend application 3 | #checkov:skip=CKV_DOCKER_3:This is not required 4 | FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION} 5 | 6 | # Copy dependencies 7 | COPY requirements.txt ${LAMBDA_TASK_ROOT} 8 | RUN pip install -r requirements.txt --no-cache-dir --no-binary pydantic 9 | 10 | # Copy function code 11 | COPY api/ ${LAMBDA_TASK_ROOT}/api/ 12 | COPY handler.py ${LAMBDA_TASK_ROOT} 13 | 14 | CMD ["handler.handler"] 15 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/api/backend/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/api/routers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 4 | # with the License. A copy of the License is located at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 10 | # and limitations under the License. 11 | 12 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/api/settings.py: -------------------------------------------------------------------------------- 1 | """ API settings.""" 2 | 3 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 6 | # with the License. A copy of the License is located at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 11 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 12 | # and limitations under the License. 13 | 14 | from pydantic import field_validator 15 | from pydantic_settings import BaseSettings 16 | 17 | 18 | class ApiSettings(BaseSettings): 19 | """FASTAPI application settings.""" 20 | 21 | name: str = "AgieTiler" 22 | cors_origins: str = "*" 23 | cors_allow_methods: str = "GET" 24 | root_path: str = "" 25 | debug: bool = False 26 | stac_url: str = None 27 | 28 | @field_validator("cors_origins") 29 | def parse_cors_origin(cls, v): 30 | """Parse CORS origins.""" 31 | return [origin.strip() for origin in v.split(",")] 32 | 33 | @field_validator("cors_allow_methods") 34 | def parse_cors_allow_methods(cls, v): 35 | """Parse CORS allowed methods.""" 36 | return [method.strip().upper() for method in v.split(",")] 37 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/handler.py: -------------------------------------------------------------------------------- 1 | """AWS Lambda handler.""" 2 | 3 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 6 | # with the License. A copy of the License is located at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 11 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 12 | # and limitations under the License. 13 | 14 | import logging 15 | 16 | from api.main import app 17 | from api.settings import ApiSettings 18 | from mangum import Mangum 19 | 20 | logging.getLogger("mangum.lifespan").setLevel(logging.ERROR) 21 | logging.getLogger("mangum.http").setLevel(logging.ERROR) 22 | 23 | api_settings = ApiSettings() 24 | 25 | handler = Mangum(app, api_gateway_base_path=api_settings.root_path, lifespan="auto") 26 | -------------------------------------------------------------------------------- /python/apps/tiler/lambda/requirements.txt: -------------------------------------------------------------------------------- 1 | affine==2.4.0 2 | annotated-types==0.7.0 3 | anyio==4.4.0 4 | attrs==23.2.0 5 | boto3==1.34.127 6 | botocore==1.34.127 7 | cachetools==5.3.3 8 | click==8.1.7 9 | click-plugins==1.1.1 10 | cligj==0.7.2 11 | cogeo-mosaic==7.1.0 12 | color-operations==0.1.3 13 | dnspython==2.6.1 14 | email_validator==2.1.2 15 | fastapi==0.111.0 16 | fastapi-cli==0.0.4 17 | geojson-pydantic==1.1.0 18 | h11==0.14.0 19 | httpcore==1.0.5 20 | httptools==0.6.1 21 | httpx==0.27.0 22 | httpx-auth-awssigv4==0.1.4 23 | idna==3.7 24 | Jinja2==3.1.4 25 | jmespath==1.0.1 26 | mangum==0.17.0 27 | markdown-it-py==3.0.0 28 | MarkupSafe==2.1.5 29 | mdurl==0.1.2 30 | morecantile==5.3.0 31 | numexpr==2.10.0 32 | numpy==1.26.4 33 | orjson==3.10.5 34 | pydantic==2.7.4 35 | pydantic-settings==2.3.3 36 | pydantic_core==2.18.4 37 | Pygments==2.18.0 38 | pyparsing==3.1.2 39 | pyproj==3.6.1 40 | pystac==1.10.1 41 | python-dateutil==2.9.0.post0 42 | python-dotenv==1.0.1 43 | python-multipart==0.0.9 44 | PyYAML==6.0.1 45 | rasterio==1.3.11 46 | rich==13.7.1 47 | rio-tiler==6.6.1 48 | s3transfer==0.10.1 49 | shapely==2.0.4 50 | shellingham==1.5.4 51 | simplejson==3.19.2 52 | six==1.16.0 53 | sniffio==1.3.1 54 | snuggs==1.4.7 55 | starlette==0.37.2 56 | supermorecado==0.1.2 57 | titiler.core==0.18.1 58 | typer==0.12.3 59 | typing_extensions==4.12.2 60 | ujson==5.10.0 61 | urllib3==2.2.2 62 | uvicorn==0.30.1 63 | uvloop==0.19.0 64 | watchfiles==0.22.0 65 | websockets==12.0 66 | -------------------------------------------------------------------------------- /python/notebook/README.md: -------------------------------------------------------------------------------- 1 | # Engine Flow POC 2 | 3 | Just a notebook, trying out the different steps. 4 | 5 | ## Setup 6 | 7 | Create conda environment: 8 | 9 | ```shell 10 | > conda create -c conda-forge -n agie-engine --file requirements.txt 11 | ``` 12 | 13 | Enable Jupyter extensions: 14 | 15 | ```shell 16 | > jupyter nbextension enable --py widgetsnbextension 17 | ``` 18 | 19 | Activate: 20 | 21 | ```shell 22 | > conda activate agie-engine 23 | ``` 24 | -------------------------------------------------------------------------------- /scripts/clean.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 7 | # with the License. A copy of the License is located at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 12 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 13 | # and limitations under the License. 14 | # 15 | 16 | set -e 17 | if [[ "$DEBUG" == "true" ]]; then 18 | set -x 19 | fi 20 | 21 | function help_message { 22 | cat < use ts-node and dev plugins 26 | process.env.NODE_ENV = 'development'; 27 | 28 | tsNode.register({ project }); 29 | 30 | // In dev mode, always show stack traces 31 | oclif.settings.debug = true; 32 | 33 | // Start the CLI 34 | await oclif.execute({ development: true, dir: project }); 35 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/bin/run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | node "%~dp0\run" %* 4 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/bin/run.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 7 | * with the License. A copy of the License is located at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 12 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 13 | * and limitations under the License. 14 | */ 15 | import { execute } from '@oclif/core'; 16 | 17 | await execute({ dir: import.meta.url }); 18 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/src/commands/build.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { AgieCommand } from '../types/agieCommand.js'; 15 | import shell from 'shelljs'; 16 | 17 | const { SILENT_COMMAND_EXECUTION: isSilentStr } = process.env; 18 | const isSilent = isSilentStr ? isSilentStr === 'true' : false; 19 | 20 | export default class AgieBuild extends AgieCommand { 21 | public static description = 'Performs build operations for AGIE'; 22 | public static examples = ['<%= config.bin %> <%= command.id %>']; 23 | 24 | public async runChild(): Promise { 25 | const commands = ['. ~/.nvm/nvm.sh', 'nvm use v20.11.1', 'rush update --bypass-policy', 'rush rebuild']; 26 | shell.exec(commands.join(this.bashAndOperator), { silent: isSilent }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export { run } from "@oclif/core"; 15 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/src/types/agieCommand.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Command } from '@oclif/core'; 15 | import { switchToAgieInfrastructureFolder } from '../utils/shell.js'; 16 | 17 | export abstract class AgieCommand extends Command { 18 | protected bashAndOperator = ' && '; 19 | 20 | abstract runChild(): Promise | Record[] | void>; 21 | 22 | public async run(): Promise | Record[] | void> { 23 | await switchToAgieInfrastructureFolder(); 24 | return await this.runChild(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/src/utils/cloudformation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { DescribeStacksCommand } from '@aws-sdk/client-cloudformation'; 15 | import { getCloudFormationClient } from './awsClient.js'; 16 | 17 | export interface StackMetadata { 18 | name?: string; 19 | status?: string; 20 | } 21 | 22 | const getDeployedStackByName = async (stackName: string, region: string, roleArn?: string): Promise => { 23 | const cfClient = await getCloudFormationClient(region, roleArn); 24 | return await cfClient.send(new DescribeStacksCommand({ StackName: stackName })).then(async (r) => { 25 | const stackName = r.Stacks?.[0].StackName; 26 | const stackStatus = r.Stacks?.[0].StackStatus; 27 | return { name: stackName, status: stackStatus }; 28 | }); 29 | }; 30 | 31 | export { getDeployedStackByName }; 32 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/src/utils/help.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Command, CommandHelp, Flags, Help } from '@oclif/core'; 15 | import Flag = Command.Flag; 16 | 17 | export default class AgieHelp extends Help { 18 | public getCommandHelpClass(command: Command.Loadable): CommandHelp { 19 | command.flags = { 20 | ...command.flags, 21 | }; 22 | 23 | return new this.CommandHelpClass(command, this.config, this.opts); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/src/utils/ssm.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { GetParameterCommand } from '@aws-sdk/client-ssm'; 15 | import { getSSMClient } from './awsClient.js'; 16 | 17 | async function getParameterValue(path: string, region: string, roleArn?: string): Promise { 18 | const ssm = await getSSMClient(region!, roleArn); 19 | const response = await ssm.send( 20 | new GetParameterCommand({ 21 | Name: path, 22 | }), 23 | ); 24 | return response.Parameter?.Value as string; 25 | } 26 | 27 | export { getParameterValue }; 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | "noPropertyAccessFromIndexSignature": false, 13 | // overrides of extends 14 | "strict": false, 15 | "exactOptionalPropertyTypes": false, 16 | "strictNullChecks": true 17 | }, 18 | "ts-node": { 19 | "esm": true 20 | }, 21 | "include": ["src/**/*.ts"], 22 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 23 | } 24 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/engine", 3 | "entries": [ 4 | { 5 | "version": "0.2.0", 6 | "tag": "@agie/engine_v0.2.0", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "minor": [ 10 | { 11 | "comment": "New package created for engine functionality, including API routes, schemas, services and repositories for engines and registrations" 12 | } 13 | ], 14 | "dependency": [ 15 | { 16 | "comment": "Updating dependency \"@agie/events\" to `0.2.0`" 17 | }, 18 | { 19 | "comment": "Updating dependency \"@agie/clients\" to `1.1.0`" 20 | }, 21 | { 22 | "comment": "Updating dependency \"@agie/rest-api-authorizer\" to `0.1.0`" 23 | }, 24 | { 25 | "comment": "Updating dependency \"@agie/resource-api-base\" to `1.0.1`" 26 | } 27 | ] 28 | } 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/engine 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.2.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - New package created for engine functionality, including API routes, schemas, services and repositories for engines and registrations 11 | 12 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/api/engines/examples.ts: -------------------------------------------------------------------------------- 1 | import { EngineNew, EngineResource, EngineResourceList, EngineUpdate } from './schemas.js'; 2 | 3 | export const newEngineRequestExample: EngineNew = { 4 | name: 'sample-engine-processor', 5 | jobRoleArn: 'sample-role-arn', 6 | image: 'account.dkr.ecr.region.amazonaws.com/process-image:v1', 7 | memory: 2048, 8 | vcpus: 1, 9 | environment: { 10 | SENTINEL_COLLECTION: 'sentinel-2-c1-l2a', 11 | }, 12 | }; 13 | 14 | export const updateEngineRequestExample: EngineUpdate = { 15 | memory: 4096, 16 | vcpus: 2, 17 | environment: { 18 | SENTINEL_COLLECTION: 'sentinel-2-c1-l2a', 19 | }, 20 | }; 21 | 22 | export const engineExample: EngineResource = { 23 | ...newEngineRequestExample, 24 | id: '01jbv38j4mkej1pysmcs1bsp6q', 25 | jobDefinitionArn: 'arn:aws:batch:region:account:job-definition/sample-engine-processor:1', 26 | createdAt: '2024-10-30T03:30:58.734Z', 27 | createdBy: 'someone@somewhere.com', 28 | }; 29 | 30 | export const engineListExample: EngineResourceList = { 31 | engines: [engineExample], 32 | }; 33 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/api/registrations/examples.ts: -------------------------------------------------------------------------------- 1 | import { RegistrationResourceList } from './schemas.js'; 2 | 3 | export const registrationListExample: RegistrationResourceList = { 4 | registrations: [ 5 | { 6 | engineId: 'engine1', 7 | regionId: 'region1', 8 | createdAt: '2024-10-30T03:30:58.734Z', 9 | }, 10 | { 11 | engineId: 'engine1', 12 | regionId: 'region2', 13 | createdAt: '2024-10-30T03:30:58.734Z', 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/api/registrations/schemas.ts: -------------------------------------------------------------------------------- 1 | import { createdAt } from '@agie/resource-api-base'; 2 | import { Static, Type } from '@sinclair/typebox'; 3 | import { NextToken, regionId } from '../../common/schemas.js'; 4 | 5 | export const registrationResource = Type.Object( 6 | { 7 | engineId: Type.String({ description: 'Engine Identifier associated with the registration resource.' }), 8 | regionId: Type.String({ description: 'Region Identifier associated with the registration resource.' }), 9 | createdAt, 10 | }, 11 | { 12 | $id: 'registration_resource', 13 | } 14 | ); 15 | 16 | export const registrationResourceList = Type.Object( 17 | { 18 | registrations: Type.Array(Type.Ref(registrationResource)), 19 | pagination: Type.Optional( 20 | Type.Object({ 21 | lastEvaluated: Type.Optional(regionId), 22 | }) 23 | ), 24 | }, 25 | { 26 | $id: 'registration_list', 27 | } 28 | ); 29 | 30 | export type RegistrationResource = Static; 31 | export type RegistrationResourceList = Static; 32 | 33 | export interface RegistrationListOptions { 34 | count?: number; 35 | token?: NextToken; 36 | } 37 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/common/pkUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export enum PkType { 15 | Engine = 'en', 16 | EngineType = 'et', 17 | Region = 'rg', 18 | RegistrationType = 'rt', 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/common/schemas.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | /* eslint-disable @rushstack/typedef-var */ 15 | import { Type } from '@sinclair/typebox'; 16 | 17 | export const regionId = Type.String({ description: 'Unique Region ID.' }); 18 | 19 | export const startDateTime = Type.String({ description: "The query window's start time." }); 20 | 21 | export const endDateTime = Type.String({ description: "The query window's end time" }); 22 | 23 | export type NextToken = string; 24 | 25 | export type ListPaginationOptions = { 26 | count?: number; 27 | token?: NextToken; 28 | }; 29 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/lambda_apiGateway.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import awsLambdaFastify, { PromiseHandler } from '@fastify/aws-lambda'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | import type { FastifyInstance } from 'fastify'; 19 | 20 | const server: FastifyInstance = await buildApp(); 21 | 22 | export const handler: PromiseHandler = awsLambdaFastify(server, { 23 | decorateRequest: false, 24 | serializeLambdaArguments: true, 25 | }); 26 | 27 | await server.ready(); 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/src/server.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import url from 'url'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | const startServer = async (): Promise => { 19 | const app = await buildApp(); 20 | try { 21 | await app.listen({ port: app.config.PORT, host: '0.0.0.0' }); 22 | } catch (err) { 23 | app.log.error(err); 24 | process.exit(1); 25 | } 26 | }; 27 | 28 | // if called directly, e.g. local dev, start the fastify server 29 | const path: string = process.argv[1] as string; 30 | const href: string = url.pathToFileURL(path).href; 31 | if (import.meta.url === href) { 32 | await startServer(); 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/engine/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | 16 | // overrides of extends 17 | "strict": false, 18 | "exactOptionalPropertyTypes": false 19 | }, 20 | "include": [ 21 | "src/**/*.ts" 22 | ], 23 | "exclude": [ 24 | "./**/__mocks__/*.ts", 25 | ".git", 26 | ".history", 27 | ".vscode", 28 | "cdk.out", 29 | "dist", 30 | "lib", 31 | "node_modules" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/executor/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/executor 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.2.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Removed authz plugin and related files, replacing with @agie/rest-api-authorizer 11 | - Added EnginesClient to JobsService and module.awilix 12 | 13 | ### Patches 14 | 15 | - Updated imports to use @agie/rest-api-authorizer instead of local scopes 16 | - Modified JobsService to use EnginesClient for job definition retrieval 17 | 18 | ## 0.1.0 19 | Thu, 31 Oct 2024 05:15:58 GMT 20 | 21 | ### Minor changes 22 | 23 | - Added new API endpoints and functionality for managing execution tasks and task items 24 | - Added new schemas and models for execution tasks and task items 25 | - Added new repository and service layers for execution tasks and task items 26 | - Added new dependencies for DynamoDB, SQS, and other AWS services 27 | 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/executor/docs/images/AGIE HLA-executor-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/executor/docs/images/AGIE HLA-executor-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/executor/docs/images/AGIE HLA-executor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/executor/docs/images/AGIE HLA-executor.png -------------------------------------------------------------------------------- /typescript/packages/apps/executor/src/common/pkUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export enum PkType { 15 | ExecutionTask = 'et', 16 | ExecutionTaskItem = 'ei', 17 | StartDate = 'sd', 18 | Subject = 'su', 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/apps/executor/src/common/schemas.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | /* eslint-disable @rushstack/typedef-var */ 15 | import { Type } from '@sinclair/typebox'; 16 | 17 | export const regionId = Type.String({ description: 'Unique Region ID.' }); 18 | 19 | export const startDateTime = Type.String({ description: "The query window's start time." }); 20 | 21 | export const endDateTime = Type.String({ description: "The query window's end time" }); 22 | 23 | export type NextToken = string; 24 | 25 | export type ListPaginationOptions = { 26 | count?: number; 27 | token?: NextToken; 28 | }; 29 | -------------------------------------------------------------------------------- /typescript/packages/apps/executor/src/lambda_apiGateway.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import awsLambdaFastify, { PromiseHandler } from '@fastify/aws-lambda'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | import type { FastifyInstance } from 'fastify'; 19 | 20 | const server: FastifyInstance = await buildApp(); 21 | 22 | export const handler: PromiseHandler = awsLambdaFastify(server, { 23 | decorateRequest: false, 24 | serializeLambdaArguments: true, 25 | callbackWaitsForEmptyEventLoop: false 26 | }); 27 | 28 | await server.ready(); 29 | -------------------------------------------------------------------------------- /typescript/packages/apps/executor/src/server.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import url from 'url'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | const startServer = async (): Promise => { 19 | const app = await buildApp(); 20 | try { 21 | await app.listen({ port: app.config.PORT, host: '0.0.0.0' }); 22 | } catch (err) { 23 | app.log.error(err); 24 | process.exit(1); 25 | } 26 | }; 27 | 28 | // if called directly, e.g. local dev, start the fastify server 29 | const path: string = process.argv[1] as string; 30 | const href: string = url.pathToFileURL(path).href; 31 | if (import.meta.url === href) { 32 | await startServer(); 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/executor/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | 16 | // overrides of extends 17 | "strict": false, 18 | "exactOptionalPropertyTypes": false 19 | }, 20 | "include": [ 21 | "src/**/*.ts" 22 | ], 23 | "exclude": [ 24 | "./**/__mocks__/*.ts", 25 | ".git", 26 | ".history", 27 | ".vscode", 28 | "cdk.out", 29 | "dist", 30 | "lib", 31 | "node_modules" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/notifications 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.1.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Removed local authorization plugin and scopes, replacing with @agie/rest-api-authorizer package 11 | 12 | ### Patches 13 | 14 | - Updated imports and usage of authorization functions throughout the codebase 15 | - Minor code formatting and import ordering changes 16 | 17 | ## 0.0.2 18 | Thu, 31 Oct 2024 05:15:58 GMT 19 | 20 | _Initial release_ 21 | 22 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/docs/images/AGIE HLA-notifications-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/notifications/docs/images/AGIE HLA-notifications-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/docs/images/AGIE HLA-notifications.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/notifications/docs/images/AGIE HLA-notifications.png -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/docs/security.md: -------------------------------------------------------------------------------- 1 | # Notifications Module Authentication & Authorization 2 | 3 | Authentication of users is carried out using Amazon Cognito, and authorization of users using [Amazon Verified Permissions](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/what-is-avp.html). 4 | 5 | Users within Cognito are assigned a role of `admin`, `contributor`, or `reader`. 6 | 7 | ## REST API Authorization 8 | 9 | The following actions and permissions are configured: 10 | 11 | | Action | Method | Resource Path | Users with access | 12 | |--------------------|--------|-----------------------------------|-------------------| 13 | | CreateSubscription | POST | /regions/{regionId}/subscriptions | All users | 14 | | ListSubscription | GET | /subscriptions | All users | 15 | | DeleteSubscription | GET | /subscriptions/{subscriptionId} | All users | 16 | 17 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/src/api/subscriptions/example.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { CreateSubscription, Subscription, SubscriptionList } from "./schemas.js"; 15 | 16 | export const subscriptionResourceExample: Subscription = { 17 | regionId: '01hwvwmm5d2crn4xx8k0s0a61z', 18 | id: '01hwy44p6yjpvkdx4c9g675h55', 19 | createdAt: '2024-10-02T00:00:00.000Z', 20 | } 21 | 22 | export const subscriptionListResourceExample: SubscriptionList = { 23 | subscriptions: [subscriptionResourceExample] 24 | } 25 | export const subscriptionPostRequestExample: CreateSubscription = {} 26 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/src/common/pkUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export enum PkType { 15 | SubscriptionId = 'si', 16 | UserId = 'ui', 17 | RegionId = 'ri', 18 | } 19 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/src/common/snsUtil.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export class SnsUtil { 15 | readonly TOPIC_PREFIX = 'agie-events-'; 16 | 17 | constructor(readonly region: string, 18 | readonly accountId: string) { 19 | } 20 | 21 | public topicName(userId: string) { 22 | return `${this.TOPIC_PREFIX}${encodeURI(userId)}`; 23 | } 24 | 25 | public topicArn(userId: string): string { 26 | return `arn:aws:sns:${this.region}:${this.accountId}:${this.topicName(userId)}`; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/src/lambda_apiGateway.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import awsLambdaFastify, { PromiseHandler } from '@fastify/aws-lambda'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | import type { FastifyInstance } from 'fastify'; 19 | 20 | const server: FastifyInstance = await buildApp(); 21 | 22 | export const handler: PromiseHandler = awsLambdaFastify(server, { 23 | decorateRequest: false, 24 | serializeLambdaArguments: true, 25 | }); 26 | 27 | await server.ready(); 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/src/server.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import url from 'url'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | const startServer = async (): Promise => { 19 | const app = await buildApp(); 20 | try { 21 | await app.listen({ port: app.config.PORT, host: '0.0.0.0' }); 22 | } catch (err) { 23 | app.log.error(err); 24 | process.exit(1); 25 | } 26 | }; 27 | 28 | // if called directly, e.g. local dev, start the fastify server 29 | const path: string = process.argv[1] as string; 30 | const href: string = url.pathToFileURL(path).href; 31 | if (import.meta.url === href) { 32 | await startServer(); 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/notifications/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | // overrides of extends 16 | "strict": false, 17 | "exactOptionalPropertyTypes": false 18 | }, 19 | "include": [ 20 | "src/**/*.ts" 21 | ], 22 | "exclude": [ 23 | "./**/__mocks__/*.ts", 24 | ".git", 25 | ".history", 26 | ".vscode", 27 | "cdk.out", 28 | "dist", 29 | "lib", 30 | "node_modules" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/regions-extension", 3 | "entries": [ 4 | { 5 | "version": "0.0.3", 6 | "tag": "@agie/regions-extension_v0.0.3", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "dependency": [ 10 | { 11 | "comment": "Updating dependency \"@agie/events\" to `0.2.0`" 12 | }, 13 | { 14 | "comment": "Updating dependency \"@agie/clients\" to `1.1.0`" 15 | } 16 | ] 17 | } 18 | }, 19 | { 20 | "version": "0.0.2", 21 | "tag": "@agie/regions-extension_v0.0.2", 22 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 23 | "comments": { 24 | "dependency": [ 25 | { 26 | "comment": "Updating dependency \"@agie/events\" to `0.1.0`" 27 | }, 28 | { 29 | "comment": "Updating dependency \"@agie/clients\" to `1.0.1`" 30 | } 31 | ] 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/regions-extension 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.0.3 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | _Version update only_ 9 | 10 | ## 0.0.2 11 | Thu, 31 Oct 2024 05:15:58 GMT 12 | 13 | _Initial release_ 14 | 15 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/README.md: -------------------------------------------------------------------------------- 1 | # Regions Extension Module 2 | 3 | ## Overview 4 | 5 | The `Regions Extension` module updates the attributes of AGIE `Region` resources with latest analysis result for a region. You can use this module as a template to augment your `Region` resources (Groups, Regions or Polygon) with external or aggregated data. 6 | 7 | ## Architecture 8 | 9 | ### AGIE Conceptual Architecture 10 | 11 | ![conceptual](docs/images/AGIE%20HLA-regions-extension-conceptual.png) 12 | 13 | The `Regions Extension` module subscribes to analysis results CRUD events from `Results` module and update the associated region resource attributes with latest analysis result details. 14 | 15 | ### Regions Extension Logical Architecture 16 | 17 | ![logical](docs/images/AGIE%20HLA-regions-extension.png) 18 | 19 | The `Regions Extension` AWS Lambda subscribes to `Result` module events from the shared Amazon EventBridge and update the `Region` resource by invoking the `Region` module API Lambda. 20 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/docs/images/AGIE HLA-regions-extension-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/regions-extension/docs/images/AGIE HLA-regions-extension-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/docs/images/AGIE HLA-regions-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/regions-extension/docs/images/AGIE HLA-regions-extension.png -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/regions-extension", 3 | "version": "0.0.3", 4 | "description": "Extending the functionality of the core region module to augment resources with external data.", 5 | "exports": { 6 | ".": { 7 | "import": "./dist/index.js" 8 | } 9 | }, 10 | "types": "./dist/index.d.js", 11 | "type": "module", 12 | "scripts": { 13 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 14 | "build": "npx tsc -b", 15 | "test": "npm run build && vitest run --passWithNoTests", 16 | "prestart": "npx tsx src/localConfigGenerator.ts", 17 | "start": "rushx build && tsx src/server.ts", 18 | "cdk": "cdk" 19 | }, 20 | "dependencies": { 21 | "@agie/events": "workspace:*", 22 | "@agie/clients": "workspace:*", 23 | "@agie/lambda-invoker": "workspace:*", 24 | "@aws-sdk/client-lambda": "~3", 25 | "@fastify/awilix": "~6", 26 | "@fastify/aws-lambda": "~5", 27 | "awilix": "~11", 28 | "aws-lambda": "~1", 29 | "aws-xray-sdk": "~3", 30 | "dayjs": "~1", 31 | "dotenv": "~16", 32 | "fastify-plugin": "~5", 33 | "fastify": "~5", 34 | "ow": "~2", 35 | "pino-pretty": "~11", 36 | "pino": "~9" 37 | }, 38 | "devDependencies": { 39 | "@tsconfig/node20": "~20", 40 | "@types/aws-lambda": "~8", 41 | "@types/node": "~22", 42 | "eslint": "~9", 43 | "shx": "~0", 44 | "tsx": "~4", 45 | "typescript": "~5", 46 | "vitest": "~2", 47 | "vitest-mock-extended": "~2" 48 | }, 49 | "private": false 50 | } 51 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | 16 | // overrides of extends 17 | "strict": false, 18 | "exactOptionalPropertyTypes": false 19 | }, 20 | "include": [ 21 | "src/**/*.ts" 22 | ], 23 | "exclude": [ 24 | "./**/__mocks__/*.ts", 25 | ".git", 26 | ".history", 27 | ".vscode", 28 | "cdk.out", 29 | "dist", 30 | "lib", 31 | "node_modules" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/regions 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 1.0.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Breaking changes 9 | 10 | - Removed common/scopes.ts file and replaced its usage with @agie/rest-api-authorizer 11 | 12 | ### Minor changes 13 | 14 | - Added new dependencies: @agie/clients, @agie/lambda-invoker, and @aws-sdk/client-lambda 15 | - Added engineId to processingConfig schema in regions/schemas.ts 16 | - Updated RegionService to include enginesClient in constructor and added validation for engineId 17 | - Updated module.awilix.ts to include new dependencies and services 18 | 19 | ## 0.0.2 20 | Thu, 31 Oct 2024 05:15:58 GMT 21 | 22 | ### Patches 23 | 24 | - Minor refactoring in TaskService class: Added async/await syntax to the SQS message sending process for better asynchronous handling. 25 | 26 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | # Semgrep issue https://sg.run/e4JE 4 | # Ignore reason: The docker compose is not being used to deploy, it's mainly for local testing 5 | # nosemgrep 6 | cache: 7 | image: redis:7.0.15-alpine 8 | restart: always 9 | ports: 10 | - '6379:6379' 11 | command: redis-server --save 20 1 --loglevel warning 12 | volumes: 13 | - cache:/data 14 | volumes: 15 | cache: 16 | driver: local 17 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/docs/images/AGIE HLA-regions-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/regions/docs/images/AGIE HLA-regions-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/regions/docs/images/AGIE HLA-regions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/regions/docs/images/AGIE HLA-regions.png -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/api/polygonTaskItems/examples.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { TaskItemList, TaskItemResource } from "../../common/taskItems/schemas.js"; 15 | 16 | export const taskItemResourceExample: TaskItemResource = { 17 | name: "testPolygon" 18 | } 19 | 20 | export const taskItemListExample: TaskItemList = { 21 | taskItems: [taskItemResourceExample] 22 | } 23 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/api/regionTaskItems/examples.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { TaskItemList, TaskItemResource } from "../../common/taskItems/schemas.js"; 15 | 16 | export const taskItemResourceExample: TaskItemResource = { 17 | name: "testPolygon" 18 | } 19 | 20 | export const taskItemListExample: TaskItemList = { 21 | taskItems: [taskItemResourceExample] 22 | } 23 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/common/pkTypes.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export enum PkType { 15 | Group = 'g', 16 | Region = 'r', 17 | Polygon = 'p', 18 | State = 's', 19 | LatestState = 'ps', 20 | TagKey = 'tk', 21 | TagValue = 'tv', 22 | Timestamp = 'ts', 23 | PolygonTask = 'pt', 24 | PolygonTaskItem = 'pi', 25 | RegionTask = 'rt', 26 | RegionTaskItem = 'ri' 27 | } 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/common/tasks/workflows.interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | 15 | import { TaskBatch } from "./schemas.js"; 16 | 17 | export interface WorkflowAction { 18 | process(task: TaskBatch): Promise; 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './api/groups/schemas.js'; 15 | export * from './api/polygons/schemas.js'; 16 | export * from './api/regions/schemas.js'; 17 | export * from './api/states/schemas.js'; 18 | export { Tags } from './common/schemas.js'; 19 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/lambda_apiGateway.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import awsLambdaFastify, { PromiseHandler } from '@fastify/aws-lambda'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | import type { FastifyInstance } from 'fastify'; 19 | 20 | const server: FastifyInstance = await buildApp(); 21 | 22 | export const handler: PromiseHandler = awsLambdaFastify(server, { 23 | decorateRequest: false, 24 | serializeLambdaArguments: true, 25 | callbackWaitsForEmptyEventLoop: false 26 | }); 27 | 28 | await server.ready(); 29 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/src/server.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import url from 'url'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | const startServer = async (): Promise => { 19 | const app = await buildApp(); 20 | try { 21 | await app.listen({ port: app.config.PORT, host: '0.0.0.0' }); 22 | } catch (err) { 23 | app.log.error(err); 24 | process.exit(1); 25 | } 26 | }; 27 | 28 | // if called directly, e.g. local dev, start the fastify server 29 | const path: string = process.argv[1] as string; 30 | const href: string = url.pathToFileURL(path).href; 31 | if (import.meta.url === href) { 32 | await startServer(); 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/regions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "composite": true, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "esModuleInterop": true, 12 | "ignoreDeprecations": "5.0", 13 | "noPropertyAccessFromIndexSignature": false, 14 | // overrides of extends 15 | "strict": false, 16 | "exactOptionalPropertyTypes": false 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/results 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.1.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Removed local scopes.ts file and replaced with @agie/rest-api-authorizer package for authentication and authorization 11 | - Removed local authz.ts plugin and replaced with authzPlugin from @agie/rest-api-authorizer 12 | 13 | ### Patches 14 | 15 | - Updated imports and usage of SecurityContext and SecurityScope to use from @agie/rest-api-authorizer 16 | - Minor code formatting and cleanup changes 17 | 18 | ## 0.0.2 19 | Thu, 31 Oct 2024 05:15:58 GMT 20 | 21 | _Initial release_ 22 | 23 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/docs/images/AGIE HLA-results-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/results/docs/images/AGIE HLA-results-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/results/docs/images/AGIE HLA-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/results/docs/images/AGIE HLA-results.png -------------------------------------------------------------------------------- /typescript/packages/apps/results/src/api/results/example.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Result, ResultList } from './schemas.js'; 15 | 16 | export const resultResourceExample: Result = { 17 | regionId: '01j8sbj1bjwwtv7482rnrdxtqg', 18 | id: '01j8seqvy55xy4k4p51nz976zh', 19 | createdAt: '2024-09-27T09:59:39.352Z', 20 | startDateTime: '2024-09-22T09:59:32.518Z', 21 | endDateTime: '2024-09-27T09:59:32.518Z', 22 | engineType: 'aws-batch', 23 | status: 'succeeded', 24 | executionId: '2128c070-04ad-4476-8450-42d53b5954b4', 25 | updatedAt: '2024-09-27T10:01:08.091Z', 26 | message: 'Essential container in task exited', 27 | }; 28 | 29 | export const resultListResourceExample: ResultList = { 30 | results: [resultResourceExample], 31 | pagination: { 32 | count: 20, 33 | }, 34 | }; 35 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/src/common/pkUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export enum PkType { 15 | RegionId = 'ri', 16 | ResultId = 'rs', 17 | Status = 'st', 18 | EndDateTime = 'ed', 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/src/common/schemas.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Type } from '@sinclair/typebox'; 15 | import { apiVersion100 } from './types.js'; 16 | 17 | /** 18 | * Common headers 19 | */ 20 | export const commonHeaders = Type.Object({ 21 | 'accept-version': Type.String({ description: 'API version', default: apiVersion100 }), 22 | accept: Type.String({ description: 'Accepted Content Type', default: 'application/json' }), 23 | }); 24 | 25 | export const countPaginationQS = Type.Integer({ description: 'Count of results to return, if not specified default to 20', default: 20 }); 26 | export const fromIdPaginationQS = Type.Optional(Type.String({ description: 'Id to paginate from (exclusive).' })); 27 | export const fromTokenPaginationQS = Type.Optional(Type.String({ description: 'Token used to paginate from (exclusive).' })); 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/src/lambda_apiGateway.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import awsLambdaFastify, { PromiseHandler } from '@fastify/aws-lambda'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | import type { FastifyInstance } from 'fastify'; 19 | 20 | const server: FastifyInstance = await buildApp(); 21 | 22 | export const handler: PromiseHandler = awsLambdaFastify(server, { 23 | decorateRequest: false, 24 | serializeLambdaArguments: true, 25 | }); 26 | 27 | await server.ready(); 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/src/server.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import url from 'url'; 15 | 16 | import { buildApp } from './app.js'; 17 | 18 | const startServer = async (): Promise => { 19 | const app = await buildApp(); 20 | try { 21 | await app.listen({ port: app.config.PORT, host: '0.0.0.0' }); 22 | } catch (err) { 23 | app.log.error(err); 24 | process.exit(1); 25 | } 26 | }; 27 | 28 | // if called directly, e.g. local dev, start the fastify server 29 | const path: string = process.argv[1] as string; 30 | const href: string = url.pathToFileURL(path).href; 31 | if (import.meta.url === href) { 32 | await startServer(); 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/results/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | // overrides of extends 16 | "strict": false, 17 | "exactOptionalPropertyTypes": false 18 | }, 19 | "include": [ 20 | "src/**/*.ts" 21 | ], 22 | "exclude": [ 23 | "./**/__mocks__/*.ts", 24 | ".git", 25 | ".history", 26 | ".vscode", 27 | "cdk.out", 28 | "dist", 29 | "lib", 30 | "node_modules" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/scheduler", 3 | "entries": [ 4 | { 5 | "version": "0.0.3", 6 | "tag": "@agie/scheduler_v0.0.3", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "patch": [ 10 | { 11 | "comment": "Modified the 'custom:role' claim in the authorizer object from '/|||reader' to 'reader'" 12 | } 13 | ], 14 | "dependency": [ 15 | { 16 | "comment": "Updating dependency \"@agie/events\" to `0.2.0`" 17 | }, 18 | { 19 | "comment": "Updating dependency \"@agie/clients\" to `1.1.0`" 20 | } 21 | ] 22 | } 23 | }, 24 | { 25 | "version": "0.0.2", 26 | "tag": "@agie/scheduler_v0.0.2", 27 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 28 | "comments": { 29 | "dependency": [ 30 | { 31 | "comment": "Updating dependency \"@agie/events\" to `0.1.0`" 32 | }, 33 | { 34 | "comment": "Updating dependency \"@agie/clients\" to `1.0.1`" 35 | } 36 | ] 37 | } 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/scheduler 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.0.3 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Patches 9 | 10 | - Modified the 'custom:role' claim in the authorizer object from '/|||reader' to 'reader' 11 | 12 | ## 0.0.2 13 | Thu, 31 Oct 2024 05:15:58 GMT 14 | 15 | _Initial release_ 16 | 17 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/docs/images/AGIE HLA-scheduler-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/scheduler/docs/images/AGIE HLA-scheduler-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/docs/images/AGIE HLA-scheduler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/scheduler/docs/images/AGIE HLA-scheduler.png -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/src/common/pkUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export enum PkType { 15 | RegionId = 'ri', 16 | Day = 'dy', 17 | } 18 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/src/jobs/model.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { RegionResource } from '@agie/events'; 15 | 16 | export type StartJobRequest = RegionResource & { scheduleDateTime: string }; 17 | 18 | export interface BatchEngineInput { 19 | polygonId: string; 20 | groupId: string; 21 | regionId: string; 22 | coordinates: [[number, number]], 23 | exclusions?: [[[number, number]]]; 24 | scheduleDateTime: string; 25 | } 26 | 27 | export type BatchEngineRun = { 28 | regionId: string; 29 | scheduleDay: string; 30 | ttl?: number; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/src/lambda_eventbridge_scheduler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Region } from '@agie/clients'; 15 | import { AwilixContainer } from 'awilix'; 16 | import { Callback, Context, Handler } from 'aws-lambda'; 17 | import { FastifyInstance } from 'fastify'; 18 | import { buildLightApp } from './app.light.js'; 19 | import { JobsService } from './jobs/service.js'; 20 | 21 | const app: FastifyInstance = await buildLightApp(); 22 | const di: AwilixContainer = app.diContainer; 23 | 24 | const jobsService = di.resolve('jobsService'); 25 | 26 | export const handler: Handler = async (event, _context: Context, _callback: Callback) => { 27 | app.log.debug(`EventBridgeSchdulerLambda > handler > event: ${JSON.stringify(event)}`); 28 | await jobsService.startJobOnSchedule(event); 29 | app.log.debug(`EventBridgeSchdulerLambda > handler >exit`); 30 | }; 31 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/src/schedules/model.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export interface CreateScheduleRequest { 15 | polygonId: string; 16 | groupId: string; 17 | regionId: string; 18 | coordinates: [[number, number]]; 19 | scheduleExpression: string; 20 | scheduleExpressionTimezone?: string; 21 | } 22 | -------------------------------------------------------------------------------- /typescript/packages/apps/scheduler/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | 16 | // overrides of extends 17 | "strict": false, 18 | "exactOptionalPropertyTypes": false 19 | }, 20 | "include": [ 21 | "src/**/*.ts" 22 | ], 23 | "exclude": [ 24 | "./**/__mocks__/*.ts", 25 | ".git", 26 | ".history", 27 | ".vscode", 28 | "cdk.out", 29 | "dist", 30 | "lib", 31 | "node_modules" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/.env.sample: -------------------------------------------------------------------------------- 1 | VITE_LOCATION_SERVICE_BASE_MAP_NAME=agie.XXX.baseNavigationMap 2 | VITE_LOCATION_SERVICE_SAT_MAP_NAME=agie.XXX.baseSatelliteMap 3 | VITE_LOCATION_SERVICE_MAP_REGION=us-west-2 4 | VITE_COGNITO_USER_POOL_ID="us-west-2_XXX" 5 | VITE_COGNITO_USER_POOL_REGION="us-west-2" 6 | VITE_COGNITO_USER_POOL_CLIENT_ID="XXX" 7 | VITE_UI_REST_API_URL="https://XXX.execute-api.us-west-2.amazonaws.com/XXX/" 8 | VITE_STAC_API_ENDPOINT="https://XXX.execute-api.us-west-2.amazonaws.com/XXX/" 9 | VITE_IDENTITY_POOL_ID="us-west-2:XXX" 10 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | module.exports = { 15 | root: true, 16 | env: { browser: true, es2020: true }, 17 | extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'], 18 | ignorePatterns: ['dist', '.eslintrc.cjs'], 19 | parser: '@typescript-eslint/parser', 20 | plugins: ['react-refresh'], 21 | rules: { 22 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 23 | }, 24 | }; 25 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/ui", 3 | "entries": [ 4 | { 5 | "version": "0.0.2", 6 | "tag": "@agie/ui_v0.0.2", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "dependency": [ 10 | { 11 | "comment": "Updating dependency \"@agie/regions\" to `1.0.0`" 12 | } 13 | ] 14 | } 15 | }, 16 | { 17 | "version": "0.0.1", 18 | "tag": "@agie/ui_v0.0.1", 19 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 20 | "comments": { 21 | "dependency": [ 22 | { 23 | "comment": "Updating dependency \"@agie/regions\" to `0.0.2`" 24 | } 25 | ] 26 | } 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/ui 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.0.2 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | _Version update only_ 9 | 10 | ## 0.0.1 11 | Thu, 31 Oct 2024 05:15:58 GMT 12 | 13 | _Initial release_ 14 | 15 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/docs/images/AGIE HLA-ui-conceptual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/ui/docs/images/AGIE HLA-ui-conceptual.png -------------------------------------------------------------------------------- /typescript/packages/apps/ui/docs/images/AGIE HLA-ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-solutions-library-samples/guidance-for-automated-geospatial-insights-engine-on-aws/ff322c75f5e4511359f2556bae7c311f14a20bd7/typescript/packages/apps/ui/docs/images/AGIE HLA-ui.png -------------------------------------------------------------------------------- /typescript/packages/apps/ui/index.html: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | AGIE 21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/public/logo-white.svg: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/app/hooks.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux" 15 | import type { RootState, AppDispatch } from "./store" 16 | 17 | // Use throughout your app instead of plain `useDispatch` and `useSelector` 18 | export const useAppDispatch: () => AppDispatch = useDispatch 19 | export const useAppSelector: TypedUseSelectorHook = useSelector 20 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/app/store.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Action, ThunkAction, configureStore } from '@reduxjs/toolkit'; 15 | import { regionsApiSlice } from '../slices/regionsApiSlice'; 16 | import { tilerApiSlice } from '../slices/tilerApiSlice'; 17 | 18 | export const store = configureStore({ 19 | reducer: { 20 | [regionsApiSlice.reducerPath]: regionsApiSlice.reducer, 21 | [tilerApiSlice.reducerPath]: tilerApiSlice.reducer, 22 | }, 23 | devTools: true, 24 | middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(regionsApiSlice.middleware).concat(tilerApiSlice.middleware), 25 | }); 26 | 27 | export type AppDispatch = typeof store.dispatch; 28 | export type RootState = ReturnType; 29 | export type AppThunk = ThunkAction>; 30 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/hooks/useMapBoundingBox.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { useEffect, useState } from 'react'; 15 | import { MapRef } from 'react-map-gl/maplibre'; 16 | 17 | export const useMapBoundingBox = (mapRef: React.RefObject) => { 18 | const [boundingBox, setBoundingBox] = useState(undefined); 19 | 20 | const updateBoundingBox = () => { 21 | if (mapRef.current) { 22 | const bounds = mapRef.current.getBounds(); 23 | const boundingBox = [bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth()]; 24 | setBoundingBox(boundingBox); 25 | } 26 | }; 27 | 28 | useEffect(() => { 29 | if (mapRef.current) { 30 | updateBoundingBox(); 31 | } 32 | }, [mapRef.current]); 33 | 34 | return { boundingBox, updateBoundingBox }; 35 | }; 36 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/index.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | :root { 15 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 16 | line-height: 1.5; 17 | font-weight: 400; 18 | 19 | color-scheme: light dark; 20 | color: rgba(255, 255, 255, 0.87); 21 | background-color: #242424; 22 | 23 | font-synthesis: none; 24 | text-rendering: optimizeLegibility; 25 | -webkit-font-smoothing: antialiased; 26 | -moz-osx-font-smoothing: grayscale; 27 | } 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/main.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | window.global ||= window; 15 | import React from 'react'; 16 | import ReactDOM from 'react-dom/client'; 17 | import { Provider } from 'react-redux'; 18 | import App from './App'; 19 | import { store } from './app/store'; 20 | import './index.css'; 21 | 22 | ReactDOM.createRoot(document.getElementById('root')!).render( 23 | 24 | 25 | 26 | 27 | 28 | ); 29 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/pages/Crops/CreateCropModal.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/pages/Crops/EditCropModal.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/pages/Farms/EditFarm.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/pages/Farms/ListFarms.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { useParams } from 'react-router-dom'; 15 | import Breadcrumbs from '../../shared/Breadcrumbs'; 16 | import Shell from '../../shared/Shell'; 17 | import FarmsTable from './FarmsTable'; 18 | 19 | export default function ListFarms() { 20 | const { growerId } = useParams(); 21 | const breadcrumbsItems = [{ text: 'Farms', href: '/farms' }]; 22 | if (growerId) { 23 | breadcrumbsItems.unshift({ text: 'Growers', href: '/growers' }, { text: growerId, href: `/growers/${growerId}` }); 24 | } 25 | 26 | return } contentType="table" content={} />; 27 | } 28 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/pages/Farms/ProcessingStatus.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { StatusIndicator } from '@cloudscape-design/components'; 15 | 16 | export default function ({ status }: { status: 'succeeded' | 'failed' | string | undefined | null }) { 17 | switch (status) { 18 | case 'succeeded': 19 | return Succeeded; 20 | case 'in-progress': 21 | return In progress; 22 | case 'pending': 23 | return Pending; 24 | case 'failed': 25 | return Failed; 26 | default: 27 | return '-'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/pages/Fields/ListFields.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { useParams } from 'react-router-dom'; 15 | import Breadcrumbs from '../../shared/Breadcrumbs'; 16 | import Shell from '../../shared/Shell'; 17 | import FieldsTable from './FieldsTable'; 18 | 19 | export default function ListFields() { 20 | const { growerId, farmId } = useParams(); 21 | 22 | return ( 23 | } 25 | contentType="table" 26 | content={} 27 | /> 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/shared/Breadcrumbs.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import BreadcrumbGroup, { BreadcrumbGroupProps } from '@cloudscape-design/components/breadcrumb-group'; 15 | import { useNavigate } from 'react-router-dom'; 16 | 17 | export default function ({ items }: { items: BreadcrumbGroupProps['items'] }) { 18 | const navigate = useNavigate(); 19 | return ( 20 | { 22 | event.preventDefault(); 23 | navigate(event.detail.href); 24 | }} 25 | items={[{ text: 'AGIE', href: '/' }, ...items]} 26 | ariaLabel="Breadcrumbs" 27 | /> 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/shared/Shell.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { AppLayout, AppLayoutProps } from '@cloudscape-design/components'; 15 | import SideNavigation from './SideNavigation'; 16 | import TopNavigation from './TopNavigation'; 17 | 18 | export interface ShellProps { 19 | breadcrumbs: AppLayoutProps['breadcrumbs']; 20 | contentType: AppLayoutProps['contentType']; 21 | content: AppLayoutProps['content']; 22 | } 23 | export default function Shell(props: ShellProps) { 24 | return ( 25 | <> 26 | 27 | } contentType={props.contentType} content={props.content}> 28 | 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | /// 15 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/upload-to-s3.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 7 | # with the License. A copy of the License is located at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 12 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 13 | # and limitations under the License. 14 | # 15 | 16 | # Retrieve the website hosting bucket 17 | AGIE_WEBSITE_BUCKET=$(aws ssm get-parameters --names /agie/${ENVIRONMENT}/ui/websiteBucket --query 'Parameters[0].Value' --output text --region $AWS_REGION) 18 | 19 | # Upload the bundled artifacts to the bucket 20 | aws s3 sync ./dist s3://"$AGIE_WEBSITE_BUCKET" --region $AWS_REGION 21 | -------------------------------------------------------------------------------- /typescript/packages/apps/ui/vite.config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { defineConfig } from 'vite' 15 | import react from '@vitejs/plugin-react' 16 | 17 | // https://vitejs.dev/config/ 18 | export default defineConfig({ 19 | plugins: [react()], 20 | }) 21 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/integration-tests 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.2.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Added new integration tests for engine API, including tests for registering regions to engines, creating/listing/deleting engines, and running processing with a new engine 11 | - Added new utility functions for engine-related API calls in common.utils.ts 12 | 13 | ### Patches 14 | 15 | - Updated localConfigGenerator.ts to include engine-related environment variables 16 | 17 | ## 0.1.0 18 | Thu, 31 Oct 2024 05:15:58 GMT 19 | 20 | ### Minor changes 21 | 22 | - Added new integration tests for executor module 23 | 24 | ### Patches 25 | 26 | - Added executor API URL to local config generator 27 | - Updated createResourcesMethodForModules to include executor module 28 | 29 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/README.md: -------------------------------------------------------------------------------- 1 | # Integration Tests 2 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/integration-tests", 3 | "version": "0.2.0", 4 | "description": "Framework wide integration tests.", 5 | "type": "module", 6 | "scripts": { 7 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 8 | "build": "npx tsc -b", 9 | "test": "npm run build", 10 | "test:integration": "npm run build && vitest run", 11 | "pretest": "npx tsx src/localConfigGenerator.ts" 12 | }, 13 | "devDependencies": { 14 | "@types/aws4": "~1", 15 | "@agie/regions": "workspace:*", 16 | "@agie/clients": "workspace:*", 17 | "@aws-amplify/core": "~6", 18 | "@aws-amplify/auth": "~6", 19 | "aws-amplify": "~6", 20 | "@aws-sdk/client-ssm": "~3", 21 | "@aws-sdk/client-sts": "~3", 22 | "@aws-sdk/credential-providers": "~3", 23 | "@aws-sdk/client-cloudformation": "~3", 24 | "@aws-sdk/client-secrets-manager": "~3", 25 | "@aws-sdk/client-eventbridge": "~3", 26 | "@opensearch-project/opensearch": "~2", 27 | "@aws-sdk/client-cognito-identity-provider": "~3", 28 | "@tsconfig/node20": "~20", 29 | "@types/node": "~22", 30 | "@vitest/ui": "~2", 31 | "dayjs": "~1", 32 | "dotenv": "~16", 33 | "eslint": "~9", 34 | "jwt-encode": "~1", 35 | "pactum-matchers": "~1", 36 | "pactum": "~3", 37 | "shx": "~0", 38 | "tsx": "~4", 39 | "typescript": "~5", 40 | "vitest-mock-extended": "~2", 41 | "vitest": "~2", 42 | "ulid": "~2", 43 | "aws4": "~1" 44 | }, 45 | "private": false, 46 | "dependencies": { 47 | "p-wait-for": "~5" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/engine/engine.data.ts: -------------------------------------------------------------------------------- 1 | import { ID_PATTERN, ISO8601_DATE_TIME_MS_PATTERN } from '../utils/regex.js'; 2 | 3 | export const ENGINE_INTEGRATION_TEST_TAG_KEY = 'created-by-integration-test'; 4 | export const ENGINE_INTEGRATION_TEST_TAG_VALUE = 'engine-module-resources'; 5 | 6 | export const create_execution_task_body = (regionId: string): object => { 7 | return { 8 | regionId: regionId, 9 | startDateTime: '2023-02-01T09:30:00.000Z', 10 | endDateTime: '2023-03-01T09:30:00.000Z', 11 | interval: { 12 | duration: 1, 13 | unit: 'month', 14 | }, 15 | }; 16 | }; 17 | 18 | export const created_execution_task_resource = (username: string, regionId: string): object => { 19 | return { 20 | ...create_execution_task_body(regionId), 21 | id: ID_PATTERN, 22 | createdAt: ISO8601_DATE_TIME_MS_PATTERN, 23 | createdBy: username, 24 | taskStatus: 'waiting', 25 | }; 26 | }; 27 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/executor/executor.data.ts: -------------------------------------------------------------------------------- 1 | import { ID_PATTERN, ISO8601_DATE_TIME_MS_PATTERN } from '../utils/regex.js'; 2 | 3 | export const EXECUTOR_INTEGRATION_TEST_TAG_KEY = 'created-by-integration-test'; 4 | export const EXECUTOR_INTEGRATION_TEST_TAG_VALUE = 'executor-module-resources'; 5 | 6 | export const create_execution_task_body = (regionId: string): object => { 7 | return { 8 | regionId: regionId, 9 | startDateTime: '2023-02-01T09:30:00.000Z', 10 | endDateTime: '2023-04-01T09:30:00.000Z', 11 | interval: { 12 | duration: 1, 13 | unit: 'month', 14 | }, 15 | }; 16 | }; 17 | 18 | export const created_execution_task_resource = (username: string, regionId: string): object => { 19 | return { 20 | ...create_execution_task_body, 21 | id: ID_PATTERN, 22 | createdAt: ISO8601_DATE_TIME_MS_PATTERN, 23 | createdBy: username, 24 | taskStatus: 'waiting', 25 | }; 26 | }; 27 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/notifications/notifications.data.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export const NOTIFICATIONS_INTEGRATION_TEST_TAG_KEY = 'created-by-integration-test'; 15 | export const NOTIFICATIONS_INTEGRATION_TEST_TAG_VALUE = 'notifications-module-notifications'; 16 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/utils/config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import * as dotenv from 'dotenv'; 15 | import path from 'path'; 16 | 17 | export const initializeConfig = (pathToRoot: string, print = true): void => { 18 | dotenv.config({ 19 | /* 20 | * Semgrep issue https://sg.run/OPqk 21 | * Ignore reason: This path is not being specified by user 22 | */ 23 | // nosemgrep 24 | path: path.join(pathToRoot, 'local.env'), 25 | debug: true, 26 | }); 27 | 28 | if (print) { 29 | printConfig(); 30 | } 31 | }; 32 | 33 | export const printConfig = () => { 34 | console.log('==================== Config: ==================== '); 35 | Object.entries(process.env) 36 | .filter(([k]) => k.startsWith('AGIE_')) 37 | .sort((a, b) => a[0].localeCompare(b[0])) 38 | .forEach(([key, value]) => { 39 | console.log(`\t${key}: ${value}`); 40 | }); 41 | console.log('================================================= '); 42 | }; 43 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/utils/generateToken.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { authorizeUser } from './auth.js'; 15 | import { getParameter } from './ssm.js'; 16 | 17 | const [environment, username, password, newPassword] = process.argv.slice(2); 18 | 19 | console.log(environment, username, password, newPassword); 20 | if (process.argv.length < 3) { 21 | throw new Error('Missing arguments\r\nHow to run the command: \r\n> npm run generate:token -- '); 22 | } 23 | (async () => { 24 | process.env.COGNITO_CLIENT_ID = await getParameter(`/agie/${environment}/shared/cognitoUserPoolClientId`); 25 | process.env.COGNITO_USER_POOL_ID = await getParameter(`/agie/${environment}/shared/cognitoUserPoolId`); 26 | console.log('authorizeUser'); 27 | const token = await authorizeUser(username, password, newPassword); 28 | console.log(token); 29 | })().catch((e) => console.log(e)); 30 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/utils/headers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export type AuthenticationType = 'token' | 'apiKey'; 15 | 16 | export const COMMON_HEADERS = (idToken: string | undefined) => { 17 | const common = { 18 | 'Content-Type': 'application/json', 19 | Accept: 'application/json', 20 | 'Accept-Version': '1.0.0', 21 | }; 22 | if (!idToken) return common; 23 | common['Authorization'] = `Bearer ${idToken}`; 24 | return common; 25 | }; 26 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/utils/regex.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export const ID_PATTERN = /^[a-z0-9]{26}$/; 15 | 16 | export const UUID_PATTERN = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/ 17 | 18 | export const PAGINATION_TOKEN_PATTERN = /^[\w\W]+$/; 19 | 20 | export const ISO8601_DATE_TIME_MS_PATTERN = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d.\d+([+-][0-2]\d(:?[0-5]\d)?|Z)$/; 21 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/src/utils/ssm.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { GetParameterCommand, SSMClient } from '@aws-sdk/client-ssm'; 15 | 16 | export async function getParameter(path: string): Promise { 17 | const ssm = new SSMClient({}); 18 | const response = await ssm.send( 19 | new GetParameterCommand({ 20 | Name: path, 21 | }) 22 | ); 23 | return response.Parameter?.Value as string; 24 | } 25 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | "noPropertyAccessFromIndexSignature": false, 13 | 14 | // overrides of extends 15 | "strict": false, 16 | "exactOptionalPropertyTypes": false 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /typescript/packages/integration-tests/vitest.config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { defineConfig } from 'vitest/config'; 15 | 16 | export default defineConfig({ 17 | test: { 18 | testTimeout: 30_000, 19 | exclude: ['**/node_modules/**', '.history', 'dist'], 20 | 21 | globals: true, 22 | 23 | ////// none of these work: 24 | // testTimeout: 600000, 25 | hookTimeout: 60_000, 26 | // teardownTimeout: 600000, 27 | 28 | // onConsoleLog(log: string, type: 'stdout' | 'stderr'): false | void { 29 | // console.log('log in test: ', log); 30 | // if (log === 'message from third party library' && type === 'stdout') { 31 | // return false; 32 | // } 33 | // }, 34 | }, 35 | }); 36 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/cdk-common", 3 | "entries": [ 4 | { 5 | "version": "0.1.0", 6 | "tag": "@agie/cdk-common_v0.1.0", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "minor": [ 10 | { 11 | "comment": "Added new esbuild.ts file for bundling lambda functions" 12 | } 13 | ], 14 | "patch": [ 15 | { 16 | "comment": "Updated package.json to include new build and bundle scripts" 17 | }, 18 | { 19 | "comment": "Added new dependencies esbuild and ts-node" 20 | }, 21 | { 22 | "comment": "Updated tsconfig.json to exclude esbuild.ts" 23 | } 24 | ] 25 | } 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/cdk-common 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.1.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Added new esbuild.ts file for bundling lambda functions 11 | 12 | ### Patches 13 | 14 | - Updated package.json to include new build and bundle scripts 15 | - Added new dependencies esbuild and ts-node 16 | - Updated tsconfig.json to exclude esbuild.ts 17 | 18 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/esbuild.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { build } from 'esbuild'; 15 | 16 | const banner = ` 17 | import { createRequire } from 'module'; 18 | const require = createRequire(import.meta.url); 19 | import { fileURLToPath } from 'url'; 20 | import { dirname } from 'path'; 21 | const __filename = fileURLToPath(import.meta.url); 22 | const __dirname = dirname(__filename); 23 | `; 24 | 25 | console.log(`Processing release build...`); 26 | build({ 27 | bundle: true, 28 | entryPoints: ['src/dynamodb-seeder/lambdas/index.ts'], 29 | minify: false, 30 | format: 'esm', 31 | platform: 'node', 32 | target: 'node20', 33 | sourcemap: false, 34 | sourcesContent: false, 35 | outfile: 'dist/dynamodb-seeder/lambdas/index.mjs', 36 | banner: { 37 | js: banner, 38 | }, 39 | }); 40 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/src/context/util.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | import type { App } from 'aws-cdk-lib'; 14 | 15 | const tryGetBooleanContext = (app: App, contextName: string, defaultValue: boolean): boolean => { 16 | const contextValue = app.node.tryGetContext(contextName); 17 | if (contextValue === undefined) return defaultValue; 18 | // if it's boolean return as it is 19 | if (typeof contextValue === 'boolean') return contextValue; 20 | // if it's string check if its equal to 'true' 21 | return contextValue === 'true'; 22 | }; 23 | 24 | function getOrThrow(app: App, name: string): string { 25 | const attribute = app.node.tryGetContext(name) as string; 26 | if (attribute === undefined) { 27 | throw new Error(`'${name}' is required`); 28 | } 29 | return attribute; 30 | } 31 | 32 | export { getOrThrow, tryGetBooleanContext }; 33 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/src/environment/util.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { STS } from '@aws-sdk/client-sts'; 15 | 16 | export interface AwsEnvironment { 17 | accountId?: string; 18 | region?: string; 19 | } 20 | 21 | const getAwsEnvironment = async (): Promise => { 22 | const sts = new STS({}); 23 | 24 | let accountId, region; 25 | try { 26 | const callerIdentity = await sts.getCallerIdentity({}); 27 | accountId = callerIdentity.Account; 28 | region = await sts.config.region(); 29 | } catch (Exception) { 30 | console.log(`Could not retrieve caller identity when fetching environment`); 31 | } 32 | 33 | return { 34 | accountId, 35 | region, 36 | }; 37 | }; 38 | 39 | export { getAwsEnvironment }; 40 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/src/facts/facts.utils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Fact } from 'aws-cdk-lib/region-info'; 15 | import { factMappings, RegionMapping } from './fact-tables.js'; 16 | 17 | function registerFact(factName: string, regionMapping: RegionMapping) { 18 | for (const [region, value] of Object.entries(regionMapping)) { 19 | Fact.register({ 20 | region, 21 | name: factName, 22 | value: value, 23 | }); 24 | } 25 | } 26 | export function registerAllFacts(): void { 27 | for (const [factName, regionMapping] of Object.entries(factMappings)) { 28 | registerFact(factName, regionMapping); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/src/facts/lambdaArchitecture.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Stack, Token } from 'aws-cdk-lib'; 15 | import { Architecture } from 'aws-cdk-lib/aws-lambda'; 16 | import type { Construct } from 'constructs'; 17 | import { FactNames } from './fact-tables.js'; 18 | 19 | export function getLambdaArchitecture(scope: Construct): Architecture { 20 | const preferredArchitecture = Stack.of(scope).regionalFact(FactNames.PREFERRED_LAMBDA_ARCHITECTURE, Architecture.X86_64.name); 21 | if (Token.isUnresolved(preferredArchitecture)) { 22 | return Architecture.custom(preferredArchitecture); 23 | } 24 | return preferredArchitecture === Architecture.ARM_64.name ? Architecture.ARM_64 : Architecture.X86_64; 25 | } 26 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './context/util.js'; 15 | export * from './dynamodb-seeder/dynamodb-seeder.js'; 16 | export * from './dynamodb-seeder/seeds.js'; 17 | export * from './environment/util.js'; 18 | export * from './eventBridge/eventbus.construct.js'; 19 | export * from './facts/facts.utils.js'; 20 | export * from './facts/lambdaArchitecture.js'; 21 | export * from './s3/s3.construct.js'; 22 | -------------------------------------------------------------------------------- /typescript/packages/libraries/cdk-common/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | "noPropertyAccessFromIndexSignature": false, 13 | 14 | // overrides of extends 15 | "strict": false, 16 | "exactOptionalPropertyTypes": false, 17 | 18 | "composite": true 19 | }, 20 | "include": ["src/**/*.ts"], 21 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules", "esbuild.ts"] 22 | } 23 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/clients", 3 | "entries": [ 4 | { 5 | "version": "1.1.0", 6 | "tag": "@agie/clients_v1.1.0", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "minor": [ 10 | { 11 | "comment": "Added new EnginesClient class with a 'get' method to retrieve engine resources" 12 | }, 13 | { 14 | "comment": "Added new EngineResource interface to define the structure of engine resources" 15 | }, 16 | { 17 | "comment": "Updated index.ts to export new engines-related modules" 18 | } 19 | ], 20 | "dependency": [ 21 | { 22 | "comment": "Updating dependency \"@agie/events\" to `0.2.0`" 23 | } 24 | ] 25 | } 26 | }, 27 | { 28 | "version": "1.0.1", 29 | "tag": "@agie/clients_v1.0.1", 30 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 31 | "comments": { 32 | "dependency": [ 33 | { 34 | "comment": "Updating dependency \"@agie/events\" to `0.1.0`" 35 | } 36 | ] 37 | } 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/clients 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 1.1.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Added new EnginesClient class with a 'get' method to retrieve engine resources 11 | - Added new EngineResource interface to define the structure of engine resources 12 | - Updated index.ts to export new engines-related modules 13 | 14 | ## 1.0.1 15 | Thu, 31 Oct 2024 05:15:58 GMT 16 | 17 | _Initial release_ 18 | 19 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/clients", 3 | "version": "1.1.0", 4 | "description": "Client library", 5 | "author": "Pouya Bahavar ", 6 | "exports": { 7 | ".": { 8 | "import": "./dist/index.js" 9 | } 10 | }, 11 | "types": "./dist/index.d.js", 12 | "type": "module", 13 | "scripts": { 14 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 15 | "build": "npx tsc -b", 16 | "test": "npm run build && vitest run --passWithNoTests" 17 | }, 18 | "dependencies": { 19 | "@agie/events": "workspace:*", 20 | "@agie/lambda-invoker": "workspace:*", 21 | "@aws-sdk/client-lambda": "~3", 22 | "ow": "~2", 23 | "@aws-sdk/client-sns": "~3", 24 | "@aws-sdk/client-secrets-manager": "~3", 25 | "axios": "~1" 26 | }, 27 | "devDependencies": { 28 | "@tsconfig/node20": "~20", 29 | "@types/node": "~22", 30 | "@typescript-eslint/eslint-plugin": "~8", 31 | "@typescript-eslint/parser": "~8", 32 | "aws-sdk-client-mock": "~4", 33 | "eslint": "~9", 34 | "pino-pretty": "~11", 35 | "pino": "~9", 36 | "shx": "~0", 37 | "tsx": "~4", 38 | "typescript": "~5", 39 | "vitest-mock-extended": "~2", 40 | "vitest": "~2", 41 | "axios": "~1", 42 | "aws4-axios": "~3" 43 | }, 44 | "private": false 45 | } 46 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/src/clients/engines.models.ts: -------------------------------------------------------------------------------- 1 | export interface EngineResource { 2 | id: string; 3 | name: string; 4 | jobRoleArn: string; 5 | jobDefinitionArn: string; 6 | image: string; 7 | memory: number; 8 | vcpus: number; 9 | } 10 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/src/clients/results.models.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export interface ListResultsOptions { 15 | paginationToken?: string; 16 | count?: number; 17 | status?: 'queued' | 'starting' | 'inProgress' | 'failed' | 'succeeded'; 18 | } 19 | 20 | export interface ResultResource { 21 | regionId: string; 22 | id: string; 23 | startDateTime: string; 24 | endDateTime: string; 25 | executionId: string; 26 | createdAt: string; 27 | updatedAt?: string; 28 | message?: string; 29 | engineType: string; 30 | status: string; 31 | } 32 | 33 | export interface ResultListResource { 34 | results: ResultResource[]; 35 | pagination?: { 36 | count: number; 37 | lastEvaluatedToken: string; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/src/clients/stacServer.model.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export interface SearchRequest { 15 | limit?: number; 16 | bbox: number[]; 17 | datetime?: string; 18 | ids?: string[]; 19 | collections: string[]; 20 | query?: Record 21 | } 22 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/src/common/models.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export interface LambdaRequestContext { 15 | authorizer: { 16 | claims: { 17 | email: string; 18 | 'custom:role': string; 19 | }; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './clients/engines.client.js'; 15 | export * from './clients/engines.models.js'; 16 | export * from './clients/regions.client.js'; 17 | export * from './clients/regions.models.js'; 18 | export * from './clients/results.client.js'; 19 | export * from './clients/results.models.js'; 20 | export * from './clients/stacServer.client.js'; 21 | export * from './common/models.js'; 22 | -------------------------------------------------------------------------------- /typescript/packages/libraries/clients/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "composite": true, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "esModuleInterop": true, 12 | "ignoreDeprecations": "5.0", 13 | // overrides of extends 14 | "strict": false, 15 | "exactOptionalPropertyTypes": false 16 | }, 17 | "include": ["src/**/*.ts"], 18 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/libraries/dynamodb-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/dynamodb-utils", 3 | "version": "0.0.1", 4 | "description": "Common DynamoDB utils.", 5 | "author": "Dean Hart ", 6 | "exports": { 7 | ".": { 8 | "import": "./dist/index.js" 9 | } 10 | }, 11 | "types": "./dist/index.d.js", 12 | "type": "module", 13 | "scripts": { 14 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 15 | "build": "npx tsc -b", 16 | "test": "npm run build && vitest run --passWithNoTests" 17 | }, 18 | "dependencies": { 19 | "@aws-sdk/client-dynamodb": "~3", 20 | "@aws-sdk/lib-dynamodb": "~3", 21 | "@aws-sdk/types": "~3", 22 | "@aws-sdk/util-dynamodb": "~3", 23 | "pino": "~9", 24 | "pino-pretty": "~11" 25 | }, 26 | "devDependencies": { 27 | "@tsconfig/node20": "~20", 28 | "@types/node": "~22", 29 | "eslint": "~9", 30 | "shx": "~0", 31 | "tsx": "~4", 32 | "typescript": "~5", 33 | "vitest": "~2", 34 | "vitest-mock-extended": "~2" 35 | }, 36 | "private": false 37 | } 38 | -------------------------------------------------------------------------------- /typescript/packages/libraries/dynamodb-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './dynamoDb.util.js'; 15 | export * from './pkUtils.util.js'; 16 | -------------------------------------------------------------------------------- /typescript/packages/libraries/dynamodb-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": [ 7 | "node" 8 | ], 9 | "declaration": true, 10 | "declarationMap": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "ignoreDeprecations": "5.0", 14 | "noPropertyAccessFromIndexSignature": false, 15 | 16 | // overrides of extends 17 | "strict": false, 18 | "exactOptionalPropertyTypes": false 19 | }, 20 | "include": [ 21 | "src/**/*.ts" 22 | ], 23 | "exclude": [ 24 | "./**/__mocks__/*.ts", 25 | ".git", 26 | ".history", 27 | ".vscode", 28 | "cdk.out", 29 | "dist", 30 | "lib", 31 | "node_modules" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/libraries/events/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/events", 3 | "entries": [ 4 | { 5 | "version": "0.2.0", 6 | "tag": "@agie/events_v0.2.0", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "minor": [ 10 | { 11 | "comment": "Added new property 'engineId' to ProcessingConfig interface" 12 | } 13 | ] 14 | } 15 | }, 16 | { 17 | "version": "0.1.0", 18 | "tag": "@agie/events_v0.1.0", 19 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 20 | "comments": { 21 | "minor": [ 22 | { 23 | "comment": "Added new optional property 'taskId' to StartJobRequest type" 24 | } 25 | ] 26 | } 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /typescript/packages/libraries/events/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/events 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.2.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Added new property 'engineId' to ProcessingConfig interface 11 | 12 | ## 0.1.0 13 | Thu, 31 Oct 2024 05:15:58 GMT 14 | 15 | ### Minor changes 16 | 17 | - Added new optional property 'taskId' to StartJobRequest type 18 | 19 | -------------------------------------------------------------------------------- /typescript/packages/libraries/events/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/events", 3 | "version": "0.2.0", 4 | "description": "Agie events", 5 | "author": "William Sia ", 6 | "exports": { 7 | ".": { 8 | "import": "./dist/index.js", 9 | "require": "./dist/index.cjs" 10 | } 11 | }, 12 | "main": "./dist/index.cjs", 13 | "types": "./dist/index.d.js", 14 | "type": "module", 15 | "scripts": { 16 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 17 | "build": "npx tsc -b", 18 | "test": "npm run build && vitest run --passWithNoTests" 19 | }, 20 | "dependencies": { 21 | "@aws-sdk/client-eventbridge": "~3", 22 | "@sinclair/typebox": "~0" 23 | }, 24 | "devDependencies": { 25 | "@tsconfig/node20": "~20", 26 | "@types/node": "~22", 27 | "@typescript-eslint/eslint-plugin": "~8", 28 | "@typescript-eslint/parser": "~8", 29 | "aws-sdk-client-mock": "~4", 30 | "eslint": "~9", 31 | "pino": "~9", 32 | "shx": "~0", 33 | "typescript": "~5", 34 | "vitest": "~2", 35 | "vitest-mock-extended": "~2" 36 | }, 37 | "private": false 38 | } 39 | -------------------------------------------------------------------------------- /typescript/packages/libraries/events/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './common/models.js'; 15 | export * from './publisher.js'; 16 | export * from './regions/models.js'; 17 | export * from './results/models.js'; 18 | -------------------------------------------------------------------------------- /typescript/packages/libraries/events/src/regions/models.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export type Priority = 'low' | 'standard' | 'high'; 15 | 16 | export type Mode = 'scheduled' | 'disabled' | 'onNewScene'; 17 | 18 | export interface ProcessingConfig { 19 | mode: Mode; 20 | priority?: Priority; 21 | scheduleExpression?: string; 22 | scheduleExpressionTimezone?: string; 23 | engineId?: string; 24 | } 25 | 26 | export interface RegionResource { 27 | id: string; 28 | groupId: string; 29 | name: string; 30 | boundingBox: number[]; 31 | processingConfig: ProcessingConfig; 32 | tags?: Record; 33 | attributes?: Record; 34 | createdAt: string; 35 | createdBy: string; 36 | updatedAt?: string; 37 | updatedBy?: string; 38 | } 39 | -------------------------------------------------------------------------------- /typescript/packages/libraries/events/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "composite": true, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "esModuleInterop": true, 12 | "ignoreDeprecations": "5.0", 13 | // overrides of extends 14 | "strict": false, 15 | "exactOptionalPropertyTypes": false 16 | }, 17 | "include": ["src/**/*.ts"], 18 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/libraries/helpers/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/helpers", 3 | "entries": [ 4 | { 5 | "version": "0.0.3", 6 | "tag": "@agie/helpers_v0.0.3", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "dependency": [ 10 | { 11 | "comment": "Updating dependency \"@agie/infrastructure\" to `0.2.0`" 12 | }, 13 | { 14 | "comment": "Updating dependency \"@agie/infrastructure\" to `0.2.0`" 15 | } 16 | ] 17 | } 18 | }, 19 | { 20 | "version": "0.0.2", 21 | "tag": "@agie/helpers_v0.0.2", 22 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 23 | "comments": { 24 | "dependency": [ 25 | { 26 | "comment": "Updating dependency \"@agie/infrastructure\" to `0.1.0`" 27 | }, 28 | { 29 | "comment": "Updating dependency \"@agie/infrastructure\" to `0.1.0`" 30 | } 31 | ] 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /typescript/packages/libraries/helpers/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/helpers 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.0.3 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | _Version update only_ 9 | 10 | ## 0.0.2 11 | Thu, 31 Oct 2024 05:15:58 GMT 12 | 13 | _Initial release_ 14 | 15 | -------------------------------------------------------------------------------- /typescript/packages/libraries/helpers/esbuild.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { build } from 'esbuild'; 15 | 16 | const banner = ` 17 | import { createRequire } from 'module'; 18 | const require = createRequire(import.meta.url); 19 | import { fileURLToPath } from 'url'; 20 | import { dirname } from 'path'; 21 | const __filename = fileURLToPath(import.meta.url); 22 | const __dirname = dirname(__filename); 23 | `; 24 | 25 | console.log(`Processing release build...`); 26 | build({ 27 | bundle: true, 28 | entryPoints: ['src/index.ts'], 29 | minify: false, 30 | format: 'esm', 31 | platform: 'node', 32 | target: 'node20', 33 | sourcemap: false, 34 | sourcesContent: false, 35 | outfile: 'dist/index.mjs', 36 | banner: { 37 | js: banner, 38 | }, 39 | }); 40 | -------------------------------------------------------------------------------- /typescript/packages/libraries/helpers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/helpers", 3 | "version": "0.0.3", 4 | "description": "AGIE helpers.", 5 | "author": "Dean Hart ", 6 | "type": "module", 7 | "exports": { 8 | ".": { 9 | "import": "./dist/index.js", 10 | "require": "./dist/index.cjs" 11 | } 12 | }, 13 | "main": "./dist/index.cjs", 14 | "types": "./dist/index.d.js", 15 | "scripts": { 16 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 17 | "build": "npx tsc -b", 18 | "test": "npm run build && vitest run --passWithNoTests", 19 | "build:bundled": "npx tsx esbuild.ts" 20 | }, 21 | "dependencies": { 22 | "@agie/infrastructure": "workspace:*", 23 | "@aws-amplify/auth": "~6", 24 | "@aws-sdk/client-ssm": "~3", 25 | "aws-amplify": "~6", 26 | "ow": "~2" 27 | }, 28 | "devDependencies": { 29 | "@tsconfig/node20": "~20", 30 | "@types/aws-lambda": "~8", 31 | "@types/node": "~22", 32 | "@agie/infrastructure": "workspace:*", 33 | "@typescript-eslint/eslint-plugin": "~8", 34 | "@typescript-eslint/parser": "~8", 35 | "aws-cdk": "~2", 36 | "cdk-nag": "~2", 37 | "esbuild": "~0", 38 | "eslint": "~9", 39 | "shx": "~0", 40 | "tsx": "~4", 41 | "typescript": "~5", 42 | "vitest": "~2", 43 | "vitest-mock-extended": "~2" 44 | }, 45 | "private": false 46 | } 47 | -------------------------------------------------------------------------------- /typescript/packages/libraries/helpers/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './auth.js'; 15 | -------------------------------------------------------------------------------- /typescript/packages/libraries/helpers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | "noPropertyAccessFromIndexSignature": false, 13 | 14 | // overrides of extends 15 | "strict": false, 16 | "exactOptionalPropertyTypes": false 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /typescript/packages/libraries/lambda-invoker/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/lambda-invoker", 3 | "version": "1.0.0", 4 | "description": "Lambda Invoker", 5 | "author": "Dean Hart ", 6 | "exports": { 7 | ".": { 8 | "import": "./dist/index.js" 9 | } 10 | }, 11 | "types": "./dist/index.d.js", 12 | "type": "module", 13 | "scripts": { 14 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 15 | "build": "npx tsc -b", 16 | "test": "npm run build && vitest run --passWithNoTests" 17 | }, 18 | "dependencies": { 19 | "@aws-sdk/client-lambda": "~3", 20 | "@aws-sdk/util-utf8-node": "~3", 21 | "@aws-sdk/client-sso-oidc": "~3", 22 | "http-errors": "~2", 23 | "js-yaml": "~4", 24 | "readable-stream": "~4" 25 | }, 26 | "devDependencies": { 27 | "@tsconfig/node20": "~20", 28 | "@types/http-errors": "~2", 29 | "@types/node": "~22", 30 | "@typescript-eslint/eslint-plugin": "~8", 31 | "@typescript-eslint/parser": "~8", 32 | "aws-sdk-client-mock": "~4", 33 | "eslint": "~9", 34 | "pino": "~9", 35 | "shx": "~0", 36 | "tsx": "~4", 37 | "typescript": "~5", 38 | "vitest": "~2", 39 | "vitest-mock-extended": "~2" 40 | }, 41 | "private": false 42 | } 43 | -------------------------------------------------------------------------------- /typescript/packages/libraries/lambda-invoker/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './invoker.js'; 15 | export * from './models.js'; 16 | -------------------------------------------------------------------------------- /typescript/packages/libraries/lambda-invoker/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | "noPropertyAccessFromIndexSignature": false, 13 | // overrides of extends 14 | "strict": false, 15 | "exactOptionalPropertyTypes": false 16 | }, 17 | "include": ["src/**/*.ts"], 18 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 19 | } 20 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/resource-api-base", 3 | "entries": [ 4 | { 5 | "version": "1.0.1", 6 | "tag": "@agie/resource-api-base_v1.0.1", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "patch": [ 10 | { 11 | "comment": "Changed the name property of InvalidRequestError from 'InvalidRequest' to 'InvalidRequestError'" 12 | } 13 | ] 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/resource-api-base 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 1.0.1 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Patches 9 | 10 | - Changed the name property of InvalidRequestError from 'InvalidRequest' to 'InvalidRequestError' 11 | 12 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/README.md: -------------------------------------------------------------------------------- 1 | # resource-api-base library 2 | 3 | ## Introduction 4 | 5 | This library acts as the base for all resource apis. It provides common config, and dependency injection functionality. 6 | 7 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/src/common/models.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import type { NativeAttributeValue } from '@aws-sdk/util-dynamodb'; 15 | import type { Static } from '@sinclair/typebox'; 16 | import type { configuration, configurationSource } from './schemas.js'; 17 | 18 | export type DynamoDbItem = Record; 19 | export type Configuration = Static; 20 | export type ConfigurationSource = Static; 21 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './common/errors.js'; 15 | export * from './common/models.js'; 16 | export * from './common/schemas.js'; 17 | export * from './common/types.js'; 18 | export * from './common/utils.js'; 19 | export * from './plugins/base.awilix.js'; 20 | export * from './plugins/base.config.js'; 21 | export * from './resources/models.js'; 22 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/src/plugins/base.config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | import { Static, Type } from '@sinclair/typebox'; 15 | 16 | // eslint-disable-next-line @rushstack/typedef-var 17 | export const baseConfigSchema = Type.Object({ 18 | AWS_REGION: Type.String(), 19 | LOG_LEVEL: Type.String({ default: 'info' }), 20 | NODE_ENV: Type.String(), 21 | EVENT_BUS_NAME: Type.String(), 22 | TABLE_NAME: Type.Optional(Type.String()), 23 | MODULE_NAME: Type.Optional(Type.String()), 24 | }); 25 | 26 | export type BaseConfigSchemaType = Static; 27 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/src/resources/models.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export interface Resource { 15 | id: string; 16 | keyPrefix: string; 17 | alternateId?: string; 18 | } 19 | 20 | export interface ListIdsPaginationTokenKey { 21 | paginationToken: string; 22 | } 23 | 24 | export interface ListIdsPaginationOptions { 25 | count?: number; 26 | from?: ListIdsPaginationKey; 27 | } 28 | 29 | export interface ListIdsPaginationKey { 30 | id: string; 31 | groupId?: string; 32 | } 33 | -------------------------------------------------------------------------------- /typescript/packages/libraries/resource-api-base/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "composite": true, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "esModuleInterop": true, 12 | "ignoreDeprecations": "5.0", 13 | // overrides of extends 14 | "strict": false, 15 | "exactOptionalPropertyTypes": false, 16 | "allowSyntheticDefaultImports": true 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /typescript/packages/libraries/rest-api-authorizer/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/rest-api-authorizer", 3 | "entries": [ 4 | { 5 | "version": "0.1.0", 6 | "tag": "@agie/rest-api-authorizer_v0.1.0", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "patch": [ 10 | { 11 | "comment": "Added new dependency 'jwt-decode' to package.json" 12 | } 13 | ], 14 | "minor": [ 15 | { 16 | "comment": "Added new exports in index.ts for 'authz.js' and 'scopes.js'" 17 | }, 18 | { 19 | "comment": "Added new file 'authz.ts' with authentication plugin implementation" 20 | }, 21 | { 22 | "comment": "Added new file 'scopes.ts' with security scope definitions" 23 | } 24 | ], 25 | "dependency": [ 26 | { 27 | "comment": "Updating dependency \"@agie/resource-api-base\" to `1.0.1`" 28 | } 29 | ] 30 | } 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /typescript/packages/libraries/rest-api-authorizer/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/rest-api-authorizer 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.1.0 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | ### Minor changes 9 | 10 | - Added new exports in index.ts for 'authz.js' and 'scopes.js' 11 | - Added new file 'authz.ts' with authentication plugin implementation 12 | - Added new file 'scopes.ts' with security scope definitions 13 | 14 | ### Patches 15 | 16 | - Added new dependency 'jwt-decode' to package.json 17 | 18 | -------------------------------------------------------------------------------- /typescript/packages/libraries/rest-api-authorizer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/rest-api-authorizer", 3 | "version": "0.1.0", 4 | "description": "REST API Authorizer.", 5 | "exports": { 6 | ".": { 7 | "import": "./dist/index.js" 8 | } 9 | }, 10 | "types": "./dist/index.d.js", 11 | "type": "module", 12 | "scripts": { 13 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 14 | "build": "npx tsc -b", 15 | "test": "npm run build && vitest run" 16 | }, 17 | "dependencies": { 18 | "@agie/resource-api-base": "workspace:*", 19 | "@aws-sdk/client-verifiedpermissions": "~3", 20 | "@aws-sdk/client-secrets-manager": "~3", 21 | "@fastify/awilix": "~6", 22 | "awilix": "~11", 23 | "aws-jwt-verify": "~4", 24 | "aws-lambda": "~1", 25 | "aws-xray-sdk": "~3", 26 | "dotenv": "~16", 27 | "fastify-plugin": "~5", 28 | "fastify": "~5", 29 | "jwt-decode": "~4", 30 | "ow": "~2", 31 | "pino-pretty": "~11", 32 | "pino": "~9" 33 | }, 34 | "devDependencies": { 35 | "@tsconfig/node20": "~20", 36 | "@types/aws-lambda": "~8", 37 | "@types/node": "~22", 38 | "aws-sdk-client-mock": "~4", 39 | "eslint": "~9", 40 | "shx": "~0", 41 | "tsx": "~4", 42 | "typescript": "~5", 43 | "vitest-mock-extended": "~2", 44 | "vitest": "~2" 45 | }, 46 | "private": false 47 | } 48 | -------------------------------------------------------------------------------- /typescript/packages/libraries/rest-api-authorizer/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export * from './apiAuthorizer.service.js'; 15 | export * from './plugins/authz.js'; 16 | export * from './plugins/rest-api-auth.awilix.js'; 17 | export * from './plugins/scopes.js'; 18 | -------------------------------------------------------------------------------- /typescript/packages/libraries/rest-api-authorizer/src/plugins/scopes.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export interface SecurityContext { 15 | email: string; 16 | role: SecurityScope; 17 | phoneNumber: string; 18 | sub: string; 19 | } 20 | 21 | export enum SecurityScope { 22 | admin = 'admin', 23 | contributor = 'contributor', 24 | reader = 'reader', 25 | } 26 | 27 | export const atLeastAdmin: SecurityScope[] = [SecurityScope.admin]; 28 | export const atLeastContributor: SecurityScope[] = [...atLeastAdmin, SecurityScope.contributor]; 29 | export const atLeastReader: SecurityScope[] = [...atLeastContributor, SecurityScope.reader]; 30 | -------------------------------------------------------------------------------- /typescript/packages/libraries/rest-api-authorizer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "composite": true, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "esModuleInterop": true, 12 | "ignoreDeprecations": "5.0", 13 | "noPropertyAccessFromIndexSignature": false, 14 | // overrides of extends 15 | "strict": false, 16 | "exactOptionalPropertyTypes": false 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /typescript/packages/seeder/CHANGELOG.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/seeder", 3 | "entries": [ 4 | { 5 | "version": "0.0.3", 6 | "tag": "@agie/seeder_v0.0.3", 7 | "date": "Tue, 19 Nov 2024 00:04:28 GMT", 8 | "comments": { 9 | "dependency": [ 10 | { 11 | "comment": "Updating dependency \"@agie/clients\" to `1.1.0`" 12 | } 13 | ] 14 | } 15 | }, 16 | { 17 | "version": "0.0.2", 18 | "tag": "@agie/seeder_v0.0.2", 19 | "date": "Thu, 31 Oct 2024 05:15:58 GMT", 20 | "comments": { 21 | "dependency": [ 22 | { 23 | "comment": "Updating dependency \"@agie/clients\" to `1.0.1`" 24 | } 25 | ] 26 | } 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /typescript/packages/seeder/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - @agie/seeder 2 | 3 | This log was last generated on Tue, 19 Nov 2024 00:04:28 GMT and should not be manually modified. 4 | 5 | ## 0.0.3 6 | Tue, 19 Nov 2024 00:04:28 GMT 7 | 8 | _Version update only_ 9 | 10 | ## 0.0.2 11 | Thu, 31 Oct 2024 05:15:58 GMT 12 | 13 | _Initial release_ 14 | 15 | -------------------------------------------------------------------------------- /typescript/packages/seeder/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@agie/seeder", 3 | "version": "0.0.3", 4 | "description": "Tools to seed AGIE deployment with some data.", 5 | "type": "module", 6 | "scripts": { 7 | "clean:package": "npx shx rm -rf dist *.log .rush tsconfig.tsbuildinfo", 8 | "build": "npx tsc -b", 9 | "seed": "npx tsx src/seedData.ts" 10 | }, 11 | "devDependencies": { 12 | "@aws-amplify/core": "~6", 13 | "@aws-amplify/auth": "~6", 14 | "aws-amplify": "~6", 15 | "@agie/clients": "workspace:*", 16 | "fast-glob": "~3", 17 | "@aws-sdk/client-ssm": "~3", 18 | "@aws-sdk/client-cognito-identity-provider": "~3", 19 | "@tsconfig/node20": "~20", 20 | "@types/node": "~22", 21 | "@vitest/ui": "~2", 22 | "dayjs": "~1", 23 | "dotenv": "~16", 24 | "eslint": "~9", 25 | "shx": "~0", 26 | "tsx": "~4", 27 | "typescript": "~5", 28 | "vitest-mock-extended": "~2", 29 | "vitest": "~2", 30 | "ulid": "~2", 31 | "axios": "~1" 32 | }, 33 | "private": false, 34 | "dependencies": {} 35 | } 36 | -------------------------------------------------------------------------------- /typescript/packages/seeder/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node20/tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "rootDir": "src", 6 | "types": ["node"], 7 | "declaration": true, 8 | "declarationMap": true, 9 | "sourceMap": true, 10 | "esModuleInterop": true, 11 | "ignoreDeprecations": "5.0", 12 | "noPropertyAccessFromIndexSignature": false, 13 | 14 | // overrides of extends 15 | "strict": false, 16 | "exactOptionalPropertyTypes": false 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["./**/__mocks__/*.ts", ".git", ".history", ".vscode", "cdk.out", "dist", "lib", "node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /vitest.workspace.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. A copy of the License is located at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES 10 | * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | export default ['typescript/packages/integration-tests/vitest.config.ts']; 15 | --------------------------------------------------------------------------------