@superatomai/sdk-web 0.0.13 → 0.0.14

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 CHANGED
@@ -704,6 +704,82 @@ zod.z.object({
704
704
  to: MessageParticipantSchema.optional(),
705
705
  payload: BookmarksResponsePayloadSchema
706
706
  });
707
+ var KbNodeDataSchema = zod.z.object({
708
+ id: zod.z.number().optional(),
709
+ title: zod.z.string(),
710
+ content: zod.z.string(),
711
+ category: zod.z.string().nullable().optional(),
712
+ tags: zod.z.array(zod.z.string()).nullable().optional(),
713
+ createdBy: zod.z.number(),
714
+ updatedBy: zod.z.number().optional(),
715
+ createdAt: zod.z.string().optional(),
716
+ updatedAt: zod.z.string().optional()
717
+ });
718
+ var KbNodesQueryFiltersSchema = zod.z.object({
719
+ query: zod.z.string().optional(),
720
+ category: zod.z.string().optional(),
721
+ tags: zod.z.array(zod.z.string()).optional(),
722
+ createdBy: zod.z.number().optional()
723
+ });
724
+ var KbNodesRequestPayloadSchema = zod.z.object({
725
+ operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "search", "getByCategory", "getByUser", "getCategories", "getTags"]),
726
+ data: zod.z.object({
727
+ id: zod.z.number().optional(),
728
+ title: zod.z.string().optional(),
729
+ content: zod.z.string().optional(),
730
+ category: zod.z.string().optional(),
731
+ tags: zod.z.array(zod.z.string()).optional(),
732
+ createdBy: zod.z.number().optional(),
733
+ updatedBy: zod.z.number().optional(),
734
+ userId: zod.z.number().optional(),
735
+ // Query/search operation fields
736
+ query: zod.z.string().optional(),
737
+ filters: KbNodesQueryFiltersSchema.optional(),
738
+ limit: zod.z.number().optional(),
739
+ offset: zod.z.number().optional()
740
+ }).optional()
741
+ });
742
+ var KbNodesRequestMessageSchema = zod.z.object({
743
+ id: zod.z.string(),
744
+ type: zod.z.literal("KB_NODES"),
745
+ from: MessageParticipantSchema,
746
+ to: MessageParticipantSchema.optional(),
747
+ payload: KbNodesRequestPayloadSchema
748
+ });
749
+ var KbNodesResponsePayloadSchema = zod.z.object({
750
+ success: zod.z.boolean(),
751
+ error: zod.z.string().optional(),
752
+ data: zod.z.object({
753
+ // Single node operations
754
+ id: zod.z.number().optional(),
755
+ title: zod.z.string().optional(),
756
+ content: zod.z.string().optional(),
757
+ category: zod.z.string().nullable().optional(),
758
+ tags: zod.z.array(zod.z.string()).nullable().optional(),
759
+ createdBy: zod.z.number().optional(),
760
+ updatedBy: zod.z.number().optional(),
761
+ createdAt: zod.z.string().optional(),
762
+ updatedAt: zod.z.string().optional(),
763
+ message: zod.z.string().optional(),
764
+ // GetOne response
765
+ node: KbNodeDataSchema.optional(),
766
+ // List operations
767
+ nodes: zod.z.array(KbNodeDataSchema).optional(),
768
+ count: zod.z.number().optional(),
769
+ // getByCategory/getByUser
770
+ userId: zod.z.number().optional(),
771
+ // getCategories
772
+ categories: zod.z.array(zod.z.string()).optional()
773
+ // getTags
774
+ }).optional()
775
+ });
776
+ var KbNodesResponseMessageSchema = zod.z.object({
777
+ id: zod.z.string(),
778
+ type: zod.z.literal("KB_NODES_RES"),
779
+ from: MessageParticipantSchema,
780
+ to: MessageParticipantSchema.optional(),
781
+ payload: KbNodesResponsePayloadSchema
782
+ });
707
783
  var ClientConfigSchema = zod.z.object({
708
784
  userId: zod.z.string(),
709
785
  projectId: zod.z.string(),
@@ -728,23 +804,31 @@ __export(services_exports, {
728
804
  UIElementSchema: () => UIElementSchema,
729
805
  createBookmark: () => createBookmark,
730
806
  createDashboard: () => createDashboard,
807
+ createKbNode: () => createKbNode,
731
808
  createReport: () => createReport,
732
809
  createUI: () => createUI,
733
810
  createUser: () => createUser,
734
811
  deleteBookmark: () => deleteBookmark,
735
812
  deleteDashboard: () => deleteDashboard,
813
+ deleteKbNode: () => deleteKbNode,
736
814
  deleteReport: () => deleteReport,
737
815
  deleteUI: () => deleteUI,
738
816
  deleteUser: () => deleteUser,
739
817
  getActions: () => getActions,
740
818
  getAllBookmarks: () => getAllBookmarks,
741
819
  getAllDashboards: () => getAllDashboards,
820
+ getAllKbNodes: () => getAllKbNodes,
742
821
  getAllReports: () => getAllReports,
743
822
  getAllUIs: () => getAllUIs,
744
823
  getAllUsers: () => getAllUsers,
745
824
  getBookmark: () => getBookmark,
746
825
  getComponentSuggestions: () => getComponentSuggestions,
747
826
  getDashboard: () => getDashboard,
827
+ getKbNode: () => getKbNode,
828
+ getKbNodeCategories: () => getKbNodeCategories,
829
+ getKbNodeTags: () => getKbNodeTags,
830
+ getKbNodesByCategory: () => getKbNodesByCategory,
831
+ getKbNodesByUser: () => getKbNodesByUser,
748
832
  getReport: () => getReport,
749
833
  getUI: () => getUI,
750
834
  getUser: () => getUser,
@@ -755,6 +839,7 @@ __export(services_exports, {
755
839
  queryUsers: () => queryUsers,
756
840
  requestBundle: () => requestBundle,
757
841
  requestData: () => requestData,
842
+ searchKbNodes: () => searchKbNodes,
758
843
  sendAuthLoginRequest: () => sendAuthLoginRequest,
759
844
  sendAuthVerifyRequest: () => sendAuthVerifyRequest,
760
845
  sendComponents: () => sendComponents,
@@ -762,6 +847,7 @@ __export(services_exports, {
762
847
  sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
763
848
  updateBookmark: () => updateBookmark,
764
849
  updateDashboard: () => updateDashboard,
850
+ updateKbNode: () => updateKbNode,
765
851
  updateReport: () => updateReport,
766
852
  updateUI: () => updateUI,
767
853
  updateUser: () => updateUser
@@ -1787,6 +1873,277 @@ async function queryUIs(client, options = {}, timeout) {
1787
1873
  };
1788
1874
  }
1789
1875
 
1876
+ // src/services/kb-nodes.ts
1877
+ async function createKbNode(client, title, content, createdBy, category, tags, timeout) {
1878
+ const messageId = `kb_nodes_create_${Date.now()}`;
1879
+ const message = KbNodesRequestMessageSchema.parse({
1880
+ id: messageId,
1881
+ type: "KB_NODES",
1882
+ from: { type: client.type },
1883
+ to: { type: "data-agent" },
1884
+ payload: {
1885
+ operation: "create",
1886
+ data: {
1887
+ title,
1888
+ content,
1889
+ createdBy,
1890
+ category,
1891
+ tags
1892
+ }
1893
+ }
1894
+ });
1895
+ const response = await client.sendWithResponse(message, timeout);
1896
+ const payload = response.payload;
1897
+ return {
1898
+ success: payload.success,
1899
+ error: payload.error,
1900
+ message: payload.data?.message,
1901
+ node: payload.data ? {
1902
+ id: payload.data.id,
1903
+ title: payload.data.title || title,
1904
+ content: payload.data.content || content,
1905
+ category: payload.data.category,
1906
+ tags: payload.data.tags,
1907
+ createdBy: payload.data.createdBy || createdBy,
1908
+ updatedBy: payload.data.updatedBy,
1909
+ createdAt: payload.data.createdAt,
1910
+ updatedAt: payload.data.updatedAt
1911
+ } : void 0
1912
+ };
1913
+ }
1914
+ async function updateKbNode(client, id, updatedBy, updates, timeout) {
1915
+ const messageId = `kb_nodes_update_${Date.now()}`;
1916
+ const message = KbNodesRequestMessageSchema.parse({
1917
+ id: messageId,
1918
+ type: "KB_NODES",
1919
+ from: { type: client.type },
1920
+ to: { type: "data-agent" },
1921
+ payload: {
1922
+ operation: "update",
1923
+ data: {
1924
+ id,
1925
+ updatedBy,
1926
+ ...updates
1927
+ }
1928
+ }
1929
+ });
1930
+ const response = await client.sendWithResponse(message, timeout);
1931
+ const payload = response.payload;
1932
+ return {
1933
+ success: payload.success,
1934
+ error: payload.error,
1935
+ message: payload.data?.message,
1936
+ node: payload.data ? {
1937
+ id: payload.data.id,
1938
+ title: payload.data.title || "",
1939
+ content: payload.data.content || "",
1940
+ category: payload.data.category,
1941
+ tags: payload.data.tags,
1942
+ createdBy: payload.data.createdBy || 0,
1943
+ updatedBy: payload.data.updatedBy,
1944
+ createdAt: payload.data.createdAt,
1945
+ updatedAt: payload.data.updatedAt
1946
+ } : void 0
1947
+ };
1948
+ }
1949
+ async function deleteKbNode(client, id, timeout) {
1950
+ const messageId = `kb_nodes_delete_${Date.now()}`;
1951
+ const message = KbNodesRequestMessageSchema.parse({
1952
+ id: messageId,
1953
+ type: "KB_NODES",
1954
+ from: { type: client.type },
1955
+ to: { type: "data-agent" },
1956
+ payload: {
1957
+ operation: "delete",
1958
+ data: {
1959
+ id
1960
+ }
1961
+ }
1962
+ });
1963
+ const response = await client.sendWithResponse(message, timeout);
1964
+ const payload = response.payload;
1965
+ return {
1966
+ success: payload.success,
1967
+ error: payload.error,
1968
+ message: payload.data?.message
1969
+ };
1970
+ }
1971
+ async function getAllKbNodes(client, limit, offset, timeout) {
1972
+ const messageId = `kb_nodes_getall_${Date.now()}`;
1973
+ const message = KbNodesRequestMessageSchema.parse({
1974
+ id: messageId,
1975
+ type: "KB_NODES",
1976
+ from: { type: client.type },
1977
+ to: { type: "data-agent" },
1978
+ payload: {
1979
+ operation: "getAll",
1980
+ data: {
1981
+ limit,
1982
+ offset
1983
+ }
1984
+ }
1985
+ });
1986
+ const response = await client.sendWithResponse(message, timeout);
1987
+ const payload = response.payload;
1988
+ return {
1989
+ success: payload.success,
1990
+ error: payload.error,
1991
+ nodes: payload.data?.nodes,
1992
+ count: payload.data?.count,
1993
+ message: payload.data?.message
1994
+ };
1995
+ }
1996
+ async function getKbNode(client, id, timeout) {
1997
+ const messageId = `kb_nodes_getone_${Date.now()}`;
1998
+ const message = KbNodesRequestMessageSchema.parse({
1999
+ id: messageId,
2000
+ type: "KB_NODES",
2001
+ from: { type: client.type },
2002
+ to: { type: "data-agent" },
2003
+ payload: {
2004
+ operation: "getOne",
2005
+ data: {
2006
+ id
2007
+ }
2008
+ }
2009
+ });
2010
+ const response = await client.sendWithResponse(message, timeout);
2011
+ const payload = response.payload;
2012
+ return {
2013
+ success: payload.success,
2014
+ error: payload.error,
2015
+ node: payload.data?.node,
2016
+ message: payload.data?.message
2017
+ };
2018
+ }
2019
+ async function searchKbNodes(client, options = {}, timeout) {
2020
+ const { query, category, tags, createdBy, limit, offset } = options;
2021
+ const messageId = `kb_nodes_search_${Date.now()}`;
2022
+ const message = KbNodesRequestMessageSchema.parse({
2023
+ id: messageId,
2024
+ type: "KB_NODES",
2025
+ from: { type: client.type },
2026
+ to: { type: "data-agent" },
2027
+ payload: {
2028
+ operation: "search",
2029
+ data: {
2030
+ query,
2031
+ category,
2032
+ tags,
2033
+ createdBy,
2034
+ limit,
2035
+ offset
2036
+ }
2037
+ }
2038
+ });
2039
+ const response = await client.sendWithResponse(message, timeout);
2040
+ const payload = response.payload;
2041
+ return {
2042
+ success: payload.success,
2043
+ error: payload.error,
2044
+ nodes: payload.data?.nodes,
2045
+ count: payload.data?.count,
2046
+ message: payload.data?.message
2047
+ };
2048
+ }
2049
+ async function getKbNodesByCategory(client, category, limit, offset, timeout) {
2050
+ const messageId = `kb_nodes_getbycategory_${Date.now()}`;
2051
+ const message = KbNodesRequestMessageSchema.parse({
2052
+ id: messageId,
2053
+ type: "KB_NODES",
2054
+ from: { type: client.type },
2055
+ to: { type: "data-agent" },
2056
+ payload: {
2057
+ operation: "getByCategory",
2058
+ data: {
2059
+ category,
2060
+ limit,
2061
+ offset
2062
+ }
2063
+ }
2064
+ });
2065
+ const response = await client.sendWithResponse(message, timeout);
2066
+ const payload = response.payload;
2067
+ return {
2068
+ success: payload.success,
2069
+ error: payload.error,
2070
+ nodes: payload.data?.nodes,
2071
+ count: payload.data?.count,
2072
+ category: payload.data?.category || category,
2073
+ message: payload.data?.message
2074
+ };
2075
+ }
2076
+ async function getKbNodesByUser(client, userId, limit, offset, timeout) {
2077
+ const messageId = `kb_nodes_getbyuser_${Date.now()}`;
2078
+ const message = KbNodesRequestMessageSchema.parse({
2079
+ id: messageId,
2080
+ type: "KB_NODES",
2081
+ from: { type: client.type },
2082
+ to: { type: "data-agent" },
2083
+ payload: {
2084
+ operation: "getByUser",
2085
+ data: {
2086
+ userId,
2087
+ limit,
2088
+ offset
2089
+ }
2090
+ }
2091
+ });
2092
+ const response = await client.sendWithResponse(message, timeout);
2093
+ const payload = response.payload;
2094
+ return {
2095
+ success: payload.success,
2096
+ error: payload.error,
2097
+ nodes: payload.data?.nodes,
2098
+ count: payload.data?.count,
2099
+ userId: payload.data?.userId || userId,
2100
+ message: payload.data?.message
2101
+ };
2102
+ }
2103
+ async function getKbNodeCategories(client, timeout) {
2104
+ const messageId = `kb_nodes_getcategories_${Date.now()}`;
2105
+ const message = KbNodesRequestMessageSchema.parse({
2106
+ id: messageId,
2107
+ type: "KB_NODES",
2108
+ from: { type: client.type },
2109
+ to: { type: "data-agent" },
2110
+ payload: {
2111
+ operation: "getCategories"
2112
+ }
2113
+ });
2114
+ const response = await client.sendWithResponse(message, timeout);
2115
+ const payload = response.payload;
2116
+ return {
2117
+ success: payload.success,
2118
+ error: payload.error,
2119
+ categories: payload.data?.categories,
2120
+ count: payload.data?.count,
2121
+ message: payload.data?.message
2122
+ };
2123
+ }
2124
+ async function getKbNodeTags(client, timeout) {
2125
+ const messageId = `kb_nodes_gettags_${Date.now()}`;
2126
+ const message = KbNodesRequestMessageSchema.parse({
2127
+ id: messageId,
2128
+ type: "KB_NODES",
2129
+ from: { type: client.type },
2130
+ to: { type: "data-agent" },
2131
+ payload: {
2132
+ operation: "getTags"
2133
+ }
2134
+ });
2135
+ const response = await client.sendWithResponse(message, timeout);
2136
+ const payload = response.payload;
2137
+ const responseData = payload.data;
2138
+ return {
2139
+ success: payload.success,
2140
+ error: payload.error,
2141
+ tags: responseData?.tags,
2142
+ count: payload.data?.count,
2143
+ message: payload.data?.message
2144
+ };
2145
+ }
2146
+
1790
2147
  // src/client.ts
1791
2148
  var SuperatomClient = class {
1792
2149
  constructor(config) {
@@ -2372,6 +2729,88 @@ var SuperatomClient = class {
2372
2729
  this.log("info", "Querying UIs with filters:", options?.filters);
2373
2730
  return queryUIs(this, options, timeout);
2374
2731
  }
2732
+ // ==================== KB Nodes (Knowledge Base) Management Methods ====================
2733
+ // These methods delegate to kb-nodes service for knowledge base CRUD operations
2734
+ /**
2735
+ * Create a new knowledge base node
2736
+ * Delegates to kb-nodes service
2737
+ */
2738
+ async createKbNode(title, content, createdBy, category, tags, timeout) {
2739
+ this.log("info", "Creating KB node:", title);
2740
+ return createKbNode(this, title, content, createdBy, category, tags, timeout);
2741
+ }
2742
+ /**
2743
+ * Update an existing knowledge base node
2744
+ * Delegates to kb-nodes service
2745
+ */
2746
+ async updateKbNode(id, updatedBy, updates, timeout) {
2747
+ this.log("info", "Updating KB node:", id);
2748
+ return updateKbNode(this, id, updatedBy, updates, timeout);
2749
+ }
2750
+ /**
2751
+ * Delete a knowledge base node
2752
+ * Delegates to kb-nodes service
2753
+ */
2754
+ async deleteKbNode(id, timeout) {
2755
+ this.log("info", "Deleting KB node:", id);
2756
+ return deleteKbNode(this, id, timeout);
2757
+ }
2758
+ /**
2759
+ * Get all knowledge base nodes
2760
+ * Delegates to kb-nodes service
2761
+ */
2762
+ async getAllKbNodes(limit, offset, timeout) {
2763
+ this.log("info", "Fetching all KB nodes");
2764
+ return getAllKbNodes(this, limit, offset, timeout);
2765
+ }
2766
+ /**
2767
+ * Get a specific knowledge base node by ID
2768
+ * Delegates to kb-nodes service
2769
+ */
2770
+ async getKbNode(id, timeout) {
2771
+ this.log("info", "Fetching KB node:", id);
2772
+ return getKbNode(this, id, timeout);
2773
+ }
2774
+ /**
2775
+ * Search knowledge base nodes with full-text search and filters
2776
+ * Delegates to kb-nodes service
2777
+ */
2778
+ async searchKbNodes(options = {}, timeout) {
2779
+ this.log("info", "Searching KB nodes with query:", options.query);
2780
+ return searchKbNodes(this, options, timeout);
2781
+ }
2782
+ /**
2783
+ * Get knowledge base nodes by category
2784
+ * Delegates to kb-nodes service
2785
+ */
2786
+ async getKbNodesByCategory(category, limit, offset, timeout) {
2787
+ this.log("info", "Fetching KB nodes by category:", category);
2788
+ return getKbNodesByCategory(this, category, limit, offset, timeout);
2789
+ }
2790
+ /**
2791
+ * Get knowledge base nodes by user (creator)
2792
+ * Delegates to kb-nodes service
2793
+ */
2794
+ async getKbNodesByUser(userId, limit, offset, timeout) {
2795
+ this.log("info", "Fetching KB nodes by user:", userId);
2796
+ return getKbNodesByUser(this, userId, limit, offset, timeout);
2797
+ }
2798
+ /**
2799
+ * Get all unique categories from knowledge base nodes
2800
+ * Delegates to kb-nodes service
2801
+ */
2802
+ async getKbNodeCategories(timeout) {
2803
+ this.log("info", "Fetching KB node categories");
2804
+ return getKbNodeCategories(this, timeout);
2805
+ }
2806
+ /**
2807
+ * Get all unique tags from knowledge base nodes
2808
+ * Delegates to kb-nodes service
2809
+ */
2810
+ async getKbNodeTags(timeout) {
2811
+ this.log("info", "Fetching KB node tags");
2812
+ return getKbNodeTags(this, timeout);
2813
+ }
2375
2814
  /**
2376
2815
  * Internal logging
2377
2816
  */
@@ -2443,6 +2882,12 @@ exports.DataRequestMessageSchema = DataRequestMessageSchema;
2443
2882
  exports.DataRequestPayloadSchema = DataRequestPayloadSchema;
2444
2883
  exports.DataResponseMessageSchema = DataResponseMessageSchema;
2445
2884
  exports.DataResponsePayloadSchema = DataResponsePayloadSchema;
2885
+ exports.KbNodeDataSchema = KbNodeDataSchema;
2886
+ exports.KbNodesQueryFiltersSchema = KbNodesQueryFiltersSchema;
2887
+ exports.KbNodesRequestMessageSchema = KbNodesRequestMessageSchema;
2888
+ exports.KbNodesRequestPayloadSchema = KbNodesRequestPayloadSchema;
2889
+ exports.KbNodesResponseMessageSchema = KbNodesResponseMessageSchema;
2890
+ exports.KbNodesResponsePayloadSchema = KbNodesResponsePayloadSchema;
2446
2891
  exports.MessageParticipantSchema = MessageParticipantSchema;
2447
2892
  exports.MessageSchema = MessageSchema;
2448
2893
  exports.SDK_VERSION = SDK_VERSION;