@qelos/sdk 3.11.2 → 3.11.3

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.
@@ -0,0 +1,12 @@
1
+ import BaseSDK from "../base-sdk";
2
+ import { QelosSDKOptions } from "../types";
3
+ export default class QlManageLambdas extends BaseSDK {
4
+ private options;
5
+ private relativePath;
6
+ constructor(options: QelosSDKOptions);
7
+ getList(sourceId: string): Promise<unknown>;
8
+ getLambda(sourceId: string, functionName: string): Promise<unknown>;
9
+ create(sourceId: string, data: any): Promise<unknown>;
10
+ update(sourceId: string, functionName: string, data: any): Promise<unknown>;
11
+ remove(sourceId: string, functionName: string): Promise<Response>;
12
+ }
@@ -0,0 +1,33 @@
1
+ import BaseSDK from "../base-sdk";
2
+ export default class QlManageLambdas extends BaseSDK {
3
+ options;
4
+ relativePath = '/api/lambdas';
5
+ constructor(options) {
6
+ super(options);
7
+ this.options = options;
8
+ }
9
+ getList(sourceId) {
10
+ return this.callJsonApi(`${this.relativePath}/${sourceId}`);
11
+ }
12
+ getLambda(sourceId, functionName) {
13
+ return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`);
14
+ }
15
+ create(sourceId, data) {
16
+ return this.callJsonApi(`${this.relativePath}/${sourceId}`, {
17
+ method: 'POST',
18
+ body: JSON.stringify(data),
19
+ headers: { 'content-type': 'application/json' },
20
+ });
21
+ }
22
+ update(sourceId, functionName, data) {
23
+ return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`, {
24
+ method: 'PUT',
25
+ body: JSON.stringify(data),
26
+ headers: { 'content-type': 'application/json' },
27
+ });
28
+ }
29
+ remove(sourceId, functionName) {
30
+ return this.callApi(`${this.relativePath}/${sourceId}/${functionName}`, { method: 'DELETE' });
31
+ }
32
+ }
33
+ //# sourceMappingURL=admin-lambdas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-lambdas.js","sourceRoot":"","sources":["../../src/administrator/admin-lambdas.ts"],"names":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EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClG,CAAC;CACJ"}
@@ -10,7 +10,10 @@ import { QlRoles } from './roles';
10
10
  import QlIntegrationSources from './integration-sources';
11
11
  import QlManagePlugins from './manage-plugins';
12
12
  import QlComponents from './components';
