From 11e48e4e830d802e8b98589da5a3383ba2f89362 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 4 Mar 2026 10:01:19 -0500 Subject: [PATCH 1/3] run linter --- .../performApplicationPerformanceTest.ts | 8 +- .../performPerformanceTest.ts | 6 +- .../performTransferManagerTest.ts | 8 +- .../internal-tooling/performanceTest.ts | 6 +- .../internal-tooling/performanceUtils.ts | 26 +- handwritten/storage/src/acl.ts | 34 +-- handwritten/storage/src/bucket.ts | 206 ++++++++-------- handwritten/storage/src/channel.ts | 2 +- handwritten/storage/src/crc32c.ts | 10 +- handwritten/storage/src/file.ts | 184 +++++++-------- .../storage/src/hash-stream-validator.ts | 4 +- handwritten/storage/src/hmacKey.ts | 8 +- handwritten/storage/src/iam.ts | 32 +-- .../src/nodejs-common/service-object.ts | 36 +-- .../storage/src/nodejs-common/service.ts | 8 +- handwritten/storage/src/nodejs-common/util.ts | 58 +++-- handwritten/storage/src/notification.ts | 2 +- handwritten/storage/src/resumable-upload.ts | 32 +-- handwritten/storage/src/signer.ts | 38 +-- handwritten/storage/src/storage.ts | 56 ++--- handwritten/storage/src/transfer-manager.ts | 64 ++--- handwritten/storage/src/util.ts | 10 +- handwritten/storage/system-test/common.ts | 6 +- handwritten/storage/system-test/kitchen.ts | 26 +- handwritten/storage/system-test/storage.ts | 223 +++++++++--------- 25 files changed, 544 insertions(+), 549 deletions(-) diff --git a/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts b/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts index eedcda1f604..99b0f151f93 100644 --- a/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts +++ b/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts @@ -56,7 +56,7 @@ async function main() { ({bucket} = await performanceTestSetup( argv.project! as string, - argv.bucket! as string, + argv.bucket! as string )); switch (argv.test_type) { @@ -78,7 +78,7 @@ async function main() { async function uploadInParallel( bucket: Bucket, paths: string[], - options: UploadOptions, + options: UploadOptions ) { const promises: Promise[] = []; for (const index in paths) { @@ -115,7 +115,7 @@ async function performWriteTest(): Promise { argv.num_objects as number, TEST_NAME_STRING, fileSizeRange.low, - fileSizeRange.high, + fileSizeRange.high ); const start = performance.now(); @@ -157,7 +157,7 @@ async function performReadTest(): Promise { argv.num_objects as number, TEST_NAME_STRING, fileSizeRange.low, - fileSizeRange.high, + fileSizeRange.high ); await uploadInParallel(bucket, creationInfo.paths, {validation: checkType}); diff --git a/handwritten/storage/internal-tooling/performPerformanceTest.ts b/handwritten/storage/internal-tooling/performPerformanceTest.ts index 82fda1c9f73..a23f547c83a 100644 --- a/handwritten/storage/internal-tooling/performPerformanceTest.ts +++ b/handwritten/storage/internal-tooling/performPerformanceTest.ts @@ -54,7 +54,7 @@ async function main() { ({bucket} = await performanceTestSetup( argv.project! as string, - argv.bucket! as string, + argv.bucket! as string )); switch (argv.test_type) { @@ -84,7 +84,7 @@ async function performRangedReadTest(): Promise { fileName, fileSizeRange.low, fileSizeRange.high, - getDirName(), + getDirName() ); const file = bucket.file(`${fileName}`); const destinationFileName = generateRandomFileName(TEST_NAME_STRING); @@ -142,7 +142,7 @@ async function performWriteReadTest(): Promise { fileName, fileSizeRange.low, fileSizeRange.high, - getDirName(), + getDirName() ); for (let j = 0; j < DEFAULT_NUMBER_OF_WRITES; j++) { diff --git a/handwritten/storage/internal-tooling/performTransferManagerTest.ts b/handwritten/storage/internal-tooling/performTransferManagerTest.ts index 6e21e774630..097e999f752 100644 --- a/handwritten/storage/internal-tooling/performTransferManagerTest.ts +++ b/handwritten/storage/internal-tooling/performTransferManagerTest.ts @@ -56,7 +56,7 @@ async function main() { ({bucket, transferManager} = await performanceTestSetup( argv.project! as string, - argv.bucket! as string, + argv.bucket! as string )); switch (argv.test_type) { @@ -104,7 +104,7 @@ async function performUploadManyFilesTest(): Promise { TEST_NAME_STRING, fileSizeRange.low, fileSizeRange.high, - DIRECTORY_PROBABILITY, + DIRECTORY_PROBABILITY ); const start = performance.now(); @@ -153,7 +153,7 @@ async function performDownloadManyFilesTest(): Promise { TEST_NAME_STRING, fileSizeRange.low, fileSizeRange.high, - DIRECTORY_PROBABILITY, + DIRECTORY_PROBABILITY ); await transferManager.uploadManyFiles(creationInfo.paths, { @@ -210,7 +210,7 @@ async function performChunkUploadDownloadTest(): Promise { fileName, fileSizeRange.low, fileSizeRange.high, - getDirName(), + getDirName() ); const file = bucket.file(`${fileName}`); let result: TestResult = { diff --git a/handwritten/storage/internal-tooling/performanceTest.ts b/handwritten/storage/internal-tooling/performanceTest.ts index 02adc10f76f..995eaf96784 100644 --- a/handwritten/storage/internal-tooling/performanceTest.ts +++ b/handwritten/storage/internal-tooling/performanceTest.ts @@ -44,7 +44,7 @@ function main() { if (numThreads > iterationsRemaining) { log( `${numThreads} is greater than number of iterations (${iterationsRemaining}). Using ${iterationsRemaining} threads instead.`, - argv.debug as boolean, + argv.debug as boolean ); numThreads = iterationsRemaining; } @@ -65,7 +65,7 @@ function createWorker() { iterationsRemaining--; log( `Starting new iteration. Current iterations remaining: ${iterationsRemaining}`, - argv.debug as boolean, + argv.debug as boolean ); let testPath = ''; if ( @@ -122,7 +122,7 @@ async function recordResult(results: TestResult[] | TestResult) { : [results]; for await (const outputString of convertToCloudMonitoringFormat( - resultsToAppend, + resultsToAppend )) { argv.file_name ? await appendFile(argv.file_name as string, `${outputString}\n`) diff --git a/handwritten/storage/internal-tooling/performanceUtils.ts b/handwritten/storage/internal-tooling/performanceUtils.ts index b0633bdf1c4..b0ff2d1d587 100644 --- a/handwritten/storage/internal-tooling/performanceUtils.ts +++ b/handwritten/storage/internal-tooling/performanceUtils.ts @@ -214,20 +214,20 @@ export function generateRandomFileName(baseName: string): string { export function generateRandomFile( fileName: string, fileSizeLowerBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES, + DEFAULT_OBJECT_RANGE_SIZE_BYTES ).low, fileSizeUpperBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES, + DEFAULT_OBJECT_RANGE_SIZE_BYTES ).high, - currentDirectory: string = mkdtempSync(randomString()), + currentDirectory: string = mkdtempSync(randomString()) ): number { const fileSizeBytes = randomInteger( fileSizeLowerBoundBytes, - fileSizeUpperBoundBytes, + fileSizeUpperBoundBytes ); execSync( - `head --bytes=${fileSizeBytes} /dev/urandom > ${currentDirectory}/${fileName}`, + `head --bytes=${fileSizeBytes} /dev/urandom > ${currentDirectory}/${fileName}` ); return fileSizeBytes; @@ -247,12 +247,12 @@ export function generateRandomDirectoryStructure( maxObjects: number, baseName: string, fileSizeLowerBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES, + DEFAULT_OBJECT_RANGE_SIZE_BYTES ).low, fileSizeUpperBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES, + DEFAULT_OBJECT_RANGE_SIZE_BYTES ).high, - directoryProbability: number = DEFAULT_DIRECTORY_PROBABILITY, + directoryProbability: number = DEFAULT_DIRECTORY_PROBABILITY ): RandomDirectoryCreationInformation { let curPath = baseName; const creationInfo: RandomDirectoryCreationInformation = { @@ -272,7 +272,7 @@ export function generateRandomDirectoryStructure( randomName, fileSizeLowerBoundBytes, fileSizeUpperBoundBytes, - curPath, + curPath ); creationInfo.paths.push(path.join(curPath, randomName)); } @@ -288,7 +288,7 @@ export function generateRandomDirectoryStructure( */ export function cleanupFile( fileName: string, - directoryName: string = getDirName(), + directoryName: string = getDirName() ): void { unlinkSync(`${directoryName}/${fileName}`); } @@ -302,7 +302,7 @@ export function cleanupFile( */ export async function performanceTestSetup( projectId: string, - bucketName: string, + bucketName: string ): Promise { const storage = new Storage({projectId}); const bucket = storage.bucket(bucketName, { @@ -346,7 +346,7 @@ export function getValidationType(): 'md5' | 'crc32c' | boolean | undefined { * @returns {AsyncGenerator} A string containing the results of the conversion to cloud monitoring format. */ export async function* convertToCloudMonitoringFormat( - results: TestResult[], + results: TestResult[] ): AsyncGenerator { for (const curResult of results) { const throughput = @@ -384,7 +384,7 @@ export async function* convertToCloudMonitoringFormat( export function log( messageOrError: string | Error, shouldLog: boolean, - isError = false, + isError = false ): void { if (shouldLog) { isError ? console.error(messageOrError) : console.log(messageOrError); diff --git a/handwritten/storage/src/acl.ts b/handwritten/storage/src/acl.ts index ecd02bb7a83..9776b0340e0 100644 --- a/handwritten/storage/src/acl.ts +++ b/handwritten/storage/src/acl.ts @@ -23,7 +23,7 @@ export interface AclOptions { pathPrefix: string; request: ( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ) => void; } @@ -35,7 +35,7 @@ export interface GetAclCallback { ( err: Error | null, acl?: AccessControlObject | AccessControlObject[] | null, - apiResponse?: AclMetadata, + apiResponse?: AclMetadata ): void; } export interface GetAclOptions { @@ -55,7 +55,7 @@ export interface UpdateAclCallback { ( err: Error | null, acl?: AccessControlObject | null, - apiResponse?: AclMetadata, + apiResponse?: AclMetadata ): void; } @@ -70,7 +70,7 @@ export interface AddAclCallback { ( err: Error | null, acl?: AccessControlObject | null, - apiResponse?: AclMetadata, + apiResponse?: AclMetadata ): void; } export type RemoveAclResponse = [AclMetadata]; @@ -331,7 +331,7 @@ class AclRoleAccessorMethods { (acc as any)[method] = ( entityId: string, options: {}, - callback: Function | {}, + callback: Function | {} ) => { let apiEntity; @@ -355,7 +355,7 @@ class AclRoleAccessorMethods { entity: apiEntity, role, }, - options, + options ); const args = [options]; @@ -420,7 +420,7 @@ class Acl extends AclRoleAccessorMethods { pathPrefix: string; request_: ( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ) => void; constructor(options: AclOptions) { @@ -508,7 +508,7 @@ class Acl extends AclRoleAccessorMethods { */ add( options: AddAclOptions, - callback?: AddAclCallback, + callback?: AddAclCallback ): void | Promise { const query = {} as AclQuery; @@ -538,7 +538,7 @@ class Acl extends AclRoleAccessorMethods { } callback!(null, this.makeAclObject_(resp), resp); - }, + } ); } @@ -608,7 +608,7 @@ class Acl extends AclRoleAccessorMethods { */ delete( options: RemoveAclOptions, - callback?: RemoveAclCallback, + callback?: RemoveAclCallback ): void | Promise { const query = {} as AclQuery; @@ -628,7 +628,7 @@ class Acl extends AclRoleAccessorMethods { }, (err, resp) => { callback!(err, resp); - }, + } ); } @@ -722,7 +722,7 @@ class Acl extends AclRoleAccessorMethods { */ get( optionsOrCallback?: GetAclOptions | GetAclCallback, - cb?: GetAclCallback, + cb?: GetAclCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : null; @@ -763,7 +763,7 @@ class Acl extends AclRoleAccessorMethods { } callback!(null, results, resp); - }, + } ); } @@ -830,7 +830,7 @@ class Acl extends AclRoleAccessorMethods { */ update( options: UpdateAclOptions, - callback?: UpdateAclCallback, + callback?: UpdateAclCallback ): void | Promise { const query = {} as AclQuery; @@ -858,7 +858,7 @@ class Acl extends AclRoleAccessorMethods { } callback!(null, this.makeAclObject_(resp), resp); - }, + } ); } @@ -868,7 +868,7 @@ class Acl extends AclRoleAccessorMethods { * @private */ makeAclObject_( - accessControlObject: AccessControlObject, + accessControlObject: AccessControlObject ): AccessControlObject { const obj = { entity: accessControlObject.entity, @@ -895,7 +895,7 @@ class Acl extends AclRoleAccessorMethods { */ request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void { reqOpts.uri = this.pathPrefix + reqOpts.uri; this.request_(reqOpts, callback); diff --git a/handwritten/storage/src/bucket.ts b/handwritten/storage/src/bucket.ts index fde1a9bfd18..d354209057e 100644 --- a/handwritten/storage/src/bucket.ts +++ b/handwritten/storage/src/bucket.ts @@ -97,7 +97,7 @@ export interface GetFilesCallback { err: Error | null, files?: File[], nextQuery?: {}, - apiResponse?: unknown, + apiResponse?: unknown ): void; } @@ -217,7 +217,7 @@ export interface CreateNotificationCallback { ( err: Error | null, notification: Notification | null, - apiResponse: unknown, + apiResponse: unknown ): void; } @@ -380,7 +380,7 @@ export interface GetBucketMetadataCallback { ( err: ApiError | null, metadata: BucketMetadata | null, - apiResponse: unknown, + apiResponse: unknown ): void; } @@ -416,7 +416,7 @@ export interface GetNotificationsCallback { ( err: Error | null, notifications: Notification[] | null, - apiResponse: unknown, + apiResponse: unknown ): void; } @@ -1280,16 +1280,16 @@ class Bucket extends ServiceObject { addLifecycleRule( rule: LifecycleRule | LifecycleRule[], - options?: AddLifecycleRuleOptions, + options?: AddLifecycleRuleOptions ): Promise; addLifecycleRule( rule: LifecycleRule | LifecycleRule[], options: AddLifecycleRuleOptions, - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; addLifecycleRule( rule: LifecycleRule | LifecycleRule[], - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; /** * @typedef {object} AddLifecycleRuleOptions Configuration options for Bucket#addLifecycleRule(). @@ -1462,7 +1462,7 @@ class Bucket extends ServiceObject { addLifecycleRule( rule: LifecycleRule | LifecycleRule[], optionsOrCallback?: AddLifecycleRuleOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback, + callback?: SetBucketMetadataCallback ): Promise | void { let options: AddLifecycleRuleOptions = {}; @@ -1516,7 +1516,7 @@ class Bucket extends ServiceObject { lifecycle: {rule: currentLifecycleRules!.concat(rules)}, }, options as AddLifecycleRuleOptions, - callback!, + callback! ); }); } @@ -1524,18 +1524,18 @@ class Bucket extends ServiceObject { combine( sources: string[] | File[], destination: string | File, - options?: CombineOptions, + options?: CombineOptions ): Promise; combine( sources: string[] | File[], destination: string | File, options: CombineOptions, - callback: CombineCallback, + callback: CombineCallback ): void; combine( sources: string[] | File[], destination: string | File, - callback: CombineCallback, + callback: CombineCallback ): void; /** * @typedef {object} CombineOptions @@ -1611,7 +1611,7 @@ class Bucket extends ServiceObject { sources: string[] | File[], destination: string | File, optionsOrCallback?: CombineOptions | CombineCallback, - callback?: CombineCallback, + callback?: CombineCallback ): Promise | void { if (!Array.isArray(sources) || sources.length === 0) { throw new Error(BucketExceptionMessages.PROVIDE_SOURCE_FILE); @@ -1631,7 +1631,7 @@ class Bucket extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.setMetadata, // Not relevant but param is required AvailableServiceObjectMethods.setMetadata, // Same as above - options, + options ); const convertToFile = (file: string | File): File => { @@ -1690,7 +1690,7 @@ class Bucket extends ServiceObject { if (source.metadata && source.metadata.generation) { sourceObject.generation = parseInt( - source.metadata.generation.toString(), + source.metadata.generation.toString() ); } @@ -1707,25 +1707,25 @@ class Bucket extends ServiceObject { } callback!(null, destinationFile, resp); - }, + } ); } createChannel( id: string, config: CreateChannelConfig, - options?: CreateChannelOptions, + options?: CreateChannelOptions ): Promise; createChannel( id: string, config: CreateChannelConfig, - callback: CreateChannelCallback, + callback: CreateChannelCallback ): void; createChannel( id: string, config: CreateChannelConfig, options: CreateChannelOptions, - callback: CreateChannelCallback, + callback: CreateChannelCallback ): void; /** * See a {@link https://cloud.google.com/storage/docs/json_api/v1/objects/watchAll| Objects: watchAll request body}. @@ -1822,7 +1822,7 @@ class Bucket extends ServiceObject { id: string, config: CreateChannelConfig, optionsOrCallback?: CreateChannelOptions | CreateChannelCallback, - callback?: CreateChannelCallback, + callback?: CreateChannelCallback ): Promise | void { if (typeof id !== 'string') { throw new Error(BucketExceptionMessages.CHANNEL_ID_REQUIRED); @@ -1844,7 +1844,7 @@ class Bucket extends ServiceObject { id, type: 'web_hook', }, - config, + config ), qs: options, }, @@ -1860,18 +1860,18 @@ class Bucket extends ServiceObject { channel.metadata = apiResponse; callback!(null, channel, apiResponse); - }, + } ); } createNotification( topic: string, - options?: CreateNotificationOptions, + options?: CreateNotificationOptions ): Promise; createNotification( topic: string, options: CreateNotificationOptions, - callback: CreateNotificationCallback, + callback: CreateNotificationCallback ): void; createNotification(topic: string, callback: CreateNotificationCallback): void; /** @@ -1981,7 +1981,7 @@ class Bucket extends ServiceObject { createNotification( topic: string, optionsOrCallback?: CreateNotificationOptions | CreateNotificationCallback, - callback?: CreateNotificationCallback, + callback?: CreateNotificationCallback ): Promise | void { let options: CreateNotificationOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2038,7 +2038,7 @@ class Bucket extends ServiceObject { notification.metadata = apiResponse; callback!(null, notification, apiResponse); - }, + } ); } @@ -2127,7 +2127,7 @@ class Bucket extends ServiceObject { */ deleteFiles( queryOrCallback?: DeleteFilesOptions | DeleteFilesCallback, - callback?: DeleteFilesCallback, + callback?: DeleteFilesCallback ): Promise | void { let query: DeleteFilesOptions = {}; if (typeof queryOrCallback === 'function') { @@ -2164,7 +2164,7 @@ class Bucket extends ServiceObject { limit(() => deleteFile(curFile)).catch(e => { filesStream.destroy(); throw e; - }), + }) ); } @@ -2182,13 +2182,13 @@ class Bucket extends ServiceObject { deleteLabels(callback: DeleteLabelsCallback): void; deleteLabels( labels: string | string[], - options: DeleteLabelsOptions, + options: DeleteLabelsOptions ): Promise; deleteLabels(labels: string | string[], callback: DeleteLabelsCallback): void; deleteLabels( labels: string | string[], options: DeleteLabelsOptions, - callback: DeleteLabelsCallback, + callback: DeleteLabelsCallback ): void; /** * @deprecated @@ -2250,7 +2250,7 @@ class Bucket extends ServiceObject { | DeleteLabelsCallback | DeleteLabelsOptions, optionsOrCallback?: DeleteLabelsCallback | DeleteLabelsOptions, - callback?: DeleteLabelsCallback, + callback?: DeleteLabelsCallback ): Promise | void { let labels = new Array(); let options: DeleteLabelsOptions = {}; @@ -2298,12 +2298,12 @@ class Bucket extends ServiceObject { } disableRequesterPays( - options?: DisableRequesterPaysOptions, + options?: DisableRequesterPaysOptions ): Promise; disableRequesterPays(callback: DisableRequesterPaysCallback): void; disableRequesterPays( options: DisableRequesterPaysOptions, - callback: DisableRequesterPaysCallback, + callback: DisableRequesterPaysCallback ): void; /** * @typedef {array} DisableRequesterPaysResponse @@ -2356,7 +2356,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | DisableRequesterPaysOptions | DisableRequesterPaysCallback, - callback?: DisableRequesterPaysCallback, + callback?: DisableRequesterPaysCallback ): Promise | void { let options: DisableRequesterPaysOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2372,16 +2372,16 @@ class Bucket extends ServiceObject { }, }, options, - callback!, + callback! ); } enableLogging( - config: EnableLoggingOptions, + config: EnableLoggingOptions ): Promise; enableLogging( config: EnableLoggingOptions, - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; /** * Configuration object for enabling logging. @@ -2441,7 +2441,7 @@ class Bucket extends ServiceObject { */ enableLogging( config: EnableLoggingOptions, - callback?: SetBucketMetadataCallback, + callback?: SetBucketMetadataCallback ): Promise | void { if ( !config || @@ -2449,7 +2449,7 @@ class Bucket extends ServiceObject { typeof config.prefix === 'undefined' ) { throw new Error( - BucketExceptionMessages.CONFIGURATION_OBJECT_PREFIX_REQUIRED, + BucketExceptionMessages.CONFIGURATION_OBJECT_PREFIX_REQUIRED ); } @@ -2483,7 +2483,7 @@ class Bucket extends ServiceObject { }, }, options, - callback!, + callback! ); } catch (e) { callback!(e as Error); @@ -2493,12 +2493,12 @@ class Bucket extends ServiceObject { } enableRequesterPays( - options?: EnableRequesterPaysOptions, + options?: EnableRequesterPaysOptions ): Promise; enableRequesterPays(callback: EnableRequesterPaysCallback): void; enableRequesterPays( options: EnableRequesterPaysOptions, - callback: EnableRequesterPaysCallback, + callback: EnableRequesterPaysCallback ): void; /** @@ -2554,7 +2554,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | EnableRequesterPaysCallback | EnableRequesterPaysOptions, - cb?: EnableRequesterPaysCallback, + cb?: EnableRequesterPaysCallback ): Promise | void { let options: EnableRequesterPaysOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2570,7 +2570,7 @@ class Bucket extends ServiceObject { }, }, options, - cb!, + cb! ); } @@ -2816,7 +2816,7 @@ class Bucket extends ServiceObject { */ getFiles( queryOrCallback?: GetFilesOptions | GetFilesCallback, - callback?: GetFilesCallback, + callback?: GetFilesCallback ): void | Promise { let query = typeof queryOrCallback === 'object' ? queryOrCallback : {}; if (!callback) { @@ -2874,7 +2874,7 @@ class Bucket extends ServiceObject { } // eslint-disable-next-line @typescript-eslint/no-explicit-any (callback as any)(null, files, nextQuery, resp); - }, + } ); } @@ -2935,7 +2935,7 @@ class Bucket extends ServiceObject { */ getLabels( optionsOrCallback?: GetLabelsOptions | GetLabelsCallback, - callback?: GetLabelsCallback, + callback?: GetLabelsCallback ): Promise | void { let options: GetLabelsOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2953,17 +2953,17 @@ class Bucket extends ServiceObject { } callback!(null, metadata?.labels || {}); - }, + } ); } getNotifications( - options?: GetNotificationsOptions, + options?: GetNotificationsOptions ): Promise; getNotifications(callback: GetNotificationsCallback): void; getNotifications( options: GetNotificationsOptions, - callback: GetNotificationsCallback, + callback: GetNotificationsCallback ): void; /** * @typedef {object} GetNotificationsOptions Configuration options for Bucket#getNotification(). @@ -3020,7 +3020,7 @@ class Bucket extends ServiceObject { */ getNotifications( optionsOrCallback?: GetNotificationsOptions | GetNotificationsCallback, - callback?: GetNotificationsCallback, + callback?: GetNotificationsCallback ): Promise | void { let options: GetNotificationsOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -3045,18 +3045,18 @@ class Bucket extends ServiceObject { const notificationInstance = this.notification(notification.id!); notificationInstance.metadata = notification; return notificationInstance; - }, + } ); callback!(null, notifications, resp); - }, + } ); } getSignedUrl(cfg: GetBucketSignedUrlConfig): Promise; getSignedUrl( cfg: GetBucketSignedUrlConfig, - callback: GetSignedUrlCallback, + callback: GetSignedUrlCallback ): void; /** * @typedef {array} GetSignedUrlResponse @@ -3186,7 +3186,7 @@ class Bucket extends ServiceObject { */ getSignedUrl( cfg: GetBucketSignedUrlConfig, - callback?: GetSignedUrlCallback, + callback?: GetSignedUrlCallback ): void | Promise { const method = BucketActionToHTTPMethod[cfg.action]; @@ -3206,7 +3206,7 @@ class Bucket extends ServiceObject { this.storage.authClient, this, undefined, - this.storage, + this.storage ); } @@ -3252,7 +3252,7 @@ class Bucket extends ServiceObject { */ lock( metageneration: number | string, - callback?: BucketLockCallback, + callback?: BucketLockCallback ): Promise | void { const metatype = typeof metageneration; if (metatype !== 'number' && metatype !== 'string') { @@ -3267,7 +3267,7 @@ class Bucket extends ServiceObject { ifMetagenerationMatch: metageneration, }, }, - callback!, + callback! ); } @@ -3293,12 +3293,12 @@ class Bucket extends ServiceObject { } makePrivate( - options?: MakeBucketPrivateOptions, + options?: MakeBucketPrivateOptions ): Promise; makePrivate(callback: MakeBucketPrivateCallback): void; makePrivate( options: MakeBucketPrivateOptions, - callback: MakeBucketPrivateCallback, + callback: MakeBucketPrivateCallback ): void; /** * @typedef {array} MakeBucketPrivateResponse @@ -3403,7 +3403,7 @@ class Bucket extends ServiceObject { */ makePrivate( optionsOrCallback?: MakeBucketPrivateOptions | MakeBucketPrivateCallback, - callback?: MakeBucketPrivateCallback, + callback?: MakeBucketPrivateCallback ): Promise | void { const options: MakeBucketPrivateRequest = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3450,7 +3450,7 @@ class Bucket extends ServiceObject { const internalCall = () => { if (options.includeFiles) { return promisify( - this.makeAllFilesPublicPrivate_, + this.makeAllFilesPublicPrivate_ ).call(this, options); } return Promise.resolve([] as File[]); @@ -3462,12 +3462,12 @@ class Bucket extends ServiceObject { } makePublic( - options?: MakeBucketPublicOptions, + options?: MakeBucketPublicOptions ): Promise; makePublic(callback: MakeBucketPublicCallback): void; makePublic( options: MakeBucketPublicOptions, - callback: MakeBucketPublicCallback, + callback: MakeBucketPublicCallback ): void; /** * @typedef {object} MakeBucketPublicOptions @@ -3564,7 +3564,7 @@ class Bucket extends ServiceObject { */ makePublic( optionsOrCallback?: MakeBucketPublicOptions | MakeBucketPublicCallback, - callback?: MakeBucketPublicCallback, + callback?: MakeBucketPublicCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3587,7 +3587,7 @@ class Bucket extends ServiceObject { .then(() => { if (req.includeFiles) { return promisify( - this.makeAllFilesPublicPrivate_, + this.makeAllFilesPublicPrivate_ ).call(this, req); } return []; @@ -3619,12 +3619,12 @@ class Bucket extends ServiceObject { } removeRetentionPeriod( - options?: SetBucketMetadataOptions, + options?: SetBucketMetadataOptions ): Promise; removeRetentionPeriod(callback: SetBucketMetadataCallback): void; removeRetentionPeriod( options: SetBucketMetadataOptions, - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; /** * Remove an already-existing retention policy from this bucket, if it is not @@ -3651,7 +3651,7 @@ class Bucket extends ServiceObject { */ removeRetentionPeriod( optionsOrCallback?: SetBucketMetadataOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback, + callback?: SetBucketMetadataCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3663,14 +3663,14 @@ class Bucket extends ServiceObject { retentionPolicy: null, }, options, - callback!, + callback! ); } request(reqOpts: DecorateRequestOptions): Promise; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void; /** * Makes request and applies userProject query parameter if necessary. @@ -3682,7 +3682,7 @@ class Bucket extends ServiceObject { */ request( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | Promise { if (this.userProject && (!reqOpts.qs || !reqOpts.qs.userProject)) { reqOpts.qs = {...reqOpts.qs, userProject: this.userProject}; @@ -3692,13 +3692,13 @@ class Bucket extends ServiceObject { setLabels( labels: Labels, - options?: SetLabelsOptions, + options?: SetLabelsOptions ): Promise; setLabels(labels: Labels, callback: SetLabelsCallback): void; setLabels( labels: Labels, options: SetLabelsOptions, - callback: SetLabelsCallback, + callback: SetLabelsCallback ): void; /** * @deprecated @@ -3760,7 +3760,7 @@ class Bucket extends ServiceObject { setLabels( labels: Labels, optionsOrCallback?: SetLabelsOptions | SetLabelsCallback, - callback?: SetLabelsCallback, + callback?: SetLabelsCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3774,21 +3774,21 @@ class Bucket extends ServiceObject { setMetadata( metadata: BucketMetadata, - options?: SetMetadataOptions, + options?: SetMetadataOptions ): Promise>; setMetadata( metadata: BucketMetadata, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: BucketMetadata, options: SetMetadataOptions, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: BucketMetadata, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback, + cb?: MetadataCallback ): Promise> | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3800,7 +3800,7 @@ class Bucket extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.setMetadata, AvailableServiceObjectMethods.setMetadata, - options, + options ); super @@ -3814,16 +3814,16 @@ class Bucket extends ServiceObject { setRetentionPeriod( duration: number, - options?: SetBucketMetadataOptions, + options?: SetBucketMetadataOptions ): Promise; setRetentionPeriod( duration: number, - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; setRetentionPeriod( duration: number, options: SetBucketMetadataOptions, - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; /** * Lock all objects contained in the bucket, based on their creation time. Any @@ -3866,7 +3866,7 @@ class Bucket extends ServiceObject { setRetentionPeriod( duration: number, optionsOrCallback?: SetBucketMetadataOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback, + callback?: SetBucketMetadataCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3879,22 +3879,22 @@ class Bucket extends ServiceObject { }, }, options, - callback!, + callback! ); } setCorsConfiguration( corsConfiguration: Cors[], - options?: SetBucketMetadataOptions, + options?: SetBucketMetadataOptions ): Promise; setCorsConfiguration( corsConfiguration: Cors[], - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; setCorsConfiguration( corsConfiguration: Cors[], options: SetBucketMetadataOptions, - callback: SetBucketMetadataCallback, + callback: SetBucketMetadataCallback ): void; /** * @@ -3945,7 +3945,7 @@ class Bucket extends ServiceObject { setCorsConfiguration( corsConfiguration: Cors[], optionsOrCallback?: SetBucketMetadataOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback, + callback?: SetBucketMetadataCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3956,22 +3956,22 @@ class Bucket extends ServiceObject { cors: corsConfiguration, }, options, - callback!, + callback! ); } setStorageClass( storageClass: string, - options?: SetBucketStorageClassOptions, + options?: SetBucketStorageClassOptions ): Promise; setStorageClass( storageClass: string, - callback: SetBucketStorageClassCallback, + callback: SetBucketStorageClassCallback ): void; setStorageClass( storageClass: string, options: SetBucketStorageClassOptions, - callback: SetBucketStorageClassCallback, + callback: SetBucketStorageClassCallback ): void; /** * @typedef {object} SetBucketStorageClassOptions @@ -4023,7 +4023,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | SetBucketStorageClassOptions | SetBucketStorageClassCallback, - callback?: SetBucketStorageClassCallback, + callback?: SetBucketStorageClassCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -4085,7 +4085,7 @@ class Bucket extends ServiceObject { upload( pathString: string, options: UploadOptions, - callback: UploadCallback, + callback: UploadCallback ): void; upload(pathString: string, callback: UploadCallback): void; /** @@ -4345,7 +4345,7 @@ class Bucket extends ServiceObject { upload( pathString: string, optionsOrCallback?: UploadOptions | UploadCallback, - callback?: UploadCallback, + callback?: UploadCallback ): Promise | void { const upload = (numberOfRetries: number | undefined) => { const returnValue = AsyncRetry( @@ -4384,7 +4384,7 @@ class Bucket extends ServiceObject { factor: this.storage.retryOptions.retryDelayMultiplier, maxTimeout: this.storage.retryOptions.maxRetryDelay! * 1000, //convert to milliseconds maxRetryTime: this.storage.retryOptions.totalTimeout! * 1000, //convert to milliseconds - }, + } ); if (!callback) { @@ -4414,7 +4414,7 @@ class Bucket extends ServiceObject { { metadata: {}, }, - options, + options ); // Do not retry if precondition option ifGenerationMatch is not set @@ -4458,12 +4458,12 @@ class Bucket extends ServiceObject { } makeAllFilesPublicPrivate_( - options?: MakeAllFilesPublicPrivateOptions, + options?: MakeAllFilesPublicPrivateOptions ): Promise; makeAllFilesPublicPrivate_(callback: MakeAllFilesPublicPrivateCallback): void; makeAllFilesPublicPrivate_( options: MakeAllFilesPublicPrivateOptions, - callback: MakeAllFilesPublicPrivateCallback, + callback: MakeAllFilesPublicPrivateCallback ): void; /** * @private @@ -4513,7 +4513,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | MakeAllFilesPublicPrivateOptions | MakeAllFilesPublicPrivateCallback, - callback?: MakeAllFilesPublicPrivateCallback, + callback?: MakeAllFilesPublicPrivateCallback ): Promise | void { const MAX_PARALLEL_LIMIT = 10; const errors = [] as Error[]; @@ -4546,7 +4546,7 @@ class Bucket extends ServiceObject { }) .then( () => callback!(errors.length > 0 ? errors : null, updatedFiles), - err => callback!(err, updatedFiles), + err => callback!(err, updatedFiles) ); } @@ -4559,7 +4559,7 @@ class Bucket extends ServiceObject { coreOpts: any, // eslint-disable-next-line @typescript-eslint/no-explicit-any methodType: AvailableServiceObjectMethods, - localPreconditionOptions?: PreconditionOptions, + localPreconditionOptions?: PreconditionOptions ): void { if ( typeof coreOpts === 'object' && diff --git a/handwritten/storage/src/channel.ts b/handwritten/storage/src/channel.ts index eccb2707194..ee0c10984b4 100644 --- a/handwritten/storage/src/channel.ts +++ b/handwritten/storage/src/channel.ts @@ -106,7 +106,7 @@ class Channel extends ServiceObject { }, (err, apiResponse) => { callback!(err, apiResponse); - }, + } ); } } diff --git a/handwritten/storage/src/crc32c.ts b/handwritten/storage/src/crc32c.ts index 5d4ac75a6c9..929cc1d5a95 100644 --- a/handwritten/storage/src/crc32c.ts +++ b/handwritten/storage/src/crc32c.ts @@ -231,7 +231,7 @@ class CRC32C implements CRC32CValidator { * @param value 4-byte `ArrayBufferView`/`Buffer`/`TypedArray` */ private static fromBuffer( - value: ArrayBuffer | ArrayBufferView | Buffer, + value: ArrayBuffer | ArrayBufferView | Buffer ): CRC32C { let buffer: Buffer; @@ -247,7 +247,7 @@ class CRC32C implements CRC32CValidator { if (buffer.byteLength !== 4) { throw new RangeError( - CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BUFFER_LENGTH(buffer.byteLength), + CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BUFFER_LENGTH(buffer.byteLength) ); } @@ -283,7 +283,7 @@ class CRC32C implements CRC32CValidator { if (buffer.byteLength !== 4) { throw new RangeError( - CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BASE64_RANGE(buffer.byteLength), + CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BASE64_RANGE(buffer.byteLength) ); } @@ -298,7 +298,7 @@ class CRC32C implements CRC32CValidator { private static fromNumber(value: number): CRC32C { if (!Number.isSafeInteger(value) || value > 2 ** 32 || value < -(2 ** 32)) { throw new RangeError( - CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_INTEGER(value), + CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_INTEGER(value) ); } @@ -312,7 +312,7 @@ class CRC32C implements CRC32CValidator { * @param value A number, 4-byte `ArrayBufferView`/`Buffer`/`TypedArray`, or 4-byte base64-encoded data (string) */ static from( - value: ArrayBuffer | ArrayBufferView | CRC32CValidator | string | number, + value: ArrayBuffer | ArrayBufferView | CRC32CValidator | string | number ): CRC32C { if (typeof value === 'number') { return this.fromNumber(value); diff --git a/handwritten/storage/src/file.ts b/handwritten/storage/src/file.ts index 5c51e63dfb0..7a85ae96ea3 100644 --- a/handwritten/storage/src/file.ts +++ b/handwritten/storage/src/file.ts @@ -83,7 +83,7 @@ export interface GetExpirationDateCallback { ( err: Error | null, expirationDate?: Date | null, - apiResponse?: unknown, + apiResponse?: unknown ): void; } @@ -296,7 +296,7 @@ export interface MoveCallback { ( err: Error | null, destinationFile?: File | null, - apiResponse?: unknown, + apiResponse?: unknown ): void; } @@ -360,7 +360,7 @@ const COMPRESSIBLE_MIME_REGEX = new RegExp( ] .map(r => r.source) .join(''), - 'i', + 'i' ); export interface FileOptions { @@ -398,7 +398,7 @@ export type DownloadResponse = [Buffer]; export type DownloadCallback = ( err: RequestError | null, - contents: Buffer, + contents: Buffer ) => void; export interface DownloadOptions extends CreateReadStreamOptions { @@ -1118,7 +1118,7 @@ class File extends ServiceObject { * - if `idempotencyStrategy` is set to `RetryNever` */ private shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?: PreconditionOptions, + options?: PreconditionOptions ): boolean { return !( (options?.ifGenerationMatch === undefined && @@ -1132,13 +1132,13 @@ class File extends ServiceObject { copy( destination: string | Bucket | File, - options?: CopyOptions, + options?: CopyOptions ): Promise; copy(destination: string | Bucket | File, callback: CopyCallback): void; copy( destination: string | Bucket | File, options: CopyOptions, - callback: CopyCallback, + callback: CopyCallback ): void; /** * @typedef {array} CopyResponse @@ -1275,10 +1275,10 @@ class File extends ServiceObject { copy( destination: string | Bucket | File, optionsOrCallback?: CopyOptions | CopyCallback, - callback?: CopyCallback, + callback?: CopyCallback ): Promise | void { const noDestinationError = new Error( - FileExceptionMessages.DESTINATION_NO_NAME, + FileExceptionMessages.DESTINATION_NO_NAME ); if (!destination) { @@ -1358,7 +1358,7 @@ class File extends ServiceObject { this.kmsKeyName = query.destinationKmsKeyName; const keyIndex = this.interceptors.indexOf( - this.encryptionKeyInterceptor!, + this.encryptionKeyInterceptor! ); if (keyIndex > -1) { this.interceptors.splice(keyIndex, 1); @@ -1367,7 +1367,7 @@ class File extends ServiceObject { if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?.preconditionOpts, + options?.preconditionOpts ) ) { this.storage.retryOptions.autoRetry = false; @@ -1382,7 +1382,7 @@ class File extends ServiceObject { { method: 'POST', uri: `/rewriteTo/b/${destBucket.name}/o/${encodeURIComponent( - newFile.name, + newFile.name )}`, qs: query, json: options, @@ -1413,7 +1413,7 @@ class File extends ServiceObject { } callback!(null, newFile, resp); - }, + } ); } @@ -1568,7 +1568,7 @@ class File extends ServiceObject { const onResponse = ( err: Error | null, _body: ResponseBody, - rawResponseStream: unknown, + rawResponseStream: unknown ) => { if (err) { // Get error message from the body. @@ -1620,7 +1620,7 @@ class File extends ServiceObject { if (md5 && !hashes.md5) { const hashError = new RequestError( - FileExceptionMessages.MD5_NOT_AVAILABLE, + FileExceptionMessages.MD5_NOT_AVAILABLE ); hashError.code = 'MD5_NOT_AVAILABLE'; throughStream.destroy(hashError); @@ -1639,7 +1639,7 @@ class File extends ServiceObject { rawResponseStream as Readable, ...(transformStreams as [Transform]), throughStream, - onComplete, + onComplete ); }; @@ -1698,11 +1698,11 @@ class File extends ServiceObject { } createResumableUpload( - options?: CreateResumableUploadOptions, + options?: CreateResumableUploadOptions ): Promise; createResumableUpload( options: CreateResumableUploadOptions, - callback: CreateResumableUploadCallback, + callback: CreateResumableUploadCallback ): void; createResumableUpload(callback: CreateResumableUploadCallback): void; /** @@ -1793,7 +1793,7 @@ class File extends ServiceObject { optionsOrCallback?: | CreateResumableUploadOptions | CreateResumableUploadCallback, - callback?: CreateResumableUploadCallback, + callback?: CreateResumableUploadCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -1819,7 +1819,7 @@ class File extends ServiceObject { bucket: this.bucket.name, customRequestOptions: this.getRequestInterceptors().reduce( (reqOpts, interceptorFn) => interceptorFn(reqOpts), - {}, + {} ), file: this.name, generation: this.generation, @@ -1838,7 +1838,7 @@ class File extends ServiceObject { useAuthWithCustomEndpoint: this.storage.useAuthWithCustomEndpoint, [GCCL_GCS_CMD_KEY]: options[GCCL_GCS_CMD_KEY], }, - callback!, + callback! ); this.storage.retryOptions.autoRetry = this.instanceRetryValue; } @@ -2053,7 +2053,7 @@ class File extends ServiceObject { if (crc32c && !options.isPartialUpload && !options.resumeCRC32C) { throw new RangeError( - FileExceptionMessages.MISSING_RESUME_CRC32C_FINAL_UPLOAD, + FileExceptionMessages.MISSING_RESUME_CRC32C_FINAL_UPLOAD ); } } @@ -2200,7 +2200,7 @@ class File extends ServiceObject { } catch (e) { pipelineCallback(e as Error); } - }, + } ); }); @@ -2219,7 +2219,7 @@ class File extends ServiceObject { delete(callback: DeleteCallback): void; delete( optionsOrCallback?: DeleteOptions | DeleteCallback, - cb?: DeleteCallback, + cb?: DeleteCallback ): Promise<[r.Response]> | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -2228,7 +2228,7 @@ class File extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.delete, AvailableServiceObjectMethods.delete, - options, + options ); super @@ -2309,7 +2309,7 @@ class File extends ServiceObject { */ download( optionsOrCallback?: DownloadOptions | DownloadCallback, - cb?: DownloadCallback, + cb?: DownloadCallback ): Promise | void { let options: DownloadOptions; if (typeof optionsOrCallback === 'function') { @@ -2421,7 +2421,7 @@ class File extends ServiceObject { setEncryptionKey(encryptionKey: string | Buffer) { this.encryptionKey = encryptionKey; this.encryptionKeyBase64 = Buffer.from(encryptionKey as string).toString( - 'base64', + 'base64' ); this.encryptionKeyHash = crypto .createHash('sha256') @@ -2456,7 +2456,7 @@ class File extends ServiceObject { static from( publicUrlOrGsUrl: string, storageInstance: Storage, - options?: FileOptions, + options?: FileOptions ): File { const gsMatches = [...publicUrlOrGsUrl.matchAll(GS_UTIL_URL_REGEX)]; const httpsMatches = [...publicUrlOrGsUrl.matchAll(HTTPS_PUBLIC_URL_REGEX)]; @@ -2469,7 +2469,7 @@ class File extends ServiceObject { return new File(bucket, httpsMatches[0][4], options); } else { throw new Error( - 'URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file', + 'URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file' ); } } @@ -2479,7 +2479,7 @@ class File extends ServiceObject { get(options: GetFileOptions, callback: InstanceResponseCallback): void; get( optionsOrCallback?: GetFileOptions | InstanceResponseCallback, - cb?: InstanceResponseCallback, + cb?: InstanceResponseCallback ): Promise> | void { // eslint-disable-next-line @typescript-eslint/no-explicit-any const options: any = @@ -2528,7 +2528,7 @@ class File extends ServiceObject { * ``` */ getExpirationDate( - callback?: GetExpirationDateCallback, + callback?: GetExpirationDateCallback ): void | Promise { this.getMetadata( (err: ApiError | null, metadata: FileMetadata, apiResponse: unknown) => { @@ -2546,21 +2546,21 @@ class File extends ServiceObject { callback!( null, new Date(metadata.retentionExpirationTime), - apiResponse, + apiResponse ); - }, + } ); } generateSignedPostPolicyV2( - options: GenerateSignedPostPolicyV2Options, + options: GenerateSignedPostPolicyV2Options ): Promise; generateSignedPostPolicyV2( options: GenerateSignedPostPolicyV2Options, - callback: GenerateSignedPostPolicyV2Callback, + callback: GenerateSignedPostPolicyV2Callback ): void; generateSignedPostPolicyV2( - callback: GenerateSignedPostPolicyV2Callback, + callback: GenerateSignedPostPolicyV2Callback ): void; /** * @typedef {array} GenerateSignedPostPolicyV2Response @@ -2655,16 +2655,16 @@ class File extends ServiceObject { optionsOrCallback?: | GenerateSignedPostPolicyV2Options | GenerateSignedPostPolicyV2Callback, - cb?: GenerateSignedPostPolicyV2Callback, + cb?: GenerateSignedPostPolicyV2Callback ): void | Promise { const args = normalize( optionsOrCallback, - cb, + cb ); let options = args.options; const callback = args.callback; const expires = new Date( - (options as GenerateSignedPostPolicyV2Options).expires, + (options as GenerateSignedPostPolicyV2Options).expires ); if (isNaN(expires.getTime())) { @@ -2753,19 +2753,19 @@ class File extends ServiceObject { }, err => { callback(new SigningError(err.message)); - }, + } ); } generateSignedPostPolicyV4( - options: GenerateSignedPostPolicyV4Options, + options: GenerateSignedPostPolicyV4Options ): Promise; generateSignedPostPolicyV4( options: GenerateSignedPostPolicyV4Options, - callback: GenerateSignedPostPolicyV4Callback, + callback: GenerateSignedPostPolicyV4Callback ): void; generateSignedPostPolicyV4( - callback: GenerateSignedPostPolicyV4Callback, + callback: GenerateSignedPostPolicyV4Callback ): void; /** * @typedef {object} SignedPostPolicyV4Output @@ -2859,7 +2859,7 @@ class File extends ServiceObject { optionsOrCallback?: | GenerateSignedPostPolicyV4Options | GenerateSignedPostPolicyV4Callback, - cb?: GenerateSignedPostPolicyV4Callback, + cb?: GenerateSignedPostPolicyV4Callback ): void | Promise { const args = normalize< GenerateSignedPostPolicyV4Options, @@ -2868,7 +2868,7 @@ class File extends ServiceObject { let options = args.options; const callback = args.callback; const expires = new Date( - (options as GenerateSignedPostPolicyV4Options).expires, + (options as GenerateSignedPostPolicyV4Options).expires ); if (isNaN(expires.getTime())) { @@ -2881,7 +2881,7 @@ class File extends ServiceObject { if (expires.valueOf() - Date.now() > SEVEN_DAYS * 1000) { throw new Error( - `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).`, + `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).` ); } @@ -2928,7 +2928,7 @@ class File extends ServiceObject { try { const signature = await this.storage.authClient.sign( policyBase64, - options.signingEndpoint, + options.signingEndpoint ); const signatureHex = Buffer.from(signature, 'base64').toString('hex'); const universe = this.parent.storage.universeDomain; @@ -3140,7 +3140,7 @@ class File extends ServiceObject { */ getSignedUrl( cfg: GetSignedUrlConfig, - callback?: GetSignedUrlCallback, + callback?: GetSignedUrlCallback ): void | Promise { const method = ActionToHTTPMethod[cfg.action]; const extensionHeaders = objectKeyToLowercase(cfg.extensionHeaders || {}); @@ -3191,7 +3191,7 @@ class File extends ServiceObject { this.storage.authClient, this.bucket, this, - this.storage, + this.storage ); } @@ -3289,17 +3289,17 @@ class File extends ServiceObject { } else { callback!(null, true); } - }, + } ); } makePrivate( - options?: MakeFilePrivateOptions, + options?: MakeFilePrivateOptions ): Promise; makePrivate(callback: MakeFilePrivateCallback): void; makePrivate( options: MakeFilePrivateOptions, - callback: MakeFilePrivateCallback, + callback: MakeFilePrivateCallback ): void; /** * @typedef {object} MakeFilePrivateOptions Configuration options for File#makePrivate(). @@ -3357,7 +3357,7 @@ class File extends ServiceObject { */ makePrivate( optionsOrCallback?: MakeFilePrivateOptions | MakeFilePrivateCallback, - callback?: MakeFilePrivateCallback, + callback?: MakeFilePrivateCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3429,7 +3429,7 @@ class File extends ServiceObject { * Another example: */ makePublic( - callback?: MakeFilePublicCallback, + callback?: MakeFilePublicCallback ): Promise | void { callback = callback || util.noop; this.acl.add( @@ -3439,7 +3439,7 @@ class File extends ServiceObject { }, (err, acl, resp) => { callback!(err, resp); - }, + } ); } @@ -3468,16 +3468,16 @@ class File extends ServiceObject { moveFileAtomic( destination: string | File, - options?: MoveFileAtomicOptions, + options?: MoveFileAtomicOptions ): Promise; moveFileAtomic( destination: string | File, - callback: MoveFileAtomicCallback, + callback: MoveFileAtomicCallback ): void; moveFileAtomic( destination: string | File, options: MoveFileAtomicOptions, - callback: MoveFileAtomicCallback, + callback: MoveFileAtomicCallback ): void; /** * @typedef {array} MoveFileAtomicResponse @@ -3577,10 +3577,10 @@ class File extends ServiceObject { moveFileAtomic( destination: string | File, optionsOrCallback?: MoveFileAtomicOptions | MoveFileAtomicCallback, - callback?: MoveFileAtomicCallback, + callback?: MoveFileAtomicCallback ): Promise | void { const noDestinationError = new Error( - FileExceptionMessages.DESTINATION_NO_NAME, + FileExceptionMessages.DESTINATION_NO_NAME ); if (!destination) { @@ -3617,7 +3617,7 @@ class File extends ServiceObject { if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?.preconditionOpts, + options?.preconditionOpts ) ) { this.storage.retryOptions.autoRetry = false; @@ -3647,19 +3647,19 @@ class File extends ServiceObject { } callback!(null, newFile, resp); - }, + } ); } move( destination: string | Bucket | File, - options?: MoveOptions, + options?: MoveOptions ): Promise; move(destination: string | Bucket | File, callback: MoveCallback): void; move( destination: string | Bucket | File, options: MoveOptions, - callback: MoveCallback, + callback: MoveCallback ): void; /** * @typedef {array} MoveResponse @@ -3794,7 +3794,7 @@ class File extends ServiceObject { move( destination: string | Bucket | File, optionsOrCallback?: MoveOptions | MoveCallback, - callback?: MoveCallback, + callback?: MoveCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3830,13 +3830,13 @@ class File extends ServiceObject { rename( destinationFile: string | File, - options?: RenameOptions, + options?: RenameOptions ): Promise; rename(destinationFile: string | File, callback: RenameCallback): void; rename( destinationFile: string | File, options: RenameOptions, - callback: RenameCallback, + callback: RenameCallback ): void; /** * @typedef {array} RenameResponse @@ -3925,7 +3925,7 @@ class File extends ServiceObject { rename( destinationFile: string | File, optionsOrCallback?: RenameOptions | RenameCallback, - callback?: RenameCallback, + callback?: RenameCallback ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3975,7 +3975,7 @@ class File extends ServiceObject { request(reqOpts: DecorateRequestOptions): Promise; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void; /** * Makes request and applies userProject query parameter if necessary. @@ -3987,18 +3987,18 @@ class File extends ServiceObject { */ request( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | Promise { return this.parent.request.call(this, reqOpts, callback!); } rotateEncryptionKey( - options?: RotateEncryptionKeyOptions, + options?: RotateEncryptionKeyOptions ): Promise; rotateEncryptionKey(callback: RotateEncryptionKeyCallback): void; rotateEncryptionKey( options: RotateEncryptionKeyOptions, - callback: RotateEncryptionKeyCallback, + callback: RotateEncryptionKeyCallback ): void; /** * @callback RotateEncryptionKeyCallback @@ -4036,7 +4036,7 @@ class File extends ServiceObject { optionsOrCallback?: | RotateEncryptionKeyOptions | RotateEncryptionKeyCallback, - callback?: RotateEncryptionKeyCallback, + callback?: RotateEncryptionKeyCallback ): Promise | void { callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : callback; @@ -4119,7 +4119,7 @@ class File extends ServiceObject { save( data: SaveData, optionsOrCallback?: SaveOptions | SaveCallback, - callback?: SaveCallback, + callback?: SaveCallback ): Promise | void { // tslint:enable:no-any callback = @@ -4130,7 +4130,7 @@ class File extends ServiceObject { let maxRetries = this.storage.retryOptions.maxRetries; if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?.preconditionOpts, + options?.preconditionOpts ) ) { maxRetries = 0; @@ -4189,7 +4189,7 @@ class File extends ServiceObject { factor: this.storage.retryOptions.retryDelayMultiplier, maxTimeout: this.storage.retryOptions.maxRetryDelay! * 1000, //convert to milliseconds maxRetryTime: this.storage.retryOptions.totalTimeout! * 1000, //convert to milliseconds - }, + } ); if (!callback) { return returnValue; @@ -4206,21 +4206,21 @@ class File extends ServiceObject { setMetadata( metadata: FileMetadata, - options?: SetMetadataOptions, + options?: SetMetadataOptions ): Promise>; setMetadata( metadata: FileMetadata, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: FileMetadata, options: SetMetadataOptions, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: FileMetadata, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback, + cb?: MetadataCallback ): Promise> | void { // eslint-disable-next-line @typescript-eslint/no-explicit-any const options: any = @@ -4233,7 +4233,7 @@ class File extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.setMetadata, AvailableServiceObjectMethods.setMetadata, - options, + options ); super @@ -4247,16 +4247,16 @@ class File extends ServiceObject { setStorageClass( storageClass: string, - options?: SetStorageClassOptions, + options?: SetStorageClassOptions ): Promise; setStorageClass( storageClass: string, options: SetStorageClassOptions, - callback: SetStorageClassCallback, + callback: SetStorageClassCallback ): void; setStorageClass( storageClass: string, - callback?: SetStorageClassCallback, + callback?: SetStorageClassCallback ): void; /** * @typedef {array} SetStorageClassResponse @@ -4307,7 +4307,7 @@ class File extends ServiceObject { setStorageClass( storageClass: string, optionsOrCallback?: SetStorageClassOptions | SetStorageClassCallback, - callback?: SetStorageClassCallback, + callback?: SetStorageClassCallback ): Promise | void { callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : callback; @@ -4367,14 +4367,14 @@ class File extends ServiceObject { */ startResumableUpload_( dup: Duplexify, - options: CreateResumableUploadOptions = {}, + options: CreateResumableUploadOptions = {} ): void { options.metadata ??= {}; const retryOptions = this.storage.retryOptions; if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options.preconditionOpts, + options.preconditionOpts ) ) { retryOptions.autoRetry = false; @@ -4385,7 +4385,7 @@ class File extends ServiceObject { bucket: this.bucket.name, customRequestOptions: this.getRequestInterceptors().reduce( (reqOpts, interceptorFn) => interceptorFn(reqOpts), - {}, + {} ), file: this.name, generation: this.generation, @@ -4449,7 +4449,7 @@ class File extends ServiceObject { */ startSimpleUpload_( dup: Duplexify, - options: CreateWriteStreamOptions = {}, + options: CreateWriteStreamOptions = {} ): void { options.metadata ??= {}; @@ -4492,7 +4492,7 @@ class File extends ServiceObject { Object.assign( reqOpts.qs, this.instancePreconditionOpts, - options.preconditionOpts, + options.preconditionOpts ); util.makeWritableStream(dup, { @@ -4518,7 +4518,7 @@ class File extends ServiceObject { // eslint-disable-next-line @typescript-eslint/no-explicit-any coreOpts: any, methodType: AvailableServiceObjectMethods, - localPreconditionOptions?: PreconditionOptions, + localPreconditionOptions?: PreconditionOptions ): void { if ( (typeof coreOpts === 'object' && @@ -4564,7 +4564,7 @@ class File extends ServiceObject { */ async #validateIntegrity( hashCalculatingStream: HashStreamValidator, - verify: {crc32c?: boolean; md5?: boolean} = {}, + verify: {crc32c?: boolean; md5?: boolean} = {} ) { const metadata = this.metadata; diff --git a/handwritten/storage/src/hash-stream-validator.ts b/handwritten/storage/src/hash-stream-validator.ts index b41dd51b6dc..9e9f67d330c 100644 --- a/handwritten/storage/src/hash-stream-validator.ts +++ b/handwritten/storage/src/hash-stream-validator.ts @@ -117,7 +117,7 @@ class HashStreamValidator extends Transform { if (failed) { const mismatchError = new RequestError( - FileExceptionMessages.DOWNLOAD_MISMATCH, + FileExceptionMessages.DOWNLOAD_MISMATCH ); mismatchError.code = 'CONTENT_DOWNLOAD_MISMATCH'; @@ -130,7 +130,7 @@ class HashStreamValidator extends Transform { _transform( chunk: Buffer, encoding: BufferEncoding, - callback: (e?: Error) => void, + callback: (e?: Error) => void ) { this.push(chunk, encoding); diff --git a/handwritten/storage/src/hmacKey.ts b/handwritten/storage/src/hmacKey.ts index 4f73737331d..9b79daa5e8c 100644 --- a/handwritten/storage/src/hmacKey.ts +++ b/handwritten/storage/src/hmacKey.ts @@ -371,21 +371,21 @@ export class HmacKey extends ServiceObject { */ setMetadata( metadata: HmacKeyMetadata, - options?: SetMetadataOptions, + options?: SetMetadataOptions ): Promise>; setMetadata( metadata: HmacKeyMetadata, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: HmacKeyMetadata, options: SetMetadataOptions, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: HmacKeyMetadata, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback, + cb?: MetadataCallback ): Promise> | void { // ETag preconditions are not currently supported. Retries should be disabled if the idempotency strategy is not set to RetryAlways if ( diff --git a/handwritten/storage/src/iam.ts b/handwritten/storage/src/iam.ts index 7a90a1b36d4..8f6ee5d76d3 100644 --- a/handwritten/storage/src/iam.ts +++ b/handwritten/storage/src/iam.ts @@ -99,7 +99,7 @@ export interface TestIamPermissionsCallback { ( err?: Error | null, acl?: {[key: string]: boolean} | null, - apiResponse?: unknown, + apiResponse?: unknown ): void; } @@ -143,7 +143,7 @@ export enum IAMExceptionMessages { class Iam { private request_: ( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ) => void; private resourceId_: string; @@ -242,7 +242,7 @@ class Iam { */ getPolicy( optionsOrCallback?: GetPolicyOptions | GetPolicyCallback, - callback?: GetPolicyCallback, + callback?: GetPolicyCallback ): Promise | void { const {options, callback: cb} = normalize< GetPolicyOptions, @@ -266,19 +266,19 @@ class Iam { uri: '/iam', qs, }, - cb!, + cb! ); } setPolicy( policy: Policy, - options?: SetPolicyOptions, + options?: SetPolicyOptions ): Promise; setPolicy(policy: Policy, callback: SetPolicyCallback): void; setPolicy( policy: Policy, options: SetPolicyOptions, - callback: SetPolicyCallback, + callback: SetPolicyCallback ): void; /** * Set the IAM policy. @@ -331,7 +331,7 @@ class Iam { setPolicy( policy: Policy, optionsOrCallback?: SetPolicyOptions | SetPolicyCallback, - callback?: SetPolicyCallback, + callback?: SetPolicyCallback ): Promise | void { if (policy === null || typeof policy !== 'object') { throw new Error(IAMExceptionMessages.POLICY_OBJECT_REQUIRED); @@ -356,26 +356,26 @@ class Iam { { resourceId: this.resourceId_, }, - policy, + policy ), qs: options, }, - cb, + cb ); } testPermissions( permissions: string | string[], - options?: TestIamPermissionsOptions, + options?: TestIamPermissionsOptions ): Promise; testPermissions( permissions: string | string[], - callback: TestIamPermissionsCallback, + callback: TestIamPermissionsCallback ): void; testPermissions( permissions: string | string[], options: TestIamPermissionsOptions, - callback: TestIamPermissionsCallback, + callback: TestIamPermissionsCallback ): void; /** * Test a set of permissions for a resource. @@ -435,7 +435,7 @@ class Iam { testPermissions( permissions: string | string[], optionsOrCallback?: TestIamPermissionsOptions | TestIamPermissionsCallback, - callback?: TestIamPermissionsCallback, + callback?: TestIamPermissionsCallback ): Promise | void { if (!Array.isArray(permissions) && typeof permissions !== 'string') { throw new Error(IAMExceptionMessages.PERMISSIONS_REQUIRED); @@ -454,7 +454,7 @@ class Iam { { permissions: permissionsArray, }, - options, + options ); this.request_( @@ -478,11 +478,11 @@ class Iam { acc[permission] = availablePermissions.indexOf(permission) > -1; return acc; }, - {}, + {} ); cb!(null, permissionsHash, resp); - }, + } ); } } diff --git a/handwritten/storage/src/nodejs-common/service-object.ts b/handwritten/storage/src/nodejs-common/service-object.ts index 4f83189d525..a4e369a3f5e 100644 --- a/handwritten/storage/src/nodejs-common/service-object.ts +++ b/handwritten/storage/src/nodejs-common/service-object.ts @@ -34,7 +34,7 @@ export interface ServiceObjectParent { requestStream(reqOpts: DecorateRequestOptions): r.Request; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void; } @@ -48,7 +48,7 @@ export type MetadataResponse = [K, r.Response]; export type MetadataCallback = ( err: Error | null, metadata?: K, - apiResponse?: r.Response, + apiResponse?: r.Response ) => void; export type ExistsOptions = object; @@ -237,7 +237,7 @@ class ServiceObject extends EventEmitter { create(callback: CreateCallback): void; create( optionsOrCallback?: CreateOptions | CreateCallback, - callback?: CreateCallback, + callback?: CreateCallback ): void | Promise> { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; @@ -282,7 +282,7 @@ class ServiceObject extends EventEmitter { delete(callback: DeleteCallback): void; delete( optionsOrCallback?: DeleteOptions | DeleteCallback, - cb?: DeleteCallback, + cb?: DeleteCallback ): Promise<[r.Response]> | void { const [options, callback] = util.maybeOptionsOrCallback< DeleteOptions, @@ -317,7 +317,7 @@ class ServiceObject extends EventEmitter { } } callback(err, res); - }, + } ); } @@ -333,7 +333,7 @@ class ServiceObject extends EventEmitter { exists(callback: ExistsCallback): void; exists( optionsOrCallback?: ExistsOptions | ExistsCallback, - cb?: ExistsCallback, + cb?: ExistsCallback ): void | Promise<[boolean]> { const [options, callback] = util.maybeOptionsOrCallback< ExistsOptions, @@ -370,7 +370,7 @@ class ServiceObject extends EventEmitter { get(options: GetOrCreateOptions, callback: InstanceResponseCallback): void; get( optionsOrCallback?: GetOrCreateOptions | InstanceResponseCallback, - cb?: InstanceResponseCallback, + cb?: InstanceResponseCallback ): Promise> | void { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; @@ -387,7 +387,7 @@ class ServiceObject extends EventEmitter { function onCreate( err: ApiError | null, instance: T, - apiResponse: r.Response, + apiResponse: r.Response ) { if (err) { if (err.code === 409) { @@ -431,7 +431,7 @@ class ServiceObject extends EventEmitter { getMetadata(callback: MetadataCallback): void; getMetadata( optionsOrCallback: GetMetadataOptions | MetadataCallback, - cb?: MetadataCallback, + cb?: MetadataCallback ): Promise> | void { const [options, callback] = util.maybeOptionsOrCallback< GetMetadataOptions, @@ -459,7 +459,7 @@ class ServiceObject extends EventEmitter { (err: Error | null, body?: ResponseBody, res?: r.Response) => { this.metadata = body; callback!(err, this.metadata, res); - }, + } ); } @@ -485,18 +485,18 @@ class ServiceObject extends EventEmitter { */ setMetadata( metadata: K, - options?: SetMetadataOptions, + options?: SetMetadataOptions ): Promise>; setMetadata(metadata: K, callback: MetadataCallback): void; setMetadata( metadata: K, options: SetMetadataOptions, - callback: MetadataCallback, + callback: MetadataCallback ): void; setMetadata( metadata: K, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback, + cb?: MetadataCallback ): Promise> | void { const [options, callback] = util.maybeOptionsOrCallback< SetMetadataOptions, @@ -529,7 +529,7 @@ class ServiceObject extends EventEmitter { (err: Error | null, body?: ResponseBody, res?: r.Response) => { this.metadata = body; callback!(err, this.metadata, res); - }, + } ); } @@ -545,11 +545,11 @@ class ServiceObject extends EventEmitter { private request_(reqOpts: StreamRequestOptions): r.Request; private request_( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void; private request_( reqOpts: DecorateRequestOptions | StreamRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | r.Request { reqOpts = {...reqOpts}; @@ -595,11 +595,11 @@ class ServiceObject extends EventEmitter { request(reqOpts: DecorateRequestOptions): Promise; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void; request( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | Promise { this.request_(reqOpts, callback!); } diff --git a/handwritten/storage/src/nodejs-common/service.ts b/handwritten/storage/src/nodejs-common/service.ts index 6e2a6cb9078..9ade0478e04 100644 --- a/handwritten/storage/src/nodejs-common/service.ts +++ b/handwritten/storage/src/nodejs-common/service.ts @@ -183,7 +183,7 @@ export class Service { getProjectId(): Promise; getProjectId(callback: (err: Error | null, projectId?: string) => void): void; getProjectId( - callback?: (err: Error | null, projectId?: string) => void, + callback?: (err: Error | null, projectId?: string) => void ): Promise | void { if (!callback) { return this.getProjectIdAsync(); @@ -211,11 +211,11 @@ export class Service { private request_(reqOpts: StreamRequestOptions): r.Request; private request_( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void; private request_( reqOpts: DecorateRequestOptions | StreamRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | r.Request { reqOpts = {...reqOpts, timeout: this.timeout}; const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; @@ -298,7 +298,7 @@ export class Service { */ request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void { Service.prototype.request_.call(this, reqOpts, callback); } diff --git a/handwritten/storage/src/nodejs-common/util.ts b/handwritten/storage/src/nodejs-common/util.ts index 9ba3051add3..aec0b2f5064 100644 --- a/handwritten/storage/src/nodejs-common/util.ts +++ b/handwritten/storage/src/nodejs-common/util.ts @@ -96,17 +96,17 @@ export interface DuplexifyConstructor { obj( writable?: Writable | false | null, readable?: Readable | false | null, - options?: DuplexifyOptions, + options?: DuplexifyOptions ): Duplexify; new ( writable?: Writable | false | null, readable?: Readable | false | null, - options?: DuplexifyOptions, + options?: DuplexifyOptions ): Duplexify; ( writable?: Writable | false | null, readable?: Readable | false | null, - options?: DuplexifyOptions, + options?: DuplexifyOptions ): Duplexify; } @@ -119,18 +119,18 @@ export interface MakeAuthenticatedRequest { (reqOpts: DecorateRequestOptions): Duplexify; ( reqOpts: DecorateRequestOptions, - options?: MakeAuthenticatedRequestOptions, + options?: MakeAuthenticatedRequestOptions ): void | Abortable; ( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | Abortable; ( reqOpts: DecorateRequestOptions, - optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback, + optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback ): void | Abortable | Duplexify; getCredentials: ( - callback: (err?: Error | null, credentials?: CredentialBody) => void, + callback: (err?: Error | null, credentials?: CredentialBody) => void ) => void; authClient: GoogleAuth; } @@ -233,9 +233,9 @@ export interface MakeWritableStreamOptions { fnobj: { onAuthenticated( err: Error | null, - authenticatedReqOpts?: r.Options, + authenticatedReqOpts?: r.Options ): void; - }, + } ): void; } @@ -300,7 +300,7 @@ export class ApiError extends Error { */ static createMultiErrorMessage( err: GoogleErrorBody, - errors?: GoogleInnerError[], + errors?: GoogleInnerError[] ): string { const messages: Set = new Set(); @@ -321,7 +321,7 @@ export class ApiError extends Error { if (messageArr.length > 1) { messageArr = messageArr.map((message, i) => ` ${i + 1}. ${message}`); messageArr.unshift( - 'Multiple errors occurred during the request. Please see the `errors` array for complete details.\n', + 'Multiple errors occurred during the request. Please see the `errors` array for complete details.\n' ); messageArr.push('\n'); } @@ -412,7 +412,7 @@ export class Util { err: Error | null, resp?: r.Response | null, body?: ResponseBody, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ) { callback = callback || util.noop; @@ -510,7 +510,7 @@ export class Util { makeWritableStream( dup: Duplexify, options: MakeWritableStreamOptions, - onComplete?: Function, + onComplete?: Function ) { onComplete = onComplete || util.noop; @@ -558,7 +558,7 @@ export class Util { } requestDefaults.headers = util._getDefaultHeaders( - reqOpts[GCCL_GCS_CMD_KEY], + reqOpts[GCCL_GCS_CMD_KEY] ); const request = teenyRequest.defaults(requestDefaults); request(authenticatedReqOpts!, (err, resp, body) => { @@ -625,7 +625,7 @@ export class Util { * @param {array} config.scopes - Array of scopes required for the API. */ makeAuthenticatedRequestFactory( - config: MakeAuthenticatedRequestFactoryConfig, + config: MakeAuthenticatedRequestFactoryConfig ) { const googleAutoAuthConfig = {...config}; if (googleAutoAuthConfig.projectId === DEFAULT_PROJECT_ID_TOKEN) { @@ -656,21 +656,19 @@ export class Util { * authenticated request options. */ function makeAuthenticatedRequest( - reqOpts: DecorateRequestOptions, + reqOpts: DecorateRequestOptions ): Duplexify; function makeAuthenticatedRequest( reqOpts: DecorateRequestOptions, - options?: MakeAuthenticatedRequestOptions, + options?: MakeAuthenticatedRequestOptions ): void | Abortable; function makeAuthenticatedRequest( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback, + callback?: BodyResponseCallback ): void | Abortable; function makeAuthenticatedRequest( reqOpts: DecorateRequestOptions, - optionsOrCallback?: - | MakeAuthenticatedRequestOptions - | BodyResponseCallback, + optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback ): void | Abortable | Duplexify { let stream: Duplexify; let projectId: string; @@ -693,7 +691,7 @@ export class Util { const onAuthenticated = async ( err: Error | null, - authenticatedReqOpts?: DecorateRequestOptions, + authenticatedReqOpts?: DecorateRequestOptions ) => { const authLibraryError = err; const autoAuthFailed = @@ -712,7 +710,7 @@ export class Util { // Try with existing `projectId` value authenticatedReqOpts = util.decorateRequest( authenticatedReqOpts!, - projectId, + projectId ); err = null; @@ -725,7 +723,7 @@ export class Util { authenticatedReqOpts = util.decorateRequest( authenticatedReqOpts!, - projectId, + projectId ); err = null; @@ -771,7 +769,7 @@ export class Util { apiResponseError = authLibraryError; } callback!(apiResponseError, ...params); - }, + } ); } }; @@ -820,7 +818,7 @@ export class Util { return onAuthenticated( null, - authorizedReqOpts as DecorateRequestOptions, + authorizedReqOpts as DecorateRequestOptions ); } catch (e) { return onAuthenticated(e as Error); @@ -868,7 +866,7 @@ export class Util { makeRequest( reqOpts: DecorateRequestOptions, config: MakeRequestConfig, - callback: BodyResponseCallback, + callback: BodyResponseCallback ): void | Abortable { let autoRetryValue = AUTO_RETRY_DEFAULT; if (config.autoRetry !== undefined) { @@ -885,7 +883,7 @@ export class Util { } requestDefaults.headers = this._getDefaultHeaders( - reqOpts[GCCL_GCS_CMD_KEY], + reqOpts[GCCL_GCS_CMD_KEY] ); const options = { request: teenyRequest.defaults(requestDefaults), @@ -915,7 +913,7 @@ export class Util { // eslint-disable-next-line @typescript-eslint/no-explicit-any (err: Error | null, response: {}, body: any) => { util.handleResp(err, response as {} as r.Response, body, callback!); - }, + } ); } const dup = config.stream as AbortableDuplex; @@ -1016,7 +1014,7 @@ export class Util { */ maybeOptionsOrCallback void>( optionsOrCallback?: T | C, - cb?: C, + cb?: C ): [T, C] { return typeof optionsOrCallback === 'function' ? [{} as T, optionsOrCallback as C] diff --git a/handwritten/storage/src/notification.ts b/handwritten/storage/src/notification.ts index 95b2e081188..6d63a899f2e 100644 --- a/handwritten/storage/src/notification.ts +++ b/handwritten/storage/src/notification.ts @@ -72,7 +72,7 @@ export interface GetNotificationCallback { ( err: Error | null, notification?: Notification | null, - apiResponse?: unknown, + apiResponse?: unknown ): void; } diff --git a/handwritten/storage/src/resumable-upload.ts b/handwritten/storage/src/resumable-upload.ts index af9e92a0cc2..07b5a28f191 100644 --- a/handwritten/storage/src/resumable-upload.ts +++ b/handwritten/storage/src/resumable-upload.ts @@ -109,7 +109,7 @@ export interface UploadConfig extends Pick { */ authClient?: { request: ( - opts: GaxiosOptions, + opts: GaxiosOptions ) => Promise> | GaxiosPromise; }; @@ -311,7 +311,7 @@ export class Upload extends Writable { */ authClient: { request: ( - opts: GaxiosOptions, + opts: GaxiosOptions ) => Promise> | GaxiosPromise; }; cacheKey: string; @@ -373,13 +373,13 @@ export class Upload extends Writable { if (cfg.offset && !cfg.uri) { throw new RangeError( - 'Cannot provide an `offset` without providing a `uri`', + 'Cannot provide an `offset` without providing a `uri`' ); } if (cfg.isPartialUpload && !cfg.chunkSize) { throw new RangeError( - 'Cannot set `isPartialUpload` without providing a `chunkSize`', + 'Cannot set `isPartialUpload` without providing a `chunkSize`' ); } @@ -546,7 +546,7 @@ export class Upload extends Writable { _write( chunk: Buffer | string, encoding: BufferEncoding, - readCallback = () => {}, + readCallback = () => {} ) { // Backwards-compatible event this.emit('writing'); @@ -590,7 +590,7 @@ export class Upload extends Writable { #validateChecksum( clientHash: string | undefined, serverHash: string | undefined, - hashType: 'CRC32C' | 'MD5', + hashType: 'CRC32C' | 'MD5' ): boolean { // Only validate if both client and server hashes are present. if (clientHash && serverHash) { @@ -823,7 +823,7 @@ export class Upload extends Writable { name: this.file, uploadType: 'resumable', }, - this.params, + this.params ), data: metadata, headers: { @@ -891,7 +891,7 @@ export class Upload extends Writable { factor: this.retryOptions.retryDelayMultiplier, maxTimeout: this.retryOptions.maxRetryDelay! * 1000, //convert to milliseconds maxRetryTime: this.retryOptions.totalTimeout! * 1000, //convert to milliseconds - }, + } ); this.uri = uri; @@ -1174,7 +1174,7 @@ export class Upload extends Writable { this.#validateChecksum( clientCrc32cToValidate, serverCrc32c, - 'CRC32C', + 'CRC32C' ) || this.#validateChecksum(clientMd5HashToValidate, serverMd5, 'MD5') ) { @@ -1207,7 +1207,7 @@ export class Upload extends Writable { * @returns the current upload status */ async checkUploadStatus( - config: CheckUploadStatusConfig = {}, + config: CheckUploadStatusConfig = {} ): Promise> { let googAPIClient = `${getRuntimeTrackingString()} gccl/${ packageJson.version @@ -1316,7 +1316,7 @@ export class Upload extends Writable { }; const res = await this.authClient.request<{error?: object}>( - combinedReqOpts, + combinedReqOpts ); if (res.data && res.data.error) { throw res.data.error; @@ -1387,8 +1387,8 @@ export class Upload extends Writable { if (retryDelay <= 0) { this.destroy( new Error( - `Retry total time limit exceeded - ${JSON.stringify(resp.data)}`, - ), + `Retry total time limit exceeded - ${JSON.stringify(resp.data)}` + ) ); return; } @@ -1410,7 +1410,7 @@ export class Upload extends Writable { this.numRetries++; } else { this.destroy( - new Error(`Retry limit exceeded - ${JSON.stringify(resp.data)}`), + new Error(`Retry limit exceeded - ${JSON.stringify(resp.data)}`) ); } } @@ -1464,7 +1464,7 @@ export function createURI(cfg: UploadConfig): Promise; export function createURI(cfg: UploadConfig, callback: CreateUriCallback): void; export function createURI( cfg: UploadConfig, - callback?: CreateUriCallback, + callback?: CreateUriCallback ): void | Promise { const up = new Upload(cfg); if (!callback) { @@ -1480,7 +1480,7 @@ export function createURI( * @returns the current upload status */ export function checkUploadStatus( - cfg: UploadConfig & Required>, + cfg: UploadConfig & Required> ) { const up = new Upload(cfg); diff --git a/handwritten/storage/src/signer.ts b/handwritten/storage/src/signer.ts index a657cef6133..879bc4d2a57 100644 --- a/handwritten/storage/src/signer.ts +++ b/handwritten/storage/src/signer.ts @@ -152,11 +152,11 @@ export class URLSigner { * move it before optional properties. In the next major we should refactor the * constructor of this class to only accept a config object. */ - private storage: Storage = new Storage(), + private storage: Storage = new Storage() ) {} getSignedUrl( - cfg: SignerGetSignedUrlConfig, + cfg: SignerGetSignedUrlConfig ): Promise { const expiresInSeconds = this.parseExpires(cfg.expires); const method = cfg.method; @@ -164,7 +164,7 @@ export class URLSigner { if (expiresInSeconds < accessibleAtInSeconds) { throw new Error( - SignerExceptionMessages.EXPIRATION_BEFORE_ACCESSIBLE_DATE, + SignerExceptionMessages.EXPIRATION_BEFORE_ACCESSIBLE_DATE ); } @@ -200,7 +200,7 @@ export class URLSigner { promise = this.getSignedUrlV4(config); } else { throw new Error( - `Invalid signed URL version: ${version}. Supported versions are 'v2' and 'v4'.`, + `Invalid signed URL version: ${version}. Supported versions are 'v2' and 'v4'.` ); } @@ -208,13 +208,13 @@ export class URLSigner { query = Object.assign(query, cfg.queryParams); const signedUrl = new url.URL( - cfg.host?.toString() || config.cname || this.storage.apiEndpoint, + cfg.host?.toString() || config.cname || this.storage.apiEndpoint ); signedUrl.pathname = this.getResourcePath( !!config.cname, this.bucket.name, - config.file, + config.file ); // eslint-disable-next-line @typescript-eslint/no-explicit-any signedUrl.search = qsStringify(query as any); @@ -223,15 +223,15 @@ export class URLSigner { } private getSignedUrlV2( - config: GetSignedUrlConfigInternal, + config: GetSignedUrlConfigInternal ): Promise { const canonicalHeadersString = this.getCanonicalHeaders( - config.extensionHeaders || {}, + config.extensionHeaders || {} ); const resourcePath = this.getResourcePath( false, config.bucket, - config.file, + config.file ); const blobToSign = [ @@ -247,7 +247,7 @@ export class URLSigner { try { const signature = await auth.sign( blobToSign, - config.signingEndpoint?.toString(), + config.signingEndpoint?.toString() ); const credentials = await auth.getCredentials(); @@ -267,7 +267,7 @@ export class URLSigner { } private getSignedUrlV4( - config: GetSignedUrlConfigInternal, + config: GetSignedUrlConfigInternal ): Promise { config.accessibleAt = config.accessibleAt ? config.accessibleAt @@ -279,13 +279,13 @@ export class URLSigner { // v4 limit expiration to be 7 days maximum if (expiresPeriodInSeconds > SEVEN_DAYS) { throw new Error( - `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).`, + `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).` ); } const extensionHeaders = Object.assign({}, config.extensionHeaders); const fqdn = new url.URL( - config.host?.toString() || config.cname || this.storage.apiEndpoint, + config.host?.toString() || config.cname || this.storage.apiEndpoint ); extensionHeaders.host = fqdn.hostname; if (config.contentMd5) { @@ -322,7 +322,7 @@ export class URLSigner { const credential = `${credentials.client_email}/${credentialScope}`; const dateISO = formatAsUTCISO( config.accessibleAt ? config.accessibleAt : new Date(), - true, + true ); const queryParams: Query = { 'X-Goog-Algorithm': 'GOOG4-RSA-SHA256', @@ -342,7 +342,7 @@ export class URLSigner { canonicalQueryParams, extensionHeadersString, signedHeaders, - contentSha256, + contentSha256 ); const hash = crypto @@ -360,7 +360,7 @@ export class URLSigner { try { const signature = await this.auth.sign( blobToSign, - config.signingEndpoint?.toString(), + config.signingEndpoint?.toString() ); const signatureHex = Buffer.from(signature, 'base64').toString('hex'); const signedQuery: Query = Object.assign({}, queryParams, { @@ -421,7 +421,7 @@ export class URLSigner { query: string, headers: string, signedHeaders: string, - contentSha256?: string, + contentSha256?: string ) { return [ method, @@ -453,7 +453,7 @@ export class URLSigner { parseExpires( expires: string | number | Date, - current: Date = new Date(), + current: Date = new Date() ): number { const expiresInMSeconds = new Date(expires).valueOf(); @@ -470,7 +470,7 @@ export class URLSigner { parseAccessibleAt(accessibleAt?: string | number | Date): number { const accessibleAtInMSeconds = new Date( - accessibleAt || new Date(), + accessibleAt || new Date() ).valueOf(); if (isNaN(accessibleAtInMSeconds)) { diff --git a/handwritten/storage/src/storage.ts b/handwritten/storage/src/storage.ts index dd0f735f6ed..ab036e15b0e 100644 --- a/handwritten/storage/src/storage.ts +++ b/handwritten/storage/src/storage.ts @@ -43,7 +43,7 @@ export interface GetServiceAccountCallback { ( err: Error | null, serviceAccount?: ServiceAccount, - apiResponse?: unknown, + apiResponse?: unknown ): void; } @@ -176,7 +176,7 @@ export interface GetBucketsCallback { err: Error | null, buckets: Bucket[], nextQuery?: {}, - apiResponse?: unknown, + apiResponse?: unknown ): void; } export interface GetBucketsRequest { @@ -209,7 +209,7 @@ export interface CreateHmacKeyCallback { err: Error | null, hmacKey?: HmacKey | null, secret?: string | null, - apiResponse?: HmacKeyResourceResponse, + apiResponse?: HmacKeyResourceResponse ): void; } @@ -229,7 +229,7 @@ export interface GetHmacKeysCallback { err: Error | null, hmacKeys: HmacKey[] | null, nextQuery?: {}, - apiResponse?: unknown, + apiResponse?: unknown ): void; } @@ -858,18 +858,18 @@ export class Storage extends Service { createBucket( name: string, - metadata?: CreateBucketRequest, + metadata?: CreateBucketRequest ): Promise; createBucket(name: string, callback: BucketCallback): void; createBucket( name: string, metadata: CreateBucketRequest, - callback: BucketCallback, + callback: BucketCallback ): void; createBucket( name: string, metadata: CreateBucketRequest, - callback: BucketCallback, + callback: BucketCallback ): void; /** * @typedef {array} CreateBucketResponse @@ -999,7 +999,7 @@ export class Storage extends Service { createBucket( name: string, metadataOrCallback?: BucketCallback | CreateBucketRequest, - callback?: BucketCallback, + callback?: BucketCallback ): Promise | void { if (!name) { throw new Error(StorageExceptionMessages.BUCKET_NAME_REQUIRED_CREATE); @@ -1028,14 +1028,14 @@ export class Storage extends Service { standard: 'STANDARD', } as const; const storageClassKeys = Object.keys( - storageClasses, + storageClasses ) as (keyof typeof storageClasses)[]; for (const storageClass of storageClassKeys) { if (body[storageClass]) { if (metadata.storageClass && metadata.storageClass !== storageClass) { throw new Error( - `Both \`${storageClass}\` and \`storageClass\` were provided.`, + `Both \`${storageClass}\` and \`storageClass\` were provided.` ); } body.storageClass = storageClasses[storageClass]; @@ -1096,22 +1096,22 @@ export class Storage extends Service { bucket.metadata = resp; callback!(null, bucket, resp); - }, + } ); } createHmacKey( serviceAccountEmail: string, - options?: CreateHmacKeyOptions, + options?: CreateHmacKeyOptions ): Promise; createHmacKey( serviceAccountEmail: string, - callback: CreateHmacKeyCallback, + callback: CreateHmacKeyCallback ): void; createHmacKey( serviceAccountEmail: string, options: CreateHmacKeyOptions, - callback: CreateHmacKeyCallback, + callback: CreateHmacKeyCallback ): void; /** * @typedef {object} CreateHmacKeyOptions @@ -1189,7 +1189,7 @@ export class Storage extends Service { createHmacKey( serviceAccountEmail: string, optionsOrCb?: CreateHmacKeyOptions | CreateHmacKeyCallback, - cb?: CreateHmacKeyCallback, + cb?: CreateHmacKeyCallback ): Promise | void { if (typeof serviceAccountEmail !== 'string') { throw new Error(StorageExceptionMessages.HMAC_SERVICE_ACCOUNT); @@ -1223,7 +1223,7 @@ export class Storage extends Service { hmacKey.metadata = resp.metadata; callback!(null, hmacKey, resp.secret, resp); - }, + } ); } @@ -1319,11 +1319,11 @@ export class Storage extends Service { */ getBuckets( optionsOrCallback?: GetBucketsRequest | GetBucketsCallback, - cb?: GetBucketsCallback, + cb?: GetBucketsCallback ): void | Promise { const {options, callback} = normalize( optionsOrCallback, - cb, + cb ); options.project = options.project || this.projectId; @@ -1365,7 +1365,7 @@ export class Storage extends Service { : null; callback(null, buckets, nextQuery, resp); - }, + } ); } @@ -1457,7 +1457,7 @@ export class Storage extends Service { getHmacKeys(options: GetHmacKeysOptions, callback: GetHmacKeysCallback): void; getHmacKeys( optionsOrCb?: GetHmacKeysOptions | GetHmacKeysCallback, - cb?: GetHmacKeysCallback, + cb?: GetHmacKeysCallback ): Promise | void { const {options, callback} = normalize(optionsOrCb, cb); const query = Object.assign({}, options); @@ -1489,19 +1489,19 @@ export class Storage extends Service { : null; callback(null, hmacKeys, nextQuery, resp); - }, + } ); } getServiceAccount( - options?: GetServiceAccountOptions, + options?: GetServiceAccountOptions ): Promise; getServiceAccount( - options?: GetServiceAccountOptions, + options?: GetServiceAccountOptions ): Promise; getServiceAccount( options: GetServiceAccountOptions, - callback: GetServiceAccountCallback, + callback: GetServiceAccountCallback ): void; getServiceAccount(callback: GetServiceAccountCallback): void; /** @@ -1554,11 +1554,11 @@ export class Storage extends Service { */ getServiceAccount( optionsOrCallback?: GetServiceAccountOptions | GetServiceAccountCallback, - cb?: GetServiceAccountCallback, + cb?: GetServiceAccountCallback ): void | Promise { const {options, callback} = normalize( optionsOrCallback, - cb, + cb ); this.request( { @@ -1577,14 +1577,14 @@ export class Storage extends Service { // eslint-disable-next-line no-prototype-builtins if (resp.hasOwnProperty(prop)) { const camelCaseProp = prop.replace(/_(\w)/g, (_, match) => - match.toUpperCase(), + match.toUpperCase() ); camelCaseResponse[camelCaseProp] = resp[prop]; } } callback(null, camelCaseResponse, resp); - }, + } ); } diff --git a/handwritten/storage/src/transfer-manager.ts b/handwritten/storage/src/transfer-manager.ts index be34c76f08e..dd4e41eeb31 100644 --- a/handwritten/storage/src/transfer-manager.ts +++ b/handwritten/storage/src/transfer-manager.ts @@ -96,7 +96,7 @@ export interface UploadManyFilesOptions { concurrencyLimit?: number; customDestinationBuilder?( path: string, - options: UploadManyFilesOptions, + options: UploadManyFilesOptions ): string; skipIfExists?: boolean; prefix?: string; @@ -140,7 +140,7 @@ export interface MultiPartUploadHelper { uploadPart( partNumber: number, chunk: Buffer, - validation?: 'md5' | false, + validation?: 'md5' | false ): Promise; completeUpload(): Promise; abortUpload(): Promise; @@ -150,14 +150,14 @@ export type MultiPartHelperGenerator = ( bucket: Bucket, fileName: string, uploadId?: string, - partsMap?: Map, + partsMap?: Map ) => MultiPartUploadHelper; const defaultMultiPartGenerator: MultiPartHelperGenerator = ( bucket, fileName, uploadId, - partsMap, + partsMap ) => { return new XMLMultiPartUploadHelper(bucket, fileName, uploadId, partsMap); }; @@ -169,7 +169,7 @@ export class MultiPartUploadError extends Error { constructor( message: string, uploadId: string, - partsMap: Map, + partsMap: Map ) { super(message); this.uploadId = uploadId; @@ -198,7 +198,7 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper { bucket: Bucket, fileName: string, uploadId?: string, - partsMap?: Map, + partsMap?: Map ) { this.authClient = bucket.storage.authClient || new GoogleAuth(); this.uploadId = uploadId || ''; @@ -289,7 +289,7 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper { async uploadPart( partNumber: number, chunk: Buffer, - validation?: 'md5' | false, + validation?: 'md5' | false ): Promise { const url = `${this.baseUrl}?partNumber=${partNumber}&uploadId=${this.uploadId}`; let headers: Headers = this.#setGoogApiClientHeaders(); @@ -327,14 +327,14 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper { async completeUpload(): Promise { const url = `${this.baseUrl}?uploadId=${this.uploadId}`; const sortedMap = new Map( - [...this.partsMap.entries()].sort((a, b) => a[0] - b[0]), + [...this.partsMap.entries()].sort((a, b) => a[0] - b[0]) ); const parts: {}[] = []; for (const entry of sortedMap.entries()) { parts.push({PartNumber: entry[0], ETag: entry[1]}); } const body = `${this.xmlBuilder.build( - parts, + parts )}`; return AsyncRetry(async bail => { try { @@ -456,7 +456,7 @@ export class TransferManager { */ async uploadManyFiles( filePathsOrDirectory: string[] | string, - options: UploadManyFilesOptions = {}, + options: UploadManyFilesOptions = {} ): Promise { if (options.skipIfExists && options.passthroughOptions?.preconditionOpts) { options.passthroughOptions.preconditionOpts.ifGenerationMatch = 0; @@ -472,13 +472,13 @@ export class TransferManager { } const limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_UPLOAD_LIMIT, + options.concurrencyLimit || DEFAULT_PARALLEL_UPLOAD_LIMIT ); const promises: Promise[] = []; let allPaths: string[] = []; if (!Array.isArray(filePathsOrDirectory)) { for await (const curPath of this.getPathsFromDirectory( - filePathsOrDirectory, + filePathsOrDirectory )) { allPaths.push(curPath); } @@ -503,14 +503,14 @@ export class TransferManager { if (options.prefix) { passThroughOptionsCopy.destination = path.posix.join( ...options.prefix.split(path.sep), - passThroughOptionsCopy.destination, + passThroughOptionsCopy.destination ); } promises.push( limit(() => - this.bucket.upload(filePath, passThroughOptionsCopy as UploadOptions), - ), + this.bucket.upload(filePath, passThroughOptionsCopy as UploadOptions) + ) ); } @@ -565,10 +565,10 @@ export class TransferManager { */ async downloadManyFiles( filesOrFolder: File[] | string[] | string, - options: DownloadManyFilesOptions = {}, + options: DownloadManyFilesOptions = {} ): Promise { const limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_DOWNLOAD_LIMIT, + options.concurrencyLimit || DEFAULT_PARALLEL_DOWNLOAD_LIMIT ); const promises: Promise[] = []; let files: File[] = []; @@ -602,7 +602,7 @@ export class TransferManager { passThroughOptionsCopy.destination = path.join( options.prefix || '', passThroughOptionsCopy.destination || '', - file.name, + file.name ); } if (options.stripPrefix) { @@ -626,7 +626,7 @@ export class TransferManager { } return file.download(passThroughOptionsCopy); - }), + }) ); } @@ -668,12 +668,12 @@ export class TransferManager { */ async downloadFileInChunks( fileOrName: File | string, - options: DownloadFileInChunksOptions = {}, + options: DownloadFileInChunksOptions = {} ): Promise { let chunkSize = options.chunkSizeBytes || DOWNLOAD_IN_CHUNKS_DEFAULT_CHUNK_SIZE; let limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_DOWNLOAD_LIMIT, + options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_DOWNLOAD_LIMIT ); const noReturnData = Boolean(options.noReturnData); const promises: Promise[] = []; @@ -708,11 +708,11 @@ export class TransferManager { resp[0], 0, resp[0].length, - chunkStart, + chunkStart ); if (noReturnData) return; return result.buffer; - }), + }) ); start += chunkSize; @@ -729,7 +729,7 @@ export class TransferManager { const downloadedCrc32C = await CRC32C.fromFile(filePath); if (!downloadedCrc32C.validate(fileInfo[0].metadata.crc32c)) { const mismatchError = new RequestError( - FileExceptionMessages.DOWNLOAD_MISMATCH, + FileExceptionMessages.DOWNLOAD_MISMATCH ); mismatchError.code = 'CONTENT_DOWNLOAD_MISMATCH'; throw mismatchError; @@ -786,12 +786,12 @@ export class TransferManager { async uploadFileInChunks( filePath: string, options: UploadFileInChunksOptions = {}, - generator: MultiPartHelperGenerator = defaultMultiPartGenerator, + generator: MultiPartHelperGenerator = defaultMultiPartGenerator ): Promise { const chunkSize = options.chunkSizeBytes || UPLOAD_IN_CHUNKS_DEFAULT_CHUNK_SIZE; const limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_UPLOAD_LIMIT, + options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_UPLOAD_LIMIT ); const maxQueueSize = options.maxQueueSize || @@ -802,7 +802,7 @@ export class TransferManager { this.bucket, fileName, options.uploadId, - options.partsMap, + options.partsMap ); let partNumber = 1; let promises: Promise[] = []; @@ -824,8 +824,8 @@ export class TransferManager { } promises.push( limit(() => - mpuHelper.uploadPart(partNumber++, curChunk, options.validation), - ), + mpuHelper.uploadPart(partNumber++, curChunk, options.validation) + ) ); } await Promise.all(promises); @@ -842,20 +842,20 @@ export class TransferManager { throw new MultiPartUploadError( (e as Error).message, mpuHelper.uploadId!, - mpuHelper.partsMap!, + mpuHelper.partsMap! ); } } throw new MultiPartUploadError( (e as Error).message, mpuHelper.uploadId!, - mpuHelper.partsMap!, + mpuHelper.partsMap! ); } } private async *getPathsFromDirectory( - directory: string, + directory: string ): AsyncGenerator { const filesAndSubdirectories = await fsp.readdir(directory, { withFileTypes: true, diff --git a/handwritten/storage/src/util.ts b/handwritten/storage/src/util.ts index 4957a210b6c..259f7c0f3e8 100644 --- a/handwritten/storage/src/util.ts +++ b/handwritten/storage/src/util.ts @@ -26,7 +26,7 @@ const isEsm = true; export function normalize( optionsOrCallback?: T | U, - cb?: U, + cb?: U ) { const options = ( typeof optionsOrCallback === 'object' ? optionsOrCallback : {} @@ -58,7 +58,7 @@ export function objectEntries(obj: {[key: string]: T}): Array<[string, T]> { export function fixedEncodeURIComponent(str: string): string { return encodeURIComponent(str).replace( /[!'()*]/g, - c => '%' + c.charCodeAt(0).toString(16).toUpperCase(), + c => '%' + c.charCodeAt(0).toString(16).toUpperCase() ); } @@ -110,7 +110,7 @@ export function unicodeJSONStringify(obj: object) { return JSON.stringify(obj).replace( /[\u0080-\uFFFF]/g, (char: string) => - '\\u' + ('0000' + char.charCodeAt(0).toString(16)).slice(-4), + '\\u' + ('0000' + char.charCodeAt(0).toString(16)).slice(-4) ); } @@ -154,7 +154,7 @@ export function formatAsUTCISO( dateTimeToFormat: Date, includeTime = false, dateDelimiter = '', - timeDelimiter = '', + timeDelimiter = '' ): string { const year = dateTimeToFormat.getUTCFullYear(); const month = dateTimeToFormat.getUTCMonth() + 1; @@ -246,7 +246,7 @@ export class PassThroughShim extends PassThrough { _write( chunk: never, encoding: BufferEncoding, - callback: (error?: Error | null | undefined) => void, + callback: (error?: Error | null | undefined) => void ): void { if (this.shouldEmitWriting) { this.emit('writing'); diff --git a/handwritten/storage/system-test/common.ts b/handwritten/storage/system-test/common.ts index b0364218b5a..17bc59b6142 100644 --- a/handwritten/storage/system-test/common.ts +++ b/handwritten/storage/system-test/common.ts @@ -52,7 +52,7 @@ describe('Common', () => { assert.ifError(err); assert.strictEqual(resp, mockResponse); mockServer.close(done); - }, + } ); }); @@ -80,7 +80,7 @@ describe('Common', () => { assert.strictEqual((err! as common.ApiError).code, 408); assert.strictEqual(numRequestAttempts, 4); mockServer.close(done); - }, + } ); }); @@ -108,7 +108,7 @@ describe('Common', () => { assert(err?.message.includes('ECONNREFUSED')); const timeResponse = Date.now(); assert(timeResponse - timeRequest > minExpectedResponseTime); - }, + } ); done(); }); diff --git a/handwritten/storage/system-test/kitchen.ts b/handwritten/storage/system-test/kitchen.ts index fbfe9bd2eff..e63615f7ba8 100644 --- a/handwritten/storage/system-test/kitchen.ts +++ b/handwritten/storage/system-test/kitchen.ts @@ -110,7 +110,7 @@ describe('resumable-upload', () => { file: filePath, retryOptions: retryOptions, metadata: {contentType: 'image/jpg'}, - }), + }) ) .on('error', done) .on('response', resp => { @@ -138,7 +138,7 @@ describe('resumable-upload', () => { type DoUploadCallback = (...args: any[]) => void; const doUpload = ( opts: {interrupt?: boolean}, - callback: DoUploadCallback, + callback: DoUploadCallback ) => { let sizeStreamed = 0; let destroyed = false; @@ -183,7 +183,7 @@ describe('resumable-upload', () => { assert.strictEqual(metadata.size, size); assert.strictEqual(typeof metadata.size, 'number'); done(); - }, + } ); }); }); @@ -223,7 +223,7 @@ describe('resumable-upload', () => { file: filePath, metadata, retryOptions: retryOptions, - }), + }) ) .on('error', (err: ErrorWithCode) => { assert.strictEqual(err.status, 400); @@ -244,8 +244,8 @@ describe('resumable-upload', () => { file.createWriteStream({ chunkSize, }), - e => (e ? reject(e) : resolve()), - ), + e => (e ? reject(e) : resolve()) + ) ); const [results] = await file.getMetadata(); @@ -291,7 +291,7 @@ describe('resumable-upload', () => { }); await new Promise((resolve, reject) => - pipeline(readable, writable, e => (e ? reject(e) : resolve())), + pipeline(readable, writable, e => (e ? reject(e) : resolve())) ); } @@ -302,7 +302,7 @@ describe('resumable-upload', () => { assert.equal( crc32cGenerated, count, - 'crc32c should be generated on each upload', + 'crc32c should be generated on each upload' ); assert.equal(results.size, FILE_SIZE); }); @@ -326,14 +326,14 @@ describe('resumable-upload', () => { crc32c: true, clientCrc32c: crc32c, retryOptions: retryOptions, - }), + }) ) .on('error', err => { console.log(err); done( new Error( - `Upload failed unexpectedly on success path: ${err.message}`, - ), + `Upload failed unexpectedly on success path: ${err.message}` + ) ); }) .on('response', resp => { @@ -357,12 +357,12 @@ describe('resumable-upload', () => { clientCrc32c: KNOWN_CRC32C_OF_ZEROS, crc32c: true, retryOptions: retryOptions, - }), + }) ) .on('error', (err: Error) => { assert.ok( err.message.includes(EXPECTED_ERROR_MESSAGE_PART), - `Expected error message part "${EXPECTED_ERROR_MESSAGE_PART}" not found in: ${err.message}`, + `Expected error message part "${EXPECTED_ERROR_MESSAGE_PART}" not found in: ${err.message}` ); done(); }); diff --git a/handwritten/storage/system-test/storage.ts b/handwritten/storage/system-test/storage.ts index 2f14fe01296..15257fb59db 100644 --- a/handwritten/storage/system-test/storage.ts +++ b/handwritten/storage/system-test/storage.ts @@ -92,20 +92,20 @@ describe('storage', function () { logo: { path: path.join( getDirName(), - '../../../system-test/data/CloudPlatform_128px_Retina.png', + '../../../system-test/data/CloudPlatform_128px_Retina.png' ), }, big: { path: path.join( getDirName(), - '../../../system-test/data/three-mb-file.tif', + '../../../system-test/data/three-mb-file.tif' ), hash: undefined, }, html: { path: path.join( getDirName(), - '../../../system-test/data/long-html-file.html', + '../../../system-test/data/long-html-file.html' ), }, empty: { @@ -205,7 +205,7 @@ describe('storage', function () { await assert.rejects( file.download(), (err: Error) => - err.message.indexOf('does not have storage.objects.get') > -1, + err.message.indexOf('does not have storage.objects.get') > -1 ); }); @@ -218,7 +218,7 @@ describe('storage', function () { /does not have storage\.objects\.create access/, ]; assert( - allowedErrorMessages.some(msg => msg.test((e as Error).message)), + allowedErrorMessages.some(msg => msg.test((e as Error).message)) ); } }); @@ -231,7 +231,7 @@ describe('storage', function () { // Introduce a delay between tests to avoid getting an error. beforeEach(async () => { await new Promise(resolve => - setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME), + setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME) ); }); @@ -270,7 +270,7 @@ describe('storage', function () { const [accessControlGet] = await bucket.acl.get(opts); assert.strictEqual( (accessControlGet as AccessControlObject).role, - storage.acl.OWNER_ROLE, + storage.acl.OWNER_ROLE ); await bucket.acl.delete(opts); }); @@ -302,7 +302,7 @@ describe('storage', function () { role: 'READER', }); await new Promise(resolve => - setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME), + setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME) ); await bucket.acl.delete({entity: 'allUsers'}); }); @@ -314,13 +314,13 @@ describe('storage', function () { */ it.skip('should make files public', async () => { await Promise.all( - ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)), + ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)) ); await bucket.makePublic({includeFiles: true}); const [files] = await bucket.getFiles(); const resps = await Promise.all( - files.map(file => isFilePublicAsync(file)), + files.map(file => isFilePublicAsync(file)) ); resps.forEach(resp => assert.strictEqual(resp, true)); await Promise.all([ @@ -338,7 +338,7 @@ describe('storage', function () { try { await bucket.makePublic(); await new Promise(resolve => - setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME), + setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME) ); await bucket.makePrivate(); assert.rejects(bucket.acl.get({entity: 'allUsers'}), err => { @@ -352,13 +352,13 @@ describe('storage', function () { it('should make files private', async () => { await Promise.all( - ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)), + ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)) ); await bucket.makePrivate({includeFiles: true}); const [files] = await bucket.getFiles(); const resps = await Promise.all( - files.map(file => isFilePublicAsync(file)), + files.map(file => isFilePublicAsync(file)) ); resps.forEach(resp => { assert.strictEqual(resp, false); @@ -400,7 +400,7 @@ describe('storage', function () { const [accessControlGet] = await file.acl.get({entity: USER_ACCOUNT}); assert.strictEqual( (accessControlGet as AccessControlObject).role, - storage.acl.OWNER_ROLE, + storage.acl.OWNER_ROLE ); await file.acl.delete({entity: USER_ACCOUNT}); }); @@ -444,7 +444,7 @@ describe('storage', function () { assert.doesNotReject(file.makePrivate()); assert.rejects( file.acl.get({entity: 'allUsers'}), - validateMakeFilePrivateRejects, + validateMakeFilePrivateRejects ); }); @@ -517,11 +517,11 @@ describe('storage', function () { bucket.upload(FILES.big.path, { resumable: true, private: true, - }), + }) ); assert.rejects( file.acl.get({entity: 'allUsers'}), - validateMakeFilePrivateRejects, + validateMakeFilePrivateRejects ); }); }); @@ -574,7 +574,7 @@ describe('storage', function () { const legacyBucketReaderBinding = newPolicy!.bindings.filter( binding => { return binding.role === 'roles/storage.legacyBucketReader'; - }, + } )[0]; assert(legacyBucketReaderBinding.members.includes('allUsers')); }); @@ -641,7 +641,7 @@ describe('storage', function () { const setPublicAccessPrevention = ( bucket: Bucket, - configuration: string, + configuration: string ) => { return bucket.setMetadata({ iamConfiguration: { @@ -651,14 +651,14 @@ describe('storage', function () { }; const validateUnexpectedPublicAccessPreventionValueError = ( - err: ApiError, + err: ApiError ) => { assert.strictEqual(err.code, 400); return true; }; const validateConfiguringPublicAccessWhenPAPEnforcedError = ( - err: ApiError, + err: ApiError ) => { assert.strictEqual(err.code, 412); return true; @@ -669,14 +669,14 @@ describe('storage', function () { it('inserts a bucket with enforced public access prevention', async () => { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_ENFORCED, + PUBLIC_ACCESS_PREVENTION_ENFORCED ); const [bucketMetadata] = await bucket.getMetadata(); const publicAccessPreventionStatus = bucketMetadata!.iamConfiguration!.publicAccessPrevention; return assert.strictEqual( publicAccessPreventionStatus, - PUBLIC_ACCESS_PREVENTION_ENFORCED, + PUBLIC_ACCESS_PREVENTION_ENFORCED ); }); @@ -696,21 +696,21 @@ describe('storage', function () { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_ENFORCED, + PUBLIC_ACCESS_PREVENTION_ENFORCED ); }); it('bucket cannot be made public', async () => { return assert.rejects( () => bucket.makePublic(), - validateConfiguringPublicAccessWhenPAPEnforcedError, + validateConfiguringPublicAccessWhenPAPEnforcedError ); }); it('object cannot be made public via ACL', async () => { return assert.rejects( () => file.makePublic(), - validateConfiguringPublicAccessWhenPAPEnforcedError, + validateConfiguringPublicAccessWhenPAPEnforcedError ); }); }); @@ -718,21 +718,21 @@ describe('storage', function () { it('inserts a bucket with inherited public access prevention', async () => { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_INHERITED, + PUBLIC_ACCESS_PREVENTION_INHERITED ); const [bucketMetadata] = await bucket.getMetadata(); const publicAccessPreventionStatus = bucketMetadata!.iamConfiguration!.publicAccessPrevention; return assert.strictEqual( publicAccessPreventionStatus, - PUBLIC_ACCESS_PREVENTION_INHERITED, + PUBLIC_ACCESS_PREVENTION_INHERITED ); }); it('makes public a bucket with inherited public access prevention', async () => { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_INHERITED, + PUBLIC_ACCESS_PREVENTION_INHERITED ); return assert.ok(() => bucket.makePublic()); }); @@ -740,7 +740,7 @@ describe('storage', function () { it('should fail to insert a bucket with unexpected public access prevention value', async () => { await assert.rejects( () => setPublicAccessPrevention(bucket, 'unexpected value'), - validateUnexpectedPublicAccessPreventionValueError, + validateUnexpectedPublicAccessPreventionValueError ); }); @@ -758,7 +758,7 @@ describe('storage', function () { const [updatedBucketMetadata] = await bucket.getMetadata(); return assert.strictEqual( updatedBucketMetadata!.iamConfiguration!.publicAccessPrevention, - publicAccessPreventionStatus, + publicAccessPreventionStatus ); }); @@ -775,13 +775,13 @@ describe('storage', function () { bucketMetadata!.iamConfiguration!.uniformBucketLevelAccess!.enabled; await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_INHERITED, + PUBLIC_ACCESS_PREVENTION_INHERITED ); const [updatedBucketMetadata] = await bucket.getMetadata(); return assert.strictEqual( updatedBucketMetadata!.iamConfiguration!.uniformBucketLevelAccess! .enabled, - ublaSetting, + ublaSetting ); }); }); @@ -799,7 +799,7 @@ describe('storage', function () { const setTurboReplication = ( bucket: Bucket, - turboReplicationConfiguration: string, + turboReplicationConfiguration: string ) => { return bucket.setMetadata({ rpo: turboReplicationConfiguration, @@ -925,7 +925,7 @@ describe('storage', function () { assert(metadata[0].softDeletePolicy.effectiveTime); assert.deepStrictEqual( metadata[0].softDeletePolicy.retentionDurationSeconds, - SOFT_DELETE_RETENTION_SECONDS.toString(), + SOFT_DELETE_RETENTION_SECONDS.toString() ); }); @@ -954,7 +954,7 @@ describe('storage', function () { assert(softDeletedFile); assert.strictEqual( softDeletedFile.metadata.generation, - metadata.generation, + metadata.generation ); }); @@ -988,7 +988,7 @@ describe('storage', function () { assert.strictEqual(softDeletedFiles.length, 2); assert.notStrictEqual( softDeletedFiles![0].metadata.restoreToken, - undefined, + undefined ); }); @@ -1004,7 +1004,7 @@ describe('storage', function () { assert(softDeletedFile); assert.strictEqual( softDeletedFile.metadata.generation, - metadata.generation, + metadata.generation ); assert.notStrictEqual(softDeletedFile.metadata.restoreToken, undefined); }); @@ -1023,7 +1023,7 @@ describe('storage', function () { assert(softDeletedFile); const restoredFile = await f1.restore({ generation: parseInt( - softDeletedFile.metadata.generation?.toString() || '0', + softDeletedFile.metadata.generation?.toString() || '0' ), restoreToken: softDeletedFile.metadata.restoreToken, }); @@ -1129,7 +1129,7 @@ describe('storage', function () { await new Promise(res => setTimeout(res, UNIFORM_ACCESS_WAIT_TIME)); } catch (err) { assert( - validateUniformBucketLevelAccessEnabledError(err as ApiError), + validateUniformBucketLevelAccessEnabledError(err as ApiError) ); break; } @@ -1144,7 +1144,7 @@ describe('storage', function () { await new Promise(res => setTimeout(res, UNIFORM_ACCESS_WAIT_TIME)); } catch (err) { assert( - validateUniformBucketLevelAccessEnabledError(err as ApiError), + validateUniformBucketLevelAccessEnabledError(err as ApiError) ); break; } @@ -1261,7 +1261,7 @@ describe('storage', function () { after(async () => { await Promise.all( - bucketsToCreate.map(bucket => storage.bucket(bucket).delete()), + bucketsToCreate.map(bucket => storage.bucket(bucket).delete()) ); }); @@ -1404,7 +1404,7 @@ describe('storage', function () { const [metadata] = await bucket.getMetadata(); assert.deepStrictEqual( metadata.labels, - Object.assign({}, LABELS, newLabels), + Object.assign({}, LABELS, newLabels) ); }); @@ -1491,7 +1491,7 @@ describe('storage', function () { }); assert.strictEqual( bucket.metadata.lifecycle!.rule!.length, - numExistingRules + 2, + numExistingRules + 2 ); }); @@ -1512,8 +1512,8 @@ describe('storage', function () { rule.action.type === 'Delete' && typeof rule.condition.matchesPrefix === 'object' && (rule.condition.matchesPrefix as string[]).length === 1 && - Array.isArray(rule.condition.matchesPrefix), - ), + Array.isArray(rule.condition.matchesPrefix) + ) ); }); @@ -1532,8 +1532,8 @@ describe('storage', function () { (rule: LifecycleRule) => typeof rule.action === 'object' && rule.action.type === 'Delete' && - Array.isArray(rule.condition.matchesPrefix), - ), + Array.isArray(rule.condition.matchesPrefix) + ) ); }); @@ -1576,8 +1576,8 @@ describe('storage', function () { typeof rule.action === 'object' && rule.action.type === 'Delete' && rule.condition.noncurrentTimeBefore === NONCURRENT_TIME_BEFORE && - rule.condition.daysSinceNoncurrentTime === 100, - ), + rule.condition.daysSinceNoncurrentTime === 100 + ) ); }); @@ -1600,8 +1600,8 @@ describe('storage', function () { typeof rule.action === 'object' && rule.action.type === 'Delete' && rule.condition.customTimeBefore === CUSTOM_TIME_BEFORE && - rule.condition.daysSinceCustomTime === 100, - ), + rule.condition.daysSinceCustomTime === 100 + ) ); }); @@ -1701,7 +1701,7 @@ describe('storage', function () { await storage.createBucket(bucket.name); const [metadata] = await bucket.getMetadata(); assert( - [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled), + [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled) ); }); @@ -1711,7 +1711,7 @@ describe('storage', function () { }); const [metadata] = await bucket.getMetadata(); assert( - [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled), + [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled) ); }); @@ -1742,7 +1742,7 @@ describe('storage', function () { await bucket.getMetadata(); assert.strictEqual( bucket.metadata!.retentionPolicy!.retentionPeriod, - `${RETENTION_DURATION_SECONDS}`, + `${RETENTION_DURATION_SECONDS}` ); }); @@ -1753,7 +1753,7 @@ describe('storage', function () { await bucket.getMetadata(); assert.strictEqual( bucket.metadata!.retentionPolicy!.retentionPeriod, - `${RETENTION_DURATION_SECONDS}`, + `${RETENTION_DURATION_SECONDS}` ); }); @@ -1768,7 +1768,7 @@ describe('storage', function () { bucket.setRetentionPeriod(RETENTION_DURATION_SECONDS / 2), (err: ApiError) => { return err.code === 403; - }, + } ); }); @@ -1779,7 +1779,7 @@ describe('storage', function () { await bucket.getMetadata(); assert.strictEqual( bucket.metadata!.retentionPolicy!.retentionPeriod, - `${RETENTION_DURATION_SECONDS}`, + `${RETENTION_DURATION_SECONDS}` ); await bucket.removeRetentionPeriod(); @@ -1853,12 +1853,12 @@ describe('storage', function () { after(async () => { await new Promise(resolve => - setTimeout(resolve, RETENTION_PERIOD_SECONDS * 1000), + setTimeout(resolve, RETENTION_PERIOD_SECONDS * 1000) ); await Promise.all( FILES.map(async file => { return file.delete(); - }), + }) ); }); @@ -1946,7 +1946,7 @@ describe('storage', function () { const file = new File(objectRetentionBucket, fileName); const [metadata] = await file.setMetadata( {retention: null}, - {overrideUnlockedRetention: true}, + {overrideUnlockedRetention: true} ); assert.strictEqual(metadata.retention, undefined); }); @@ -2047,7 +2047,7 @@ describe('storage', function () { // Get the service account for the "second" account (the // one that will read the requester pays file). const clientEmail = JSON.parse( - fs.readFileSync(key2!, 'utf-8'), + fs.readFileSync(key2!, 'utf-8') ).client_email; policy.bindings.push({ role: 'roles/storage.admin', @@ -2096,7 +2096,7 @@ describe('storage', function () { * @returns The result of the successful request pays operation. */ async function requesterPaysDoubleTest( - testFunction: F, + testFunction: F ): Promise> { const failureMessage = 'Bucket is a requester pays bucket but no user project provided.'; @@ -2106,7 +2106,7 @@ describe('storage', function () { (err as Error).message.includes(failureMessage), `Expected '${ (err as Error).message - }' to include '${failureMessage}'`, + }' to include '${failureMessage}'` ); return true; }); @@ -2129,14 +2129,14 @@ describe('storage', function () { await bucketNonAllowList.combine( sourceFiles, destinationFile, - USER_PROJECT_OPTIONS, + USER_PROJECT_OPTIONS ); // eslint-disable-next-line @typescript-eslint/no-explicit-any function createFileAsync(fileObject: any) { return fileObject.file.save( fileObject.contents, - USER_PROJECT_OPTIONS, + USER_PROJECT_OPTIONS ); } }); @@ -2189,7 +2189,7 @@ describe('storage', function () { await requesterPaysDoubleTest(async options => { return bucketNonAllowList.setStorageClass( 'multi-regional', - options, + options ); }); }); @@ -2403,7 +2403,7 @@ describe('storage', function () { .on('end', () => { file.hash = hash.digest('base64'); resolve(); - }), + }) ); } await Promise.all(Object.keys(FILES).map(key => setHash(key))); @@ -2469,7 +2469,7 @@ describe('storage', function () { }, }, }), - /Metadata part is too large/, + /Metadata part is too large/ ); }); @@ -2542,7 +2542,7 @@ describe('storage', function () { }); assert.strictEqual( String(fileContents).slice(0, 20), - String(remoteContents), + String(remoteContents) ); }); @@ -2613,7 +2613,7 @@ describe('storage', function () { .on('response', raw => { assert.strictEqual( raw.toJSON().headers['content-encoding'], - undefined, + undefined ); }) .pipe(fs.createWriteStream(tmpFilePath)) @@ -2766,8 +2766,8 @@ describe('storage', function () { [ 'The target object is encrypted by a', 'customer-supplied encryption key.', - ].join(' '), - ) > -1, + ].join(' ') + ) > -1 ); }); }); @@ -2874,7 +2874,7 @@ describe('storage', function () { const projectIdRegExp = /^.+\/locations/; const actualKmsKeyName = metadata!.kmsKeyName!.replace( projectIdRegExp, - '', + '' ); let expectedKmsKeyName = kmsKeyName.replace(projectIdRegExp, ''); @@ -2894,7 +2894,7 @@ describe('storage', function () { const projectIdRegExp = /^.+\/locations/; const actualKmsKeyName = metadata!.kmsKeyName!.replace( projectIdRegExp, - '', + '' ); let expectedKmsKeyName = kmsKeyName.replace(projectIdRegExp, ''); @@ -2934,7 +2934,7 @@ describe('storage', function () { beforeEach(async () => { await new Promise(res => - setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME), + setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME) ); await bucket.setMetadata({ encryption: { @@ -2945,7 +2945,7 @@ describe('storage', function () { afterEach(async () => { await new Promise(res => - setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME), + setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME) ); await bucket.setMetadata({ encryption: null, @@ -2960,7 +2960,7 @@ describe('storage', function () { const actualKmsKeyName = metadata!.encryption!.defaultKmsKeyName!.replace( projectIdRegExp, - '', + '' ); const expectedKmsKeyName = kmsKeyName.replace(projectIdRegExp, ''); assert.strictEqual(actualKmsKeyName, expectedKmsKeyName); @@ -2972,7 +2972,7 @@ describe('storage', function () { await createCryptoKeyAsync(cryptoKeyId); await new Promise(res => - setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME), + setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME) ); await bucket.setMetadata({ encryption: { @@ -2989,7 +2989,7 @@ describe('storage', function () { assert.strictEqual( fileMetadata.kmsKeyName, - `${metadata!.encryption!.defaultKmsKeyName}/cryptoKeyVersions/1`, + `${metadata!.encryption!.defaultKmsKeyName}/cryptoKeyVersions/1` ); }); }); @@ -3017,7 +3017,7 @@ describe('storage', function () { const [metadata] = await copiedFile.getMetadata(); assert.strictEqual( typeof metadata!.metadata!.originalProperty, - 'undefined', + 'undefined' ); assert.strictEqual(metadata!.metadata!.newProperty, 'true'); await Promise.all([file.delete, copiedFile.delete()]); @@ -3110,7 +3110,7 @@ describe('storage', function () { async function uploadAndVerify( file: File, - options: Omit, + options: Omit ) { await bucket.upload(filePath, { destination: file, @@ -3260,13 +3260,11 @@ describe('storage', function () { const [contents] = await destinationFile.download(); assert.strictEqual( contents.toString(), - files.map(x => x.contents).join(''), + files.map(x => x.contents).join('') ); await Promise.all( - sourceFiles - .concat([destinationFile]) - .map(file => deleteFileAsync(file)), + sourceFiles.concat([destinationFile]).map(file => deleteFileAsync(file)) ); }); }); @@ -3292,7 +3290,7 @@ describe('storage', function () { const ms = Math.pow(2, retries) * 1000 + Math.random() * 1000; return new Promise(done => { console.info( - `retrying "${test.title}" with accessId ${accessId} in ${ms}ms`, + `retrying "${test.title}" with accessId ${accessId} in ${ms}ms` ); setTimeout(done, ms); }); @@ -3334,7 +3332,7 @@ describe('storage', function () { assert(hmacKeys.length > 0); assert( hmacKeys.some(hmacKey => hmacKey.id === accessId), - 'created HMAC key not found from getHmacKeys result', + 'created HMAC key not found from getHmacKeys result' ); }); @@ -3363,7 +3361,7 @@ describe('storage', function () { assert(Array.isArray(hmacKeys)); assert( !hmacKeys.some(hmacKey => hmacKey.id === accessId), - 'deleted HMAC key is found from getHmacKeys result', + 'deleted HMAC key is found from getHmacKeys result' ); }); @@ -3398,17 +3396,16 @@ describe('storage', function () { const [hmacKeys] = await storage.getHmacKeys({projectId: HMAC_PROJECT}); assert( hmacKeys.some( - hmacKey => - hmacKey.metadata!.serviceAccountEmail === SERVICE_ACCOUNT, + hmacKey => hmacKey.metadata!.serviceAccountEmail === SERVICE_ACCOUNT ), - `Expected at least 1 key for service account: ${SERVICE_ACCOUNT}`, + `Expected at least 1 key for service account: ${SERVICE_ACCOUNT}` ); assert( hmacKeys.some( hmacKey => - hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT, + hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT ), - `Expected at least 1 key for service account: ${SECOND_SERVICE_ACCOUNT}`, + `Expected at least 1 key for service account: ${SECOND_SERVICE_ACCOUNT}` ); }); @@ -3420,9 +3417,9 @@ describe('storage', function () { assert( hmacKeys.every( hmacKey => - hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT, + hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT ), - 'HMAC key belonging to other service accounts unexpected', + 'HMAC key belonging to other service accounts unexpected' ); }); }); @@ -3483,7 +3480,7 @@ describe('storage', function () { assert.deepStrictEqual( (result as {prefixes: string[]}).prefixes, - expected, + expected ); }); @@ -3624,7 +3621,7 @@ describe('storage', function () { assert.strictEqual(files![0].name, files![1].name); assert.notStrictEqual( files![0].metadata.generation, - files![1].metadata.generation, + files![1].metadata.generation ); }); @@ -3640,7 +3637,7 @@ describe('storage', function () { assert.strictEqual(err.code, 412); assert.strictEqual(err.errors![0].reason, 'conditionNotMet'); return true; - }, + } ); await bucketWithVersioning .file(fileName) @@ -3701,7 +3698,7 @@ describe('storage', function () { await fetch(signedDeleteUrl, {method: 'DELETE'}); assert.rejects( () => file.getMetadata(), - (err: ApiError) => err.code === 404, + (err: ApiError) => err.code === 404 ); }); }); @@ -3775,10 +3772,10 @@ describe('storage', function () { assert(err instanceof Error); assert.strictEqual( err.message, - `Max allowed expiration is seven days (${SEVEN_DAYS_IN_SECONDS.toString()} seconds).`, + `Max allowed expiration is seven days (${SEVEN_DAYS_IN_SECONDS.toString()} seconds).` ); return true; - }, + } ); }); @@ -3961,7 +3958,7 @@ describe('storage', function () { topic.name, { eventTypes: ['OBJECT_FINALIZE'], - }, + } ); notification = createNotificationData[0]; subscription = topic.subscription(generateName()); @@ -4086,10 +4083,10 @@ describe('storage', function () { const TEST_UNIVERSE_DOMAIN = isNullOrUndefined('TEST_UNIVERSE_DOMAIN'); const TEST_PROJECT_ID = isNullOrUndefined('TEST_UNIVERSE_PROJECT_ID'); const TEST_UNIVERSE_LOCATION = isNullOrUndefined( - 'TEST_UNIVERSE_LOCATION', + 'TEST_UNIVERSE_LOCATION' ); const CREDENTIAL_PATH = isNullOrUndefined( - 'TEST_UNIVERSE_DOMAIN_CREDENTIAL', + 'TEST_UNIVERSE_DOMAIN_CREDENTIAL' ); // Create a client with universe domain credentials universeDomainStorage = new Storage({ @@ -4156,13 +4153,13 @@ describe('storage', function () { function deleteBucket( bucket: Bucket, options: {}, - callback: DeleteBucketCallback, + callback: DeleteBucketCallback ): void; function deleteBucket(bucket: Bucket, callback: DeleteBucketCallback): void; function deleteBucket( bucket: Bucket, optsOrCb: {} | DeleteBucketCallback, - callback?: DeleteBucketCallback, + callback?: DeleteBucketCallback ) { let options = typeof optsOrCb === 'object' ? optsOrCb : {}; callback = @@ -4212,10 +4209,10 @@ describe('storage', function () { const [buckets] = await storage.getBuckets({prefix: TESTS_PREFIX}); const limit = pLimit(10); await new Promise(resolve => - setTimeout(resolve, RETENTION_DURATION_SECONDS * 1000), + setTimeout(resolve, RETENTION_DURATION_SECONDS * 1000) ); return Promise.all( - buckets.map(bucket => limit(() => deleteBucketAsync(bucket))), + buckets.map(bucket => limit(() => deleteBucketAsync(bucket))) ); } @@ -4227,7 +4224,7 @@ describe('storage', function () { }); const limit = pLimit(10); return Promise.all( - filteredTopics.map(topic => limit(() => deleteTopicAsync(topic))), + filteredTopics.map(topic => limit(() => deleteTopicAsync(topic))) ); } @@ -4254,7 +4251,7 @@ describe('storage', function () { async function deleteStaleHmacKeys( serviceAccountEmail: string, - projectId: string, + projectId: string ) { const old = new Date(); old.setHours(old.getHours() - 1); @@ -4274,8 +4271,8 @@ describe('storage', function () { limit(async () => { await hmacKey.setMetadata({state: 'INACTIVE'}); await hmacKey.delete(); - }), - ), + }) + ) ); } From 8a88034d127e628b39a30cc5c2e66b24cfe45f87 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 4 Mar 2026 10:09:30 -0500 Subject: [PATCH 2/3] Fix remaining linting issues --- handwritten/storage/system-test/fixtures/index-cjs.js | 3 ++- handwritten/storage/system-test/fixtures/index-esm.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/handwritten/storage/system-test/fixtures/index-cjs.js b/handwritten/storage/system-test/fixtures/index-cjs.js index b987f57c0d6..bce3e1f7ac9 100644 --- a/handwritten/storage/system-test/fixtures/index-cjs.js +++ b/handwritten/storage/system-test/fixtures/index-cjs.js @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -/* eslint-disable node/no-missing-require, no-unused-vars, no-undef */ +// eslint-disable-next-line no-undef const {Storage} = require('@google-cloud/storage'); function main() { + // eslint-disable-next-line no-unused-vars const storage = new Storage(); } diff --git a/handwritten/storage/system-test/fixtures/index-esm.js b/handwritten/storage/system-test/fixtures/index-esm.js index 92cae36bcc5..bce3e1f7ac9 100644 --- a/handwritten/storage/system-test/fixtures/index-esm.js +++ b/handwritten/storage/system-test/fixtures/index-esm.js @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -/* eslint-disable node/no-missing-import, no-unused-vars */ -import {Storage} from '@google-cloud/storage'; +// eslint-disable-next-line no-undef +const {Storage} = require('@google-cloud/storage'); function main() { + // eslint-disable-next-line no-unused-vars const storage = new Storage(); } From be22f589fc5d5644da16651a8906aa5906fbae44 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 4 Mar 2026 15:27:42 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../performApplicationPerformanceTest.ts | 8 +- .../performPerformanceTest.ts | 6 +- .../performTransferManagerTest.ts | 8 +- .../internal-tooling/performanceTest.ts | 6 +- .../internal-tooling/performanceUtils.ts | 26 +- handwritten/storage/src/acl.ts | 34 +-- handwritten/storage/src/bucket.ts | 206 ++++++++-------- handwritten/storage/src/channel.ts | 2 +- handwritten/storage/src/crc32c.ts | 10 +- handwritten/storage/src/file.ts | 184 +++++++-------- .../storage/src/hash-stream-validator.ts | 4 +- handwritten/storage/src/hmacKey.ts | 8 +- handwritten/storage/src/iam.ts | 32 +-- .../src/nodejs-common/service-object.ts | 36 +-- .../storage/src/nodejs-common/service.ts | 8 +- handwritten/storage/src/nodejs-common/util.ts | 58 ++--- handwritten/storage/src/notification.ts | 2 +- handwritten/storage/src/resumable-upload.ts | 32 +-- handwritten/storage/src/signer.ts | 38 +-- handwritten/storage/src/storage.ts | 56 ++--- handwritten/storage/src/transfer-manager.ts | 64 ++--- handwritten/storage/src/util.ts | 10 +- handwritten/storage/system-test/common.ts | 6 +- handwritten/storage/system-test/kitchen.ts | 26 +- handwritten/storage/system-test/storage.ts | 223 +++++++++--------- 25 files changed, 549 insertions(+), 544 deletions(-) diff --git a/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts b/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts index 99b0f151f93..eedcda1f604 100644 --- a/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts +++ b/handwritten/storage/internal-tooling/performApplicationPerformanceTest.ts @@ -56,7 +56,7 @@ async function main() { ({bucket} = await performanceTestSetup( argv.project! as string, - argv.bucket! as string + argv.bucket! as string, )); switch (argv.test_type) { @@ -78,7 +78,7 @@ async function main() { async function uploadInParallel( bucket: Bucket, paths: string[], - options: UploadOptions + options: UploadOptions, ) { const promises: Promise[] = []; for (const index in paths) { @@ -115,7 +115,7 @@ async function performWriteTest(): Promise { argv.num_objects as number, TEST_NAME_STRING, fileSizeRange.low, - fileSizeRange.high + fileSizeRange.high, ); const start = performance.now(); @@ -157,7 +157,7 @@ async function performReadTest(): Promise { argv.num_objects as number, TEST_NAME_STRING, fileSizeRange.low, - fileSizeRange.high + fileSizeRange.high, ); await uploadInParallel(bucket, creationInfo.paths, {validation: checkType}); diff --git a/handwritten/storage/internal-tooling/performPerformanceTest.ts b/handwritten/storage/internal-tooling/performPerformanceTest.ts index a23f547c83a..82fda1c9f73 100644 --- a/handwritten/storage/internal-tooling/performPerformanceTest.ts +++ b/handwritten/storage/internal-tooling/performPerformanceTest.ts @@ -54,7 +54,7 @@ async function main() { ({bucket} = await performanceTestSetup( argv.project! as string, - argv.bucket! as string + argv.bucket! as string, )); switch (argv.test_type) { @@ -84,7 +84,7 @@ async function performRangedReadTest(): Promise { fileName, fileSizeRange.low, fileSizeRange.high, - getDirName() + getDirName(), ); const file = bucket.file(`${fileName}`); const destinationFileName = generateRandomFileName(TEST_NAME_STRING); @@ -142,7 +142,7 @@ async function performWriteReadTest(): Promise { fileName, fileSizeRange.low, fileSizeRange.high, - getDirName() + getDirName(), ); for (let j = 0; j < DEFAULT_NUMBER_OF_WRITES; j++) { diff --git a/handwritten/storage/internal-tooling/performTransferManagerTest.ts b/handwritten/storage/internal-tooling/performTransferManagerTest.ts index 097e999f752..6e21e774630 100644 --- a/handwritten/storage/internal-tooling/performTransferManagerTest.ts +++ b/handwritten/storage/internal-tooling/performTransferManagerTest.ts @@ -56,7 +56,7 @@ async function main() { ({bucket, transferManager} = await performanceTestSetup( argv.project! as string, - argv.bucket! as string + argv.bucket! as string, )); switch (argv.test_type) { @@ -104,7 +104,7 @@ async function performUploadManyFilesTest(): Promise { TEST_NAME_STRING, fileSizeRange.low, fileSizeRange.high, - DIRECTORY_PROBABILITY + DIRECTORY_PROBABILITY, ); const start = performance.now(); @@ -153,7 +153,7 @@ async function performDownloadManyFilesTest(): Promise { TEST_NAME_STRING, fileSizeRange.low, fileSizeRange.high, - DIRECTORY_PROBABILITY + DIRECTORY_PROBABILITY, ); await transferManager.uploadManyFiles(creationInfo.paths, { @@ -210,7 +210,7 @@ async function performChunkUploadDownloadTest(): Promise { fileName, fileSizeRange.low, fileSizeRange.high, - getDirName() + getDirName(), ); const file = bucket.file(`${fileName}`); let result: TestResult = { diff --git a/handwritten/storage/internal-tooling/performanceTest.ts b/handwritten/storage/internal-tooling/performanceTest.ts index 995eaf96784..02adc10f76f 100644 --- a/handwritten/storage/internal-tooling/performanceTest.ts +++ b/handwritten/storage/internal-tooling/performanceTest.ts @@ -44,7 +44,7 @@ function main() { if (numThreads > iterationsRemaining) { log( `${numThreads} is greater than number of iterations (${iterationsRemaining}). Using ${iterationsRemaining} threads instead.`, - argv.debug as boolean + argv.debug as boolean, ); numThreads = iterationsRemaining; } @@ -65,7 +65,7 @@ function createWorker() { iterationsRemaining--; log( `Starting new iteration. Current iterations remaining: ${iterationsRemaining}`, - argv.debug as boolean + argv.debug as boolean, ); let testPath = ''; if ( @@ -122,7 +122,7 @@ async function recordResult(results: TestResult[] | TestResult) { : [results]; for await (const outputString of convertToCloudMonitoringFormat( - resultsToAppend + resultsToAppend, )) { argv.file_name ? await appendFile(argv.file_name as string, `${outputString}\n`) diff --git a/handwritten/storage/internal-tooling/performanceUtils.ts b/handwritten/storage/internal-tooling/performanceUtils.ts index b0ff2d1d587..b0633bdf1c4 100644 --- a/handwritten/storage/internal-tooling/performanceUtils.ts +++ b/handwritten/storage/internal-tooling/performanceUtils.ts @@ -214,20 +214,20 @@ export function generateRandomFileName(baseName: string): string { export function generateRandomFile( fileName: string, fileSizeLowerBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES + DEFAULT_OBJECT_RANGE_SIZE_BYTES, ).low, fileSizeUpperBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES + DEFAULT_OBJECT_RANGE_SIZE_BYTES, ).high, - currentDirectory: string = mkdtempSync(randomString()) + currentDirectory: string = mkdtempSync(randomString()), ): number { const fileSizeBytes = randomInteger( fileSizeLowerBoundBytes, - fileSizeUpperBoundBytes + fileSizeUpperBoundBytes, ); execSync( - `head --bytes=${fileSizeBytes} /dev/urandom > ${currentDirectory}/${fileName}` + `head --bytes=${fileSizeBytes} /dev/urandom > ${currentDirectory}/${fileName}`, ); return fileSizeBytes; @@ -247,12 +247,12 @@ export function generateRandomDirectoryStructure( maxObjects: number, baseName: string, fileSizeLowerBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES + DEFAULT_OBJECT_RANGE_SIZE_BYTES, ).low, fileSizeUpperBoundBytes: number = getLowHighFileSize( - DEFAULT_OBJECT_RANGE_SIZE_BYTES + DEFAULT_OBJECT_RANGE_SIZE_BYTES, ).high, - directoryProbability: number = DEFAULT_DIRECTORY_PROBABILITY + directoryProbability: number = DEFAULT_DIRECTORY_PROBABILITY, ): RandomDirectoryCreationInformation { let curPath = baseName; const creationInfo: RandomDirectoryCreationInformation = { @@ -272,7 +272,7 @@ export function generateRandomDirectoryStructure( randomName, fileSizeLowerBoundBytes, fileSizeUpperBoundBytes, - curPath + curPath, ); creationInfo.paths.push(path.join(curPath, randomName)); } @@ -288,7 +288,7 @@ export function generateRandomDirectoryStructure( */ export function cleanupFile( fileName: string, - directoryName: string = getDirName() + directoryName: string = getDirName(), ): void { unlinkSync(`${directoryName}/${fileName}`); } @@ -302,7 +302,7 @@ export function cleanupFile( */ export async function performanceTestSetup( projectId: string, - bucketName: string + bucketName: string, ): Promise { const storage = new Storage({projectId}); const bucket = storage.bucket(bucketName, { @@ -346,7 +346,7 @@ export function getValidationType(): 'md5' | 'crc32c' | boolean | undefined { * @returns {AsyncGenerator} A string containing the results of the conversion to cloud monitoring format. */ export async function* convertToCloudMonitoringFormat( - results: TestResult[] + results: TestResult[], ): AsyncGenerator { for (const curResult of results) { const throughput = @@ -384,7 +384,7 @@ export async function* convertToCloudMonitoringFormat( export function log( messageOrError: string | Error, shouldLog: boolean, - isError = false + isError = false, ): void { if (shouldLog) { isError ? console.error(messageOrError) : console.log(messageOrError); diff --git a/handwritten/storage/src/acl.ts b/handwritten/storage/src/acl.ts index 9776b0340e0..ecd02bb7a83 100644 --- a/handwritten/storage/src/acl.ts +++ b/handwritten/storage/src/acl.ts @@ -23,7 +23,7 @@ export interface AclOptions { pathPrefix: string; request: ( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ) => void; } @@ -35,7 +35,7 @@ export interface GetAclCallback { ( err: Error | null, acl?: AccessControlObject | AccessControlObject[] | null, - apiResponse?: AclMetadata + apiResponse?: AclMetadata, ): void; } export interface GetAclOptions { @@ -55,7 +55,7 @@ export interface UpdateAclCallback { ( err: Error | null, acl?: AccessControlObject | null, - apiResponse?: AclMetadata + apiResponse?: AclMetadata, ): void; } @@ -70,7 +70,7 @@ export interface AddAclCallback { ( err: Error | null, acl?: AccessControlObject | null, - apiResponse?: AclMetadata + apiResponse?: AclMetadata, ): void; } export type RemoveAclResponse = [AclMetadata]; @@ -331,7 +331,7 @@ class AclRoleAccessorMethods { (acc as any)[method] = ( entityId: string, options: {}, - callback: Function | {} + callback: Function | {}, ) => { let apiEntity; @@ -355,7 +355,7 @@ class AclRoleAccessorMethods { entity: apiEntity, role, }, - options + options, ); const args = [options]; @@ -420,7 +420,7 @@ class Acl extends AclRoleAccessorMethods { pathPrefix: string; request_: ( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ) => void; constructor(options: AclOptions) { @@ -508,7 +508,7 @@ class Acl extends AclRoleAccessorMethods { */ add( options: AddAclOptions, - callback?: AddAclCallback + callback?: AddAclCallback, ): void | Promise { const query = {} as AclQuery; @@ -538,7 +538,7 @@ class Acl extends AclRoleAccessorMethods { } callback!(null, this.makeAclObject_(resp), resp); - } + }, ); } @@ -608,7 +608,7 @@ class Acl extends AclRoleAccessorMethods { */ delete( options: RemoveAclOptions, - callback?: RemoveAclCallback + callback?: RemoveAclCallback, ): void | Promise { const query = {} as AclQuery; @@ -628,7 +628,7 @@ class Acl extends AclRoleAccessorMethods { }, (err, resp) => { callback!(err, resp); - } + }, ); } @@ -722,7 +722,7 @@ class Acl extends AclRoleAccessorMethods { */ get( optionsOrCallback?: GetAclOptions | GetAclCallback, - cb?: GetAclCallback + cb?: GetAclCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : null; @@ -763,7 +763,7 @@ class Acl extends AclRoleAccessorMethods { } callback!(null, results, resp); - } + }, ); } @@ -830,7 +830,7 @@ class Acl extends AclRoleAccessorMethods { */ update( options: UpdateAclOptions, - callback?: UpdateAclCallback + callback?: UpdateAclCallback, ): void | Promise { const query = {} as AclQuery; @@ -858,7 +858,7 @@ class Acl extends AclRoleAccessorMethods { } callback!(null, this.makeAclObject_(resp), resp); - } + }, ); } @@ -868,7 +868,7 @@ class Acl extends AclRoleAccessorMethods { * @private */ makeAclObject_( - accessControlObject: AccessControlObject + accessControlObject: AccessControlObject, ): AccessControlObject { const obj = { entity: accessControlObject.entity, @@ -895,7 +895,7 @@ class Acl extends AclRoleAccessorMethods { */ request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void { reqOpts.uri = this.pathPrefix + reqOpts.uri; this.request_(reqOpts, callback); diff --git a/handwritten/storage/src/bucket.ts b/handwritten/storage/src/bucket.ts index d354209057e..fde1a9bfd18 100644 --- a/handwritten/storage/src/bucket.ts +++ b/handwritten/storage/src/bucket.ts @@ -97,7 +97,7 @@ export interface GetFilesCallback { err: Error | null, files?: File[], nextQuery?: {}, - apiResponse?: unknown + apiResponse?: unknown, ): void; } @@ -217,7 +217,7 @@ export interface CreateNotificationCallback { ( err: Error | null, notification: Notification | null, - apiResponse: unknown + apiResponse: unknown, ): void; } @@ -380,7 +380,7 @@ export interface GetBucketMetadataCallback { ( err: ApiError | null, metadata: BucketMetadata | null, - apiResponse: unknown + apiResponse: unknown, ): void; } @@ -416,7 +416,7 @@ export interface GetNotificationsCallback { ( err: Error | null, notifications: Notification[] | null, - apiResponse: unknown + apiResponse: unknown, ): void; } @@ -1280,16 +1280,16 @@ class Bucket extends ServiceObject { addLifecycleRule( rule: LifecycleRule | LifecycleRule[], - options?: AddLifecycleRuleOptions + options?: AddLifecycleRuleOptions, ): Promise; addLifecycleRule( rule: LifecycleRule | LifecycleRule[], options: AddLifecycleRuleOptions, - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; addLifecycleRule( rule: LifecycleRule | LifecycleRule[], - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; /** * @typedef {object} AddLifecycleRuleOptions Configuration options for Bucket#addLifecycleRule(). @@ -1462,7 +1462,7 @@ class Bucket extends ServiceObject { addLifecycleRule( rule: LifecycleRule | LifecycleRule[], optionsOrCallback?: AddLifecycleRuleOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback + callback?: SetBucketMetadataCallback, ): Promise | void { let options: AddLifecycleRuleOptions = {}; @@ -1516,7 +1516,7 @@ class Bucket extends ServiceObject { lifecycle: {rule: currentLifecycleRules!.concat(rules)}, }, options as AddLifecycleRuleOptions, - callback! + callback!, ); }); } @@ -1524,18 +1524,18 @@ class Bucket extends ServiceObject { combine( sources: string[] | File[], destination: string | File, - options?: CombineOptions + options?: CombineOptions, ): Promise; combine( sources: string[] | File[], destination: string | File, options: CombineOptions, - callback: CombineCallback + callback: CombineCallback, ): void; combine( sources: string[] | File[], destination: string | File, - callback: CombineCallback + callback: CombineCallback, ): void; /** * @typedef {object} CombineOptions @@ -1611,7 +1611,7 @@ class Bucket extends ServiceObject { sources: string[] | File[], destination: string | File, optionsOrCallback?: CombineOptions | CombineCallback, - callback?: CombineCallback + callback?: CombineCallback, ): Promise | void { if (!Array.isArray(sources) || sources.length === 0) { throw new Error(BucketExceptionMessages.PROVIDE_SOURCE_FILE); @@ -1631,7 +1631,7 @@ class Bucket extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.setMetadata, // Not relevant but param is required AvailableServiceObjectMethods.setMetadata, // Same as above - options + options, ); const convertToFile = (file: string | File): File => { @@ -1690,7 +1690,7 @@ class Bucket extends ServiceObject { if (source.metadata && source.metadata.generation) { sourceObject.generation = parseInt( - source.metadata.generation.toString() + source.metadata.generation.toString(), ); } @@ -1707,25 +1707,25 @@ class Bucket extends ServiceObject { } callback!(null, destinationFile, resp); - } + }, ); } createChannel( id: string, config: CreateChannelConfig, - options?: CreateChannelOptions + options?: CreateChannelOptions, ): Promise; createChannel( id: string, config: CreateChannelConfig, - callback: CreateChannelCallback + callback: CreateChannelCallback, ): void; createChannel( id: string, config: CreateChannelConfig, options: CreateChannelOptions, - callback: CreateChannelCallback + callback: CreateChannelCallback, ): void; /** * See a {@link https://cloud.google.com/storage/docs/json_api/v1/objects/watchAll| Objects: watchAll request body}. @@ -1822,7 +1822,7 @@ class Bucket extends ServiceObject { id: string, config: CreateChannelConfig, optionsOrCallback?: CreateChannelOptions | CreateChannelCallback, - callback?: CreateChannelCallback + callback?: CreateChannelCallback, ): Promise | void { if (typeof id !== 'string') { throw new Error(BucketExceptionMessages.CHANNEL_ID_REQUIRED); @@ -1844,7 +1844,7 @@ class Bucket extends ServiceObject { id, type: 'web_hook', }, - config + config, ), qs: options, }, @@ -1860,18 +1860,18 @@ class Bucket extends ServiceObject { channel.metadata = apiResponse; callback!(null, channel, apiResponse); - } + }, ); } createNotification( topic: string, - options?: CreateNotificationOptions + options?: CreateNotificationOptions, ): Promise; createNotification( topic: string, options: CreateNotificationOptions, - callback: CreateNotificationCallback + callback: CreateNotificationCallback, ): void; createNotification(topic: string, callback: CreateNotificationCallback): void; /** @@ -1981,7 +1981,7 @@ class Bucket extends ServiceObject { createNotification( topic: string, optionsOrCallback?: CreateNotificationOptions | CreateNotificationCallback, - callback?: CreateNotificationCallback + callback?: CreateNotificationCallback, ): Promise | void { let options: CreateNotificationOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2038,7 +2038,7 @@ class Bucket extends ServiceObject { notification.metadata = apiResponse; callback!(null, notification, apiResponse); - } + }, ); } @@ -2127,7 +2127,7 @@ class Bucket extends ServiceObject { */ deleteFiles( queryOrCallback?: DeleteFilesOptions | DeleteFilesCallback, - callback?: DeleteFilesCallback + callback?: DeleteFilesCallback, ): Promise | void { let query: DeleteFilesOptions = {}; if (typeof queryOrCallback === 'function') { @@ -2164,7 +2164,7 @@ class Bucket extends ServiceObject { limit(() => deleteFile(curFile)).catch(e => { filesStream.destroy(); throw e; - }) + }), ); } @@ -2182,13 +2182,13 @@ class Bucket extends ServiceObject { deleteLabels(callback: DeleteLabelsCallback): void; deleteLabels( labels: string | string[], - options: DeleteLabelsOptions + options: DeleteLabelsOptions, ): Promise; deleteLabels(labels: string | string[], callback: DeleteLabelsCallback): void; deleteLabels( labels: string | string[], options: DeleteLabelsOptions, - callback: DeleteLabelsCallback + callback: DeleteLabelsCallback, ): void; /** * @deprecated @@ -2250,7 +2250,7 @@ class Bucket extends ServiceObject { | DeleteLabelsCallback | DeleteLabelsOptions, optionsOrCallback?: DeleteLabelsCallback | DeleteLabelsOptions, - callback?: DeleteLabelsCallback + callback?: DeleteLabelsCallback, ): Promise | void { let labels = new Array(); let options: DeleteLabelsOptions = {}; @@ -2298,12 +2298,12 @@ class Bucket extends ServiceObject { } disableRequesterPays( - options?: DisableRequesterPaysOptions + options?: DisableRequesterPaysOptions, ): Promise; disableRequesterPays(callback: DisableRequesterPaysCallback): void; disableRequesterPays( options: DisableRequesterPaysOptions, - callback: DisableRequesterPaysCallback + callback: DisableRequesterPaysCallback, ): void; /** * @typedef {array} DisableRequesterPaysResponse @@ -2356,7 +2356,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | DisableRequesterPaysOptions | DisableRequesterPaysCallback, - callback?: DisableRequesterPaysCallback + callback?: DisableRequesterPaysCallback, ): Promise | void { let options: DisableRequesterPaysOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2372,16 +2372,16 @@ class Bucket extends ServiceObject { }, }, options, - callback! + callback!, ); } enableLogging( - config: EnableLoggingOptions + config: EnableLoggingOptions, ): Promise; enableLogging( config: EnableLoggingOptions, - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; /** * Configuration object for enabling logging. @@ -2441,7 +2441,7 @@ class Bucket extends ServiceObject { */ enableLogging( config: EnableLoggingOptions, - callback?: SetBucketMetadataCallback + callback?: SetBucketMetadataCallback, ): Promise | void { if ( !config || @@ -2449,7 +2449,7 @@ class Bucket extends ServiceObject { typeof config.prefix === 'undefined' ) { throw new Error( - BucketExceptionMessages.CONFIGURATION_OBJECT_PREFIX_REQUIRED + BucketExceptionMessages.CONFIGURATION_OBJECT_PREFIX_REQUIRED, ); } @@ -2483,7 +2483,7 @@ class Bucket extends ServiceObject { }, }, options, - callback! + callback!, ); } catch (e) { callback!(e as Error); @@ -2493,12 +2493,12 @@ class Bucket extends ServiceObject { } enableRequesterPays( - options?: EnableRequesterPaysOptions + options?: EnableRequesterPaysOptions, ): Promise; enableRequesterPays(callback: EnableRequesterPaysCallback): void; enableRequesterPays( options: EnableRequesterPaysOptions, - callback: EnableRequesterPaysCallback + callback: EnableRequesterPaysCallback, ): void; /** @@ -2554,7 +2554,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | EnableRequesterPaysCallback | EnableRequesterPaysOptions, - cb?: EnableRequesterPaysCallback + cb?: EnableRequesterPaysCallback, ): Promise | void { let options: EnableRequesterPaysOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2570,7 +2570,7 @@ class Bucket extends ServiceObject { }, }, options, - cb! + cb!, ); } @@ -2816,7 +2816,7 @@ class Bucket extends ServiceObject { */ getFiles( queryOrCallback?: GetFilesOptions | GetFilesCallback, - callback?: GetFilesCallback + callback?: GetFilesCallback, ): void | Promise { let query = typeof queryOrCallback === 'object' ? queryOrCallback : {}; if (!callback) { @@ -2874,7 +2874,7 @@ class Bucket extends ServiceObject { } // eslint-disable-next-line @typescript-eslint/no-explicit-any (callback as any)(null, files, nextQuery, resp); - } + }, ); } @@ -2935,7 +2935,7 @@ class Bucket extends ServiceObject { */ getLabels( optionsOrCallback?: GetLabelsOptions | GetLabelsCallback, - callback?: GetLabelsCallback + callback?: GetLabelsCallback, ): Promise | void { let options: GetLabelsOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -2953,17 +2953,17 @@ class Bucket extends ServiceObject { } callback!(null, metadata?.labels || {}); - } + }, ); } getNotifications( - options?: GetNotificationsOptions + options?: GetNotificationsOptions, ): Promise; getNotifications(callback: GetNotificationsCallback): void; getNotifications( options: GetNotificationsOptions, - callback: GetNotificationsCallback + callback: GetNotificationsCallback, ): void; /** * @typedef {object} GetNotificationsOptions Configuration options for Bucket#getNotification(). @@ -3020,7 +3020,7 @@ class Bucket extends ServiceObject { */ getNotifications( optionsOrCallback?: GetNotificationsOptions | GetNotificationsCallback, - callback?: GetNotificationsCallback + callback?: GetNotificationsCallback, ): Promise | void { let options: GetNotificationsOptions = {}; if (typeof optionsOrCallback === 'function') { @@ -3045,18 +3045,18 @@ class Bucket extends ServiceObject { const notificationInstance = this.notification(notification.id!); notificationInstance.metadata = notification; return notificationInstance; - } + }, ); callback!(null, notifications, resp); - } + }, ); } getSignedUrl(cfg: GetBucketSignedUrlConfig): Promise; getSignedUrl( cfg: GetBucketSignedUrlConfig, - callback: GetSignedUrlCallback + callback: GetSignedUrlCallback, ): void; /** * @typedef {array} GetSignedUrlResponse @@ -3186,7 +3186,7 @@ class Bucket extends ServiceObject { */ getSignedUrl( cfg: GetBucketSignedUrlConfig, - callback?: GetSignedUrlCallback + callback?: GetSignedUrlCallback, ): void | Promise { const method = BucketActionToHTTPMethod[cfg.action]; @@ -3206,7 +3206,7 @@ class Bucket extends ServiceObject { this.storage.authClient, this, undefined, - this.storage + this.storage, ); } @@ -3252,7 +3252,7 @@ class Bucket extends ServiceObject { */ lock( metageneration: number | string, - callback?: BucketLockCallback + callback?: BucketLockCallback, ): Promise | void { const metatype = typeof metageneration; if (metatype !== 'number' && metatype !== 'string') { @@ -3267,7 +3267,7 @@ class Bucket extends ServiceObject { ifMetagenerationMatch: metageneration, }, }, - callback! + callback!, ); } @@ -3293,12 +3293,12 @@ class Bucket extends ServiceObject { } makePrivate( - options?: MakeBucketPrivateOptions + options?: MakeBucketPrivateOptions, ): Promise; makePrivate(callback: MakeBucketPrivateCallback): void; makePrivate( options: MakeBucketPrivateOptions, - callback: MakeBucketPrivateCallback + callback: MakeBucketPrivateCallback, ): void; /** * @typedef {array} MakeBucketPrivateResponse @@ -3403,7 +3403,7 @@ class Bucket extends ServiceObject { */ makePrivate( optionsOrCallback?: MakeBucketPrivateOptions | MakeBucketPrivateCallback, - callback?: MakeBucketPrivateCallback + callback?: MakeBucketPrivateCallback, ): Promise | void { const options: MakeBucketPrivateRequest = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3450,7 +3450,7 @@ class Bucket extends ServiceObject { const internalCall = () => { if (options.includeFiles) { return promisify( - this.makeAllFilesPublicPrivate_ + this.makeAllFilesPublicPrivate_, ).call(this, options); } return Promise.resolve([] as File[]); @@ -3462,12 +3462,12 @@ class Bucket extends ServiceObject { } makePublic( - options?: MakeBucketPublicOptions + options?: MakeBucketPublicOptions, ): Promise; makePublic(callback: MakeBucketPublicCallback): void; makePublic( options: MakeBucketPublicOptions, - callback: MakeBucketPublicCallback + callback: MakeBucketPublicCallback, ): void; /** * @typedef {object} MakeBucketPublicOptions @@ -3564,7 +3564,7 @@ class Bucket extends ServiceObject { */ makePublic( optionsOrCallback?: MakeBucketPublicOptions | MakeBucketPublicCallback, - callback?: MakeBucketPublicCallback + callback?: MakeBucketPublicCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3587,7 +3587,7 @@ class Bucket extends ServiceObject { .then(() => { if (req.includeFiles) { return promisify( - this.makeAllFilesPublicPrivate_ + this.makeAllFilesPublicPrivate_, ).call(this, req); } return []; @@ -3619,12 +3619,12 @@ class Bucket extends ServiceObject { } removeRetentionPeriod( - options?: SetBucketMetadataOptions + options?: SetBucketMetadataOptions, ): Promise; removeRetentionPeriod(callback: SetBucketMetadataCallback): void; removeRetentionPeriod( options: SetBucketMetadataOptions, - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; /** * Remove an already-existing retention policy from this bucket, if it is not @@ -3651,7 +3651,7 @@ class Bucket extends ServiceObject { */ removeRetentionPeriod( optionsOrCallback?: SetBucketMetadataOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback + callback?: SetBucketMetadataCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3663,14 +3663,14 @@ class Bucket extends ServiceObject { retentionPolicy: null, }, options, - callback! + callback!, ); } request(reqOpts: DecorateRequestOptions): Promise; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void; /** * Makes request and applies userProject query parameter if necessary. @@ -3682,7 +3682,7 @@ class Bucket extends ServiceObject { */ request( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | Promise { if (this.userProject && (!reqOpts.qs || !reqOpts.qs.userProject)) { reqOpts.qs = {...reqOpts.qs, userProject: this.userProject}; @@ -3692,13 +3692,13 @@ class Bucket extends ServiceObject { setLabels( labels: Labels, - options?: SetLabelsOptions + options?: SetLabelsOptions, ): Promise; setLabels(labels: Labels, callback: SetLabelsCallback): void; setLabels( labels: Labels, options: SetLabelsOptions, - callback: SetLabelsCallback + callback: SetLabelsCallback, ): void; /** * @deprecated @@ -3760,7 +3760,7 @@ class Bucket extends ServiceObject { setLabels( labels: Labels, optionsOrCallback?: SetLabelsOptions | SetLabelsCallback, - callback?: SetLabelsCallback + callback?: SetLabelsCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3774,21 +3774,21 @@ class Bucket extends ServiceObject { setMetadata( metadata: BucketMetadata, - options?: SetMetadataOptions + options?: SetMetadataOptions, ): Promise>; setMetadata( metadata: BucketMetadata, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: BucketMetadata, options: SetMetadataOptions, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: BucketMetadata, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback + cb?: MetadataCallback, ): Promise> | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3800,7 +3800,7 @@ class Bucket extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.setMetadata, AvailableServiceObjectMethods.setMetadata, - options + options, ); super @@ -3814,16 +3814,16 @@ class Bucket extends ServiceObject { setRetentionPeriod( duration: number, - options?: SetBucketMetadataOptions + options?: SetBucketMetadataOptions, ): Promise; setRetentionPeriod( duration: number, - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; setRetentionPeriod( duration: number, options: SetBucketMetadataOptions, - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; /** * Lock all objects contained in the bucket, based on their creation time. Any @@ -3866,7 +3866,7 @@ class Bucket extends ServiceObject { setRetentionPeriod( duration: number, optionsOrCallback?: SetBucketMetadataOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback + callback?: SetBucketMetadataCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3879,22 +3879,22 @@ class Bucket extends ServiceObject { }, }, options, - callback! + callback!, ); } setCorsConfiguration( corsConfiguration: Cors[], - options?: SetBucketMetadataOptions + options?: SetBucketMetadataOptions, ): Promise; setCorsConfiguration( corsConfiguration: Cors[], - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; setCorsConfiguration( corsConfiguration: Cors[], options: SetBucketMetadataOptions, - callback: SetBucketMetadataCallback + callback: SetBucketMetadataCallback, ): void; /** * @@ -3945,7 +3945,7 @@ class Bucket extends ServiceObject { setCorsConfiguration( corsConfiguration: Cors[], optionsOrCallback?: SetBucketMetadataOptions | SetBucketMetadataCallback, - callback?: SetBucketMetadataCallback + callback?: SetBucketMetadataCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3956,22 +3956,22 @@ class Bucket extends ServiceObject { cors: corsConfiguration, }, options, - callback! + callback!, ); } setStorageClass( storageClass: string, - options?: SetBucketStorageClassOptions + options?: SetBucketStorageClassOptions, ): Promise; setStorageClass( storageClass: string, - callback: SetBucketStorageClassCallback + callback: SetBucketStorageClassCallback, ): void; setStorageClass( storageClass: string, options: SetBucketStorageClassOptions, - callback: SetBucketStorageClassCallback + callback: SetBucketStorageClassCallback, ): void; /** * @typedef {object} SetBucketStorageClassOptions @@ -4023,7 +4023,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | SetBucketStorageClassOptions | SetBucketStorageClassCallback, - callback?: SetBucketStorageClassCallback + callback?: SetBucketStorageClassCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -4085,7 +4085,7 @@ class Bucket extends ServiceObject { upload( pathString: string, options: UploadOptions, - callback: UploadCallback + callback: UploadCallback, ): void; upload(pathString: string, callback: UploadCallback): void; /** @@ -4345,7 +4345,7 @@ class Bucket extends ServiceObject { upload( pathString: string, optionsOrCallback?: UploadOptions | UploadCallback, - callback?: UploadCallback + callback?: UploadCallback, ): Promise | void { const upload = (numberOfRetries: number | undefined) => { const returnValue = AsyncRetry( @@ -4384,7 +4384,7 @@ class Bucket extends ServiceObject { factor: this.storage.retryOptions.retryDelayMultiplier, maxTimeout: this.storage.retryOptions.maxRetryDelay! * 1000, //convert to milliseconds maxRetryTime: this.storage.retryOptions.totalTimeout! * 1000, //convert to milliseconds - } + }, ); if (!callback) { @@ -4414,7 +4414,7 @@ class Bucket extends ServiceObject { { metadata: {}, }, - options + options, ); // Do not retry if precondition option ifGenerationMatch is not set @@ -4458,12 +4458,12 @@ class Bucket extends ServiceObject { } makeAllFilesPublicPrivate_( - options?: MakeAllFilesPublicPrivateOptions + options?: MakeAllFilesPublicPrivateOptions, ): Promise; makeAllFilesPublicPrivate_(callback: MakeAllFilesPublicPrivateCallback): void; makeAllFilesPublicPrivate_( options: MakeAllFilesPublicPrivateOptions, - callback: MakeAllFilesPublicPrivateCallback + callback: MakeAllFilesPublicPrivateCallback, ): void; /** * @private @@ -4513,7 +4513,7 @@ class Bucket extends ServiceObject { optionsOrCallback?: | MakeAllFilesPublicPrivateOptions | MakeAllFilesPublicPrivateCallback, - callback?: MakeAllFilesPublicPrivateCallback + callback?: MakeAllFilesPublicPrivateCallback, ): Promise | void { const MAX_PARALLEL_LIMIT = 10; const errors = [] as Error[]; @@ -4546,7 +4546,7 @@ class Bucket extends ServiceObject { }) .then( () => callback!(errors.length > 0 ? errors : null, updatedFiles), - err => callback!(err, updatedFiles) + err => callback!(err, updatedFiles), ); } @@ -4559,7 +4559,7 @@ class Bucket extends ServiceObject { coreOpts: any, // eslint-disable-next-line @typescript-eslint/no-explicit-any methodType: AvailableServiceObjectMethods, - localPreconditionOptions?: PreconditionOptions + localPreconditionOptions?: PreconditionOptions, ): void { if ( typeof coreOpts === 'object' && diff --git a/handwritten/storage/src/channel.ts b/handwritten/storage/src/channel.ts index ee0c10984b4..eccb2707194 100644 --- a/handwritten/storage/src/channel.ts +++ b/handwritten/storage/src/channel.ts @@ -106,7 +106,7 @@ class Channel extends ServiceObject { }, (err, apiResponse) => { callback!(err, apiResponse); - } + }, ); } } diff --git a/handwritten/storage/src/crc32c.ts b/handwritten/storage/src/crc32c.ts index 929cc1d5a95..5d4ac75a6c9 100644 --- a/handwritten/storage/src/crc32c.ts +++ b/handwritten/storage/src/crc32c.ts @@ -231,7 +231,7 @@ class CRC32C implements CRC32CValidator { * @param value 4-byte `ArrayBufferView`/`Buffer`/`TypedArray` */ private static fromBuffer( - value: ArrayBuffer | ArrayBufferView | Buffer + value: ArrayBuffer | ArrayBufferView | Buffer, ): CRC32C { let buffer: Buffer; @@ -247,7 +247,7 @@ class CRC32C implements CRC32CValidator { if (buffer.byteLength !== 4) { throw new RangeError( - CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BUFFER_LENGTH(buffer.byteLength) + CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BUFFER_LENGTH(buffer.byteLength), ); } @@ -283,7 +283,7 @@ class CRC32C implements CRC32CValidator { if (buffer.byteLength !== 4) { throw new RangeError( - CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BASE64_RANGE(buffer.byteLength) + CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_BASE64_RANGE(buffer.byteLength), ); } @@ -298,7 +298,7 @@ class CRC32C implements CRC32CValidator { private static fromNumber(value: number): CRC32C { if (!Number.isSafeInteger(value) || value > 2 ** 32 || value < -(2 ** 32)) { throw new RangeError( - CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_INTEGER(value) + CRC32C_EXCEPTION_MESSAGES.INVALID_INIT_INTEGER(value), ); } @@ -312,7 +312,7 @@ class CRC32C implements CRC32CValidator { * @param value A number, 4-byte `ArrayBufferView`/`Buffer`/`TypedArray`, or 4-byte base64-encoded data (string) */ static from( - value: ArrayBuffer | ArrayBufferView | CRC32CValidator | string | number + value: ArrayBuffer | ArrayBufferView | CRC32CValidator | string | number, ): CRC32C { if (typeof value === 'number') { return this.fromNumber(value); diff --git a/handwritten/storage/src/file.ts b/handwritten/storage/src/file.ts index 7a85ae96ea3..5c51e63dfb0 100644 --- a/handwritten/storage/src/file.ts +++ b/handwritten/storage/src/file.ts @@ -83,7 +83,7 @@ export interface GetExpirationDateCallback { ( err: Error | null, expirationDate?: Date | null, - apiResponse?: unknown + apiResponse?: unknown, ): void; } @@ -296,7 +296,7 @@ export interface MoveCallback { ( err: Error | null, destinationFile?: File | null, - apiResponse?: unknown + apiResponse?: unknown, ): void; } @@ -360,7 +360,7 @@ const COMPRESSIBLE_MIME_REGEX = new RegExp( ] .map(r => r.source) .join(''), - 'i' + 'i', ); export interface FileOptions { @@ -398,7 +398,7 @@ export type DownloadResponse = [Buffer]; export type DownloadCallback = ( err: RequestError | null, - contents: Buffer + contents: Buffer, ) => void; export interface DownloadOptions extends CreateReadStreamOptions { @@ -1118,7 +1118,7 @@ class File extends ServiceObject { * - if `idempotencyStrategy` is set to `RetryNever` */ private shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?: PreconditionOptions + options?: PreconditionOptions, ): boolean { return !( (options?.ifGenerationMatch === undefined && @@ -1132,13 +1132,13 @@ class File extends ServiceObject { copy( destination: string | Bucket | File, - options?: CopyOptions + options?: CopyOptions, ): Promise; copy(destination: string | Bucket | File, callback: CopyCallback): void; copy( destination: string | Bucket | File, options: CopyOptions, - callback: CopyCallback + callback: CopyCallback, ): void; /** * @typedef {array} CopyResponse @@ -1275,10 +1275,10 @@ class File extends ServiceObject { copy( destination: string | Bucket | File, optionsOrCallback?: CopyOptions | CopyCallback, - callback?: CopyCallback + callback?: CopyCallback, ): Promise | void { const noDestinationError = new Error( - FileExceptionMessages.DESTINATION_NO_NAME + FileExceptionMessages.DESTINATION_NO_NAME, ); if (!destination) { @@ -1358,7 +1358,7 @@ class File extends ServiceObject { this.kmsKeyName = query.destinationKmsKeyName; const keyIndex = this.interceptors.indexOf( - this.encryptionKeyInterceptor! + this.encryptionKeyInterceptor!, ); if (keyIndex > -1) { this.interceptors.splice(keyIndex, 1); @@ -1367,7 +1367,7 @@ class File extends ServiceObject { if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?.preconditionOpts + options?.preconditionOpts, ) ) { this.storage.retryOptions.autoRetry = false; @@ -1382,7 +1382,7 @@ class File extends ServiceObject { { method: 'POST', uri: `/rewriteTo/b/${destBucket.name}/o/${encodeURIComponent( - newFile.name + newFile.name, )}`, qs: query, json: options, @@ -1413,7 +1413,7 @@ class File extends ServiceObject { } callback!(null, newFile, resp); - } + }, ); } @@ -1568,7 +1568,7 @@ class File extends ServiceObject { const onResponse = ( err: Error | null, _body: ResponseBody, - rawResponseStream: unknown + rawResponseStream: unknown, ) => { if (err) { // Get error message from the body. @@ -1620,7 +1620,7 @@ class File extends ServiceObject { if (md5 && !hashes.md5) { const hashError = new RequestError( - FileExceptionMessages.MD5_NOT_AVAILABLE + FileExceptionMessages.MD5_NOT_AVAILABLE, ); hashError.code = 'MD5_NOT_AVAILABLE'; throughStream.destroy(hashError); @@ -1639,7 +1639,7 @@ class File extends ServiceObject { rawResponseStream as Readable, ...(transformStreams as [Transform]), throughStream, - onComplete + onComplete, ); }; @@ -1698,11 +1698,11 @@ class File extends ServiceObject { } createResumableUpload( - options?: CreateResumableUploadOptions + options?: CreateResumableUploadOptions, ): Promise; createResumableUpload( options: CreateResumableUploadOptions, - callback: CreateResumableUploadCallback + callback: CreateResumableUploadCallback, ): void; createResumableUpload(callback: CreateResumableUploadCallback): void; /** @@ -1793,7 +1793,7 @@ class File extends ServiceObject { optionsOrCallback?: | CreateResumableUploadOptions | CreateResumableUploadCallback, - callback?: CreateResumableUploadCallback + callback?: CreateResumableUploadCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -1819,7 +1819,7 @@ class File extends ServiceObject { bucket: this.bucket.name, customRequestOptions: this.getRequestInterceptors().reduce( (reqOpts, interceptorFn) => interceptorFn(reqOpts), - {} + {}, ), file: this.name, generation: this.generation, @@ -1838,7 +1838,7 @@ class File extends ServiceObject { useAuthWithCustomEndpoint: this.storage.useAuthWithCustomEndpoint, [GCCL_GCS_CMD_KEY]: options[GCCL_GCS_CMD_KEY], }, - callback! + callback!, ); this.storage.retryOptions.autoRetry = this.instanceRetryValue; } @@ -2053,7 +2053,7 @@ class File extends ServiceObject { if (crc32c && !options.isPartialUpload && !options.resumeCRC32C) { throw new RangeError( - FileExceptionMessages.MISSING_RESUME_CRC32C_FINAL_UPLOAD + FileExceptionMessages.MISSING_RESUME_CRC32C_FINAL_UPLOAD, ); } } @@ -2200,7 +2200,7 @@ class File extends ServiceObject { } catch (e) { pipelineCallback(e as Error); } - } + }, ); }); @@ -2219,7 +2219,7 @@ class File extends ServiceObject { delete(callback: DeleteCallback): void; delete( optionsOrCallback?: DeleteOptions | DeleteCallback, - cb?: DeleteCallback + cb?: DeleteCallback, ): Promise<[r.Response]> | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -2228,7 +2228,7 @@ class File extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.delete, AvailableServiceObjectMethods.delete, - options + options, ); super @@ -2309,7 +2309,7 @@ class File extends ServiceObject { */ download( optionsOrCallback?: DownloadOptions | DownloadCallback, - cb?: DownloadCallback + cb?: DownloadCallback, ): Promise | void { let options: DownloadOptions; if (typeof optionsOrCallback === 'function') { @@ -2421,7 +2421,7 @@ class File extends ServiceObject { setEncryptionKey(encryptionKey: string | Buffer) { this.encryptionKey = encryptionKey; this.encryptionKeyBase64 = Buffer.from(encryptionKey as string).toString( - 'base64' + 'base64', ); this.encryptionKeyHash = crypto .createHash('sha256') @@ -2456,7 +2456,7 @@ class File extends ServiceObject { static from( publicUrlOrGsUrl: string, storageInstance: Storage, - options?: FileOptions + options?: FileOptions, ): File { const gsMatches = [...publicUrlOrGsUrl.matchAll(GS_UTIL_URL_REGEX)]; const httpsMatches = [...publicUrlOrGsUrl.matchAll(HTTPS_PUBLIC_URL_REGEX)]; @@ -2469,7 +2469,7 @@ class File extends ServiceObject { return new File(bucket, httpsMatches[0][4], options); } else { throw new Error( - 'URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file' + 'URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file', ); } } @@ -2479,7 +2479,7 @@ class File extends ServiceObject { get(options: GetFileOptions, callback: InstanceResponseCallback): void; get( optionsOrCallback?: GetFileOptions | InstanceResponseCallback, - cb?: InstanceResponseCallback + cb?: InstanceResponseCallback, ): Promise> | void { // eslint-disable-next-line @typescript-eslint/no-explicit-any const options: any = @@ -2528,7 +2528,7 @@ class File extends ServiceObject { * ``` */ getExpirationDate( - callback?: GetExpirationDateCallback + callback?: GetExpirationDateCallback, ): void | Promise { this.getMetadata( (err: ApiError | null, metadata: FileMetadata, apiResponse: unknown) => { @@ -2546,21 +2546,21 @@ class File extends ServiceObject { callback!( null, new Date(metadata.retentionExpirationTime), - apiResponse + apiResponse, ); - } + }, ); } generateSignedPostPolicyV2( - options: GenerateSignedPostPolicyV2Options + options: GenerateSignedPostPolicyV2Options, ): Promise; generateSignedPostPolicyV2( options: GenerateSignedPostPolicyV2Options, - callback: GenerateSignedPostPolicyV2Callback + callback: GenerateSignedPostPolicyV2Callback, ): void; generateSignedPostPolicyV2( - callback: GenerateSignedPostPolicyV2Callback + callback: GenerateSignedPostPolicyV2Callback, ): void; /** * @typedef {array} GenerateSignedPostPolicyV2Response @@ -2655,16 +2655,16 @@ class File extends ServiceObject { optionsOrCallback?: | GenerateSignedPostPolicyV2Options | GenerateSignedPostPolicyV2Callback, - cb?: GenerateSignedPostPolicyV2Callback + cb?: GenerateSignedPostPolicyV2Callback, ): void | Promise { const args = normalize( optionsOrCallback, - cb + cb, ); let options = args.options; const callback = args.callback; const expires = new Date( - (options as GenerateSignedPostPolicyV2Options).expires + (options as GenerateSignedPostPolicyV2Options).expires, ); if (isNaN(expires.getTime())) { @@ -2753,19 +2753,19 @@ class File extends ServiceObject { }, err => { callback(new SigningError(err.message)); - } + }, ); } generateSignedPostPolicyV4( - options: GenerateSignedPostPolicyV4Options + options: GenerateSignedPostPolicyV4Options, ): Promise; generateSignedPostPolicyV4( options: GenerateSignedPostPolicyV4Options, - callback: GenerateSignedPostPolicyV4Callback + callback: GenerateSignedPostPolicyV4Callback, ): void; generateSignedPostPolicyV4( - callback: GenerateSignedPostPolicyV4Callback + callback: GenerateSignedPostPolicyV4Callback, ): void; /** * @typedef {object} SignedPostPolicyV4Output @@ -2859,7 +2859,7 @@ class File extends ServiceObject { optionsOrCallback?: | GenerateSignedPostPolicyV4Options | GenerateSignedPostPolicyV4Callback, - cb?: GenerateSignedPostPolicyV4Callback + cb?: GenerateSignedPostPolicyV4Callback, ): void | Promise { const args = normalize< GenerateSignedPostPolicyV4Options, @@ -2868,7 +2868,7 @@ class File extends ServiceObject { let options = args.options; const callback = args.callback; const expires = new Date( - (options as GenerateSignedPostPolicyV4Options).expires + (options as GenerateSignedPostPolicyV4Options).expires, ); if (isNaN(expires.getTime())) { @@ -2881,7 +2881,7 @@ class File extends ServiceObject { if (expires.valueOf() - Date.now() > SEVEN_DAYS * 1000) { throw new Error( - `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).` + `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).`, ); } @@ -2928,7 +2928,7 @@ class File extends ServiceObject { try { const signature = await this.storage.authClient.sign( policyBase64, - options.signingEndpoint + options.signingEndpoint, ); const signatureHex = Buffer.from(signature, 'base64').toString('hex'); const universe = this.parent.storage.universeDomain; @@ -3140,7 +3140,7 @@ class File extends ServiceObject { */ getSignedUrl( cfg: GetSignedUrlConfig, - callback?: GetSignedUrlCallback + callback?: GetSignedUrlCallback, ): void | Promise { const method = ActionToHTTPMethod[cfg.action]; const extensionHeaders = objectKeyToLowercase(cfg.extensionHeaders || {}); @@ -3191,7 +3191,7 @@ class File extends ServiceObject { this.storage.authClient, this.bucket, this, - this.storage + this.storage, ); } @@ -3289,17 +3289,17 @@ class File extends ServiceObject { } else { callback!(null, true); } - } + }, ); } makePrivate( - options?: MakeFilePrivateOptions + options?: MakeFilePrivateOptions, ): Promise; makePrivate(callback: MakeFilePrivateCallback): void; makePrivate( options: MakeFilePrivateOptions, - callback: MakeFilePrivateCallback + callback: MakeFilePrivateCallback, ): void; /** * @typedef {object} MakeFilePrivateOptions Configuration options for File#makePrivate(). @@ -3357,7 +3357,7 @@ class File extends ServiceObject { */ makePrivate( optionsOrCallback?: MakeFilePrivateOptions | MakeFilePrivateCallback, - callback?: MakeFilePrivateCallback + callback?: MakeFilePrivateCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3429,7 +3429,7 @@ class File extends ServiceObject { * Another example: */ makePublic( - callback?: MakeFilePublicCallback + callback?: MakeFilePublicCallback, ): Promise | void { callback = callback || util.noop; this.acl.add( @@ -3439,7 +3439,7 @@ class File extends ServiceObject { }, (err, acl, resp) => { callback!(err, resp); - } + }, ); } @@ -3468,16 +3468,16 @@ class File extends ServiceObject { moveFileAtomic( destination: string | File, - options?: MoveFileAtomicOptions + options?: MoveFileAtomicOptions, ): Promise; moveFileAtomic( destination: string | File, - callback: MoveFileAtomicCallback + callback: MoveFileAtomicCallback, ): void; moveFileAtomic( destination: string | File, options: MoveFileAtomicOptions, - callback: MoveFileAtomicCallback + callback: MoveFileAtomicCallback, ): void; /** * @typedef {array} MoveFileAtomicResponse @@ -3577,10 +3577,10 @@ class File extends ServiceObject { moveFileAtomic( destination: string | File, optionsOrCallback?: MoveFileAtomicOptions | MoveFileAtomicCallback, - callback?: MoveFileAtomicCallback + callback?: MoveFileAtomicCallback, ): Promise | void { const noDestinationError = new Error( - FileExceptionMessages.DESTINATION_NO_NAME + FileExceptionMessages.DESTINATION_NO_NAME, ); if (!destination) { @@ -3617,7 +3617,7 @@ class File extends ServiceObject { if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?.preconditionOpts + options?.preconditionOpts, ) ) { this.storage.retryOptions.autoRetry = false; @@ -3647,19 +3647,19 @@ class File extends ServiceObject { } callback!(null, newFile, resp); - } + }, ); } move( destination: string | Bucket | File, - options?: MoveOptions + options?: MoveOptions, ): Promise; move(destination: string | Bucket | File, callback: MoveCallback): void; move( destination: string | Bucket | File, options: MoveOptions, - callback: MoveCallback + callback: MoveCallback, ): void; /** * @typedef {array} MoveResponse @@ -3794,7 +3794,7 @@ class File extends ServiceObject { move( destination: string | Bucket | File, optionsOrCallback?: MoveOptions | MoveCallback, - callback?: MoveCallback + callback?: MoveCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3830,13 +3830,13 @@ class File extends ServiceObject { rename( destinationFile: string | File, - options?: RenameOptions + options?: RenameOptions, ): Promise; rename(destinationFile: string | File, callback: RenameCallback): void; rename( destinationFile: string | File, options: RenameOptions, - callback: RenameCallback + callback: RenameCallback, ): void; /** * @typedef {array} RenameResponse @@ -3925,7 +3925,7 @@ class File extends ServiceObject { rename( destinationFile: string | File, optionsOrCallback?: RenameOptions | RenameCallback, - callback?: RenameCallback + callback?: RenameCallback, ): Promise | void { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -3975,7 +3975,7 @@ class File extends ServiceObject { request(reqOpts: DecorateRequestOptions): Promise; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void; /** * Makes request and applies userProject query parameter if necessary. @@ -3987,18 +3987,18 @@ class File extends ServiceObject { */ request( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | Promise { return this.parent.request.call(this, reqOpts, callback!); } rotateEncryptionKey( - options?: RotateEncryptionKeyOptions + options?: RotateEncryptionKeyOptions, ): Promise; rotateEncryptionKey(callback: RotateEncryptionKeyCallback): void; rotateEncryptionKey( options: RotateEncryptionKeyOptions, - callback: RotateEncryptionKeyCallback + callback: RotateEncryptionKeyCallback, ): void; /** * @callback RotateEncryptionKeyCallback @@ -4036,7 +4036,7 @@ class File extends ServiceObject { optionsOrCallback?: | RotateEncryptionKeyOptions | RotateEncryptionKeyCallback, - callback?: RotateEncryptionKeyCallback + callback?: RotateEncryptionKeyCallback, ): Promise | void { callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : callback; @@ -4119,7 +4119,7 @@ class File extends ServiceObject { save( data: SaveData, optionsOrCallback?: SaveOptions | SaveCallback, - callback?: SaveCallback + callback?: SaveCallback, ): Promise | void { // tslint:enable:no-any callback = @@ -4130,7 +4130,7 @@ class File extends ServiceObject { let maxRetries = this.storage.retryOptions.maxRetries; if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options?.preconditionOpts + options?.preconditionOpts, ) ) { maxRetries = 0; @@ -4189,7 +4189,7 @@ class File extends ServiceObject { factor: this.storage.retryOptions.retryDelayMultiplier, maxTimeout: this.storage.retryOptions.maxRetryDelay! * 1000, //convert to milliseconds maxRetryTime: this.storage.retryOptions.totalTimeout! * 1000, //convert to milliseconds - } + }, ); if (!callback) { return returnValue; @@ -4206,21 +4206,21 @@ class File extends ServiceObject { setMetadata( metadata: FileMetadata, - options?: SetMetadataOptions + options?: SetMetadataOptions, ): Promise>; setMetadata( metadata: FileMetadata, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: FileMetadata, options: SetMetadataOptions, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: FileMetadata, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback + cb?: MetadataCallback, ): Promise> | void { // eslint-disable-next-line @typescript-eslint/no-explicit-any const options: any = @@ -4233,7 +4233,7 @@ class File extends ServiceObject { this.disableAutoRetryConditionallyIdempotent_( this.methods.setMetadata, AvailableServiceObjectMethods.setMetadata, - options + options, ); super @@ -4247,16 +4247,16 @@ class File extends ServiceObject { setStorageClass( storageClass: string, - options?: SetStorageClassOptions + options?: SetStorageClassOptions, ): Promise; setStorageClass( storageClass: string, options: SetStorageClassOptions, - callback: SetStorageClassCallback + callback: SetStorageClassCallback, ): void; setStorageClass( storageClass: string, - callback?: SetStorageClassCallback + callback?: SetStorageClassCallback, ): void; /** * @typedef {array} SetStorageClassResponse @@ -4307,7 +4307,7 @@ class File extends ServiceObject { setStorageClass( storageClass: string, optionsOrCallback?: SetStorageClassOptions | SetStorageClassCallback, - callback?: SetStorageClassCallback + callback?: SetStorageClassCallback, ): Promise | void { callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : callback; @@ -4367,14 +4367,14 @@ class File extends ServiceObject { */ startResumableUpload_( dup: Duplexify, - options: CreateResumableUploadOptions = {} + options: CreateResumableUploadOptions = {}, ): void { options.metadata ??= {}; const retryOptions = this.storage.retryOptions; if ( !this.shouldRetryBasedOnPreconditionAndIdempotencyStrat( - options.preconditionOpts + options.preconditionOpts, ) ) { retryOptions.autoRetry = false; @@ -4385,7 +4385,7 @@ class File extends ServiceObject { bucket: this.bucket.name, customRequestOptions: this.getRequestInterceptors().reduce( (reqOpts, interceptorFn) => interceptorFn(reqOpts), - {} + {}, ), file: this.name, generation: this.generation, @@ -4449,7 +4449,7 @@ class File extends ServiceObject { */ startSimpleUpload_( dup: Duplexify, - options: CreateWriteStreamOptions = {} + options: CreateWriteStreamOptions = {}, ): void { options.metadata ??= {}; @@ -4492,7 +4492,7 @@ class File extends ServiceObject { Object.assign( reqOpts.qs, this.instancePreconditionOpts, - options.preconditionOpts + options.preconditionOpts, ); util.makeWritableStream(dup, { @@ -4518,7 +4518,7 @@ class File extends ServiceObject { // eslint-disable-next-line @typescript-eslint/no-explicit-any coreOpts: any, methodType: AvailableServiceObjectMethods, - localPreconditionOptions?: PreconditionOptions + localPreconditionOptions?: PreconditionOptions, ): void { if ( (typeof coreOpts === 'object' && @@ -4564,7 +4564,7 @@ class File extends ServiceObject { */ async #validateIntegrity( hashCalculatingStream: HashStreamValidator, - verify: {crc32c?: boolean; md5?: boolean} = {} + verify: {crc32c?: boolean; md5?: boolean} = {}, ) { const metadata = this.metadata; diff --git a/handwritten/storage/src/hash-stream-validator.ts b/handwritten/storage/src/hash-stream-validator.ts index 9e9f67d330c..b41dd51b6dc 100644 --- a/handwritten/storage/src/hash-stream-validator.ts +++ b/handwritten/storage/src/hash-stream-validator.ts @@ -117,7 +117,7 @@ class HashStreamValidator extends Transform { if (failed) { const mismatchError = new RequestError( - FileExceptionMessages.DOWNLOAD_MISMATCH + FileExceptionMessages.DOWNLOAD_MISMATCH, ); mismatchError.code = 'CONTENT_DOWNLOAD_MISMATCH'; @@ -130,7 +130,7 @@ class HashStreamValidator extends Transform { _transform( chunk: Buffer, encoding: BufferEncoding, - callback: (e?: Error) => void + callback: (e?: Error) => void, ) { this.push(chunk, encoding); diff --git a/handwritten/storage/src/hmacKey.ts b/handwritten/storage/src/hmacKey.ts index 9b79daa5e8c..4f73737331d 100644 --- a/handwritten/storage/src/hmacKey.ts +++ b/handwritten/storage/src/hmacKey.ts @@ -371,21 +371,21 @@ export class HmacKey extends ServiceObject { */ setMetadata( metadata: HmacKeyMetadata, - options?: SetMetadataOptions + options?: SetMetadataOptions, ): Promise>; setMetadata( metadata: HmacKeyMetadata, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: HmacKeyMetadata, options: SetMetadataOptions, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: HmacKeyMetadata, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback + cb?: MetadataCallback, ): Promise> | void { // ETag preconditions are not currently supported. Retries should be disabled if the idempotency strategy is not set to RetryAlways if ( diff --git a/handwritten/storage/src/iam.ts b/handwritten/storage/src/iam.ts index 8f6ee5d76d3..7a90a1b36d4 100644 --- a/handwritten/storage/src/iam.ts +++ b/handwritten/storage/src/iam.ts @@ -99,7 +99,7 @@ export interface TestIamPermissionsCallback { ( err?: Error | null, acl?: {[key: string]: boolean} | null, - apiResponse?: unknown + apiResponse?: unknown, ): void; } @@ -143,7 +143,7 @@ export enum IAMExceptionMessages { class Iam { private request_: ( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ) => void; private resourceId_: string; @@ -242,7 +242,7 @@ class Iam { */ getPolicy( optionsOrCallback?: GetPolicyOptions | GetPolicyCallback, - callback?: GetPolicyCallback + callback?: GetPolicyCallback, ): Promise | void { const {options, callback: cb} = normalize< GetPolicyOptions, @@ -266,19 +266,19 @@ class Iam { uri: '/iam', qs, }, - cb! + cb!, ); } setPolicy( policy: Policy, - options?: SetPolicyOptions + options?: SetPolicyOptions, ): Promise; setPolicy(policy: Policy, callback: SetPolicyCallback): void; setPolicy( policy: Policy, options: SetPolicyOptions, - callback: SetPolicyCallback + callback: SetPolicyCallback, ): void; /** * Set the IAM policy. @@ -331,7 +331,7 @@ class Iam { setPolicy( policy: Policy, optionsOrCallback?: SetPolicyOptions | SetPolicyCallback, - callback?: SetPolicyCallback + callback?: SetPolicyCallback, ): Promise | void { if (policy === null || typeof policy !== 'object') { throw new Error(IAMExceptionMessages.POLICY_OBJECT_REQUIRED); @@ -356,26 +356,26 @@ class Iam { { resourceId: this.resourceId_, }, - policy + policy, ), qs: options, }, - cb + cb, ); } testPermissions( permissions: string | string[], - options?: TestIamPermissionsOptions + options?: TestIamPermissionsOptions, ): Promise; testPermissions( permissions: string | string[], - callback: TestIamPermissionsCallback + callback: TestIamPermissionsCallback, ): void; testPermissions( permissions: string | string[], options: TestIamPermissionsOptions, - callback: TestIamPermissionsCallback + callback: TestIamPermissionsCallback, ): void; /** * Test a set of permissions for a resource. @@ -435,7 +435,7 @@ class Iam { testPermissions( permissions: string | string[], optionsOrCallback?: TestIamPermissionsOptions | TestIamPermissionsCallback, - callback?: TestIamPermissionsCallback + callback?: TestIamPermissionsCallback, ): Promise | void { if (!Array.isArray(permissions) && typeof permissions !== 'string') { throw new Error(IAMExceptionMessages.PERMISSIONS_REQUIRED); @@ -454,7 +454,7 @@ class Iam { { permissions: permissionsArray, }, - options + options, ); this.request_( @@ -478,11 +478,11 @@ class Iam { acc[permission] = availablePermissions.indexOf(permission) > -1; return acc; }, - {} + {}, ); cb!(null, permissionsHash, resp); - } + }, ); } } diff --git a/handwritten/storage/src/nodejs-common/service-object.ts b/handwritten/storage/src/nodejs-common/service-object.ts index a4e369a3f5e..4f83189d525 100644 --- a/handwritten/storage/src/nodejs-common/service-object.ts +++ b/handwritten/storage/src/nodejs-common/service-object.ts @@ -34,7 +34,7 @@ export interface ServiceObjectParent { requestStream(reqOpts: DecorateRequestOptions): r.Request; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void; } @@ -48,7 +48,7 @@ export type MetadataResponse = [K, r.Response]; export type MetadataCallback = ( err: Error | null, metadata?: K, - apiResponse?: r.Response + apiResponse?: r.Response, ) => void; export type ExistsOptions = object; @@ -237,7 +237,7 @@ class ServiceObject extends EventEmitter { create(callback: CreateCallback): void; create( optionsOrCallback?: CreateOptions | CreateCallback, - callback?: CreateCallback + callback?: CreateCallback, ): void | Promise> { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; @@ -282,7 +282,7 @@ class ServiceObject extends EventEmitter { delete(callback: DeleteCallback): void; delete( optionsOrCallback?: DeleteOptions | DeleteCallback, - cb?: DeleteCallback + cb?: DeleteCallback, ): Promise<[r.Response]> | void { const [options, callback] = util.maybeOptionsOrCallback< DeleteOptions, @@ -317,7 +317,7 @@ class ServiceObject extends EventEmitter { } } callback(err, res); - } + }, ); } @@ -333,7 +333,7 @@ class ServiceObject extends EventEmitter { exists(callback: ExistsCallback): void; exists( optionsOrCallback?: ExistsOptions | ExistsCallback, - cb?: ExistsCallback + cb?: ExistsCallback, ): void | Promise<[boolean]> { const [options, callback] = util.maybeOptionsOrCallback< ExistsOptions, @@ -370,7 +370,7 @@ class ServiceObject extends EventEmitter { get(options: GetOrCreateOptions, callback: InstanceResponseCallback): void; get( optionsOrCallback?: GetOrCreateOptions | InstanceResponseCallback, - cb?: InstanceResponseCallback + cb?: InstanceResponseCallback, ): Promise> | void { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; @@ -387,7 +387,7 @@ class ServiceObject extends EventEmitter { function onCreate( err: ApiError | null, instance: T, - apiResponse: r.Response + apiResponse: r.Response, ) { if (err) { if (err.code === 409) { @@ -431,7 +431,7 @@ class ServiceObject extends EventEmitter { getMetadata(callback: MetadataCallback): void; getMetadata( optionsOrCallback: GetMetadataOptions | MetadataCallback, - cb?: MetadataCallback + cb?: MetadataCallback, ): Promise> | void { const [options, callback] = util.maybeOptionsOrCallback< GetMetadataOptions, @@ -459,7 +459,7 @@ class ServiceObject extends EventEmitter { (err: Error | null, body?: ResponseBody, res?: r.Response) => { this.metadata = body; callback!(err, this.metadata, res); - } + }, ); } @@ -485,18 +485,18 @@ class ServiceObject extends EventEmitter { */ setMetadata( metadata: K, - options?: SetMetadataOptions + options?: SetMetadataOptions, ): Promise>; setMetadata(metadata: K, callback: MetadataCallback): void; setMetadata( metadata: K, options: SetMetadataOptions, - callback: MetadataCallback + callback: MetadataCallback, ): void; setMetadata( metadata: K, optionsOrCallback: SetMetadataOptions | MetadataCallback, - cb?: MetadataCallback + cb?: MetadataCallback, ): Promise> | void { const [options, callback] = util.maybeOptionsOrCallback< SetMetadataOptions, @@ -529,7 +529,7 @@ class ServiceObject extends EventEmitter { (err: Error | null, body?: ResponseBody, res?: r.Response) => { this.metadata = body; callback!(err, this.metadata, res); - } + }, ); } @@ -545,11 +545,11 @@ class ServiceObject extends EventEmitter { private request_(reqOpts: StreamRequestOptions): r.Request; private request_( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void; private request_( reqOpts: DecorateRequestOptions | StreamRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | r.Request { reqOpts = {...reqOpts}; @@ -595,11 +595,11 @@ class ServiceObject extends EventEmitter { request(reqOpts: DecorateRequestOptions): Promise; request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void; request( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | Promise { this.request_(reqOpts, callback!); } diff --git a/handwritten/storage/src/nodejs-common/service.ts b/handwritten/storage/src/nodejs-common/service.ts index 9ade0478e04..6e2a6cb9078 100644 --- a/handwritten/storage/src/nodejs-common/service.ts +++ b/handwritten/storage/src/nodejs-common/service.ts @@ -183,7 +183,7 @@ export class Service { getProjectId(): Promise; getProjectId(callback: (err: Error | null, projectId?: string) => void): void; getProjectId( - callback?: (err: Error | null, projectId?: string) => void + callback?: (err: Error | null, projectId?: string) => void, ): Promise | void { if (!callback) { return this.getProjectIdAsync(); @@ -211,11 +211,11 @@ export class Service { private request_(reqOpts: StreamRequestOptions): r.Request; private request_( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void; private request_( reqOpts: DecorateRequestOptions | StreamRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | r.Request { reqOpts = {...reqOpts, timeout: this.timeout}; const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; @@ -298,7 +298,7 @@ export class Service { */ request( reqOpts: DecorateRequestOptions, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void { Service.prototype.request_.call(this, reqOpts, callback); } diff --git a/handwritten/storage/src/nodejs-common/util.ts b/handwritten/storage/src/nodejs-common/util.ts index aec0b2f5064..9ba3051add3 100644 --- a/handwritten/storage/src/nodejs-common/util.ts +++ b/handwritten/storage/src/nodejs-common/util.ts @@ -96,17 +96,17 @@ export interface DuplexifyConstructor { obj( writable?: Writable | false | null, readable?: Readable | false | null, - options?: DuplexifyOptions + options?: DuplexifyOptions, ): Duplexify; new ( writable?: Writable | false | null, readable?: Readable | false | null, - options?: DuplexifyOptions + options?: DuplexifyOptions, ): Duplexify; ( writable?: Writable | false | null, readable?: Readable | false | null, - options?: DuplexifyOptions + options?: DuplexifyOptions, ): Duplexify; } @@ -119,18 +119,18 @@ export interface MakeAuthenticatedRequest { (reqOpts: DecorateRequestOptions): Duplexify; ( reqOpts: DecorateRequestOptions, - options?: MakeAuthenticatedRequestOptions + options?: MakeAuthenticatedRequestOptions, ): void | Abortable; ( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | Abortable; ( reqOpts: DecorateRequestOptions, - optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback + optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback, ): void | Abortable | Duplexify; getCredentials: ( - callback: (err?: Error | null, credentials?: CredentialBody) => void + callback: (err?: Error | null, credentials?: CredentialBody) => void, ) => void; authClient: GoogleAuth; } @@ -233,9 +233,9 @@ export interface MakeWritableStreamOptions { fnobj: { onAuthenticated( err: Error | null, - authenticatedReqOpts?: r.Options + authenticatedReqOpts?: r.Options, ): void; - } + }, ): void; } @@ -300,7 +300,7 @@ export class ApiError extends Error { */ static createMultiErrorMessage( err: GoogleErrorBody, - errors?: GoogleInnerError[] + errors?: GoogleInnerError[], ): string { const messages: Set = new Set(); @@ -321,7 +321,7 @@ export class ApiError extends Error { if (messageArr.length > 1) { messageArr = messageArr.map((message, i) => ` ${i + 1}. ${message}`); messageArr.unshift( - 'Multiple errors occurred during the request. Please see the `errors` array for complete details.\n' + 'Multiple errors occurred during the request. Please see the `errors` array for complete details.\n', ); messageArr.push('\n'); } @@ -412,7 +412,7 @@ export class Util { err: Error | null, resp?: r.Response | null, body?: ResponseBody, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ) { callback = callback || util.noop; @@ -510,7 +510,7 @@ export class Util { makeWritableStream( dup: Duplexify, options: MakeWritableStreamOptions, - onComplete?: Function + onComplete?: Function, ) { onComplete = onComplete || util.noop; @@ -558,7 +558,7 @@ export class Util { } requestDefaults.headers = util._getDefaultHeaders( - reqOpts[GCCL_GCS_CMD_KEY] + reqOpts[GCCL_GCS_CMD_KEY], ); const request = teenyRequest.defaults(requestDefaults); request(authenticatedReqOpts!, (err, resp, body) => { @@ -625,7 +625,7 @@ export class Util { * @param {array} config.scopes - Array of scopes required for the API. */ makeAuthenticatedRequestFactory( - config: MakeAuthenticatedRequestFactoryConfig + config: MakeAuthenticatedRequestFactoryConfig, ) { const googleAutoAuthConfig = {...config}; if (googleAutoAuthConfig.projectId === DEFAULT_PROJECT_ID_TOKEN) { @@ -656,19 +656,21 @@ export class Util { * authenticated request options. */ function makeAuthenticatedRequest( - reqOpts: DecorateRequestOptions + reqOpts: DecorateRequestOptions, ): Duplexify; function makeAuthenticatedRequest( reqOpts: DecorateRequestOptions, - options?: MakeAuthenticatedRequestOptions + options?: MakeAuthenticatedRequestOptions, ): void | Abortable; function makeAuthenticatedRequest( reqOpts: DecorateRequestOptions, - callback?: BodyResponseCallback + callback?: BodyResponseCallback, ): void | Abortable; function makeAuthenticatedRequest( reqOpts: DecorateRequestOptions, - optionsOrCallback?: MakeAuthenticatedRequestOptions | BodyResponseCallback + optionsOrCallback?: + | MakeAuthenticatedRequestOptions + | BodyResponseCallback, ): void | Abortable | Duplexify { let stream: Duplexify; let projectId: string; @@ -691,7 +693,7 @@ export class Util { const onAuthenticated = async ( err: Error | null, - authenticatedReqOpts?: DecorateRequestOptions + authenticatedReqOpts?: DecorateRequestOptions, ) => { const authLibraryError = err; const autoAuthFailed = @@ -710,7 +712,7 @@ export class Util { // Try with existing `projectId` value authenticatedReqOpts = util.decorateRequest( authenticatedReqOpts!, - projectId + projectId, ); err = null; @@ -723,7 +725,7 @@ export class Util { authenticatedReqOpts = util.decorateRequest( authenticatedReqOpts!, - projectId + projectId, ); err = null; @@ -769,7 +771,7 @@ export class Util { apiResponseError = authLibraryError; } callback!(apiResponseError, ...params); - } + }, ); } }; @@ -818,7 +820,7 @@ export class Util { return onAuthenticated( null, - authorizedReqOpts as DecorateRequestOptions + authorizedReqOpts as DecorateRequestOptions, ); } catch (e) { return onAuthenticated(e as Error); @@ -866,7 +868,7 @@ export class Util { makeRequest( reqOpts: DecorateRequestOptions, config: MakeRequestConfig, - callback: BodyResponseCallback + callback: BodyResponseCallback, ): void | Abortable { let autoRetryValue = AUTO_RETRY_DEFAULT; if (config.autoRetry !== undefined) { @@ -883,7 +885,7 @@ export class Util { } requestDefaults.headers = this._getDefaultHeaders( - reqOpts[GCCL_GCS_CMD_KEY] + reqOpts[GCCL_GCS_CMD_KEY], ); const options = { request: teenyRequest.defaults(requestDefaults), @@ -913,7 +915,7 @@ export class Util { // eslint-disable-next-line @typescript-eslint/no-explicit-any (err: Error | null, response: {}, body: any) => { util.handleResp(err, response as {} as r.Response, body, callback!); - } + }, ); } const dup = config.stream as AbortableDuplex; @@ -1014,7 +1016,7 @@ export class Util { */ maybeOptionsOrCallback void>( optionsOrCallback?: T | C, - cb?: C + cb?: C, ): [T, C] { return typeof optionsOrCallback === 'function' ? [{} as T, optionsOrCallback as C] diff --git a/handwritten/storage/src/notification.ts b/handwritten/storage/src/notification.ts index 6d63a899f2e..95b2e081188 100644 --- a/handwritten/storage/src/notification.ts +++ b/handwritten/storage/src/notification.ts @@ -72,7 +72,7 @@ export interface GetNotificationCallback { ( err: Error | null, notification?: Notification | null, - apiResponse?: unknown + apiResponse?: unknown, ): void; } diff --git a/handwritten/storage/src/resumable-upload.ts b/handwritten/storage/src/resumable-upload.ts index 07b5a28f191..af9e92a0cc2 100644 --- a/handwritten/storage/src/resumable-upload.ts +++ b/handwritten/storage/src/resumable-upload.ts @@ -109,7 +109,7 @@ export interface UploadConfig extends Pick { */ authClient?: { request: ( - opts: GaxiosOptions + opts: GaxiosOptions, ) => Promise> | GaxiosPromise; }; @@ -311,7 +311,7 @@ export class Upload extends Writable { */ authClient: { request: ( - opts: GaxiosOptions + opts: GaxiosOptions, ) => Promise> | GaxiosPromise; }; cacheKey: string; @@ -373,13 +373,13 @@ export class Upload extends Writable { if (cfg.offset && !cfg.uri) { throw new RangeError( - 'Cannot provide an `offset` without providing a `uri`' + 'Cannot provide an `offset` without providing a `uri`', ); } if (cfg.isPartialUpload && !cfg.chunkSize) { throw new RangeError( - 'Cannot set `isPartialUpload` without providing a `chunkSize`' + 'Cannot set `isPartialUpload` without providing a `chunkSize`', ); } @@ -546,7 +546,7 @@ export class Upload extends Writable { _write( chunk: Buffer | string, encoding: BufferEncoding, - readCallback = () => {} + readCallback = () => {}, ) { // Backwards-compatible event this.emit('writing'); @@ -590,7 +590,7 @@ export class Upload extends Writable { #validateChecksum( clientHash: string | undefined, serverHash: string | undefined, - hashType: 'CRC32C' | 'MD5' + hashType: 'CRC32C' | 'MD5', ): boolean { // Only validate if both client and server hashes are present. if (clientHash && serverHash) { @@ -823,7 +823,7 @@ export class Upload extends Writable { name: this.file, uploadType: 'resumable', }, - this.params + this.params, ), data: metadata, headers: { @@ -891,7 +891,7 @@ export class Upload extends Writable { factor: this.retryOptions.retryDelayMultiplier, maxTimeout: this.retryOptions.maxRetryDelay! * 1000, //convert to milliseconds maxRetryTime: this.retryOptions.totalTimeout! * 1000, //convert to milliseconds - } + }, ); this.uri = uri; @@ -1174,7 +1174,7 @@ export class Upload extends Writable { this.#validateChecksum( clientCrc32cToValidate, serverCrc32c, - 'CRC32C' + 'CRC32C', ) || this.#validateChecksum(clientMd5HashToValidate, serverMd5, 'MD5') ) { @@ -1207,7 +1207,7 @@ export class Upload extends Writable { * @returns the current upload status */ async checkUploadStatus( - config: CheckUploadStatusConfig = {} + config: CheckUploadStatusConfig = {}, ): Promise> { let googAPIClient = `${getRuntimeTrackingString()} gccl/${ packageJson.version @@ -1316,7 +1316,7 @@ export class Upload extends Writable { }; const res = await this.authClient.request<{error?: object}>( - combinedReqOpts + combinedReqOpts, ); if (res.data && res.data.error) { throw res.data.error; @@ -1387,8 +1387,8 @@ export class Upload extends Writable { if (retryDelay <= 0) { this.destroy( new Error( - `Retry total time limit exceeded - ${JSON.stringify(resp.data)}` - ) + `Retry total time limit exceeded - ${JSON.stringify(resp.data)}`, + ), ); return; } @@ -1410,7 +1410,7 @@ export class Upload extends Writable { this.numRetries++; } else { this.destroy( - new Error(`Retry limit exceeded - ${JSON.stringify(resp.data)}`) + new Error(`Retry limit exceeded - ${JSON.stringify(resp.data)}`), ); } } @@ -1464,7 +1464,7 @@ export function createURI(cfg: UploadConfig): Promise; export function createURI(cfg: UploadConfig, callback: CreateUriCallback): void; export function createURI( cfg: UploadConfig, - callback?: CreateUriCallback + callback?: CreateUriCallback, ): void | Promise { const up = new Upload(cfg); if (!callback) { @@ -1480,7 +1480,7 @@ export function createURI( * @returns the current upload status */ export function checkUploadStatus( - cfg: UploadConfig & Required> + cfg: UploadConfig & Required>, ) { const up = new Upload(cfg); diff --git a/handwritten/storage/src/signer.ts b/handwritten/storage/src/signer.ts index 879bc4d2a57..a657cef6133 100644 --- a/handwritten/storage/src/signer.ts +++ b/handwritten/storage/src/signer.ts @@ -152,11 +152,11 @@ export class URLSigner { * move it before optional properties. In the next major we should refactor the * constructor of this class to only accept a config object. */ - private storage: Storage = new Storage() + private storage: Storage = new Storage(), ) {} getSignedUrl( - cfg: SignerGetSignedUrlConfig + cfg: SignerGetSignedUrlConfig, ): Promise { const expiresInSeconds = this.parseExpires(cfg.expires); const method = cfg.method; @@ -164,7 +164,7 @@ export class URLSigner { if (expiresInSeconds < accessibleAtInSeconds) { throw new Error( - SignerExceptionMessages.EXPIRATION_BEFORE_ACCESSIBLE_DATE + SignerExceptionMessages.EXPIRATION_BEFORE_ACCESSIBLE_DATE, ); } @@ -200,7 +200,7 @@ export class URLSigner { promise = this.getSignedUrlV4(config); } else { throw new Error( - `Invalid signed URL version: ${version}. Supported versions are 'v2' and 'v4'.` + `Invalid signed URL version: ${version}. Supported versions are 'v2' and 'v4'.`, ); } @@ -208,13 +208,13 @@ export class URLSigner { query = Object.assign(query, cfg.queryParams); const signedUrl = new url.URL( - cfg.host?.toString() || config.cname || this.storage.apiEndpoint + cfg.host?.toString() || config.cname || this.storage.apiEndpoint, ); signedUrl.pathname = this.getResourcePath( !!config.cname, this.bucket.name, - config.file + config.file, ); // eslint-disable-next-line @typescript-eslint/no-explicit-any signedUrl.search = qsStringify(query as any); @@ -223,15 +223,15 @@ export class URLSigner { } private getSignedUrlV2( - config: GetSignedUrlConfigInternal + config: GetSignedUrlConfigInternal, ): Promise { const canonicalHeadersString = this.getCanonicalHeaders( - config.extensionHeaders || {} + config.extensionHeaders || {}, ); const resourcePath = this.getResourcePath( false, config.bucket, - config.file + config.file, ); const blobToSign = [ @@ -247,7 +247,7 @@ export class URLSigner { try { const signature = await auth.sign( blobToSign, - config.signingEndpoint?.toString() + config.signingEndpoint?.toString(), ); const credentials = await auth.getCredentials(); @@ -267,7 +267,7 @@ export class URLSigner { } private getSignedUrlV4( - config: GetSignedUrlConfigInternal + config: GetSignedUrlConfigInternal, ): Promise { config.accessibleAt = config.accessibleAt ? config.accessibleAt @@ -279,13 +279,13 @@ export class URLSigner { // v4 limit expiration to be 7 days maximum if (expiresPeriodInSeconds > SEVEN_DAYS) { throw new Error( - `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).` + `Max allowed expiration is seven days (${SEVEN_DAYS} seconds).`, ); } const extensionHeaders = Object.assign({}, config.extensionHeaders); const fqdn = new url.URL( - config.host?.toString() || config.cname || this.storage.apiEndpoint + config.host?.toString() || config.cname || this.storage.apiEndpoint, ); extensionHeaders.host = fqdn.hostname; if (config.contentMd5) { @@ -322,7 +322,7 @@ export class URLSigner { const credential = `${credentials.client_email}/${credentialScope}`; const dateISO = formatAsUTCISO( config.accessibleAt ? config.accessibleAt : new Date(), - true + true, ); const queryParams: Query = { 'X-Goog-Algorithm': 'GOOG4-RSA-SHA256', @@ -342,7 +342,7 @@ export class URLSigner { canonicalQueryParams, extensionHeadersString, signedHeaders, - contentSha256 + contentSha256, ); const hash = crypto @@ -360,7 +360,7 @@ export class URLSigner { try { const signature = await this.auth.sign( blobToSign, - config.signingEndpoint?.toString() + config.signingEndpoint?.toString(), ); const signatureHex = Buffer.from(signature, 'base64').toString('hex'); const signedQuery: Query = Object.assign({}, queryParams, { @@ -421,7 +421,7 @@ export class URLSigner { query: string, headers: string, signedHeaders: string, - contentSha256?: string + contentSha256?: string, ) { return [ method, @@ -453,7 +453,7 @@ export class URLSigner { parseExpires( expires: string | number | Date, - current: Date = new Date() + current: Date = new Date(), ): number { const expiresInMSeconds = new Date(expires).valueOf(); @@ -470,7 +470,7 @@ export class URLSigner { parseAccessibleAt(accessibleAt?: string | number | Date): number { const accessibleAtInMSeconds = new Date( - accessibleAt || new Date() + accessibleAt || new Date(), ).valueOf(); if (isNaN(accessibleAtInMSeconds)) { diff --git a/handwritten/storage/src/storage.ts b/handwritten/storage/src/storage.ts index ab036e15b0e..dd0f735f6ed 100644 --- a/handwritten/storage/src/storage.ts +++ b/handwritten/storage/src/storage.ts @@ -43,7 +43,7 @@ export interface GetServiceAccountCallback { ( err: Error | null, serviceAccount?: ServiceAccount, - apiResponse?: unknown + apiResponse?: unknown, ): void; } @@ -176,7 +176,7 @@ export interface GetBucketsCallback { err: Error | null, buckets: Bucket[], nextQuery?: {}, - apiResponse?: unknown + apiResponse?: unknown, ): void; } export interface GetBucketsRequest { @@ -209,7 +209,7 @@ export interface CreateHmacKeyCallback { err: Error | null, hmacKey?: HmacKey | null, secret?: string | null, - apiResponse?: HmacKeyResourceResponse + apiResponse?: HmacKeyResourceResponse, ): void; } @@ -229,7 +229,7 @@ export interface GetHmacKeysCallback { err: Error | null, hmacKeys: HmacKey[] | null, nextQuery?: {}, - apiResponse?: unknown + apiResponse?: unknown, ): void; } @@ -858,18 +858,18 @@ export class Storage extends Service { createBucket( name: string, - metadata?: CreateBucketRequest + metadata?: CreateBucketRequest, ): Promise; createBucket(name: string, callback: BucketCallback): void; createBucket( name: string, metadata: CreateBucketRequest, - callback: BucketCallback + callback: BucketCallback, ): void; createBucket( name: string, metadata: CreateBucketRequest, - callback: BucketCallback + callback: BucketCallback, ): void; /** * @typedef {array} CreateBucketResponse @@ -999,7 +999,7 @@ export class Storage extends Service { createBucket( name: string, metadataOrCallback?: BucketCallback | CreateBucketRequest, - callback?: BucketCallback + callback?: BucketCallback, ): Promise | void { if (!name) { throw new Error(StorageExceptionMessages.BUCKET_NAME_REQUIRED_CREATE); @@ -1028,14 +1028,14 @@ export class Storage extends Service { standard: 'STANDARD', } as const; const storageClassKeys = Object.keys( - storageClasses + storageClasses, ) as (keyof typeof storageClasses)[]; for (const storageClass of storageClassKeys) { if (body[storageClass]) { if (metadata.storageClass && metadata.storageClass !== storageClass) { throw new Error( - `Both \`${storageClass}\` and \`storageClass\` were provided.` + `Both \`${storageClass}\` and \`storageClass\` were provided.`, ); } body.storageClass = storageClasses[storageClass]; @@ -1096,22 +1096,22 @@ export class Storage extends Service { bucket.metadata = resp; callback!(null, bucket, resp); - } + }, ); } createHmacKey( serviceAccountEmail: string, - options?: CreateHmacKeyOptions + options?: CreateHmacKeyOptions, ): Promise; createHmacKey( serviceAccountEmail: string, - callback: CreateHmacKeyCallback + callback: CreateHmacKeyCallback, ): void; createHmacKey( serviceAccountEmail: string, options: CreateHmacKeyOptions, - callback: CreateHmacKeyCallback + callback: CreateHmacKeyCallback, ): void; /** * @typedef {object} CreateHmacKeyOptions @@ -1189,7 +1189,7 @@ export class Storage extends Service { createHmacKey( serviceAccountEmail: string, optionsOrCb?: CreateHmacKeyOptions | CreateHmacKeyCallback, - cb?: CreateHmacKeyCallback + cb?: CreateHmacKeyCallback, ): Promise | void { if (typeof serviceAccountEmail !== 'string') { throw new Error(StorageExceptionMessages.HMAC_SERVICE_ACCOUNT); @@ -1223,7 +1223,7 @@ export class Storage extends Service { hmacKey.metadata = resp.metadata; callback!(null, hmacKey, resp.secret, resp); - } + }, ); } @@ -1319,11 +1319,11 @@ export class Storage extends Service { */ getBuckets( optionsOrCallback?: GetBucketsRequest | GetBucketsCallback, - cb?: GetBucketsCallback + cb?: GetBucketsCallback, ): void | Promise { const {options, callback} = normalize( optionsOrCallback, - cb + cb, ); options.project = options.project || this.projectId; @@ -1365,7 +1365,7 @@ export class Storage extends Service { : null; callback(null, buckets, nextQuery, resp); - } + }, ); } @@ -1457,7 +1457,7 @@ export class Storage extends Service { getHmacKeys(options: GetHmacKeysOptions, callback: GetHmacKeysCallback): void; getHmacKeys( optionsOrCb?: GetHmacKeysOptions | GetHmacKeysCallback, - cb?: GetHmacKeysCallback + cb?: GetHmacKeysCallback, ): Promise | void { const {options, callback} = normalize(optionsOrCb, cb); const query = Object.assign({}, options); @@ -1489,19 +1489,19 @@ export class Storage extends Service { : null; callback(null, hmacKeys, nextQuery, resp); - } + }, ); } getServiceAccount( - options?: GetServiceAccountOptions + options?: GetServiceAccountOptions, ): Promise; getServiceAccount( - options?: GetServiceAccountOptions + options?: GetServiceAccountOptions, ): Promise; getServiceAccount( options: GetServiceAccountOptions, - callback: GetServiceAccountCallback + callback: GetServiceAccountCallback, ): void; getServiceAccount(callback: GetServiceAccountCallback): void; /** @@ -1554,11 +1554,11 @@ export class Storage extends Service { */ getServiceAccount( optionsOrCallback?: GetServiceAccountOptions | GetServiceAccountCallback, - cb?: GetServiceAccountCallback + cb?: GetServiceAccountCallback, ): void | Promise { const {options, callback} = normalize( optionsOrCallback, - cb + cb, ); this.request( { @@ -1577,14 +1577,14 @@ export class Storage extends Service { // eslint-disable-next-line no-prototype-builtins if (resp.hasOwnProperty(prop)) { const camelCaseProp = prop.replace(/_(\w)/g, (_, match) => - match.toUpperCase() + match.toUpperCase(), ); camelCaseResponse[camelCaseProp] = resp[prop]; } } callback(null, camelCaseResponse, resp); - } + }, ); } diff --git a/handwritten/storage/src/transfer-manager.ts b/handwritten/storage/src/transfer-manager.ts index dd4e41eeb31..be34c76f08e 100644 --- a/handwritten/storage/src/transfer-manager.ts +++ b/handwritten/storage/src/transfer-manager.ts @@ -96,7 +96,7 @@ export interface UploadManyFilesOptions { concurrencyLimit?: number; customDestinationBuilder?( path: string, - options: UploadManyFilesOptions + options: UploadManyFilesOptions, ): string; skipIfExists?: boolean; prefix?: string; @@ -140,7 +140,7 @@ export interface MultiPartUploadHelper { uploadPart( partNumber: number, chunk: Buffer, - validation?: 'md5' | false + validation?: 'md5' | false, ): Promise; completeUpload(): Promise; abortUpload(): Promise; @@ -150,14 +150,14 @@ export type MultiPartHelperGenerator = ( bucket: Bucket, fileName: string, uploadId?: string, - partsMap?: Map + partsMap?: Map, ) => MultiPartUploadHelper; const defaultMultiPartGenerator: MultiPartHelperGenerator = ( bucket, fileName, uploadId, - partsMap + partsMap, ) => { return new XMLMultiPartUploadHelper(bucket, fileName, uploadId, partsMap); }; @@ -169,7 +169,7 @@ export class MultiPartUploadError extends Error { constructor( message: string, uploadId: string, - partsMap: Map + partsMap: Map, ) { super(message); this.uploadId = uploadId; @@ -198,7 +198,7 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper { bucket: Bucket, fileName: string, uploadId?: string, - partsMap?: Map + partsMap?: Map, ) { this.authClient = bucket.storage.authClient || new GoogleAuth(); this.uploadId = uploadId || ''; @@ -289,7 +289,7 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper { async uploadPart( partNumber: number, chunk: Buffer, - validation?: 'md5' | false + validation?: 'md5' | false, ): Promise { const url = `${this.baseUrl}?partNumber=${partNumber}&uploadId=${this.uploadId}`; let headers: Headers = this.#setGoogApiClientHeaders(); @@ -327,14 +327,14 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper { async completeUpload(): Promise { const url = `${this.baseUrl}?uploadId=${this.uploadId}`; const sortedMap = new Map( - [...this.partsMap.entries()].sort((a, b) => a[0] - b[0]) + [...this.partsMap.entries()].sort((a, b) => a[0] - b[0]), ); const parts: {}[] = []; for (const entry of sortedMap.entries()) { parts.push({PartNumber: entry[0], ETag: entry[1]}); } const body = `${this.xmlBuilder.build( - parts + parts, )}`; return AsyncRetry(async bail => { try { @@ -456,7 +456,7 @@ export class TransferManager { */ async uploadManyFiles( filePathsOrDirectory: string[] | string, - options: UploadManyFilesOptions = {} + options: UploadManyFilesOptions = {}, ): Promise { if (options.skipIfExists && options.passthroughOptions?.preconditionOpts) { options.passthroughOptions.preconditionOpts.ifGenerationMatch = 0; @@ -472,13 +472,13 @@ export class TransferManager { } const limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_UPLOAD_LIMIT + options.concurrencyLimit || DEFAULT_PARALLEL_UPLOAD_LIMIT, ); const promises: Promise[] = []; let allPaths: string[] = []; if (!Array.isArray(filePathsOrDirectory)) { for await (const curPath of this.getPathsFromDirectory( - filePathsOrDirectory + filePathsOrDirectory, )) { allPaths.push(curPath); } @@ -503,14 +503,14 @@ export class TransferManager { if (options.prefix) { passThroughOptionsCopy.destination = path.posix.join( ...options.prefix.split(path.sep), - passThroughOptionsCopy.destination + passThroughOptionsCopy.destination, ); } promises.push( limit(() => - this.bucket.upload(filePath, passThroughOptionsCopy as UploadOptions) - ) + this.bucket.upload(filePath, passThroughOptionsCopy as UploadOptions), + ), ); } @@ -565,10 +565,10 @@ export class TransferManager { */ async downloadManyFiles( filesOrFolder: File[] | string[] | string, - options: DownloadManyFilesOptions = {} + options: DownloadManyFilesOptions = {}, ): Promise { const limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_DOWNLOAD_LIMIT + options.concurrencyLimit || DEFAULT_PARALLEL_DOWNLOAD_LIMIT, ); const promises: Promise[] = []; let files: File[] = []; @@ -602,7 +602,7 @@ export class TransferManager { passThroughOptionsCopy.destination = path.join( options.prefix || '', passThroughOptionsCopy.destination || '', - file.name + file.name, ); } if (options.stripPrefix) { @@ -626,7 +626,7 @@ export class TransferManager { } return file.download(passThroughOptionsCopy); - }) + }), ); } @@ -668,12 +668,12 @@ export class TransferManager { */ async downloadFileInChunks( fileOrName: File | string, - options: DownloadFileInChunksOptions = {} + options: DownloadFileInChunksOptions = {}, ): Promise { let chunkSize = options.chunkSizeBytes || DOWNLOAD_IN_CHUNKS_DEFAULT_CHUNK_SIZE; let limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_DOWNLOAD_LIMIT + options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_DOWNLOAD_LIMIT, ); const noReturnData = Boolean(options.noReturnData); const promises: Promise[] = []; @@ -708,11 +708,11 @@ export class TransferManager { resp[0], 0, resp[0].length, - chunkStart + chunkStart, ); if (noReturnData) return; return result.buffer; - }) + }), ); start += chunkSize; @@ -729,7 +729,7 @@ export class TransferManager { const downloadedCrc32C = await CRC32C.fromFile(filePath); if (!downloadedCrc32C.validate(fileInfo[0].metadata.crc32c)) { const mismatchError = new RequestError( - FileExceptionMessages.DOWNLOAD_MISMATCH + FileExceptionMessages.DOWNLOAD_MISMATCH, ); mismatchError.code = 'CONTENT_DOWNLOAD_MISMATCH'; throw mismatchError; @@ -786,12 +786,12 @@ export class TransferManager { async uploadFileInChunks( filePath: string, options: UploadFileInChunksOptions = {}, - generator: MultiPartHelperGenerator = defaultMultiPartGenerator + generator: MultiPartHelperGenerator = defaultMultiPartGenerator, ): Promise { const chunkSize = options.chunkSizeBytes || UPLOAD_IN_CHUNKS_DEFAULT_CHUNK_SIZE; const limit = pLimit( - options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_UPLOAD_LIMIT + options.concurrencyLimit || DEFAULT_PARALLEL_CHUNKED_UPLOAD_LIMIT, ); const maxQueueSize = options.maxQueueSize || @@ -802,7 +802,7 @@ export class TransferManager { this.bucket, fileName, options.uploadId, - options.partsMap + options.partsMap, ); let partNumber = 1; let promises: Promise[] = []; @@ -824,8 +824,8 @@ export class TransferManager { } promises.push( limit(() => - mpuHelper.uploadPart(partNumber++, curChunk, options.validation) - ) + mpuHelper.uploadPart(partNumber++, curChunk, options.validation), + ), ); } await Promise.all(promises); @@ -842,20 +842,20 @@ export class TransferManager { throw new MultiPartUploadError( (e as Error).message, mpuHelper.uploadId!, - mpuHelper.partsMap! + mpuHelper.partsMap!, ); } } throw new MultiPartUploadError( (e as Error).message, mpuHelper.uploadId!, - mpuHelper.partsMap! + mpuHelper.partsMap!, ); } } private async *getPathsFromDirectory( - directory: string + directory: string, ): AsyncGenerator { const filesAndSubdirectories = await fsp.readdir(directory, { withFileTypes: true, diff --git a/handwritten/storage/src/util.ts b/handwritten/storage/src/util.ts index 259f7c0f3e8..4957a210b6c 100644 --- a/handwritten/storage/src/util.ts +++ b/handwritten/storage/src/util.ts @@ -26,7 +26,7 @@ const isEsm = true; export function normalize( optionsOrCallback?: T | U, - cb?: U + cb?: U, ) { const options = ( typeof optionsOrCallback === 'object' ? optionsOrCallback : {} @@ -58,7 +58,7 @@ export function objectEntries(obj: {[key: string]: T}): Array<[string, T]> { export function fixedEncodeURIComponent(str: string): string { return encodeURIComponent(str).replace( /[!'()*]/g, - c => '%' + c.charCodeAt(0).toString(16).toUpperCase() + c => '%' + c.charCodeAt(0).toString(16).toUpperCase(), ); } @@ -110,7 +110,7 @@ export function unicodeJSONStringify(obj: object) { return JSON.stringify(obj).replace( /[\u0080-\uFFFF]/g, (char: string) => - '\\u' + ('0000' + char.charCodeAt(0).toString(16)).slice(-4) + '\\u' + ('0000' + char.charCodeAt(0).toString(16)).slice(-4), ); } @@ -154,7 +154,7 @@ export function formatAsUTCISO( dateTimeToFormat: Date, includeTime = false, dateDelimiter = '', - timeDelimiter = '' + timeDelimiter = '', ): string { const year = dateTimeToFormat.getUTCFullYear(); const month = dateTimeToFormat.getUTCMonth() + 1; @@ -246,7 +246,7 @@ export class PassThroughShim extends PassThrough { _write( chunk: never, encoding: BufferEncoding, - callback: (error?: Error | null | undefined) => void + callback: (error?: Error | null | undefined) => void, ): void { if (this.shouldEmitWriting) { this.emit('writing'); diff --git a/handwritten/storage/system-test/common.ts b/handwritten/storage/system-test/common.ts index 17bc59b6142..b0364218b5a 100644 --- a/handwritten/storage/system-test/common.ts +++ b/handwritten/storage/system-test/common.ts @@ -52,7 +52,7 @@ describe('Common', () => { assert.ifError(err); assert.strictEqual(resp, mockResponse); mockServer.close(done); - } + }, ); }); @@ -80,7 +80,7 @@ describe('Common', () => { assert.strictEqual((err! as common.ApiError).code, 408); assert.strictEqual(numRequestAttempts, 4); mockServer.close(done); - } + }, ); }); @@ -108,7 +108,7 @@ describe('Common', () => { assert(err?.message.includes('ECONNREFUSED')); const timeResponse = Date.now(); assert(timeResponse - timeRequest > minExpectedResponseTime); - } + }, ); done(); }); diff --git a/handwritten/storage/system-test/kitchen.ts b/handwritten/storage/system-test/kitchen.ts index e63615f7ba8..fbfe9bd2eff 100644 --- a/handwritten/storage/system-test/kitchen.ts +++ b/handwritten/storage/system-test/kitchen.ts @@ -110,7 +110,7 @@ describe('resumable-upload', () => { file: filePath, retryOptions: retryOptions, metadata: {contentType: 'image/jpg'}, - }) + }), ) .on('error', done) .on('response', resp => { @@ -138,7 +138,7 @@ describe('resumable-upload', () => { type DoUploadCallback = (...args: any[]) => void; const doUpload = ( opts: {interrupt?: boolean}, - callback: DoUploadCallback + callback: DoUploadCallback, ) => { let sizeStreamed = 0; let destroyed = false; @@ -183,7 +183,7 @@ describe('resumable-upload', () => { assert.strictEqual(metadata.size, size); assert.strictEqual(typeof metadata.size, 'number'); done(); - } + }, ); }); }); @@ -223,7 +223,7 @@ describe('resumable-upload', () => { file: filePath, metadata, retryOptions: retryOptions, - }) + }), ) .on('error', (err: ErrorWithCode) => { assert.strictEqual(err.status, 400); @@ -244,8 +244,8 @@ describe('resumable-upload', () => { file.createWriteStream({ chunkSize, }), - e => (e ? reject(e) : resolve()) - ) + e => (e ? reject(e) : resolve()), + ), ); const [results] = await file.getMetadata(); @@ -291,7 +291,7 @@ describe('resumable-upload', () => { }); await new Promise((resolve, reject) => - pipeline(readable, writable, e => (e ? reject(e) : resolve())) + pipeline(readable, writable, e => (e ? reject(e) : resolve())), ); } @@ -302,7 +302,7 @@ describe('resumable-upload', () => { assert.equal( crc32cGenerated, count, - 'crc32c should be generated on each upload' + 'crc32c should be generated on each upload', ); assert.equal(results.size, FILE_SIZE); }); @@ -326,14 +326,14 @@ describe('resumable-upload', () => { crc32c: true, clientCrc32c: crc32c, retryOptions: retryOptions, - }) + }), ) .on('error', err => { console.log(err); done( new Error( - `Upload failed unexpectedly on success path: ${err.message}` - ) + `Upload failed unexpectedly on success path: ${err.message}`, + ), ); }) .on('response', resp => { @@ -357,12 +357,12 @@ describe('resumable-upload', () => { clientCrc32c: KNOWN_CRC32C_OF_ZEROS, crc32c: true, retryOptions: retryOptions, - }) + }), ) .on('error', (err: Error) => { assert.ok( err.message.includes(EXPECTED_ERROR_MESSAGE_PART), - `Expected error message part "${EXPECTED_ERROR_MESSAGE_PART}" not found in: ${err.message}` + `Expected error message part "${EXPECTED_ERROR_MESSAGE_PART}" not found in: ${err.message}`, ); done(); }); diff --git a/handwritten/storage/system-test/storage.ts b/handwritten/storage/system-test/storage.ts index 15257fb59db..2f14fe01296 100644 --- a/handwritten/storage/system-test/storage.ts +++ b/handwritten/storage/system-test/storage.ts @@ -92,20 +92,20 @@ describe('storage', function () { logo: { path: path.join( getDirName(), - '../../../system-test/data/CloudPlatform_128px_Retina.png' + '../../../system-test/data/CloudPlatform_128px_Retina.png', ), }, big: { path: path.join( getDirName(), - '../../../system-test/data/three-mb-file.tif' + '../../../system-test/data/three-mb-file.tif', ), hash: undefined, }, html: { path: path.join( getDirName(), - '../../../system-test/data/long-html-file.html' + '../../../system-test/data/long-html-file.html', ), }, empty: { @@ -205,7 +205,7 @@ describe('storage', function () { await assert.rejects( file.download(), (err: Error) => - err.message.indexOf('does not have storage.objects.get') > -1 + err.message.indexOf('does not have storage.objects.get') > -1, ); }); @@ -218,7 +218,7 @@ describe('storage', function () { /does not have storage\.objects\.create access/, ]; assert( - allowedErrorMessages.some(msg => msg.test((e as Error).message)) + allowedErrorMessages.some(msg => msg.test((e as Error).message)), ); } }); @@ -231,7 +231,7 @@ describe('storage', function () { // Introduce a delay between tests to avoid getting an error. beforeEach(async () => { await new Promise(resolve => - setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME) + setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME), ); }); @@ -270,7 +270,7 @@ describe('storage', function () { const [accessControlGet] = await bucket.acl.get(opts); assert.strictEqual( (accessControlGet as AccessControlObject).role, - storage.acl.OWNER_ROLE + storage.acl.OWNER_ROLE, ); await bucket.acl.delete(opts); }); @@ -302,7 +302,7 @@ describe('storage', function () { role: 'READER', }); await new Promise(resolve => - setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME) + setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME), ); await bucket.acl.delete({entity: 'allUsers'}); }); @@ -314,13 +314,13 @@ describe('storage', function () { */ it.skip('should make files public', async () => { await Promise.all( - ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)) + ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)), ); await bucket.makePublic({includeFiles: true}); const [files] = await bucket.getFiles(); const resps = await Promise.all( - files.map(file => isFilePublicAsync(file)) + files.map(file => isFilePublicAsync(file)), ); resps.forEach(resp => assert.strictEqual(resp, true)); await Promise.all([ @@ -338,7 +338,7 @@ describe('storage', function () { try { await bucket.makePublic(); await new Promise(resolve => - setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME) + setTimeout(resolve, BUCKET_METADATA_UPDATE_WAIT_TIME), ); await bucket.makePrivate(); assert.rejects(bucket.acl.get({entity: 'allUsers'}), err => { @@ -352,13 +352,13 @@ describe('storage', function () { it('should make files private', async () => { await Promise.all( - ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)) + ['a', 'b', 'c'].map(text => createFileWithContentPromise(text)), ); await bucket.makePrivate({includeFiles: true}); const [files] = await bucket.getFiles(); const resps = await Promise.all( - files.map(file => isFilePublicAsync(file)) + files.map(file => isFilePublicAsync(file)), ); resps.forEach(resp => { assert.strictEqual(resp, false); @@ -400,7 +400,7 @@ describe('storage', function () { const [accessControlGet] = await file.acl.get({entity: USER_ACCOUNT}); assert.strictEqual( (accessControlGet as AccessControlObject).role, - storage.acl.OWNER_ROLE + storage.acl.OWNER_ROLE, ); await file.acl.delete({entity: USER_ACCOUNT}); }); @@ -444,7 +444,7 @@ describe('storage', function () { assert.doesNotReject(file.makePrivate()); assert.rejects( file.acl.get({entity: 'allUsers'}), - validateMakeFilePrivateRejects + validateMakeFilePrivateRejects, ); }); @@ -517,11 +517,11 @@ describe('storage', function () { bucket.upload(FILES.big.path, { resumable: true, private: true, - }) + }), ); assert.rejects( file.acl.get({entity: 'allUsers'}), - validateMakeFilePrivateRejects + validateMakeFilePrivateRejects, ); }); }); @@ -574,7 +574,7 @@ describe('storage', function () { const legacyBucketReaderBinding = newPolicy!.bindings.filter( binding => { return binding.role === 'roles/storage.legacyBucketReader'; - } + }, )[0]; assert(legacyBucketReaderBinding.members.includes('allUsers')); }); @@ -641,7 +641,7 @@ describe('storage', function () { const setPublicAccessPrevention = ( bucket: Bucket, - configuration: string + configuration: string, ) => { return bucket.setMetadata({ iamConfiguration: { @@ -651,14 +651,14 @@ describe('storage', function () { }; const validateUnexpectedPublicAccessPreventionValueError = ( - err: ApiError + err: ApiError, ) => { assert.strictEqual(err.code, 400); return true; }; const validateConfiguringPublicAccessWhenPAPEnforcedError = ( - err: ApiError + err: ApiError, ) => { assert.strictEqual(err.code, 412); return true; @@ -669,14 +669,14 @@ describe('storage', function () { it('inserts a bucket with enforced public access prevention', async () => { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_ENFORCED + PUBLIC_ACCESS_PREVENTION_ENFORCED, ); const [bucketMetadata] = await bucket.getMetadata(); const publicAccessPreventionStatus = bucketMetadata!.iamConfiguration!.publicAccessPrevention; return assert.strictEqual( publicAccessPreventionStatus, - PUBLIC_ACCESS_PREVENTION_ENFORCED + PUBLIC_ACCESS_PREVENTION_ENFORCED, ); }); @@ -696,21 +696,21 @@ describe('storage', function () { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_ENFORCED + PUBLIC_ACCESS_PREVENTION_ENFORCED, ); }); it('bucket cannot be made public', async () => { return assert.rejects( () => bucket.makePublic(), - validateConfiguringPublicAccessWhenPAPEnforcedError + validateConfiguringPublicAccessWhenPAPEnforcedError, ); }); it('object cannot be made public via ACL', async () => { return assert.rejects( () => file.makePublic(), - validateConfiguringPublicAccessWhenPAPEnforcedError + validateConfiguringPublicAccessWhenPAPEnforcedError, ); }); }); @@ -718,21 +718,21 @@ describe('storage', function () { it('inserts a bucket with inherited public access prevention', async () => { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_INHERITED + PUBLIC_ACCESS_PREVENTION_INHERITED, ); const [bucketMetadata] = await bucket.getMetadata(); const publicAccessPreventionStatus = bucketMetadata!.iamConfiguration!.publicAccessPrevention; return assert.strictEqual( publicAccessPreventionStatus, - PUBLIC_ACCESS_PREVENTION_INHERITED + PUBLIC_ACCESS_PREVENTION_INHERITED, ); }); it('makes public a bucket with inherited public access prevention', async () => { await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_INHERITED + PUBLIC_ACCESS_PREVENTION_INHERITED, ); return assert.ok(() => bucket.makePublic()); }); @@ -740,7 +740,7 @@ describe('storage', function () { it('should fail to insert a bucket with unexpected public access prevention value', async () => { await assert.rejects( () => setPublicAccessPrevention(bucket, 'unexpected value'), - validateUnexpectedPublicAccessPreventionValueError + validateUnexpectedPublicAccessPreventionValueError, ); }); @@ -758,7 +758,7 @@ describe('storage', function () { const [updatedBucketMetadata] = await bucket.getMetadata(); return assert.strictEqual( updatedBucketMetadata!.iamConfiguration!.publicAccessPrevention, - publicAccessPreventionStatus + publicAccessPreventionStatus, ); }); @@ -775,13 +775,13 @@ describe('storage', function () { bucketMetadata!.iamConfiguration!.uniformBucketLevelAccess!.enabled; await setPublicAccessPrevention( bucket, - PUBLIC_ACCESS_PREVENTION_INHERITED + PUBLIC_ACCESS_PREVENTION_INHERITED, ); const [updatedBucketMetadata] = await bucket.getMetadata(); return assert.strictEqual( updatedBucketMetadata!.iamConfiguration!.uniformBucketLevelAccess! .enabled, - ublaSetting + ublaSetting, ); }); }); @@ -799,7 +799,7 @@ describe('storage', function () { const setTurboReplication = ( bucket: Bucket, - turboReplicationConfiguration: string + turboReplicationConfiguration: string, ) => { return bucket.setMetadata({ rpo: turboReplicationConfiguration, @@ -925,7 +925,7 @@ describe('storage', function () { assert(metadata[0].softDeletePolicy.effectiveTime); assert.deepStrictEqual( metadata[0].softDeletePolicy.retentionDurationSeconds, - SOFT_DELETE_RETENTION_SECONDS.toString() + SOFT_DELETE_RETENTION_SECONDS.toString(), ); }); @@ -954,7 +954,7 @@ describe('storage', function () { assert(softDeletedFile); assert.strictEqual( softDeletedFile.metadata.generation, - metadata.generation + metadata.generation, ); }); @@ -988,7 +988,7 @@ describe('storage', function () { assert.strictEqual(softDeletedFiles.length, 2); assert.notStrictEqual( softDeletedFiles![0].metadata.restoreToken, - undefined + undefined, ); }); @@ -1004,7 +1004,7 @@ describe('storage', function () { assert(softDeletedFile); assert.strictEqual( softDeletedFile.metadata.generation, - metadata.generation + metadata.generation, ); assert.notStrictEqual(softDeletedFile.metadata.restoreToken, undefined); }); @@ -1023,7 +1023,7 @@ describe('storage', function () { assert(softDeletedFile); const restoredFile = await f1.restore({ generation: parseInt( - softDeletedFile.metadata.generation?.toString() || '0' + softDeletedFile.metadata.generation?.toString() || '0', ), restoreToken: softDeletedFile.metadata.restoreToken, }); @@ -1129,7 +1129,7 @@ describe('storage', function () { await new Promise(res => setTimeout(res, UNIFORM_ACCESS_WAIT_TIME)); } catch (err) { assert( - validateUniformBucketLevelAccessEnabledError(err as ApiError) + validateUniformBucketLevelAccessEnabledError(err as ApiError), ); break; } @@ -1144,7 +1144,7 @@ describe('storage', function () { await new Promise(res => setTimeout(res, UNIFORM_ACCESS_WAIT_TIME)); } catch (err) { assert( - validateUniformBucketLevelAccessEnabledError(err as ApiError) + validateUniformBucketLevelAccessEnabledError(err as ApiError), ); break; } @@ -1261,7 +1261,7 @@ describe('storage', function () { after(async () => { await Promise.all( - bucketsToCreate.map(bucket => storage.bucket(bucket).delete()) + bucketsToCreate.map(bucket => storage.bucket(bucket).delete()), ); }); @@ -1404,7 +1404,7 @@ describe('storage', function () { const [metadata] = await bucket.getMetadata(); assert.deepStrictEqual( metadata.labels, - Object.assign({}, LABELS, newLabels) + Object.assign({}, LABELS, newLabels), ); }); @@ -1491,7 +1491,7 @@ describe('storage', function () { }); assert.strictEqual( bucket.metadata.lifecycle!.rule!.length, - numExistingRules + 2 + numExistingRules + 2, ); }); @@ -1512,8 +1512,8 @@ describe('storage', function () { rule.action.type === 'Delete' && typeof rule.condition.matchesPrefix === 'object' && (rule.condition.matchesPrefix as string[]).length === 1 && - Array.isArray(rule.condition.matchesPrefix) - ) + Array.isArray(rule.condition.matchesPrefix), + ), ); }); @@ -1532,8 +1532,8 @@ describe('storage', function () { (rule: LifecycleRule) => typeof rule.action === 'object' && rule.action.type === 'Delete' && - Array.isArray(rule.condition.matchesPrefix) - ) + Array.isArray(rule.condition.matchesPrefix), + ), ); }); @@ -1576,8 +1576,8 @@ describe('storage', function () { typeof rule.action === 'object' && rule.action.type === 'Delete' && rule.condition.noncurrentTimeBefore === NONCURRENT_TIME_BEFORE && - rule.condition.daysSinceNoncurrentTime === 100 - ) + rule.condition.daysSinceNoncurrentTime === 100, + ), ); }); @@ -1600,8 +1600,8 @@ describe('storage', function () { typeof rule.action === 'object' && rule.action.type === 'Delete' && rule.condition.customTimeBefore === CUSTOM_TIME_BEFORE && - rule.condition.daysSinceCustomTime === 100 - ) + rule.condition.daysSinceCustomTime === 100, + ), ); }); @@ -1701,7 +1701,7 @@ describe('storage', function () { await storage.createBucket(bucket.name); const [metadata] = await bucket.getMetadata(); assert( - [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled) + [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled), ); }); @@ -1711,7 +1711,7 @@ describe('storage', function () { }); const [metadata] = await bucket.getMetadata(); assert( - [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled) + [undefined, false].includes(metadata?.hierarchicalNamespace?.enabled), ); }); @@ -1742,7 +1742,7 @@ describe('storage', function () { await bucket.getMetadata(); assert.strictEqual( bucket.metadata!.retentionPolicy!.retentionPeriod, - `${RETENTION_DURATION_SECONDS}` + `${RETENTION_DURATION_SECONDS}`, ); }); @@ -1753,7 +1753,7 @@ describe('storage', function () { await bucket.getMetadata(); assert.strictEqual( bucket.metadata!.retentionPolicy!.retentionPeriod, - `${RETENTION_DURATION_SECONDS}` + `${RETENTION_DURATION_SECONDS}`, ); }); @@ -1768,7 +1768,7 @@ describe('storage', function () { bucket.setRetentionPeriod(RETENTION_DURATION_SECONDS / 2), (err: ApiError) => { return err.code === 403; - } + }, ); }); @@ -1779,7 +1779,7 @@ describe('storage', function () { await bucket.getMetadata(); assert.strictEqual( bucket.metadata!.retentionPolicy!.retentionPeriod, - `${RETENTION_DURATION_SECONDS}` + `${RETENTION_DURATION_SECONDS}`, ); await bucket.removeRetentionPeriod(); @@ -1853,12 +1853,12 @@ describe('storage', function () { after(async () => { await new Promise(resolve => - setTimeout(resolve, RETENTION_PERIOD_SECONDS * 1000) + setTimeout(resolve, RETENTION_PERIOD_SECONDS * 1000), ); await Promise.all( FILES.map(async file => { return file.delete(); - }) + }), ); }); @@ -1946,7 +1946,7 @@ describe('storage', function () { const file = new File(objectRetentionBucket, fileName); const [metadata] = await file.setMetadata( {retention: null}, - {overrideUnlockedRetention: true} + {overrideUnlockedRetention: true}, ); assert.strictEqual(metadata.retention, undefined); }); @@ -2047,7 +2047,7 @@ describe('storage', function () { // Get the service account for the "second" account (the // one that will read the requester pays file). const clientEmail = JSON.parse( - fs.readFileSync(key2!, 'utf-8') + fs.readFileSync(key2!, 'utf-8'), ).client_email; policy.bindings.push({ role: 'roles/storage.admin', @@ -2096,7 +2096,7 @@ describe('storage', function () { * @returns The result of the successful request pays operation. */ async function requesterPaysDoubleTest( - testFunction: F + testFunction: F, ): Promise> { const failureMessage = 'Bucket is a requester pays bucket but no user project provided.'; @@ -2106,7 +2106,7 @@ describe('storage', function () { (err as Error).message.includes(failureMessage), `Expected '${ (err as Error).message - }' to include '${failureMessage}'` + }' to include '${failureMessage}'`, ); return true; }); @@ -2129,14 +2129,14 @@ describe('storage', function () { await bucketNonAllowList.combine( sourceFiles, destinationFile, - USER_PROJECT_OPTIONS + USER_PROJECT_OPTIONS, ); // eslint-disable-next-line @typescript-eslint/no-explicit-any function createFileAsync(fileObject: any) { return fileObject.file.save( fileObject.contents, - USER_PROJECT_OPTIONS + USER_PROJECT_OPTIONS, ); } }); @@ -2189,7 +2189,7 @@ describe('storage', function () { await requesterPaysDoubleTest(async options => { return bucketNonAllowList.setStorageClass( 'multi-regional', - options + options, ); }); }); @@ -2403,7 +2403,7 @@ describe('storage', function () { .on('end', () => { file.hash = hash.digest('base64'); resolve(); - }) + }), ); } await Promise.all(Object.keys(FILES).map(key => setHash(key))); @@ -2469,7 +2469,7 @@ describe('storage', function () { }, }, }), - /Metadata part is too large/ + /Metadata part is too large/, ); }); @@ -2542,7 +2542,7 @@ describe('storage', function () { }); assert.strictEqual( String(fileContents).slice(0, 20), - String(remoteContents) + String(remoteContents), ); }); @@ -2613,7 +2613,7 @@ describe('storage', function () { .on('response', raw => { assert.strictEqual( raw.toJSON().headers['content-encoding'], - undefined + undefined, ); }) .pipe(fs.createWriteStream(tmpFilePath)) @@ -2766,8 +2766,8 @@ describe('storage', function () { [ 'The target object is encrypted by a', 'customer-supplied encryption key.', - ].join(' ') - ) > -1 + ].join(' '), + ) > -1, ); }); }); @@ -2874,7 +2874,7 @@ describe('storage', function () { const projectIdRegExp = /^.+\/locations/; const actualKmsKeyName = metadata!.kmsKeyName!.replace( projectIdRegExp, - '' + '', ); let expectedKmsKeyName = kmsKeyName.replace(projectIdRegExp, ''); @@ -2894,7 +2894,7 @@ describe('storage', function () { const projectIdRegExp = /^.+\/locations/; const actualKmsKeyName = metadata!.kmsKeyName!.replace( projectIdRegExp, - '' + '', ); let expectedKmsKeyName = kmsKeyName.replace(projectIdRegExp, ''); @@ -2934,7 +2934,7 @@ describe('storage', function () { beforeEach(async () => { await new Promise(res => - setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME) + setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME), ); await bucket.setMetadata({ encryption: { @@ -2945,7 +2945,7 @@ describe('storage', function () { afterEach(async () => { await new Promise(res => - setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME) + setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME), ); await bucket.setMetadata({ encryption: null, @@ -2960,7 +2960,7 @@ describe('storage', function () { const actualKmsKeyName = metadata!.encryption!.defaultKmsKeyName!.replace( projectIdRegExp, - '' + '', ); const expectedKmsKeyName = kmsKeyName.replace(projectIdRegExp, ''); assert.strictEqual(actualKmsKeyName, expectedKmsKeyName); @@ -2972,7 +2972,7 @@ describe('storage', function () { await createCryptoKeyAsync(cryptoKeyId); await new Promise(res => - setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME) + setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME), ); await bucket.setMetadata({ encryption: { @@ -2989,7 +2989,7 @@ describe('storage', function () { assert.strictEqual( fileMetadata.kmsKeyName, - `${metadata!.encryption!.defaultKmsKeyName}/cryptoKeyVersions/1` + `${metadata!.encryption!.defaultKmsKeyName}/cryptoKeyVersions/1`, ); }); }); @@ -3017,7 +3017,7 @@ describe('storage', function () { const [metadata] = await copiedFile.getMetadata(); assert.strictEqual( typeof metadata!.metadata!.originalProperty, - 'undefined' + 'undefined', ); assert.strictEqual(metadata!.metadata!.newProperty, 'true'); await Promise.all([file.delete, copiedFile.delete()]); @@ -3110,7 +3110,7 @@ describe('storage', function () { async function uploadAndVerify( file: File, - options: Omit + options: Omit, ) { await bucket.upload(filePath, { destination: file, @@ -3260,11 +3260,13 @@ describe('storage', function () { const [contents] = await destinationFile.download(); assert.strictEqual( contents.toString(), - files.map(x => x.contents).join('') + files.map(x => x.contents).join(''), ); await Promise.all( - sourceFiles.concat([destinationFile]).map(file => deleteFileAsync(file)) + sourceFiles + .concat([destinationFile]) + .map(file => deleteFileAsync(file)), ); }); }); @@ -3290,7 +3292,7 @@ describe('storage', function () { const ms = Math.pow(2, retries) * 1000 + Math.random() * 1000; return new Promise(done => { console.info( - `retrying "${test.title}" with accessId ${accessId} in ${ms}ms` + `retrying "${test.title}" with accessId ${accessId} in ${ms}ms`, ); setTimeout(done, ms); }); @@ -3332,7 +3334,7 @@ describe('storage', function () { assert(hmacKeys.length > 0); assert( hmacKeys.some(hmacKey => hmacKey.id === accessId), - 'created HMAC key not found from getHmacKeys result' + 'created HMAC key not found from getHmacKeys result', ); }); @@ -3361,7 +3363,7 @@ describe('storage', function () { assert(Array.isArray(hmacKeys)); assert( !hmacKeys.some(hmacKey => hmacKey.id === accessId), - 'deleted HMAC key is found from getHmacKeys result' + 'deleted HMAC key is found from getHmacKeys result', ); }); @@ -3396,16 +3398,17 @@ describe('storage', function () { const [hmacKeys] = await storage.getHmacKeys({projectId: HMAC_PROJECT}); assert( hmacKeys.some( - hmacKey => hmacKey.metadata!.serviceAccountEmail === SERVICE_ACCOUNT + hmacKey => + hmacKey.metadata!.serviceAccountEmail === SERVICE_ACCOUNT, ), - `Expected at least 1 key for service account: ${SERVICE_ACCOUNT}` + `Expected at least 1 key for service account: ${SERVICE_ACCOUNT}`, ); assert( hmacKeys.some( hmacKey => - hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT + hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT, ), - `Expected at least 1 key for service account: ${SECOND_SERVICE_ACCOUNT}` + `Expected at least 1 key for service account: ${SECOND_SERVICE_ACCOUNT}`, ); }); @@ -3417,9 +3420,9 @@ describe('storage', function () { assert( hmacKeys.every( hmacKey => - hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT + hmacKey.metadata!.serviceAccountEmail === SECOND_SERVICE_ACCOUNT, ), - 'HMAC key belonging to other service accounts unexpected' + 'HMAC key belonging to other service accounts unexpected', ); }); }); @@ -3480,7 +3483,7 @@ describe('storage', function () { assert.deepStrictEqual( (result as {prefixes: string[]}).prefixes, - expected + expected, ); }); @@ -3621,7 +3624,7 @@ describe('storage', function () { assert.strictEqual(files![0].name, files![1].name); assert.notStrictEqual( files![0].metadata.generation, - files![1].metadata.generation + files![1].metadata.generation, ); }); @@ -3637,7 +3640,7 @@ describe('storage', function () { assert.strictEqual(err.code, 412); assert.strictEqual(err.errors![0].reason, 'conditionNotMet'); return true; - } + }, ); await bucketWithVersioning .file(fileName) @@ -3698,7 +3701,7 @@ describe('storage', function () { await fetch(signedDeleteUrl, {method: 'DELETE'}); assert.rejects( () => file.getMetadata(), - (err: ApiError) => err.code === 404 + (err: ApiError) => err.code === 404, ); }); }); @@ -3772,10 +3775,10 @@ describe('storage', function () { assert(err instanceof Error); assert.strictEqual( err.message, - `Max allowed expiration is seven days (${SEVEN_DAYS_IN_SECONDS.toString()} seconds).` + `Max allowed expiration is seven days (${SEVEN_DAYS_IN_SECONDS.toString()} seconds).`, ); return true; - } + }, ); }); @@ -3958,7 +3961,7 @@ describe('storage', function () { topic.name, { eventTypes: ['OBJECT_FINALIZE'], - } + }, ); notification = createNotificationData[0]; subscription = topic.subscription(generateName()); @@ -4083,10 +4086,10 @@ describe('storage', function () { const TEST_UNIVERSE_DOMAIN = isNullOrUndefined('TEST_UNIVERSE_DOMAIN'); const TEST_PROJECT_ID = isNullOrUndefined('TEST_UNIVERSE_PROJECT_ID'); const TEST_UNIVERSE_LOCATION = isNullOrUndefined( - 'TEST_UNIVERSE_LOCATION' + 'TEST_UNIVERSE_LOCATION', ); const CREDENTIAL_PATH = isNullOrUndefined( - 'TEST_UNIVERSE_DOMAIN_CREDENTIAL' + 'TEST_UNIVERSE_DOMAIN_CREDENTIAL', ); // Create a client with universe domain credentials universeDomainStorage = new Storage({ @@ -4153,13 +4156,13 @@ describe('storage', function () { function deleteBucket( bucket: Bucket, options: {}, - callback: DeleteBucketCallback + callback: DeleteBucketCallback, ): void; function deleteBucket(bucket: Bucket, callback: DeleteBucketCallback): void; function deleteBucket( bucket: Bucket, optsOrCb: {} | DeleteBucketCallback, - callback?: DeleteBucketCallback + callback?: DeleteBucketCallback, ) { let options = typeof optsOrCb === 'object' ? optsOrCb : {}; callback = @@ -4209,10 +4212,10 @@ describe('storage', function () { const [buckets] = await storage.getBuckets({prefix: TESTS_PREFIX}); const limit = pLimit(10); await new Promise(resolve => - setTimeout(resolve, RETENTION_DURATION_SECONDS * 1000) + setTimeout(resolve, RETENTION_DURATION_SECONDS * 1000), ); return Promise.all( - buckets.map(bucket => limit(() => deleteBucketAsync(bucket))) + buckets.map(bucket => limit(() => deleteBucketAsync(bucket))), ); } @@ -4224,7 +4227,7 @@ describe('storage', function () { }); const limit = pLimit(10); return Promise.all( - filteredTopics.map(topic => limit(() => deleteTopicAsync(topic))) + filteredTopics.map(topic => limit(() => deleteTopicAsync(topic))), ); } @@ -4251,7 +4254,7 @@ describe('storage', function () { async function deleteStaleHmacKeys( serviceAccountEmail: string, - projectId: string + projectId: string, ) { const old = new Date(); old.setHours(old.getHours() - 1); @@ -4271,8 +4274,8 @@ describe('storage', function () { limit(async () => { await hmacKey.setMetadata({state: 'INACTIVE'}); await hmacKey.delete(); - }) - ) + }), + ), ); }