33
34 <div class="form-group">
35 <label for="notion-database-id">Database ID</label>
36 <input type="text" id="notion-database-id" placeholder="Enter Notion database ID">
37 <small>The ID of the database containing your variables.</small>
38 </div>
39
8 */
9export async function syncVariablesFromNotion(
10 databaseId: string,
11 apiKey: string,
12 mappingConfig?: MappingConfig
13): Promise<VariableData[]> {
14 // Validate inputs
15 if (!databaseId) throw new Error('Notion database ID is required');
16 if (!apiKey) throw new Error('Notion API key is required');
17
18 try {
19 // Query the Notion database
20 const data = await queryNotionDatabase(databaseId, apiKey);
21
22 // Use default mapping if not provided
32
33/**
34 * Query a Notion database
35 */
36async function queryNotionDatabase(databaseId: string, apiKey: string) {
37 const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
38 method: 'POST',
39 headers: {
41export interface NotionConfig {
42 apiKey: string;
43 databaseId: string;
44 mappingConfig: MappingConfig;
45}
57 mappingConfig: MappingConfig;
58 // Notion specific
59 databaseId?: string;
60 // Coda specific
61 docId?: string;
31 try {
32 figma.notify('Syncing variables from Notion...');
33 const variables = await syncVariablesFromNotion(msg.databaseId, msg.apiKey);
34 await applyVariablesToFigma(variables, msg.mappingConfig);
35 figma.notify('Variables synced successfully!');
38 await figma.clientStorage.setAsync(StorageKeys.CONFIG, {
39 source: 'notion',
40 databaseId: msg.databaseId,
41 mappingConfig: msg.mappingConfig,
42 lastSync: new Date().toISOString()
9- [ ] make it one click to branch off like old jp townie demos
10- [ ] opentownie as a pr bot
11- [ ] give it the ability to see its own client-side and server-side logs by building a middleware that shoves them into a SQL light database date and then give it a tool to access them
12- [ ] do a browser use or screenshot thing to give it access to its own visual output
13- [ ] Have it default to creating a new branch off main
7export const thinkTool = tool({
8 description:
9 "Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.",
10 parameters: z.object({
11 thought: z.string().describe("A thought to think about."),
192```
193โโโ backend/
194โ โโโ database/
195โ โ โโโ migrations.ts # Schema definitions
196โ โ โโโ queries.ts # DB query functions
252 ```
253
254### Database Patterns
255- Run migrations on startup or comment out for performance
256- Change table names when modifying schemas rather than altering
10 overLimit,
11 startTrackingUsage,
12} from "../database/queries.tsx";
13import {
14 getTextEditorTool,
4import { INFERENCE_CALLS_TABLE, USAGE_TABLE } from "./schema.tsx";
5
6// Eventually we'll have a user database,
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering