@naturali/sdk 0.71.2 → 0.72.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.cjs CHANGED
@@ -1,5 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/generated/core/bodySerializer.gen.ts
3
+ const serializeFormDataPair = (data, key, value) => {
4
+ if (typeof value === "string" || value instanceof Blob) data.append(key, value);
5
+ else if (value instanceof Date) data.append(key, value.toISOString());
6
+ else data.append(key, JSON.stringify(value));
7
+ };
8
+ const formDataBodySerializer = { bodySerializer: (body) => {
9
+ const data = new FormData();
10
+ Object.entries(body).forEach(([key, value]) => {
11
+ if (value === void 0 || value === null) return;
12
+ if (Array.isArray(value)) value.forEach((v) => serializeFormDataPair(data, key, v));
13
+ else serializeFormDataPair(data, key, value);
14
+ });
15
+ return data;
16
+ } };
3
17
  const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
4
18
  //#endregion
5
19
  //#region src/generated/core/serverSentEvents.gen.ts
@@ -1660,6 +1674,196 @@ var Conversations = class {
1660
1674
  });
1661
1675
  }
1662
1676
  };
1677
+ var Documents = class {
1678
+ /**
1679
+ * List documents
1680
+ *
1681
+ * Returns all documents the caller has access to. If projectId is provided, returns only documents in that project. project keys are scoped to a single project automatically. JWT users without projectId receive documents across all their accessible projects.
1682
+ */
1683
+ static listDocuments(options) {
1684
+ return (options.client ?? client).get({
1685
+ url: "/v1/projects/{project_id}/documents",
1686
+ ...options
1687
+ });
1688
+ }
1689
+ /**
1690
+ * Create a document
1691
+ *
1692
+ * Creates a new text document and generates an embedding vector for semantic search. project keys automatically infer the project from the key's scope; JWT callers must supply projectId.
1693
+ */
1694
+ static createDocument(options) {
1695
+ return (options.client ?? client).post({
1696
+ url: "/v1/projects/{project_id}/documents",
1697
+ ...options,
1698
+ headers: {
1699
+ "Content-Type": "application/json",
1700
+ ...options.headers
1701
+ }
1702
+ });
1703
+ }
1704
+ /**
1705
+ * Ingest a file into a chunked document
1706
+ *
1707
+ * Parses an already-uploaded file and creates one Document split into one or
1708
+ * more embedded chunks. The source format is detected from the file's content
1709
+ * type: PDFs are parsed page-by-page; `text/plain` and `text/markdown` files
1710
+ * are read as a single source. How the source is chunked is controlled by
1711
+ * `chunk_strategy`.
1712
+ *
1713
+ * A file can only back one Document — a second call with the same `file_id`
1714
+ * returns `409 FILE_ALREADY_INGESTED`. To re-process an already-ingested file
1715
+ * (e.g. with a different `chunk_strategy`), use
1716
+ * `POST /documents/{document_id}/ingest`; to ingest the same source under a
1717
+ * different path, upload a new copy of the file first.
1718
+ *
1719
+ */
1720
+ static ingestDocument(options) {
1721
+ return (options.client ?? client).post({
1722
+ url: "/v1/projects/{project_id}/documents/ingest",
1723
+ ...options,
1724
+ headers: {
1725
+ "Content-Type": "application/json",
1726
+ ...options.headers
1727
+ }
1728
+ });
1729
+ }
1730
+ /**
1731
+ * Delete a document
1732
+ *
1733
+ * Deletes a document and its underlying file
1734
+ */
1735
+ static deleteDocument(options) {
1736
+ return (options.client ?? client).delete({
1737
+ url: "/v1/projects/{project_id}/documents/{document_id}",
1738
+ ...options
1739
+ });
1740
+ }
1741
+ /**
1742
+ * Get a document by ID
1743
+ *
1744
+ * Returns a document with its text content
1745
+ */
1746
+ static getDocument(options) {
1747
+ return (options.client ?? client).get({
1748
+ url: "/v1/projects/{project_id}/documents/{document_id}",
1749
+ ...options
1750
+ });
1751
+ }
1752
+ /**
1753
+ * Update a document
1754
+ *
1755
+ * Updates document content, title, path, metadata, or tags. Supplying `path` moves the document to a new logical path within the project.
1756
+ */
1757
+ static updateDocument(options) {
1758
+ return (options.client ?? client).patch({
1759
+ url: "/v1/projects/{project_id}/documents/{document_id}",
1760
+ ...options,
1761
+ headers: {
1762
+ "Content-Type": "application/json",
1763
+ ...options.headers
1764
+ }
1765
+ });
1766
+ }
1767
+ /**
1768
+ * Get document ingestion status
1769
+ *
1770
+ * Returns a lightweight ingestion status payload for polling — `status`,
1771
+ * `chunk_count`, `total_pages`, and (when failed) `error`. Unlike
1772
+ * `GET /documents/{document_id}`, it never returns the assembled chunk
1773
+ * content, so it is cheap to poll on large documents. A document whose
1774
+ * ingestion has stalled (no progress past the configured timeout) is
1775
+ * transitioned to `failed` with `error=INGESTION_TIMEOUT` on read.
1776
+ *
1777
+ */
1778
+ static getDocumentStatus(options) {
1779
+ return (options.client ?? client).get({
1780
+ url: "/v1/projects/{project_id}/documents/{document_id}/status",
1781
+ ...options
1782
+ });
1783
+ }
1784
+ /**
1785
+ * Re-ingest an existing document
1786
+ *
1787
+ * Re-runs ingestion for an existing document against its already-stored
1788
+ * source file. Existing chunks are discarded and the document is reset to
1789
+ * `status=pending` before re-processing. Use this to recover a document
1790
+ * stuck in `processing`/`failed` or to re-chunk with a different strategy
1791
+ * without re-uploading the file. Background by default (`202`); pass
1792
+ * `?wait=true` to run synchronously (`201`).
1793
+ *
1794
+ */
1795
+ static reingestDocument(options) {
1796
+ return (options.client ?? client).post({
1797
+ url: "/v1/projects/{project_id}/documents/{document_id}/ingest",
1798
+ ...options,
1799
+ headers: {
1800
+ "Content-Type": "application/json",
1801
+ ...options.headers
1802
+ }
1803
+ });
1804
+ }
1805
+ /**
1806
+ * Get document tags
1807
+ *
1808
+ * Returns all tags attached to the document
1809
+ */
1810
+ static getDocumentTags(options) {
1811
+ return (options.client ?? client).get({
1812
+ url: "/v1/projects/{project_id}/documents/{document_id}/tags",
1813
+ ...options
1814
+ });
1815
+ }
1816
+ /**
1817
+ * Merge document tags
1818
+ *
1819
+ * Merges provided tags with existing tags (existing tags are preserved unless overridden)
1820
+ */
1821
+ static mergeDocumentTags(options) {
1822
+ return (options.client ?? client).patch({
1823
+ url: "/v1/projects/{project_id}/documents/{document_id}/tags",
1824
+ ...options,
1825
+ headers: {
1826
+ "Content-Type": "application/json",
1827
+ ...options.headers
1828
+ }
1829
+ });
1830
+ }
1831
+ /**
1832
+ * Replace document tags
1833
+ *
1834
+ * Replaces all tags on the document with the provided tags (not merged)
1835
+ */
1836
+ static replaceDocumentTags(options) {
1837
+ return (options.client ?? client).put({
1838
+ url: "/v1/projects/{project_id}/documents/{document_id}/tags",
1839
+ ...options,
1840
+ headers: {
1841
+ "Content-Type": "application/json",
1842
+ ...options.headers
1843
+ }
1844
+ });
1845
+ }
1846
+ };
1847
+ var Embeddings = class {
1848
+ /**
1849
+ * Create embeddings
1850
+ *
1851
+ * Generates embedding vectors for one or more text inputs using the server's configured embedding model.
1852
+ * Provide `input` for a single text or `inputs` for a batch. At least one is required.
1853
+ * Returns `embedding` when `input` is used, and `embeddings` when `inputs` is used.
1854
+ *
1855
+ */
1856
+ static createEmbeddings(options) {
1857
+ return (options.client ?? client).post({
1858
+ url: "/v1/projects/{project_id}/embeddings",
1859
+ ...options,
1860
+ headers: {
1861
+ "Content-Type": "application/json",
1862
+ ...options.headers
1863
+ }
1864
+ });
1865
+ }
1866
+ };
1663
1867
  var Evaluations = class {
1664
1868
  /**
1665
1869
  * List datasets
@@ -1936,6 +2140,165 @@ var Evaluations = class {
1936
2140
  });
1937
2141
  }
1938
2142
  };
2143
+ var Files = class {
2144
+ /**
2145
+ * List all files
2146
+ *
2147
+ * Returns a list of all stored files
2148
+ */
2149
+ static listFiles(options) {
2150
+ return (options.client ?? client).get({
2151
+ url: "/v1/projects/{project_id}/files",
2152
+ ...options
2153
+ });
2154
+ }
2155
+ /**
2156
+ * Create a file
2157
+ *
2158
+ * Creates a new file record in the system
2159
+ */
2160
+ static createFile(options) {
2161
+ return (options.client ?? client).post({
2162
+ url: "/v1/projects/{project_id}/files",
2163
+ ...options,
2164
+ headers: {
2165
+ "Content-Type": "application/json",
2166
+ ...options.headers
2167
+ }
2168
+ });
2169
+ }
2170
+ /**
2171
+ * Upload a file
2172
+ *
2173
+ * Uploads a file to the server and stores it in the configured storage directory
2174
+ */
2175
+ static uploadFile(options) {
2176
+ return (options.client ?? client).post({
2177
+ ...formDataBodySerializer,
2178
+ url: "/v1/projects/{project_id}/files/upload",
2179
+ ...options,
2180
+ headers: {
2181
+ "Content-Type": null,
2182
+ ...options.headers
2183
+ }
2184
+ });
2185
+ }
2186
+ /**
2187
+ * Upload a file using base64 encoding
2188
+ *
2189
+ * Uploads a file to the server using base64-encoded content
2190
+ */
2191
+ static uploadFileBase64(options) {
2192
+ return (options.client ?? client).post({
2193
+ url: "/v1/projects/{project_id}/files/upload/base64",
2194
+ ...options,
2195
+ headers: {
2196
+ "Content-Type": "application/json",
2197
+ ...options.headers
2198
+ }
2199
+ });
2200
+ }
2201
+ /**
2202
+ * Delete a file
2203
+ *
2204
+ * Removes a file from the system by ID
2205
+ */
2206
+ static deleteFile(options) {
2207
+ return (options.client ?? client).delete({
2208
+ url: "/v1/projects/{project_id}/files/{file_id}",
2209
+ ...options
2210
+ });
2211
+ }
2212
+ /**
2213
+ * Get a file by ID
2214
+ *
2215
+ * Returns the data and metadata of a specific file
2216
+ */
2217
+ static getFile(options) {
2218
+ return (options.client ?? client).get({
2219
+ url: "/v1/projects/{project_id}/files/{file_id}",
2220
+ ...options
2221
+ });
2222
+ }
2223
+ /**
2224
+ * Download a file
2225
+ *
2226
+ * Streams the file content to the client
2227
+ */
2228
+ static downloadFile(options) {
2229
+ return (options.client ?? client).get({
2230
+ url: "/v1/projects/{project_id}/files/{file_id}/download",
2231
+ ...options
2232
+ });
2233
+ }
2234
+ /**
2235
+ * Update file metadata
2236
+ *
2237
+ * Updates the metadata field of a file
2238
+ */
2239
+ static updateFileMetadata(options) {
2240
+ return (options.client ?? client).patch({
2241
+ url: "/v1/projects/{project_id}/files/{file_id}/metadata",
2242
+ ...options,
2243
+ headers: {
2244
+ "Content-Type": "application/json",
2245
+ ...options.headers
2246
+ }
2247
+ });
2248
+ }
2249
+ /**
2250
+ * Download file as base64
2251
+ *
2252
+ * Returns the file content encoded as base64
2253
+ */
2254
+ static downloadFileBase64(options) {
2255
+ return (options.client ?? client).get({
2256
+ url: "/v1/projects/{project_id}/files/{file_id}/download/base64",
2257
+ ...options
2258
+ });
2259
+ }
2260
+ /**
2261
+ * Get file tags
2262
+ *
2263
+ * Returns all tags attached to the file
2264
+ */
2265
+ static getFileTags(options) {
2266
+ return (options.client ?? client).get({
2267
+ url: "/v1/projects/{project_id}/files/{file_id}/tags",
2268
+ ...options
2269
+ });
2270
+ }
2271
+ /**
2272
+ * Merge file tags
2273
+ *
2274
+ * Merges provided tags with existing tags
2275
+ */
2276
+ static mergeFileTags(options) {
2277
+ return (options.client ?? client).patch({
2278
+ url: "/v1/projects/{project_id}/files/{file_id}/tags",
2279
+ ...options,
2280
+ headers: {
2281
+ "Content-Type": "application/json",
2282
+ ...options.headers
2283
+ }
2284
+ });
2285
+ }
2286
+ /**
2287
+ * Replace file tags
2288
+ *
2289
+ * Replaces all tags on the file with the provided tags
2290
+ */
2291
+ static replaceFileTags(options) {
2292
+ return (options.client ?? client).put({
2293
+ url: "/v1/projects/{project_id}/files/{file_id}/tags",
2294
+ ...options,
2295
+ headers: {
2296
+ "Content-Type": "application/json",
2297
+ ...options.headers
2298
+ }
2299
+ });
2300
+ }
2301
+ };
1939
2302
  var Generations = class {
1940
2303
  /**
1941
2304
  * List generations
@@ -2012,6 +2375,88 @@ var Generations = class {
2012
2375
  });
2013
2376
  }
2014
2377
  };
2378
+ var IngestionRules = class {
2379
+ /**
2380
+ * List ingestion rules
2381
+ *
2382
+ * Returns the ingestion rules for a project
2383
+ */
2384
+ static listIngestionRules(options) {
2385
+ return (options.client ?? client).get({
2386
+ url: "/v1/projects/{project_id}/ingestion-rules",
2387
+ ...options
2388
+ });
2389
+ }
2390
+ /**
2391
+ * Create an ingestion rule
2392
+ *
2393
+ * Creates a rule mapping a content_type glob to a converter. Exactly one of tool_id or agent_id must be set.
2394
+ */
2395
+ static createIngestionRule(options) {
2396
+ return (options.client ?? client).post({
2397
+ url: "/v1/projects/{project_id}/ingestion-rules",
2398
+ ...options,
2399
+ headers: {
2400
+ "Content-Type": "application/json",
2401
+ ...options.headers
2402
+ }
2403
+ });
2404
+ }
2405
+ /**
2406
+ * Delete an ingestion rule
2407
+ *
2408
+ * Deletes an ingestion rule
2409
+ */
2410
+ static deleteIngestionRule(options) {
2411
+ return (options.client ?? client).delete({
2412
+ url: "/v1/projects/{project_id}/ingestion-rules/{ingestion_rule_id}",
2413
+ ...options
2414
+ });
2415
+ }
2416
+ /**
2417
+ * Get an ingestion rule
2418
+ *
2419
+ * Returns a specific ingestion rule
2420
+ */
2421
+ static getIngestionRule(options) {
2422
+ return (options.client ?? client).get({
2423
+ url: "/v1/projects/{project_id}/ingestion-rules/{ingestion_rule_id}",
2424
+ ...options
2425
+ });
2426
+ }
2427
+ /**
2428
+ * Update an ingestion rule
2429
+ *
2430
+ * Updates fields of an ingestion rule
2431
+ */
2432
+ static updateIngestionRule(options) {
2433
+ return (options.client ?? client).patch({
2434
+ url: "/v1/projects/{project_id}/ingestion-rules/{ingestion_rule_id}",
2435
+ ...options,
2436
+ headers: {
2437
+ "Content-Type": "application/json",
2438
+ ...options.headers
2439
+ }
2440
+ });
2441
+ }
2442
+ };
2443
+ var Knowledge = class {
2444
+ /**
2445
+ * Search knowledge
2446
+ *
2447
+ * Searches across documents and memory entries using semantic search, file paths, document IDs, or memory IDs/tags. At least one of `query`, `document_paths`, `document_ids`, `memory_ids`, or `memory_tags` must be provided.
2448
+ */
2449
+ static searchKnowledge(options) {
2450
+ return (options.client ?? client).post({
2451
+ url: "/v1/projects/{project_id}/knowledge/search",
2452
+ ...options,
2453
+ headers: {
2454
+ "Content-Type": "application/json",
2455
+ ...options.headers
2456
+ }
2457
+ });
2458
+ }
2459
+ };
2015
2460
  var ModelRoutes = class {
2016
2461
  /**
2017
2462
  * List model routes
@@ -3344,8 +3789,13 @@ var NaturaliClient = class {
3344
3789
  channels;
3345
3790
  auth;
3346
3791
  conversations;
3792
+ documents;
3793
+ embeddings;
3347
3794
  evaluations;
3795
+ files;
3348
3796
  generations;
3797
+ ingestionRules;
3798
+ knowledge;
3349
3799
  modelRoutes;
3350
3800
  models;
3351
3801
  orchestrations;
@@ -3378,8 +3828,13 @@ var NaturaliClient = class {
3378
3828
  this.channels = bindResource(Channels, this.http);
3379
3829
  this.auth = bindResource(Auth, this.http);
3380
3830
  this.conversations = bindResource(Conversations, this.http);
3831
+ this.documents = bindResource(Documents, this.http);
3832
+ this.embeddings = bindResource(Embeddings, this.http);
3381
3833
  this.evaluations = bindResource(Evaluations, this.http);
3834
+ this.files = bindResource(Files, this.http);
3382
3835
  this.generations = bindResource(Generations, this.http);
3836
+ this.ingestionRules = bindResource(IngestionRules, this.http);
3837
+ this.knowledge = bindResource(Knowledge, this.http);
3383
3838
  this.modelRoutes = bindResource(ModelRoutes, this.http);
3384
3839
  this.models = bindResource(Models, this.http);
3385
3840
  this.orchestrations = bindResource(Orchestrations, this.http);
@@ -3405,8 +3860,13 @@ exports.Assistant = Assistant;
3405
3860
  exports.Auth = Auth;
3406
3861
  exports.Channels = Channels;
3407
3862
  exports.Conversations = Conversations;
3863
+ exports.Documents = Documents;
3864
+ exports.Embeddings = Embeddings;
3408
3865
  exports.Evaluations = Evaluations;
3866
+ exports.Files = Files;
3409
3867
  exports.Generations = Generations;
3868
+ exports.IngestionRules = IngestionRules;
3869
+ exports.Knowledge = Knowledge;
3410
3870
  exports.ModelRoutes = ModelRoutes;
3411
3871
  exports.Models = Models;
3412
3872
  exports.NaturaliClient = NaturaliClient;