@gridfox/sdk
v0.3.0
Published
Typed Gridfox API SDK
Keywords
Readme
@gridfox/sdk
A typed runtime SDK for the Gridfox public API.
Current scope
GridfoxClientwith API key auth and configurable base URL/timeout.- Typed table client primitives:
listsearch(query + pagination helpers)getcreateupdatedelete
- Integration compile test against generated
@gridfox/codegenoutput.
Usage
import {
GridfoxFilter,
createGridfoxClient,
getFieldName,
pickWritableFields
} from '@gridfox/sdk'
import {
Products,
ProductsWritableFields,
type ProductRecord,
type ProductCreateInput,
type ProductUpdateInput
} from './generated/Products.js'
const client = createGridfoxClient({ apiKey: process.env.GRIDFOX_API_KEY ?? '' })
const products = client.table<ProductRecord, ProductCreateInput, ProductUpdateInput>(Products)
const productNameField = getFieldName(Products, 'productName')
const createPayload = pickWritableFields(
{ [productNameField]: 'Example', SKU: 999 },
ProductsWritableFields
)
void createPayload
const rows = await products.list()
const page = await products.search({
filter: GridfoxFilter.and(
GridfoxFilter.eq('Status', 'Active'),
GridfoxFilter.raw("Archived eq false")
),
orderBy: 'Product Name',
page: { number: 1, size: 50 }
})Embedded host auth mode (postMessage)
import { createGridfoxClient } from '@gridfox/sdk'
const client = createGridfoxClient({
customAuth: {
parentOrigin: 'https://app.gridfox.com'
}
})This mode requests auth + project context from the parent host using:
request-gridfox-custom-auth->gridfox-custom-authrequest-gridfox-project-id->gridfox-project-id
Local live SDK validation
See real-project-tests/README.md for local real-project checks using SDK CRUD calls against api.gridfox.com.
