Skip to content

Commit

Permalink
update: release v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
POPPIN-FUMI committed Nov 22, 2023
1 parent 7ad1509 commit 8328657
Show file tree
Hide file tree
Showing 26 changed files with 2,679 additions and 3 deletions.
900 changes: 900 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { addDataToSheet } from './lib/addDataToSheet';
export { getDataFromSheet } from './lib/getDataFromSheet';
export type * from './spreadsheetTypes';
41 changes: 41 additions & 0 deletions dist/src/lib/addDataToSheet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { AppendDataResponse } from '@/spreadsheetTypes';
/**
* Adds specified data to a Google Spreadsheet.
* Requires the ID of the spreadsheet and the name of the sheet where data will be added.
* The function assumes that the
* 'GOOGLE_APPLICATION_CREDENTIALS' environment variable is set with the path
* to the Google service account credentials JSON file. It returns the data
* from the spreadsheet.
*
* @param {string} spreadsheetId - The ID of the spreadsheet to which data is being added.
* @param {string} sheetTitle - The name of the sheet where data will be added.
* @param {Array<Array<string | number>>} values - Array of data to be added to the spreadsheet. Each sub-array corresponds to a row in the spreadsheet.
* @returns {Promise<AppendDataResponse>} - A promise containing the response from the Google Sheets API.
* @throws {Error} - Throws an error if there's an issue with the request to the Google Sheets API.
*
* @example
* ```
* // Spreadsheet ID and sheet name
* const spreadsheetId = 'your-spreadsheet-id';
* const sheetTitle = 'your-sheet-name';
*
* // Data to be added
* const data = [
* ['Header1', 'Header2', 'Header3'],
* ['Value1', 'Value2', 'Value3']
* ];
*
* // Asynchronously call the function
* const run = async () => {
* try {
* const response = await addDataToSheet(spreadsheetId, sheetTitle, data);
* console.log('Added data:', response);
* } catch (error) {
* console.error('Error:', error);
* }
* };
*
* run();
* ```
*/
export declare function addDataToSheet(spreadsheetId: string, sheetTitle: string, values: Array<Array<string | number>>): Promise<AppendDataResponse>;
33 changes: 33 additions & 0 deletions dist/src/lib/createNewSheet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { CreateNewSheetResponse } from '@/spreadsheetTypes';
/**
* Creates a new sheet within an existing Google Sheets spreadsheet.
*
* This function uses the Google Sheets API to create a new sheet within a
* specified spreadsheet. It requires the spreadsheet ID where the new sheet
* will be added and the title for the new sheet. The function assumes that the
* 'GOOGLE_APPLICATION_CREDENTIALS' environment variable is set with the path
* to the Google service account credentials JSON file.
*
* Set up the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable:
* export GOOGLE_APPLICATION_CREDENTIALS=path_to_your_credentials.json
*
* @param {string} spreadsheetId - The ID of the Google Sheets spreadsheet where the new sheet will be added.
* @param {string} sheetTitle - The title for the new sheet.
* @returns {Promise<any>} - A promise that resolves with the response from the Google Sheets API after the new sheet is created.
* @throws {Error} - Throws an error if there is an issue with creating the new sheet.
*
* @example
* ```
* const spreadsheetId = 'your_spreadsheet_id_here';
* const sheetTitle = 'New Sheet Title';
* (async () => {
* try {
* const response = await createNewSheet(spreadsheetId, sheetTitle);
* console.log('New Sheet Created:', response);
* } catch (error) {
* console.error(error);
* }
* })();
* ```
*/
export declare function createNewSheet(spreadsheetId: string, sheetTitle: string): Promise<CreateNewSheetResponse>;
36 changes: 36 additions & 0 deletions dist/src/lib/getDataFromSheet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { SpreadsheetData } from '@/spreadsheetTypes';
/**
* Retrieves data from a specified Google Sheets spreadsheet and range.
*
* This function uses the Google Sheets API to fetch data from a specified
* spreadsheet.
* It requires the spreadsheet ID and the name of the spreadsheet
* range to retrieve the data from.
* The function assumes that the
* 'GOOGLE_APPLICATION_CREDENTIALS' environment variable is set with the path
* to the Google service account credentials JSON file. It returns the data
* from the spreadsheet.
*
* Set up the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable:
* export GOOGLE_APPLICATION_CREDENTIALS=path_to_your_credentials.json
*
* @param {string} spreadsheetId - The ID of the Google Sheets spreadsheet.
* @param {string} range - The name of the range in the spreadsheet to retrieve data from.
* @returns {Promise<Array<Array<string | number>>>} - A promise that resolves with the data from the spreadsheet as an array of arrays, each representing a row of data.
* @throws {Error} - Throws an error if there is an issue with fetching data from the spreadsheet.
*
* @example
* ```
* const spreadsheetId = 'your_spreadsheet_id_here';
* const range = 'Sheet1!A1:D5';
* (async () => {
* try {
* const data = await getDataFromSheet(spreadsheetId, range);
* console.log(data);
* } catch (error) {
* console.error(error);
* }
* })();
* ```
*/
export declare function getDataFromSheet(spreadsheetId: string, range: string): Promise<SpreadsheetData>;
1 change: 1 addition & 0 deletions dist/src/lib/version.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const VERSION = "0.1.1";
33 changes: 33 additions & 0 deletions dist/src/spreadsheetTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export type AppendDataResponse = {
spreadsheetId: string;
tableRange: string;
updates: {
spreadsheetId: string;
updatedRange: string;
updatedRows: number;
updatedColumns: number;
updatedCells: number;
};
};
export type SpreadsheetRow = Array<string | number>;
export type SpreadsheetData = Array<SpreadsheetRow>;
export type GridProperties = {
rowCount: number;
columnCount: number;
};
export type SheetProperties = {
sheetId: number;
title: string;
index: number;
sheetType: string;
gridProperties: GridProperties;
};
export type AddSheetResponse = {
properties: SheetProperties;
};
export type CreateNewSheetResponse = {
spreadsheetId: string;
replies: Array<{
addSheet: AddSheetResponse;
}>;
};
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
85 changes: 85 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
:root {
--light-hl-0: #795E26;
--dark-hl-0: #DCDCAA;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #A31515;
--dark-hl-2: #CE9178;
--light-hl-3: #0000FF;
--dark-hl-3: #569CD6;
--light-hl-4: #AF00DB;
--dark-hl-4: #C586C0;
--light-hl-5: #001080;
--dark-hl-5: #9CDCFE;
--light-hl-6: #0070C1;
--dark-hl-6: #4FC1FF;
--light-hl-7: #098658;
--dark-hl-7: #B5CEA8;
--light-hl-8: #008000;
--dark-hl-8: #6A9955;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
pre, code { background: var(--code-background); }
59 changes: 59 additions & 0 deletions docs/assets/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/navigation.js

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

1 change: 1 addition & 0 deletions docs/assets/search.js

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

Loading

0 comments on commit 8328657

Please sign in to comment.