@nexo-labs/payload-typesense 1.9.8 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -6,6 +6,71 @@ import { Agent } from "http";
6
6
  import { Agent as Agent$1 } from "https";
7
7
  import { ReadStream } from "fs";
8
8
 
9
+ //#region src/adapter/types.d.ts
10
+
11
+ /**
12
+ * All valid Typesense field types
13
+ * @see https://typesense.org/docs/latest/api/collections.html#schema-parameters
14
+ */
15
+ type TypesenseFieldType = 'string' | 'int32' | 'int64' | 'float' | 'bool' | 'string[]' | 'float[]' | 'int32[]' | 'int64[]' | 'bool[]' | 'object' | 'object[]' | 'geopoint' | 'geopoint[]' | 'auto';
16
+ /**
17
+ * Typesense-specific field mapping
18
+ * Extends the base FieldMapping with Typesense-specific properties
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const fields: TypesenseFieldMapping[] = [
23
+ * { name: 'title', type: 'string', index: true },
24
+ * { name: 'views', type: 'int64' },
25
+ * { name: 'tags', type: 'string[]', facet: true },
26
+ * { name: 'category', payloadField: 'category.name', type: 'string', facet: true },
27
+ * ];
28
+ * ```
29
+ */
30
+ interface TypesenseFieldMapping extends FieldMapping {
31
+ /**
32
+ * Typesense field type
33
+ */
34
+ type: TypesenseFieldType;
35
+ /**
36
+ * Whether the field should be faceted (filterable in Typesense UI)
37
+ */
38
+ facet?: boolean;
39
+ /**
40
+ * Whether the field should be indexed (searchable)
41
+ * @default true
42
+ */
43
+ index?: boolean;
44
+ /**
45
+ * Whether the field is optional (can be missing from documents)
46
+ */
47
+ optional?: boolean;
48
+ }
49
+ /**
50
+ * Typesense field schema for collection creation
51
+ * Used internally when creating/updating collections
52
+ */
53
+ interface TypesenseFieldSchema {
54
+ name: string;
55
+ type: TypesenseFieldType;
56
+ facet?: boolean;
57
+ index?: boolean;
58
+ optional?: boolean;
59
+ /** Number of dimensions for vector fields (float[]) */
60
+ vectorDimensions?: number;
61
+ /** Allow additional properties for compatibility with BaseCollectionSchema */
62
+ [key: string]: unknown;
63
+ }
64
+ /**
65
+ * Typesense collection schema for creation/update
66
+ * Extends BaseCollectionSchema with Typesense-specific options
67
+ */
68
+ interface TypesenseCollectionSchema extends BaseCollectionSchema {
69
+ fields: TypesenseFieldSchema[];
70
+ /** Default sorting field (must be a numeric field) */
71
+ defaultSortingField?: string;
72
+ }
73
+ //#endregion
9
74
  //#region src/shared/types/plugin-types.d.ts
10
75
  /**
11
76
  * Hybrid search configuration for combining semantic and keyword search
@@ -393,10 +458,10 @@ interface TypesenseSearchConfig {
393
458
  * Configuration for the Typesense RAG plugin
394
459
  * ...
395
460
  */