13
+ import QlIntegrations from './integrations';
14
+ import QlManageLambdas from './admin-lambdas';
13
15
  export default class QelosAdministratorSDK<T = any> extends QelosSDK {
16
+ manageLambdas: QlManageLambdas;
14
17
  users: QlUsers<T>;
15
18
  manageConfigurations: QlManageConfigurations;
16
19
  manageBlueprints: QlManageBlueprints;
@@ -21,6 +24,7 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
21
24
  integrationSources: QlIntegrationSources;
22
25
  managePlugins: QlManagePlugins;
23
26
  components: QlComponents;
27
+ integrations: QlIntegrations;
24
28
  constructor(options: QelosSDKOptions);
25
29
  impersonateUser(userId: string, workspaceId?: string): void;
26
30
  clearImpersonation(): void;
@@ -9,7 +9,10 @@ import { QlRoles } from './roles';
9
9
  import QlIntegrationSources from './integration-sources';
10
10
  import QlManagePlugins from './manage-plugins';
11
11
  import QlComponents from './components';
12
+ import QlIntegrations from './integrations';
13
+ import QlManageLambdas from './admin-lambdas';
12
14
  export default class QelosAdministratorSDK extends QelosSDK {
15
+ manageLambdas;
13
16
  users;
14
17
  manageConfigurations;
15
18
  manageBlueprints;
@@ -20,8 +23,10 @@ export default class QelosAdministratorSDK extends QelosSDK {
20
23
  integrationSources;
21
24
  managePlugins;
22
25
  components;
26
+ integrations;
23
27
  constructor(options) {
24
28
  super(options);
29
+ this.manageLambdas = new QlManageLambdas(options);
25
30
  this.users = new QlUsers(options);
26
31
  this.manageConfigurations = new QlManageConfigurations(options);
27
32
  this.manageBlueprints = new QlManageBlueprints(options);
@@ -32,6 +37,7 @@ export default class QelosAdministratorSDK extends QelosSDK {
32
37
  this.integrationSources = new QlIntegrationSources(options);
33
38
  this.managePlugins = new QlManagePlugins(options);
34
39
  this.components = new QlComponents(options);
40
+ this.integrations = new QlIntegrations(options);
35
41
  if (!options.extraQueryParams) {
36
42
  options.extraQueryParams = () => ({
37
43
  bypassAdmin: 'true'
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/administrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,sBAAsB,MAAM,yBAAyB,CAAC;AAC7D,OAAO,iBAAiB,MAAM,cAAc,CAAC;AAC7C,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,oBAAoB,MAAM,uBAAuB,CAAC;AACzD,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAGxC,MAAM,CAAC,OAAO,OAAO,qBAA+B,SAAQ,QAAQ;IAClE,KAAK,CAAa;IAClB,oBAAoB,CAAyB;IAC7C,gBAAgB,CAAqB;IACrC,MAAM,CAAW;IACjB,MAAM,CAAW;IACjB,eAAe,CAAoB;IACnC,KAAK,CAAU;IACf,kBAAkB,CAAuB;IACzC,aAAa,CAAkB;IAC/B,UAAU,CAAe;IAEzB,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,CAAI,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,gBAAgB,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,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G,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QAEhD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;YAC7B,OAAO,CAAC,gBAAgB,GAAG,GAAG,EAAE,CAAC,CAAC;gBAChC,WAAW,EAAE,MAAM;aACpB,CAAC,CAAA;SACH;IACH,CAAC;IAED,eAAe,CAAC,MAAc,EAAE,WAAoB;QAClD,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QACnD,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,eAAe,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC;SAC9D;IACH,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;QAC9C,IAAI,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;IACrD,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ import { QelosSDKOptions, RequestExtra } from '../types';
2
+ import BaseSDK from '../base-sdk';
3
+ import { IIntegration } from '@qelos/global-types';
4
+ export default class QlIntegrations extends BaseSDK {
5
+ private options;
6
+ private relativePath;
7
+ constructor(options: QelosSDKOptions);
8
+ getIntegration(integrationId: string, extra?: RequestExtra): Promise<IIntegration>;
9
+ getList(query?: {
10
+ plugin?: string;
11
+ user?: string;
12
+ 'trigger.source'?: string;
13
+ 'target.source'?: string;
14
+ 'trigger.kind'?: string;
15
+ 'target.kind'?: string;
16
+ kind?: string;
17
+ source?: string;
18
+ active?: boolean;
19
+ id?: string;
20
+ _id?: string;
21
+ }, extra?: RequestExtra): Promise<IIntegration[]>;
22
+ remove(integrationId: string): Promise<any>;
23
+ update(integrationId: string, changes: {
24
+ active?: boolean;
25
+ trigger?: any;
26
+ target?: any;
27
+ dataManipulation?: any;
28
+ }): Promise<IIntegration>;
29
+ create(integration: {
30
+ trigger: any;
31
+ target: any;
32
+ dataManipulation?: any;
33
+ active?: boolean;
34
+ }): Promise<IIntegration>;
35
+ }
@@ -0,0 +1,33 @@
1
+ import BaseSDK from '../base-sdk';
2
+ export default class QlIntegrations extends BaseSDK {
3
+ options;
4
+ relativePath = '/api/integrations';
5
+ constructor(options) {
6
+ super(options);
7
+ this.options = options;
8
+ }
9
+ getIntegration(integrationId, extra) {
10
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, extra);
11
+ }
12
+ getList(query, extra) {
13
+ return this.callJsonApi(this.relativePath + this.getQueryParams(query), extra);
14
+ }
15
+ remove(integrationId) {
16
+ return this.callApi(`${this.relativePath}/${integrationId}`, { method: 'delete' });
17
+ }
18
+ update(integrationId, changes) {
19
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
20
+ method: 'put',
21
+ headers: { 'content-type': 'application/json' },
22
+ body: JSON.stringify(changes)
23
+ });
24
+ }
25
+ create(integration) {
26
+ return this.callJsonApi(this.relativePath, {
27
+ method: 'post',
28
+ headers: { 'content-type': 'application/json' },
29
+ body: JSON.stringify(integration)
30
+ });
31
+ }
32
+ }
33
+ //# sourceMappingURL=integrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/administrator/integrations.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAG7B;IAFZ,YAAY,GAAG,mBAAmB,CAAC;IAE3C,YAAoB,OAAwB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QADI,YAAO,GAAP,OAAO,CAAiB;IAE5C,CAAC;IAED,cAAc,CAAC,aAAqB,EAAE,KAAoB;QACxD,OAAO,IAAI,CAAC,WAAW,CAAe,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE,KAAK,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,CAAC,KAYP,EAAE,KAAoB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAiB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,CAAC,aAAqB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,MAAM,CAAC,aAAqB,EAAE,OAK7B;QACC,OAAO,IAAI,CAAC,WAAW,CACrB,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EACvC;YACE,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CACF,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAKN;QACC,OAAO,IAAI,CAAC,WAAW,CAAe,IAAI,CAAC,YAAY,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC;CAEF"}
package/dist/ai.d.ts ADDED
@@ -0,0 +1,116 @@
1
+ import { QelosSDKOptions } from './types';
2
+ import BaseSDK from './base-sdk';
3
+ export interface IMessage {
4
+ role: string;
5
+ content: string;
6
+ timestamp?: Date | string;
7
+ tool_calls?: any[];
8
+ name?: string;
9
+ tool_call_id?: string;
10
+ function_call?: any;
11
+ message_id?: string;
12
+ }
13
+ export interface IMessageSummary {
14
+ fromIndex: number;
15
+ toIndex: number;
16
+ summary: string;
17
+ }
18
+ export interface IThread {
19
+ _id?: string;
20
+ integration: string;
21
+ title?: string;
22
+ messages: IMessage[];
23
+ messageSummaries: IMessageSummary[];
24
+ created?: Date;
25
+ updated?: Date;
26
+ user?: string;
27
+ workspace?: string;
28
+ }
29
+ export interface IChatCompletionOptions {
30
+ messages: IMessage[];
31
+ model?: string;
32
+ temperature?: number;
33
+ top_p?: number;
34
+ frequency_penalty?: number;
35
+ presence_penalty?: number;
36
+ stop?: string | string[];
37
+ max_tokens?: number;
38
+ response_format?: any;
39
+ context?: Record<string, any>;
40
+ stream?: boolean;
41
+ }
42
+ export interface ISSEStreamProcessor extends AsyncIterable<any> {
43
+ processManually(onData: (data: any) => void | boolean): Promise<void>;
44
+ }
45
+ export interface IChatCompletionResponse {
46
+ id: string;
47
+ object: string;
48
+ created: number;
49
+ model: string;
50
+ choices: Array<{
51
+ index: number;
52
+ message: IMessage;
53
+ finish_reason: string;
54
+ }>;
55
+ usage?: {
56
+ prompt_tokens: number;
57
+ completion_tokens: number;
58
+ total_tokens: number;
59
+ };
60
+ }
61
+ export interface ICreateThreadRequest {
62
+ integration: string;
63
+ title?: string;
64
+ }
65
+ export default class QlAI extends BaseSDK {
66
+ private relativePath;
67
+ constructor(options: QelosSDKOptions);
68
+ /**
69
+ * Create a new thread
70
+ */
71
+ createThread(data: ICreateThreadRequest): Promise<IThread>;
72
+ /**
73
+ * Get a specific thread by ID
74
+ */
75
+ getThread(threadId: string): Promise<IThread>;
76
+ /**
77
+ * List threads with optional filters
78
+ */
79
+ listThreads(options?: {
80
+ integration?: string;
81
+ limit?: number;
82
+ page?: number;
83
+ sort?: string;
84
+ user?: string;
85
+ workspace?: string;
86
+ [key: string]: string | number;
87
+ }): Promise<IThread[]>;
88
+ /**
89
+ * Delete a thread
90
+ */
91
+ deleteThread(threadId: string): Promise<{
92
+ success: boolean;
93
+ }>;
94
+ /**
95
+ * Create a chat completion without a thread
96
+ */
97
+ chat(integrationId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
98
+ /**
99
+ * Create a chat completion with a thread
100
+ */
101
+ chatInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
102
+ /**
103
+ * Create a streaming chat completion without a thread
104
+ * Returns a ReadableStream for Server-Sent Events
105
+ */
106
+ streamChat(integrationId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
107
+ /**
108
+ * Create a streaming chat completion with a thread
109
+ * Returns a ReadableStream for Server-Sent Events
110
+ */
111
+ streamChatInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
112
+ /**
113
+ * Helper method to parse Server-Sent Events stream
114
+ */
115
+ parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor;
116
+ }
package/dist/ai.js ADDED
@@ -0,0 +1,175 @@
1
+ import BaseSDK from './base-sdk';
2
+ export default class QlAI extends BaseSDK {
3
+ relativePath = '/api/ai';
4
+ constructor(options) {
5
+ super(options);
6
+ }
7
+ // Thread CRUD Operations
8
+ /**
9
+ * Create a new thread
10
+ */
11
+ createThread(data) {
12
+ return this.callJsonApi(this.relativePath + '/threads', {
13
+ method: 'POST',
14
+ headers: { 'content-type': 'application/json' },
15
+ body: JSON.stringify(data)
16
+ });
17
+ }
18
+ /**
19
+ * Get a specific thread by ID
20
+ */
21
+ getThread(threadId) {
22
+ return this.callJsonApi(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`);
23
+ }
24
+ /**
25
+ * List threads with optional filters
26
+ */
27
+ listThreads(options) {
28
+ const queryParams = this.getQueryParams(options);
29
+ return this.callJsonApi(`${this.relativePath}/threads${queryParams}`);
30
+ }
31
+ /**
32
+ * Delete a thread
33
+ */
34
+ deleteThread(threadId) {
35
+ return this.callJsonApi(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`, {
36
+ method: 'DELETE'
37
+ });
38
+ }
39
+ // Chat Completion Operations
40
+ /**
41
+ * Create a chat completion without a thread
42
+ */
43
+ chat(integrationId, options) {
44
+ return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion${this.getQueryParams({})}`, {
45
+ method: 'POST',
46
+ headers: { 'content-type': 'application/json' },
47
+ body: JSON.stringify(options)
48
+ });
49
+ }
50
+ /**
51
+ * Create a chat completion with a thread
52
+ */
53
+ chatInThread(integrationId, threadId, options) {
54
+ return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${this.getQueryParams({})}`, {
55
+ method: 'POST',
56
+ headers: { 'content-type': 'application/json' },
57
+ body: JSON.stringify(options)
58
+ });
59
+ }
60
+ /**
61
+ * Create a streaming chat completion without a thread
62
+ * Returns a ReadableStream for Server-Sent Events
63
+ */
64
+ async streamChat(integrationId, options) {
65
+ const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion${this.getQueryParams({ stream: true })}`, {
66
+ method: 'POST',
67
+ headers: {
68
+ 'content-type': 'application/json',
69
+ 'accept': 'text/event-stream'
70
+ },
71
+ body: JSON.stringify({ ...options, stream: true })
72
+ });
73
+ if (!response.ok) {
74
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
75
+ }
76
+ return response.body;
77
+ }
78
+ /**
79
+ * Create a streaming chat completion with a thread
80
+ * Returns a ReadableStream for Server-Sent Events
81
+ */
82
+ async streamChatInThread(integrationId, threadId, options) {
83
+ const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${this.getQueryParams({ stream: true })}`, {
84
+ method: 'POST',
85
+ headers: {
86
+ 'content-type': 'application/json',
87
+ 'accept': 'text/event-stream'
88
+ },
89
+ body: JSON.stringify({ ...options, stream: true })
90
+ });
91
+ if (!response.ok) {
92
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
93
+ }
94
+ return response.body;
95
+ }
96
+ /**
97
+ * Helper method to parse Server-Sent Events stream
98
+ */
99
+ parseSSEStream(stream) {
100
+ const processStream = async (onData) => {
101
+ const reader = stream.getReader();
102
+ const decoder = new TextDecoder();
103
+ let buffer = "";
104
+ try {
105
+ while (true) {
106
+ const { done, value } = await reader.read();
107
+ if (done)
108
+ break;
109
+ buffer += decoder.decode(value, { stream: true });
110
+ let lines = buffer.split(/\r?\n/);
111
+ buffer = lines.pop() || ""; // Keep incomplete line
112
+ for (const line of lines) {
113
+ if (line.startsWith('data: ')) {
114
+ const data = line.slice(6);
115
+ if (data === '[DONE]')
116
+ return;
117
+ try {
118
+ const parsed = JSON.parse(data);
119
+ const shouldContinue = onData(parsed);
120
+ if (shouldContinue === false) {
121
+ return;
122
+ }
123
+ }
124
+ catch (e) {
125
+ // Skip invalid JSON
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ finally {
132
+ reader.releaseLock();
133
+ }
134
+ };
135
+ const processor = {
136
+ async *[Symbol.asyncIterator]() {
137
+ const reader = stream.getReader();
138
+ const decoder = new TextDecoder();
139
+ let buffer = "";
140
+ try {
141
+ while (true) {
142
+ const { done, value } = await reader.read();
143
+ if (done) {
144
+ break;
145
+ }
146
+ buffer += decoder.decode(value, { stream: true });
147
+ let lines = buffer.split(/\r?\n/);
148
+ buffer = lines.pop() || ""; // Keep incomplete line
149
+ for (const line of lines) {
150
+ if (line.startsWith('data: ')) {
151
+ const data = line.slice(6);
152
+ if (data === '[DONE]') {
153
+ return;
154
+ }
155
+ try {
156
+ const parsed = JSON.parse(data);
157
+ yield parsed;
158
+ }
159
+ catch (e) {
160
+ //
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ finally {
167
+ reader.releaseLock();
168
+ }
169
+ },
170
+ processManually: processStream
171
+ };
172
+ return processor;
173
+ }
174
+ }
175
+ //# sourceMappingURL=ai.js.map
package/dist/ai.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AAuEjC,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IAC/B,YAAY,GAAG,SAAS,CAAC;IACjC,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB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AAI,IAAI,KAAK,QAAQ,EAAE;oCACrB,OAAO;iCACR;gCAED,IAAI;oCACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oCAChC,MAAM,MAAM,CAAC;iCACd;gCAAC,OAAO,CAAC,EAAE;oCACV,EAAE;iCACH;6BACF;yBACF;qBACF;iBACF;wBAAS;oBACR,MAAM,CAAC,WAAW,EAAE,CAAC;iBACtB;YACH,CAAC;YAED,eAAe,EAAE,aAAa;SAC/B,CAAC;QAEF,OAAO,SAAgC,CAAC;IAC1C,CAAC;CACF"}
@@ -15,4 +15,11 @@ export default class QlBlueprints extends BaseSDK {
15
15
  getCount(blueprintKey: string, query?: Record<string, any>): Promise<{
16
16
  count: number;
17
17
  }>;
18
+ getSum(blueprintKey: string, sumProperty: string, groupByProperty?: string, query?: Record<string, any>): Promise<{
19
+ groups?: Array<{
20
+ group: any;
21
+ sum: number;
22
+ }>;
23
+ sum: number;
24
+ }>;
18
25
  }
@@ -32,5 +32,9 @@ export default class QlBlueprints extends BaseSDK {
32
32
  const qs = this.getQueryParams(query);
33
33
  return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/count${qs}`);
34
34
  }
35
+ getSum(blueprintKey, sumProperty, groupByProperty, query) {
36
+ const qs = this.getQueryParams({ ...query, sum: sumProperty, ...(groupByProperty && { groupBy: groupByProperty }) });
37
+ return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/sum${qs}`);
38
+ }
35
39
  }
36
40
  //# sourceMappingURL=blueprints.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../src/blueprints.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAK3B;IAJZ,YAAY,GAAG,iBAAiB,CAAC;IAEzC,SAAS,GAAG,IAAI,G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,CAAC;IAChH,CAAC;IAED,WAAW,CAAC,YAAoB,EAAE,KAA2B;QAC3D,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAsB,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,cAAc,EAAE,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,QAAQ,CAAC,YAAoB,EAAE,KAA2B;QACxD,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAoB,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,MAAM,CAAC,YAAoB,EAAE,WAAmB,EAAE,eAAwB,EAAE,KAA2B;QACrG,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC;QACrH,OAAO,IAAI,CAAC,WAAW,CAA+D,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,cAAc,EAAE,EAAE,CAAC,CAAC;IAChJ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ import QlAuthentication from './authentication';
6
6
  import QlWorkspaces from './workspaces';
7
7
  import QlInvites from './invites';
8
8
  import QlBlueprints from './blueprints';
9
+ import QlAI from './ai';
10
+ import QlLambdas from './lambdas';
9
11
  export default class QelosSDK extends BaseSDK {
10
12
  #private;
11
13
  private options;
@@ -15,6 +17,8 @@ export default class QelosSDK extends BaseSDK {
15
17
  workspaces: QlWorkspaces;
16
18
  invites: QlInvites;
17
19
  blueprints: QlBlueprints;
20
+ ai: QlAI;
21
+ lambdas: QlLambdas;
18
22
  constructor(options: QelosSDKOptions);
19
23
  setCustomHeader(key: string, value: string): void;
20
24
  removeCustomHeader(key: string): void;
package/dist/index.js CHANGED
@@ -5,6 +5,8 @@ import QlAuthentication from './authentication';
5
5
  import QlWorkspaces from './workspaces';
6
6
  import QlInvites from './invites';
7
7
  import QlBlueprints from './blueprints';
8
+ import QlAI from './ai';
9
+ import QlLambdas from './lambdas';
8
10
  const noExtraHeadersUrls = new Set(['/api/token/refresh', '/api/signin', '/api/signup']);
9
11
  export default class QelosSDK extends BaseSDK {
10
12
  options;
@@ -15,6 +17,8 @@ export default class QelosSDK extends BaseSDK {
15
17
  workspaces;
16
18
  invites;
17
19
  blueprints;
20
+ ai;
21
+ lambdas;
18
22
  constructor(options) {
19
23
  super(options);
20
24
  this.options = options;
@@ -24,6 +28,8 @@ export default class QelosSDK extends BaseSDK {
24
28
  this.workspaces = new QlWorkspaces(this.options);
25
29
  this.invites = new QlInvites(this.options);
26
30
  this.blueprints = new QlBlueprints(this.options);
31
+ this.ai = new QlAI(this.options);
32
+ this.lambdas = new QlLambdas(this.options);
27
33
  const isBrowser = globalThis.navigator && globalThis.window && globalThis.document;
28
34
  if (!options.getAccessToken) {
29
35
  options.getAccessToken = () => this.authentication.accessToken;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AACnD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;AAExF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OA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,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBACpD,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;iBACnC;gBACD,IAAI,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;gBACzD,IAAI,CAAC,KAAK,EAAE;oBACV,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;oBACzC,KAAK,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;iBAClC;gBACD,IAAI,KAAK,EAAE;oBACT,OAAO,EAAE,aAAa,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;iBACpE;gBACD,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YACnC,CAAC,CAAA;SACF;IACH,CAAC;IAED,eAAe,CAAC,GAAW,EAAE,KAAa;QACxC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnC,CAAC;IAED,kBAAkB,CAAC,GAAW;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import BaseSDK from "./base-sdk";
2
+ import { QelosSDKOptions } from "./types";
3
+ export default class QlLambdas extends BaseSDK {
4
+ private options;
5
+ private relativePath;
6
+ constructor(options: QelosSDKOptions);
7
+ execute(integrationId: string, data?: RequestInit): Promise<unknown>;
8
+ get(integrationId: string, data?: RequestInit): Promise<unknown>;
9
+ post(integrationId: string, data?: RequestInit): Promise<unknown>;
10
+ put(integrationId: string, data?: RequestInit): Promise<unknown>;
11
+ delete(integrationId: string, data?: RequestInit): Promise<unknown>;
12
+ }
@@ -0,0 +1,36 @@
1
+ import BaseSDK from "./base-sdk";
2
+ export default class QlLambdas extends BaseSDK {
3
+ options;
4
+ relativePath = '/api/webhooks';
5
+ constructor(options) {
6
+ super(options);
7
+ this.options = options;
8
+ }
9
+ execute(integrationId, data) {
10
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
11
+ }
12
+ get(integrationId, data) {
13
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
14
+ }
15
+ post(integrationId, data) {
16
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
17
+ method: 'POST',
18
+ body: data?.body ? JSON.stringify(data?.body) : undefined,
19
+ headers: { 'content-type': 'application/json' },
20
+ });
21
+ }
22
+ put(integrationId, data) {
23
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
24
+ method: 'PUT',
25
+ body: data?.body ? JSON.stringify(data?.body) : undefined,
26
+ headers: { 'content-type': 'application/json' },
27
+ });
28
+ }
29
+ delete(integrationId, data) {
30
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
31
+ ...data,
32
+ method: 'DELETE',
33
+ });
34
+ }
35
+ }
36
+ //# sourceMappingURL=lambdas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambdas.js","sourceRoot":"","sources":["../src/lambdas.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,OAAO;IAGxB;IAFZ,YAAY,GAAG,eAAe,CAAC;IAEvC,YAAoB,OAAwB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QADI,YAAO,GAAP,OAAO,CAAiB;IAE5C,CAAC;IAED,OAAO,CAAC,aAAqB,EAAE,IAAkB;QAC/C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,GAAG,CAAC,aAAqB,EAAE,IAAkB;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,CAAC,aAAqB,EAAE,IAAkB;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE;YAC/D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACzD,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,aAAqB,EAAE,IAAkB;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE;YAC/D,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACzD,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,aAAqB,EAAE,IAAkB;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE;YAC/D,GAAG,IAAI;YACP,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qelos/sdk",
3
- "version": "3.11.2",
3
+ "version": "3.11.3",
4
4
  "description": "SDK for Qelos API",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,38 @@
1
+ import BaseSDK from "../base-sdk";
2
+ import { QelosSDKOptions } from "../types";
3
+
4
+ export default class QlManageLambdas extends BaseSDK {
5
+ private relativePath = '/api/lambdas';
6
+
7
+ constructor(private options: QelosSDKOptions) {
8
+ super(options)
9
+ }
10
+
11
+ public getList(sourceId: string) {
12
+ return this.callJsonApi(`${this.relativePath}/${sourceId}`);
13
+ }
14
+
15
+ public getLambda(sourceId: string, functionName: string) {
16
+ return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`);
17
+ }
18
+
19
+ public create(sourceId: string, data: any) {
20
+ return this.callJsonApi(`${this.relativePath}/${sourceId}`, {
21
+ method: 'POST',
22
+ body: JSON.stringify(data),
23
+ headers: { 'content-type': 'application/json' },
24
+ });
25
+ }
26
+
27
+ public update(sourceId: string, functionName: string, data: any) {
28
+ return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`, {
29
+ method: 'PUT',
30
+ body: JSON.stringify(data),
31
+ headers: { 'content-type': 'application/json' },
32
+ });
33
+ }
34
+
35
+ public remove(sourceId: string, functionName: string) {
36
+ return this.callApi(`${this.relativePath}/${sourceId}/${functionName}`, { method: 'DELETE' });
37
+ }
38
+ }
@@ -10,9 +10,12 @@ import { QlRoles } from './roles';
10
10
  import QlIntegrationSources from './integration-sources';
11
11
  import QlManagePlugins from './manage-plugins';
12
12
  import QlComponents from './components';
13
+ import QlIntegrations from './integrations';
14
+ import QlManageLambdas from './admin-lambdas';
13
15
 
14
16
 
15
17
  export default class QelosAdministratorSDK<T = any> extends QelosSDK {
18
+ manageLambdas: QlManageLambdas;
16
19
  users: QlUsers<T>;
17
20
  manageConfigurations: QlManageConfigurations;
18
21
  manageBlueprints: QlManageBlueprints;
@@ -23,9 +26,11 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
23
26
  integrationSources: QlIntegrationSources;
24
27
  managePlugins: QlManagePlugins;
25
28
  components: QlComponents;
29
+ integrations: QlIntegrations;
26
30
 
27
31
  constructor(options: QelosSDKOptions) {
28
32
  super(options);
33
+ this.manageLambdas = new QlManageLambdas(options);
29
34
  this.users = new QlUsers<T>(options);
30
35
  this.manageConfigurations = new QlManageConfigurations(options);
31
36
  this.manageBlueprints = new QlManageBlueprints(options);
@@ -36,6 +41,7 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
36
41
  this.integrationSources = new QlIntegrationSources(options);
37
42
  this.managePlugins = new QlManagePlugins(options);
38
43
  this.components = new QlComponents(options);
44
+ this.integrations = new QlIntegrations(options);
39
45
 
40
46
  if (!options.extraQueryParams) {
41
47
  options.extraQueryParams = () => ({
@@ -55,4 +61,4 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
55
61
  this.removeCustomHeader('x-impersonate-user');
56
62
  this.removeCustomHeader('x-impersonate-workspace');
57
63
  }
58
- }
64
+ }
@@ -0,0 +1,65 @@
1
+ import { QelosSDKOptions, RequestExtra } from '../types';
2
+ import BaseSDK from '../base-sdk';
3
+ import { IIntegration } from '@qelos/global-types';
4
+
5
+ export default class QlIntegrations extends BaseSDK {
6
+ private relativePath = '/api/integrations';
7
+
8
+ constructor(private options: QelosSDKOptions) {
9
+ super(options)
10
+ }
11
+
12
+ getIntegration(integrationId: string, extra?: RequestExtra) {
13
+ return this.callJsonApi<IIntegration>(`${this.relativePath}/${integrationId}`, extra);
14
+ }
15
+
16
+ getList(query?: {
17
+ plugin?: string;
18
+ user?: string;
19
+ 'trigger.source'?: string;
20
+ 'target.source'?: string;
21
+ 'trigger.kind'?: string;
22
+ 'target.kind'?: string;
23
+ kind?: string;
24
+ source?: string;
25
+ active?: boolean;
26
+ id?: string;
27
+ _id?: string;
28
+ }, extra?: RequestExtra) {
29
+ return this.callJsonApi<IIntegration[]>(this.relativePath + this.getQueryParams(query), extra);
30
+ }
31
+
32
+ remove(integrationId: string): Promise<any> {
33
+ return this.callApi(`${this.relativePath}/${integrationId}`, { method: 'delete' });
34
+ }
35
+
36
+ update(integrationId: string, changes: {
37
+ active?: boolean;
38
+ trigger?: any;
39
+ target?: any;
40
+ dataManipulation?: any;
41
+ }): Promise<IIntegration> {
42
+ return this.callJsonApi<IIntegration>(
43
+ `${this.relativePath}/${integrationId}`,
44
+ {
45
+ method: 'put',
46
+ headers: { 'content-type': 'application/json' },
47
+ body: JSON.stringify(changes)
48
+ }
49
+ )
50
+ }
51
+
52
+ create(integration: {
53
+ trigger: any;
54
+ target: any;
55
+ dataManipulation?: any;
56
+ active?: boolean;
57
+ }): Promise<IIntegration> {
58
+ return this.callJsonApi<IIntegration>(this.relativePath, {
59
+ method: 'post',
60
+ headers: { 'content-type': 'application/json' },
61
+ body: JSON.stringify(integration)
62
+ })
63
+ }
64
+
65
+ }
package/src/ai.ts ADDED
@@ -0,0 +1,295 @@
1
+ import { QelosSDKOptions } from './types';
2
+ import BaseSDK from './base-sdk';
3
+
4
+ export interface IMessage {
5
+ role: string;
6
+ content: string;
7
+ timestamp?: Date | string;
8
+ tool_calls?: any[];
9
+ name?: string;
10
+ tool_call_id?: string;
11
+ function_call?: any;
12
+ message_id?: string;
13
+ }
14
+
15
+ export interface IMessageSummary {
16
+ fromIndex: number;
17
+ toIndex: number;
18
+ summary: string;
19
+ }
20
+
21
+ export interface IThread {
22
+ _id?: string;
23
+ integration: string;
24
+ title?: string;
25
+ messages: IMessage[];
26
+ messageSummaries: IMessageSummary[];
27
+ created?: Date;
28
+ updated?: Date;
29
+ user?: string;
30
+ workspace?: string;
31
+ }
32
+
33
+ export interface IChatCompletionOptions {
34
+ messages: IMessage[];
35
+ model?: string;
36
+ temperature?: number;
37
+ top_p?: number;
38
+ frequency_penalty?: number;
39
+ presence_penalty?: number;
40
+ stop?: string | string[];
41
+ max_tokens?: number;
42
+ response_format?: any;
43
+ context?: Record<string, any>;
44
+ stream?: boolean;
45
+ }
46
+
47
+ export interface ISSEStreamProcessor extends AsyncIterable<any> {
48
+ processManually(onData: (data: any) => void | boolean): Promise<void>;
49
+ }
50
+
51
+ export interface IChatCompletionResponse {
52
+ id: string;
53
+ object: string;
54
+ created: number;
55
+ model: string;
56
+ choices: Array<{
57
+ index: number;
58
+ message: IMessage;
59
+ finish_reason: string;
60
+ }>;
61
+ usage?: {
62
+ prompt_tokens: number;
63
+ completion_tokens: number;
64
+ total_tokens: number;
65
+ };
66
+ }
67
+
68
+ export interface ICreateThreadRequest {
69
+ integration: string;
70
+ title?: string;
71
+ }
72
+
73
+ export default class QlAI extends BaseSDK {
74
+ private relativePath = '/api/ai';
75
+ constructor(options: QelosSDKOptions) {
76
+ super(options);
77
+ }
78
+
79
+ // Thread CRUD Operations
80
+
81
+ /**
82
+ * Create a new thread
83
+ */
84
+ createThread(data: ICreateThreadRequest): Promise<IThread> {
85
+ return this.callJsonApi<IThread>(this.relativePath + '/threads', {
86
+ method: 'POST',
87
+ headers: { 'content-type': 'application/json' },
88
+ body: JSON.stringify(data)
89
+ });
90
+ }
91
+
92
+ /**
93
+ * Get a specific thread by ID
94
+ */
95
+ getThread(threadId: string): Promise<IThread> {
96
+ return this.callJsonApi<IThread>(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`);
97
+ }
98
+
99
+ /**
100
+ * List threads with optional filters
101
+ */
102
+ listThreads(options?: {
103
+ integration?: string;
104
+ limit?: number;
105
+ page?: number;
106
+ sort?: string;
107
+ user?: string;
108
+ workspace?: string;
109
+ [key: string]: string | number;
110
+ }): Promise<IThread[]> {
111
+ const queryParams = this.getQueryParams(options);
112
+ return this.callJsonApi<IThread[]>(
113
+ `${this.relativePath}/threads${queryParams}`
114
+ );
115
+ }
116
+
117
+ /**
118
+ * Delete a thread
119
+ */
120
+ deleteThread(threadId: string): Promise<{ success: boolean }> {
121
+ return this.callJsonApi<{ success: boolean }>(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`, {
122
+ method: 'DELETE'
123
+ });
124
+ }
125
+
126
+ // Chat Completion Operations
127
+
128
+ /**
129
+ * Create a chat completion without a thread
130
+ */
131
+ chat(
132
+ integrationId: string,
133
+ options: IChatCompletionOptions
134
+ ): Promise<IChatCompletionResponse> {
135
+ return this.callJsonApi<IChatCompletionResponse>(`${this.relativePath}/${integrationId}/chat-completion${this.getQueryParams({})}`, {
136
+ method: 'POST',
137
+ headers: { 'content-type': 'application/json' },
138
+ body: JSON.stringify(options)
139
+ });
140
+ }
141
+
142
+ /**
143
+ * Create a chat completion with a thread
144
+ */
145
+ chatInThread(
146
+ integrationId: string,
147
+ threadId: string,
148
+ options: IChatCompletionOptions
149
+ ): Promise<IChatCompletionResponse> {
150
+ return this.callJsonApi<IChatCompletionResponse>(
151
+ `${this.relativePath}/${integrationId}/chat-completion/${threadId}${this.getQueryParams({})}`,
152
+ {
153
+ method: 'POST',
154
+ headers: { 'content-type': 'application/json' },
155
+ body: JSON.stringify(options)
156
+ }
157
+ );
158
+ }
159
+
160
+ /**
161
+ * Create a streaming chat completion without a thread
162
+ * Returns a ReadableStream for Server-Sent Events
163
+ */
164
+ async streamChat(
165
+ integrationId: string,
166
+ options: IChatCompletionOptions
167
+ ): Promise<ReadableStream<Uint8Array>> {
168
+ const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion${this.getQueryParams({ stream: true })}`, {
169
+ method: 'POST',
170
+ headers: {
171
+ 'content-type': 'application/json',
172
+ 'accept': 'text/event-stream'
173
+ },
174
+ body: JSON.stringify({ ...options, stream: true })
175
+ });
176
+
177
+ if (!response.ok) {
178
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
179
+ }
180
+
181
+ return response.body!;
182
+ }
183
+
184
+ /**
185
+ * Create a streaming chat completion with a thread
186
+ * Returns a ReadableStream for Server-Sent Events
187
+ */
188
+ async streamChatInThread(
189
+ integrationId: string,
190
+ threadId: string,
191
+ options: IChatCompletionOptions
192
+ ): Promise<ReadableStream<Uint8Array>> {
193
+ const response = await this.callApi(
194
+ `${this.relativePath}/${integrationId}/chat-completion/${threadId}${this.getQueryParams({ stream: true })}`,
195
+ {
196
+ method: 'POST',
197
+ headers: {
198
+ 'content-type': 'application/json',
199
+ 'accept': 'text/event-stream'
200
+ },
201
+ body: JSON.stringify({ ...options, stream: true })
202
+ }
203
+ );
204
+
205
+ if (!response.ok) {
206
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
207
+ }
208
+
209
+ return response.body!;
210
+ }
211
+
212
+ /**
213
+ * Helper method to parse Server-Sent Events stream
214
+ */
215
+ parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor {
216
+ const processStream = async (onData: (data: any) => void | boolean): Promise<void> => {
217
+ const reader = stream.getReader();
218
+ const decoder = new TextDecoder();
219
+ let buffer = "";
220
+
221
+ try {
222
+ while (true) {
223
+ const { done, value } = await reader.read();
224
+ if (done) break;
225
+
226
+ buffer += decoder.decode(value, { stream: true });
227
+ let lines = buffer.split(/\r?\n/);
228
+ buffer = lines.pop() || ""; // Keep incomplete line
229
+
230
+ for (const line of lines) {
231
+ if (line.startsWith('data: ')) {
232
+ const data = line.slice(6);
233
+ if (data === '[DONE]') return;
234
+
235
+ try {
236
+ const parsed = JSON.parse(data);
237
+ const shouldContinue = onData(parsed);
238
+ if (shouldContinue === false) {
239
+ return;
240
+ }
241
+ } catch (e) {
242
+ // Skip invalid JSON
243
+ }
244
+ }
245
+ }
246
+ }
247
+ } finally {
248
+ reader.releaseLock();
249
+ }
250
+ };
251
+
252
+ const processor = {
253
+ async *[Symbol.asyncIterator]() {
254
+ const reader = stream.getReader();
255
+ const decoder = new TextDecoder();
256
+ let buffer = "";
257
+
258
+ try {
259
+ while (true) {
260
+ const { done, value } = await reader.read();
261
+ if (done) {
262
+ break;
263
+ }
264
+
265
+ buffer += decoder.decode(value, { stream: true });
266
+ let lines = buffer.split(/\r?\n/);
267
+ buffer = lines.pop() || ""; // Keep incomplete line
268
+
269
+ for (const line of lines) {
270
+ if (line.startsWith('data: ')) {
271
+ const data = line.slice(6);
272
+ if (data === '[DONE]') {
273
+ return;
274
+ }
275
+
276
+ try {
277
+ const parsed = JSON.parse(data);
278
+ yield parsed;
279
+ } catch (e) {
280
+ //
281
+ }
282
+ }
283
+ }
284
+ }
285
+ } finally {
286
+ reader.releaseLock();
287
+ }
288
+ },
289
+
290
+ processManually: processStream
291
+ };
292
+
293
+ return processor as ISSEStreamProcessor;
294
+ }
295
+ }
package/src/blueprints.ts CHANGED
@@ -41,4 +41,9 @@ export default class QlBlueprints extends BaseSDK {
41
41
  const qs = this.getQueryParams(query);
42
42
  return this.callJsonApi<{ count: number }>(`${this.relativePath}/${blueprintKey}/charts/count${qs}`);
43
43
  }
44
+
45
+ getSum(blueprintKey: string, sumProperty: string, groupByProperty?: string, query?: Record<string, any>) {
46
+ const qs = this.getQueryParams({ ...query, sum: sumProperty, ...(groupByProperty && { groupBy: groupByProperty }) });
47
+ return this.callJsonApi<{ groups?: Array<{ group: any; sum: number }>; sum: number }>(`${this.relativePath}/${blueprintKey}/charts/sum${qs}`);
48
+ }
44
49
  }
package/src/index.ts CHANGED
@@ -6,6 +6,8 @@ import QlAuthentication from './authentication';
6
6
  import QlWorkspaces from './workspaces';
7
7
  import QlInvites from './invites';
8
8
  import QlBlueprints from './blueprints';
9
+ import QlAI from './ai';
10
+ import QlLambdas from './lambdas';
9
11
 
10
12
  const noExtraHeadersUrls = new Set(['/api/token/refresh', '/api/signin', '/api/signup'])
11
13
 
@@ -18,6 +20,8 @@ export default class QelosSDK extends BaseSDK {
18
20
  workspaces: QlWorkspaces;
19
21
  invites: QlInvites;
20
22
  blueprints: QlBlueprints;
23
+ ai: QlAI;
24
+ lambdas: QlLambdas;
21
25
 
22
26
  constructor(private options: QelosSDKOptions) {
23
27
  super(options);
@@ -27,6 +31,8 @@ export default class QelosSDK extends BaseSDK {
27
31
  this.workspaces = new QlWorkspaces(this.options);
28
32
  this.invites = new QlInvites(this.options);
29
33
  this.blueprints = new QlBlueprints(this.options);
34
+ this.ai = new QlAI(this.options);
35
+ this.lambdas = new QlLambdas(this.options);
30
36
 
31
37
  const isBrowser = globalThis.navigator && globalThis.window && globalThis.document
32
38
 
@@ -59,5 +65,4 @@ export default class QelosSDK extends BaseSDK {
59
65
  removeCustomHeader(key: string) {
60
66
  delete this.#customHeaders[key];
61
67
  }
62
-
63
- }
68
+ }
package/src/lambdas.ts ADDED
@@ -0,0 +1,41 @@
1
+ import BaseSDK from "./base-sdk";
2
+ import { QelosSDKOptions } from "./types";
3
+
4
+ export default class QlLambdas extends BaseSDK {
5
+ private relativePath = '/api/webhooks';
6
+
7
+ constructor(private options: QelosSDKOptions) {
8
+ super(options)
9
+ }
10
+
11
+ execute(integrationId: string, data?: RequestInit) {
12
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
13
+ }
14
+
15
+ get(integrationId: string, data?: RequestInit) {
16
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
17
+ }
18
+
19
+ post(integrationId: string, data?: RequestInit) {
20
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
21
+ method: 'POST',
22
+ body: data?.body ? JSON.stringify(data?.body) : undefined,
23
+ headers: { 'content-type': 'application/json' },
24
+ });
25
+ }
26
+
27
+ put(integrationId: string, data?: RequestInit) {
28
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
29
+ method: 'PUT',
30
+ body: data?.body ? JSON.stringify(data?.body) : undefined,
31
+ headers: { 'content-type': 'application/json' },
32
+ });
33
+ }
34
+
35
+ delete(integrationId: string, data?: RequestInit) {
36
+ return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
37
+ ...data,
38
+ method: 'DELETE',
39
+ });
40
+ }
41
+ }