-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:deco-cx/apps into feat-blog-like
- Loading branch information
Showing
21 changed files
with
1,905 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, preview } from "../../google-sheets/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,5 @@ | |
"jsx": "react-jsx", | ||
"jsxImportSource": "preact" | ||
}, | ||
"version": "0.64.16" | ||
"version": "0.64.21" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AppContext } from "../mod.ts"; | ||
|
||
export default function doc(_: null, __: Request, ctx: AppContext) { | ||
return ctx.doc; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// DO NOT EDIT. This file is generated by deco. | ||
// This file SHOULD be checked into source version control. | ||
// This file is automatically updated during development when running `dev.ts`. | ||
|
||
import * as $$$0 from "./loaders/doc.ts"; | ||
|
||
const manifest = { | ||
"loaders": { | ||
"google-sheets/loaders/doc.ts": $$$0, | ||
}, | ||
"name": "google-sheets", | ||
"baseUrl": import.meta.url, | ||
}; | ||
|
||
export type Manifest = typeof manifest; | ||
|
||
export default manifest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import type { App, FnContext } from "@deco/deco"; | ||
import { PreviewContainer } from "../utils/preview.tsx"; | ||
import type { Secret } from "../website/loaders/secret.ts"; | ||
import manifest, { Manifest } from "./manifest.gen.ts"; | ||
import { GoogleSpreadsheet } from "npm:google-spreadsheet@^4.1.4"; | ||
import { JWT } from "npm:google-auth-library@^9.14.1"; | ||
|
||
export type AppContext = FnContext<State, Manifest>; | ||
|
||
export interface Props { | ||
client_email: string; | ||
private_key: Secret; | ||
sheet_id: string; | ||
scopes: string[]; | ||
} | ||
|
||
// Here we define the state of the app | ||
// You choose what to put in the state | ||
export interface State extends Omit<Props, "token"> { | ||
doc: GoogleSpreadsheet; | ||
} | ||
|
||
/** | ||
* @title Google Sheets | ||
* @description This is an app that enables a google spreadsheet integration. | ||
* @category Tool | ||
* @logo https://raw.githubusercontent.com/deco-cx/apps/main/google-sheets/logo.png | ||
*/ | ||
export default function GoogleSheet(props: Props): App<Manifest, State> { | ||
const SCOPES = props.scopes; | ||
|
||
const jwt = new JWT({ | ||
email: props.client_email, | ||
key: props.private_key?.get() || "", | ||
scopes: SCOPES, | ||
}); | ||
|
||
const doc = new GoogleSpreadsheet( | ||
props.sheet_id, | ||
jwt, | ||
); | ||
|
||
return { | ||
state: { | ||
...props, | ||
doc, | ||
}, | ||
manifest, | ||
}; | ||
} | ||
|
||
// It is important to use the same name as the default export of the app | ||
export const preview = () => { | ||
return { | ||
Component: PreviewContainer, | ||
props: { | ||
name: "Google Sheets", | ||
owner: "deco.cx", | ||
description: | ||
"This is an app that enables a google spreadsheet integration.", | ||
logo: | ||
"https://raw.githubusercontent.com/deco-cx/apps/main/google-sheets/logo.png", | ||
images: [], | ||
tabs: [], | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.