Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion src/Drive/driveOps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
/** @module */
/**
* @file Handles talking to the Google Spreadsheet API
* @file Handles talking to the Google Drive API
* ## Links to Google Drive documentation
* [mime-types](https://developers.google.com/drive/api/v3/mime-types)
* [all file meta data](https://developers.google.com/drive/api/v3/reference/files)
Expand All @@ -14,6 +14,7 @@
*/
const ds = require('./driveService')
const logger = require('../utils/logger')
const { drive } = require('googleapis/build/src/apis/drive')
const MAX_FILES_PER_PAGE = 1000

let _driveService
Expand Down Expand Up @@ -51,6 +52,24 @@ const autoInit = () => {
_driveService = ds.init()
}

const createSpreadsheet= async (sheetNameAndFolderId) =>{
const {name, folderId} = sheetNameAndFolderId
const fileMetaData = {
name,
parents: folderId
}

const media = {
mimeType: mimeType.getType(mimeType.SPREADSHEET)
}
const createData= {
resource: fileMetaData,
media,
fields: `id`,
}

return await _driveService.files.create(createData)
}
/**
* @typedef {object} WithNameExactMatch
* @property {string} withName
Expand Down
4 changes: 2 additions & 2 deletions src/Drive/driveOps.test.int.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ const {driveOps} = gsweet
before(() => {logger.level = 'info'})
after(() => {logger.level = 'debug'})

describe('INTEGRATION TEST driveOps module', function () {
describe.only('INTEGRATION TEST driveOps module', function () {
this.timeout(20000)
const {mimeType} = driveOps
const FOLDER_TYPE = mimeType.getType(mimeType.FOLDER)
const SPREADSHEET_TYPE = mimeType.getType(mimeType.SPREADSHEET)

it('fileList() should return MAX_FILES_PER_QUERY files', async () => {
it.only('fileList() should return MAX_FILES_PER_QUERY files', async () => {
const fileList = await driveOps.listFiles()
fileList.length.should.equal(MAX_FILES_PER_QUERY)
})
Expand Down
8 changes: 5 additions & 3 deletions src/Sheets/sheetOps.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ const getSheetValues = async sheetRange => {
})
return result.data.values
} catch (err) {
const msg = `${err.response.data.error.message}`
const msg = `gsweet ${err.response.data.error.message}`

logger.error(msg)
throw msg
throw new Error (msg)
}
}

Expand Down Expand Up @@ -178,7 +179,7 @@ const getSheetTitle = async sheetId => {
* Get the grid properties which is an object with a rowCount and columnCount
* property.
* @param {SheetIndexName} sheetInfo
* @returns {Promise<gridProperties>}
* @returns {Promise<Pro>}
*/
const getSheetGridProperties = async sheetInfo => {
const {sheetId} = sheetInfo
Expand Down Expand Up @@ -325,6 +326,7 @@ const copySheetByNameFromTo = async({fromSpreadsheetId, fromSheetName, toSpread
}



/**
* @typedef CopySheetResult
* @property {boolean} success
Expand Down
3 changes: 1 addition & 2 deletions src/Sheets/sheetOps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ describe('sheetOps module', () => {
sheetOps.init(throwSheetService)
await sheetOps.getSheetValues(sheetRange)
.catch(err => {
console.log(err)
err.should.contain('test throw')
err.message.should.contain('test throw')
})
})
})
Expand Down
1 change: 0 additions & 1 deletion src/googleAuthHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const init = () => {
initialized = true
} catch (error) {
console.log('problem parsing environment variable gsweet')
console.log(process.env.GSWEET)
}
}

Expand Down