@bagelink/sdk 1.8.82 → 1.8.86

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
@@ -927,7 +927,9 @@ function generateStreamEventTypeDefinitions() {
927
927
  function fileTemplate(tsString, typeForImport, baseURL) {
928
928
  const streamTypeDefs = generateStreamEventTypeDefinitions();
929
929
  const hasStreamEndpoints = Object.keys(streamEventTypes).length > 0;
930
- const streamImports = hasStreamEndpoints ? `createSSEStreamPost, createSSEStream, StreamController, type SSEStreamOptions,` : "";
930
+ const hasGetStreams = tsString.includes("createSSEStream(");
931
+ const hasPostStreams = tsString.includes("createSSEStreamPost(");
932
+ const streamImports = hasStreamEndpoints ? `${hasPostStreams ? "createSSEStreamPost, " : ""}${hasGetStreams ? "createSSEStream, " : ""}StreamController, type SSEStreamOptions,` : "";
931
933
  const templateCode = `import ax from 'axios';
932
934
  import type { AxiosResponse } from 'axios';
933
935
  import type { ${typeForImport.join(", ")} } from './types.d';
@@ -989,11 +991,12 @@ type ApiInstance = typeof api & {
989
991
  $lastResponse: Ref<AxiosResponse | null>
990
992
  $axios: typeof axios
991
993
  $ApiResponse: typeof ApiResponse
994
+ $config: Ref<ApiConfig | null>
992
995
  }
993
996
 
994
997
  // Global state
995
- let apiConfig: ApiConfig | null = null
996
998
  let apiInstance: ApiInstance | null = null
999
+ let apiConfig = ref<ApiConfig | null>(null)
997
1000
 
998
1001
  /**
999
1002
  * Create and configure the API instance
@@ -1001,8 +1004,8 @@ let apiInstance: ApiInstance | null = null
1001
1004
  * @returns Configured API instance
1002
1005
  */
1003
1006
  export function createApi(config: ApiConfig = {}): ApiInstance {
1004
- // Store config
1005
- apiConfig = config
1007
+ // Store config for access via useApi().$config
1008
+ apiConfig.value = config
1006
1009
 
1007
1010
  // Configure axios defaults
1008
1011
  if (config.baseURL) {
@@ -1069,7 +1072,8 @@ export function createApi(config: ApiConfig = {}): ApiInstance {
1069
1072
  $raw: api,
1070
1073
  $lastResponse: lastResponse,
1071
1074
  $axios: axios,
1072
- $ApiResponse: ApiResponse
1075
+ $ApiResponse: ApiResponse,
1076
+ $config: apiConfig
1073
1077
  } as ApiInstance
1074
1078
 
1075
1079
  return apiInstance
package/dist/index.mjs CHANGED
@@ -921,7 +921,9 @@ function generateStreamEventTypeDefinitions() {
921
921
  function fileTemplate(tsString, typeForImport, baseURL) {
922
922
  const streamTypeDefs = generateStreamEventTypeDefinitions();
923
923
  const hasStreamEndpoints = Object.keys(streamEventTypes).length > 0;
924
- const streamImports = hasStreamEndpoints ? `createSSEStreamPost, createSSEStream, StreamController, type SSEStreamOptions,` : "";
924
+ const hasGetStreams = tsString.includes("createSSEStream(");
925
+ const hasPostStreams = tsString.includes("createSSEStreamPost(");
926
+ const streamImports = hasStreamEndpoints ? `${hasPostStreams ? "createSSEStreamPost, " : ""}${hasGetStreams ? "createSSEStream, " : ""}StreamController, type SSEStreamOptions,` : "";
925
927
  const templateCode = `import ax from 'axios';
926
928
  import type { AxiosResponse } from 'axios';
927
929
  import type { ${typeForImport.join(", ")} } from './types.d';
@@ -983,11 +985,12 @@ type ApiInstance = typeof api & {
983
985
  $lastResponse: Ref<AxiosResponse | null>
984
986
  $axios: typeof axios
985
987
  $ApiResponse: typeof ApiResponse
988
+ $config: Ref<ApiConfig | null>
986
989
  }
987
990
 
988
991
  // Global state
989
- let apiConfig: ApiConfig | null = null
990
992
  let apiInstance: ApiInstance | null = null
993
+ let apiConfig = ref<ApiConfig | null>(null)
991
994
 
992
995
  /**
993
996
  * Create and configure the API instance
@@ -995,8 +998,8 @@ let apiInstance: ApiInstance | null = null
995
998
  * @returns Configured API instance
996
999
  */
997
1000
  export function createApi(config: ApiConfig = {}): ApiInstance {
998
- // Store config
999
- apiConfig = config
1001
+ // Store config for access via useApi().$config
1002
+ apiConfig.value = config
1000
1003
 
1001
1004
  // Configure axios defaults
1002
1005
  if (config.baseURL) {
@@ -1063,7 +1066,8 @@ export function createApi(config: ApiConfig = {}): ApiInstance {
1063
1066
  $raw: api,
1064
1067
  $lastResponse: lastResponse,
1065
1068
  $axios: axios,
1066
- $ApiResponse: ApiResponse
1069
+ $ApiResponse: ApiResponse,
1070
+ $config: apiConfig
1067
1071
  } as ApiInstance
1068
1072
 
1069
1073
  return apiInstance
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/sdk",
3
3
  "type": "module",
4
- "version": "1.8.82",
4
+ "version": "1.8.86",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -946,8 +946,13 @@ function fileTemplate(
946
946
  const streamTypeDefs = generateStreamEventTypeDefinitions()
947
947
 
948
948
  const hasStreamEndpoints = Object.keys(streamEventTypes).length > 0
949
+
950
+ // Determine which stream functions are actually used
951
+ const hasGetStreams = tsString.includes('createSSEStream(')
952
+ const hasPostStreams = tsString.includes('createSSEStreamPost(')
953
+
949
954
  const streamImports = hasStreamEndpoints
950
- ? `createSSEStreamPost, createSSEStream, StreamController, type SSEStreamOptions,`
955
+ ? `${hasPostStreams ? 'createSSEStreamPost, ' : ''}${hasGetStreams ? 'createSSEStream, ' : ''}StreamController, type SSEStreamOptions,`
951
956
  : ''
952
957
 
953
958
  const templateCode = `import ax from 'axios';
@@ -1011,11 +1016,12 @@ type ApiInstance = typeof api & {
1011
1016
  $lastResponse: Ref<AxiosResponse | null>
1012
1017
  $axios: typeof axios
1013
1018
  $ApiResponse: typeof ApiResponse
1019
+ $config: Ref<ApiConfig | null>
1014
1020
  }
1015
1021
 
1016
1022
  // Global state
1017
- let apiConfig: ApiConfig | null = null
1018
1023
  let apiInstance: ApiInstance | null = null
1024
+ let apiConfig = ref<ApiConfig | null>(null)
1019
1025
 
1020
1026
  /**
1021
1027
  * Create and configure the API instance
@@ -1023,8 +1029,8 @@ let apiInstance: ApiInstance | null = null
1023
1029
  * @returns Configured API instance
1024
1030
  */
1025
1031
  export function createApi(config: ApiConfig = {}): ApiInstance {
1026
- // Store config
1027
- apiConfig = config
1032
+ // Store config for access via useApi().$config
1033
+ apiConfig.value = config
1028
1034
 
1029
1035
  // Configure axios defaults
1030
1036
  if (config.baseURL) {
@@ -1091,7 +1097,8 @@ export function createApi(config: ApiConfig = {}): ApiInstance {
1091
1097
  $raw: api,
1092
1098
  $lastResponse: lastResponse,
1093
1099
  $axios: axios,
1094
- $ApiResponse: ApiResponse
1100
+ $ApiResponse: ApiResponse,
1101
+ $config: apiConfig
1095
1102
  } as ApiInstance
1096
1103
 
1097
1104
  return apiInstance