Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: google sheets #989

Merged
merged 2 commits into from
Jan 21, 2025
Merged
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
1 change: 1 addition & 0 deletions deco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const compatibilityApps = [{

const config = {
apps: [
app("google-sheets"),
app("posthog"),
app("decopilot-app"),
app("smarthint"),
Expand Down
1 change: 1 addition & 0 deletions decohub/apps/google-sheets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, preview } from "../../google-sheets/mod.ts";
94 changes: 48 additions & 46 deletions decohub/manifest.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@ import * as $$$$$$$$$$$4 from "./apps/blog.ts";
import * as $$$$$$$$$$$5 from "./apps/brand-assistant.ts";
import * as $$$$$$$$$$$6 from "./apps/crux.ts";
import * as $$$$$$$$$$$7 from "./apps/emailjs.ts";
import * as $$$$$$$$$$$8 from "./apps/htmx.ts";
import * as $$$$$$$$$$$9 from "./apps/implementation.ts";
import * as $$$$$$$$$$$10 from "./apps/konfidency.ts";
import * as $$$$$$$$$$$11 from "./apps/linx-impulse.ts";
import * as $$$$$$$$$$$12 from "./apps/linx.ts";
import * as $$$$$$$$$$$13 from "./apps/mailchimp.ts";
import * as $$$$$$$$$$$14 from "./apps/nuvemshop.ts";
import * as $$$$$$$$$$$15 from "./apps/posthog.ts";
import * as $$$$$$$$$$$16 from "./apps/power-reviews.ts";
import * as $$$$$$$$$$$17 from "./apps/ra-trustvox.ts";
import * as $$$$$$$$$$$18 from "./apps/resend.ts";
import * as $$$$$$$$$$$19 from "./apps/shopify.ts";
import * as $$$$$$$$$$$20 from "./apps/smarthint.ts";
import * as $$$$$$$$$$$21 from "./apps/sourei.ts";
import * as $$$$$$$$$$$22 from "./apps/streamshop.ts";
import * as $$$$$$$$$$$23 from "./apps/typesense.ts";
import * as $$$$$$$$$$$24 from "./apps/verified-reviews.ts";
import * as $$$$$$$$$$$25 from "./apps/vnda.ts";
import * as $$$$$$$$$$$26 from "./apps/vtex.ts";
import * as $$$$$$$$$$$27 from "./apps/wake.ts";
import * as $$$$$$$$$$$28 from "./apps/wap.ts";
import * as $$$$$$$$$$$29 from "./apps/weather.ts";
import * as $$$$$$$$$$$30 from "./apps/workflows.ts";
import * as $$$$$$$$$$$8 from "./apps/google-sheets.ts";
import * as $$$$$$$$$$$9 from "./apps/htmx.ts";
import * as $$$$$$$$$$$10 from "./apps/implementation.ts";
import * as $$$$$$$$$$$11 from "./apps/konfidency.ts";
import * as $$$$$$$$$$$12 from "./apps/linx-impulse.ts";
import * as $$$$$$$$$$$13 from "./apps/linx.ts";
import * as $$$$$$$$$$$14 from "./apps/mailchimp.ts";
import * as $$$$$$$$$$$15 from "./apps/nuvemshop.ts";
import * as $$$$$$$$$$$16 from "./apps/posthog.ts";
import * as $$$$$$$$$$$17 from "./apps/power-reviews.ts";
import * as $$$$$$$$$$$18 from "./apps/ra-trustvox.ts";
import * as $$$$$$$$$$$19 from "./apps/resend.ts";
import * as $$$$$$$$$$$20 from "./apps/shopify.ts";
import * as $$$$$$$$$$$21 from "./apps/smarthint.ts";
import * as $$$$$$$$$$$22 from "./apps/sourei.ts";
import * as $$$$$$$$$$$23 from "./apps/streamshop.ts";
import * as $$$$$$$$$$$24 from "./apps/typesense.ts";
import * as $$$$$$$$$$$25 from "./apps/verified-reviews.ts";
import * as $$$$$$$$$$$26 from "./apps/vnda.ts";
import * as $$$$$$$$$$$27 from "./apps/vtex.ts";
import * as $$$$$$$$$$$28 from "./apps/wake.ts";
import * as $$$$$$$$$$$29 from "./apps/wap.ts";
import * as $$$$$$$$$$$30 from "./apps/weather.ts";
import * as $$$$$$$$$$$31 from "./apps/workflows.ts";

const manifest = {
"apps": {
Expand All @@ -44,29 +45,30 @@ const manifest = {
"decohub/apps/brand-assistant.ts": $$$$$$$$$$$5,
"decohub/apps/crux.ts": $$$$$$$$$$$6,
"decohub/apps/emailjs.ts": $$$$$$$$$$$7,
"decohub/apps/htmx.ts": $$$$$$$$$$$8,
"decohub/apps/implementation.ts": $$$$$$$$$$$9,
"decohub/apps/konfidency.ts": $$$$$$$$$$$10,
"decohub/apps/linx-impulse.ts": $$$$$$$$$$$11,
"decohub/apps/linx.ts": $$$$$$$$$$$12,
"decohub/apps/mailchimp.ts": $$$$$$$$$$$13,
"decohub/apps/nuvemshop.ts": $$$$$$$$$$$14,
"decohub/apps/posthog.ts": $$$$$$$$$$$15,
"decohub/apps/power-reviews.ts": $$$$$$$$$$$16,
"decohub/apps/ra-trustvox.ts": $$$$$$$$$$$17,
"decohub/apps/resend.ts": $$$$$$$$$$$18,
"decohub/apps/shopify.ts": $$$$$$$$$$$19,
"decohub/apps/smarthint.ts": $$$$$$$$$$$20,
"decohub/apps/sourei.ts": $$$$$$$$$$$21,
"decohub/apps/streamshop.ts": $$$$$$$$$$$22,
"decohub/apps/typesense.ts": $$$$$$$$$$$23,
"decohub/apps/verified-reviews.ts": $$$$$$$$$$$24,
"decohub/apps/vnda.ts": $$$$$$$$$$$25,
"decohub/apps/vtex.ts": $$$$$$$$$$$26,
"decohub/apps/wake.ts": $$$$$$$$$$$27,
"decohub/apps/wap.ts": $$$$$$$$$$$28,
"decohub/apps/weather.ts": $$$$$$$$$$$29,
"decohub/apps/workflows.ts": $$$$$$$$$$$30,
"decohub/apps/google-sheets.ts": $$$$$$$$$$$8,
"decohub/apps/htmx.ts": $$$$$$$$$$$9,
"decohub/apps/implementation.ts": $$$$$$$$$$$10,
"decohub/apps/konfidency.ts": $$$$$$$$$$$11,
"decohub/apps/linx-impulse.ts": $$$$$$$$$$$12,
"decohub/apps/linx.ts": $$$$$$$$$$$13,
"decohub/apps/mailchimp.ts": $$$$$$$$$$$14,
"decohub/apps/nuvemshop.ts": $$$$$$$$$$$15,
"decohub/apps/posthog.ts": $$$$$$$$$$$16,
"decohub/apps/power-reviews.ts": $$$$$$$$$$$17,
"decohub/apps/ra-trustvox.ts": $$$$$$$$$$$18,
"decohub/apps/resend.ts": $$$$$$$$$$$19,
"decohub/apps/shopify.ts": $$$$$$$$$$$20,
"decohub/apps/smarthint.ts": $$$$$$$$$$$21,
"decohub/apps/sourei.ts": $$$$$$$$$$$22,
"decohub/apps/streamshop.ts": $$$$$$$$$$$23,
"decohub/apps/typesense.ts": $$$$$$$$$$$24,
"decohub/apps/verified-reviews.ts": $$$$$$$$$$$25,
"decohub/apps/vnda.ts": $$$$$$$$$$$26,
"decohub/apps/vtex.ts": $$$$$$$$$$$27,
"decohub/apps/wake.ts": $$$$$$$$$$$28,
"decohub/apps/wap.ts": $$$$$$$$$$$29,
"decohub/apps/weather.ts": $$$$$$$$$$$30,
"decohub/apps/workflows.ts": $$$$$$$$$$$31,
},
"name": "decohub",
"baseUrl": import.meta.url,
Expand Down
5 changes: 5 additions & 0 deletions google-sheets/loaders/doc.ts
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;
}
Binary file added google-sheets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions google-sheets/manifest.gen.ts
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;
67 changes: 67 additions & 0 deletions google-sheets/mod.ts
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: [],
},
};
};
Loading