### Execute Example Scripts Source: https://github.com/undefinedsco/drizzle-solid/blob/main/GEMINI.md Commands to run provided example scripts that demonstrate server setup, authentication, and CRUD operations. ```bash yarn example:setup yarn example:auth yarn example:usage yarn example:basic ``` -------------------------------- ### Minimal Node.js Authentication and Drizzle-Solid Client Setup Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/node-session-authentication.md This example demonstrates the minimal Node.js authentication flow using `@inrupt/solid-client-authn-node` and sets up a Drizzle-Solid client for interacting with a Solid Pod. It covers session creation, client credential login, and initializing a Drizzle table. ```typescript import { Session } from '@inrupt/solid-client-authn-node'; import { pod, podTable, string } from '@undefineds.co/drizzle-solid'; async function main() { const session = new Session(); await session.login({ oidcIssuer: process.env.SOLID_OIDC_ISSUER!, clientId: process.env.SOLID_CLIENT_ID!, clientSecret: process.env.SOLID_CLIENT_SECRET!, tokenType: 'DPoP', }); if (!session.info.isLoggedIn) { throw new Error('Session login failed'); } const todos = podTable('todos', { id: string('id').primaryKey(), title: string('title').predicate('http://schema.org/name'), }, { base: '/data/todos.ttl', type: 'http://schema.org/Thing', }); const client = pod(session); await client.init(todos); const rows = await client.collection(todos).list({ limit: 10 }); console.log(rows); } main().catch(console.error); ``` -------------------------------- ### Install dependencies for drizzle-solid Source: https://github.com/undefinedsco/drizzle-solid/blob/main/README.md Commands to install the core library and optional SPARQL engine dependencies using yarn or npm. ```bash yarn add @undefineds.co/drizzle-solid drizzle-orm yarn add @comunica/query-sparql-solid ``` ```bash npm install @undefineds.co/drizzle-solid drizzle-orm npm install @comunica/query-sparql-solid ``` -------------------------------- ### Install Drizzle Solid and Dependencies Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Installs the core Drizzle Solid package, drizzle-orm, and authentication dependencies. It also shows optional installation for a SPARQL engine. ```bash # Install core dependencies yarn add @undefineds.co/drizzle-solid drizzle-orm # Install authentication (Node.js) yarn add @inrupt/solid-client-authn-node # Optional: Install SPARQL engine for advanced queries yarn add @comunica/query-sparql-solid ``` -------------------------------- ### Check Example Structure Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/guides/testing.md Performs a structural check on example files to ensure they adhere to the expected format and conventions. This is part of the verification process for user-facing examples. ```bash yarn examples:check ``` -------------------------------- ### IRI-based Entity Operations in TypeScript Source: https://github.com/undefinedsco/drizzle-solid/blob/main/examples/README.md Demonstrates how to perform single-entity operations (get, update, delete) using explicit IRI targets with Drizzle Solid. This is useful for detail pages, shared resources, or remote links. ```typescript const profile = client.entity(profileTable, 'https://alice.pod/profile/card#me'); await profile.get(); await profile.update({ name: 'New Name' }); await profile.delete(); ``` -------------------------------- ### Data Discovery with TypeScript Source: https://github.com/undefinedsco/drizzle-solid/blob/main/examples/README.md Shows how to dynamically discover data locations using Drizzle Solid's data discovery API. This avoids hardcoding paths and allows apps to find data locations. ```typescript const locations = await client.discovery.discover('https://schema.org/Person'); ``` -------------------------------- ### Run Full Project Verification Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/guides/testing.md Executes a comprehensive verification process for the entire project, ensuring code quality and test coverage. This command is typically invoked using Yarn. ```bash yarn quality ``` -------------------------------- ### Run Unit Tests with Vitest Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/guides/testing.md Executes all unit tests located in the 'tests/unit' directory using the Vitest test runner. Unit tests focus on fast feedback for pure logic, query builders, RDF mapping, type-level behavior, and helper utilities. ```bash yarn vitest --run tests/unit ``` -------------------------------- ### Shape Selection in TypeScript Source: https://github.com/undefinedsco/drizzle-solid/blob/main/examples/README.md Demonstrates how to select a specific Shape when a container has multiple Shapes from different applications using Drizzle Solid. This allows for precise data retrieval. ```typescript const table = await client.locationToTable(location); const byApp = await client.locationToTable(location, { appId: 'https://acme.com/app#id' }); const byShape = await client.locationToTable(location, { shape: 'https://shapes.example/Person.shacl' }); ``` -------------------------------- ### Run Integration Tests Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/guides/testing.md Executes integration tests, primarily targeting Community Solid Server / Pod behavior. These tests verify CRUD operations, TypeIndex flows, SPARQL endpoint behavior, and other Solid-specific semantics. The command defaults to an in-process xpod runtime when remote Solid credentials are not provided. ```bash yarn test:integration ``` -------------------------------- ### Collection-based Reads and Subscriptions in TypeScript Source: https://github.com/undefinedsco/drizzle-solid/blob/main/examples/README.md Illustrates how to perform list reads, filtering, and collection subscriptions using explicit collection semantics in Drizzle Solid. This is the preferred method for collection-based operations. ```typescript const posts = client.collection(postsTable); const latest = await posts.list({ limit: 20 }); const first = await posts.first({ where: { id: 'post-1' } }); ``` -------------------------------- ### Reproduce N3 Patch literal mismatch Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/investigations/css-issues-report.md Example of a Turtle resource and an N3 Patch request that fails to delete an integer literal due to representation differences between shorthand and canonical forms. ```turtle <#me> 20 . ``` ```turtle @prefix solid: . @prefix xsd: . _:patch a solid:InsertDeletePatch; solid:delete { <#me> "20"^^xsd:integer . }; solid:insert { <#me> 99 . }. ``` -------------------------------- ### Discover resources using pod and drizzle constructors Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/guides/architecture.md Demonstrates how to initialize a client using either the pod or drizzle constructor and perform a discovery operation for a specific schema type. Both methods share the same underlying runtime, allowing for interchangeable use based on the preferred API style. ```typescript const client = pod(session); const locations = await client.discovery.discover('https://schema.org/Person'); ``` ```typescript const db = drizzle(session); const locations = await db.discovery.discover('https://schema.org/Person'); ``` -------------------------------- ### Create Pod Client with pod() API Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Demonstrates creating a semantic-first Solid Pod client using the `pod()` function. It includes authentication with a Solid Pod, defining a table schema with predicates, and initializing the client. ```typescript import { pod, podTable, string, datetime, solid } from '@undefineds.co/drizzle-solid'; import { Session } from '@inrupt/solid-client-authn-node'; // Authenticate with Solid Pod const session = new Session(); await session.login({ oidcIssuer: 'https://solidcommunity.net/', clientId: process.env.SOLID_CLIENT_ID, clientSecret: process.env.SOLID_CLIENT_SECRET, tokenType: 'DPoP' }); // Define a table schema const posts = podTable('posts', { id: string('id').primaryKey(), title: string('title').predicate('http://schema.org/headline'), content: string('content').predicate('http://schema.org/text'), createdAt: datetime('createdAt').predicate('http://schema.org/dateCreated') }, { base: 'https://alice.solidcommunity.net/data/posts/', subjectTemplate: '{id}.ttl', type: 'http://schema.org/CreativeWork' }); // Create client and initialize const client = pod(session); await client.init(posts); // Alternative: Use inline session helper const inlineClient = pod(solid({ webId: 'https://alice.solidcommunity.net/profile/card#me', fetch: authenticatedFetch })); ``` -------------------------------- ### Run Project Tests Source: https://github.com/undefinedsco/drizzle-solid/blob/main/GEMINI.md Commands to execute unit and integration tests using Vitest, including options for watch mode, coverage, and real Solid Pod integration. ```bash yarn test yarn test:watch yarn test:coverage SOLID_ENABLE_REAL_TESTS=true npx vitest run tests/integration/css --runInBand yarn css:install ``` -------------------------------- ### Generate Parity Tests Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/guides/testing.md Generates parity tests based on upstream Drizzle tests. This command is used to create scaffolding for compatibility checks between Drizzle and Solid behaviors. ```bash yarn parity:generate ``` -------------------------------- ### Running Tests with Drizzle Solid Source: https://github.com/undefinedsco/drizzle-solid/blob/main/README.md This command demonstrates how to build, lint, and run integration tests for Drizzle Solid. It requires specific environment variables to be set for test execution. ```bash yarn build yarn lint SOLID_ENABLE_REAL_TESTS=true SOLID_SERIAL_TESTS=true yarn vitest --run --silent ``` -------------------------------- ### Execute SPARQL Queries and Convert Builders with Drizzle-Solid Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Demonstrates how to execute raw SPARQL queries using both pod and drizzle clients, and how to convert Drizzle query builders into SPARQL strings. This functionality is useful for advanced data retrieval and interoperability with RDF-based Pod storage. ```typescript import { pod, drizzle, podTable, string } from '@undefineds.co/drizzle-solid'; const posts = podTable('posts', { id: string('id').primaryKey(), title: string('title').predicate('http://schema.org/headline'), content: string('content').predicate('http://schema.org/text') }, { base: 'https://alice.pod/data/posts.ttl', type: 'http://schema.org/CreativeWork' }); const client = pod(session); const sparqlResults = await client.sparql(` SELECT ?s ?title WHERE { ?s a . ?s ?title . } LIMIT 10 `); const db = drizzle(session); const dbResults = await db.executeSPARQL(` SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 5 `); const query = db.select().from(posts); const sparqlString = query.toSPARQL(); ``` -------------------------------- ### SubjectResolver Interface Definition (TypeScript) Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/architecture-refactor-proposal.md Defines the SubjectResolver interface for resolving and parsing subject URIs. It handles resolving subjects from table records, parsing URIs, getting resource URLs, and determining resource modes (document or fragment). ```typescript // src/core/subject/types.ts type ResourceMode = 'document' | 'fragment'; interface SubjectResolver { resolve(table: PodTable, record: Record, index?: number): string; parse(uri: string, table: PodTable): ParsedSubject | null; getResourceUrl(subjectUri: string): string; getResourceMode(table: PodTable): ResourceMode; } ``` -------------------------------- ### Bind schemas to runtime clients Source: https://github.com/undefinedsco/drizzle-solid/blob/main/README.md Shows how to bind a reusable schema to a specific Pod location using either the semantic pod() façade or the Drizzle-aligned entry point. ```typescript // Using pod() façade const client = pod(session); const profileTable = client.bind(profileSchema, { base: 'https://alice.example/profile/card', }); // Using drizzle() entry point const db = drizzle(session); const profileTable = db.createTable(profileSchema, { base: 'https://alice.example/profile/card', }); ``` -------------------------------- ### Create Drizzle-Compatible Client with drizzle() API Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Shows how to create a Drizzle-compatible Solid Pod client using the `drizzle()` function. This approach is suitable for users familiar with drizzle-orm, allowing them to maintain existing code patterns while interacting with Solid Pod data. It includes defining schemas, relations, and performing Drizzle-style queries. ```typescript import { drizzle, podTable, string, uri } from '@undefineds.co/drizzle-solid'; import { relations } from 'drizzle-orm'; const users = podTable('users', { id: string('id').primaryKey(), name: string('name').predicate('http://xmlns.com/foaf/0.1/name'), }, { base: 'https://alice.pod/data/users.ttl', type: 'http://xmlns.com/foaf/0.1/Person', }); const posts = podTable('posts', { id: string('id').primaryKey(), title: string('title').predicate('http://schema.org/headline'), authorId: uri('author').predicate('http://schema.org/author').link(users), }, { base: 'https://alice.pod/data/posts.ttl', type: 'http://schema.org/CreativeWork', }); const postsRelations = relations(posts, ({ one }) => ({ author: one(users, { fields: [posts.authorId], references: [users.id], }), })); const schema = { users, posts, postsRelations }; const db = drizzle(session, { schema }); // Use Drizzle-style query builders const results = await db.query.posts.findMany({ with: { author: true } }); // Output: [{ id: 'post-1', title: "Alice's Post", author: { id: 'alice', name: 'Alice' } }] ``` -------------------------------- ### Perform manual project release Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/RELEASE.md Standard manual workflow for updating the package version, committing the changes, and pushing tags to the remote repository to trigger CI/CD pipelines. ```bash # 1. Update version in package.json npm version patch # or minor, or major # 2. Commit the change git add package.json git commit -m "chore: bump version to X.Y.Z" # 3. Create and push tag git tag -a vX.Y.Z -m "Release vX.Y.Z" git push origin main git push origin vX.Y.Z ``` -------------------------------- ### Automate project release using shell script Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/RELEASE.md Executes the internal release script to perform automated version bumping, quality checks, and git tagging. Supports patch, minor, and major semantic version increments. ```bash # Patch release (0.2.8 → 0.2.9) ./scripts/release.sh patch # Minor release (0.2.8 → 0.3.0) ./scripts/release.sh minor # Major release (0.2.8 → 1.0.0) ./scripts/release.sh major ``` -------------------------------- ### Configure Solid Environment Variables Source: https://github.com/undefinedsco/drizzle-solid/blob/main/examples/USAGE.md Sets the required OIDC and client credentials in the shell environment. These variables are necessary for the application to authenticate with the Solid server. ```bash export SOLID_CLIENT_ID="your-client-id" export SOLID_CLIENT_SECRET="your-client-secret" export SOLID_OIDC_ISSUER="http://localhost:3000" ``` -------------------------------- ### Define schema and perform CRUD operations with pod() Source: https://github.com/undefinedsco/drizzle-solid/blob/main/README.md Demonstrates defining a Pod-based table schema and performing create, read, update, and delete operations using the semantic-first pod() client. ```typescript import { pod, podTable, string, datetime, } from '@undefineds.co/drizzle-solid'; const posts = podTable('posts', { id: string('id').primaryKey(), title: string('title').predicate('http://schema.org/headline'), content: string('content').predicate('http://schema.org/text'), createdAt: datetime('createdAt').predicate('http://schema.org/dateCreated'), }, { base: 'https://alice.example/data/posts/', subjectTemplate: '{id}.ttl', type: 'http://schema.org/CreativeWork', }); const client = pod(session); await client.init(posts); const postsCollection = client.collection(posts); const created = await postsCollection.create({ id: 'post-1', title: 'Hello Solid', content: 'Stored as RDF in a Pod document.', createdAt: new Date(), }); const first = await postsCollection.first({ where: { id: 'post-1' }, }); const postIri = created?.['@id'] ?? postsCollection.iriFor({ id: 'post-1', title: 'Hello Solid', content: 'Stored as RDF in a Pod document.', createdAt: new Date(), }); const post = client.entity(posts, postIri); await post.update({ title: 'Updated title' }); await post.delete(); ``` -------------------------------- ### Discover Data Locations with Drizzle-Solid Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Demonstrates how to use the discovery API to locate RDF data across Pods based on classes or application IDs. It includes methods for listing registrations, converting locations to tables, and performing cross-Pod discovery. ```typescript import { pod, podTable, string, id, solid } from '@undefineds.co/drizzle-solid'; const client = pod(session); // Discover locations for a specific RDF class const personLocations = await client.discovery.discover('https://schema.org/Person'); // Filter by application ID const appLocations = await client.discovery.discover('https://schema.org/Person', { appId: 'https://myapp.example.com/' }); // List all data registrations const allRegistrations = await client.discovery.discoverAll?.() ?? []; // Convert discovered location to a table if (personLocations.length > 0) { const personTable = await client.locationToTable(personLocations[0]); const people = await client.collection(personTable).list(); } // Cross-Pod discovery const otherWebId = 'https://bob.solidcommunity.net/profile/card#me'; const crossPodClient = pod(solid({ webId: otherWebId, fetch: session.fetch, sessionId: 'cross-pod-discovery' })); const sharedLocations = await crossPodClient.discovery.discover('https://schema.org/Person'); ``` -------------------------------- ### Define Pod resource schemas with podTable() Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt The podTable() function maps data fields to RDF predicates and defines storage locations using base paths and subject templates. It supports Document Mode for individual files, Fragment Mode for multiple resources per file, and partitioned resource structures. ```typescript import { podTable, string, datetime, uri, int, boolean, id } from '@undefineds.co/drizzle-solid'; // Document Mode: One resource per file const users = podTable('users', { id: string('id').primaryKey(), name: string('name').predicate('http://xmlns.com/foaf/0.1/name'), email: string('email').predicate('http://schema.org/email'), age: int('age').predicate('http://xmlns.com/foaf/0.1/age'), active: boolean('active').predicate('http://xmlns.com/activeFlag') }, { base: 'https://alice.pod/data/users/', subjectTemplate: '{id}.ttl', type: 'http://xmlns.com/foaf/0.1/Person' }); // Fragment Mode: Multiple resources in one file const tags = podTable('tags', { id: id(), name: string('name').predicate('http://schema.org/name'), color: string('color').predicate('http://schema.org/color') }, { base: 'https://alice.pod/data/tags.ttl', subjectTemplate: '#{id}', type: 'http://schema.org/DefinedTerm' }); // Multi-variable template: Partitioned resources const messages = podTable('messages', { id: string('id').primaryKey(), chatId: string('chatId').predicate('http://example.org/chatId'), content: string('content').predicate('http://schema.org/text'), timestamp: datetime('timestamp').predicate('http://schema.org/dateCreated') }, { base: 'https://alice.pod/data/chats/', subjectTemplate: '{chatId}/messages.ttl#{id}', type: 'http://schema.org/Message' }); ``` -------------------------------- ### Execute Federated Cross-Pod Queries Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Shows how to define federated relations between tables and execute queries that span multiple Pods. It covers automatic federation via the client and manual control using the FederatedQueryExecutor. ```typescript import { pod, podTable, string, id, relations, FederatedQueryExecutor } from '@undefineds.co/drizzle-solid'; const friends = podTable('friends', { id: id(), name: string('name').predicate('https://schema.org/name'), webId: string('webId').predicate('https://schema.org/identifier'), }, { base: 'https://alice.pod/data/friends.ttl', type: 'https://schema.org/Person' }); const posts = podTable('posts', { id: id(), title: string('title').predicate('https://schema.org/headline'), content: string('content').predicate('https://schema.org/content'), }, { type: 'https://schema.org/BlogPosting', base: '/data/posts/' }); const friendsRelations = relations(friends, ({ many }) => ({ posts: many(posts.$schema, { discover: (friend: any) => friend.webId }) })); const client = pod(session, { schema: { friends, posts, friendsRelations } }); // Query with automatic federation const friendsWithPosts = await client.query.friends.findMany(); // Direct executor usage const executor = new FederatedQueryExecutor({ fetch: session.fetch, timeout: 10000 }); const result = await executor.execute( [{ id: 'alice', name: 'Alice', webId: 'https://alice.solidcommunity.net/profile/card#me' }], { type: 'many', table: posts.$schema, isFederated: true, discover: (friend: any) => friend.webId, relationName: 'posts' }, { parallel: true, maxConcurrency: 3 } ); ``` -------------------------------- ### Generate Zod Schemas for Runtime Validation Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Shows how to create Zod schemas from table definitions for insert, update, and full table operations. It also demonstrates extending these schemas with custom refinements for advanced validation logic. ```typescript import { podTable, string, int, datetime, boolean, createTableSchema, createInsertSchema, createUpdateSchema, TableSchemaBuilder } from '@undefineds.co/drizzle-solid'; import { z } from 'zod'; const users = podTable('users', { id: string('id').primaryKey(), name: string('name').predicate('http://xmlns.com/foaf/0.1/name'), email: string('email').predicate('http://schema.org/email'), age: int('age').predicate('http://xmlns.com/foaf/0.1/age'), active: boolean('active').predicate('http://schema.org/activeFlag'), createdAt: datetime('createdAt').predicate('http://schema.org/dateCreated') }, { base: 'https://alice.pod/data/users.ttl', type: 'http://xmlns.com/foaf/0.1/Person' }); const userSchema = createTableSchema(users); const builder = new TableSchemaBuilder(users); const customSchema = builder.extend({ email: z.string().email('Invalid email format'), age: z.number().min(0).max(150) }).build(); const parseResult = userSchema.safeParse({ id: 'user-1', name: 'Alice' }); ``` -------------------------------- ### Linting and Quality Assurance Source: https://github.com/undefinedsco/drizzle-solid/blob/main/GEMINI.md Commands to maintain code quality through linting and comprehensive build/test checks. ```bash yarn lint yarn lint:fix yarn quality ``` -------------------------------- ### Manage WebID Profile and Type Indexes with Drizzle Solid Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt This snippet demonstrates how to initialize the ProfileManager, retrieve profile metadata, manage public and private type indexes, and register new data types. It requires an active session and is used to handle data discovery and profile updates within a Solid Pod. ```typescript import { ProfileManager, pod } from '@undefineds.co/drizzle-solid'; const client = pod(session); const profileManager = new ProfileManager(session); // Get profile information const webId = session.info.webId; const profile = await profileManager.getProfile(webId); console.log('Name:', profile.name); console.log('Storage:', profile.storage); console.log('Inbox:', profile.inbox); console.log('Preferences:', profile.preferencesFile); // Get type index locations const publicTypeIndex = await profileManager.getPublicTypeIndex(webId); const privateTypeIndex = await profileManager.getPrivateTypeIndex(webId); console.log('Public TypeIndex:', publicTypeIndex); console.log('Private TypeIndex:', privateTypeIndex); // Register a type in the type index await profileManager.registerType({ typeIndex: publicTypeIndex, forClass: 'http://schema.org/BlogPosting', instance: 'https://alice.pod/data/posts.ttl', }); // List registered types const registrations = await profileManager.listTypeRegistrations(publicTypeIndex); for (const reg of registrations) { console.log(`Class: ${reg.forClass}`); console.log(`Location: ${reg.instance || reg.instanceContainer}`); } // Update profile information await profileManager.updateProfile(webId, { name: 'Alice Smith', bio: 'Solid enthusiast' }); ``` -------------------------------- ### Entity API for Exact-Target Operations Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt The `client.entity()` API allows for precise manipulation of individual entities using their known IRI. ```APIDOC ## Entity API for Exact-Target Operations ### Description Provides IRI-based operations for precise entity manipulation when the exact resource identifier is known. ### Method GET, PUT, DELETE ### Endpoint Entity-specific endpoints derived from the pod configuration and entity IRI. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **update**: Object containing fields to update for the entity. ### Request Example ```json // Update entity { "title": "Updated Title", "content": "Updated content" } ``` ### Response #### Success Response (200) - **get**: The entity data. - **update**: The updated entity data. #### Response Example ```json // Example for get/update { "@id": "https://alice.pod/data/posts/my-post.ttl", "id": "my-post", "title": "Updated Title", "content": "Updated content", "createdAt": "2024-07-27T10:00:00.000Z" } ``` ``` -------------------------------- ### Build and Compile Drizzle Solid Source: https://github.com/undefinedsco/drizzle-solid/blob/main/GEMINI.md Commands to compile the TypeScript source code into JavaScript using the project's build scripts. ```bash yarn build ``` -------------------------------- ### Collection API for CRUD Operations Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt The `client.collection()` API provides methods for managing collections of entities, including creating, listing, and querying. ```APIDOC ## Collection API for CRUD Operations ### Description Provides collection-oriented operations for listing, creating, and querying entities. ### Method Various (e.g., POST for create, GET for list) ### Endpoint Collection-specific endpoints determined by the pod configuration. ### Parameters #### Path Parameters None #### Query Parameters - **where** (QueryCondition) - Optional - Filtering conditions for listing entities. - **limit** (number) - Optional - Maximum number of entities to return. #### Request Body - **create**: Object representing the entity to create. - **createMany**: Array of objects representing entities to create. ### Request Example ```json // Create single entity { "id": "post-1", "title": "Hello World", "content": "My first post", "status": "published", "createdAt": "2024-07-27T10:00:00.000Z" } // List with filtering { "where": { "status": "published" }, "limit": 10 } ``` ### Response #### Success Response (200) - **create/createMany**: The created entity or entities. - **list**: An array of entities matching the query. - **first**: The first entity matching the query, or null. #### Response Example ```json // Example for create { "@id": "https://alice.pod/data/posts/post-1.ttl", "id": "post-1", "title": "Hello World", "content": "My first post", "status": "published", "createdAt": "2024-07-27T10:00:00.000Z" } // Example for list [ { "@id": "https://alice.pod/data/posts/post-1.ttl", "id": "post-1", "title": "Hello World", "content": "My first post", "status": "published", "createdAt": "2024-07-27T10:00:00.000Z" } ] ``` ``` -------------------------------- ### Fix version mismatch errors Source: https://github.com/undefinedsco/drizzle-solid/blob/main/docs/RELEASE.md Corrects a discrepancy between the package.json version and the git tag by updating the local file and amending the previous commit. ```bash # Update package.json to match the tag npm version X.Y.Z --no-git-tag-version git add package.json git commit --amend --no-edit git push origin main --force-with-lease ``` -------------------------------- ### Perform CRUD operations with Collection API in TypeScript Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt Demonstrates how to define a podTable schema and use the collection API for creating, listing, and filtering entities. It supports complex queries using logical operators like 'and', 'or', and 'gt'. ```typescript import { pod, podTable, string, datetime, eq, and, or, gt } from '@undefineds.co/drizzle-solid'; const posts = podTable('posts', { id: string('id').primaryKey(), title: string('title').predicate('http://schema.org/headline'), content: string('content').predicate('http://schema.org/text'), status: string('status').predicate('http://schema.org/status'), createdAt: datetime('createdAt').predicate('http://schema.org/dateCreated') }, { base: 'https://alice.pod/data/posts/', subjectTemplate: '{id}.ttl', type: 'http://schema.org/CreativeWork' }); const client = pod(session); await client.init(posts); const postsCollection = client.collection(posts); // Create single entity const created = await postsCollection.create({ id: 'post-1', title: 'Hello World', content: 'My first post', status: 'published', createdAt: new Date() }); // List with filtering const publishedPosts = await postsCollection.list({ where: eq(posts.status, 'published'), limit: 10 }); // Complex filtering const recentPublished = await postsCollection.list({ where: and( eq(posts.status, 'published'), gt(posts.createdAt, new Date('2024-01-01')) ) }); ``` -------------------------------- ### Create and bind reusable schemas with solidSchema() Source: https://context7.com/undefinedsco/drizzle-solid/llms.txt The solidSchema() function defines portable data structures that are decoupled from specific Pod locations. These schemas can be bound to different base URLs at runtime using the client.bind() method. ```typescript import { pod, solidSchema, string, datetime, id } from '@undefineds.co/drizzle-solid'; // Define reusable schema (no location binding) const profileSchema = solidSchema({ id: id(), name: string('name').predicate('http://xmlns.com/foaf/0.1/name'), bio: string('bio').predicate('http://schema.org/description'), }, { type: 'http://xmlns.com/foaf/0.1/Person' }); const agentSchema = solidSchema({ id: id(), name: string('name').predicate('http://schema.org/name'), description: string('description').predicate('http://schema.org/description'), createdAt: datetime('createdAt').predicate('http://schema.org/dateCreated') }, { type: 'http://schema.org/SoftwareApplication' }); const client = pod(session); // Bind schemas to specific Pod locations const profileTable = client.bind(profileSchema, { base: 'https://alice.pod/profile/card', }); const agentTable = client.bind(agentSchema, { base: 'https://alice.pod/data/agents.ttl', }); await client.init(agentTable); // Use bound tables normally const agents = client.collection(agentTable); await agents.create({ name: 'My Agent', description: 'A helpful assistant', createdAt: new Date() }); ```