notion-2-blueskynotion.ts7 matches
1import type { NotionPost, NotionDatabaseResponse } from './types.ts';
23const NOTION_API_BASE = 'https://api.notion.com/v1';
5export class NotionClient {
6private token: string;
7private databaseId: string;
89constructor(token: string, databaseId: string) {
10this.token = token;
11this.databaseId = databaseId;
12}
1353};
5455const response: NotionDatabaseResponse = await this.makeRequest(
56`/databases/${this.databaseId}/query`,
57{
58method: 'POST',
87}
8889private parseNotionPage(page: NotionDatabaseResponse['results'][0]): NotionPost {
90const props = page.properties;
91
notion-2-blueskytypes.ts1 match
35}
3637export interface NotionDatabaseResponse {
38results: Array<{
39id: string;
notion-2-blueskydebug-env.ts4 matches
4export default async function(req: Request) {
5const blueskyHandle = Deno.env.get('BLUESKY_HANDLE');
6const notionDatabaseId = Deno.env.get('NOTION_DATABASE_ID');
7
8return new Response(JSON.stringify({
13cleaned: blueskyHandle ? blueskyHandle.replace(/[^\w.-]/g, '') : null
14},
15notionDatabaseId: {
16value: notionDatabaseId,
17length: notionDatabaseId?.length,
18}
19}, null, 2), {
notion-2-blueskytest.ts19 matches
84try {
85const notionToken = Deno.env.get('NOTION_TOKEN');
86const notionDatabaseId = Deno.env.get('NOTION_DATABASE_ID');
87const blueskyHandle = Deno.env.get('BLUESKY_HANDLE');
88const blueskyAppPassword = Deno.env.get('BLUESKY_APP_PASSWORD');
90const missing = [];
91if (!notionToken) missing.push('NOTION_TOKEN');
92if (!notionDatabaseId) missing.push('NOTION_DATABASE_ID');
93if (!blueskyHandle) missing.push('BLUESKY_HANDLE');
94if (!blueskyAppPassword) missing.push('BLUESKY_APP_PASSWORD');
108success: true,
109message: 'All required environment variables are set',
110details: `Handle: ${cleanHandle}\nDatabase ID: ${notionDatabaseId.substring(0, 8)}...`
111});
112}
122try {
123const notionToken = Deno.env.get('NOTION_TOKEN');
124const notionDatabaseId = Deno.env.get('NOTION_DATABASE_ID');
125
126if (notionToken && notionDatabaseId) {
127const notion = new NotionClient(notionToken, notionDatabaseId);
128const posts = await notion.getScheduledPosts();
129
131name: 'Notion Connection',
132success: true,
133message: `Successfully connected to Notion database`,
134details: `Found ${posts.length} scheduled posts ready to publish`
135});
140success: false,
141message: `Failed to connect to Notion: ${error.message}`,
142details: 'Check your NOTION_TOKEN and NOTION_DATABASE_ID. Make sure the integration has access to the database.'
143});
144}
171}
172173// Test 4: Database Schema Check
174try {
175const notionToken = Deno.env.get('NOTION_TOKEN');
176const notionDatabaseId = Deno.env.get('NOTION_DATABASE_ID');
177
178if (notionToken && notionDatabaseId) {
179const response = await fetch(`https://api.notion.com/v1/databases/${notionDatabaseId}`, {
180headers: {
181'Authorization': `Bearer ${notionToken}`,
185
186if (response.ok) {
187const database = await response.json();
188const properties = database.properties;
189
190const requiredFields = ['Title', 'Text', 'Scheduled Date', 'Status', 'URL'];
193if (missingFields.length > 0) {
194tests.push({
195name: 'Database Schema',
196success: false,
197message: `Missing required fields: ${missingFields.join(', ')}`,
200} else {
201tests.push({
202name: 'Database Schema',
203success: true,
204message: 'All required database fields are present',
205details: `Fields: ${Object.keys(properties).join(', ')}`
206});
212} catch (error) {
213tests.push({
214name: 'Database Schema',
215success: false,
216message: `Failed to check database schema: ${error.message}`,
217});
218}
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({
8description:
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.",
10parameters: z.object({
11thought: z.string().describe("A thought to think about."),
Towniesystem_prompt.txt2 matches
174```
175โโโ backend/
176โ โโโ database/
177โ โ โโโ migrations.ts # Schema definitions
178โ โ โโโ queries.ts # DB query functions
234```
235236### Database Patterns
237- Run migrations on startup or comment out for performance
238- Change table names when modifying schemas rather than altering
Towniesend-message.ts1 match
10overLimit,
11startTrackingUsage,
12} from "../database/queries.tsx";
13import { makeChangeValTypeTool, makeFetchTool, makeTextEditorTool } from "../tools/index.ts";
14import fileWithLinesNumbers from "../utils/fileWithLinesNumbers.ts";
Towniequeries.tsx1 match
4import { INFERENCE_CALLS_TABLE, USAGE_TABLE } from "./schema.tsx";
56// Eventually we'll have a user database,
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
Townie.cursorrules2 matches
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257```
258259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering