Skip to content

Commit

Permalink
feat!: better typing for metadata (#2234)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
ddelgrosso1 and renovate-bot authored Jul 24, 2023
1 parent e24b099 commit ee8354e
Show file tree
Hide file tree
Showing 23 changed files with 818 additions and 676 deletions.
6 changes: 4 additions & 2 deletions conformance-test/libraryMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,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 @@ -474,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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"compressible": "^2.0.12",
"duplexify": "^4.0.0",
"ent": "^2.2.0",
"gaxios": "^5.0.0",
"gaxios": "^5.1.2",
"google-auth-library": "^8.0.1",
"mime": "^3.0.0",
"mime-types": "^2.0.8",
Expand Down Expand Up @@ -86,7 +86,7 @@
"@types/tmp": "0.2.3",
"@types/uuid": "^8.0.0",
"@types/yargs": "^17.0.10",
"c8": "^7.0.0",
"c8": "^8.0.0",
"form-data": "^4.0.0",
"gts": "^3.1.0",
"jsdoc": "^4.0.0",
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 ee8354e

Please sign in to comment.