396
- interface TypesenseRAGPluginConfig<TSlug extends CollectionSlug> {
461
+ interface TypesenseRAGPluginConfig {
397
462
  /** Typesense connection configuration */
398
463
  typesense: TypesenseConnectionConfig;
399
- collectionName: TSlug;
464
+ collectionName: CollectionSlug;
400
465
  /**
401
466
  * Embedding provider config (for RAG query embedding)
402
467
  * Note: The RAG handler creates its own provider instance to track usage/spending.
@@ -404,7 +469,7 @@ interface TypesenseRAGPluginConfig<TSlug extends CollectionSlug> {
404
469
  */
405
470
  embeddingConfig?: EmbeddingProviderConfig;
406
471
  /** Collection configurations (for schema sync) */
407
- collections?: Record<string, TableConfig[]>;
472
+ collections?: Record<string, TableConfig<TypesenseFieldMapping>[]>;
408
473
  /** Search configuration */
409
474
  search?: TypesenseSearchConfig;
410
475
  /** RAG agent configurations */
@@ -434,7 +499,7 @@ interface TypesenseRAGPluginConfig<TSlug extends CollectionSlug> {
434
499
  * @param config - Typesense RAG plugin configuration
435
500
  * @returns Payload config modifier function
436
501
  */
437
- declare function createTypesenseRAGPlugin<TConfig extends Config, TSlug extends CollectionSlug>(config: TypesenseRAGPluginConfig<TSlug>): (payloadConfig: TConfig) => TConfig;
502
+ declare function createTypesenseRAGPlugin(config: TypesenseRAGPluginConfig): (payloadConfig: Config) => Config;
438
503
  //#endregion
439
504
  //#region ../../node_modules/.pnpm/typesense@2.1.0_@babel+runtime@7.28.6/node_modules/typesense/lib/Typesense/Errors/TypesenseError.d.ts
440
505
  declare class TypesenseError extends Error {
@@ -1828,70 +1893,6 @@ declare class Client {
1828
1893
  nlSearchModels(id: string): NLSearchModel;
1829
1894
  }
1830
1895
  //#endregion
1831
- //#region src/adapter/types.d.ts
1832
- /**
1833
- * All valid Typesense field types
1834
- * @see https://typesense.org/docs/latest/api/collections.html#schema-parameters
1835
- */
1836
- type TypesenseFieldType = 'string' | 'int32' | 'int64' | 'float' | 'bool' | 'string[]' | 'float[]' | 'int32[]' | 'int64[]' | 'bool[]' | 'object' | 'object[]' | 'geopoint' | 'geopoint[]' | 'auto';
1837
- /**
1838
- * Typesense-specific field mapping
1839
- * Extends the base FieldMapping with Typesense-specific properties
1840
- *
1841
- * @example
1842
- * ```typescript
1843
- * const fields: TypesenseFieldMapping[] = [
1844
- * { name: 'title', type: 'string', index: true },
1845
- * { name: 'views', type: 'int64' },
1846
- * { name: 'tags', type: 'string[]', facet: true },
1847
- * { name: 'category', payloadField: 'category.name', type: 'string', facet: true },
1848
- * ];
1849
- * ```
1850
- */
1851
- interface TypesenseFieldMapping extends FieldMapping {
1852
- /**
1853
- * Typesense field type
1854
- */
1855
- type: TypesenseFieldType;
1856
- /**
1857
- * Whether the field should be faceted (filterable in Typesense UI)
1858
- */
1859
- facet?: boolean;
1860
- /**
1861
- * Whether the field should be indexed (searchable)
1862
- * @default true
1863
- */
1864
- index?: boolean;
1865
- /**
1866
- * Whether the field is optional (can be missing from documents)
1867
- */
1868
- optional?: boolean;
1869
- }
1870
- /**
1871
- * Typesense field schema for collection creation
1872
- * Used internally when creating/updating collections
1873
- */
1874
- interface TypesenseFieldSchema {
1875
- name: string;
1876
- type: TypesenseFieldType;
1877
- facet?: boolean;
1878
- index?: boolean;
1879
- optional?: boolean;
1880
- /** Number of dimensions for vector fields (float[]) */
1881
- vectorDimensions?: number;
1882
- /** Allow additional properties for compatibility with BaseCollectionSchema */
1883
- [key: string]: unknown;
1884
- }
1885
- /**
1886
- * Typesense collection schema for creation/update
1887
- * Extends BaseCollectionSchema with Typesense-specific options
1888
- */
1889
- interface TypesenseCollectionSchema extends BaseCollectionSchema {
1890
- fields: TypesenseFieldSchema[];
1891
- /** Default sorting field (must be a numeric field) */
1892
- defaultSortingField?: string;
1893
- }
1894
- //#endregion
1895
1896
  //#region src/adapter/typesense-adapter.d.ts
1896
1897
  /**
1897
1898
  * Typesense implementation of the IndexerAdapter interface
@@ -2036,7 +2037,7 @@ interface FeatureFlags {
2036
2037
  interface ModularPluginConfig {
2037
2038
  typesense: TypesenseConnectionConfig;
2038
2039
  features: FeatureFlags;
2039
- collections: Record<CollectionSlug | string, TableConfig[]>;
2040
+ collections: Record<CollectionSlug | string, TableConfig<TypesenseFieldMapping>[]>;
2040
2041
  /** Resolve document type from Typesense collection name */
2041
2042
  documentTypeResolver?: (collectionName: string) => string;
2042
2043
  }
@@ -2393,23 +2394,28 @@ declare function executeRAGSearch(typesenseConfig: TypesenseConnectionConfig, se
2393
2394
  //#endregion
2394
2395
  //#region src/features/rag/handlers/session-handlers.d.ts
2395
2396
  /**
2396
- * Session data structure
2397
+ * Common fields shared between public session data and internal session documents
2397
2398
  */
2398
- type ChatSessionData = {
2399
+ type ChatSessionBase = {
2400
+ total_tokens?: number;
2401
+ total_cost?: number;
2402
+ last_activity?: string;
2403
+ };
2404
+ /**
2405
+ * Public session data structure
2406
+ */
2407
+ type ChatSessionData = ChatSessionBase & {
2399
2408
  conversation_id: string;
2400
2409
  title?: string;
2401
2410
  messages: Array<Record<string, unknown>>;
2402
2411
  status: string;
2403
- total_tokens?: number;
2404
- total_cost?: number;
2405
- last_activity?: string;
2406
2412
  };
2407
2413
  /**
2408
2414
  * Configuration for session operations
2409
2415
  */
2410
- type SessionConfig<TSlug extends CollectionSlug> = {
2416
+ type SessionConfig = {
2411
2417
  /** Collection name for sessions */
2412
- collectionName?: TSlug;
2418
+ collectionName?: CollectionSlug;
2413
2419
  /** Time window for active sessions in milliseconds */
2414
2420
  activeSessionWindow?: number;
2415
2421
  };
@@ -2421,7 +2427,7 @@ type SessionConfig<TSlug extends CollectionSlug> = {
2421
2427
  * @param config - Session configuration
2422
2428
  * @returns Promise with session data or null
2423
2429
  */
2424
- declare function getActiveSession<TSlug extends CollectionSlug>(payload: Payload, userId: string | number, config?: SessionConfig<TSlug>): Promise<ChatSessionData | null>;
2430
+ declare function getActiveSession(payload: Payload, userId: string | number, config?: SessionConfig): Promise<ChatSessionData | null>;
2425
2431
  /**
2426
2432
  * Get session by conversation ID
2427
2433
  *
@@ -2431,7 +2437,7 @@ declare function getActiveSession<TSlug extends CollectionSlug>(payload: Payload
2431
2437
  * @param config - Session configuration
2432
2438
  * @returns Promise with session data or null
2433
2439
  */
2434
- declare function getSessionByConversationId<TSlug extends CollectionSlug>(payload: Payload, userId: string | number, conversationId: string, config?: SessionConfig<TSlug>): Promise<ChatSessionData | null>;
2440
+ declare function getSessionByConversationId(payload: Payload, userId: string | number, conversationId: string, config?: SessionConfig): Promise<ChatSessionData | null>;
2435
2441
  /**
2436
2442
  * Close a chat session
2437
2443
  *
@@ -2441,7 +2447,7 @@ declare function getSessionByConversationId<TSlug extends CollectionSlug>(payloa
2441
2447
  * @param config - Session configuration
2442
2448
  * @returns Promise with updated session data or null if not found
2443
2449
  */
2444
- declare function closeSession<TSlug extends CollectionSlug>(payload: Payload, userId: string | number, conversationId: string, config?: SessionConfig<TSlug>): Promise<ChatSessionData | null>;
2450
+ declare function closeSession(payload: Payload, userId: string | number, conversationId: string, config?: SessionConfig): Promise<ChatSessionData | null>;
2445
2451
  //#endregion
2446
2452
  //#region src/features/rag/query-builder.d.ts
2447
2453
  /**
@@ -2627,7 +2633,7 @@ declare const deleteDocumentFromTypesense: (typesenseClient: Client, collectionS
2627
2633
  *
2628
2634
  * @param config - RAG plugin configuration (composable, doesn't depend on ModularPluginConfig)
2629
2635
  */
2630
- declare function createRAGPayloadHandlers<TSlug extends CollectionSlug>(config: TypesenseRAGPluginConfig<TSlug>): Array<{
2636
+ declare function createRAGPayloadHandlers(config: TypesenseRAGPluginConfig): Array<{
2631
2637
  path: string;
2632
2638
  method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put';
2633
2639
  handler: PayloadHandler;