├── backend ├── .gitignore ├── src │ ├── service │ │ ├── index.ts │ │ └── aiQuery.ts │ ├── index.ts │ └── public │ │ └── README.md ├── package.json ├── tsconfig.json └── README.md ├── .prettierrc ├── tsconfig.json ├── frontend ├── src │ ├── types.ts │ ├── components │ │ ├── LoadingIndicator.tsx │ │ ├── LoadingIndicator.css │ │ ├── TripList.tsx │ │ ├── AddTripForm.css │ │ ├── AskAI.tsx │ │ ├── AskAI.css │ │ ├── AddTripForm.tsx │ │ ├── Trip.tsx │ │ └── Trip.css │ ├── App.css │ ├── vite-env.d.ts │ ├── index.css │ ├── main.tsx │ └── App.tsx ├── vite.config.ts ├── tsconfig.node.json ├── .gitignore ├── index.html ├── .eslintrc.cjs ├── tsconfig.json ├── package.json ├── public │ └── squid.svg ├── README.md └── package-lock.json ├── .gitignore ├── package.json ├── LICENSE └── README.md /backend/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | node_modules 3 | dist -------------------------------------------------------------------------------- /backend/src/service/index.ts: -------------------------------------------------------------------------------- 1 | export * from './aiQuery'; 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./backend" }, 5 | { "path": "./frontend" } 6 | ] 7 | } -------------------------------------------------------------------------------- /frontend/src/types.ts: -------------------------------------------------------------------------------- 1 | export type Trip = { 2 | startDate: Date 3 | endDate: Date 4 | country: string; 5 | notes: string[]; 6 | id: string 7 | } -------------------------------------------------------------------------------- /frontend/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /frontend/src/components/LoadingIndicator.tsx: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import "./LoadingIndicator.css" 3 | 4 | function LoadingIndicator() { 5 | return
6 | } 7 | 8 | export default LoadingIndicator -------------------------------------------------------------------------------- /frontend/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .card { 2 | margin: 20px 20px 20px 20px; 3 | border: 1px solid #ccc; 4 | border-radius: 10px; 5 | padding: 30px; 6 | box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 7 | background-color: #f9f9f9; 8 | } 9 | 10 | .internal-card { 11 | width: 100%; 12 | margin-bottom: 20px; 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? -------------------------------------------------------------------------------- /frontend/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | interface ImportMetaEnv { 4 | readonly VITE_SQUID_APP_ID: string; 5 | readonly VITE_SQUID_REGION: SquidRegion; 6 | readonly VITE_SQUID_ENVIRONMENT_ID: EnvironmentId; 7 | readonly VITE_SQUID_DEVELOPER_ID: string; 8 | } 9 | 10 | interface ImportMeta { 11 | readonly env: ImportMetaEnv; 12 | } 13 | -------------------------------------------------------------------------------- /frontend/src/components/LoadingIndicator.css: -------------------------------------------------------------------------------- 1 | .loading-indicator { 2 | display: inline-block; 3 | width: 24px; 4 | height: 24px; 5 | border: 3px solid rgba(0, 0, 0, 0.1); 6 | border-radius: 50%; 7 | border-top-color: #007bff; 8 | animation: spin 1s ease-in-out infinite; 9 | } 10 | 11 | @keyframes spin { 12 | to { 13 | transform: rotate(360deg); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontend/src/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 3 | line-height: 1.5; 4 | font-weight: 400; 5 | 6 | color-scheme: light dark; 7 | color: rgba(255, 255, 255, 0.87); 8 | background-color: #242424; 9 | 10 | font-synthesis: none; 11 | text-rendering: optimizeLegibility; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | -------------------------------------------------------------------------------- /frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Squid Starter App 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /backend/src/index.ts: -------------------------------------------------------------------------------- 1 | import { SquidProject } from '@squidcloud/backend'; 2 | 3 | /***************************** 4 | * * 5 | * INTERNAL USE ONLY * 6 | * DO NOT MODIFY * 7 | * * 8 | *****************************/ 9 | 10 | /** Export all the Squid services */ 11 | export * from './service'; 12 | 13 | class ExportedSquidProject extends SquidProject {} 14 | 15 | export default new ExportedSquidProject(); 16 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "squid build", 8 | "start": "squid start", 9 | "deploy": "squid deploy" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "@squidcloud/backend": "^1.0.261" 15 | }, 16 | "devDependencies": { 17 | "@squidcloud/cli": "^1.0.261", 18 | "typescript": "^5.1.6" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "scripts": { 6 | "start": "samples start", 7 | "build": "npm run build --workspaces", 8 | "format": "prettier . --write" 9 | }, 10 | "devDependencies": { 11 | "@squidcloud/samples": "^1.0.12", 12 | "prettier": "^3.2.5" 13 | }, 14 | "workspaces": [ 15 | "frontend", 16 | "backend" 17 | ], 18 | "dependencies": { 19 | "date-fns": "^3.6.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /frontend/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | ], 9 | ignorePatterns: ['dist', '.eslintrc.cjs'], 10 | parser: '@typescript-eslint/parser', 11 | plugins: ['react-refresh'], 12 | rules: { 13 | 'react-refresh/only-export-components': [ 14 | 'warn', 15 | { allowConstantExport: true }, 16 | ], 17 | }, 18 | } 19 | -------------------------------------------------------------------------------- /frontend/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import App from './App.tsx'; 4 | import { SquidContextProvider } from '@squidcloud/react'; 5 | import './index.css'; 6 | 7 | ReactDOM.createRoot(document.getElementById('root')!).render( 8 | 16 | 17 | , 18 | ); 19 | -------------------------------------------------------------------------------- /frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /backend/src/service/aiQuery.ts: -------------------------------------------------------------------------------- 1 | import { SquidService, secureDatabase, executable } from '@squidcloud/backend'; 2 | 3 | export class ExampleService extends SquidService { 4 | @secureDatabase('all', 'built_in_db') 5 | allowAccessToBuiltInDb(): boolean { 6 | return true; 7 | } 8 | 9 | @executable() 10 | async askQuestion(question: string): Promise { 11 | const aiResponse = await this.squid 12 | .ai() 13 | .executeAiQuery('built_in_db', question); 14 | 15 | console.log(` 16 | Question: ${question} 17 | Query: ${aiResponse.executedQuery ?? 'No query executed'} 18 | Explanation: ${aiResponse.explanation ?? 'No Explanation'}`) 19 | 20 | return aiResponse.answer 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /backend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./src", 13 | "incremental": true, 14 | "importHelpers": true, 15 | "skipLibCheck": true, 16 | "strictNullChecks": true, 17 | "noImplicitAny": false, 18 | "strictBindCallApply": false, 19 | "forceConsistentCasingInFileNames": false, 20 | "noFallthroughCasesInSwitch": false, 21 | "esModuleInterop": true, 22 | "resolveJsonModule": true, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /frontend/src/components/TripList.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Trip } from '../types'; 3 | import TripCard from './Trip'; 4 | import "./Trip.css" 5 | 6 | type Props = { 7 | trips: Trip[]; 8 | onDelete: (id: string) => void; 9 | onAddNote: (tripId: string, note: string) => void; 10 | onDeleteNote: (tripId: string, noteIndex: number) => void; 11 | }; 12 | 13 | function TripList({ trips, onDelete, onAddNote, onDeleteNote }: Props) { 14 | return ( 15 |
16 | {trips && trips.map((trip, index) => )} 24 |
25 | ); 26 | } 27 | 28 | export default TripList -------------------------------------------------------------------------------- /frontend/src/components/AddTripForm.css: -------------------------------------------------------------------------------- 1 | .trip-container { 2 | width: 100%; 3 | margin-bottom: 20px; 4 | } 5 | 6 | .trip-container h3 { 7 | margin-bottom: 10px; 8 | text-align: center; 9 | font-family: Arial, sans-serif; 10 | color: #333; 11 | } 12 | 13 | .trip-form { 14 | width: 100%; 15 | display: flex; 16 | flex-direction: row; 17 | justify-content: space-between; 18 | align-items: center; 19 | } 20 | 21 | .trip-form select, 22 | .trip-form input[type='date'] { 23 | width: calc(33% - 10px); 24 | padding: 10px; 25 | border: 1px solid #ccc; 26 | border-radius: 5px; 27 | font-family: Arial, sans-serif; 28 | margin: 5px; 29 | } 30 | 31 | .trip-form button { 32 | padding: 10px; 33 | border: none; 34 | border-radius: 5px; 35 | background-color: #007bff; 36 | color: white; 37 | font-size: 16px; 38 | cursor: pointer; 39 | font-family: Arial, sans-serif; 40 | margin: 5px; 41 | } 42 | 43 | .trip-form button:hover { 44 | background-color: #0056b3; 45 | } 46 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "setup-env": "samples setup-env --prefix VITE_", 8 | "dev": "vite", 9 | "build": "tsc && vite build", 10 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 11 | "preview": "vite preview" 12 | }, 13 | "dependencies": { 14 | "@squidcloud/react": "^1.0.55", 15 | "@squidcloud/samples": "^1.0.12", 16 | "react": "^18.2.0", 17 | "react-dom": "^18.2.0" 18 | }, 19 | "devDependencies": { 20 | "@types/react": "^18.2.64", 21 | "@types/react-dom": "^18.2.21", 22 | "@typescript-eslint/eslint-plugin": "^7.1.1", 23 | "@typescript-eslint/parser": "^7.1.1", 24 | "@vitejs/plugin-react": "^4.2.1", 25 | "eslint": "^8.57.0", 26 | "eslint-plugin-react-hooks": "^4.6.0", 27 | "eslint-plugin-react-refresh": "^0.4.5", 28 | "typescript": "^5.2.2", 29 | "vite": "^5.1.6" 30 | } 31 | } -------------------------------------------------------------------------------- /backend/src/public/README.md: -------------------------------------------------------------------------------- 1 | # Assets Directory 2 | 3 | The assets directory is used to store files that will be uploaded to the Squid server along with your code. These files 4 | are secure and can only be accessed by your backend application. You can use the assets directory to store images, 5 | template files, or any other files that your code depends on. 6 | 7 | It's important to keep all necessary assets in this directory to ensure that your code runs correctly on the Squid 8 | server. If you need to include large assets, consider using a content delivery network (CDN) or hosting them on a 9 | separate server. 10 | 11 | To reference an asset in your backend project, inside a class that extends the `SquidService` base class, you can use: 12 | 13 | ```typescript 14 | @executable() 15 | async sendEmail(email: string): Promise { 16 | const templateFile = `${this.assetsDirectory}/email-template.html` 17 | console.log(`Sending email with the ${templateFile} template...`) 18 | } 19 | ``` 20 | 21 | Thank you for using Squid! Happy coding! 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024 Squid Cloud, Inc 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /frontend/public/squid.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /frontend/src/components/AskAI.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { useSquid } from '@squidcloud/react'; 3 | import './AskAI.css'; 4 | import LoadingIndicator from './LoadingIndicator'; 5 | 6 | function AskAI() { 7 | const [text, setText] = useState(''); 8 | const [result, setResult] = useState(''); 9 | const [loading, setLoading] = useState(false); 10 | const squid = useSquid(); 11 | 12 | const askPressed = async () => { 13 | if (!text) return; 14 | setLoading(true); 15 | const result = await squid.executeFunction('askQuestion', text); 16 | setResult(result); 17 | setText(''); 18 | setLoading(false); 19 | }; 20 | 21 | const closeResult = () => { 22 | setResult(''); 23 | }; 24 | 25 | return ( 26 |
27 |

Ask a Question!

28 | setText(e.target.value)} 32 | /> 33 | {loading ? ( 34 | 35 | ) : ( 36 | 37 | )} 38 | {result && ( 39 |
40 |