@narrative.io/data-collaboration-sdk-ts 0.0.86 → 0.0.88

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.
@@ -1,6 +1,6 @@
1
1
  import { type ApiRecords } from '../types';
2
2
  import { BaseApi } from '../base-api';
3
- import { type DataStream } from './types';
3
+ import { type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet } from './types';
4
4
  /**
5
5
  * @module DataStreamsApi
6
6
  * @description This module provides methods for interacting with Data Streams.
@@ -24,4 +24,4 @@ declare class DataStreamsApi extends BaseApi {
24
24
  getDataStreamBySlug(slug: string, companyId: number, authenticated: boolean): Promise<DataStream>;
25
25
  private getBaseUri;
26
26
  }
27
- export { DataStreamsApi, type DataStream };
27
+ export { DataStreamsApi, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type DataStream };
package/build/index.d.ts CHANGED
@@ -17,7 +17,7 @@ import { type Product, ProductsApi } from './products';
17
17
  import { CompanyInfoApi, type CompanyInfo } from './company-info';
18
18
  import { InstallationsApi, type Installation } from './installations';
19
19
  import { NqlApi, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression } from './nql';
20
- import { DataStreamsApi, type DataStream } from './data-streams';
20
+ import { DataStreamsApi, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet } from './data-streams';
21
21
  import { ForecastApi, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState } from './forecast';
22
22
  import { ContractsApi, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView } from './contracts';
23
23
  import { getNqlObject, buildNql } from './nql/NQLParser';
@@ -30,4 +30,4 @@ declare class NarrativeApi extends BaseApi {
30
30
  }
31
31
  interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi {
32
32
  }
33
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type RefAttribute, type SubAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall };
33
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type RefAttribute, type SubAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall };
@@ -818,206 +818,29 @@ declare const isConversationInputMessage: (input: unknown) => input is {
818
818
  id?: string | undefined;
819
819
  };
820
820
  declare const RosettaRequestMessageSchema: z.ZodUnion<[z.ZodObject<{
821
- type: z.ZodLiteral<"addMessage">;
822
- data: z.ZodUnion<[z.ZodObject<{
823
- role: z.ZodEnum<["user"]>;
824
- content: z.ZodString;
825
- name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
826
- timestamp: z.ZodOptional<z.ZodNumber>;
827
- id: z.ZodOptional<z.ZodString>;
821
+ type: z.ZodLiteral<"request">;
822
+ data: z.ZodObject<{
823
+ input: z.ZodString;
824
+ apiKey: z.ZodOptional<z.ZodString>;
828
825
  }, "strip", z.ZodTypeAny, {
829
- role: "user";
830
- content: string;
831
- name?: string | undefined;
832
- timestamp?: number | undefined;
833
- id?: string | undefined;
826
+ input: string;
827
+ apiKey?: string | undefined;
834
828
  }, {
835
- role: "user";
836
- content: string;
837
- name?: string | undefined;
838
- timestamp?: number | undefined;
839
- id?: string | undefined;
840
- }>, z.ZodUnion<[z.ZodObject<{
841
- role: z.ZodEnum<["assistant"]>;
842
- content: z.ZodString;
843
- timestamp: z.ZodOptional<z.ZodNumber>;
844
- id: z.ZodOptional<z.ZodString>;
845
- }, "strict", z.ZodTypeAny, {
846
- role: "assistant";
847
- content: string;
848
- timestamp?: number | undefined;
849
- id?: string | undefined;
850
- }, {
851
- role: "assistant";
852
- content: string;
853
- timestamp?: number | undefined;
854
- id?: string | undefined;
855
- }>, z.ZodObject<{
856
- role: z.ZodEnum<["assistant"]>;
857
- content: z.ZodUnion<[z.ZodNull, z.ZodString]>;
858
- function_call: z.ZodObject<{
859
- name: z.ZodString;
860
- arguments: z.ZodString;
861
- }, "strip", z.ZodTypeAny, {
862
- name: string;
863
- arguments: string;
864
- }, {
865
- name: string;
866
- arguments: string;
867
- }>;
868
- timestamp: z.ZodOptional<z.ZodNumber>;
869
- id: z.ZodOptional<z.ZodString>;
870
- }, "strict", z.ZodTypeAny, {
871
- role: "assistant";
872
- content: string | null;
873
- function_call: {
874
- name: string;
875
- arguments: string;
876
- };
877
- timestamp?: number | undefined;
878
- id?: string | undefined;
879
- }, {
880
- role: "assistant";
881
- content: string | null;
882
- function_call: {
883
- name: string;
884
- arguments: string;
885
- };
886
- timestamp?: number | undefined;
887
- id?: string | undefined;
888
- }>]>, z.ZodObject<{
889
- role: z.ZodEnum<["function"]>;
890
- content: z.ZodString;
891
- name: z.ZodString;
892
- timestamp: z.ZodOptional<z.ZodNumber>;
893
- id: z.ZodOptional<z.ZodString>;
894
- }, "strip", z.ZodTypeAny, {
895
- name: string;
896
- role: "function";
897
- content: string;
898
- timestamp?: number | undefined;
899
- id?: string | undefined;
900
- }, {
901
- name: string;
902
- role: "function";
903
- content: string;
904
- timestamp?: number | undefined;
905
- id?: string | undefined;
906
- }>]>;
829
+ input: string;
830
+ apiKey?: string | undefined;
831
+ }>;
907
832
  }, "strip", z.ZodTypeAny, {
908
- type: "addMessage";
833
+ type: "request";
909
834
  data: {
910
- role: "user";
911
- content: string;
912
- name?: string | undefined;
913
- timestamp?: number | undefined;
914
- id?: string | undefined;
915
- } | {
916
- role: "assistant";
917
- content: string | null;
918
- function_call: {
919
- name: string;
920
- arguments: string;
921
- };
922
- timestamp?: number | undefined;
923
- id?: string | undefined;
924
- } | {
925
- role: "assistant";
926
- content: string;
927
- timestamp?: number | undefined;
928
- id?: string | undefined;
929
- } | {
930
- name: string;
931
- role: "function";
932
- content: string;
933
- timestamp?: number | undefined;
934
- id?: string | undefined;
935
- } | ({
936
- role: "assistant";
937
- content: string | null;
938
- function_call: {
939
- name: string;
940
- arguments: string;
941
- };
942
- timestamp?: number | undefined;
943
- id?: string | undefined;
944
- } & {
945
- role: "assistant";
946
- content: string;
947
- timestamp?: number | undefined;
948
- id?: string | undefined;
949
- }) | ({
950
- role: "assistant";
951
- content: string;
952
- timestamp?: number | undefined;
953
- id?: string | undefined;
954
- } & {
955
- role: "assistant";
956
- content: string | null;
957
- function_call: {
958
- name: string;
959
- arguments: string;
960
- };
961
- timestamp?: number | undefined;
962
- id?: string | undefined;
963
- });
835
+ input: string;
836
+ apiKey?: string | undefined;
837
+ };
964
838
  }, {
965
- type: "addMessage";
839
+ type: "request";
966
840
  data: {
967
- role: "user";
968
- content: string;
969
- name?: string | undefined;
970
- timestamp?: number | undefined;
971
- id?: string | undefined;
972
- } | {
973
- role: "assistant";
974
- content: string | null;
975
- function_call: {
976
- name: string;
977
- arguments: string;
978
- };
979
- timestamp?: number | undefined;
980
- id?: string | undefined;
981
- } | {
982
- role: "assistant";
983
- content: string;
984
- timestamp?: number | undefined;
985
- id?: string | undefined;
986
- } | {
987
- name: string;
988
- role: "function";
989
- content: string;
990
- timestamp?: number | undefined;
991
- id?: string | undefined;
992
- } | ({
993
- role: "assistant";
994
- content: string | null;
995
- function_call: {
996
- name: string;
997
- arguments: string;
998
- };
999
- timestamp?: number | undefined;
1000
- id?: string | undefined;
1001
- } & {
1002
- role: "assistant";
1003
- content: string;
1004
- timestamp?: number | undefined;
1005
- id?: string | undefined;
1006
- }) | ({
1007
- role: "assistant";
1008
- content: string;
1009
- timestamp?: number | undefined;
1010
- id?: string | undefined;
1011
- } & {
1012
- role: "assistant";
1013
- content: string | null;
1014
- function_call: {
1015
- name: string;
1016
- arguments: string;
1017
- };
1018
- timestamp?: number | undefined;
1019
- id?: string | undefined;
1020
- });
841
+ input: string;
842
+ apiKey?: string | undefined;
843
+ };
1021
844
  }>, z.ZodObject<{
1022
845
  type: z.ZodLiteral<"ping">;
1023
846
  }, "strip", z.ZodTypeAny, {
@@ -1039,62 +862,11 @@ declare const RosettaRequestMessageSchema: z.ZodUnion<[z.ZodObject<{
1039
862
  }>]>;
1040
863
  type RosettaRequestMessage = z.infer<typeof RosettaRequestMessageSchema>;
1041
864
  declare const isRosettaRequestMessage: (input: unknown) => input is {
1042
- type: "addMessage";
865
+ type: "request";
1043
866
  data: {
1044
- role: "user";
1045
- content: string;
1046
- name?: string | undefined;
1047
- timestamp?: number | undefined;
1048
- id?: string | undefined;
1049
- } | {
1050
- role: "assistant";
1051
- content: string | null;
1052
- function_call: {
1053
- name: string;
1054
- arguments: string;
1055
- };
1056
- timestamp?: number | undefined;
1057
- id?: string | undefined;
1058
- } | {
1059
- role: "assistant";
1060
- content: string;
1061
- timestamp?: number | undefined;
1062
- id?: string | undefined;
1063
- } | {
1064
- name: string;
1065
- role: "function";
1066
- content: string;
1067
- timestamp?: number | undefined;
1068
- id?: string | undefined;
1069
- } | ({
1070
- role: "assistant";
1071
- content: string | null;
1072
- function_call: {
1073
- name: string;
1074
- arguments: string;
1075
- };
1076
- timestamp?: number | undefined;
1077
- id?: string | undefined;
1078
- } & {
1079
- role: "assistant";
1080
- content: string;
1081
- timestamp?: number | undefined;
1082
- id?: string | undefined;
1083
- }) | ({
1084
- role: "assistant";
1085
- content: string;
1086
- timestamp?: number | undefined;
1087
- id?: string | undefined;
1088
- } & {
1089
- role: "assistant";
1090
- content: string | null;
1091
- function_call: {
1092
- name: string;
1093
- arguments: string;
1094
- };
1095
- timestamp?: number | undefined;
1096
- id?: string | undefined;
1097
- });
867
+ input: string;
868
+ apiKey?: string | undefined;
869
+ };
1098
870
  } | {
1099
871
  type: "ping";
1100
872
  } | {
@@ -1107,13 +879,21 @@ interface InfoMessageData {
1107
879
  message: string;
1108
880
  code?: string;
1109
881
  }
1110
- type ConversationHistoryType = 'conversationHistory';
1111
- type ConversationHistoryData = ConversationIOMessage[];
882
+ interface ConverationHistoryObj {
883
+ type: 'human' | 'ai';
884
+ text: string;
885
+ timestamp: number;
886
+ reference?: string;
887
+ reference_type?: string;
888
+ }
889
+ type ConversationHistoryType = 'history';
890
+ type ConversationHistoryData = ConverationHistoryObj[];
1112
891
  type ConversationUpdatedType = 'conversationUpdated';
1113
892
  type ConversationDeletedType = 'conversationDeleted';
1114
893
  interface ConversationUpdatedData {
1115
894
  change: ConversationDeletedType;
1116
895
  message?: string;
896
+ conversationId: string;
1117
897
  }
1118
898
  interface InfoMessage {
1119
899
  type: InfoMessageType;
@@ -1127,6 +907,17 @@ interface ConversationUpdatedMessage {
1127
907
  type: ConversationUpdatedType;
1128
908
  data: ConversationUpdatedData;
1129
909
  }
910
+ interface ConversationSummary {
911
+ id: string;
912
+ description?: string;
913
+ timestamp?: string;
914
+ }
915
+ type ConversationsType = 'userConversations';
916
+ type ConversationsData = ConversationSummary[];
917
+ interface ConversationListMessage {
918
+ type: ConversationsType;
919
+ data: ConversationsData;
920
+ }
1130
921
  type PongType = 'pong';
1131
922
  interface PongMessage {
1132
923
  type: PongType;
@@ -1140,14 +931,26 @@ interface ErrorMessage {
1140
931
  type: ErrorType;
1141
932
  data: ErrorData;
1142
933
  }
1143
- type ThoughtType = 'thought';
934
+ type ThoughtType = 'thought-start';
1144
935
  interface ThoughtData {
1145
- message: string;
936
+ text: string;
937
+ timestamp?: string;
1146
938
  }
1147
939
  interface ThoughtMessage {
1148
940
  type: ThoughtType;
1149
941
  data: ThoughtData;
1150
942
  }
1151
- type RosettaResponseMessage = InfoMessage | HistoryMessage | ConversationUpdatedMessage | PongMessage | ErrorMessage | ThoughtMessage;
943
+ type ResponseType = 'response';
944
+ interface ReponseData {
945
+ response: string;
946
+ reference_type?: string;
947
+ reference?: string;
948
+ timestamp?: string;
949
+ }
950
+ interface RespomseMessage {
951
+ type: ResponseType;
952
+ data: ReponseData;
953
+ }
954
+ type RosettaResponseMessage = InfoMessage | HistoryMessage | ConversationUpdatedMessage | PongMessage | ErrorMessage | ThoughtMessage | RespomseMessage | ConversationListMessage;
1152
955
  declare function isType<T>(input: unknown, schema: z.ZodType<T>): input is T;
1153
956
  export { type ConversationMessageRole, isConversationMessageRole, type ConversationMessageName, isConversationMessageName, type ConversationUserMessage, isConversationUserMessage, type ConversationAssistantMessage, isConversationAssistantMessage, type ConversationSystemMessage, isConversationSystemMessage, type ConversationFunctionMessage, isConversationFunctionMessage, type ConversationMessage, isConversationMessage, type ConversationIOMessage, isConversationInputMessage, type ConversationMessages, isConversationMessages, isType, type RosettaRequestMessage, isRosettaRequestMessage, type RosettaResponseMessage, type ConversationMessageFunctionCall, isConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithFunctionCall, type ConversationAssistantMessageWithoutFunctionCall, isConversationAssistantMessageWithoutFunctionCall };
@@ -162,9 +162,12 @@ const isConversationInputMessage = (input) => {
162
162
  /// ///////////////////////////
163
163
  // WebSocket Client -> Server
164
164
  /// ///////////////////////////
165
- const AddMessageEventSchema = z.object({
166
- type: z.literal('addMessage'),
167
- data: ChatCompletionRequestInputMessageSchema
165
+ const RequestMessageSchema = z.object({
166
+ type: z.literal('request'),
167
+ data: z.object({
168
+ input: z.string(),
169
+ apiKey: z.string().optional()
170
+ })
168
171
  });
169
172
  const PingEventSchema = z.object({
170
173
  type: z.literal('ping')
@@ -176,7 +179,7 @@ const HistoryEventSchema = z.object({
176
179
  type: z.literal('history')
177
180
  });
178
181
  const RosettaRequestMessageSchema = z.union([
179
- AddMessageEventSchema,
182
+ RequestMessageSchema,
180
183
  PingEventSchema,
181
184
  ClearHistoryEventSchema,
182
185
  HistoryEventSchema
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",