Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cleanup)!: Remove redundant callback types, move storage.ts to … #2445

Closed
wants to merge 10 commits into from
19 changes: 8 additions & 11 deletions conformance-test/conformanceCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import {Bucket, File, HmacKey, Notification, Storage} from '../src/';
import * as uuid from 'uuid';
import * as assert from 'assert';
import {DecorateRequestOptions} from '../src/nodejs-common';
import fetch from 'node-fetch';
import { GaxiosOptions } from 'gaxios';

Check failure on line 22 in conformance-test/conformanceCommon.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·GaxiosOptions·` with `GaxiosOptions`

interface RetryCase {
instructions: String[];
Expand Down Expand Up @@ -122,17 +122,14 @@
notification = bucket.notification(`${TESTS_PREFIX}`);
await notification.create();

[hmacKey] = await storage.createHmacKey(
`${TESTS_PREFIX}@email.com`
);
hmacKey = await storage.createHmacKey(`${TESTS_PREFIX}@email.com`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im guessing we can remove this once #2461 is complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a conformance test, it already runs against test bench. The change here is that it no longer returns an array, only a single element.


storage.interceptors.push({
request: requestConfig => {
requestConfig.headers = requestConfig.headers || {};
Object.assign(requestConfig.headers, {
'x-retry-test-id': creationResult.id,
});
return requestConfig as DecorateRequestOptions;
storage.interceptors.add({
resolved(config: GaxiosOptions) {
const headers = config.headers || {};
headers['x-retry-test-id'] = creationResult.id;
config.headers = headers;
return Promise.resolve(config);
},
});
});
Expand Down
11 changes: 5 additions & 6 deletions conformance-test/libraryMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import {Bucket, File, Notification, Storage, HmacKey, Policy} from '../src';
import * as path from 'path';
import {ApiError} from '../src/nodejs-common';
import {
createTestBuffer,
createTestFileFromBuffer,
Expand Down Expand Up @@ -119,7 +118,7 @@ export async function combine(options: ConformanceTestOptions) {
}

export async function create(options: ConformanceTestOptions) {
const [bucketExists] = await options.bucket!.exists();
const bucketExists = await options.bucket!.exists();
if (bucketExists) {
await options.bucket!.deleteFiles();
await options.bucket!.delete({
Expand Down Expand Up @@ -227,7 +226,7 @@ export async function getFilesStream(options: ConformanceTestOptions) {
.bucket!.getFilesStream()
.on('data', () => {})
.on('end', () => resolve(undefined))
.on('error', (err: ApiError) => reject(err));
.on('error', err => reject(err));
});
}

Expand Down Expand Up @@ -496,7 +495,7 @@ export async function createReadStream(options: ConformanceTestOptions) {
.file!.createReadStream()
.on('data', () => {})
.on('end', () => resolve(undefined))
.on('error', (err: ApiError) => reject(err));
.on('error', err => reject(err));
});
}

Expand Down Expand Up @@ -755,7 +754,7 @@ export async function iamSetPolicy(options: ConformanceTestOptions) {
};
if (options.preconditionRequired) {
const currentPolicy = await options.bucket!.iam.getPolicy();
testPolicy.etag = currentPolicy[0].etag;
testPolicy.etag = currentPolicy.etag;
}
await options.bucket!.iam.setPolicy(testPolicy);
}
Expand Down Expand Up @@ -795,7 +794,7 @@ export async function notificationGetMetadata(options: ConformanceTestOptions) {

export async function createBucket(options: ConformanceTestOptions) {
const bucket = options.storage!.bucket('test-creating-bucket');
const [exists] = await bucket.exists();
const exists = await bucket.exists();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the change here? previously we were returning an array, and now its an object?
It would be helpful to start a README doc with a list of "breaking" changes so that we make sure we cover everything

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or update PR description with a checklist of # of changes that need to happen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were returning arrays for no reason all over the place. I'm trying to bring responses much more in line with the standard JSON API responses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of breaking changes is going to be too big for comments / PR commit messsages. I have created an issue in buganizer to create a migration guide.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing out some random ideas here... It seems like migrating for returning an array vs object is the big breaking change here. Is there anyway to have some kind of flag for customers who want to keep the current behavior? We can eventually deprecate the flag but it would give customers some more time to keep the current behavior while we modernize the library

if (exists) {
bucket.delete();
}
Expand Down
2 changes: 1 addition & 1 deletion internal-tooling/performanceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export async function performanceTestSetup(
ifGenerationMatch: 0,
},
});
if (!(await bucket.exists())[0]) {
if (!(await bucket.exists())) {
await bucket.create();
}
const transferManager = new TransferManager(bucket);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"async-retry": "^1.3.3",
"duplexify": "^4.1.3",
"fast-xml-parser": "^4.3.0",
"gaxios": "^6.0.2",
"gaxios": "^6.6.0",
"google-auth-library": "^9.6.3",
"html-entities": "^2.5.2",
"mime": "^3.0.0",
Expand Down
Loading
Loading