{"_id":"@ddl-tech/wappler-pocketbase","_rev":"7-538b8938d64fcf100d1c171f6e2e8e2c","name":"@ddl-tech/wappler-pocketbase","dist-tags":{"latest":"1.1.3"},"versions":{"1.1.1":{"name":"@ddl-tech/wappler-pocketbase","version":"1.1.1","keywords":["wappler","server-connect","pocketbase","crud","database","authentication"],"author":{"name":"DDL Tech"},"license":"MIT","_id":"@ddl-tech/wappler-pocketbase@1.1.1","maintainers":[{"name":"ddl-tech","email":"damien@ddltechnology.com"}],"dist":{"shasum":"507f66a9cb2f5d0aeda74ea8f7b13106dd57cf74","tarball":"https://registry.npmjs.org/@ddl-tech/wappler-pocketbase/-/wappler-pocketbase-1.1.1.tgz","fileCount":6,"integrity":"sha512-X7osa0H8hr+1OkS+v35TkCwdeXirb9LNKd6Bc1Fz4HUtPc2maKoQ8XEVluVFywBvYP6AD6G0NdODf4DzW+0I2g==","signatures":[{"sig":"MEQCID5rM3HC6hiy6Ij5Xv4MMF/CvVCwoV6Rbibu/3gmO/rUAiAbF6NKH0aYfK6xVSioz1EXqJ+NyTjUg3MCPwgav24qbQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69778},"main":"server_connect/modules/pocketbase.js","engines":{"node":">=14.0.0"},"wappler":{"type":"server-connect-module","modules":[{"file":"server_connect/modules/pocketbase.js","name":"pocketbase","definition":"server_connect/modules/pocketbase.hjson"}]},"_npmUser":{"name":"ddl-tech","email":"damien@ddltechnology.com"},"_npmVersion":"11.4.2","description":"PocketBase CRUD module for Wappler Server Connect with complete database operations, authentication, and file management","directories":{},"_nodeVersion":"24.4.1","dependencies":{"pocketbase":"^0.21.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/wappler-pocketbase_1.1.1_1753972704845_0.32651483347384525","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@ddl-tech/wappler-pocketbase","version":"1.1.2","keywords":["wappler","server-connect","pocketbase","crud","database","authentication"],"author":{"name":"DDL Tech"},"license":"MIT","_id":"@ddl-tech/wappler-pocketbase@1.1.2","maintainers":[{"name":"ddl-tech","email":"damien@ddltechnology.com"}],"dist":{"shasum":"cbdfd0f3c1386e374fd144efe113c0d06245b2c5","tarball":"https://registry.npmjs.org/@ddl-tech/wappler-pocketbase/-/wappler-pocketbase-1.1.2.tgz","fileCount":6,"integrity":"sha512-Iavd/hDDXp6WLhQHC1HtpFUHaTgHPUszaE72xpW7jk1REcpj8zSgyX92jUL9KBbYOoGlAewnuXAwdGB0nXuCLQ==","signatures":[{"sig":"MEQCIH2UvFX4MAkG9mPGW/LhhQUbb0aMOd808qtG+OomWB61AiAXA+H5YS8GR8p8C8VDu3kWQQqGOJPhKUgrFDocGY6D0A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69778},"main":"server_connect/modules/pocketbase.js","engines":{"node":">=14.0.0"},"wappler":{"type":"server-connect-module","modules":[{"file":"server_connect/modules/pocketbase.js","name":"pocketbase","definition":"server_connect/modules/pocketbase.hjson"}]},"_npmUser":{"name":"ddl-tech","email":"damien@ddltechnology.com"},"_npmVersion":"11.4.2","description":"PocketBase CRUD module for Wappler Server Connect with complete database operations, authentication, and file management","directories":{},"_nodeVersion":"24.4.1","dependencies":{"pocketbase":"^0.21.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/wappler-pocketbase_1.1.2_1753977193737_0.3729156288758806","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@ddl-tech/wappler-pocketbase","version":"1.1.3","description":"PocketBase CRUD module for Wappler Server Connect with complete database operations, authentication, and file management","main":"server_connect/modules/pocketbase.js","keywords":["wappler","server-connect","pocketbase","crud","database","authentication"],"author":{"name":"DDL Tech"},"license":"MIT","engines":{"node":">=14.0.0"},"dependencies":{"pocketbase":"^0.21.0"},"wappler":{"type":"server-connect-module","modules":[{"name":"pocketbase","file":"server_connect/modules/pocketbase.js","definition":"server_connect/modules/pocketbase.hjson"}]},"_id":"@ddl-tech/wappler-pocketbase@1.1.3","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-ljsXiNLn3Zdxp6gCoaiIYpJ1Z9sg9Y/lOGDlj+gl3xiO7yUz05ZC2WQeWk7hrDpRNP7/BScOgYqYnZt9ID/D4g==","shasum":"68dbc72b14f3181d525018a33ce9f5d95033ff97","tarball":"https://registry.npmjs.org/@ddl-tech/wappler-pocketbase/-/wappler-pocketbase-1.1.3.tgz","fileCount":6,"unpackedSize":69772,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHSwzzefdWdcy3yCoZhAZB847sT4VpTD8wCJUL1eNrA7AiEAhI/KrZiyWDlMBAwKKMnA8X3vxYaRjASiMhoW5NH86eg="}]},"_npmUser":{"name":"ddl-tech","email":"damien@ddltechnology.com"},"directories":{},"maintainers":[{"name":"ddl-tech","email":"damien@ddltechnology.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/wappler-pocketbase_1.1.3_1753980207192_0.06143552557974585"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-01T12:49:23.670Z","modified":"2025-07-31T16:43:27.616Z","1.0.0":"2025-07-01T12:49:23.929Z","1.1.0":"2025-07-31T14:23:18.957Z","1.1.1":"2025-07-31T14:38:25.033Z","1.1.2":"2025-07-31T15:53:13.919Z","1.1.3":"2025-07-31T16:43:27.418Z"},"author":{"name":"DDL Tech"},"license":"MIT","keywords":["wappler","server-connect","pocketbase","crud","database","authentication"],"description":"PocketBase CRUD module for Wappler Server Connect with complete database operations, authentication, and file management","maintainers":[{"name":"ddl-tech","email":"damien@ddltechnology.com"}],"readme":"# PocketBase CRUD Module for Wappler Server Connect\r\n\r\nA comprehensive Node.js module for Wappler Server Connect that provides full CRUD operations and advanced features for PocketBase integration.\r\n\r\n## Features\r\n\r\n- **Complete CRUD Operations**: Create, Read, Update, Delete records\r\n- **Authentication**: User login and session management\r\n- **File Management**: Upload files and generate file URLs\r\n- **Advanced Querying**: Filtering, sorting, pagination, and relation expansion\r\n- **Batch Operations**: Perform multiple operations in transactions\r\n- **Health Monitoring**: Check PocketBase instance health\r\n- **Session Management**: Flexible manual token handling and URL persistence\r\n- **Error Handling**: Comprehensive error catching and user-friendly messages\r\n\r\n## Installation\r\n\r\n1. Copy the module files to your Wappler project:\r\n   ```\r\n   extensions/server_connect/modules/pocketbase.js\r\n   extensions/server_connect/modules/pocketbase.hjson\r\n   ```\r\n\r\n2. The PocketBase npm package will be automatically installed when you use any action from this module.\r\n\r\n## Quick Start\r\n\r\n### 1. Connect to PocketBase\r\n\r\nFirst, establish a connection to your PocketBase instance:\r\n\r\n```javascript\r\n// In Wappler Server Connect, add a \"Connect to PocketBase\" action\r\n// URL: http://127.0.0.1:8090 (or your PocketBase URL)\r\n```\r\n\r\n### 2. Authenticate User\r\n\r\n```javascript\r\n// Add \"Authenticate User\" action\r\n// URL: http://127.0.0.1:8090 (required for authentication)\r\n// Email: user@example.com\r\n// Password: userpassword\r\n// Collection: users (default)\r\n```\r\n\r\n### 3. Perform CRUD Operations\r\n\r\n```javascript\r\n// Create a record\r\n// Collection: posts\r\n// Data: {\"title\": \"My Post\", \"content\": \"Hello World\"}\r\n// Auth Token: {{authenticate1.token}}\r\n\r\n// Get records list\r\n// Collection: posts\r\n// Filter: status = true\r\n// Sort: -created\r\n// Auth Token: {{authenticate1.token}}\r\n\r\n// Update a record\r\n// Collection: posts\r\n// ID: record_id_here\r\n// Data: {\"title\": \"Updated Title\"}\r\n// Auth Token: {{authenticate1.token}}\r\n\r\n// Delete a record\r\n// Collection: posts\r\n// ID: record_id_here\r\n// Auth Token: {{authenticate1.token}}\r\n```\r\n\r\n## Available Actions\r\n\r\n### Connection & Authentication\r\n\r\n#### Connect to PocketBase\r\n- **Purpose**: Initialize connection to PocketBase instance and store URL for other actions\r\n- **Inputs**: \r\n  - `url` (required): PocketBase URL (e.g., http://127.0.0.1:8090)\r\n  - `authToken` (optional): Pre-existing auth token\r\n- **Output**: Connection status, authentication state, user info, authToken\r\n- **Note**: Stores URL in session for other actions to use automatically\r\n\r\n#### Authenticate User\r\n- **Purpose**: Login user with email/password\r\n- **Inputs**:\r\n  - `url` (required): PocketBase URL (must be specified for authentication)\r\n  - `email` (required): User email\r\n  - `password` (required): User password\r\n  - `collection` (optional): Auth collection name (default: \"users\")\r\n- **Output**: Auth token, user record, success status\r\n- **Note**: Does NOT use URL from Connect action - requires explicit URL\r\n\r\n### CRUD Operations\r\n\r\n#### Create Record\r\n- **Purpose**: Create new record in collection\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `data` (required): JSON object with record data\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Output**: Created record with ID\r\n- **File Upload**: Include file paths in data object\r\n\r\n#### Get Record\r\n- **Purpose**: Retrieve single record by ID\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `id` (required): Record ID\r\n  - `expand` (optional): Relations to expand\r\n  - `fields` (optional): Specific fields to return\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Output**: Record data\r\n\r\n#### Get Records List\r\n- **Purpose**: Get paginated list of records\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `page` (optional): Page number (default: 1)\r\n  - `perPage` (optional): Records per page (default: 30)\r\n  - `filter` (optional): Filter expression\r\n  - `sort` (optional): Sort expression\r\n  - `expand` (optional): Relations to expand\r\n  - `fields` (optional): Specific fields to return\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Output**: Paginated results with metadata\r\n\r\n#### Get All Records\r\n- **Purpose**: Retrieve all records (batch fetched)\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `filter` (optional): Filter expression\r\n  - `sort` (optional): Sort expression\r\n  - `expand` (optional): Relations to expand\r\n  - `fields` (optional): Specific fields to return\r\n  - `batch` (optional): Batch size (default: 200)\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Output**: All records array\r\n\r\n#### Update Record\r\n- **Purpose**: Update existing record\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `id` (required): Record ID\r\n  - `data` (required): JSON object with update data\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Output**: Updated record\r\n\r\n#### Delete Record\r\n- **Purpose**: Delete record by ID\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `id` (required): Record ID\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Output**: Success confirmation\r\n\r\n### File Operations\r\n\r\n#### Get File URL\r\n- **Purpose**: Generate URL for file attached to record\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `collection` (required): Collection name\r\n  - `recordId` (required): Record ID containing file\r\n  - `filename` (required): File name\r\n  - `thumb` (optional): Thumbnail size (e.g., \"100x100\")\r\n- **Output**: File URL\r\n\r\n### Advanced Operations\r\n\r\n#### Batch Operations\r\n- **Purpose**: Perform multiple operations in single transaction\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n  - `operations` (required): Array of operations\r\n  - `authToken` (optional): Authentication token for the request\r\n- **Operation Format**:\r\n  ```json\r\n  [\r\n    {\"type\": \"create\", \"collection\": \"posts\", \"data\": {...}},\r\n    {\"type\": \"update\", \"collection\": \"posts\", \"id\": \"123\", \"data\": {...}},\r\n    {\"type\": \"delete\", \"collection\": \"posts\", \"id\": \"456\"}\r\n  ]\r\n  ```\r\n- **Output**: Batch results\r\n\r\n#### Health Check\r\n- **Purpose**: Check PocketBase instance health\r\n- **Inputs**:\r\n  - `url` (optional): Leave empty to use URL from Connect action\r\n- **Output**: Health status and data\r\n\r\n## Usage Examples\r\n\r\n### Basic CRUD Workflow\r\n\r\n```javascript\r\n// 1. Connect (stores URL for other actions)\r\nConnect to PocketBase\r\n  URL: http://127.0.0.1:8090\r\n\r\n// 2. Authenticate (requires explicit URL)\r\nAuthenticate User\r\n  URL: http://127.0.0.1:8090\r\n  Email: {{$_POST.email}}\r\n  Password: {{$_POST.password}}\r\n\r\n// 3. Create Record (uses URL from Connect automatically)\r\nCreate Record\r\n  Collection: posts\r\n  Data: {\r\n    \"title\": \"{{$_POST.title}}\",\r\n    \"content\": \"{{$_POST.content}}\",\r\n    \"author\": \"{{authenticate1.user.id}}\"\r\n  }\r\n  Auth Token: {{authenticate1.token}}\r\n\r\n// 4. Get Records (uses URL from Connect automatically)\r\nGet Records List\r\n  Collection: posts\r\n  Filter: author = '{{authenticate1.user.id}}'\r\n  Sort: -created\r\n  Page: {{$_GET.page || 1}}\r\n  Per Page: 10\r\n  Auth Token: {{authenticate1.token}}\r\n```\r\n\r\n### File Upload Example\r\n\r\n```javascript\r\n// Create record with file\r\nCreate Record\r\n  Collection: posts\r\n  Data: {\r\n    \"title\": \"{{$_POST.title}}\",\r\n    \"image\": \"{{$_FILES.image.path}}\"  // File path for upload\r\n  }\r\n  Auth Token: {{authenticate1.token}}\r\n\r\n// Get file URL\r\nGet File URL\r\n  Collection: posts\r\n  Record ID: {{create1.id}}\r\n  Filename: {{create1.record.image}}\r\n  Thumb: 300x200\r\n```\r\n\r\n### Advanced Filtering\r\n\r\n```javascript\r\n// Complex filter example\r\nGet Records List\r\n  Collection: posts\r\n  Filter: status = true && created > '2023-01-01' && (category = 'tech' || category = 'news')\r\n  Sort: -created,title\r\n  Expand: author,category\r\n  Fields: id,title,content,created,author.name,category.name\r\n  Auth Token: {{authenticate1.token}}\r\n```\r\n\r\n### Batch Operations\r\n\r\n```javascript\r\nBatch Operations\r\n  Operations: [\r\n    {\r\n      \"type\": \"create\",\r\n      \"collection\": \"posts\",\r\n      \"data\": {\"title\": \"Post 1\", \"content\": \"Content 1\"}\r\n    },\r\n    {\r\n      \"type\": \"create\", \r\n      \"collection\": \"posts\",\r\n      \"data\": {\"title\": \"Post 2\", \"content\": \"Content 2\"}\r\n    },\r\n    {\r\n      \"type\": \"update\",\r\n      \"collection\": \"posts\", \r\n      \"id\": \"existing_id\",\r\n      \"data\": {\"status\": \"published\"}\r\n    }\r\n  ]\r\n  Auth Token: {{authenticate1.token}}\r\n```\r\n\r\n## Filter Expressions\r\n\r\nPocketBase supports powerful filter expressions:\r\n\r\n### Basic Operators\r\n- `=` Equal\r\n- `!=` Not equal\r\n- `>` Greater than\r\n- `>=` Greater than or equal\r\n- `<` Less than\r\n- `<=` Less than or equal\r\n- `~` Like (case insensitive)\r\n- `!~` Not like\r\n\r\n### Logical Operators\r\n- `&&` AND\r\n- `||` OR\r\n\r\n### Examples\r\n```javascript\r\n// Simple filters\r\n\"status = true\"\r\n\"created > '2023-01-01'\"\r\n\"title ~ 'hello'\"\r\n\r\n// Complex filters\r\n\"status = true && created > '2023-01-01'\"\r\n\"(category = 'tech' || category = 'news') && status = true\"\r\n\"author.name ~ 'john' && created >= '2023-01-01'\"\r\n```\r\n\r\n## Sort Expressions\r\n\r\nSort records using field names:\r\n\r\n```javascript\r\n// Ascending\r\n\"created\"\r\n\"title\"\r\n\r\n// Descending (prefix with -)\r\n\"-created\"\r\n\"-title\"\r\n\r\n// Multiple fields\r\n\"status,-created,title\"\r\n```\r\n\r\n## Error Handling\r\n\r\nThe module provides comprehensive error handling:\r\n\r\n- Connection errors\r\n- Authentication failures\r\n- Validation errors\r\n- Network timeouts\r\n- Invalid data formats\r\n\r\nAll errors are returned in a consistent format with descriptive messages.\r\n\r\n## Session Management\r\n\r\nThe module provides flexible session management:\r\n\r\n### URL Management\r\n- **Connect Action**: Stores PocketBase URL in session for other actions\r\n- **Automatic URL**: All actions (except Authenticate) use stored URL when URL field is empty\r\n- **Manual Override**: Specify URL in any action to override stored URL\r\n\r\n### Authentication Token Management\r\n- **Manual Control**: You control when and how to store authentication tokens\r\n- **No Automatic Storage**: Authentication tokens are returned but not automatically saved\r\n- **Explicit Tokens**: Pass auth tokens explicitly in each action that needs authentication\r\n\r\n### Recommended Workflow\r\n```javascript\r\n// 1. Connect (stores URL)\r\nConnect to PocketBase\r\n  URL: http://127.0.0.1:8090\r\n\r\n// 2. Authenticate (requires explicit URL)\r\nAuthenticate User\r\n  URL: http://127.0.0.1:8090\r\n  Email: {{$_POST.email}}\r\n  Password: {{$_POST.password}}\r\n\r\n// 3. Store token manually (optional - use Wappler session actions)\r\nSet Session Variable\r\n  Name: auth_token\r\n  Value: {{authenticate1.token}}\r\n\r\n// 4. Use in other actions (URL automatic, token manual)\r\nCreate Record\r\n  Collection: posts\r\n  Data: {...}\r\n  Auth Token: {{$_SESSION.auth_token}}\r\n```\r\n\r\n## Security Features\r\n\r\n- Secure token handling\r\n- Input validation\r\n- File upload security\r\n- SQL injection prevention\r\n- XSS protection\r\n\r\n## Requirements\r\n\r\n- Wappler with Node.js server model\r\n- PocketBase instance (v0.15.0+)\r\n- Node.js 14+\r\n\r\n## Support\r\n\r\nFor issues and questions:\r\n1. Check PocketBase documentation: https://pocketbase.io/docs/\r\n2. Review Wappler Server Connect documentation\r\n3. Verify your PocketBase instance is running and accessible\r\n\r\n## License\r\n\r\nThis module is provided as-is for use with Wappler projects.\r\n","readmeFilename":"README.md"}