@japro/luma-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/dist/index.cjs +382 -0
- package/dist/index.d.cts +349 -0
- package/dist/index.d.ts +349 -0
- package/dist/index.js +344 -0
- package/package.json +46 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
LumaClient: () => LumaClient,
|
|
34
|
+
createLumaClient: () => createLumaClient
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/api/generated-api.ts
|
|
39
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
40
|
+
var HttpClient = class {
|
|
41
|
+
constructor({
|
|
42
|
+
securityWorker,
|
|
43
|
+
secure,
|
|
44
|
+
format,
|
|
45
|
+
...axiosConfig
|
|
46
|
+
} = {}) {
|
|
47
|
+
this.securityData = null;
|
|
48
|
+
this.setSecurityData = (data) => {
|
|
49
|
+
this.securityData = data;
|
|
50
|
+
};
|
|
51
|
+
this.request = async ({
|
|
52
|
+
secure,
|
|
53
|
+
path,
|
|
54
|
+
type,
|
|
55
|
+
query,
|
|
56
|
+
format,
|
|
57
|
+
body,
|
|
58
|
+
...params
|
|
59
|
+
}) => {
|
|
60
|
+
const secureParams = (typeof secure === "boolean" ? secure : this.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {};
|
|
61
|
+
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
62
|
+
const responseFormat = format || this.format || void 0;
|
|
63
|
+
if (type === "multipart/form-data" /* FormData */ && body && body !== null && typeof body === "object") {
|
|
64
|
+
body = this.createFormData(body);
|
|
65
|
+
}
|
|
66
|
+
if (type === "text/plain" /* Text */ && body && body !== null && typeof body !== "string") {
|
|
67
|
+
body = JSON.stringify(body);
|
|
68
|
+
}
|
|
69
|
+
return this.instance.request({
|
|
70
|
+
...requestParams,
|
|
71
|
+
headers: {
|
|
72
|
+
...requestParams.headers || {},
|
|
73
|
+
...type ? { "Content-Type": type } : {}
|
|
74
|
+
},
|
|
75
|
+
params: query,
|
|
76
|
+
responseType: responseFormat,
|
|
77
|
+
data: body,
|
|
78
|
+
url: path
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
this.instance = import_axios.default.create({
|
|
82
|
+
...axiosConfig,
|
|
83
|
+
baseURL: axiosConfig.baseURL || ""
|
|
84
|
+
});
|
|
85
|
+
this.secure = secure;
|
|
86
|
+
this.format = format;
|
|
87
|
+
this.securityWorker = securityWorker;
|
|
88
|
+
}
|
|
89
|
+
mergeRequestParams(params1, params2) {
|
|
90
|
+
const method = params1.method || params2 && params2.method;
|
|
91
|
+
return {
|
|
92
|
+
...this.instance.defaults,
|
|
93
|
+
...params1,
|
|
94
|
+
...params2 || {},
|
|
95
|
+
headers: {
|
|
96
|
+
...method && this.instance.defaults.headers[method.toLowerCase()] || {},
|
|
97
|
+
...params1.headers || {},
|
|
98
|
+
...params2 && params2.headers || {}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
stringifyFormItem(formItem) {
|
|
103
|
+
if (typeof formItem === "object" && formItem !== null) {
|
|
104
|
+
return JSON.stringify(formItem);
|
|
105
|
+
} else {
|
|
106
|
+
return `${formItem}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
createFormData(input) {
|
|
110
|
+
if (input instanceof FormData) {
|
|
111
|
+
return input;
|
|
112
|
+
}
|
|
113
|
+
return Object.keys(input || {}).reduce((formData, key) => {
|
|
114
|
+
const property = input[key];
|
|
115
|
+
const propertyContent = property instanceof Array ? property : [property];
|
|
116
|
+
for (const formItem of propertyContent) {
|
|
117
|
+
const isFileType = formItem instanceof Blob || formItem instanceof File;
|
|
118
|
+
formData.append(
|
|
119
|
+
key,
|
|
120
|
+
isFileType ? formItem : this.stringifyFormItem(formItem)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return formData;
|
|
124
|
+
}, new FormData());
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
var API = class extends HttpClient {
|
|
128
|
+
constructor() {
|
|
129
|
+
super(...arguments);
|
|
130
|
+
this.api = {
|
|
131
|
+
/**
|
|
132
|
+
* @description Streams AI chat responses for the draft associated with `integration_id` (the external course identifier you are building a draft for), scoped to the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
133
|
+
*
|
|
134
|
+
* @tags Public - Require API Key
|
|
135
|
+
* @name ChatApiPublicV1AiChatIntegrationIdPost
|
|
136
|
+
* @summary Chat With Draft By Integration ID
|
|
137
|
+
* @request POST:/api/public/v1/ai/chat/{integration_id}
|
|
138
|
+
* @secure
|
|
139
|
+
*/
|
|
140
|
+
chatApiPublicV1AiChatIntegrationIdPost: (integrationId, data, params = {}) => this.request({
|
|
141
|
+
path: `/api/public/v1/ai/chat/${integrationId}`,
|
|
142
|
+
method: "POST",
|
|
143
|
+
body: data,
|
|
144
|
+
secure: true,
|
|
145
|
+
type: "application/json" /* Json */,
|
|
146
|
+
format: "json",
|
|
147
|
+
...params
|
|
148
|
+
}),
|
|
149
|
+
/**
|
|
150
|
+
* @description Creates a draft for a given `integration_id` (the external course identifier you are building a draft for) under the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
151
|
+
*
|
|
152
|
+
* @tags Public - Require API Key
|
|
153
|
+
* @name CreateDraftApiPublicV1DraftPost
|
|
154
|
+
* @summary Create Draft By Integration ID
|
|
155
|
+
* @request POST:/api/public/v1/draft
|
|
156
|
+
* @secure
|
|
157
|
+
*/
|
|
158
|
+
createDraftApiPublicV1DraftPost: (data, params = {}) => this.request({
|
|
159
|
+
path: `/api/public/v1/draft`,
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: data,
|
|
162
|
+
secure: true,
|
|
163
|
+
type: "application/json" /* Json */,
|
|
164
|
+
format: "json",
|
|
165
|
+
...params
|
|
166
|
+
}),
|
|
167
|
+
/**
|
|
168
|
+
* @description Uploads a file to the draft associated with `integration_id` (the external course identifier you are building a draft for), scoped to the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
169
|
+
*
|
|
170
|
+
* @tags Public - Require API Key
|
|
171
|
+
* @name IngestApiPublicV1DraftIngestIntegrationIdPost
|
|
172
|
+
* @summary Ingest File To Draft By Integration ID
|
|
173
|
+
* @request POST:/api/public/v1/draft/ingest/{integration_id}
|
|
174
|
+
* @secure
|
|
175
|
+
*/
|
|
176
|
+
ingestApiPublicV1DraftIngestIntegrationIdPost: (integrationId, data, params = {}) => this.request({
|
|
177
|
+
path: `/api/public/v1/draft/ingest/${integrationId}`,
|
|
178
|
+
method: "POST",
|
|
179
|
+
body: data,
|
|
180
|
+
secure: true,
|
|
181
|
+
type: "multipart/form-data" /* FormData */,
|
|
182
|
+
format: "json",
|
|
183
|
+
...params
|
|
184
|
+
}),
|
|
185
|
+
/**
|
|
186
|
+
* @description Removes a previously ingested document from the draft associated with `integration_id` (the external course identifier you are building a draft for), scoped to the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
187
|
+
*
|
|
188
|
+
* @tags Public - Require API Key
|
|
189
|
+
* @name DeleteIngestedDocumentApiPublicV1DraftIngestIntegrationIdDocumentIdDelete
|
|
190
|
+
* @summary Delete Ingested Document By Integration ID
|
|
191
|
+
* @request DELETE:/api/public/v1/draft/ingest/{integration_id}/{document_id}
|
|
192
|
+
* @secure
|
|
193
|
+
*/
|
|
194
|
+
deleteIngestedDocumentApiPublicV1DraftIngestIntegrationIdDocumentIdDelete: (integrationId, documentId, params = {}) => this.request({
|
|
195
|
+
path: `/api/public/v1/draft/ingest/${integrationId}/${documentId}`,
|
|
196
|
+
method: "DELETE",
|
|
197
|
+
secure: true,
|
|
198
|
+
format: "json",
|
|
199
|
+
...params
|
|
200
|
+
}),
|
|
201
|
+
/**
|
|
202
|
+
* @description Returns all files linked to the draft for the provided `integration_id` (the external course identifier you are building a draft for), scoped to the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
203
|
+
*
|
|
204
|
+
* @tags Public - Require API Key
|
|
205
|
+
* @name GetDraftFilesApiPublicV1DraftFilesIntegrationIdGet
|
|
206
|
+
* @summary Get Draft Files By Integration ID
|
|
207
|
+
* @request GET:/api/public/v1/draft/files/{integration_id}
|
|
208
|
+
* @secure
|
|
209
|
+
*/
|
|
210
|
+
getDraftFilesApiPublicV1DraftFilesIntegrationIdGet: (integrationId, params = {}) => this.request({
|
|
211
|
+
path: `/api/public/v1/draft/files/${integrationId}`,
|
|
212
|
+
method: "GET",
|
|
213
|
+
secure: true,
|
|
214
|
+
format: "json",
|
|
215
|
+
...params
|
|
216
|
+
}),
|
|
217
|
+
/**
|
|
218
|
+
* @description Fetches draft status for the provided `integration_id` (the external course identifier you are building a draft for) inside the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
219
|
+
*
|
|
220
|
+
* @tags Public - Require API Key
|
|
221
|
+
* @name GetDraftApiPublicV1DraftIntegrationIdGet
|
|
222
|
+
* @summary Get Draft Status By Integration ID
|
|
223
|
+
* @request GET:/api/public/v1/draft/{integration_id}
|
|
224
|
+
* @secure
|
|
225
|
+
*/
|
|
226
|
+
getDraftApiPublicV1DraftIntegrationIdGet: (integrationId, params = {}) => this.request({
|
|
227
|
+
path: `/api/public/v1/draft/${integrationId}`,
|
|
228
|
+
method: "GET",
|
|
229
|
+
secure: true,
|
|
230
|
+
format: "json",
|
|
231
|
+
...params
|
|
232
|
+
}),
|
|
233
|
+
/**
|
|
234
|
+
* @description Returns all draft chat messages for the draft associated with `integration_id` (the external course identifier you are building a draft for), scoped to the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
235
|
+
*
|
|
236
|
+
* @tags Public - Require API Key
|
|
237
|
+
* @name GetDraftMessagesApiPublicV1DraftMessagesIntegrationIdGet
|
|
238
|
+
* @summary Get Draft Messages By Integration ID
|
|
239
|
+
* @request GET:/api/public/v1/draft/messages/{integration_id}
|
|
240
|
+
* @secure
|
|
241
|
+
*/
|
|
242
|
+
getDraftMessagesApiPublicV1DraftMessagesIntegrationIdGet: (integrationId, params = {}) => this.request({
|
|
243
|
+
path: `/api/public/v1/draft/messages/${integrationId}`,
|
|
244
|
+
method: "GET",
|
|
245
|
+
secure: true,
|
|
246
|
+
format: "json",
|
|
247
|
+
...params
|
|
248
|
+
}),
|
|
249
|
+
/**
|
|
250
|
+
* @description Returns the generated course payload for the draft associated with `integration_id` (the external course identifier you are building a draft for), scoped to the organization resolved from `X-API-Key`. Authorization header required: `X-API-Key: <luma_api_key>`.
|
|
251
|
+
*
|
|
252
|
+
* @tags Public - Require API Key
|
|
253
|
+
* @name GetGeneratedCourseApiPublicV1DraftGeneratedCourseIntegrationIdGet
|
|
254
|
+
* @summary Get Generated Course By Integration ID
|
|
255
|
+
* @request GET:/api/public/v1/draft/generated-course/{integration_id}
|
|
256
|
+
* @secure
|
|
257
|
+
*/
|
|
258
|
+
getGeneratedCourseApiPublicV1DraftGeneratedCourseIntegrationIdGet: (integrationId, params = {}) => this.request({
|
|
259
|
+
path: `/api/public/v1/draft/generated-course/${integrationId}`,
|
|
260
|
+
method: "GET",
|
|
261
|
+
secure: true,
|
|
262
|
+
format: "json",
|
|
263
|
+
...params
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/client.ts
|
|
270
|
+
var import_node_https = require("https");
|
|
271
|
+
|
|
272
|
+
// src/executions/public-api-executions.ts
|
|
273
|
+
var PublicApiExecutions = class {
|
|
274
|
+
constructor(apiClient) {
|
|
275
|
+
this.apiClient = apiClient;
|
|
276
|
+
}
|
|
277
|
+
async chat(opts) {
|
|
278
|
+
return this.apiClient.api.chatApiPublicV1AiChatIntegrationIdPost(
|
|
279
|
+
opts.integrationId,
|
|
280
|
+
{
|
|
281
|
+
message: opts.message
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
format: "stream"
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
async createDraft(opts) {
|
|
289
|
+
const response = await this.apiClient.api.createDraftApiPublicV1DraftPost(opts);
|
|
290
|
+
return response.data;
|
|
291
|
+
}
|
|
292
|
+
async ingestDraftFile(opts) {
|
|
293
|
+
const response = await this.apiClient.api.ingestApiPublicV1DraftIngestIntegrationIdPost(
|
|
294
|
+
opts.integrationId,
|
|
295
|
+
{
|
|
296
|
+
file: opts.file
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
return response.data;
|
|
300
|
+
}
|
|
301
|
+
async deleteIngestedDocument(opts) {
|
|
302
|
+
const response = await this.apiClient.api.deleteIngestedDocumentApiPublicV1DraftIngestIntegrationIdDocumentIdDelete(
|
|
303
|
+
opts.integrationId,
|
|
304
|
+
opts.documentId
|
|
305
|
+
);
|
|
306
|
+
return response.data;
|
|
307
|
+
}
|
|
308
|
+
async getDraftFiles(opts) {
|
|
309
|
+
const response = await this.apiClient.api.getDraftFilesApiPublicV1DraftFilesIntegrationIdGet(
|
|
310
|
+
opts.integrationId
|
|
311
|
+
);
|
|
312
|
+
return response.data;
|
|
313
|
+
}
|
|
314
|
+
async getDraft(opts) {
|
|
315
|
+
const response = await this.apiClient.api.getDraftApiPublicV1DraftIntegrationIdGet(
|
|
316
|
+
opts.integrationId
|
|
317
|
+
);
|
|
318
|
+
return response.data;
|
|
319
|
+
}
|
|
320
|
+
async getDraftMessages(opts) {
|
|
321
|
+
const response = await this.apiClient.api.getDraftMessagesApiPublicV1DraftMessagesIntegrationIdGet(
|
|
322
|
+
opts.integrationId
|
|
323
|
+
);
|
|
324
|
+
return response.data;
|
|
325
|
+
}
|
|
326
|
+
async getGeneratedCourse(opts) {
|
|
327
|
+
const response = await this.apiClient.api.getGeneratedCourseApiPublicV1DraftGeneratedCourseIntegrationIdGet(
|
|
328
|
+
opts.integrationId
|
|
329
|
+
);
|
|
330
|
+
return response.data;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// src/client.ts
|
|
335
|
+
var LumaClient = class {
|
|
336
|
+
constructor(opts) {
|
|
337
|
+
const httpsAgent = opts.httpsAgent ?? (opts.allowInsecureTls ? new import_node_https.Agent({ rejectUnauthorized: false }) : void 0);
|
|
338
|
+
this.apiClient = new API({
|
|
339
|
+
baseURL: opts.baseURL,
|
|
340
|
+
secure: true,
|
|
341
|
+
httpsAgent,
|
|
342
|
+
headers: {
|
|
343
|
+
"X-API-Key": opts.apiKey
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
this.executions = new PublicApiExecutions(this.apiClient);
|
|
347
|
+
}
|
|
348
|
+
async chat(opts) {
|
|
349
|
+
return this.executions.chat(opts);
|
|
350
|
+
}
|
|
351
|
+
async createDraft(opts) {
|
|
352
|
+
return this.executions.createDraft(opts);
|
|
353
|
+
}
|
|
354
|
+
async ingestDraftFile(opts) {
|
|
355
|
+
return this.executions.ingestDraftFile(opts);
|
|
356
|
+
}
|
|
357
|
+
async deleteIngestedDocument(opts) {
|
|
358
|
+
return this.executions.deleteIngestedDocument(opts);
|
|
359
|
+
}
|
|
360
|
+
async getDraftFiles(opts) {
|
|
361
|
+
return this.executions.getDraftFiles(opts);
|
|
362
|
+
}
|
|
363
|
+
async getDraft(opts) {
|
|
364
|
+
return this.executions.getDraft(opts);
|
|
365
|
+
}
|
|
366
|
+
async getDraftMessages(opts) {
|
|
367
|
+
return this.executions.getDraftMessages(opts);
|
|
368
|
+
}
|
|
369
|
+
async getGeneratedCourse(opts) {
|
|
370
|
+
return this.executions.getGeneratedCourse(opts);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// src/index.ts
|
|
375
|
+
var createLumaClient = (opts) => {
|
|
376
|
+
return new LumaClient(opts);
|
|
377
|
+
};
|
|
378
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
379
|
+
0 && (module.exports = {
|
|
380
|
+
LumaClient,
|
|
381
|
+
createLumaClient
|
|
382
|
+
});
|