@permute/sdk 0.1.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/LICENSE +201 -0
- package/README.md +212 -0
- package/dist/client.d.ts +100 -0
- package/dist/client.js +553 -0
- package/dist/generated/openapi.d.ts +536 -0
- package/dist/generated/openapi.js +1 -0
- package/dist/generated/runtime-contract.d.ts +12 -0
- package/dist/generated/runtime-contract.js +1757 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.js +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# @permute/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript client for the Permute public API.
|
|
4
|
+
|
|
5
|
+
The SDK supports Node.js 20 and newer and includes TypeScript declarations.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @permute/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configure
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { PermuteClient } from '@permute/sdk';
|
|
15
|
+
|
|
16
|
+
const orgClient = new PermuteClient({
|
|
17
|
+
apiKey: process.env.PERMUTE_API_KEY!,
|
|
18
|
+
baseUrl: process.env.PERMUTE_API_BASE_URL,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const client = orgClient.withWorkspace(process.env.PERMUTE_WORKSPACE_ID!);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For an organization-scoped key, select a workspace before calling data APIs.
|
|
25
|
+
For a workspace-scoped key, `workspaceId` is optional because the API can infer
|
|
26
|
+
it from the key. Use `baseUrl` for custom API endpoints or tests.
|
|
27
|
+
|
|
28
|
+
## Manage Workspaces
|
|
29
|
+
|
|
30
|
+
Workspace routes use the same API-key permission system as other resources.
|
|
31
|
+
Grant `workspace:*` write access to create workspaces; exact or wildcard
|
|
32
|
+
workspace read/write/admin grants control list/get, update, and delete
|
|
33
|
+
respectively. Lists only return readable workspaces. After creating one, derive
|
|
34
|
+
a workspace client for its data operations.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const orgClient = new PermuteClient({
|
|
38
|
+
apiKey: process.env.PERMUTE_API_KEY!,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const workspace = await orgClient.workspaces.create({
|
|
42
|
+
name: 'Finance',
|
|
43
|
+
context: 'Revenue, customers, and operating performance', // Optional.
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const client = orgClient.withWorkspace(workspace.id);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For a workspace-scoped key, the data client needs only the key:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const client = new PermuteClient({
|
|
53
|
+
apiKey: process.env.PERMUTE_API_KEY!,
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`withWorkspace()` selects request context for workspace data APIs; it does not
|
|
58
|
+
grant access. The selected ID is available as `client.workspaceId`. Organization
|
|
59
|
+
APIs such as `client.workspaces.list()` do not send a workspace header.
|
|
60
|
+
|
|
61
|
+
## Upload Files
|
|
62
|
+
|
|
63
|
+
Use the one-call helper when you have file bytes in process. It creates a file
|
|
64
|
+
dataset and PUTs bytes to its signed S3 target. S3 starts processing automatically.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const uploaded = await client.datasets.create({
|
|
68
|
+
type: 'file',
|
|
69
|
+
fileName: 'Revenue.csv',
|
|
70
|
+
contentType: 'text/csv',
|
|
71
|
+
data: csvBytes,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(uploaded.sourceId, uploaded.status);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The SDK infers `sizeBytes` for strings, buffers, typed arrays, ArrayBuffers, and
|
|
78
|
+
Blobs. REST callers provide `sizeBytes`, then send a raw `PUT` to the returned
|
|
79
|
+
`data.upload.url` with every header in `data.upload.headers`. Poll
|
|
80
|
+
`client.datasets.get(result.id)` for processing status; there is no completion
|
|
81
|
+
API call.
|
|
82
|
+
|
|
83
|
+
## Manage Custom Datasets
|
|
84
|
+
|
|
85
|
+
Create a custom dataset by a stable workspace key when one logical source
|
|
86
|
+
contains multiple related tables. Calling `create()` again with the same custom
|
|
87
|
+
key returns the same dataset, allowing later writes to append or replace its
|
|
88
|
+
data. The SDK accepts JavaScript objects, encodes them as chunked NDJSON, and
|
|
89
|
+
uploads the result to a signed S3 target; callers do not need temporary files.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { CONTEXT, PermuteClient } from '@permute/sdk';
|
|
93
|
+
|
|
94
|
+
const dataset = await client.datasets.create({
|
|
95
|
+
type: 'custom',
|
|
96
|
+
key: 'quickbooks',
|
|
97
|
+
name: 'QuickBooks',
|
|
98
|
+
context: [CONTEXT.QuickBooks],
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await dataset.replace({
|
|
102
|
+
orders: [{ id: 1 }, { id: 2 }],
|
|
103
|
+
customers: [{ id: 10 }],
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log(dataset.sourceId, dataset.version, dataset.data.tables);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`replace()` sends the complete dataset snapshot. Tables omitted from the call
|
|
110
|
+
are removed, while tables with the same name keep their stable identity for
|
|
111
|
+
reports and dashboards. Retrying an identical replacement is a no-op.
|
|
112
|
+
|
|
113
|
+
Use `replaceTable()` when the supplied rows are the complete current contents
|
|
114
|
+
of one table. Existing rows not supplied are removed; other tables are unchanged:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
await dataset.replaceTable('orders', allOrders);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Use `appendTable()` only when every supplied row is new and previously written
|
|
121
|
+
rows can never be updated or deleted:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
await dataset.appendTable('events', newEvents, {
|
|
125
|
+
batchId: 'events-2026-07-15-page-2',
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`appendTable()` does not update, delete, merge, upsert, or deduplicate rows.
|
|
130
|
+
`batchId` identifies one append operation: reuse it when retrying the same rows
|
|
131
|
+
and use a new value for a new append. It prevents a retried request from being
|
|
132
|
+
applied twice; reusing it with different rows fails. It does not remove duplicate
|
|
133
|
+
rows sent in different batches.
|
|
134
|
+
|
|
135
|
+
When source records can change or disappear, collect the source's current rows
|
|
136
|
+
and use `replaceTable()` instead. The SDK serializes custom writes as chunked
|
|
137
|
+
NDJSON, uploads them directly to a signed S3 target, and waits for processing;
|
|
138
|
+
it does not build Parquet locally. The REST upload supports up to 50 tables and
|
|
139
|
+
1 GB, but the current SDK object helper encodes the supplied rows in memory, so
|
|
140
|
+
callers should stay comfortably within their process memory. `appendTable()`
|
|
141
|
+
accepts up to 10,000 rows per batch. Durable SDK operations stop polling after
|
|
142
|
+
20 minutes by default; pass `pollTimeoutMs` to set a different bound.
|
|
143
|
+
|
|
144
|
+
## Recommended Flow
|
|
145
|
+
|
|
146
|
+
Start with sources and ask Permute for an interpretation, then drop down to
|
|
147
|
+
evidence or exact rows only when the caller needs them. `answer()` starts a
|
|
148
|
+
durable analysis job and waits for its completed result.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const sources = await client.sources.list();
|
|
152
|
+
const sourceIds = sources.items.slice(0, 2).map((source) => source.id);
|
|
153
|
+
|
|
154
|
+
const answer = await client.answer({
|
|
155
|
+
question: 'What changed in revenue this quarter?',
|
|
156
|
+
sourceIds,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
console.log(answer.answer);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Use `answerJobs()` and `getAnswerJob()` directly when the caller needs to
|
|
163
|
+
persist the job ID and manage polling itself.
|
|
164
|
+
|
|
165
|
+
Use search when the caller needs supporting records or citations instead of a
|
|
166
|
+
new interpretation.
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const evidence = await client.search({
|
|
170
|
+
query: 'Q4 revenue growth drivers',
|
|
171
|
+
limit: 5,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
console.log(evidence.items);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Use SQL only when table names are known and exact rows matter. SQL requests must
|
|
178
|
+
include `sourceIds`; call `client.sources.get()` first when table names are not
|
|
179
|
+
known.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const details = await client.sources.get(sourceIds[0]);
|
|
183
|
+
|
|
184
|
+
const rows = await client.query({
|
|
185
|
+
sourceIds: [details.source.id],
|
|
186
|
+
sql: `SELECT * FROM "${details.tables[0].name}" LIMIT 10`,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
console.log(rows.rows);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Error Handling
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { PermuteApiError } from '@permute/sdk';
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
await client.query({
|
|
199
|
+
sourceIds: ['conn_hubspot123'],
|
|
200
|
+
sql: 'SELECT * FROM "deals" LIMIT 10',
|
|
201
|
+
});
|
|
202
|
+
} catch (error) {
|
|
203
|
+
if (error instanceof PermuteApiError) {
|
|
204
|
+
console.error(error.status, error.code, error.message, error.requestId);
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
Apache-2.0. Copyright 2026 Permute, Inc.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Workspace, WorkspaceCreateRequest, WorkspaceDeleteResponse, WorkspaceList, WorkspaceUpdateRequest, AnswerRequest, AnswerJobResponse, AnswerResponse, PermuteClientOptions, PermuteRequestOptions, QueryRequest, QueryResponse, SearchRequest, SearchResponse, SourceDetail, SourceList, CustomDatasetCreateRequest, DatasetResponse, FileDatasetCreateRequest, FileDatasetResponse, DatasetRows, CustomDatasetResponse } from './types.js';
|
|
2
|
+
export declare class PermuteApiError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly details?: unknown;
|
|
6
|
+
readonly requestId?: string;
|
|
7
|
+
constructor(input: {
|
|
8
|
+
status: number;
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
details?: unknown;
|
|
12
|
+
requestId?: string;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
type DatasetWriteInput = {
|
|
16
|
+
tables: Record<string, DatasetRows>;
|
|
17
|
+
mode: 'replace';
|
|
18
|
+
} | {
|
|
19
|
+
tableName: string;
|
|
20
|
+
rows: DatasetRows;
|
|
21
|
+
mode: 'replaceTable';
|
|
22
|
+
} | {
|
|
23
|
+
tableName: string;
|
|
24
|
+
rows: DatasetRows;
|
|
25
|
+
batchId: string;
|
|
26
|
+
mode: 'appendTable';
|
|
27
|
+
};
|
|
28
|
+
type DatasetWriter = (id: string, request: DatasetWriteInput, options?: PermuteRequestOptions) => Promise<CustomDatasetResponse>;
|
|
29
|
+
type DatasetReader = (id: string, options?: PermuteRequestOptions) => Promise<DatasetResponse>;
|
|
30
|
+
export declare class PermuteDataset {
|
|
31
|
+
private readonly writeTables;
|
|
32
|
+
private readonly readDataset;
|
|
33
|
+
readonly type: "custom";
|
|
34
|
+
private snapshot;
|
|
35
|
+
constructor(snapshot: CustomDatasetResponse, writeTables: DatasetWriter, readDataset: DatasetReader);
|
|
36
|
+
get data(): CustomDatasetResponse;
|
|
37
|
+
get id(): string;
|
|
38
|
+
get sourceId(): string;
|
|
39
|
+
get key(): string;
|
|
40
|
+
get name(): string;
|
|
41
|
+
get context(): string[];
|
|
42
|
+
get status(): CustomDatasetResponse['status'];
|
|
43
|
+
get version(): number;
|
|
44
|
+
replace(tables: Record<string, DatasetRows>, options?: PermuteRequestOptions): Promise<this>;
|
|
45
|
+
replaceTable(tableName: string, rows: DatasetRows, options?: PermuteRequestOptions): Promise<this>;
|
|
46
|
+
appendTable(tableName: string, rows: DatasetRows, options: {
|
|
47
|
+
batchId: string;
|
|
48
|
+
} & PermuteRequestOptions): Promise<this>;
|
|
49
|
+
refresh(options?: PermuteRequestOptions): Promise<this>;
|
|
50
|
+
}
|
|
51
|
+
export declare class PermuteFileDataset {
|
|
52
|
+
private readonly readDataset;
|
|
53
|
+
readonly type: "file";
|
|
54
|
+
private snapshot;
|
|
55
|
+
constructor(snapshot: FileDatasetResponse, readDataset: DatasetReader);
|
|
56
|
+
get data(): FileDatasetResponse;
|
|
57
|
+
get id(): string;
|
|
58
|
+
get sourceId(): string;
|
|
59
|
+
get name(): string;
|
|
60
|
+
get status(): FileDatasetResponse['status'];
|
|
61
|
+
refresh(options?: PermuteRequestOptions): Promise<this>;
|
|
62
|
+
}
|
|
63
|
+
export declare class PermuteClient {
|
|
64
|
+
readonly workspaces: {
|
|
65
|
+
list: (options?: PermuteRequestOptions) => Promise<WorkspaceList>;
|
|
66
|
+
create: (request: WorkspaceCreateRequest, options?: PermuteRequestOptions) => Promise<Workspace>;
|
|
67
|
+
get: (workspaceId: string, options?: PermuteRequestOptions) => Promise<Workspace>;
|
|
68
|
+
update: (workspaceId: string, request: WorkspaceUpdateRequest, options?: PermuteRequestOptions) => Promise<Workspace>;
|
|
69
|
+
delete: (workspaceId: string, options?: PermuteRequestOptions) => Promise<WorkspaceDeleteResponse>;
|
|
70
|
+
};
|
|
71
|
+
readonly sources: {
|
|
72
|
+
list: (options?: PermuteRequestOptions) => Promise<SourceList>;
|
|
73
|
+
get: (sourceId: string, options?: PermuteRequestOptions) => Promise<SourceDetail>;
|
|
74
|
+
};
|
|
75
|
+
readonly datasets: {
|
|
76
|
+
create: {
|
|
77
|
+
(request: CustomDatasetCreateRequest, options?: PermuteRequestOptions): Promise<PermuteDataset>;
|
|
78
|
+
(request: FileDatasetCreateRequest, options?: PermuteRequestOptions): Promise<PermuteFileDataset>;
|
|
79
|
+
};
|
|
80
|
+
getByKey: (key: string, options?: PermuteRequestOptions) => Promise<PermuteDataset | PermuteFileDataset>;
|
|
81
|
+
get: (datasetId: string, options?: PermuteRequestOptions) => Promise<PermuteDataset | PermuteFileDataset>;
|
|
82
|
+
};
|
|
83
|
+
private readonly apiKey;
|
|
84
|
+
private readonly baseUrl;
|
|
85
|
+
/** Workspace selected for workspace-scoped API operations. */
|
|
86
|
+
readonly workspaceId?: string;
|
|
87
|
+
private readonly defaultHeaders;
|
|
88
|
+
private readonly fetchImpl;
|
|
89
|
+
constructor(options: PermuteClientOptions);
|
|
90
|
+
search(request: SearchRequest, options?: PermuteRequestOptions): Promise<SearchResponse>;
|
|
91
|
+
answer(request: AnswerRequest, options?: PermuteRequestOptions): Promise<AnswerResponse>;
|
|
92
|
+
answerJobs(request: AnswerRequest, options?: PermuteRequestOptions): Promise<AnswerJobResponse>;
|
|
93
|
+
getAnswerJob(answerJobId: string, options?: PermuteRequestOptions): Promise<AnswerJobResponse>;
|
|
94
|
+
withWorkspace(workspaceId: string): PermuteClient;
|
|
95
|
+
query(request: QueryRequest, options?: PermuteRequestOptions): Promise<QueryResponse>;
|
|
96
|
+
private request;
|
|
97
|
+
private validateRequestBody;
|
|
98
|
+
private validateRequestQuery;
|
|
99
|
+
}
|
|
100
|
+
export {};
|