UNPKG

@goatlab/typesense

Version:

Modern TypeScript wrapper for Typesense search engine API

42 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSchemaTypedApi = createSchemaTypedApi; const TypesenseApi_1 = require("../TypesenseApi"); /** * Creates a strongly-typed API instance from a collection definition * * @example * ```typescript * const ProductCollection = defineCollection({ * name: 'products', * fields: [ * { name: 'id', type: 'string' }, * { name: 'name', type: 'string' }, * { name: 'price', type: 'float' }, * { name: 'inStock', type: 'bool' } * ] * }) * * const api = createSchemaTypedApi(ProductCollection)({ * prefixUrl: 'http://localhost:8108', * token: 'xyz' * }) * * // Fully typed operations * await api.documents.insert({ * id: '1', * name: 'Widget', * price: 99.99, * inStock: true * }) * ``` */ function createSchemaTypedApi(collection) { return (options) => { return new TypesenseApi_1.TypesenseApi({ ...options, collectionName: collection.name }); }; } //# sourceMappingURL=schema-typed-api.js.map