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