@narrative.io/data-collaboration-sdk-ts 0.0.107 → 0.0.108
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/build/access-rules/index.d.ts +44 -0
- package/build/access-rules/index.js +51 -0
- package/build/access-rules/types.d.ts +29 -0
- package/build/access-rules/types.js +1 -0
- package/build/apps/index.d.ts +3 -3
- package/build/apps/index.js +4 -4
- package/build/apps/types.d.ts +1 -1
- package/build/apps/types.js +0 -1
- package/build/attributes/index.d.ts +9 -9
- package/build/attributes/index.js +8 -8
- package/build/attributes/types.d.ts +5 -5
- package/build/authentication/index.d.ts +3 -3
- package/build/authentication/index.js +3 -3
- package/build/authentication/types.d.ts +3 -3
- package/build/base-api.d.ts +42 -42
- package/build/base-api.js +51 -51
- package/build/company-info/index.d.ts +3 -3
- package/build/company-info/index.js +2 -2
- package/build/contracts/index.d.ts +18 -18
- package/build/contracts/index.js +18 -18
- package/build/contracts/types.d.ts +3 -3
- package/build/data-streams/index.d.ts +10 -10
- package/build/data-streams/index.js +9 -9
- package/build/data-streams/types.d.ts +7 -7
- package/build/datasets/index.d.ts +30 -30
- package/build/datasets/index.js +32 -32
- package/build/datasets/types.d.ts +9 -9
- package/build/forecast/index.d.ts +3 -3
- package/build/forecast/index.js +3 -3
- package/build/forecast/types.d.ts +7 -7
- package/build/health/index.d.ts +2 -2
- package/build/health/index.js +2 -2
- package/build/health/types.d.ts +1 -1
- package/build/index.d.ts +32 -31
- package/build/index.js +44 -24
- package/build/installations/index.d.ts +3 -3
- package/build/installations/index.js +3 -3
- package/build/installations/types.d.ts +1 -1
- package/build/mappings/index.d.ts +16 -16
- package/build/mappings/index.js +18 -18
- package/build/mappings/types.d.ts +6 -6
- package/build/nql/DataRulesConverter.d.ts +3 -3
- package/build/nql/DataRulesConverter.js +55 -31
- package/build/nql/NQLParser.d.ts +4 -4
- package/build/nql/NQLParser.js +74 -57
- package/build/nql/SubstraitParser.d.ts +173 -173
- package/build/nql/SubstraitParser.js +270 -261
- package/build/nql/index.d.ts +4 -4
- package/build/nql/index.js +3 -3
- package/build/nql/types.d.ts +6 -6
- package/build/nql/types.js +59 -29
- package/build/ping/index.d.ts +2 -2
- package/build/ping/index.js +2 -2
- package/build/ping/types.d.ts +1 -1
- package/build/products/index.d.ts +6 -6
- package/build/products/index.js +6 -6
- package/build/products/types.d.ts +4 -4
- package/build/resources/index.d.ts +4 -4
- package/build/resources/index.js +2 -2
- package/build/resources/types.d.ts +3 -3
- package/build/rosetta/types.d.ts +12 -12
- package/build/rosetta/types.js +69 -42
- package/build/rosetta-stone/index.d.ts +3 -3
- package/build/rosetta-stone/index.js +3 -3
- package/build/types.d.ts +2 -2
- package/build/uploads/index.d.ts +8 -8
- package/build/uploads/index.js +8 -8
- package/build/utils.js +1 -1
- package/package.json +3 -1
package/build/rosetta/types.js
CHANGED
|
@@ -1,31 +1,43 @@
|
|
|
1
|
-
import z from
|
|
1
|
+
import z from "zod";
|
|
2
2
|
/// ///////////////////
|
|
3
3
|
// Role Enum
|
|
4
4
|
/// ///////////////////
|
|
5
|
-
const ChatCompletionRequestMessageRoleEnum = z.enum([
|
|
5
|
+
const ChatCompletionRequestMessageRoleEnum = z.enum([
|
|
6
|
+
"system",
|
|
7
|
+
"user",
|
|
8
|
+
"assistant",
|
|
9
|
+
"function",
|
|
10
|
+
]);
|
|
6
11
|
const isConversationMessageRole = (input) => {
|
|
7
12
|
return ChatCompletionRequestMessageRoleEnum.safeParse(input).success;
|
|
8
13
|
};
|
|
9
14
|
/// ///////////////////
|
|
10
15
|
// Name Type
|
|
11
16
|
/// ///////////////////
|
|
12
|
-
const ChatCompletionRequestMessageName = z
|
|
13
|
-
|
|
17
|
+
const ChatCompletionRequestMessageName = z
|
|
18
|
+
.string()
|
|
19
|
+
.max(64)
|
|
20
|
+
.refine((value) => /^[\w]*$/.test(value), {
|
|
21
|
+
message: "String may only contain a-z, A-Z, 0-9, and underscores",
|
|
14
22
|
});
|
|
15
23
|
const isConversationMessageName = (input) => {
|
|
16
24
|
return ChatCompletionRequestMessageName.safeParse(input).success;
|
|
17
25
|
};
|
|
18
26
|
// Valid timestampes for Rosetta AI Messages
|
|
19
|
-
const ChatCompletionRequestMessageTimestamp = z
|
|
27
|
+
const ChatCompletionRequestMessageTimestamp = z
|
|
28
|
+
.number()
|
|
29
|
+
.int()
|
|
30
|
+
.min(1670112000000)
|
|
31
|
+
.max(Date.now() + 1000 * 60 * 60 * 24);
|
|
20
32
|
/// ///////////////////
|
|
21
33
|
// User Message
|
|
22
34
|
/// ///////////////////
|
|
23
35
|
const ChatCompletionRequestUserMessageSchema = z.object({
|
|
24
|
-
role: z.enum([
|
|
36
|
+
role: z.enum(["user"]),
|
|
25
37
|
content: z.string().min(1),
|
|
26
38
|
name: ChatCompletionRequestMessageName.optional(),
|
|
27
39
|
timestamp: ChatCompletionRequestMessageTimestamp.optional(),
|
|
28
|
-
id: z.string().optional()
|
|
40
|
+
id: z.string().optional(),
|
|
29
41
|
});
|
|
30
42
|
const isConversationUserMessage = (input) => {
|
|
31
43
|
return ChatCompletionRequestUserMessageSchema.safeParse(input).success;
|
|
@@ -35,7 +47,7 @@ const isConversationUserMessage = (input) => {
|
|
|
35
47
|
/// ///////////////////
|
|
36
48
|
const ChatCompletionRequestMessageFunctionCall = z.object({
|
|
37
49
|
name: z.string(),
|
|
38
|
-
arguments: z.string()
|
|
50
|
+
arguments: z.string(),
|
|
39
51
|
});
|
|
40
52
|
const isConversationMessageFunctionCall = (input) => {
|
|
41
53
|
return ChatCompletionRequestMessageFunctionCall.safeParse(input).success;
|
|
@@ -43,22 +55,27 @@ const isConversationMessageFunctionCall = (input) => {
|
|
|
43
55
|
/// ///////////////////
|
|
44
56
|
// Assistant Message
|
|
45
57
|
/// ///////////////////
|
|
46
|
-
const ChatCompletionRequestAssistantMessageWithFunctionCall = z
|
|
47
|
-
|
|
58
|
+
const ChatCompletionRequestAssistantMessageWithFunctionCall = z
|
|
59
|
+
.object({
|
|
60
|
+
role: z.enum(["assistant"]),
|
|
48
61
|
content: z.null().or(z.string()),
|
|
49
62
|
function_call: ChatCompletionRequestMessageFunctionCall,
|
|
50
63
|
timestamp: ChatCompletionRequestMessageTimestamp.optional(),
|
|
51
|
-
id: z.string().optional()
|
|
52
|
-
})
|
|
64
|
+
id: z.string().optional(),
|
|
65
|
+
})
|
|
66
|
+
.strict();
|
|
53
67
|
const isConversationAssistantMessageWithFunctionCall = (input) => {
|
|
54
|
-
return ChatCompletionRequestAssistantMessageWithFunctionCall.safeParse(input)
|
|
68
|
+
return ChatCompletionRequestAssistantMessageWithFunctionCall.safeParse(input)
|
|
69
|
+
.success;
|
|
55
70
|
};
|
|
56
|
-
const ChatCompletionRequestAssistantMessageWihtoutFunctionCall = z
|
|
57
|
-
|
|
71
|
+
const ChatCompletionRequestAssistantMessageWihtoutFunctionCall = z
|
|
72
|
+
.object({
|
|
73
|
+
role: z.enum(["assistant"]),
|
|
58
74
|
content: z.string(),
|
|
59
75
|
timestamp: ChatCompletionRequestMessageTimestamp.optional(),
|
|
60
|
-
id: z.string().optional()
|
|
61
|
-
})
|
|
76
|
+
id: z.string().optional(),
|
|
77
|
+
})
|
|
78
|
+
.strict();
|
|
62
79
|
const isConversationAssistantMessageWithoutFunctionCall = (input) => {
|
|
63
80
|
return ChatCompletionRequestAssistantMessageWihtoutFunctionCall.safeParse(input).success;
|
|
64
81
|
};
|
|
@@ -70,8 +87,8 @@ const isConversationAssistantMessage = (input) => {
|
|
|
70
87
|
// System Message
|
|
71
88
|
/// ///////////////////
|
|
72
89
|
const ChatCompletionSystemMessageSchema = z.object({
|
|
73
|
-
role: z.enum([
|
|
74
|
-
content: z.string()
|
|
90
|
+
role: z.enum(["system"]),
|
|
91
|
+
content: z.string(),
|
|
75
92
|
});
|
|
76
93
|
const isConversationSystemMessage = (input) => {
|
|
77
94
|
return ChatCompletionSystemMessageSchema.safeParse(input).success;
|
|
@@ -80,11 +97,11 @@ const isConversationSystemMessage = (input) => {
|
|
|
80
97
|
// Function Message
|
|
81
98
|
/// ///////////////////
|
|
82
99
|
const ChatCompletionFunctionMessageSchema = z.object({
|
|
83
|
-
role: z.enum([
|
|
100
|
+
role: z.enum(["function"]),
|
|
84
101
|
content: z.string(),
|
|
85
102
|
name: z.string(),
|
|
86
103
|
timestamp: ChatCompletionRequestMessageTimestamp.optional(),
|
|
87
|
-
id: z.string().optional()
|
|
104
|
+
id: z.string().optional(),
|
|
88
105
|
});
|
|
89
106
|
const isConversationFunctionMessage = (input) => {
|
|
90
107
|
return ChatCompletionFunctionMessageSchema.safeParse(input).success;
|
|
@@ -96,7 +113,7 @@ const ChatCompletionRequestMessageSchema = z.union([
|
|
|
96
113
|
ChatCompletionRequestUserMessageSchema,
|
|
97
114
|
ChatCompletionAssistantMessage,
|
|
98
115
|
ChatCompletionSystemMessageSchema,
|
|
99
|
-
ChatCompletionFunctionMessageSchema
|
|
116
|
+
ChatCompletionFunctionMessageSchema,
|
|
100
117
|
]);
|
|
101
118
|
const isConversationMessage = (input) => {
|
|
102
119
|
return ChatCompletionRequestMessageSchema.safeParse(input).success;
|
|
@@ -107,40 +124,47 @@ const isConversationMessage = (input) => {
|
|
|
107
124
|
function validateFunctionOrder(messages) {
|
|
108
125
|
for (let i = 1; i < messages.length; i++) {
|
|
109
126
|
// Start from the second element
|
|
110
|
-
if (messages[i].role ===
|
|
127
|
+
if (messages[i].role === "function") {
|
|
111
128
|
const previousMessage = messages[i - 1];
|
|
112
|
-
if (!(previousMessage.role ===
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
if (!(previousMessage.role === "assistant" &&
|
|
130
|
+
"function_call" in previousMessage)) {
|
|
131
|
+
console.error("A message with role `function` must directly follow a message with role `assistant` and function_call not undefined", JSON.stringify(messages[i], null, 2), JSON.stringify(previousMessage, null, 2));
|
|
132
|
+
return {
|
|
133
|
+
valid: false,
|
|
134
|
+
error: "A message with role `function` must directly follow a message with role `assistant` and function_call not undefined",
|
|
135
|
+
index: i,
|
|
136
|
+
};
|
|
115
137
|
}
|
|
116
138
|
}
|
|
117
139
|
}
|
|
118
140
|
return { valid: true };
|
|
119
141
|
}
|
|
120
|
-
const ChatCompletionRequestMessagesSchema = z
|
|
142
|
+
const ChatCompletionRequestMessagesSchema = z
|
|
143
|
+
.array(ChatCompletionRequestMessageSchema)
|
|
144
|
+
.min(1)
|
|
121
145
|
.refine(
|
|
122
146
|
// We should have at most one system message
|
|
123
147
|
(data) => {
|
|
124
|
-
const systemMessageCount = data.filter((message) => message.role ===
|
|
148
|
+
const systemMessageCount = data.filter((message) => message.role === "system").length;
|
|
125
149
|
return systemMessageCount <= 1;
|
|
126
150
|
}, {
|
|
127
|
-
message:
|
|
151
|
+
message: "The message array can have at most one system message",
|
|
128
152
|
})
|
|
129
153
|
.refine(
|
|
130
154
|
// If there is a system message it should be the first message
|
|
131
155
|
(data) => {
|
|
132
|
-
const systemMessageIndex = data.findIndex((message) => message.role ===
|
|
156
|
+
const systemMessageIndex = data.findIndex((message) => message.role === "system");
|
|
133
157
|
return systemMessageIndex === 0 || systemMessageIndex === -1;
|
|
134
158
|
}, {
|
|
135
|
-
message:
|
|
159
|
+
message: "The system message needs to be the first message in the array",
|
|
136
160
|
})
|
|
137
161
|
.refine(
|
|
138
162
|
// We should have at most one system message
|
|
139
163
|
(data) => {
|
|
140
|
-
const userMessageCount = data.find((message) => message.role ===
|
|
164
|
+
const userMessageCount = data.find((message) => message.role === "user");
|
|
141
165
|
return userMessageCount !== undefined;
|
|
142
166
|
}, {
|
|
143
|
-
message:
|
|
167
|
+
message: "The message array must have at least one user message",
|
|
144
168
|
})
|
|
145
169
|
.refine((data) => {
|
|
146
170
|
return validateFunctionOrder(data).valid;
|
|
@@ -154,7 +178,7 @@ const isConversationMessages = (input) => {
|
|
|
154
178
|
const ChatCompletionRequestInputMessageSchema = z.union([
|
|
155
179
|
ChatCompletionRequestUserMessageSchema,
|
|
156
180
|
ChatCompletionAssistantMessage,
|
|
157
|
-
ChatCompletionFunctionMessageSchema
|
|
181
|
+
ChatCompletionFunctionMessageSchema,
|
|
158
182
|
]);
|
|
159
183
|
const isConversationInputMessage = (input) => {
|
|
160
184
|
return ChatCompletionRequestInputMessageSchema.safeParse(input).success;
|
|
@@ -163,27 +187,30 @@ const isConversationInputMessage = (input) => {
|
|
|
163
187
|
// WebSocket Client -> Server
|
|
164
188
|
/// ///////////////////////////
|
|
165
189
|
const RequestMessageSchema = z.object({
|
|
166
|
-
type: z.literal(
|
|
190
|
+
type: z.literal("request"),
|
|
167
191
|
data: z.object({
|
|
168
192
|
input: z.string(),
|
|
169
193
|
apiKey: z.string().optional(),
|
|
170
|
-
team_member: z
|
|
171
|
-
|
|
194
|
+
team_member: z
|
|
195
|
+
.string()
|
|
196
|
+
.optional()
|
|
197
|
+
.describe("The team member who should handle the request"),
|
|
198
|
+
}),
|
|
172
199
|
});
|
|
173
200
|
const PingEventSchema = z.object({
|
|
174
|
-
type: z.literal(
|
|
201
|
+
type: z.literal("ping"),
|
|
175
202
|
});
|
|
176
203
|
const ClearHistoryEventSchema = z.object({
|
|
177
|
-
type: z.literal(
|
|
204
|
+
type: z.literal("clearHistory"),
|
|
178
205
|
});
|
|
179
206
|
const HistoryEventSchema = z.object({
|
|
180
|
-
type: z.literal(
|
|
207
|
+
type: z.literal("history"),
|
|
181
208
|
});
|
|
182
209
|
const RosettaRequestMessageSchema = z.union([
|
|
183
210
|
RequestMessageSchema,
|
|
184
211
|
PingEventSchema,
|
|
185
212
|
ClearHistoryEventSchema,
|
|
186
|
-
HistoryEventSchema
|
|
213
|
+
HistoryEventSchema,
|
|
187
214
|
]);
|
|
188
215
|
const isRosettaRequestMessage = (input) => {
|
|
189
216
|
return RosettaRequestMessageSchema.safeParse(input).success;
|
|
@@ -197,4 +224,4 @@ function isType(input, schema) {
|
|
|
197
224
|
/// ///////////////////
|
|
198
225
|
// Exports
|
|
199
226
|
/// ///////////////////
|
|
200
|
-
export { isConversationMessageRole, isConversationMessageName, isConversationUserMessage, isConversationAssistantMessage, isConversationSystemMessage, isConversationFunctionMessage, isConversationMessage, isConversationInputMessage, isConversationMessages, isType, isRosettaRequestMessage, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall };
|
|
227
|
+
export { isConversationMessageRole, isConversationMessageName, isConversationUserMessage, isConversationAssistantMessage, isConversationSystemMessage, isConversationFunctionMessage, isConversationMessage, isConversationInputMessage, isConversationMessages, isType, isRosettaRequestMessage, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseApi } from
|
|
2
|
-
import type { RosettaStoneResponse, SampleRecords, SampleRecord } from
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { RosettaStoneResponse, SampleRecords, SampleRecord } from "./types";
|
|
3
3
|
declare class RosettaStoneApi extends BaseApi {
|
|
4
4
|
getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]>;
|
|
5
5
|
}
|
|
6
|
-
export { RosettaStoneApi, type SampleRecords, type RosettaStoneResponse, type SampleRecord };
|
|
6
|
+
export { RosettaStoneApi, type SampleRecords, type RosettaStoneResponse, type SampleRecord, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BaseApi } from
|
|
2
|
-
const resourceName =
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
const resourceName = "rosetta-stone";
|
|
3
3
|
class RosettaStoneApi extends BaseApi {
|
|
4
4
|
async getLabelsFromSample(sample) {
|
|
5
5
|
return await this.post(`${resourceName}/labels/sample`, sample);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
export { RosettaStoneApi };
|
|
8
|
+
export { RosettaStoneApi, };
|
package/build/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @typedef {'dev' | 'prod' | string} Environment
|
|
5
5
|
*/
|
|
6
|
-
export type Environment =
|
|
6
|
+
export type Environment = "dev" | "prod" | string;
|
|
7
7
|
/**
|
|
8
8
|
* Configuration object for the BaseApi class.
|
|
9
9
|
*
|
|
@@ -29,5 +29,5 @@ export interface MonetaryAmount {
|
|
|
29
29
|
};
|
|
30
30
|
microCentsUsd: number;
|
|
31
31
|
}
|
|
32
|
-
type CurrencyCode =
|
|
32
|
+
type CurrencyCode = "USD";
|
|
33
33
|
export {};
|
package/build/uploads/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { BaseApi } from
|
|
2
|
-
import { type UploadsResponse } from
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
import { type UploadsResponse } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* API class for handling file uploads.
|
|
5
5
|
* @extends BaseApi
|
|
6
6
|
*/
|
|
7
7
|
declare class UploadsApi extends BaseApi {
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
* Retrieves an upload URL for a given upload path.
|
|
10
|
+
*
|
|
11
|
+
* @async
|
|
12
|
+
* @param {string} upload_path - The path of the upload resource.
|
|
13
|
+
* @returns {Promise<UploadsResponse>} - A Promise resolving to the response data.
|
|
14
|
+
*/
|
|
15
15
|
getUploadUrl(uploadPath: string): Promise<UploadsResponse>;
|
|
16
16
|
}
|
|
17
17
|
export { type UploadsResponse, UploadsApi };
|
package/build/uploads/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { BaseApi } from
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
2
|
/**
|
|
3
3
|
* The name of the resource to be used in API requests.
|
|
4
4
|
* @constant
|
|
5
5
|
* @private
|
|
6
6
|
* @type {string}
|
|
7
7
|
*/
|
|
8
|
-
const resourceName =
|
|
8
|
+
const resourceName = "uploads";
|
|
9
9
|
/**
|
|
10
10
|
* API class for handling file uploads.
|
|
11
11
|
* @extends BaseApi
|
|
12
12
|
*/
|
|
13
13
|
class UploadsApi extends BaseApi {
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
* Retrieves an upload URL for a given upload path.
|
|
16
|
+
*
|
|
17
|
+
* @async
|
|
18
|
+
* @param {string} upload_path - The path of the upload resource.
|
|
19
|
+
* @returns {Promise<UploadsResponse>} - A Promise resolving to the response data.
|
|
20
|
+
*/
|
|
21
21
|
async getUploadUrl(uploadPath) {
|
|
22
22
|
return await this.post(`${resourceName}/${uploadPath}`);
|
|
23
23
|
}
|
package/build/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.108",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"@commitlint/config-conventional": "^17.4.2",
|
|
28
28
|
"@types/jest": "^29.5.0",
|
|
29
29
|
"babel-jest": "^29.4.3",
|
|
30
|
+
"eslint-config-prettier": "^9.0.0",
|
|
30
31
|
"eslint-config-standard-with-typescript": "^37.0.0",
|
|
32
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
31
33
|
"husky": "^8.0.0",
|
|
32
34
|
"jest": "^29.4.3",
|
|
33
35
|
"ts-jest": "^29.0.5"
|