cilantro-sdk 0.0.39 → 0.0.40
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/address-book.cjs +184 -0
- package/dist/address-book.cjs.map +7 -0
- package/dist/address-book.mjs +142 -0
- package/dist/address-book.mjs.map +7 -0
- package/dist/analytics.cjs +115 -0
- package/dist/analytics.cjs.map +7 -0
- package/dist/analytics.mjs +78 -0
- package/dist/analytics.mjs.map +7 -0
- package/dist/app.cjs +118 -0
- package/dist/app.cjs.map +7 -0
- package/dist/app.mjs +81 -0
- package/dist/app.mjs.map +7 -0
- package/dist/health.cjs +141 -0
- package/dist/health.cjs.map +7 -0
- package/dist/health.mjs +102 -0
- package/dist/health.mjs.map +7 -0
- package/dist/public.cjs +127 -0
- package/dist/public.cjs.map +7 -0
- package/dist/public.mjs +89 -0
- package/dist/public.mjs.map +7 -0
- package/dist/scheduled-transactions.cjs +177 -0
- package/dist/scheduled-transactions.cjs.map +7 -0
- package/dist/scheduled-transactions.mjs +136 -0
- package/dist/scheduled-transactions.mjs.map +7 -0
- package/dist/spending-limits.cjs +173 -0
- package/dist/spending-limits.cjs.map +7 -0
- package/dist/spending-limits.mjs +132 -0
- package/dist/spending-limits.mjs.map +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/address-book.ts
|
|
31
|
+
var address_book_exports = {};
|
|
32
|
+
__export(address_book_exports, {
|
|
33
|
+
create: () => create,
|
|
34
|
+
findAll: () => findAll,
|
|
35
|
+
findOne: () => findOne,
|
|
36
|
+
remove: () => remove,
|
|
37
|
+
update: () => update,
|
|
38
|
+
verifyAddress: () => verifyAddress
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(address_book_exports);
|
|
41
|
+
|
|
42
|
+
// src/api-client.ts
|
|
43
|
+
var import_axios = __toESM(require("axios"));
|
|
44
|
+
|
|
45
|
+
// src/config.ts
|
|
46
|
+
var GLOBAL_CONFIG_KEY = "__CILANTRO_SDK_CONFIG__";
|
|
47
|
+
function getGlobalConfig() {
|
|
48
|
+
const defaultConfig = {
|
|
49
|
+
baseURL: process.env.CILANTRO_API_URL || "https://api.cilantro.gg"
|
|
50
|
+
};
|
|
51
|
+
if (typeof globalThis !== "undefined") {
|
|
52
|
+
if (!globalThis.__CILANTRO_SDK_CONFIG__) {
|
|
53
|
+
globalThis.__CILANTRO_SDK_CONFIG__ = defaultConfig;
|
|
54
|
+
}
|
|
55
|
+
return globalThis.__CILANTRO_SDK_CONFIG__;
|
|
56
|
+
} else if (typeof globalThis.window !== "undefined") {
|
|
57
|
+
const win = globalThis.window;
|
|
58
|
+
if (!win[GLOBAL_CONFIG_KEY]) {
|
|
59
|
+
win[GLOBAL_CONFIG_KEY] = defaultConfig;
|
|
60
|
+
}
|
|
61
|
+
return win[GLOBAL_CONFIG_KEY];
|
|
62
|
+
}
|
|
63
|
+
return defaultConfig;
|
|
64
|
+
}
|
|
65
|
+
var currentConfig = getGlobalConfig();
|
|
66
|
+
function getConfig() {
|
|
67
|
+
currentConfig = getGlobalConfig();
|
|
68
|
+
return currentConfig;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/api-client.ts
|
|
72
|
+
var axiosInstance = import_axios.default.create();
|
|
73
|
+
axiosInstance.interceptors.request.use(
|
|
74
|
+
(config) => {
|
|
75
|
+
const sdkConfig = getConfig();
|
|
76
|
+
config.baseURL = sdkConfig.baseURL || "https://api.cilantro.gg";
|
|
77
|
+
if (sdkConfig.jwt) {
|
|
78
|
+
config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;
|
|
79
|
+
}
|
|
80
|
+
if (sdkConfig.apiKey) {
|
|
81
|
+
config.headers["X-API-Key"] = sdkConfig.apiKey;
|
|
82
|
+
}
|
|
83
|
+
return config;
|
|
84
|
+
},
|
|
85
|
+
(error) => {
|
|
86
|
+
return Promise.reject(error);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
var customInstance = (config, options) => {
|
|
90
|
+
const source = import_axios.default.CancelToken.source();
|
|
91
|
+
const promise = axiosInstance({
|
|
92
|
+
...config,
|
|
93
|
+
...options,
|
|
94
|
+
cancelToken: source.token
|
|
95
|
+
}).then(({ data }) => data);
|
|
96
|
+
promise.cancel = () => {
|
|
97
|
+
source.cancel("Query was cancelled");
|
|
98
|
+
};
|
|
99
|
+
return promise;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/api/address-book/address-book.ts
|
|
103
|
+
var getAddressBook = () => {
|
|
104
|
+
const addressBookControllerCreate2 = (createAddressBookDto, options) => {
|
|
105
|
+
return customInstance(
|
|
106
|
+
{
|
|
107
|
+
url: `/address-book`,
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers: { "Content-Type": "application/json" },
|
|
110
|
+
data: createAddressBookDto
|
|
111
|
+
},
|
|
112
|
+
options
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
const addressBookControllerFindAll2 = (params, options) => {
|
|
116
|
+
return customInstance(
|
|
117
|
+
{ url: `/address-book`, method: "GET", params },
|
|
118
|
+
options
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
const addressBookControllerFindOne2 = (id, options) => {
|
|
122
|
+
return customInstance(
|
|
123
|
+
{ url: `/address-book/${id}`, method: "GET" },
|
|
124
|
+
options
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
const addressBookControllerUpdate2 = (id, updateAddressBookDto, options) => {
|
|
128
|
+
return customInstance(
|
|
129
|
+
{
|
|
130
|
+
url: `/address-book/${id}`,
|
|
131
|
+
method: "PATCH",
|
|
132
|
+
headers: { "Content-Type": "application/json" },
|
|
133
|
+
data: updateAddressBookDto
|
|
134
|
+
},
|
|
135
|
+
options
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
const addressBookControllerRemove2 = (id, options) => {
|
|
139
|
+
return customInstance(
|
|
140
|
+
{ url: `/address-book/${id}`, method: "DELETE" },
|
|
141
|
+
options
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
const addressBookControllerVerifyAddress2 = (id, options) => {
|
|
145
|
+
return customInstance(
|
|
146
|
+
{ url: `/address-book/${id}/verify`, method: "POST" },
|
|
147
|
+
options
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
addressBookControllerCreate: addressBookControllerCreate2,
|
|
152
|
+
addressBookControllerFindAll: addressBookControllerFindAll2,
|
|
153
|
+
addressBookControllerFindOne: addressBookControllerFindOne2,
|
|
154
|
+
addressBookControllerUpdate: addressBookControllerUpdate2,
|
|
155
|
+
addressBookControllerRemove: addressBookControllerRemove2,
|
|
156
|
+
addressBookControllerVerifyAddress: addressBookControllerVerifyAddress2
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// src/address-book.ts
|
|
161
|
+
var {
|
|
162
|
+
addressBookControllerCreate,
|
|
163
|
+
addressBookControllerFindAll,
|
|
164
|
+
addressBookControllerFindOne,
|
|
165
|
+
addressBookControllerUpdate,
|
|
166
|
+
addressBookControllerRemove,
|
|
167
|
+
addressBookControllerVerifyAddress
|
|
168
|
+
} = getAddressBook();
|
|
169
|
+
var create = addressBookControllerCreate;
|
|
170
|
+
var findAll = addressBookControllerFindAll;
|
|
171
|
+
var findOne = addressBookControllerFindOne;
|
|
172
|
+
var update = addressBookControllerUpdate;
|
|
173
|
+
var remove = addressBookControllerRemove;
|
|
174
|
+
var verifyAddress = addressBookControllerVerifyAddress;
|
|
175
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
176
|
+
0 && (module.exports = {
|
|
177
|
+
create,
|
|
178
|
+
findAll,
|
|
179
|
+
findOne,
|
|
180
|
+
remove,
|
|
181
|
+
update,
|
|
182
|
+
verifyAddress
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=address-book.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/address-book.ts", "../src/api-client.ts", "../src/config.ts", "../src/api/address-book/address-book.ts"],
|
|
4
|
+
"sourcesContent": ["/**\r\n * Address Book module - Simplified exports for address book API functions\r\n */\r\n\r\nimport { getAddressBook } from './api/address-book/address-book';\r\n\r\nconst {\r\n addressBookControllerCreate,\r\n addressBookControllerFindAll,\r\n addressBookControllerFindOne,\r\n addressBookControllerUpdate,\r\n addressBookControllerRemove,\r\n addressBookControllerVerifyAddress,\r\n} = getAddressBook();\r\n\r\n// Export address book functions with simplified names\r\nexport const create = addressBookControllerCreate;\r\nexport const findAll = addressBookControllerFindAll;\r\nexport const findOne = addressBookControllerFindOne;\r\nexport const update = addressBookControllerUpdate;\r\nexport const remove = addressBookControllerRemove;\r\nexport const verifyAddress = addressBookControllerVerifyAddress;\r\n\r\n// Export types\r\nexport type {\r\n AddressBookControllerCreateResult,\r\n AddressBookControllerFindAllResult,\r\n AddressBookControllerFindOneResult,\r\n AddressBookControllerUpdateResult,\r\n AddressBookControllerRemoveResult,\r\n AddressBookControllerVerifyAddressResult,\r\n} from './api/address-book/address-book';\r\n\r\nexport type {\r\n CreateAddressBookDto,\r\n UpdateAddressBookDto,\r\n AddressBookControllerFindAllParams,\r\n} from './models';\r\n\r\n", "/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n AddressBookControllerFindAllParams,\n AddressBookListResponseDto,\n AddressBookResponseDto,\n CreateAddressBookDto,\n UpdateAddressBookDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAddressBook = () => {\n /**\n * Save a Solana address with a label and optional description/tags for quick access.\n * @summary Add a new address to address book\n */\n const addressBookControllerCreate = (\n createAddressBookDto: CreateAddressBookDto,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n {\n url: `/address-book`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: createAddressBookDto,\n },\n options,\n );\n };\n /**\n * Retrieve paginated list of saved addresses with optional search and tag filtering.\n * @summary Get all addresses in address book\n */\n const addressBookControllerFindAll = (\n params?: AddressBookControllerFindAllParams,\n options?: SecondParameter<\n typeof customInstance<AddressBookListResponseDto>\n >,\n ) => {\n return customInstance<AddressBookListResponseDto>(\n { url: `/address-book`, method: \"GET\", params },\n options,\n );\n };\n /**\n * Retrieve details of a specific address book entry.\n * @summary Get address book entry by ID\n */\n const addressBookControllerFindOne = (\n id: string,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n { url: `/address-book/${id}`, method: \"GET\" },\n options,\n );\n };\n /**\n * Update label, description, tags, or other metadata of an address book entry.\n * @summary Update address book entry\n */\n const addressBookControllerUpdate = (\n id: string,\n updateAddressBookDto: UpdateAddressBookDto,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n {\n url: `/address-book/${id}`,\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n data: updateAddressBookDto,\n },\n options,\n );\n };\n /**\n * Remove an address from the address book.\n * @summary Delete address book entry\n */\n const addressBookControllerRemove = (\n id: string,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n { url: `/address-book/${id}`, method: \"DELETE\" },\n options,\n );\n };\n /**\n * Verify that the saved address is a valid Solana address by checking on-chain.\n * @summary Verify address on-chain\n */\n const addressBookControllerVerifyAddress = (\n id: string,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n { url: `/address-book/${id}/verify`, method: \"POST\" },\n options,\n );\n };\n return {\n addressBookControllerCreate,\n addressBookControllerFindAll,\n addressBookControllerFindOne,\n addressBookControllerUpdate,\n addressBookControllerRemove,\n addressBookControllerVerifyAddress,\n };\n};\nexport type AddressBookControllerCreateResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAddressBook>[\"addressBookControllerCreate\"]>\n >\n>;\nexport type AddressBookControllerFindAllResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAddressBook>[\"addressBookControllerFindAll\"]\n >\n >\n>;\nexport type AddressBookControllerFindOneResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAddressBook>[\"addressBookControllerFindOne\"]\n >\n >\n>;\nexport type AddressBookControllerUpdateResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAddressBook>[\"addressBookControllerUpdate\"]>\n >\n>;\nexport type AddressBookControllerRemoveResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAddressBook>[\"addressBookControllerRemove\"]>\n >\n>;\nexport type AddressBookControllerVerifyAddressResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAddressBook>[\"addressBookControllerVerifyAddress\"]\n >\n >\n>;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["axios", "addressBookControllerCreate", "addressBookControllerFindAll", "addressBookControllerFindOne", "addressBookControllerUpdate", "addressBookControllerRemove", "addressBookControllerVerifyAddress"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// src/api-client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
// src/config.ts
|
|
5
|
+
var GLOBAL_CONFIG_KEY = "__CILANTRO_SDK_CONFIG__";
|
|
6
|
+
function getGlobalConfig() {
|
|
7
|
+
const defaultConfig = {
|
|
8
|
+
baseURL: process.env.CILANTRO_API_URL || "https://api.cilantro.gg"
|
|
9
|
+
};
|
|
10
|
+
if (typeof globalThis !== "undefined") {
|
|
11
|
+
if (!globalThis.__CILANTRO_SDK_CONFIG__) {
|
|
12
|
+
globalThis.__CILANTRO_SDK_CONFIG__ = defaultConfig;
|
|
13
|
+
}
|
|
14
|
+
return globalThis.__CILANTRO_SDK_CONFIG__;
|
|
15
|
+
} else if (typeof globalThis.window !== "undefined") {
|
|
16
|
+
const win = globalThis.window;
|
|
17
|
+
if (!win[GLOBAL_CONFIG_KEY]) {
|
|
18
|
+
win[GLOBAL_CONFIG_KEY] = defaultConfig;
|
|
19
|
+
}
|
|
20
|
+
return win[GLOBAL_CONFIG_KEY];
|
|
21
|
+
}
|
|
22
|
+
return defaultConfig;
|
|
23
|
+
}
|
|
24
|
+
var currentConfig = getGlobalConfig();
|
|
25
|
+
function getConfig() {
|
|
26
|
+
currentConfig = getGlobalConfig();
|
|
27
|
+
return currentConfig;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/api-client.ts
|
|
31
|
+
var axiosInstance = axios.create();
|
|
32
|
+
axiosInstance.interceptors.request.use(
|
|
33
|
+
(config) => {
|
|
34
|
+
const sdkConfig = getConfig();
|
|
35
|
+
config.baseURL = sdkConfig.baseURL || "https://api.cilantro.gg";
|
|
36
|
+
if (sdkConfig.jwt) {
|
|
37
|
+
config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;
|
|
38
|
+
}
|
|
39
|
+
if (sdkConfig.apiKey) {
|
|
40
|
+
config.headers["X-API-Key"] = sdkConfig.apiKey;
|
|
41
|
+
}
|
|
42
|
+
return config;
|
|
43
|
+
},
|
|
44
|
+
(error) => {
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
var customInstance = (config, options) => {
|
|
49
|
+
const source = axios.CancelToken.source();
|
|
50
|
+
const promise = axiosInstance({
|
|
51
|
+
...config,
|
|
52
|
+
...options,
|
|
53
|
+
cancelToken: source.token
|
|
54
|
+
}).then(({ data }) => data);
|
|
55
|
+
promise.cancel = () => {
|
|
56
|
+
source.cancel("Query was cancelled");
|
|
57
|
+
};
|
|
58
|
+
return promise;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/api/address-book/address-book.ts
|
|
62
|
+
var getAddressBook = () => {
|
|
63
|
+
const addressBookControllerCreate2 = (createAddressBookDto, options) => {
|
|
64
|
+
return customInstance(
|
|
65
|
+
{
|
|
66
|
+
url: `/address-book`,
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers: { "Content-Type": "application/json" },
|
|
69
|
+
data: createAddressBookDto
|
|
70
|
+
},
|
|
71
|
+
options
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
const addressBookControllerFindAll2 = (params, options) => {
|
|
75
|
+
return customInstance(
|
|
76
|
+
{ url: `/address-book`, method: "GET", params },
|
|
77
|
+
options
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
const addressBookControllerFindOne2 = (id, options) => {
|
|
81
|
+
return customInstance(
|
|
82
|
+
{ url: `/address-book/${id}`, method: "GET" },
|
|
83
|
+
options
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
const addressBookControllerUpdate2 = (id, updateAddressBookDto, options) => {
|
|
87
|
+
return customInstance(
|
|
88
|
+
{
|
|
89
|
+
url: `/address-book/${id}`,
|
|
90
|
+
method: "PATCH",
|
|
91
|
+
headers: { "Content-Type": "application/json" },
|
|
92
|
+
data: updateAddressBookDto
|
|
93
|
+
},
|
|
94
|
+
options
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
const addressBookControllerRemove2 = (id, options) => {
|
|
98
|
+
return customInstance(
|
|
99
|
+
{ url: `/address-book/${id}`, method: "DELETE" },
|
|
100
|
+
options
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
const addressBookControllerVerifyAddress2 = (id, options) => {
|
|
104
|
+
return customInstance(
|
|
105
|
+
{ url: `/address-book/${id}/verify`, method: "POST" },
|
|
106
|
+
options
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
addressBookControllerCreate: addressBookControllerCreate2,
|
|
111
|
+
addressBookControllerFindAll: addressBookControllerFindAll2,
|
|
112
|
+
addressBookControllerFindOne: addressBookControllerFindOne2,
|
|
113
|
+
addressBookControllerUpdate: addressBookControllerUpdate2,
|
|
114
|
+
addressBookControllerRemove: addressBookControllerRemove2,
|
|
115
|
+
addressBookControllerVerifyAddress: addressBookControllerVerifyAddress2
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/address-book.ts
|
|
120
|
+
var {
|
|
121
|
+
addressBookControllerCreate,
|
|
122
|
+
addressBookControllerFindAll,
|
|
123
|
+
addressBookControllerFindOne,
|
|
124
|
+
addressBookControllerUpdate,
|
|
125
|
+
addressBookControllerRemove,
|
|
126
|
+
addressBookControllerVerifyAddress
|
|
127
|
+
} = getAddressBook();
|
|
128
|
+
var create = addressBookControllerCreate;
|
|
129
|
+
var findAll = addressBookControllerFindAll;
|
|
130
|
+
var findOne = addressBookControllerFindOne;
|
|
131
|
+
var update = addressBookControllerUpdate;
|
|
132
|
+
var remove = addressBookControllerRemove;
|
|
133
|
+
var verifyAddress = addressBookControllerVerifyAddress;
|
|
134
|
+
export {
|
|
135
|
+
create,
|
|
136
|
+
findAll,
|
|
137
|
+
findOne,
|
|
138
|
+
remove,
|
|
139
|
+
update,
|
|
140
|
+
verifyAddress
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=address-book.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/api-client.ts", "../src/config.ts", "../src/api/address-book/address-book.ts", "../src/address-book.ts"],
|
|
4
|
+
"sourcesContent": ["/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n AddressBookControllerFindAllParams,\n AddressBookListResponseDto,\n AddressBookResponseDto,\n CreateAddressBookDto,\n UpdateAddressBookDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAddressBook = () => {\n /**\n * Save a Solana address with a label and optional description/tags for quick access.\n * @summary Add a new address to address book\n */\n const addressBookControllerCreate = (\n createAddressBookDto: CreateAddressBookDto,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n {\n url: `/address-book`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: createAddressBookDto,\n },\n options,\n );\n };\n /**\n * Retrieve paginated list of saved addresses with optional search and tag filtering.\n * @summary Get all addresses in address book\n */\n const addressBookControllerFindAll = (\n params?: AddressBookControllerFindAllParams,\n options?: SecondParameter<\n typeof customInstance<AddressBookListResponseDto>\n >,\n ) => {\n return customInstance<AddressBookListResponseDto>(\n { url: `/address-book`, method: \"GET\", params },\n options,\n );\n };\n /**\n * Retrieve details of a specific address book entry.\n * @summary Get address book entry by ID\n */\n const addressBookControllerFindOne = (\n id: string,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n { url: `/address-book/${id}`, method: \"GET\" },\n options,\n );\n };\n /**\n * Update label, description, tags, or other metadata of an address book entry.\n * @summary Update address book entry\n */\n const addressBookControllerUpdate = (\n id: string,\n updateAddressBookDto: UpdateAddressBookDto,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n {\n url: `/address-book/${id}`,\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n data: updateAddressBookDto,\n },\n options,\n );\n };\n /**\n * Remove an address from the address book.\n * @summary Delete address book entry\n */\n const addressBookControllerRemove = (\n id: string,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n { url: `/address-book/${id}`, method: \"DELETE\" },\n options,\n );\n };\n /**\n * Verify that the saved address is a valid Solana address by checking on-chain.\n * @summary Verify address on-chain\n */\n const addressBookControllerVerifyAddress = (\n id: string,\n options?: SecondParameter<typeof customInstance<AddressBookResponseDto>>,\n ) => {\n return customInstance<AddressBookResponseDto>(\n { url: `/address-book/${id}/verify`, method: \"POST\" },\n options,\n );\n };\n return {\n addressBookControllerCreate,\n addressBookControllerFindAll,\n addressBookControllerFindOne,\n addressBookControllerUpdate,\n addressBookControllerRemove,\n addressBookControllerVerifyAddress,\n };\n};\nexport type AddressBookControllerCreateResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAddressBook>[\"addressBookControllerCreate\"]>\n >\n>;\nexport type AddressBookControllerFindAllResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAddressBook>[\"addressBookControllerFindAll\"]\n >\n >\n>;\nexport type AddressBookControllerFindOneResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAddressBook>[\"addressBookControllerFindOne\"]\n >\n >\n>;\nexport type AddressBookControllerUpdateResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAddressBook>[\"addressBookControllerUpdate\"]>\n >\n>;\nexport type AddressBookControllerRemoveResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAddressBook>[\"addressBookControllerRemove\"]>\n >\n>;\nexport type AddressBookControllerVerifyAddressResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAddressBook>[\"addressBookControllerVerifyAddress\"]\n >\n >\n>;\n", "/**\r\n * Address Book module - Simplified exports for address book API functions\r\n */\r\n\r\nimport { getAddressBook } from './api/address-book/address-book';\r\n\r\nconst {\r\n addressBookControllerCreate,\r\n addressBookControllerFindAll,\r\n addressBookControllerFindOne,\r\n addressBookControllerUpdate,\r\n addressBookControllerRemove,\r\n addressBookControllerVerifyAddress,\r\n} = getAddressBook();\r\n\r\n// Export address book functions with simplified names\r\nexport const create = addressBookControllerCreate;\r\nexport const findAll = addressBookControllerFindAll;\r\nexport const findOne = addressBookControllerFindOne;\r\nexport const update = addressBookControllerUpdate;\r\nexport const remove = addressBookControllerRemove;\r\nexport const verifyAddress = addressBookControllerVerifyAddress;\r\n\r\n// Export types\r\nexport type {\r\n AddressBookControllerCreateResult,\r\n AddressBookControllerFindAllResult,\r\n AddressBookControllerFindOneResult,\r\n AddressBookControllerUpdateResult,\r\n AddressBookControllerRemoveResult,\r\n AddressBookControllerVerifyAddressResult,\r\n} from './api/address-book/address-book';\r\n\r\nexport type {\r\n CreateAddressBookDto,\r\n UpdateAddressBookDto,\r\n AddressBookControllerFindAllParams,\r\n} from './models';\r\n\r\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["addressBookControllerCreate", "addressBookControllerFindAll", "addressBookControllerFindOne", "addressBookControllerUpdate", "addressBookControllerRemove", "addressBookControllerVerifyAddress"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/analytics.ts
|
|
31
|
+
var analytics_exports = {};
|
|
32
|
+
__export(analytics_exports, {
|
|
33
|
+
getWalletAnalytics: () => getWalletAnalytics
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(analytics_exports);
|
|
36
|
+
|
|
37
|
+
// src/api-client.ts
|
|
38
|
+
var import_axios = __toESM(require("axios"));
|
|
39
|
+
|
|
40
|
+
// src/config.ts
|
|
41
|
+
var GLOBAL_CONFIG_KEY = "__CILANTRO_SDK_CONFIG__";
|
|
42
|
+
function getGlobalConfig() {
|
|
43
|
+
const defaultConfig = {
|
|
44
|
+
baseURL: process.env.CILANTRO_API_URL || "https://api.cilantro.gg"
|
|
45
|
+
};
|
|
46
|
+
if (typeof globalThis !== "undefined") {
|
|
47
|
+
if (!globalThis.__CILANTRO_SDK_CONFIG__) {
|
|
48
|
+
globalThis.__CILANTRO_SDK_CONFIG__ = defaultConfig;
|
|
49
|
+
}
|
|
50
|
+
return globalThis.__CILANTRO_SDK_CONFIG__;
|
|
51
|
+
} else if (typeof globalThis.window !== "undefined") {
|
|
52
|
+
const win = globalThis.window;
|
|
53
|
+
if (!win[GLOBAL_CONFIG_KEY]) {
|
|
54
|
+
win[GLOBAL_CONFIG_KEY] = defaultConfig;
|
|
55
|
+
}
|
|
56
|
+
return win[GLOBAL_CONFIG_KEY];
|
|
57
|
+
}
|
|
58
|
+
return defaultConfig;
|
|
59
|
+
}
|
|
60
|
+
var currentConfig = getGlobalConfig();
|
|
61
|
+
function getConfig() {
|
|
62
|
+
currentConfig = getGlobalConfig();
|
|
63
|
+
return currentConfig;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/api-client.ts
|
|
67
|
+
var axiosInstance = import_axios.default.create();
|
|
68
|
+
axiosInstance.interceptors.request.use(
|
|
69
|
+
(config) => {
|
|
70
|
+
const sdkConfig = getConfig();
|
|
71
|
+
config.baseURL = sdkConfig.baseURL || "https://api.cilantro.gg";
|
|
72
|
+
if (sdkConfig.jwt) {
|
|
73
|
+
config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;
|
|
74
|
+
}
|
|
75
|
+
if (sdkConfig.apiKey) {
|
|
76
|
+
config.headers["X-API-Key"] = sdkConfig.apiKey;
|
|
77
|
+
}
|
|
78
|
+
return config;
|
|
79
|
+
},
|
|
80
|
+
(error) => {
|
|
81
|
+
return Promise.reject(error);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
var customInstance = (config, options) => {
|
|
85
|
+
const source = import_axios.default.CancelToken.source();
|
|
86
|
+
const promise = axiosInstance({
|
|
87
|
+
...config,
|
|
88
|
+
...options,
|
|
89
|
+
cancelToken: source.token
|
|
90
|
+
}).then(({ data }) => data);
|
|
91
|
+
promise.cancel = () => {
|
|
92
|
+
source.cancel("Query was cancelled");
|
|
93
|
+
};
|
|
94
|
+
return promise;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/api/analytics/analytics.ts
|
|
98
|
+
var getAnalytics = () => {
|
|
99
|
+
const walletAnalyticsControllerGetWalletAnalytics2 = (id, params, options) => {
|
|
100
|
+
return customInstance(
|
|
101
|
+
{ url: `/wallets/${id}/analytics`, method: "GET", params },
|
|
102
|
+
options
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
return { walletAnalyticsControllerGetWalletAnalytics: walletAnalyticsControllerGetWalletAnalytics2 };
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/analytics.ts
|
|
109
|
+
var { walletAnalyticsControllerGetWalletAnalytics } = getAnalytics();
|
|
110
|
+
var getWalletAnalytics = walletAnalyticsControllerGetWalletAnalytics;
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
getWalletAnalytics
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=analytics.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/analytics.ts", "../src/api-client.ts", "../src/config.ts", "../src/api/analytics/analytics.ts"],
|
|
4
|
+
"sourcesContent": ["/**\r\n * Analytics module - Simplified exports for analytics API functions\r\n */\r\n\r\nimport { getAnalytics } from './api/analytics/analytics';\r\n\r\nconst { walletAnalyticsControllerGetWalletAnalytics } = getAnalytics();\r\n\r\n// Export analytics functions with simplified names\r\n// Note: Requires walletId (id) as the first parameter\r\nexport const getWalletAnalytics = walletAnalyticsControllerGetWalletAnalytics;\r\n\r\n// Export types\r\nexport type { WalletAnalyticsControllerGetWalletAnalyticsResult } from './api/analytics/analytics';\r\n\r\nexport type { WalletAnalyticsControllerGetWalletAnalyticsParams } from './models';\r\n\r\n", "/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n WalletAnalyticsControllerGetWalletAnalyticsParams,\n WalletAnalyticsResponseDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAnalytics = () => {\n /**\n * Get comprehensive analytics for a wallet including balance trends, transaction volumes, asset distribution, spending patterns, and monthly/weekly summaries. Balance history is only calculated when includeHistory=true to optimize performance.\n * @summary Get wallet analytics\n */\n const walletAnalyticsControllerGetWalletAnalytics = (\n id: string,\n params?: WalletAnalyticsControllerGetWalletAnalyticsParams,\n options?: SecondParameter<\n typeof customInstance<WalletAnalyticsResponseDto>\n >,\n ) => {\n return customInstance<WalletAnalyticsResponseDto>(\n { url: `/wallets/${id}/analytics`, method: \"GET\", params },\n options,\n );\n };\n return { walletAnalyticsControllerGetWalletAnalytics };\n};\nexport type WalletAnalyticsControllerGetWalletAnalyticsResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<\n typeof getAnalytics\n >[\"walletAnalyticsControllerGetWalletAnalytics\"]\n >\n >\n>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,mBAAwE;;;ACexE,IAAM,oBAAoB;AAQ1B,SAAS,kBAA6B;AACpC,QAAM,gBAA2B;AAAA,IAC/B,SAAS,QAAQ,IAAI,oBAAoB;AAAA,EAC3C;AAEA,MAAI,OAAO,eAAW,aAAa;AACjC,QAAI,CAAC,WAAO,yBAAyB;AACnC,iBAAO,0BAA0B;AAAA,IACnC;AACA,WAAO,WAAO;AAAA,EAChB,WAAW,OAAQ,WAAmB,WAAW,aAAa;AAC5D,UAAM,MAAO,WAAmB;AAChC,QAAI,CAAC,IAAI,iBAAiB,GAAG;AAC3B,UAAI,iBAAiB,IAAI;AAAA,IAC3B;AACA,WAAO,IAAI,iBAAiB;AAAA,EAC9B;AAGA,SAAO;AACT;AAEA,IAAI,gBAA2B,gBAAgB;AAkGxC,SAAS,YAAiC;AAE/C,kBAAgB,gBAAgB;AAChC,SAAO;AACT;;;AD/IA,IAAM,gBAA+B,aAAAA,QAAM,OAAO;AAGlD,cAAc,aAAa,QAAQ;AAAA,EACjC,CAAC,WAAW;AACV,UAAM,YAAY,UAAU;AAG5B,WAAO,UAAU,UAAU,WAAW;AAGtC,QAAI,UAAU,KAAK;AACjB,aAAO,QAAQ,gBAAgB,UAAU,UAAU,GAAG;AAAA,IACxD;AAGA,QAAI,UAAU,QAAQ;AACpB,aAAO,QAAQ,WAAW,IAAI,UAAU;AAAA,IAC1C;AAEA,WAAO;AAAA,EACT;AAAA,EACA,CAAC,UAAU;AACT,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAMO,IAAM,iBAAiB,CAC5B,QACA,YACe;AACf,QAAM,SAAS,aAAAA,QAAM,YAAY,OAAO;AACxC,QAAM,UAAU,cAAc;AAAA,IAC5B,GAAG;AAAA,IACH,GAAG;AAAA,IACH,aAAa,OAAO;AAAA,EACtB,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,MAAwB,IAAI;AAG5C,UAAQ,SAAS,MAAM;AACrB,WAAO,OAAO,qBAAqB;AAAA,EACrC;AAEA,SAAO;AACT;;;AE1CO,IAAM,eAAe,MAAM;AAKhC,QAAMC,+CAA8C,CAClD,IACA,QACA,YAGG;AACH,WAAO;AAAA,MACL,EAAE,KAAK,YAAY,EAAE,cAAc,QAAQ,OAAO,OAAO;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,6CAAAA,6CAA4C;AACvD;;;AH5BA,IAAM,EAAE,4CAA4C,IAAI,aAAa;AAI9D,IAAM,qBAAqB;",
|
|
6
|
+
"names": ["axios", "walletAnalyticsControllerGetWalletAnalytics"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/api-client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
// src/config.ts
|
|
5
|
+
var GLOBAL_CONFIG_KEY = "__CILANTRO_SDK_CONFIG__";
|
|
6
|
+
function getGlobalConfig() {
|
|
7
|
+
const defaultConfig = {
|
|
8
|
+
baseURL: process.env.CILANTRO_API_URL || "https://api.cilantro.gg"
|
|
9
|
+
};
|
|
10
|
+
if (typeof globalThis !== "undefined") {
|
|
11
|
+
if (!globalThis.__CILANTRO_SDK_CONFIG__) {
|
|
12
|
+
globalThis.__CILANTRO_SDK_CONFIG__ = defaultConfig;
|
|
13
|
+
}
|
|
14
|
+
return globalThis.__CILANTRO_SDK_CONFIG__;
|
|
15
|
+
} else if (typeof globalThis.window !== "undefined") {
|
|
16
|
+
const win = globalThis.window;
|
|
17
|
+
if (!win[GLOBAL_CONFIG_KEY]) {
|
|
18
|
+
win[GLOBAL_CONFIG_KEY] = defaultConfig;
|
|
19
|
+
}
|
|
20
|
+
return win[GLOBAL_CONFIG_KEY];
|
|
21
|
+
}
|
|
22
|
+
return defaultConfig;
|
|
23
|
+
}
|
|
24
|
+
var currentConfig = getGlobalConfig();
|
|
25
|
+
function getConfig() {
|
|
26
|
+
currentConfig = getGlobalConfig();
|
|
27
|
+
return currentConfig;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/api-client.ts
|
|
31
|
+
var axiosInstance = axios.create();
|
|
32
|
+
axiosInstance.interceptors.request.use(
|
|
33
|
+
(config) => {
|
|
34
|
+
const sdkConfig = getConfig();
|
|
35
|
+
config.baseURL = sdkConfig.baseURL || "https://api.cilantro.gg";
|
|
36
|
+
if (sdkConfig.jwt) {
|
|
37
|
+
config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;
|
|
38
|
+
}
|
|
39
|
+
if (sdkConfig.apiKey) {
|
|
40
|
+
config.headers["X-API-Key"] = sdkConfig.apiKey;
|
|
41
|
+
}
|
|
42
|
+
return config;
|
|
43
|
+
},
|
|
44
|
+
(error) => {
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
var customInstance = (config, options) => {
|
|
49
|
+
const source = axios.CancelToken.source();
|
|
50
|
+
const promise = axiosInstance({
|
|
51
|
+
...config,
|
|
52
|
+
...options,
|
|
53
|
+
cancelToken: source.token
|
|
54
|
+
}).then(({ data }) => data);
|
|
55
|
+
promise.cancel = () => {
|
|
56
|
+
source.cancel("Query was cancelled");
|
|
57
|
+
};
|
|
58
|
+
return promise;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/api/analytics/analytics.ts
|
|
62
|
+
var getAnalytics = () => {
|
|
63
|
+
const walletAnalyticsControllerGetWalletAnalytics2 = (id, params, options) => {
|
|
64
|
+
return customInstance(
|
|
65
|
+
{ url: `/wallets/${id}/analytics`, method: "GET", params },
|
|
66
|
+
options
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
return { walletAnalyticsControllerGetWalletAnalytics: walletAnalyticsControllerGetWalletAnalytics2 };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// src/analytics.ts
|
|
73
|
+
var { walletAnalyticsControllerGetWalletAnalytics } = getAnalytics();
|
|
74
|
+
var getWalletAnalytics = walletAnalyticsControllerGetWalletAnalytics;
|
|
75
|
+
export {
|
|
76
|
+
getWalletAnalytics
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=analytics.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/api-client.ts", "../src/config.ts", "../src/api/analytics/analytics.ts", "../src/analytics.ts"],
|
|
4
|
+
"sourcesContent": ["/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n WalletAnalyticsControllerGetWalletAnalyticsParams,\n WalletAnalyticsResponseDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAnalytics = () => {\n /**\n * Get comprehensive analytics for a wallet including balance trends, transaction volumes, asset distribution, spending patterns, and monthly/weekly summaries. Balance history is only calculated when includeHistory=true to optimize performance.\n * @summary Get wallet analytics\n */\n const walletAnalyticsControllerGetWalletAnalytics = (\n id: string,\n params?: WalletAnalyticsControllerGetWalletAnalyticsParams,\n options?: SecondParameter<\n typeof customInstance<WalletAnalyticsResponseDto>\n >,\n ) => {\n return customInstance<WalletAnalyticsResponseDto>(\n { url: `/wallets/${id}/analytics`, method: \"GET\", params },\n options,\n );\n };\n return { walletAnalyticsControllerGetWalletAnalytics };\n};\nexport type WalletAnalyticsControllerGetWalletAnalyticsResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<\n typeof getAnalytics\n >[\"walletAnalyticsControllerGetWalletAnalytics\"]\n >\n >\n>;\n", "/**\r\n * Analytics module - Simplified exports for analytics API functions\r\n */\r\n\r\nimport { getAnalytics } from './api/analytics/analytics';\r\n\r\nconst { walletAnalyticsControllerGetWalletAnalytics } = getAnalytics();\r\n\r\n// Export analytics functions with simplified names\r\n// Note: Requires walletId (id) as the first parameter\r\nexport const getWalletAnalytics = walletAnalyticsControllerGetWalletAnalytics;\r\n\r\n// Export types\r\nexport type { WalletAnalyticsControllerGetWalletAnalyticsResult } from './api/analytics/analytics';\r\n\r\nexport type { WalletAnalyticsControllerGetWalletAnalyticsParams } from './models';\r\n\r\n"],
|
|
5
|
+
"mappings": ";AAMA,OAAO,WAAiE;;;ACexE,IAAM,oBAAoB;AAQ1B,SAAS,kBAA6B;AACpC,QAAM,gBAA2B;AAAA,IAC/B,SAAS,QAAQ,IAAI,oBAAoB;AAAA,EAC3C;AAEA,MAAI,OAAO,eAAW,aAAa;AACjC,QAAI,CAAC,WAAO,yBAAyB;AACnC,iBAAO,0BAA0B;AAAA,IACnC;AACA,WAAO,WAAO;AAAA,EAChB,WAAW,OAAQ,WAAmB,WAAW,aAAa;AAC5D,UAAM,MAAO,WAAmB;AAChC,QAAI,CAAC,IAAI,iBAAiB,GAAG;AAC3B,UAAI,iBAAiB,IAAI;AAAA,IAC3B;AACA,WAAO,IAAI,iBAAiB;AAAA,EAC9B;AAGA,SAAO;AACT;AAEA,IAAI,gBAA2B,gBAAgB;AAkGxC,SAAS,YAAiC;AAE/C,kBAAgB,gBAAgB;AAChC,SAAO;AACT;;;AD/IA,IAAM,gBAA+B,MAAM,OAAO;AAGlD,cAAc,aAAa,QAAQ;AAAA,EACjC,CAAC,WAAW;AACV,UAAM,YAAY,UAAU;AAG5B,WAAO,UAAU,UAAU,WAAW;AAGtC,QAAI,UAAU,KAAK;AACjB,aAAO,QAAQ,gBAAgB,UAAU,UAAU,GAAG;AAAA,IACxD;AAGA,QAAI,UAAU,QAAQ;AACpB,aAAO,QAAQ,WAAW,IAAI,UAAU;AAAA,IAC1C;AAEA,WAAO;AAAA,EACT;AAAA,EACA,CAAC,UAAU;AACT,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAMO,IAAM,iBAAiB,CAC5B,QACA,YACe;AACf,QAAM,SAAS,MAAM,YAAY,OAAO;AACxC,QAAM,UAAU,cAAc;AAAA,IAC5B,GAAG;AAAA,IACH,GAAG;AAAA,IACH,aAAa,OAAO;AAAA,EACtB,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,MAAwB,IAAI;AAG5C,UAAQ,SAAS,MAAM;AACrB,WAAO,OAAO,qBAAqB;AAAA,EACrC;AAEA,SAAO;AACT;;;AE1CO,IAAM,eAAe,MAAM;AAKhC,QAAMA,+CAA8C,CAClD,IACA,QACA,YAGG;AACH,WAAO;AAAA,MACL,EAAE,KAAK,YAAY,EAAE,cAAc,QAAQ,OAAO,OAAO;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,6CAAAA,6CAA4C;AACvD;;;AC5BA,IAAM,EAAE,4CAA4C,IAAI,aAAa;AAI9D,IAAM,qBAAqB;",
|
|
6
|
+
"names": ["walletAnalyticsControllerGetWalletAnalytics"]
|
|
7
|
+
}
|