-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
184 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@midday/sdk", | ||
"description": "Midday SDK", | ||
"version": "0.0.0-beta.1", | ||
"private": false, | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/midday-ai/midday" | ||
}, | ||
"homepage": "https://midday.ai", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"files": ["dist"], | ||
"scripts": { | ||
"dev": "tsup tsup src/index.ts --format cjs,esm --dts --watch", | ||
"build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts", | ||
"npm:publish": "npm run build && npm publish", | ||
"lint": "biome check .", | ||
"check:types": "tsc --noEmit" | ||
}, | ||
"devDependencies": { | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.6.3" | ||
}, | ||
"dependencies": { | ||
"@supabase/supabase-js": "^2.46.1" | ||
} | ||
} |
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,61 @@ | ||
import type { Database } from "@midday/supabase/types"; | ||
import { type SupabaseClient, createClient } from "@supabase/supabase-js"; | ||
import { | ||
Inbox, | ||
Invoices, | ||
Metrics, | ||
Settings, | ||
Tracker, | ||
Transactions, | ||
Vault, | ||
} from "./resource"; | ||
import type { SDKOptions } from "./types"; | ||
|
||
const API_ENDPOINT = "https://api.midday.ai/v1"; | ||
|
||
export class Midday { | ||
#options: SDKOptions; | ||
#client: SupabaseClient<Database>; | ||
|
||
public transactions: Transactions; | ||
public invoices: Invoices; | ||
public tracker: Tracker; | ||
public inbox: Inbox; | ||
public vault: Vault; | ||
public metrics: Metrics; | ||
public settings: Settings; | ||
|
||
constructor(options: SDKOptions) { | ||
this.#options = { | ||
...options, | ||
apiKey: options.apiKey || process.env.MIDDAY_API_KEY || "", | ||
}; | ||
|
||
if (!this.#options.apiKey) { | ||
throw new Error( | ||
"You need to provide an API key, either via the constructor or the MIDDAY_API_KEY environment variable: https://docs.midday.ai/sdk", | ||
); | ||
} | ||
|
||
this.#client = createClient(API_ENDPOINT, undefined, { | ||
global: { | ||
headers: { | ||
Authorization: `Bearer ${this.#options.apiKey}`, | ||
}, | ||
}, | ||
auth: { | ||
persistSession: false, | ||
detectSessionInUrl: false, | ||
autoRefreshToken: false, | ||
}, | ||
}); | ||
|
||
this.transactions = new Transactions(this.#client); | ||
this.invoices = new Invoices(this.#client); | ||
this.tracker = new Tracker(this.#client); | ||
this.inbox = new Inbox(this.#client); | ||
this.vault = new Vault(this.#client); | ||
this.metrics = new Metrics(this.#client); | ||
this.settings = new Settings(this.#client); | ||
} | ||
} |
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,6 @@ | ||
export class Inbox { | ||
async list(): Promise<string[]> { | ||
// Replace with API call logic | ||
return ["Inbox 1", "Inbox 2"]; | ||
} | ||
} |
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,8 @@ | ||
export * from "./invoices"; | ||
export * from "./transactions"; | ||
export * from "./tracker"; | ||
export * from "./inbox"; | ||
export * from "./vault"; | ||
export * from "./metrics"; | ||
export * from "./settings"; | ||
export * from "./team2"; |
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,6 @@ | ||
export class Invoices { | ||
async list(): Promise<string[]> { | ||
// Replace with API call logic | ||
return ["Invoice 1", "Invoice 2"]; | ||
} | ||
} |
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,26 @@ | ||
export class Metrics { | ||
async burnRate(): Promise<number> { | ||
// Replace with API call logic | ||
return 0.5; | ||
} | ||
|
||
async runway(): Promise<number> { | ||
// Replace with API call logic | ||
return 1000; | ||
} | ||
|
||
async revenue(): Promise<number> { | ||
// Replace with API call logic | ||
return 1000; | ||
} | ||
|
||
async expenses(): Promise<number> { | ||
// Replace with API call logic | ||
return 500; | ||
} | ||
|
||
async profit(): Promise<number> { | ||
// Replace with API call logic | ||
return 500; | ||
} | ||
} |
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,6 @@ | ||
export class Settings { | ||
async list(): Promise<string[]> { | ||
// Replace with API call logic | ||
return ["Setting 1", "Setting 2"]; | ||
} | ||
} |
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,11 @@ | ||
export class Tracker { | ||
async list(): Promise<string[]> { | ||
// Replace with API call logic | ||
return ["Transaction 1", "Transaction 2"]; | ||
} | ||
|
||
async updateById(id: string, data: any): Promise<string> { | ||
// Replace with API call logic | ||
return `Transaction ${id} updated`; | ||
} | ||
} |
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,11 @@ | ||
export class Transactions { | ||
async list(): Promise<string[]> { | ||
// Replace with API call logic | ||
return ["Transaction 1", "Transaction 2"]; | ||
} | ||
|
||
async updateById(id: string, data: any): Promise<string> { | ||
// Replace with API call logic | ||
return `Transaction ${id} updated`; | ||
} | ||
} |
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,6 @@ | ||
export class Vault { | ||
async list(): Promise<string[]> { | ||
// Replace with API call logic | ||
return ["File 1", "File 2"]; | ||
} | ||
} |
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,3 @@ | ||
export type SDKOptions = { | ||
apiKey: string; | ||
}; |
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,8 @@ | ||
{ | ||
"extends": "@midday/tsconfig/base.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["dist", "node_modules"] | ||
} |