import { ConcurrentWorkerPool } from '@cloud-copilot/job'; import type { Client, Command } from '@smithy/smithy-client'; import { AwsClientPool } from '../aws/ClientPool.js'; import { type AwsCredentialProviderWithMetaData } from '../aws/coreAuth.js'; import { type ResourceTypeParts } from '../persistence/AwsIamStore.js'; import { type AwsService } from '../services.js'; import { type Tags } from '../utils/tags.js'; import { type Sync } from './sync.js'; export type ClientConstructor = new (args: any) => Client; type CommandConstructor = new (args: any) => Command; type ShortCommandConstructor = new (args: any) => Command; export type CommandConstructors = CommandConstructor | ShortCommandConstructor; export type ExtractOutputType = T extends CommandConstructors ? InstanceType extends Command ? Output : never : never; export type ExtractInputType = T extends CommandConstructors ? InstanceType extends Command ? Input : never : never; type Pagination = { inputKey: Extract, string>; outputKey: Extract, string>; } | '::no-pagination::'; type ClientInstanceOrConstructor = InstanceType; /** * Paginates through all available resources for a given AWS API * * @param clientClass The AWS Client class to use * @param commandClass The command class to invoke for the resource * @param key The key of the resource in the command output to pull * @param paginationConfig The pagination configuration for the command, defines the keys to use for pagination, use `::no-pagination::` to indicate no pagination * @param params Optional parameters to pass to the command * @returns Returns an array of resources returned from the commandClass Response Type key */ export declare function paginateResource>(clientClassOrInstance: ClientInstanceOrConstructor, commandClass: C, key: K, paginationConfig: Pagination, params?: Partial>): Promise[K]>>; type ArrayElementType = T extends (infer E)[] ? E : never; type ResourceElementType> = ArrayElementType[K]> extends string ? { name: string; } : ArrayElementType[K]>; type PromiseType> = T extends Promise ? U : never; export type ExtraFieldsDefinition> = Record, resource: ResourceElementType, accountId: string, region: string, partition: string) => Promise>; type ExtraFieldsReturnType, T extends ExtraFieldsDefinition> = { [K in keyof T]: PromiseType> | undefined; }; export type ExtendedResourceElementType, ExtraFieldsFunc extends ExtraFieldsDefinition> = ResourceElementType & { extraFields: ExtraFieldsReturnType; }; export type ResourceSyncType, ExtraFields extends ExtraFieldsDefinition = Record Promise>> = { /** * The client to use */ client: C; /** * The command to execute */ command: Cmd; /** * The key of the resource in the command output to pull */ key: K; /** * The pagination token to get from the response and pass to the next call */ paginationConfig: Pagination; /** * The resource type parts used to sync with storage * * @param accountId the account ID of the resource * @param region the region of the resource * @returns the resource type parts */ resourceTypeParts: (accountId: string, region: string) => ResourceTypeParts; /** * Custom arguments to pass to the command, useful for filtering resources. * * @param awsId The AWS account ID being queried * @param region The region being queried * @returns a set of arguments to pass to the command */ arguments?: (awsId: string, region: string) => Partial>; /** * Indicates if the resource type is global. */ globalResourceType?: boolean; /** * The function to get the tags for a resource * @param resource The resource to get the tags for * @returns The tags for the resource, or undefined if there are no tags */ tags: (resource: ExtendedResourceElementType) => Tags | undefined; /** * Create the ARN for a resource * * @param resource the resource to create the ARN for * @param region the region the resource is in * @param accountId the account the resource is in * @returns the ARN for the resource */ arn: (resource: ResourceElementType, region: string, accountId: string, partition: string) => string; /** * The extra fields to get for a resource * @param client The client to use to get the extra fields * @param resource The resource to get the extra fields for * @returns an object of extra fields to get, where the key is the name of the field and the value is a function that returns the value of the field */ extraFields?: ExtraFields; /** * The results to persist for a resource, except for the ARN and tags, those are handled automatically. * * @param resource The resource to get the custom fields for, includes extraFields from the `extraFields` function */ results: (resource: ExtendedResourceElementType) => Record; }; /** * Creates a resource sync type and returns it. This provides cleaner syntax than * making one directly and having to define the types twice. * * @param config Configuration for the resource sync type * @returns The ResourceSyncType instance passed in. */ export declare function createResourceSyncType, const ExtraFieldsFunc extends ExtraFieldsDefinition>(config: ResourceSyncType): ResourceSyncType; /** * Paginates a ResourceSyncType and returns the resources. * * @param resourceTypeSync The configuration to use. * @param credentials The credentials to use for AWS API calls. Pass undefined to use the environment credentials. * @param region The region to get the resources for. * @returns Returns all the resources for the given type in the given region with extraFields populated. */ export declare function paginateResourceConfig, ExtraFieldsFunc extends ExtraFieldsDefinition>(resourceTypeSync: ResourceSyncType, credentials: AwsCredentialProviderWithMetaData, region: string, endpoint: string | undefined, workerPool: ConcurrentWorkerPool, awsService: AwsService, resourceType: string, clientPool: AwsClientPool): Promise[]>; /** * Create a typed sync operation for a given AWS service and resource type. * * Because of obscure typescript issues, the order of the keys in `resourceTypeSync` is important. * This order is known to work: * client, command, key, paginationConfig, arn, extraFields, tags, resourceTypeParts, results * * @param awsService the AWS service to sync * @param name the name of the sync operation * @param resourceTypeSync the resource type sync configuration * @returns The sync operation */ export declare function createTypedSyncOperation, ExtraFieldsFunc extends ExtraFieldsDefinition>(awsService: AwsService, name: string, resourceTypeSync: ResourceSyncType): Sync; export {}; //# sourceMappingURL=typedSync.d.ts.map