From b31f5bec2eae7729b05fe0458d1e01c318c69a2b Mon Sep 17 00:00:00 2001 From: Alireza Sheikholmolouki <144152467+alireza-sheikholmolouki@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:46:53 +0200 Subject: [PATCH] Exported more functionality including awsRegionsId, getProcessedData and more types (#141) * types: exported all types * feat: exported more functionality including awsRegionsId, more types and getProcessedData * Create clever-yaks-behave.md --- .changeset/clever-yaks-behave.md | 5 +++++ .../config/getConfigFromProgramArguments.ts | 4 ++-- src/constants.ts | 4 ++-- src/lib/index.ts | 19 ++++++++++++++++++- src/types.ts | 5 ++++- 5 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 .changeset/clever-yaks-behave.md diff --git a/.changeset/clever-yaks-behave.md b/.changeset/clever-yaks-behave.md new file mode 100644 index 0000000..a0dbc64 --- /dev/null +++ b/.changeset/clever-yaks-behave.md @@ -0,0 +1,5 @@ +--- +"@mirohq/cloud-data-import": minor +--- + +Exported more functionality including awsRegionsId, experimental_getProcessedData() and more types diff --git a/src/aws-app/config/getConfigFromProgramArguments.ts b/src/aws-app/config/getConfigFromProgramArguments.ts index 0271062..d09f8fb 100644 --- a/src/aws-app/config/getConfigFromProgramArguments.ts +++ b/src/aws-app/config/getConfigFromProgramArguments.ts @@ -1,4 +1,4 @@ -import {Config} from '@/types' +import {AwsRegionId, Config} from '@/types' import {awsRegionIds} from '@/constants' import {getDefaultOutputName} from './getDefaultOutputName' import {SUPPORTED_ENV_VARS, getEnvConfig} from './getEnvConfig' @@ -28,7 +28,7 @@ export const getConfigFromProgramArguments = (): Config => { return awsRegionIds } - const invalidRegions = arg.filter((region) => !awsRegionIds.includes(region)) + const invalidRegions = arg.filter((region) => !awsRegionIds.includes(region as AwsRegionId)) if (invalidRegions.length) { throw new Error( `[ERROR] Invalid region(s): ${invalidRegions.join(', ')}. Valid regions are: ${awsRegionIds.join(', ')}`, diff --git a/src/constants.ts b/src/constants.ts index c233519..f0352ab 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,6 @@ // This list is extracted from https://docs.aws.amazon.com/general/latest/gr/rande.html // Tip: check git history to see when was the last time this list was updated -export const awsRegionIds: string[] = [ +export const awsRegionIds = [ 'us-east-2', 'us-east-1', 'us-west-1', @@ -32,4 +32,4 @@ export const awsRegionIds: string[] = [ 'sa-east-1', 'us-gov-east-1', 'us-gov-west-1', -] +] as const diff --git a/src/lib/index.ts b/src/lib/index.ts index 7d6bae0..224ece7 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,7 +1,10 @@ +import {getProcessedData} from '@/aws-app/process' import {createRateLimiter, getAwsScanners} from '@/scanners' export type {GetAwsScannersArguments} from '@/scanners' -export type {Scanner, ScannerError, ScannerResult, ScannerLifecycleHook} from '@/types' +export type * from '@/types' + +export {awsRegionIds} from '@/constants' /** * @public @@ -30,3 +33,17 @@ export const experimental_createRateLimiter = createRateLimiter * - If you depend on this feature, consider pinning your package version to avoid unexpected breaks. */ export const experimental_getAwsScanner = getAwsScanners + +/** + * @public + * @experimental This export is experimental and may change or be removed in future versions. + * Use with caution. + * @remarks + * WARNING: This is an experimental API. It may undergo significant changes or be removed entirely in non-major version updates. + * Before using this in production, please consider the following: + * - This API is not covered by semantic versioning guarantees. + * - Breaking changes may occur in minor or patch releases. + * - Always check the changelog before updating, even for non-major versions. + * - If you depend on this feature, consider pinning your package version to avoid unexpected breaks. + */ +export const experimental_getProcessedData = getProcessedData diff --git a/src/types.ts b/src/types.ts index 8f4081d..c939c42 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,9 +21,12 @@ import type * as Athena from '@aws-sdk/client-athena' import type {RateLimiter} from './scanners/common/RateLimiter' import type {AwsCredentialIdentity} from '@aws-sdk/types' +import {awsRegionIds} from './constants' export type SQSQueue = NonNullable +export type AwsRegionId = (typeof awsRegionIds)[number] + export type ResourceDescription = | Athena.NamedQuery | AutoScaling.AutoScalingGroup @@ -177,7 +180,7 @@ export interface StandardOutputSchema { provider: 'aws' docVersion: string resources: Resources - processed: ProcessedData + processed?: ProcessedData errors: ScannerError[] metadata: { account: string