Skip to content

Commit

Permalink
Fixed typing for Drive v2
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Dec 18, 2024
1 parent ca068cf commit 4529a4a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __tests__/test-utils/gas-stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function mockedCommentsCollection(): GoogleAppsScript.Drive.Collection.Co
};
}

export function mockedDrive(): GoogleAppsScript.Drive {
export function mockedDrive(): GoogleAppsScript.Drive_v2 {
return {
newChannel: jest.fn<() => GoogleAppsScript.Drive.Schema.Channel>(),
newChildReference:
Expand Down
5 changes: 3 additions & 2 deletions src/backend/utils/SafeDriveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export class SafeDriveService_ {
public readonly Replies: GoogleAppsScript.Drive.Collection.RepliesCollection;

public constructor() {
if (Drive.Replies === undefined) {
if ((Drive as unknown as GoogleAppsScript.Drive_v2).Replies === undefined) {
throw new Error();
}
this.Comments = new SafeCommentsCollection_();
this.Drives = new SafeDrivesCollection_();
this.Files = new SafeFilesCollection_();
this.Replies = Drive.Replies;
this.Replies =
Drive.Replies as unknown as GoogleAppsScript.Drive.Collection.RepliesCollection;
}
}
7 changes: 5 additions & 2 deletions src/backend/utils/SafeDriveService/SafeCommentsCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ export class SafeCommentsCollection_ {
private readonly unsafeComments: GoogleAppsScript.Drive.Collection.CommentsCollection;

public constructor() {
if (Drive.Comments === undefined) {
if (
(Drive as unknown as GoogleAppsScript.Drive_v2).Comments === undefined
) {
throw new Error();
}
this.unsafeComments = Drive.Comments;
this.unsafeComments =
Drive.Comments as unknown as GoogleAppsScript.Drive.Collection.CommentsCollection;
}

private static commentIsSafe(
Expand Down
5 changes: 3 additions & 2 deletions src/backend/utils/SafeDriveService/SafeDrivesCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ export class SafeDrivesCollection_ {
private readonly unsafeDrives: GoogleAppsScript.Drive.Collection.DrivesCollection;

public constructor() {
if (Drive.Drives === undefined) {
if ((Drive as unknown as GoogleAppsScript.Drive_v2).Drives === undefined) {
throw new Error();
}
this.unsafeDrives = Drive.Drives;
this.unsafeDrives =
Drive.Drives as unknown as GoogleAppsScript.Drive.Collection.DrivesCollection;
}

private static driveIsSafe<F extends DeepKeyof<SafeDrive>>(
Expand Down
5 changes: 3 additions & 2 deletions src/backend/utils/SafeDriveService/SafeFilesCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export class SafeFilesCollection_ {
private readonly unsafeFiles: GoogleAppsScript.Drive.Collection.FilesCollection;

public constructor() {
if (Drive.Files === undefined) {
if ((Drive as unknown as GoogleAppsScript.Drive_v2).Files === undefined) {
throw new Error();
}
this.unsafeFiles = Drive.Files;
this.unsafeFiles =
Drive.Files as unknown as GoogleAppsScript.Drive.Collection.FilesCollection;
}

private static fileIsSafe<F extends DeepKeyof<SafeFile>>(
Expand Down

0 comments on commit 4529a4a

Please sign in to comment.