lemma-sdk 0.2.28 → 0.2.30
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/README.md +113 -233
- package/bin/lemma-sdk.js +108 -0
- package/dist/browser/lemma-client.js +125 -4
- package/dist/client.d.ts +2 -0
- package/dist/client.js +3 -0
- package/dist/config.d.ts +2 -2
- package/dist/config.js +2 -2
- package/dist/datastore-query.d.ts +54 -0
- package/dist/datastore-query.js +157 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/namespaces/datastore.d.ts +9 -0
- package/dist/namespaces/datastore.js +13 -0
- package/dist/namespaces/records.d.ts +1 -1
- package/dist/openapi_client/index.d.ts +4 -0
- package/dist/openapi_client/index.js +1 -0
- package/dist/openapi_client/models/ConvertedArtifactResponse.d.ts +6 -0
- package/dist/openapi_client/models/ConvertedArtifactResponse.js +1 -0
- package/dist/openapi_client/models/ConvertedFileResponse.d.ts +10 -0
- package/dist/openapi_client/models/ConvertedFileResponse.js +1 -0
- package/dist/openapi_client/models/CreateFolderRequest.d.ts +3 -1
- package/dist/openapi_client/models/FlowRunEntity.d.ts +1 -0
- package/dist/openapi_client/models/ScheduledFlowStart.d.ts +3 -6
- package/dist/openapi_client/models/ScheduledFlowStartType.d.ts +4 -0
- package/dist/openapi_client/models/ScheduledFlowStartType.js +9 -0
- package/dist/openapi_client/models/WorkflowInstallRequest.d.ts +5 -0
- package/dist/openapi_client/models/WorkflowTimeInstallConfig.d.ts +19 -0
- package/dist/openapi_client/models/WorkflowTimeInstallConfig.js +1 -0
- package/dist/openapi_client/services/FilesService.d.ts +27 -1
- package/dist/openapi_client/services/FilesService.js +69 -1
- package/dist/openapi_client/services/WorkflowsService.d.ts +1 -1
- package/dist/openapi_client/services/WorkflowsService.js +1 -1
- package/dist/react/assistant-output.d.ts +6 -0
- package/dist/react/assistant-output.js +90 -0
- package/dist/react/index.d.ts +42 -8
- package/dist/react/index.js +21 -4
- package/dist/react/useAgentRun.d.ts +17 -0
- package/dist/react/useAgentRun.js +58 -0
- package/dist/react/useAssistantRun.d.ts +9 -0
- package/dist/react/useAssistantRun.js +19 -9
- package/dist/react/useAssistantSession.d.ts +5 -0
- package/dist/react/useAssistantSession.js +123 -70
- package/dist/react/useBulkRecords.d.ts +20 -0
- package/dist/react/useBulkRecords.js +72 -0
- package/dist/react/useConversation.d.ts +18 -0
- package/dist/react/useConversation.js +59 -0
- package/dist/react/useConversationMessages.d.ts +59 -0
- package/dist/react/useConversationMessages.js +167 -0
- package/dist/react/useConversations.d.ts +48 -0
- package/dist/react/useConversations.js +182 -0
- package/dist/react/useCreateRecord.d.ts +18 -0
- package/dist/react/useCreateRecord.js +58 -0
- package/dist/react/useDeleteRecord.d.ts +21 -0
- package/dist/react/useDeleteRecord.js +59 -0
- package/dist/react/useForeignKeyOptions.d.ts +31 -0
- package/dist/react/useForeignKeyOptions.js +150 -0
- package/dist/react/useJoinedRecords.d.ts +18 -0
- package/dist/react/useJoinedRecords.js +79 -0
- package/dist/react/useMembers.d.ts +22 -0
- package/dist/react/useMembers.js +59 -0
- package/dist/react/useRecord.d.ts +18 -0
- package/dist/react/useRecord.js +64 -0
- package/dist/react/useRecordForm.d.ts +42 -0
- package/dist/react/useRecordForm.js +238 -0
- package/dist/react/useRecordSchema.d.ts +20 -0
- package/dist/react/useRecordSchema.js +24 -0
- package/dist/react/useRecords.d.ts +18 -0
- package/dist/react/useRecords.js +106 -0
- package/dist/react/useRelatedRecords.d.ts +43 -0
- package/dist/react/useRelatedRecords.js +232 -0
- package/dist/react/useReverseRelatedRecords.d.ts +47 -0
- package/dist/react/useReverseRelatedRecords.js +226 -0
- package/dist/react/useSchemaForm.d.ts +24 -0
- package/dist/react/useSchemaForm.js +116 -0
- package/dist/react/useTable.d.ts +16 -0
- package/dist/react/useTable.js +59 -0
- package/dist/react/useTables.d.ts +22 -0
- package/dist/react/useTables.js +71 -0
- package/dist/react/useUpdateRecord.d.ts +21 -0
- package/dist/react/useUpdateRecord.js +62 -0
- package/dist/react/useWorkflowStart.d.ts +33 -0
- package/dist/react/useWorkflowStart.js +155 -0
- package/dist/record-form.d.ts +30 -0
- package/dist/record-form.js +199 -0
- package/dist/schema-form.d.ts +41 -0
- package/dist/schema-form.js +200 -0
- package/dist/types.d.ts +5 -1
- package/package.json +10 -5
- package/dist/react/styles.css +0 -2407
package/README.md
CHANGED
|
@@ -1,294 +1,174 @@
|
|
|
1
|
-
# Lemma TypeScript SDK
|
|
1
|
+
# Lemma TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- Pod-scoped namespaces (`tables`, `records`, `files`, `assistants`,`agents` , `workflows`, `tasks`, .)
|
|
6
|
-
- Built-in auth/session handling
|
|
7
|
-
- SSE streaming helpers
|
|
8
|
-
- React hooks and assistant UI components
|
|
3
|
+
`lemma-sdk` is the headless TypeScript SDK for Lemma. Use `lemma-sdk/react` for hooks and auth primitives, and use the Lemma shadcn registry for stock UI blocks.
|
|
9
4
|
|
|
10
5
|
## Install
|
|
11
6
|
|
|
12
7
|
```bash
|
|
13
|
-
npm
|
|
8
|
+
npm install lemma-sdk
|
|
14
9
|
```
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { LemmaClient } from "lemma-sdk";
|
|
20
|
-
|
|
21
|
-
const client = new LemmaClient({
|
|
22
|
-
apiUrl: "https://api.lemma.work",
|
|
23
|
-
authUrl: "https://auth.lemma.work/auth",
|
|
24
|
-
podId: "<pod-id>",
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
await client.initialize();
|
|
11
|
+
If your app uses shadcn/ui, configure the Lemma registry with:
|
|
28
12
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const supportAssistant = await client.assistants.get("support_assistant");
|
|
13
|
+
```bash
|
|
14
|
+
npx lemma-sdk init-shadcn
|
|
32
15
|
```
|
|
33
16
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
`LemmaClient` config resolution order:
|
|
37
|
-
|
|
38
|
-
1. Constructor overrides
|
|
39
|
-
2. `window.__LEMMA_CONFIG__`
|
|
40
|
-
3. Environment variables
|
|
41
|
-
4. Defaults
|
|
42
|
-
|
|
43
|
-
Supported env keys:
|
|
44
|
-
|
|
45
|
-
- `VITE_LEMMA_API_URL`, `REACT_APP_LEMMA_API_URL`, `LEMMA_API_URL`
|
|
46
|
-
- `VITE_LEMMA_AUTH_URL`, `REACT_APP_LEMMA_AUTH_URL`, `LEMMA_AUTH_URL`
|
|
47
|
-
- `VITE_LEMMA_POD_ID`, `REACT_APP_LEMMA_POD_ID`, `LEMMA_POD_ID`
|
|
48
|
-
|
|
49
|
-
Defaults when unset:
|
|
50
|
-
|
|
51
|
-
- `apiUrl`: `http://localhost:8000`
|
|
52
|
-
- `authUrl`: `http://localhost:3000`
|
|
53
|
-
|
|
54
|
-
## Pod Scoping
|
|
55
|
-
|
|
56
|
-
Most namespaces are pod-scoped. You can set pod scope in three ways:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
client.setPodId("pod_a");
|
|
60
|
-
|
|
61
|
-
const podBClient = client.withPod("pod_b");
|
|
17
|
+
That adds this namespace to your app's `components.json`:
|
|
62
18
|
|
|
63
|
-
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"registries": {
|
|
22
|
+
"@lemma": "https://cdn.jsdelivr.net/gh/gappyai/lemma-typescript@main/public/r/{name}.json"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
64
25
|
```
|
|
65
26
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Common pod-scoped namespaces:
|
|
69
|
-
|
|
70
|
-
- `client.tables`
|
|
71
|
-
- `client.records`
|
|
72
|
-
- `client.files`
|
|
73
|
-
- `client.functions`
|
|
74
|
-
- `client.agents`
|
|
75
|
-
- `client.tasks`
|
|
76
|
-
- `client.assistants`
|
|
77
|
-
- `client.workflows`
|
|
78
|
-
- `client.desks`
|
|
79
|
-
- `client.integrations`
|
|
80
|
-
- `client.resources`
|
|
27
|
+
If your app does not have `components.json` yet, run `npx shadcn@latest init` first or after the command above.
|
|
81
28
|
|
|
82
|
-
|
|
29
|
+
## React Hooks
|
|
83
30
|
|
|
84
|
-
|
|
85
|
-
- `client.icons`
|
|
86
|
-
- `client.pods`
|
|
87
|
-
- `client.podMembers`
|
|
88
|
-
- `client.podJoinRequests`
|
|
89
|
-
- `client.organizations`
|
|
90
|
-
- `client.podSurfaces`
|
|
31
|
+
Install React if your app needs it:
|
|
91
32
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
const result = await client.request("GET", "/models");
|
|
33
|
+
```bash
|
|
34
|
+
npm install react react-dom
|
|
96
35
|
```
|
|
97
36
|
|
|
98
|
-
|
|
37
|
+
`lemma-sdk/react` is intentionally headless-first. It includes hooks plus `AuthGuard`, but not stock assistant or records UI.
|
|
99
38
|
|
|
100
|
-
|
|
39
|
+
```tsx
|
|
40
|
+
import {
|
|
41
|
+
AuthGuard,
|
|
42
|
+
useAgentRun,
|
|
43
|
+
useConversationMessages,
|
|
44
|
+
useConversations,
|
|
45
|
+
useForeignKeyOptions,
|
|
46
|
+
useMembers,
|
|
47
|
+
useRecordForm,
|
|
48
|
+
useRecordSchema,
|
|
49
|
+
useRecords,
|
|
50
|
+
useSchemaForm,
|
|
51
|
+
useTables,
|
|
52
|
+
useWorkflowStart,
|
|
53
|
+
} from "lemma-sdk/react";
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Typical hook groups:
|
|
57
|
+
|
|
58
|
+
- data tables: `useTables`, `useTable`, `useRecords`, `useRecord`, `useRelatedRecords`, `useReverseRelatedRecords`
|
|
59
|
+
- record mutations and forms: `useCreateRecord`, `useUpdateRecord`, `useDeleteRecord`, `useBulkRecords`, `useRecordSchema`, `useRecordForm`, `useSchemaForm`
|
|
60
|
+
- assistant and runs: `useConversation`, `useConversations`, `useConversationMessages`, `useAssistantController`, `useAssistantRun`, `useAgentRun`, `useWorkflowStart`
|
|
61
|
+
- org and auth: `AuthGuard`, `useMembers`
|
|
62
|
+
|
|
63
|
+
Minimal example:
|
|
101
64
|
|
|
102
|
-
```
|
|
103
|
-
|
|
65
|
+
```tsx
|
|
66
|
+
import { LemmaClient } from "lemma-sdk";
|
|
67
|
+
import { AuthGuard, useConversations, useConversationMessages } from "lemma-sdk/react";
|
|
104
68
|
|
|
105
|
-
|
|
106
|
-
title: "Ship docs rewrite",
|
|
107
|
-
status: "todo",
|
|
108
|
-
});
|
|
69
|
+
const client = new LemmaClient({ podId: "<pod-id>" });
|
|
109
70
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
71
|
+
function SupportThread() {
|
|
72
|
+
const conversations = useConversations({
|
|
73
|
+
client,
|
|
74
|
+
podId: "<pod-id>",
|
|
75
|
+
assistantName: "support_assistant",
|
|
76
|
+
});
|
|
115
77
|
|
|
116
|
-
|
|
78
|
+
const thread = useConversationMessages({
|
|
79
|
+
client,
|
|
80
|
+
podId: "<pod-id>",
|
|
81
|
+
conversationId: conversations.effectiveSelectedConversationId,
|
|
82
|
+
});
|
|
117
83
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await client.files.upload(fileBlob, { directoryPath: "/reports", name: "q1.pdf" });
|
|
84
|
+
return <pre>{thread.finalOutputText ?? "No assistant output yet."}</pre>;
|
|
85
|
+
}
|
|
121
86
|
|
|
122
|
-
|
|
123
|
-
|
|
87
|
+
export function App() {
|
|
88
|
+
return (
|
|
89
|
+
<AuthGuard client={client}>
|
|
90
|
+
<SupportThread />
|
|
91
|
+
</AuthGuard>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
124
94
|
```
|
|
125
95
|
|
|
126
|
-
|
|
96
|
+
## Shadcn Registry
|
|
127
97
|
|
|
128
|
-
|
|
129
|
-
await client.assistants.create({
|
|
130
|
-
name: "support_assistant",
|
|
131
|
-
instruction: "Help with support triage.",
|
|
132
|
-
});
|
|
98
|
+
Lemma UI now lives in the registry, not in `lemma-sdk/react`.
|
|
133
99
|
|
|
134
|
-
|
|
135
|
-
title: "Ticket review",
|
|
136
|
-
});
|
|
100
|
+
After running `npx lemma-sdk init-shadcn`, install blocks like:
|
|
137
101
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
102
|
+
```bash
|
|
103
|
+
npx shadcn@latest add @lemma/lemma-records-page
|
|
104
|
+
npx shadcn@latest add @lemma/lemma-assistant-embedded
|
|
105
|
+
npx shadcn@latest add @lemma/lemma-workflow-start-form
|
|
141
106
|
```
|
|
142
107
|
|
|
143
|
-
|
|
108
|
+
Current registry items include:
|
|
144
109
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
110
|
+
- `lemma-assistant-experience`
|
|
111
|
+
- `lemma-assistant-embedded`
|
|
112
|
+
- `lemma-schema-form`
|
|
113
|
+
- `lemma-records-page`
|
|
114
|
+
- `lemma-record-form`
|
|
115
|
+
- `lemma-records-table`
|
|
116
|
+
- `lemma-related-records-table`
|
|
117
|
+
- `lemma-reverse-related-records-table`
|
|
118
|
+
- `lemma-workflow-start-form`
|
|
151
119
|
|
|
152
|
-
|
|
153
|
-
const requests = await client.podJoinRequests.list("pod_123", {
|
|
154
|
-
status: "PENDING",
|
|
155
|
-
limit: 50,
|
|
156
|
-
});
|
|
120
|
+
The registry is currently served from jsDelivr against this public repo:
|
|
157
121
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
org_role: "ORG_MEMBER",
|
|
161
|
-
pod_role: "POD_USER",
|
|
162
|
-
});
|
|
163
|
-
```
|
|
122
|
+
- registry root: `https://cdn.jsdelivr.net/gh/gappyai/lemma-typescript@main/public/r/registry.json`
|
|
123
|
+
- item shape: `https://cdn.jsdelivr.net/gh/gappyai/lemma-typescript@main/public/r/{name}.json`
|
|
164
124
|
|
|
165
|
-
|
|
125
|
+
For more stable installs, prefer pinning the registry URL to a tag or commit SHA instead of `@main`.
|
|
166
126
|
|
|
167
|
-
|
|
127
|
+
## Core Client
|
|
168
128
|
|
|
169
129
|
```ts
|
|
170
|
-
import {
|
|
171
|
-
|
|
172
|
-
const stream = await client.conversations.sendMessageStream(conversationId, {
|
|
173
|
-
content: "Analyze recent incidents",
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
for await (const event of readSSE(stream)) {
|
|
177
|
-
const payload = parseSSEJson(event);
|
|
178
|
-
if (!payload) continue;
|
|
179
|
-
console.log(event.event, payload);
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
Task stream example:
|
|
130
|
+
import { LemmaClient } from "lemma-sdk";
|
|
184
131
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
agent_name: "triage_agent",
|
|
188
|
-
input_data: { ticketId: "TCK-1042" },
|
|
132
|
+
const client = new LemmaClient({
|
|
133
|
+
podId: "<pod-id>",
|
|
189
134
|
});
|
|
190
135
|
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Access Grants (`accessible_tables`)
|
|
195
|
-
|
|
196
|
-
When creating agents/functions/assistants, `accessible_tables` must use object entries:
|
|
197
|
-
|
|
198
|
-
```ts
|
|
199
|
-
import { TableAccessMode } from "lemma-sdk";
|
|
136
|
+
await client.initialize();
|
|
200
137
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
{ table_name: "expense_notes", mode: TableAccessMode.WRITE },
|
|
204
|
-
];
|
|
138
|
+
const tables = await client.tables.list();
|
|
139
|
+
const records = await client.records.list("tickets");
|
|
205
140
|
```
|
|
206
141
|
|
|
207
|
-
`
|
|
142
|
+
Pod-scoped namespaces include `tables`, `records`, `assistants`, `agents`, `workflows`, `functions`, `files`, and `resources`.
|
|
143
|
+
Org and user surfaces include `users`, `organizations`, `pods`, `podMembers`, and `podJoinRequests`.
|
|
208
144
|
|
|
209
145
|
## Auth
|
|
210
146
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
For local browser testing, token injection is supported via local storage key `lemma_token`:
|
|
147
|
+
The SDK uses cookie or session auth by default.
|
|
214
148
|
|
|
215
|
-
|
|
216
|
-
import { setTestingToken, clearTestingToken } from "lemma-sdk";
|
|
217
|
-
|
|
218
|
-
setTestingToken("<access-token>");
|
|
219
|
-
clearTestingToken();
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Auth helpers:
|
|
149
|
+
Useful helpers:
|
|
223
150
|
|
|
224
151
|
- `buildAuthUrl(...)`
|
|
225
152
|
- `buildFederatedLogoutUrl(...)`
|
|
226
153
|
- `resolveSafeRedirectUri(...)`
|
|
227
|
-
- `
|
|
228
|
-
- `
|
|
154
|
+
- `setTestingToken(...)`
|
|
155
|
+
- `clearTestingToken()`
|
|
229
156
|
|
|
230
|
-
|
|
157
|
+
When `client.podId` is set and the signed-in user is not a pod member, `AuthGuard` can render the request-access flow and create or show pod join requests.
|
|
231
158
|
|
|
232
|
-
|
|
159
|
+
## Local Development
|
|
233
160
|
|
|
234
|
-
|
|
161
|
+
From the root of this repository:
|
|
235
162
|
|
|
236
163
|
```bash
|
|
237
|
-
npm
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
Import stylesheet once:
|
|
241
|
-
|
|
242
|
-
```tsx
|
|
243
|
-
import "lemma-sdk/react/styles.css";
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Fastest assistant integration:
|
|
247
|
-
|
|
248
|
-
```tsx
|
|
249
|
-
import { AssistantEmbedded } from "lemma-sdk/react";
|
|
250
|
-
|
|
251
|
-
<div style={{ height: 720, minHeight: 0 }}>
|
|
252
|
-
<AssistantEmbedded
|
|
253
|
-
client={client}
|
|
254
|
-
podId="<pod-id>"
|
|
255
|
-
assistantName="support_assistant"
|
|
256
|
-
title="Support Assistant"
|
|
257
|
-
placeholder="Message Support Assistant"
|
|
258
|
-
showConversationList
|
|
259
|
-
/>
|
|
260
|
-
</div>;
|
|
164
|
+
npm install
|
|
165
|
+
npm run build
|
|
166
|
+
npm run registry:build
|
|
261
167
|
```
|
|
262
168
|
|
|
263
|
-
|
|
169
|
+
This repo includes:
|
|
264
170
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
<App />
|
|
270
|
-
</AuthGuard>;
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
When `client.podId` is set and the signed-in user is not a pod member, `AuthGuard` automatically renders a request-access state and can create/view pod join requests.
|
|
274
|
-
|
|
275
|
-
## Browser Bundle
|
|
276
|
-
|
|
277
|
-
The package also ships a standalone browser bundle:
|
|
278
|
-
|
|
279
|
-
- npm artifact path: `dist/browser/lemma-client.js`
|
|
280
|
-
- export path: `lemma-sdk/browser-bundle`
|
|
281
|
-
- global: `window.LemmaClient.LemmaClient`
|
|
282
|
-
|
|
283
|
-
Example:
|
|
284
|
-
|
|
285
|
-
```html
|
|
286
|
-
<script src="https://unpkg.com/lemma-sdk@latest/dist/browser/lemma-client.js"></script>
|
|
287
|
-
<script>
|
|
288
|
-
const client = new window.LemmaClient.LemmaClient({
|
|
289
|
-
apiUrl: "https://api.lemma.work",
|
|
290
|
-
authUrl: "https://auth.lemma.work/auth",
|
|
291
|
-
podId: "<pod-id>"
|
|
292
|
-
});
|
|
293
|
-
</script>
|
|
294
|
-
```
|
|
171
|
+
- `registry.json` for registry source definitions
|
|
172
|
+
- `public/r` for the generated flat registry output
|
|
173
|
+
- `.github/workflows/deploy-registry-pages.yml` for GitHub Pages deployment
|
|
174
|
+
- `.github/workflows/publish-npm.yml` for npm publishing
|
package/bin/lemma-sdk.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
const SHADCN_SCHEMA_URL = "https://ui.shadcn.com/schema.json";
|
|
7
|
+
const LEMMA_REGISTRY_URL =
|
|
8
|
+
"https://cdn.jsdelivr.net/gh/gappyai/lemma-typescript@main/public/r/{name}.json";
|
|
9
|
+
|
|
10
|
+
function printUsage() {
|
|
11
|
+
console.log(`Usage:
|
|
12
|
+
lemma-sdk init-shadcn
|
|
13
|
+
|
|
14
|
+
Commands:
|
|
15
|
+
init-shadcn Add the @lemma shadcn registry to components.json in the current directory.`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function fail(message) {
|
|
19
|
+
console.error(`lemma-sdk: ${message}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function ensureObject(value, label) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
25
|
+
fail(`${label} must be a JSON object.`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function loadComponentsConfig(configPath) {
|
|
32
|
+
if (!existsSync(configPath)) {
|
|
33
|
+
return {
|
|
34
|
+
config: {
|
|
35
|
+
$schema: SHADCN_SCHEMA_URL,
|
|
36
|
+
registries: {},
|
|
37
|
+
},
|
|
38
|
+
existed: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let parsed;
|
|
43
|
+
try {
|
|
44
|
+
parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
|
45
|
+
} catch (error) {
|
|
46
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
+
fail(`Could not parse ${configPath}: ${message}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const config = ensureObject(parsed, "components.json");
|
|
51
|
+
|
|
52
|
+
if (config.$schema == null) {
|
|
53
|
+
config.$schema = SHADCN_SCHEMA_URL;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (config.registries == null) {
|
|
57
|
+
config.registries = {};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ensureObject(config.registries, "components.json registries");
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
config,
|
|
64
|
+
existed: true,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function writeComponentsConfig(configPath, config) {
|
|
69
|
+
writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function initShadcn() {
|
|
73
|
+
const configPath = resolve(process.cwd(), "components.json");
|
|
74
|
+
const { config, existed } = loadComponentsConfig(configPath);
|
|
75
|
+
|
|
76
|
+
const currentUrl = config.registries["@lemma"];
|
|
77
|
+
const alreadyConfigured = currentUrl === LEMMA_REGISTRY_URL;
|
|
78
|
+
|
|
79
|
+
config.registries["@lemma"] = LEMMA_REGISTRY_URL;
|
|
80
|
+
writeComponentsConfig(configPath, config);
|
|
81
|
+
|
|
82
|
+
if (alreadyConfigured) {
|
|
83
|
+
console.log(`@lemma is already configured in ${configPath}`);
|
|
84
|
+
} else if (existed) {
|
|
85
|
+
console.log(`Added @lemma registry to ${configPath}`);
|
|
86
|
+
} else {
|
|
87
|
+
console.log(`Created ${configPath} with the @lemma registry`);
|
|
88
|
+
console.log("If you have not initialized shadcn yet, run: npx shadcn@latest init");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log(`Registry URL: ${LEMMA_REGISTRY_URL}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const command = process.argv[2];
|
|
95
|
+
|
|
96
|
+
switch (command) {
|
|
97
|
+
case "init-shadcn":
|
|
98
|
+
initShadcn();
|
|
99
|
+
break;
|
|
100
|
+
case "-h":
|
|
101
|
+
case "--help":
|
|
102
|
+
case "help":
|
|
103
|
+
case undefined:
|
|
104
|
+
printUsage();
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
fail(`Unknown command "${command}". Run "lemma-sdk --help" for usage.`);
|
|
108
|
+
}
|
|
@@ -55,6 +55,7 @@ const tables_js_1 = require("./namespaces/tables.js");
|
|
|
55
55
|
const tasks_js_1 = require("./namespaces/tasks.js");
|
|
56
56
|
const users_js_1 = require("./namespaces/users.js");
|
|
57
57
|
const workflows_js_1 = require("./namespaces/workflows.js");
|
|
58
|
+
const datastore_js_1 = require("./namespaces/datastore.js");
|
|
58
59
|
class LemmaClient {
|
|
59
60
|
constructor(overrides = {}, internalOptions = {}) {
|
|
60
61
|
this._config = (0, config_js_1.resolveConfig)(overrides);
|
|
@@ -81,6 +82,7 @@ class LemmaClient {
|
|
|
81
82
|
this.desks = new desks_js_1.DesksNamespace(this._generated, this._http, podIdFn);
|
|
82
83
|
this.integrations = new integrations_js_1.IntegrationsNamespace(this._generated);
|
|
83
84
|
this.resources = new resources_js_1.ResourcesNamespace(this._http);
|
|
85
|
+
this.datastore = new datastore_js_1.DatastoreNamespace(this._generated, podIdFn);
|
|
84
86
|
this.users = new users_js_1.UsersNamespace(this._generated);
|
|
85
87
|
this.icons = new icons_js_1.IconsNamespace(this._generated);
|
|
86
88
|
this.pods = new pods_js_1.PodsNamespace(this._generated, this._http);
|
|
@@ -164,11 +166,11 @@ function resolveConfig(overrides = {}) {
|
|
|
164
166
|
const apiUrl = overrides.apiUrl ??
|
|
165
167
|
win.apiUrl ??
|
|
166
168
|
fromEnv("API_URL") ??
|
|
167
|
-
"
|
|
169
|
+
"https://api.asur.work";
|
|
168
170
|
const authUrl = overrides.authUrl ??
|
|
169
171
|
win.authUrl ??
|
|
170
172
|
fromEnv("AUTH_URL") ??
|
|
171
|
-
"
|
|
173
|
+
"https://auth.asur.work";
|
|
172
174
|
const podId = overrides.podId ??
|
|
173
175
|
win.podId ??
|
|
174
176
|
fromEnv("POD_ID");
|
|
@@ -2125,7 +2127,7 @@ class FilesService {
|
|
|
2125
2127
|
});
|
|
2126
2128
|
}
|
|
2127
2129
|
/**
|
|
2128
|
-
* Delete File Or Folder
|
|
2130
|
+
* Delete File Or Folder
|
|
2129
2131
|
* @param podId
|
|
2130
2132
|
* @param path
|
|
2131
2133
|
* @returns DatastoreMessageResponse Successful Response
|
|
@@ -2189,6 +2191,74 @@ class FilesService {
|
|
|
2189
2191
|
},
|
|
2190
2192
|
});
|
|
2191
2193
|
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Get Converted File Metadata
|
|
2196
|
+
* @param podId
|
|
2197
|
+
* @param path
|
|
2198
|
+
* @returns ConvertedFileResponse Successful Response
|
|
2199
|
+
* @throws ApiError
|
|
2200
|
+
*/
|
|
2201
|
+
static fileConvertedGet(podId, path) {
|
|
2202
|
+
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2203
|
+
method: 'GET',
|
|
2204
|
+
url: '/pods/{pod_id}/datastore/files/converted/by-path',
|
|
2205
|
+
path: {
|
|
2206
|
+
'pod_id': podId,
|
|
2207
|
+
},
|
|
2208
|
+
query: {
|
|
2209
|
+
'path': path,
|
|
2210
|
+
},
|
|
2211
|
+
errors: {
|
|
2212
|
+
422: `Validation Error`,
|
|
2213
|
+
},
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
/**
|
|
2217
|
+
* Download Converted File Artifact
|
|
2218
|
+
* @param podId
|
|
2219
|
+
* @param path
|
|
2220
|
+
* @param artifact
|
|
2221
|
+
* @returns any Successful Response
|
|
2222
|
+
* @throws ApiError
|
|
2223
|
+
*/
|
|
2224
|
+
static fileConvertedDownload(podId, path, artifact = 'document.md') {
|
|
2225
|
+
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2226
|
+
method: 'GET',
|
|
2227
|
+
url: '/pods/{pod_id}/datastore/files/converted/download',
|
|
2228
|
+
path: {
|
|
2229
|
+
'pod_id': podId,
|
|
2230
|
+
},
|
|
2231
|
+
query: {
|
|
2232
|
+
'path': path,
|
|
2233
|
+
'artifact': artifact,
|
|
2234
|
+
},
|
|
2235
|
+
errors: {
|
|
2236
|
+
422: `Validation Error`,
|
|
2237
|
+
},
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Render Converted File As HTML
|
|
2242
|
+
* @param podId
|
|
2243
|
+
* @param path
|
|
2244
|
+
* @returns any Successful Response
|
|
2245
|
+
* @throws ApiError
|
|
2246
|
+
*/
|
|
2247
|
+
static fileConvertedRender(podId, path) {
|
|
2248
|
+
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2249
|
+
method: 'GET',
|
|
2250
|
+
url: '/pods/{pod_id}/datastore/files/converted/render',
|
|
2251
|
+
path: {
|
|
2252
|
+
'pod_id': podId,
|
|
2253
|
+
},
|
|
2254
|
+
query: {
|
|
2255
|
+
'path': path,
|
|
2256
|
+
},
|
|
2257
|
+
errors: {
|
|
2258
|
+
422: `Validation Error`,
|
|
2259
|
+
},
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2192
2262
|
/**
|
|
2193
2263
|
* Download File
|
|
2194
2264
|
* @param podId
|
|
@@ -4929,7 +4999,7 @@ class WorkflowsService {
|
|
|
4929
4999
|
}
|
|
4930
5000
|
/**
|
|
4931
5001
|
* Install Workflow
|
|
4932
|
-
* Install a workflow for runtime execution. Provide `account_id` when the workflow needs an integration account binding.
|
|
5002
|
+
* Install a workflow for runtime execution. Provide `account_id` when the workflow needs an integration account binding, and provide `schedule` when installing a scheduled workflow.
|
|
4933
5003
|
* @param podId
|
|
4934
5004
|
* @param workflowName
|
|
4935
5005
|
* @param requestBody
|
|
@@ -5022,6 +5092,57 @@ class WorkflowsService {
|
|
|
5022
5092
|
}
|
|
5023
5093
|
exports.WorkflowsService = WorkflowsService;
|
|
5024
5094
|
|
|
5095
|
+
},
|
|
5096
|
+
"./namespaces/datastore.js": function (module, exports, require) {
|
|
5097
|
+
"use strict";
|
|
5098
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5099
|
+
exports.DatastoreNamespace = void 0;
|
|
5100
|
+
const QueryService_js_1 = require("./openapi_client/services/QueryService.js");
|
|
5101
|
+
class DatastoreNamespace {
|
|
5102
|
+
constructor(client, podId) {
|
|
5103
|
+
this.client = client;
|
|
5104
|
+
this.podId = podId;
|
|
5105
|
+
}
|
|
5106
|
+
query(request) {
|
|
5107
|
+
const payload = typeof request === "string" ? { query: request } : request;
|
|
5108
|
+
return this.client.request(() => QueryService_js_1.QueryService.queryExecute(this.podId(), payload));
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
exports.DatastoreNamespace = DatastoreNamespace;
|
|
5112
|
+
|
|
5113
|
+
},
|
|
5114
|
+
"./openapi_client/services/QueryService.js": function (module, exports, require) {
|
|
5115
|
+
"use strict";
|
|
5116
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5117
|
+
exports.QueryService = void 0;
|
|
5118
|
+
const OpenAPI_js_1 = require("./openapi_client/core/OpenAPI.js");
|
|
5119
|
+
const request_js_1 = require("./openapi_client/core/request.js");
|
|
5120
|
+
class QueryService {
|
|
5121
|
+
/**
|
|
5122
|
+
* Execute Query
|
|
5123
|
+
* Execute a read-only SQL query inside the datastore schema. Joins, aggregates, subqueries, and cross-table reads are allowed as long as the statement is read only.
|
|
5124
|
+
* @param podId
|
|
5125
|
+
* @param requestBody
|
|
5126
|
+
* @returns DatastoreQueryResponse Successful Response
|
|
5127
|
+
* @throws ApiError
|
|
5128
|
+
*/
|
|
5129
|
+
static queryExecute(podId, requestBody) {
|
|
5130
|
+
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
5131
|
+
method: 'POST',
|
|
5132
|
+
url: '/pods/{pod_id}/datastore/query',
|
|
5133
|
+
path: {
|
|
5134
|
+
'pod_id': podId,
|
|
5135
|
+
},
|
|
5136
|
+
body: requestBody,
|
|
5137
|
+
mediaType: 'application/json',
|
|
5138
|
+
errors: {
|
|
5139
|
+
422: `Validation Error`,
|
|
5140
|
+
},
|
|
5141
|
+
});
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5144
|
+
exports.QueryService = QueryService;
|
|
5145
|
+
|
|
5025
5146
|
}
|
|
5026
5147
|
};
|
|
5027
5148
|
|