lemma-sdk 0.2.28 → 0.2.31
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 +241 -201
- 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/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 +62 -8
- package/dist/react/index.js +31 -4
- package/dist/react/useAgentInputSchema.d.ts +19 -0
- package/dist/react/useAgentInputSchema.js +73 -0
- package/dist/react/useAgentRun.d.ts +17 -0
- package/dist/react/useAgentRun.js +56 -0
- package/dist/react/useAgentRuns.d.ts +33 -0
- package/dist/react/useAgentRuns.js +149 -0
- package/dist/react/useAssistantRun.d.ts +9 -0
- package/dist/react/useAssistantRun.js +28 -17
- package/dist/react/useAssistantSession.d.ts +5 -0
- package/dist/react/useAssistantSession.js +135 -86
- package/dist/react/useBulkRecords.d.ts +20 -0
- package/dist/react/useBulkRecords.js +65 -0
- package/dist/react/useConversation.d.ts +18 -0
- package/dist/react/useConversation.js +75 -0
- package/dist/react/useConversationMessages.d.ts +59 -0
- package/dist/react/useConversationMessages.js +167 -0
- package/dist/react/useConversations.d.ts +52 -0
- package/dist/react/useConversations.js +228 -0
- package/dist/react/useCreateRecord.d.ts +18 -0
- package/dist/react/useCreateRecord.js +51 -0
- package/dist/react/useCurrentUser.d.ts +14 -0
- package/dist/react/useCurrentUser.js +68 -0
- package/dist/react/useDeleteRecord.d.ts +21 -0
- package/dist/react/useDeleteRecord.js +52 -0
- package/dist/react/useFlowRunHistory.js +1 -5
- package/dist/react/useFlowSession.js +41 -33
- package/dist/react/useForeignKeyOptions.d.ts +31 -0
- package/dist/react/useForeignKeyOptions.js +161 -0
- package/dist/react/useFunctionRun.d.ts +19 -0
- package/dist/react/useFunctionRun.js +30 -0
- package/dist/react/useFunctionRuns.d.ts +33 -0
- package/dist/react/useFunctionRuns.js +149 -0
- package/dist/react/useFunctionSession.js +37 -29
- package/dist/react/useJoinedRecords.d.ts +18 -0
- package/dist/react/useJoinedRecords.js +80 -0
- package/dist/react/useMembers.d.ts +26 -0
- package/dist/react/useMembers.js +98 -0
- package/dist/react/useOrganizationMembers.d.ts +26 -0
- package/dist/react/useOrganizationMembers.js +113 -0
- package/dist/react/usePodAccess.d.ts +22 -0
- package/dist/react/usePodAccess.js +128 -0
- package/dist/react/useRecord.d.ts +18 -0
- package/dist/react/useRecord.js +75 -0
- package/dist/react/useRecordForm.d.ts +42 -0
- package/dist/react/useRecordForm.js +221 -0
- package/dist/react/useRecordSchema.d.ts +20 -0
- package/dist/react/useRecordSchema.js +24 -0
- package/dist/react/useRecords.d.ts +20 -0
- package/dist/react/useRecords.js +146 -0
- package/dist/react/useRelatedRecords.d.ts +43 -0
- package/dist/react/useRelatedRecords.js +239 -0
- package/dist/react/useReverseRelatedRecords.d.ts +47 -0
- package/dist/react/useReverseRelatedRecords.js +235 -0
- package/dist/react/useSchemaForm.d.ts +24 -0
- package/dist/react/useSchemaForm.js +104 -0
- package/dist/react/useTable.d.ts +16 -0
- package/dist/react/useTable.js +70 -0
- package/dist/react/useTables.d.ts +26 -0
- package/dist/react/useTables.js +113 -0
- package/dist/react/useTaskSession.js +11 -22
- package/dist/react/useUpdateRecord.d.ts +21 -0
- package/dist/react/useUpdateRecord.js +55 -0
- package/dist/react/useWorkflowResume.d.ts +18 -0
- package/dist/react/useWorkflowResume.js +45 -0
- package/dist/react/useWorkflowRun.d.ts +21 -0
- package/dist/react/useWorkflowRun.js +49 -0
- package/dist/react/useWorkflowRuns.d.ts +33 -0
- package/dist/react/useWorkflowRuns.js +149 -0
- package/dist/react/useWorkflowStart.d.ts +33 -0
- package/dist/react/useWorkflowStart.js +148 -0
- package/dist/react/utils.d.ts +5 -0
- package/dist/react/utils.js +25 -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 +6 -1
- package/package.json +11 -8
- package/dist/react/components/AssistantChrome.d.ts +0 -86
- package/dist/react/components/AssistantChrome.js +0 -48
- package/dist/react/components/AssistantEmbedded.d.ts +0 -10
- package/dist/react/components/AssistantEmbedded.js +0 -15
- package/dist/react/components/AssistantExperience.d.ts +0 -96
- package/dist/react/components/AssistantExperience.js +0 -1294
- package/dist/react/components/assistant-types.d.ts +0 -80
- package/dist/react/styles.css +0 -2407
- /package/dist/{react/components/assistant-types.js → openapi_client/models/ConvertedArtifactResponse.js} +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { parseForeignKeyReference } from "./datastore-query.js";
|
|
2
|
+
import { DatastoreDataType } from "./types.js";
|
|
3
|
+
function sentenceCase(value) {
|
|
4
|
+
return value
|
|
5
|
+
.replace(/_/g, " ")
|
|
6
|
+
.replace(/\s+/g, " ")
|
|
7
|
+
.trim()
|
|
8
|
+
.replace(/\b\w/g, (match) => match.toUpperCase());
|
|
9
|
+
}
|
|
10
|
+
function isBlank(value) {
|
|
11
|
+
return value === null || typeof value === "undefined" || (typeof value === "string" && value.trim() === "");
|
|
12
|
+
}
|
|
13
|
+
function isIntegerLike(value) {
|
|
14
|
+
return Number.isInteger(value);
|
|
15
|
+
}
|
|
16
|
+
function getRawColumnDefault(column) {
|
|
17
|
+
return column.default;
|
|
18
|
+
}
|
|
19
|
+
function shouldUseTextarea(column) {
|
|
20
|
+
if (typeof column.max_length === "number" && column.max_length >= 240) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return /(description|content|body|note|instruction|summary|message)/i.test(column.name);
|
|
24
|
+
}
|
|
25
|
+
function toDateInputValue(value) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
return value.includes("T") ? value.slice(0, 10) : value;
|
|
28
|
+
}
|
|
29
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
30
|
+
return value.toISOString().slice(0, 10);
|
|
31
|
+
}
|
|
32
|
+
return String(value);
|
|
33
|
+
}
|
|
34
|
+
function toDateTimeLocalInputValue(value) {
|
|
35
|
+
if (typeof value === "string") {
|
|
36
|
+
const timestamp = new Date(value);
|
|
37
|
+
if (!Number.isNaN(timestamp.getTime())) {
|
|
38
|
+
const pad = (part) => String(part).padStart(2, "0");
|
|
39
|
+
return [
|
|
40
|
+
timestamp.getFullYear(),
|
|
41
|
+
pad(timestamp.getMonth() + 1),
|
|
42
|
+
pad(timestamp.getDate()),
|
|
43
|
+
].join("-") + `T${pad(timestamp.getHours())}:${pad(timestamp.getMinutes())}`;
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
48
|
+
const pad = (part) => String(part).padStart(2, "0");
|
|
49
|
+
return [
|
|
50
|
+
value.getFullYear(),
|
|
51
|
+
pad(value.getMonth() + 1),
|
|
52
|
+
pad(value.getDate()),
|
|
53
|
+
].join("-") + `T${pad(value.getHours())}:${pad(value.getMinutes())}`;
|
|
54
|
+
}
|
|
55
|
+
return String(value);
|
|
56
|
+
}
|
|
57
|
+
export function getRecordFieldKind(column) {
|
|
58
|
+
if (column.foreign_key?.references)
|
|
59
|
+
return "foreign-key";
|
|
60
|
+
if (column.type === DatastoreDataType.ENUM)
|
|
61
|
+
return "select";
|
|
62
|
+
if (column.type === DatastoreDataType.BOOLEAN)
|
|
63
|
+
return "boolean";
|
|
64
|
+
if (column.type === DatastoreDataType.JSON || column.type === DatastoreDataType.VECTOR)
|
|
65
|
+
return "json";
|
|
66
|
+
if (column.type === DatastoreDataType.INTEGER
|
|
67
|
+
|| column.type === DatastoreDataType.FLOAT
|
|
68
|
+
|| column.type === DatastoreDataType.SERIAL) {
|
|
69
|
+
return "number";
|
|
70
|
+
}
|
|
71
|
+
if (column.type === DatastoreDataType.DATE)
|
|
72
|
+
return "date";
|
|
73
|
+
if (column.type === DatastoreDataType.DATETIME)
|
|
74
|
+
return "datetime";
|
|
75
|
+
if (column.type === DatastoreDataType.UUID)
|
|
76
|
+
return "uuid";
|
|
77
|
+
if (column.type === DatastoreDataType.TEXT && shouldUseTextarea(column))
|
|
78
|
+
return "textarea";
|
|
79
|
+
return "text";
|
|
80
|
+
}
|
|
81
|
+
export function buildRecordSchemaFields(table) {
|
|
82
|
+
return table.columns.map((column) => {
|
|
83
|
+
const foreignKey = column.foreign_key?.references
|
|
84
|
+
? parseForeignKeyReference(column.foreign_key.references)
|
|
85
|
+
: null;
|
|
86
|
+
return {
|
|
87
|
+
name: column.name,
|
|
88
|
+
label: sentenceCase(column.name),
|
|
89
|
+
kind: getRecordFieldKind(column),
|
|
90
|
+
column,
|
|
91
|
+
required: column.required === true,
|
|
92
|
+
readOnly: column.system === true || column.computed === true || column.auto === true,
|
|
93
|
+
system: column.system === true,
|
|
94
|
+
computed: column.computed === true,
|
|
95
|
+
auto: column.auto === true,
|
|
96
|
+
options: column.options ?? [],
|
|
97
|
+
foreignKey,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export function getEditableRecordFields(table) {
|
|
102
|
+
return buildRecordSchemaFields(table).filter((field) => !field.readOnly);
|
|
103
|
+
}
|
|
104
|
+
export function formatRecordValueForForm(column, value) {
|
|
105
|
+
const kind = getRecordFieldKind(column);
|
|
106
|
+
if (value === null || typeof value === "undefined") {
|
|
107
|
+
if (kind === "boolean")
|
|
108
|
+
return false;
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
111
|
+
if (kind === "boolean") {
|
|
112
|
+
return Boolean(value);
|
|
113
|
+
}
|
|
114
|
+
if (kind === "json") {
|
|
115
|
+
if (typeof value === "string")
|
|
116
|
+
return value;
|
|
117
|
+
try {
|
|
118
|
+
return JSON.stringify(value, null, 2);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return String(value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (kind === "date") {
|
|
125
|
+
return toDateInputValue(value);
|
|
126
|
+
}
|
|
127
|
+
if (kind === "datetime") {
|
|
128
|
+
return toDateTimeLocalInputValue(value);
|
|
129
|
+
}
|
|
130
|
+
if (kind === "number") {
|
|
131
|
+
return String(value);
|
|
132
|
+
}
|
|
133
|
+
return String(value);
|
|
134
|
+
}
|
|
135
|
+
export function buildRecordFormValues(table, values = {}) {
|
|
136
|
+
const next = {};
|
|
137
|
+
buildRecordSchemaFields(table).forEach((field) => {
|
|
138
|
+
const provided = values[field.name];
|
|
139
|
+
const rawDefault = getRawColumnDefault(field.column);
|
|
140
|
+
const source = typeof provided !== "undefined" ? provided : rawDefault;
|
|
141
|
+
next[field.name] = formatRecordValueForForm(field.column, source);
|
|
142
|
+
});
|
|
143
|
+
return next;
|
|
144
|
+
}
|
|
145
|
+
function coerceEmptyValue(mode, name, target) {
|
|
146
|
+
if (mode === "update") {
|
|
147
|
+
target[name] = null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function buildRecordPayload(table, values, options = {}) {
|
|
151
|
+
const mode = options.mode ?? "create";
|
|
152
|
+
const data = {};
|
|
153
|
+
const errors = {};
|
|
154
|
+
getEditableRecordFields(table).forEach((field) => {
|
|
155
|
+
const rawValue = values[field.name];
|
|
156
|
+
const value = typeof rawValue === "string" ? rawValue : rawValue;
|
|
157
|
+
if (field.kind === "boolean") {
|
|
158
|
+
data[field.name] = Boolean(rawValue);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (isBlank(value)) {
|
|
162
|
+
if (field.required) {
|
|
163
|
+
errors[field.name] = `${field.label} is required.`;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
coerceEmptyValue(mode, field.name, data);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (field.kind === "number") {
|
|
170
|
+
const parsed = Number(value);
|
|
171
|
+
if (!Number.isFinite(parsed)) {
|
|
172
|
+
errors[field.name] = `${field.label} must be a valid number.`;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if ((field.column.type === DatastoreDataType.INTEGER || field.column.type === DatastoreDataType.SERIAL)
|
|
176
|
+
&& !isIntegerLike(parsed)) {
|
|
177
|
+
errors[field.name] = `${field.label} must be a whole number.`;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
data[field.name] = parsed;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (field.kind === "json") {
|
|
184
|
+
try {
|
|
185
|
+
data[field.name] = typeof value === "string" ? JSON.parse(value) : value;
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
errors[field.name] = `${field.label} must be valid JSON.`;
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
data[field.name] = typeof value === "string" ? value : String(value);
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
data,
|
|
196
|
+
errors,
|
|
197
|
+
isValid: Object.keys(errors).length === 0,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type JsonSchemaPrimitiveType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
2
|
+
export interface JsonSchemaLike {
|
|
3
|
+
type?: JsonSchemaPrimitiveType | JsonSchemaPrimitiveType[];
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
format?: string;
|
|
7
|
+
default?: unknown;
|
|
8
|
+
enum?: unknown[];
|
|
9
|
+
properties?: Record<string, JsonSchemaLike>;
|
|
10
|
+
required?: string[];
|
|
11
|
+
items?: JsonSchemaLike;
|
|
12
|
+
anyOf?: JsonSchemaLike[];
|
|
13
|
+
oneOf?: JsonSchemaLike[];
|
|
14
|
+
allOf?: JsonSchemaLike[];
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export type SchemaFormFieldKind = "text" | "textarea" | "number" | "boolean" | "select" | "json" | "date" | "datetime" | "email";
|
|
18
|
+
export interface SchemaFormField {
|
|
19
|
+
name: string;
|
|
20
|
+
label: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
required: boolean;
|
|
23
|
+
kind: SchemaFormFieldKind;
|
|
24
|
+
type: JsonSchemaPrimitiveType | "unknown";
|
|
25
|
+
format?: string;
|
|
26
|
+
options: Array<{
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}>;
|
|
30
|
+
defaultValue?: unknown;
|
|
31
|
+
schema: JsonSchemaLike;
|
|
32
|
+
}
|
|
33
|
+
export interface BuildSchemaFormPayloadResult {
|
|
34
|
+
data: Record<string, unknown>;
|
|
35
|
+
errors: Record<string, string>;
|
|
36
|
+
isValid: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function buildSchemaFormFields(schema: JsonSchemaLike | null | undefined, uiSchema?: Record<string, unknown> | null): SchemaFormField[];
|
|
39
|
+
export declare function formatSchemaFieldValueForForm(field: SchemaFormField, value: unknown): unknown;
|
|
40
|
+
export declare function buildSchemaFormValues(schema: JsonSchemaLike | null | undefined, values?: Record<string, unknown>, uiSchema?: Record<string, unknown> | null): Record<string, unknown>;
|
|
41
|
+
export declare function buildSchemaFormPayload(schema: JsonSchemaLike | null | undefined, values: Record<string, unknown>, uiSchema?: Record<string, unknown> | null): BuildSchemaFormPayloadResult;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
function sentenceCase(value) {
|
|
2
|
+
return value
|
|
3
|
+
.replace(/_/g, " ")
|
|
4
|
+
.replace(/\s+/g, " ")
|
|
5
|
+
.trim()
|
|
6
|
+
.replace(/\b\w/g, (match) => match.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
function isBlank(value) {
|
|
12
|
+
return value === null || typeof value === "undefined" || (typeof value === "string" && value.trim() === "");
|
|
13
|
+
}
|
|
14
|
+
function normalizeSchemaType(schema) {
|
|
15
|
+
if (Array.isArray(schema.type)) {
|
|
16
|
+
const nonNull = schema.type.find((entry) => entry !== "null");
|
|
17
|
+
return nonNull ?? "unknown";
|
|
18
|
+
}
|
|
19
|
+
if (typeof schema.type === "string") {
|
|
20
|
+
return schema.type;
|
|
21
|
+
}
|
|
22
|
+
if (schema.enum?.length) {
|
|
23
|
+
return "string";
|
|
24
|
+
}
|
|
25
|
+
if (schema.properties && isRecord(schema.properties)) {
|
|
26
|
+
return "object";
|
|
27
|
+
}
|
|
28
|
+
if (schema.items) {
|
|
29
|
+
return "array";
|
|
30
|
+
}
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
function getSchemaFieldKind(schema) {
|
|
34
|
+
if (schema.enum?.length)
|
|
35
|
+
return "select";
|
|
36
|
+
const type = normalizeSchemaType(schema);
|
|
37
|
+
const format = typeof schema.format === "string" ? schema.format : undefined;
|
|
38
|
+
if (type === "boolean")
|
|
39
|
+
return "boolean";
|
|
40
|
+
if (type === "number" || type === "integer")
|
|
41
|
+
return "number";
|
|
42
|
+
if (format === "date")
|
|
43
|
+
return "date";
|
|
44
|
+
if (format === "date-time")
|
|
45
|
+
return "datetime";
|
|
46
|
+
if (format === "email")
|
|
47
|
+
return "email";
|
|
48
|
+
if (type === "object" || type === "array")
|
|
49
|
+
return "json";
|
|
50
|
+
if (format === "textarea")
|
|
51
|
+
return "textarea";
|
|
52
|
+
const title = `${schema.title ?? ""} ${schema.description ?? ""}`.toLowerCase();
|
|
53
|
+
if (/(description|body|content|message|note|summary|instructions)/.test(title)) {
|
|
54
|
+
return "textarea";
|
|
55
|
+
}
|
|
56
|
+
return "text";
|
|
57
|
+
}
|
|
58
|
+
function formatDateInputValue(value) {
|
|
59
|
+
if (typeof value === "string") {
|
|
60
|
+
return value.includes("T") ? value.slice(0, 10) : value;
|
|
61
|
+
}
|
|
62
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
63
|
+
return value.toISOString().slice(0, 10);
|
|
64
|
+
}
|
|
65
|
+
return String(value);
|
|
66
|
+
}
|
|
67
|
+
function formatDateTimeLocalInputValue(value) {
|
|
68
|
+
const date = value instanceof Date ? value : new Date(String(value));
|
|
69
|
+
if (Number.isNaN(date.getTime())) {
|
|
70
|
+
return String(value);
|
|
71
|
+
}
|
|
72
|
+
const pad = (part) => String(part).padStart(2, "0");
|
|
73
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
74
|
+
}
|
|
75
|
+
export function buildSchemaFormFields(schema, uiSchema) {
|
|
76
|
+
if (!schema || !isRecord(schema.properties))
|
|
77
|
+
return [];
|
|
78
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
79
|
+
const order = Array.isArray(uiSchema?.["ui:order"])
|
|
80
|
+
? (uiSchema?.["ui:order"]).filter((entry) => typeof entry === "string")
|
|
81
|
+
: [];
|
|
82
|
+
const orderIndex = new Map(order.map((name, index) => [name, index]));
|
|
83
|
+
const fields = Object.entries(schema.properties).map(([name, propertySchema]) => {
|
|
84
|
+
const property = isRecord(propertySchema) ? propertySchema : {};
|
|
85
|
+
const uiFieldConfig = isRecord(uiSchema?.[name]) ? uiSchema?.[name] : {};
|
|
86
|
+
const widget = typeof uiFieldConfig["ui:widget"] === "string" ? uiFieldConfig["ui:widget"] : undefined;
|
|
87
|
+
const kind = widget === "textarea" ? "textarea" : getSchemaFieldKind(property);
|
|
88
|
+
return {
|
|
89
|
+
name,
|
|
90
|
+
label: typeof property.title === "string" && property.title.trim().length > 0
|
|
91
|
+
? property.title
|
|
92
|
+
: sentenceCase(name),
|
|
93
|
+
description: typeof property.description === "string" ? property.description : undefined,
|
|
94
|
+
required: required.includes(name),
|
|
95
|
+
kind,
|
|
96
|
+
type: normalizeSchemaType(property),
|
|
97
|
+
format: typeof property.format === "string" ? property.format : undefined,
|
|
98
|
+
options: (property.enum ?? []).map((value) => ({
|
|
99
|
+
label: typeof value === "string" ? value : JSON.stringify(value),
|
|
100
|
+
value: typeof value === "string" ? value : JSON.stringify(value),
|
|
101
|
+
})),
|
|
102
|
+
defaultValue: property.default,
|
|
103
|
+
schema: property,
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
return fields.sort((left, right) => {
|
|
107
|
+
const leftIndex = orderIndex.get(left.name);
|
|
108
|
+
const rightIndex = orderIndex.get(right.name);
|
|
109
|
+
if (typeof leftIndex === "number" && typeof rightIndex === "number") {
|
|
110
|
+
return leftIndex - rightIndex;
|
|
111
|
+
}
|
|
112
|
+
if (typeof leftIndex === "number")
|
|
113
|
+
return -1;
|
|
114
|
+
if (typeof rightIndex === "number")
|
|
115
|
+
return 1;
|
|
116
|
+
return left.label.localeCompare(right.label);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export function formatSchemaFieldValueForForm(field, value) {
|
|
120
|
+
if (value === null || typeof value === "undefined") {
|
|
121
|
+
if (field.kind === "boolean")
|
|
122
|
+
return false;
|
|
123
|
+
return "";
|
|
124
|
+
}
|
|
125
|
+
if (field.kind === "boolean")
|
|
126
|
+
return Boolean(value);
|
|
127
|
+
if (field.kind === "number")
|
|
128
|
+
return String(value);
|
|
129
|
+
if (field.kind === "date")
|
|
130
|
+
return formatDateInputValue(value);
|
|
131
|
+
if (field.kind === "datetime")
|
|
132
|
+
return formatDateTimeLocalInputValue(value);
|
|
133
|
+
if (field.kind === "json") {
|
|
134
|
+
if (typeof value === "string")
|
|
135
|
+
return value;
|
|
136
|
+
try {
|
|
137
|
+
return JSON.stringify(value, null, 2);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return String(value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return String(value);
|
|
144
|
+
}
|
|
145
|
+
export function buildSchemaFormValues(schema, values = {}, uiSchema) {
|
|
146
|
+
const fields = buildSchemaFormFields(schema, uiSchema);
|
|
147
|
+
const next = {};
|
|
148
|
+
fields.forEach((field) => {
|
|
149
|
+
const provided = values[field.name];
|
|
150
|
+
const source = typeof provided !== "undefined" ? provided : field.defaultValue;
|
|
151
|
+
next[field.name] = formatSchemaFieldValueForForm(field, source);
|
|
152
|
+
});
|
|
153
|
+
return next;
|
|
154
|
+
}
|
|
155
|
+
export function buildSchemaFormPayload(schema, values, uiSchema) {
|
|
156
|
+
const fields = buildSchemaFormFields(schema, uiSchema);
|
|
157
|
+
const data = {};
|
|
158
|
+
const errors = {};
|
|
159
|
+
fields.forEach((field) => {
|
|
160
|
+
const rawValue = values[field.name];
|
|
161
|
+
if (field.kind === "boolean") {
|
|
162
|
+
data[field.name] = Boolean(rawValue);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (isBlank(rawValue)) {
|
|
166
|
+
if (field.required) {
|
|
167
|
+
errors[field.name] = `${field.label} is required.`;
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (field.kind === "number") {
|
|
172
|
+
const parsed = Number(rawValue);
|
|
173
|
+
if (!Number.isFinite(parsed)) {
|
|
174
|
+
errors[field.name] = `${field.label} must be a valid number.`;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (field.type === "integer" && !Number.isInteger(parsed)) {
|
|
178
|
+
errors[field.name] = `${field.label} must be a whole number.`;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
data[field.name] = parsed;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (field.kind === "json") {
|
|
185
|
+
try {
|
|
186
|
+
data[field.name] = typeof rawValue === "string" ? JSON.parse(rawValue) : rawValue;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
errors[field.name] = `${field.label} must be valid JSON.`;
|
|
190
|
+
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
data[field.name] = rawValue;
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
data,
|
|
197
|
+
errors,
|
|
198
|
+
isValid: Object.keys(errors).length === 0,
|
|
199
|
+
};
|
|
200
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentResponse, AssistantResponse, AvailableModels, ConversationMessageResponse, ConversationResponse, CreateAgentRequest, CreateAssistantRequest, CreateTaskRequest, FlowRunEntity, FunctionRunResponse, IconUploadResponse, OrganizationInvitationResponse, OrganizationMemberResponse, OrganizationResponse, PodConfigResponse, PodJoinRequestCreateResponse, PodMemberResponse, PodResponse, TaskMessageResponse, TaskResponse, UpdateAgentRequest, UpdateAssistantRequest, UserResponse } from "./openapi_client/index.js";
|
|
1
|
+
import type { AgentResponse, AssistantResponse, AvailableModels, ColumnSchema, ConversationMessageResponse, ConversationResponse, CreateAgentRequest, CreateAssistantRequest, CreateTaskRequest, DatastoreQueryResponse, FlowRunEntity, FlowResponse, FunctionRunResponse, IconUploadResponse, OrganizationInvitationResponse, OrganizationMemberResponse, OrganizationResponse, PodConfigResponse, PodJoinRequestCreateResponse, PodMemberResponse, PodResponse, TableResponse, TaskMessageResponse, TaskResponse, UpdateAgentRequest, UpdateAssistantRequest, UserResponse } from "./openapi_client/index.js";
|
|
2
2
|
/** Public ergonomic types. */
|
|
3
3
|
export interface PageResult<T> {
|
|
4
4
|
items: T[];
|
|
@@ -51,6 +51,10 @@ export type Task = TaskResponse;
|
|
|
51
51
|
export type TaskMessage = TaskMessageResponse;
|
|
52
52
|
export type FunctionRun = FunctionRunResponse;
|
|
53
53
|
export type FlowRun = FlowRunEntity;
|
|
54
|
+
export type Workflow = FlowResponse;
|
|
55
|
+
export type Table = TableResponse;
|
|
56
|
+
export type TableColumn = ColumnSchema;
|
|
57
|
+
export type DatastoreQueryResult = DatastoreQueryResponse;
|
|
54
58
|
export type Pod = PodResponse;
|
|
55
59
|
export type PodConfig = PodConfigResponse;
|
|
56
60
|
export type PodMember = PodMemberResponse;
|
|
@@ -65,6 +69,7 @@ export interface CursorPage<T> {
|
|
|
65
69
|
items: T[];
|
|
66
70
|
limit: number;
|
|
67
71
|
next_page_token?: string | null;
|
|
72
|
+
total?: number;
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* Re-export generated OpenAPI models/enums/services from the same module so this
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lemma-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"description": "Official TypeScript SDK for Lemma pod-scoped APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"lemma-sdk": "./bin/lemma-sdk.js"
|
|
10
|
+
},
|
|
8
11
|
"repository": {
|
|
9
12
|
"type": "git",
|
|
10
|
-
"url": "
|
|
13
|
+
"url": "https://github.com/gappyai/lemma-typescript"
|
|
11
14
|
},
|
|
12
15
|
"homepage": "https://github.com/gappyai/lemma-typescript#readme",
|
|
13
16
|
"bugs": {
|
|
@@ -29,18 +32,19 @@
|
|
|
29
32
|
"types": "./dist/react/index.d.ts",
|
|
30
33
|
"default": "./dist/react/index.js"
|
|
31
34
|
},
|
|
32
|
-
"./react/styles.css": "./dist/react/styles.css",
|
|
33
35
|
"./browser-bundle": "./dist/browser/lemma-client.js"
|
|
34
36
|
},
|
|
35
37
|
"unpkg": "dist/browser/lemma-client.js",
|
|
36
38
|
"files": [
|
|
37
|
-
"dist"
|
|
39
|
+
"dist",
|
|
40
|
+
"bin"
|
|
38
41
|
],
|
|
39
42
|
"scripts": {
|
|
40
43
|
"generate:client": "./scripts/generate_openapi_client.sh",
|
|
41
|
-
"build": "npm run clean && tsc -p tsconfig.json &&
|
|
44
|
+
"build": "npm run clean && tsc -p tsconfig.json && npm run build:bundle",
|
|
42
45
|
"build:bundle": "tsc -p tsconfig.bundle.json && node ./scripts/build_browser_bundle.mjs",
|
|
43
|
-
"clean": "
|
|
46
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })\"",
|
|
47
|
+
"registry:build": "shadcn build ./registry.json -o ./public/r",
|
|
44
48
|
"prepublishOnly": "npm run build",
|
|
45
49
|
"release:check": "npm run build && npm_config_cache=.npm-cache npm pack --dry-run"
|
|
46
50
|
},
|
|
@@ -53,13 +57,12 @@
|
|
|
53
57
|
}
|
|
54
58
|
},
|
|
55
59
|
"dependencies": {
|
|
56
|
-
"react-markdown": "^10.1.0",
|
|
57
|
-
"remark-gfm": "^4.0.1",
|
|
58
60
|
"supertokens-web-js": "^0.16.0"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@types/react": "^18.3.28",
|
|
62
64
|
"openapi-typescript-codegen": "^0.29.0",
|
|
65
|
+
"shadcn": "^4.2.0",
|
|
63
66
|
"typescript": "^5.6.3"
|
|
64
67
|
}
|
|
65
68
|
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
|
-
import type { AssistantConversationListItem, AssistantConversationRenderArgs } from "./assistant-types.js";
|
|
3
|
-
export type AssistantSurfaceTone = "default" | "subtle" | "flat";
|
|
4
|
-
export type AssistantThemeMode = "auto" | "light" | "dark";
|
|
5
|
-
export interface AssistantThemeScopeProps extends ComponentPropsWithoutRef<"div"> {
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
theme?: AssistantThemeMode;
|
|
8
|
-
}
|
|
9
|
-
export declare function AssistantThemeScope({ className, children, theme, ...props }: AssistantThemeScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export interface AssistantHeaderProps {
|
|
11
|
-
title: ReactNode;
|
|
12
|
-
subtitle?: ReactNode;
|
|
13
|
-
badge?: ReactNode;
|
|
14
|
-
controls?: ReactNode;
|
|
15
|
-
tone?: AssistantSurfaceTone;
|
|
16
|
-
className?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface AssistantMessageViewportProps extends ComponentPropsWithoutRef<"div"> {
|
|
19
|
-
innerClassName?: string;
|
|
20
|
-
children: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
export declare const AssistantMessageViewport: import("react").ForwardRefExoticComponent<AssistantMessageViewportProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
|
-
export interface AssistantShellLayoutProps {
|
|
24
|
-
sidebar?: ReactNode;
|
|
25
|
-
sidebarVisible?: boolean;
|
|
26
|
-
main: ReactNode;
|
|
27
|
-
className?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function AssistantShellLayout({ sidebar, sidebarVisible, main, className, }: AssistantShellLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export declare function AssistantHeader({ title, subtitle, badge, controls, tone, className, }: AssistantHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
-
export interface AssistantConversationListProps {
|
|
32
|
-
conversations: AssistantConversationListItem[];
|
|
33
|
-
activeConversationId: string | null;
|
|
34
|
-
onSelectConversation: (conversationId: string) => void;
|
|
35
|
-
onNewConversation?: () => void;
|
|
36
|
-
renderConversationLabel?: (args: AssistantConversationRenderArgs) => ReactNode;
|
|
37
|
-
title?: ReactNode;
|
|
38
|
-
newLabel?: ReactNode;
|
|
39
|
-
className?: string;
|
|
40
|
-
}
|
|
41
|
-
export declare function AssistantConversationList({ conversations, activeConversationId, onSelectConversation, onNewConversation, renderConversationLabel, title, newLabel, className, }: AssistantConversationListProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
-
export interface AssistantModelPickerProps<TValue extends string = string> {
|
|
43
|
-
value: TValue | null;
|
|
44
|
-
options: TValue[];
|
|
45
|
-
disabled?: boolean;
|
|
46
|
-
autoLabel?: ReactNode;
|
|
47
|
-
getOptionLabel?: (value: TValue) => ReactNode;
|
|
48
|
-
onChange: (value: TValue | null) => void;
|
|
49
|
-
className?: string;
|
|
50
|
-
}
|
|
51
|
-
export declare function AssistantModelPicker<TValue extends string = string>({ value, options, disabled, autoLabel, getOptionLabel, onChange, className, }: AssistantModelPickerProps<TValue>): import("react/jsx-runtime").JSX.Element;
|
|
52
|
-
export interface AssistantAskOverlayProps {
|
|
53
|
-
questionNumber: number;
|
|
54
|
-
totalQuestions: number;
|
|
55
|
-
question: ReactNode;
|
|
56
|
-
options: string[];
|
|
57
|
-
selectedOptions: string[];
|
|
58
|
-
canContinue: boolean;
|
|
59
|
-
continueLabel: ReactNode;
|
|
60
|
-
onSelectOption: (option: string) => void;
|
|
61
|
-
onContinue?: () => void;
|
|
62
|
-
onSkip?: () => void;
|
|
63
|
-
mode?: "single_select" | "multi_select" | "rank_priorities";
|
|
64
|
-
}
|
|
65
|
-
export declare function AssistantAskOverlay({ questionNumber, totalQuestions, question, options, selectedOptions, canContinue, continueLabel, onSelectOption, onContinue, onSkip, mode, }: AssistantAskOverlayProps): import("react/jsx-runtime").JSX.Element;
|
|
66
|
-
export interface AssistantPendingFileChipProps {
|
|
67
|
-
label: ReactNode;
|
|
68
|
-
onRemove?: () => void;
|
|
69
|
-
className?: string;
|
|
70
|
-
}
|
|
71
|
-
export interface AssistantComposerProps {
|
|
72
|
-
floating?: ReactNode;
|
|
73
|
-
status?: ReactNode;
|
|
74
|
-
pendingFiles?: ReactNode;
|
|
75
|
-
children: ReactNode;
|
|
76
|
-
tone?: AssistantSurfaceTone;
|
|
77
|
-
className?: string;
|
|
78
|
-
}
|
|
79
|
-
export declare function AssistantComposer({ floating, status, pendingFiles, children, tone, className, }: AssistantComposerProps): import("react/jsx-runtime").JSX.Element;
|
|
80
|
-
export declare function AssistantPendingFileChip({ label, onRemove, className, }: AssistantPendingFileChipProps): import("react/jsx-runtime").JSX.Element;
|
|
81
|
-
export interface AssistantStatusPillProps {
|
|
82
|
-
label: ReactNode;
|
|
83
|
-
subtle?: boolean;
|
|
84
|
-
className?: string;
|
|
85
|
-
}
|
|
86
|
-
export declare function AssistantStatusPill({ label, subtle, className, }: AssistantStatusPillProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
function cx(...values) {
|
|
4
|
-
return values.filter(Boolean).join(" ");
|
|
5
|
-
}
|
|
6
|
-
export function AssistantThemeScope({ className, children, theme = "auto", ...props }) {
|
|
7
|
-
return (_jsx("div", { "data-lemma-theme": theme, className: cx("lemma-assistant-theme", className), ...props, children: children }));
|
|
8
|
-
}
|
|
9
|
-
export const AssistantMessageViewport = forwardRef(function AssistantMessageViewport({ className, innerClassName, children, ...props }, ref) {
|
|
10
|
-
return (_jsx("div", { ref: ref, className: cx("lemma-assistant-viewport", className), ...props, children: _jsx("div", { className: cx("lemma-assistant-viewport-inner", innerClassName), children: children }) }));
|
|
11
|
-
});
|
|
12
|
-
export function AssistantShellLayout({ sidebar, sidebarVisible = false, main, className, }) {
|
|
13
|
-
const hasSidebar = !!sidebar;
|
|
14
|
-
return (_jsxs("div", { className: cx("lemma-assistant-shell", hasSidebar && "lemma-assistant-shell--with-sidebar", hasSidebar && sidebarVisible && "lemma-assistant-shell--sidebar-visible", className), children: [sidebar && sidebarVisible ? (_jsx("div", { className: "lemma-assistant-shell-sidebar", children: sidebar })) : null, main] }));
|
|
15
|
-
}
|
|
16
|
-
export function AssistantHeader({ title, subtitle, badge, controls, tone = "subtle", className, }) {
|
|
17
|
-
return (_jsxs("div", { "data-tone": tone, className: cx("lemma-assistant-header", className), children: [_jsxs("div", { className: "lemma-assistant-header-copy", children: [badge ? (_jsx("div", { className: "lemma-assistant-header-badge", children: badge })) : null, _jsxs("div", { className: "lemma-assistant-header-titles", children: [_jsx("h3", { className: "lemma-assistant-header-title", children: title }), subtitle ? (_jsx("p", { className: "lemma-assistant-header-subtitle", children: subtitle })) : null] })] }), controls ? (_jsx("div", { className: "lemma-assistant-header-controls", children: controls })) : null] }));
|
|
18
|
-
}
|
|
19
|
-
export function AssistantConversationList({ conversations, activeConversationId, onSelectConversation, onNewConversation, renderConversationLabel, title = "Conversations", newLabel = "New", className, }) {
|
|
20
|
-
return (_jsxs("aside", { className: cx("lemma-assistant-conversation-list", className), children: [_jsx("div", { className: "lemma-assistant-conversation-list-header", children: _jsxs("div", { className: "lemma-assistant-conversation-list-header-row", children: [_jsxs("div", { className: "lemma-assistant-conversation-list-copy", children: [_jsx("div", { className: "lemma-assistant-conversation-list-title", children: title }), _jsxs("div", { className: "lemma-assistant-conversation-list-meta", children: [conversations.length, " total"] })] }), onNewConversation ? (_jsx("button", { type: "button", onClick: onNewConversation, className: "lemma-assistant-conversation-list-new", children: newLabel })) : null] }) }), _jsx("div", { className: "lemma-assistant-conversation-list-items", children: conversations.map((conversation) => {
|
|
21
|
-
const isActive = conversation.id === activeConversationId;
|
|
22
|
-
return (_jsxs("button", { type: "button", onClick: () => onSelectConversation(conversation.id), className: cx("lemma-assistant-conversation-list-item", isActive && "lemma-assistant-conversation-list-item-active"), children: [_jsx("div", { className: "lemma-assistant-conversation-list-item-title", children: renderConversationLabel
|
|
23
|
-
? renderConversationLabel({ conversation, isActive })
|
|
24
|
-
: (conversation.title || "Untitled conversation") }), _jsx("div", { className: "lemma-assistant-conversation-list-item-status", children: (conversation.status || "waiting").toLowerCase() })] }, conversation.id));
|
|
25
|
-
}) })] }));
|
|
26
|
-
}
|
|
27
|
-
export function AssistantModelPicker({ value, options, disabled, autoLabel = "Auto", getOptionLabel, onChange, className, }) {
|
|
28
|
-
const autoValue = "__AUTO__";
|
|
29
|
-
return (_jsxs("select", { value: value ?? autoValue, onChange: (event) => onChange(event.target.value === autoValue ? null : event.target.value), disabled: disabled, className: cx("lemma-assistant-model-picker", className), "aria-label": "Conversation model", title: "Conversation model", children: [_jsx("option", { value: autoValue, children: autoLabel }), options.map((option) => (_jsx("option", { value: option, children: getOptionLabel ? getOptionLabel(option) : option }, option)))] }));
|
|
30
|
-
}
|
|
31
|
-
export function AssistantAskOverlay({ questionNumber, totalQuestions, question, options, selectedOptions, canContinue, continueLabel, onSelectOption, onContinue, onSkip, mode = "single_select", }) {
|
|
32
|
-
return (_jsxs("div", { className: "lemma-assistant-ask-overlay", children: [_jsxs("div", { className: "lemma-assistant-ask-overlay-header", children: [_jsxs("div", { className: "lemma-assistant-ask-overlay-copy", children: [_jsxs("div", { className: "lemma-assistant-ask-overlay-kicker", children: ["Question ", questionNumber, " of ", totalQuestions] }), _jsx("p", { className: "lemma-assistant-ask-overlay-question", children: question })] }), onSkip ? (_jsx("button", { type: "button", onClick: onSkip, className: "lemma-assistant-ask-overlay-skip", children: "Skip" })) : null] }), _jsx("div", { className: "lemma-assistant-ask-overlay-options", children: options.map((option, optionIndex) => {
|
|
33
|
-
const isSelected = selectedOptions.includes(option);
|
|
34
|
-
const rankLabel = mode === "rank_priorities" && isSelected
|
|
35
|
-
? selectedOptions.indexOf(option) + 1
|
|
36
|
-
: null;
|
|
37
|
-
return (_jsx("button", { type: "button", onClick: () => onSelectOption(option), className: cx("lemma-assistant-ask-overlay-option", isSelected && "lemma-assistant-ask-overlay-option-selected"), children: _jsxs("span", { className: "lemma-assistant-ask-overlay-option-label", children: [rankLabel ? (_jsx("span", { className: "lemma-assistant-ask-overlay-option-rank", children: rankLabel })) : (_jsx("span", { className: cx("lemma-assistant-ask-overlay-option-indicator", isSelected && "lemma-assistant-ask-overlay-option-indicator-selected") })), option] }) }, `${option}-${optionIndex}`));
|
|
38
|
-
}) }), onContinue ? (_jsx("div", { className: "lemma-assistant-ask-overlay-actions", children: _jsx("button", { type: "button", onClick: onContinue, disabled: !canContinue, className: cx("lemma-assistant-ask-overlay-continue", canContinue && "lemma-assistant-ask-overlay-continue-enabled"), children: continueLabel }) })) : null] }));
|
|
39
|
-
}
|
|
40
|
-
export function AssistantComposer({ floating, status, pendingFiles, children, tone = "subtle", className, }) {
|
|
41
|
-
return (_jsxs("div", { "data-tone": tone, "data-has-status": status ? "true" : "false", "data-has-pending-files": pendingFiles ? "true" : "false", "data-has-floating": floating ? "true" : "false", className: cx("lemma-assistant-composer", className), children: [floating ? (_jsx("div", { className: "lemma-assistant-composer-floating", children: floating })) : null, status ? (_jsx("div", { className: "lemma-assistant-composer-status-rail", children: _jsx("div", { className: "lemma-assistant-composer-status", children: status }) })) : null, pendingFiles ? (_jsx("div", { className: "lemma-assistant-composer-pending", children: pendingFiles })) : null, _jsx("div", { className: "lemma-assistant-composer-body", children: children })] }));
|
|
42
|
-
}
|
|
43
|
-
export function AssistantPendingFileChip({ label, onRemove, className, }) {
|
|
44
|
-
return (_jsxs("span", { className: cx("lemma-assistant-pending-file-chip", className), children: [_jsx("span", { className: "lemma-assistant-pending-file-chip-label", children: label }), onRemove ? (_jsx("button", { type: "button", onClick: onRemove, className: "lemma-assistant-pending-file-chip-remove", title: "Remove file", children: "\u00D7" })) : null] }));
|
|
45
|
-
}
|
|
46
|
-
export function AssistantStatusPill({ label, subtle = false, className, }) {
|
|
47
|
-
return (_jsxs("div", { className: cx("lemma-assistant-status-pill", subtle && "lemma-assistant-status-pill-subtle", className), children: [_jsxs("span", { className: "lemma-assistant-status-pill-dot", children: [_jsx("span", { className: "lemma-assistant-status-pill-dot-ping" }), _jsx("span", { className: "lemma-assistant-status-pill-dot-core" })] }), _jsx("span", { className: "lemma-assistant-status-pill-label", children: label })] }));
|
|
48
|
-
}
|