Skip to content

Commit

Permalink
feat!: Make node 14 the minimum supported version (#2244)
Browse files Browse the repository at this point in the history
* refactor!: Remove `extend` and Treat Provided Options as Mutable (#2204)

* refactor: Remove `extend`

This is the prelimary, `src`-only commit.

* fix: object merging

* chore: remove log

* chore: minor clean-up

* chore: more clean-up

* refactor: remove `extend`

* perf!: treat provided options as mutable

* feat!: stronger typing for lifecycle rules (#2215)

* fix!: Do not return responsebody in delete, only raw response (#2236)

* fix!: Remove extraneous validation in favor of server errors (#2237)

* fix!: Remove extraneous validation in favor of server errors

* remove test

* refactor!: mark bucket.setLabels and associated interfaces as deprecated (#2214)

* refactor!: mark bucket.setLabels and associated interfaces as deprecated

* update addBucketLabel to use setMetadata

* mark getLabels / deleteLabels deprecated, update samples

* feat!: disable source maps for smaller bundle size (#2240)

* feat!: better typing for metadata (#2234)

* test: cleanup kms tests to avoid setting incorrect keys (#2213)

* chore(deps): update dependency c8 to v8 (#2221)

* feat!: better typing for metadata

* more metadata typing

* fix merge problems

* remove extend

* fix merge conflicts

---------

Co-authored-by: Mend Renovate <[email protected]>

* chore!: make node 14 the minimum version (#2230)

* chore!: make node 14 the minimum version

* move conformance test to node 14

* package upgrades, fix unit test compilation

* update google owned deps

* fix tests

* remove node 12 kokoro folders

* merge and fix issues

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* export new metadata types from index

* fix samples tests

* fix system test

---------

Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Mend Renovate <[email protected]>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 3, 2023
1 parent 1756827 commit f48dcd2
Show file tree
Hide file tree
Showing 49 changed files with 1,138 additions and 1,198 deletions.
2 changes: 1 addition & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ branchProtectionRules:
- "ci/kokoro: System test"
- docs
- lint
- test (12)
- test (14)
- test (16)
- test (18)
- cla/google
- windows
- OwlBot Post Processor
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14, 16, 18]
node: [14, 16, 18, 20]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 14
- run: node --version
- run: npm install
- run: npm run conformance-test
24 changes: 0 additions & 24 deletions .kokoro/continuous/node12/common.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions .kokoro/continuous/node12/lint.cfg

This file was deleted.

12 changes: 0 additions & 12 deletions .kokoro/continuous/node12/samples-test.cfg

This file was deleted.

12 changes: 0 additions & 12 deletions .kokoro/continuous/node12/system-test.cfg

This file was deleted.

Empty file removed .kokoro/continuous/node12/test.cfg
Empty file.
24 changes: 0 additions & 24 deletions .kokoro/presubmit/node12/common.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions .kokoro/presubmit/node12/conformance-test.cfg

This file was deleted.

12 changes: 0 additions & 12 deletions .kokoro/presubmit/node12/samples-test.cfg

This file was deleted.

12 changes: 0 additions & 12 deletions .kokoro/presubmit/node12/system-test.cfg

This file was deleted.

Empty file removed .kokoro/presubmit/node12/test.cfg
Empty file.
18 changes: 13 additions & 5 deletions conformance-test/libraryMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export async function addLifecycleRuleInstancePrecondition(
options: ConformanceTestOptions
) {
await options.bucket!.addLifecycleRule({
action: 'delete',
action: {
type: 'Delete',
},
condition: {
age: 365 * 3, // Specified in days.
},
Expand All @@ -53,7 +55,9 @@ export async function addLifecycleRule(options: ConformanceTestOptions) {
if (options.preconditionRequired) {
await options.bucket!.addLifecycleRule(
{
action: 'delete',
action: {
type: 'Delete',
},
condition: {
age: 365 * 3, // Specified in days.
},
Expand All @@ -64,7 +68,9 @@ export async function addLifecycleRule(options: ConformanceTestOptions) {
);
} else {
await options.bucket!.addLifecycleRule({
action: 'delete',
action: {
type: 'Delete',
},
condition: {
age: 365 * 3, // Specified in days.
},
Expand Down Expand Up @@ -104,7 +110,7 @@ export async function combine(options: ConformanceTestOptions) {
await allFiles.save('allfiles contents');
if (options.preconditionRequired) {
await options.bucket!.combine(sources, allFiles, {
ifGenerationMatch: allFiles.metadata.generation,
ifGenerationMatch: allFiles.metadata.generation!,
});
} else {
await options.bucket!.combine(sources, allFiles);
Expand Down Expand Up @@ -468,7 +474,9 @@ export async function copy(options: ConformanceTestOptions) {

if (options.preconditionRequired) {
await options.file!.copy('a-different-file.png', {
preconditionOpts: {ifGenerationMatch: newFile.metadata.generation},
preconditionOpts: {
ifGenerationMatch: newFile.metadata.generation!,
},
});
} else {
await options.file!.copy('a-different-file.png');
Expand Down
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
"node": ">=12"
"node": ">=14"
},
"repository": "googleapis/nodejs-storage",
"main": "./build/src/index.js",
Expand Down Expand Up @@ -58,15 +58,14 @@
"compressible": "^2.0.12",
"duplexify": "^4.0.0",
"ent": "^2.2.0",
"extend": "^3.0.2",
"fast-xml-parser": "^4.2.2",
"gaxios": "^5.0.0",
"google-auth-library": "^8.0.1",
"gaxios": "^6.0.2",
"google-auth-library": "^9.0.0",
"mime": "^3.0.0",
"mime-types": "^2.0.8",
"p-limit": "^3.0.1",
"retry-request": "^5.0.0",
"teeny-request": "^8.0.0",
"retry-request": "^6.0.0",
"teeny-request": "^9.0.0",
"uuid": "^8.0.0"
},
"devDependencies": {
Expand All @@ -76,22 +75,21 @@
"@types/async-retry": "^1.4.3",
"@types/compressible": "^2.0.0",
"@types/ent": "^2.2.1",
"@types/extend": "^3.0.0",
"@types/mime": "^3.0.0",
"@types/mime-types": "^2.1.0",
"@types/mocha": "^9.1.1",
"@types/mockery": "^1.4.29",
"@types/node": "^18.0.0",
"@types/node": "^20.4.4",
"@types/node-fetch": "^2.1.3",
"@types/proxyquire": "^1.3.28",
"@types/request": "^2.48.4",
"@types/sinon": "^10.0.0",
"@types/sinon": "^10.0.15",
"@types/tmp": "0.2.3",
"@types/uuid": "^8.0.0",
"@types/yargs": "^17.0.10",
"c8": "^8.0.0",
"form-data": "^4.0.0",
"gts": "^3.1.0",
"gts": "^3.1.1",
"jsdoc": "^4.0.0",
"jsdoc-fresh": "^2.0.0",
"jsdoc-region-tag": "^2.0.0",
Expand All @@ -101,9 +99,9 @@
"nock": "~13.3.0",
"node-fetch": "^2.6.7",
"proxyquire": "^2.1.3",
"sinon": "^15.0.0",
"sinon": "^15.2.0",
"tmp": "^0.2.0",
"typescript": "^4.6.4",
"typescript": "^5.1.6",
"yargs": "^17.3.1"
}
}
2 changes: 1 addition & 1 deletion samples/addBucketLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function main(
};

async function addBucketLabel() {
await storage.bucket(bucketName).setLabels(labels);
await storage.bucket(bucketName).setMetadata({labels});
console.log(`Added label to bucket ${bucketName}`);
}

Expand Down
4 changes: 3 additions & 1 deletion samples/enableBucketLifecycleManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ function main(bucketName = 'my-bucket') {

async function enableBucketLifecycleManagement() {
const [metadata] = await storage.bucket(bucketName).addLifecycleRule({
action: 'delete',
action: {
type: 'Delete',
},
condition: {age: 100},
});

Expand Down
7 changes: 5 additions & 2 deletions samples/removeBucketLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// description: Removes bucket label.
// usage: node removeBucketLabel.js <BUCKET_NAME> labelone)

function main(bucketName = 'my-bucket', labelKey = ['label1', 'label2']) {
function main(bucketName = 'my-bucket', labelKey = 'labelone') {
// [START storage_remove_bucket_label]
/**
* TODO(developer): Uncomment the following lines before running the sample.
Expand All @@ -37,7 +37,10 @@ function main(bucketName = 'my-bucket', labelKey = ['label1', 'label2']) {
const storage = new Storage();

async function removeBucketLabel() {
await storage.bucket(bucketName).deleteLabels(labelKey);
const labels = {};
// To remove a label set the value of the key to null.
labels[labelKey] = null;
await storage.bucket(bucketName).setMetadata({labels});
console.log(`Removed labels from bucket ${bucketName}`);
}

Expand Down
2 changes: 1 addition & 1 deletion samples/system-test/bucketLifecycle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Bucket lifecycle management', () => {
it('should disable all lifecycle rules', async () => {
// Add a lifecycle rule in order for the sample to delete.
await bucket.addLifecycleRule({
action: 'delete',
action: {type: 'Delete'},
condition: {age: 100},
});

Expand Down
33 changes: 24 additions & 9 deletions src/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import {
BodyResponseCallback,
DecorateRequestOptions,
Metadata,
BaseMetadata,
} from './nodejs-common';
import {promisifyAll} from '@google-cloud/promisify';

Expand All @@ -29,13 +29,13 @@ export interface AclOptions {

export type GetAclResponse = [
AccessControlObject | AccessControlObject[],
Metadata
AclMetadata
];
export interface GetAclCallback {
(
err: Error | null,
acl?: AccessControlObject | AccessControlObject[] | null,
apiResponse?: Metadata
apiResponse?: AclMetadata
): void;
}
export interface GetAclOptions {
Expand All @@ -50,12 +50,12 @@ export interface UpdateAclOptions {
generation?: number;
userProject?: string;
}
export type UpdateAclResponse = [AccessControlObject, Metadata];
export type UpdateAclResponse = [AccessControlObject, AclMetadata];
export interface UpdateAclCallback {
(
err: Error | null,
acl?: AccessControlObject | null,
apiResponse?: Metadata
apiResponse?: AclMetadata
): void;
}

Expand All @@ -65,17 +65,17 @@ export interface AddAclOptions {
generation?: number;
userProject?: string;
}
export type AddAclResponse = [AccessControlObject, Metadata];
export type AddAclResponse = [AccessControlObject, AclMetadata];
export interface AddAclCallback {
(
err: Error | null,
acl?: AccessControlObject | null,
apiResponse?: Metadata
apiResponse?: AclMetadata
): void;
}
export type RemoveAclResponse = [Metadata];
export type RemoveAclResponse = [AclMetadata];
export interface RemoveAclCallback {
(err: Error | null, apiResponse?: Metadata): void;
(err: Error | null, apiResponse?: AclMetadata): void;
}
export interface RemoveAclOptions {
entity: string;
Expand All @@ -94,6 +94,21 @@ export interface AccessControlObject {
projectTeam: string;
}

export interface AclMetadata extends BaseMetadata {
bucket?: string;
domain?: string;
entity?: string;
entityId?: string;
generation?: string;
object?: string;
projectTeam?: {
projectNumber?: string;
team?: 'editors' | 'owners' | 'viewers';
};
role?: 'OWNER' | 'READER' | 'WRITER' | 'FULL_CONTROL';
[key: string]: unknown;
}

/**
* Attach functionality to a {@link Storage.acl} instance. This will add an
* object for each role group (owners, readers, and writers), with each object
Expand Down
Loading

0 comments on commit f48dcd2

Please sign in to comment.