mixpeek 1.3.0

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,123 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+
3
+ /**
4
+ * Mixpeek TypeScript/JavaScript SDK
5
+ *
6
+ * A modern, type-safe client for the Mixpeek multimodal data processing and retrieval platform.
7
+ * This wrapper class provides a developer-friendly interface to the auto-generated API clients.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Mixpeek } from 'mixpeek';
12
+ *
13
+ * const client = new Mixpeek({
14
+ * apiKey: process.env.MIXPEEK_API_KEY,
15
+ * namespace: 'my-namespace'
16
+ * });
17
+ *
18
+ * // Use the client
19
+ * const collections = await client.collections.listCollections();
20
+ * ```
21
+ */
22
+
23
+ interface MixpeekOptions {
24
+ /**
25
+ * Mixpeek API key (required).
26
+ * Can also be set via MIXPEEK_API_KEY environment variable.
27
+ */
28
+ apiKey?: string;
29
+ /**
30
+ * Base URL for the Mixpeek API.
31
+ * @default 'https://api.mixpeek.com'
32
+ */
33
+ baseUrl?: string;
34
+ /**
35
+ * Namespace for multi-tenant isolation.
36
+ * @default 'default'
37
+ */
38
+ namespace?: string;
39
+ /**
40
+ * Request timeout in milliseconds.
41
+ * @default 30000 (30 seconds)
42
+ */
43
+ timeout?: number;
44
+ /**
45
+ * Additional axios configuration options.
46
+ */
47
+ axiosConfig?: AxiosRequestConfig;
48
+ }
49
+ /**
50
+ * Main Mixpeek SDK client.
51
+ *
52
+ * This class provides a developer-friendly interface to all Mixpeek APIs with:
53
+ * - Automatic authentication
54
+ * - Type-safe API calls
55
+ * - Runtime validation (if Zod schemas are available)
56
+ * - Error handling
57
+ * - Request/response interceptors
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const client = new Mixpeek({ apiKey: 'sk_...' });
62
+ *
63
+ * // Access API endpoints
64
+ * const collections = await client.collections.listCollections();
65
+ * const retrievers = await client.retrievers.listRetrievers();
66
+ * ```
67
+ */
68
+ declare class Mixpeek {
69
+ private axiosInstance;
70
+ private apiKey;
71
+ private baseUrl;
72
+ private namespace;
73
+ collections?: any;
74
+ retrievers?: any;
75
+ documents?: any;
76
+ buckets?: any;
77
+ organizations?: any;
78
+ marketplace?: any;
79
+ agents?: any;
80
+ taxonomies?: any;
81
+ /**
82
+ * Create a new Mixpeek client.
83
+ *
84
+ * @param options - Configuration options
85
+ * @throws {Error} If API key is not provided
86
+ */
87
+ constructor(options?: MixpeekOptions);
88
+ /**
89
+ * Initialize all API clients from generated code.
90
+ * This method dynamically imports the generated API classes.
91
+ */
92
+ private initializeApiClients;
93
+ /**
94
+ * Update the API key (useful for re-authentication).
95
+ *
96
+ * @param apiKey - New API key
97
+ */
98
+ setApiKey(apiKey: string): void;
99
+ /**
100
+ * Update the namespace.
101
+ *
102
+ * @param namespace - New namespace
103
+ */
104
+ setNamespace(namespace: string): void;
105
+ /**
106
+ * Get current configuration.
107
+ */
108
+ getConfig(): {
109
+ apiKey: string;
110
+ baseUrl: string;
111
+ namespace: string;
112
+ };
113
+ /**
114
+ * Make a raw HTTP request using the configured axios instance.
115
+ * Useful for calling endpoints not yet covered by the SDK.
116
+ *
117
+ * @param config - Axios request configuration
118
+ * @returns Axios response
119
+ */
120
+ request<T = any>(config: AxiosRequestConfig): Promise<T>;
121
+ }
122
+
123
+ export { Mixpeek, type MixpeekOptions };
@@ -0,0 +1,123 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+
3
+ /**
4
+ * Mixpeek TypeScript/JavaScript SDK
5
+ *
6
+ * A modern, type-safe client for the Mixpeek multimodal data processing and retrieval platform.
7
+ * This wrapper class provides a developer-friendly interface to the auto-generated API clients.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Mixpeek } from 'mixpeek';
12
+ *
13
+ * const client = new Mixpeek({
14
+ * apiKey: process.env.MIXPEEK_API_KEY,
15
+ * namespace: 'my-namespace'
16
+ * });
17
+ *
18
+ * // Use the client
19
+ * const collections = await client.collections.listCollections();
20
+ * ```
21
+ */
22
+
23
+ interface MixpeekOptions {
24
+ /**
25
+ * Mixpeek API key (required).
26
+ * Can also be set via MIXPEEK_API_KEY environment variable.
27
+ */
28
+ apiKey?: string;
29
+ /**
30
+ * Base URL for the Mixpeek API.
31
+ * @default 'https://api.mixpeek.com'
32
+ */
33
+ baseUrl?: string;
34
+ /**
35
+ * Namespace for multi-tenant isolation.
36
+ * @default 'default'
37
+ */
38
+ namespace?: string;
39
+ /**
40
+ * Request timeout in milliseconds.
41
+ * @default 30000 (30 seconds)
42
+ */
43
+ timeout?: number;
44
+ /**
45
+ * Additional axios configuration options.
46
+ */
47
+ axiosConfig?: AxiosRequestConfig;
48
+ }
49
+ /**
50
+ * Main Mixpeek SDK client.
51
+ *
52
+ * This class provides a developer-friendly interface to all Mixpeek APIs with:
53
+ * - Automatic authentication
54
+ * - Type-safe API calls
55
+ * - Runtime validation (if Zod schemas are available)
56
+ * - Error handling
57
+ * - Request/response interceptors
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const client = new Mixpeek({ apiKey: 'sk_...' });
62
+ *
63
+ * // Access API endpoints
64
+ * const collections = await client.collections.listCollections();
65
+ * const retrievers = await client.retrievers.listRetrievers();
66
+ * ```
67
+ */
68
+ declare class Mixpeek {
69
+ private axiosInstance;
70
+ private apiKey;
71
+ private baseUrl;
72
+ private namespace;
73
+ collections?: any;
74
+ retrievers?: any;
75
+ documents?: any;
76
+ buckets?: any;
77
+ organizations?: any;
78
+ marketplace?: any;
79
+ agents?: any;
80
+ taxonomies?: any;
81
+ /**
82
+ * Create a new Mixpeek client.
83
+ *
84
+ * @param options - Configuration options
85
+ * @throws {Error} If API key is not provided
86
+ */
87
+ constructor(options?: MixpeekOptions);
88
+ /**
89
+ * Initialize all API clients from generated code.
90
+ * This method dynamically imports the generated API classes.
91
+ */
92
+ private initializeApiClients;
93
+ /**
94
+ * Update the API key (useful for re-authentication).
95
+ *
96
+ * @param apiKey - New API key
97
+ */
98
+ setApiKey(apiKey: string): void;
99
+ /**
100
+ * Update the namespace.
101
+ *
102
+ * @param namespace - New namespace
103
+ */
104
+ setNamespace(namespace: string): void;
105
+ /**
106
+ * Get current configuration.
107
+ */
108
+ getConfig(): {
109
+ apiKey: string;
110
+ baseUrl: string;
111
+ namespace: string;
112
+ };
113
+ /**
114
+ * Make a raw HTTP request using the configured axios instance.
115
+ * Useful for calling endpoints not yet covered by the SDK.
116
+ *
117
+ * @param config - Axios request configuration
118
+ * @returns Axios response
119
+ */
120
+ request<T = any>(config: AxiosRequestConfig): Promise<T>;
121
+ }
122
+
123
+ export { Mixpeek, type MixpeekOptions };
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
8
+
9
+ // lib/client.ts
10
+ var Mixpeek = class {
11
+ /**
12
+ * Create a new Mixpeek client.
13
+ *
14
+ * @param options - Configuration options
15
+ * @throws {Error} If API key is not provided
16
+ */
17
+ constructor(options = {}) {
18
+ this.apiKey = options.apiKey || process.env.MIXPEEK_API_KEY || "";
19
+ if (!this.apiKey) {
20
+ throw new Error(
21
+ "Mixpeek API key required. Provide via constructor options or MIXPEEK_API_KEY environment variable.\nGet your API key at: https://dash.mixpeek.com"
22
+ );
23
+ }
24
+ this.baseUrl = options.baseUrl || "https://api.mixpeek.com";
25
+ this.namespace = options.namespace || "default";
26
+ this.axiosInstance = axios__default.default.create({
27
+ baseURL: this.baseUrl,
28
+ timeout: options.timeout || 3e4,
29
+ headers: {
30
+ "Authorization": `Bearer ${this.apiKey}`,
31
+ "X-Namespace": this.namespace,
32
+ "Content-Type": "application/json",
33
+ "User-Agent": "mixpeek-js-sdk/1.3.0"
34
+ },
35
+ ...options.axiosConfig
36
+ });
37
+ this.axiosInstance.interceptors.response.use(
38
+ (response) => response,
39
+ (error) => {
40
+ if (error.response) {
41
+ const status = error.response.status;
42
+ const data = error.response.data;
43
+ if (status === 401) {
44
+ throw new Error("Authentication failed. Check your API key.");
45
+ } else if (status === 403) {
46
+ throw new Error("Access forbidden. Check your permissions.");
47
+ } else if (status === 404) {
48
+ throw new Error(data?.error?.message || "Resource not found.");
49
+ } else if (status === 429) {
50
+ throw new Error("Rate limit exceeded. Please retry later.");
51
+ } else if (status >= 500) {
52
+ throw new Error("Mixpeek server error. Please try again later.");
53
+ }
54
+ error.message = data?.error?.message || error.message;
55
+ }
56
+ return Promise.reject(error);
57
+ }
58
+ );
59
+ this.initializeApiClients();
60
+ }
61
+ /**
62
+ * Initialize all API clients from generated code.
63
+ * This method dynamically imports the generated API classes.
64
+ */
65
+ initializeApiClients() {
66
+ try {
67
+ console.log("\u2705 Mixpeek client initialized");
68
+ } catch (error) {
69
+ console.warn(
70
+ "\u26A0\uFE0F Generated API clients not found. Run: npm run generate\nSome API methods may not be available until generation is complete."
71
+ );
72
+ }
73
+ }
74
+ /**
75
+ * Update the API key (useful for re-authentication).
76
+ *
77
+ * @param apiKey - New API key
78
+ */
79
+ setApiKey(apiKey) {
80
+ this.apiKey = apiKey;
81
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${apiKey}`;
82
+ }
83
+ /**
84
+ * Update the namespace.
85
+ *
86
+ * @param namespace - New namespace
87
+ */
88
+ setNamespace(namespace) {
89
+ this.namespace = namespace;
90
+ this.axiosInstance.defaults.headers.common["X-Namespace"] = namespace;
91
+ }
92
+ /**
93
+ * Get current configuration.
94
+ */
95
+ getConfig() {
96
+ return {
97
+ apiKey: this.apiKey.substring(0, 10) + "...",
98
+ // Don't expose full key
99
+ baseUrl: this.baseUrl,
100
+ namespace: this.namespace
101
+ };
102
+ }
103
+ /**
104
+ * Make a raw HTTP request using the configured axios instance.
105
+ * Useful for calling endpoints not yet covered by the SDK.
106
+ *
107
+ * @param config - Axios request configuration
108
+ * @returns Axios response
109
+ */
110
+ async request(config) {
111
+ const response = await this.axiosInstance.request(config);
112
+ return response.data;
113
+ }
114
+ };
115
+
116
+ exports.Mixpeek = Mixpeek;
117
+ //# sourceMappingURL=index.js.map
118
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../lib/client.ts"],"names":["axios"],"mappings":";;;;;;;;;AA4EO,IAAM,UAAN,MAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBnB,WAAA,CAAY,OAAA,GAA0B,EAAC,EAAG;AAExC,IAAA,IAAA,CAAK,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,OAAA,CAAQ,IAAI,eAAA,IAAmB,EAAA;AAE/D,IAAA,IAAI,CAAC,KAAK,MAAA,EAAQ;AAChB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OAEF;AAAA,IACF;AAGA,IAAA,IAAA,CAAK,OAAA,GAAU,QAAQ,OAAA,IAAW,yBAAA;AAClC,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,SAAA,IAAa,SAAA;AAGtC,IAAA,IAAA,CAAK,aAAA,GAAgBA,uBAAM,MAAA,CAAO;AAAA,MAChC,SAAS,IAAA,CAAK,OAAA;AAAA,MACd,OAAA,EAAS,QAAQ,OAAA,IAAW,GAAA;AAAA,MAC5B,OAAA,EAAS;AAAA,QACP,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,QACtC,eAAe,IAAA,CAAK,SAAA;AAAA,QACpB,cAAA,EAAgB,kBAAA;AAAA,QAChB,YAAA,EAAc;AAAA,OAChB;AAAA,MACA,GAAG,OAAA,CAAQ;AAAA,KACZ,CAAA;AAGD,IAAA,IAAA,CAAK,aAAA,CAAc,aAAa,QAAA,CAAS,GAAA;AAAA,MACvC,CAAA,QAAA,KAAY,QAAA;AAAA,MACZ,CAAA,KAAA,KAAS;AAEP,QAAA,IAAI,MAAM,QAAA,EAAU;AAClB,UAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CA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AChF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,aAAa,SAAA,EAAyB;AAC3C,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AACjB,IAAA,IAAA,CAAK,aAAA,CAAc,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,aAAa,CAAA,GAAI,SAAA;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA,EAKO,SAAA,GAAoE;AACzE,IAAA,OAAO;AAAA,MACL,QAAQ,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,CAAA,EAAG,EAAE,CAAA,GAAI,KAAA;AAAA;AAAA,MACvC,SAAS,IAAA,CAAK,OAAA;AAAA,MACd,WAAW,IAAA,CAAK;AAAA,KAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAa,QAAiB,MAAA,EAAwC;AACpE,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,aAAA,CAAc,QAAW,MAAM,CAAA;AAC3D,IAAA,OAAO,QAAA,CAAS,IAAA;AAAA,EAClB;AACF","file":"index.js","sourcesContent":["/**\n * Mixpeek TypeScript/JavaScript SDK\n *\n * A modern, type-safe client for the Mixpeek multimodal data processing and retrieval platform.\n * This wrapper class provides a developer-friendly interface to the auto-generated API clients.\n *\n * @example\n * ```typescript\n * import { Mixpeek } from 'mixpeek';\n *\n * const client = new Mixpeek({\n * apiKey: process.env.MIXPEEK_API_KEY,\n * namespace: 'my-namespace'\n * });\n *\n * // Use the client\n * const collections = await client.collections.listCollections();\n * ```\n */\n\nimport axios, { AxiosInstance, AxiosRequestConfig } from 'axios';\n\n// Import generated API classes\n// Note: These imports will work after OpenAPI generation\n// For now, we'll use dynamic imports and type guards\n\nexport interface MixpeekOptions {\n /**\n * Mixpeek API key (required).\n * Can also be set via MIXPEEK_API_KEY environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Mixpeek API.\n * @default 'https://api.mixpeek.com'\n */\n baseUrl?: string;\n\n /**\n * Namespace for multi-tenant isolation.\n * @default 'default'\n */\n namespace?: string;\n\n /**\n * Request timeout in milliseconds.\n * @default 30000 (30 seconds)\n */\n timeout?: number;\n\n /**\n * Additional axios configuration options.\n */\n axiosConfig?: AxiosRequestConfig;\n}\n\n/**\n * Main Mixpeek SDK client.\n *\n * This class provides a developer-friendly interface to all Mixpeek APIs with:\n * - Automatic authentication\n * - Type-safe API calls\n * - Runtime validation (if Zod schemas are available)\n * - Error handling\n * - Request/response interceptors\n *\n * @example\n * ```typescript\n * const client = new Mixpeek({ apiKey: 'sk_...' });\n *\n * // Access API endpoints\n * const collections = await client.collections.listCollections();\n * const retrievers = await client.retrievers.listRetrievers();\n * ```\n */\nexport class Mixpeek {\n private axiosInstance: AxiosInstance;\n private apiKey: string;\n private baseUrl: string;\n private namespace: string;\n\n // API clients (will be populated after generation)\n public collections?: any;\n public retrievers?: any;\n public documents?: any;\n public buckets?: any;\n public organizations?: any;\n public marketplace?: any;\n public agents?: any;\n public taxonomies?: any;\n\n /**\n * Create a new Mixpeek client.\n *\n * @param options - Configuration options\n * @throws {Error} If API key is not provided\n */\n constructor(options: MixpeekOptions = {}) {\n // Get API key from options or environment\n this.apiKey = options.apiKey || process.env.MIXPEEK_API_KEY || '';\n\n if (!this.apiKey) {\n throw new Error(\n 'Mixpeek API key required. Provide via constructor options or MIXPEEK_API_KEY environment variable.\\n' +\n 'Get your API key at: https://dash.mixpeek.com'\n );\n }\n\n // Set configuration\n this.baseUrl = options.baseUrl || 'https://api.mixpeek.com';\n this.namespace = options.namespace || 'default';\n\n // Create axios instance with default configuration\n this.axiosInstance = axios.create({\n baseURL: this.baseUrl,\n timeout: options.timeout || 30000,\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'X-Namespace': this.namespace,\n 'Content-Type': 'application/json',\n 'User-Agent': 'mixpeek-js-sdk/1.3.0'\n },\n ...options.axiosConfig\n });\n\n // Add response interceptor for error handling\n this.axiosInstance.interceptors.response.use(\n response => response,\n error => {\n // Enhance error messages\n if (error.response) {\n const status = error.response.status;\n const data = error.response.data;\n\n if (status === 401) {\n throw new Error('Authentication failed. Check your API key.');\n } else if (status === 403) {\n throw new Error('Access forbidden. Check your permissions.');\n } else if (status === 404) {\n throw new Error(data?.error?.message || 'Resource not found.');\n } else if (status === 429) {\n throw new Error('Rate limit exceeded. Please retry later.');\n } else if (status >= 500) {\n throw new Error('Mixpeek server error. Please try again later.');\n }\n\n // Pass through other errors with enhanced message\n error.message = data?.error?.message || error.message;\n }\n\n return Promise.reject(error);\n }\n );\n\n // Initialize API clients\n this.initializeApiClients();\n }\n\n /**\n * Initialize all API clients from generated code.\n * This method dynamically imports the generated API classes.\n */\n private initializeApiClients(): void {\n try {\n // Try to import generated API classes\n // These will be available after running npm run generate\n\n // Note: This is a simplified version. After generation, we'll have actual imports like:\n // import { CollectionsApi, RetrieversApi } from '../src/api';\n // this.collections = new CollectionsApi(configuration, undefined, this.axiosInstance);\n\n console.log('✅ Mixpeek client initialized');\n } catch (error) {\n console.warn(\n '⚠️ Generated API clients not found. Run: npm run generate\\n' +\n 'Some API methods may not be available until generation is complete.'\n );\n }\n }\n\n /**\n * Update the API key (useful for re-authentication).\n *\n * @param apiKey - New API key\n */\n public setApiKey(apiKey: string): void {\n this.apiKey = apiKey;\n this.axiosInstance.defaults.headers.common['Authorization'] = `Bearer ${apiKey}`;\n }\n\n /**\n * Update the namespace.\n *\n * @param namespace - New namespace\n */\n public setNamespace(namespace: string): void {\n this.namespace = namespace;\n this.axiosInstance.defaults.headers.common['X-Namespace'] = namespace;\n }\n\n /**\n * Get current configuration.\n */\n public getConfig(): { apiKey: string; baseUrl: string; namespace: string } {\n return {\n apiKey: this.apiKey.substring(0, 10) + '...', // Don't expose full key\n baseUrl: this.baseUrl,\n namespace: this.namespace\n };\n }\n\n /**\n * Make a raw HTTP request using the configured axios instance.\n * Useful for calling endpoints not yet covered by the SDK.\n *\n * @param config - Axios request configuration\n * @returns Axios response\n */\n public async request<T = any>(config: AxiosRequestConfig): Promise<T> {\n const response = await this.axiosInstance.request<T>(config);\n return response.data;\n }\n}\n\n/**\n * Default export for convenience.\n */\nexport default Mixpeek;\n"]}
@@ -0,0 +1,112 @@
1
+ import axios from 'axios';
2
+
3
+ // lib/client.ts
4
+ var Mixpeek = class {
5
+ /**
6
+ * Create a new Mixpeek client.
7
+ *
8
+ * @param options - Configuration options
9
+ * @throws {Error} If API key is not provided
10
+ */
11
+ constructor(options = {}) {
12
+ this.apiKey = options.apiKey || process.env.MIXPEEK_API_KEY || "";
13
+ if (!this.apiKey) {
14
+ throw new Error(
15
+ "Mixpeek API key required. Provide via constructor options or MIXPEEK_API_KEY environment variable.\nGet your API key at: https://dash.mixpeek.com"
16
+ );
17
+ }
18
+ this.baseUrl = options.baseUrl || "https://api.mixpeek.com";
19
+ this.namespace = options.namespace || "default";
20
+ this.axiosInstance = axios.create({
21
+ baseURL: this.baseUrl,
22
+ timeout: options.timeout || 3e4,
23
+ headers: {
24
+ "Authorization": `Bearer ${this.apiKey}`,
25
+ "X-Namespace": this.namespace,
26
+ "Content-Type": "application/json",
27
+ "User-Agent": "mixpeek-js-sdk/1.3.0"
28
+ },
29
+ ...options.axiosConfig
30
+ });
31
+ this.axiosInstance.interceptors.response.use(
32
+ (response) => response,
33
+ (error) => {
34
+ if (error.response) {
35
+ const status = error.response.status;
36
+ const data = error.response.data;
37
+ if (status === 401) {
38
+ throw new Error("Authentication failed. Check your API key.");
39
+ } else if (status === 403) {
40
+ throw new Error("Access forbidden. Check your permissions.");
41
+ } else if (status === 404) {
42
+ throw new Error(data?.error?.message || "Resource not found.");
43
+ } else if (status === 429) {
44
+ throw new Error("Rate limit exceeded. Please retry later.");
45
+ } else if (status >= 500) {
46
+ throw new Error("Mixpeek server error. Please try again later.");
47
+ }
48
+ error.message = data?.error?.message || error.message;
49
+ }
50
+ return Promise.reject(error);
51
+ }
52
+ );
53
+ this.initializeApiClients();
54
+ }
55
+ /**
56
+ * Initialize all API clients from generated code.
57
+ * This method dynamically imports the generated API classes.
58
+ */
59
+ initializeApiClients() {
60
+ try {
61
+ console.log("\u2705 Mixpeek client initialized");
62
+ } catch (error) {
63
+ console.warn(
64
+ "\u26A0\uFE0F Generated API clients not found. Run: npm run generate\nSome API methods may not be available until generation is complete."
65
+ );
66
+ }
67
+ }
68
+ /**
69
+ * Update the API key (useful for re-authentication).
70
+ *
71
+ * @param apiKey - New API key
72
+ */
73
+ setApiKey(apiKey) {
74
+ this.apiKey = apiKey;
75
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${apiKey}`;
76
+ }
77
+ /**
78
+ * Update the namespace.
79
+ *
80
+ * @param namespace - New namespace
81
+ */
82
+ setNamespace(namespace) {
83
+ this.namespace = namespace;
84
+ this.axiosInstance.defaults.headers.common["X-Namespace"] = namespace;
85
+ }
86
+ /**
87
+ * Get current configuration.
88
+ */
89
+ getConfig() {
90
+ return {
91
+ apiKey: this.apiKey.substring(0, 10) + "...",
92
+ // Don't expose full key
93
+ baseUrl: this.baseUrl,
94
+ namespace: this.namespace
95
+ };
96
+ }
97
+ /**
98
+ * Make a raw HTTP request using the configured axios instance.
99
+ * Useful for calling endpoints not yet covered by the SDK.
100
+ *
101
+ * @param config - Axios request configuration
102
+ * @returns Axios response
103
+ */
104
+ async request(config) {
105
+ const response = await this.axiosInstance.request(config);
106
+ return response.data;
107
+ }
108
+ };
109
+
110
+ export { Mixpeek };
111
+ //# sourceMappingURL=index.mjs.map
112
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../lib/client.ts"],"names":[],"mappings":";;;AA4EO,IAAM,UAAN,MAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBnB,WAAA,CAAY,OAAA,GAA0B,EAAC,EAAG;AAExC,IAAA,IAAA,CAAK,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,OAAA,CAAQ,IAAI,eAAA,IAAmB,EAAA;AAE/D,IAAA,I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AA,MACd,WAAW,IAAA,CAAK;AAAA,KAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAa,QAAiB,MAAA,EAAwC;AACpE,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,aAAA,CAAc,QAAW,MAAM,CAAA;AAC3D,IAAA,OAAO,QAAA,CAAS,IAAA;AAAA,EAClB;AACF","file":"index.mjs","sourcesContent":["/**\n * Mixpeek TypeScript/JavaScript SDK\n *\n * A modern, type-safe client for the Mixpeek multimodal data processing and retrieval platform.\n * This wrapper class provides a developer-friendly interface to the auto-generated API clients.\n *\n * @example\n * ```typescript\n * import { Mixpeek } from 'mixpeek';\n *\n * const client = new Mixpeek({\n * apiKey: process.env.MIXPEEK_API_KEY,\n * namespace: 'my-namespace'\n * });\n *\n * // Use the client\n * const collections = await client.collections.listCollections();\n * ```\n */\n\nimport axios, { AxiosInstance, AxiosRequestConfig } from 'axios';\n\n// Import generated API classes\n// Note: These imports will work after OpenAPI generation\n// For now, we'll use dynamic imports and type guards\n\nexport interface MixpeekOptions {\n /**\n * Mixpeek API key (required).\n * Can also be set via MIXPEEK_API_KEY environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Mixpeek API.\n * @default 'https://api.mixpeek.com'\n */\n baseUrl?: string;\n\n /**\n * Namespace for multi-tenant isolation.\n * @default 'default'\n */\n namespace?: string;\n\n /**\n * Request timeout in milliseconds.\n * @default 30000 (30 seconds)\n */\n timeout?: number;\n\n /**\n * Additional axios configuration options.\n */\n axiosConfig?: AxiosRequestConfig;\n}\n\n/**\n * Main Mixpeek SDK client.\n *\n * This class provides a developer-friendly interface to all Mixpeek APIs with:\n * - Automatic authentication\n * - Type-safe API calls\n * - Runtime validation (if Zod schemas are available)\n * - Error handling\n * - Request/response interceptors\n *\n * @example\n * ```typescript\n * const client = new Mixpeek({ apiKey: 'sk_...' });\n *\n * // Access API endpoints\n * const collections = await client.collections.listCollections();\n * const retrievers = await client.retrievers.listRetrievers();\n * ```\n */\nexport class Mixpeek {\n private axiosInstance: AxiosInstance;\n private apiKey: string;\n private baseUrl: string;\n private namespace: string;\n\n // API clients (will be populated after generation)\n public collections?: any;\n public retrievers?: any;\n public documents?: any;\n public buckets?: any;\n public organizations?: any;\n public marketplace?: any;\n public agents?: any;\n public taxonomies?: any;\n\n /**\n * Create a new Mixpeek client.\n *\n * @param options - Configuration options\n * @throws {Error} If API key is not provided\n */\n constructor(options: MixpeekOptions = {}) {\n // Get API key from options or environment\n this.apiKey = options.apiKey || process.env.MIXPEEK_API_KEY || '';\n\n if (!this.apiKey) {\n throw new Error(\n 'Mixpeek API key required. Provide via constructor options or MIXPEEK_API_KEY environment variable.\\n' +\n 'Get your API key at: https://dash.mixpeek.com'\n );\n }\n\n // Set configuration\n this.baseUrl = options.baseUrl || 'https://api.mixpeek.com';\n this.namespace = options.namespace || 'default';\n\n // Create axios instance with default configuration\n this.axiosInstance = axios.create({\n baseURL: this.baseUrl,\n timeout: options.timeout || 30000,\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'X-Namespace': this.namespace,\n 'Content-Type': 'application/json',\n 'User-Agent': 'mixpeek-js-sdk/1.3.0'\n },\n ...options.axiosConfig\n });\n\n // Add response interceptor for error handling\n this.axiosInstance.interceptors.response.use(\n response => response,\n error => {\n // Enhance error messages\n if (error.response) {\n const status = error.response.status;\n const data = error.response.data;\n\n if (status === 401) {\n throw new Error('Authentication failed. Check your API key.');\n } else if (status === 403) {\n throw new Error('Access forbidden. Check your permissions.');\n } else if (status === 404) {\n throw new Error(data?.error?.message || 'Resource not found.');\n } else if (status === 429) {\n throw new Error('Rate limit exceeded. Please retry later.');\n } else if (status >= 500) {\n throw new Error('Mixpeek server error. Please try again later.');\n }\n\n // Pass through other errors with enhanced message\n error.message = data?.error?.message || error.message;\n }\n\n return Promise.reject(error);\n }\n );\n\n // Initialize API clients\n this.initializeApiClients();\n }\n\n /**\n * Initialize all API clients from generated code.\n * This method dynamically imports the generated API classes.\n */\n private initializeApiClients(): void {\n try {\n // Try to import generated API classes\n // These will be available after running npm run generate\n\n // Note: This is a simplified version. After generation, we'll have actual imports like:\n // import { CollectionsApi, RetrieversApi } from '../src/api';\n // this.collections = new CollectionsApi(configuration, undefined, this.axiosInstance);\n\n console.log('✅ Mixpeek client initialized');\n } catch (error) {\n console.warn(\n '⚠️ Generated API clients not found. Run: npm run generate\\n' +\n 'Some API methods may not be available until generation is complete.'\n );\n }\n }\n\n /**\n * Update the API key (useful for re-authentication).\n *\n * @param apiKey - New API key\n */\n public setApiKey(apiKey: string): void {\n this.apiKey = apiKey;\n this.axiosInstance.defaults.headers.common['Authorization'] = `Bearer ${apiKey}`;\n }\n\n /**\n * Update the namespace.\n *\n * @param namespace - New namespace\n */\n public setNamespace(namespace: string): void {\n this.namespace = namespace;\n this.axiosInstance.defaults.headers.common['X-Namespace'] = namespace;\n }\n\n /**\n * Get current configuration.\n */\n public getConfig(): { apiKey: string; baseUrl: string; namespace: string } {\n return {\n apiKey: this.apiKey.substring(0, 10) + '...', // Don't expose full key\n baseUrl: this.baseUrl,\n namespace: this.namespace\n };\n }\n\n /**\n * Make a raw HTTP request using the configured axios instance.\n * Useful for calling endpoints not yet covered by the SDK.\n *\n * @param config - Axios request configuration\n * @returns Axios response\n */\n public async request<T = any>(config: AxiosRequestConfig): Promise<T> {\n const response = await this.axiosInstance.request<T>(config);\n return response.data;\n }\n}\n\n/**\n * Default export for convenience.\n */\nexport default Mixpeek;\n"]}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "mixpeek",
3
+ "version": "1.3.0",
4
+ "description": "Official Mixpeek TypeScript/JavaScript SDK for multimodal data processing and retrieval",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "generate": "bash scripts/generate.sh",
22
+ "generate:zod": "ts-node scripts/generate_zod.ts",
23
+ "inject:wrapper": "ts-node scripts/inject_wrapper.ts",
24
+ "build": "tsup index.ts lib/index.ts --format cjs,esm --dts --sourcemap --clean",
25
+ "prepublishOnly": "npm run build",
26
+ "test": "jest",
27
+ "test:unit": "jest --testPathPattern=test/unit",
28
+ "test:integration": "jest --testPathPattern=test/integration",
29
+ "lint": "eslint src/ lib/",
30
+ "typecheck": "tsc --noEmit"
31
+ },
32
+ "keywords": [
33
+ "mixpeek",
34
+ "multimodal",
35
+ "search",
36
+ "retrieval",
37
+ "vector",
38
+ "ai",
39
+ "sdk",
40
+ "api-client",
41
+ "typescript"
42
+ ],
43
+ "author": {
44
+ "name": "Mixpeek Support",
45
+ "email": "info@mixpeek.com",
46
+ "url": "https://mixpeek.com"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/mixpeek/server.git",
52
+ "directory": "sdk/javascript-client"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/mixpeek/server/issues"
56
+ },
57
+ "homepage": "https://docs.mixpeek.com",
58
+ "engines": {
59
+ "node": ">=16.0.0"
60
+ },
61
+ "dependencies": {
62
+ "axios": "^1.6.0",
63
+ "zod": "^3.22.0"
64
+ },
65
+ "devDependencies": {
66
+ "@openapitools/openapi-generator-cli": "^2.13.0",
67
+ "@types/jest": "^29.5.0",
68
+ "@types/node": "^20.0.0",
69
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
70
+ "@typescript-eslint/parser": "^6.0.0",
71
+ "eslint": "^8.0.0",
72
+ "jest": "^29.0.0",
73
+ "openapi-zod-client": "^1.18.0",
74
+ "ts-jest": "^29.0.0",
75
+ "ts-node": "^10.0.0",
76
+ "tsup": "^8.0.0",
77
+ "typescript": "^5.3.0"
78
+ }
79
+ }