Skip to content

Commit

Permalink
feat!: better typing for metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 committed Jun 29, 2023
1 parent 37ce0a6 commit 3d90b3d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"duplexify": "^4.0.0",
"ent": "^2.2.0",
"extend": "^3.0.2",
"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
39 changes: 26 additions & 13 deletions src/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {
BodyResponseCallback,
DecorateRequestOptions,
Metadata,
} from './nodejs-common';
import {BodyResponseCallback, DecorateRequestOptions} from './nodejs-common';
import {promisifyAll} from '@google-cloud/promisify';

export interface AclOptions {
Expand All @@ -29,13 +25,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 +46,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 +61,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 +90,23 @@ export interface AccessControlObject {
projectTeam: string;
}

export interface AclMetadata {
bucket?: string;
domain?: string;
entity?: string;
entityId?: string;
etag?: string;
id?: string;
kind?: string;
projectTeam?: {
projectNumber?: string;
team?: 'editors' | 'owners' | 'viewers';
};
role?: 'OWNER' | 'READER' | 'WRITER';
selfLink?: string;
[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

0 comments on commit 3d90b3d

Please sign in to comment.