@takyonic/sdk 1.0.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.
- package/README.md +295 -0
- package/dist/admin-client.d.ts +64 -0
- package/dist/admin-client.d.ts.map +1 -0
- package/dist/admin-client.js +126 -0
- package/dist/admin-client.js.map +1 -0
- package/dist/client.d.ts +102 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +229 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +47 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +97 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/table-builder.d.ts +159 -0
- package/dist/table-builder.d.ts.map +1 -0
- package/dist/table-builder.js +251 -0
- package/dist/table-builder.js.map +1 -0
- package/dist/types.d.ts +148 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableBuilder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Maximum number of records per bulk write request.
|
|
6
|
+
* The Takyonic server enforces this limit.
|
|
7
|
+
*/
|
|
8
|
+
const BULK_WRITE_BATCH_SIZE = 1000;
|
|
9
|
+
/**
|
|
10
|
+
* TableBuilder provides a fluent/chainable API for querying and modifying table data.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Search with filters
|
|
15
|
+
* const logs = await db.table('logs')
|
|
16
|
+
* .where('severity', '>', 4)
|
|
17
|
+
* .where('event', '=', 'error')
|
|
18
|
+
* .get();
|
|
19
|
+
*
|
|
20
|
+
* // Find a single record
|
|
21
|
+
* const user = await db.table('users').findById('user-123');
|
|
22
|
+
*
|
|
23
|
+
* // Insert records
|
|
24
|
+
* await db.table('logs').insert({ id: 'log-1', message: 'Hello' });
|
|
25
|
+
*
|
|
26
|
+
* // Bulk insert with automatic batching
|
|
27
|
+
* await db.table('logs').insertMany(thousandsOfRecords);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
class TableBuilder {
|
|
31
|
+
client;
|
|
32
|
+
tableName;
|
|
33
|
+
filters = [];
|
|
34
|
+
constructor(client, tableName) {
|
|
35
|
+
// Store reference - avoid circular import by using interface
|
|
36
|
+
this.client = client;
|
|
37
|
+
this.tableName = tableName;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Adds a filter condition to the query.
|
|
41
|
+
* Multiple calls to where() are combined with AND logic.
|
|
42
|
+
*
|
|
43
|
+
* @param column - The column name to filter on
|
|
44
|
+
* @param operator - Comparison operator ('>', '<', '>=', '<=', '=', '!=')
|
|
45
|
+
* @param value - The value to compare against
|
|
46
|
+
* @returns The TableBuilder instance for chaining
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const results = await db.table('logs')
|
|
51
|
+
* .where('severity', '>=', 3)
|
|
52
|
+
* .where('event', '=', 'login')
|
|
53
|
+
* .get();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
where(column, operator, value) {
|
|
57
|
+
// Create a new TableBuilder with the same state plus the new filter
|
|
58
|
+
const builder = new TableBuilder(this.client, this.tableName);
|
|
59
|
+
builder.filters = [...this.filters, { column, operator, value }];
|
|
60
|
+
return builder;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Adds a full-text search filter using PostgreSQL FTS.
|
|
64
|
+
* Uses GIN indexes for sub-millisecond text searching across large datasets.
|
|
65
|
+
* Multiple search() calls are combined with AND logic.
|
|
66
|
+
*
|
|
67
|
+
* @param column - The column name to search in (text, varchar, or jsonb)
|
|
68
|
+
* @param query - The search terms (words are combined with AND logic)
|
|
69
|
+
* @returns The TableBuilder instance for chaining
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Find logs containing "critical" in the event field
|
|
74
|
+
* const logs = await db.table('logs')
|
|
75
|
+
* .search('event', 'critical')
|
|
76
|
+
* .get();
|
|
77
|
+
*
|
|
78
|
+
* // Combine FTS with regular filters
|
|
79
|
+
* const errorLogs = await db.table('logs')
|
|
80
|
+
* .search('payload', 'database connection')
|
|
81
|
+
* .where('severity', '>', 3)
|
|
82
|
+
* .get();
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
search(column, query) {
|
|
86
|
+
const builder = new TableBuilder(this.client, this.tableName);
|
|
87
|
+
builder.filters = [...this.filters, { column, operator: '@', value: query }];
|
|
88
|
+
return builder;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Executes the query with all applied filters and returns the matching records.
|
|
92
|
+
*
|
|
93
|
+
* @returns Promise resolving to an array of matching records
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const logs = await db.table('logs')
|
|
98
|
+
* .where('severity', '>', 4)
|
|
99
|
+
* .get();
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async get() {
|
|
103
|
+
// Build query parameters from filters
|
|
104
|
+
// The Takyonic server expects format: ?column=operator+value
|
|
105
|
+
// e.g., ?severity=>4 or ?age=>=18
|
|
106
|
+
const queryParams = {};
|
|
107
|
+
for (const filter of this.filters) {
|
|
108
|
+
// Combine operator and value
|
|
109
|
+
// The operator and value are automatically URL-encoded by URLSearchParams
|
|
110
|
+
queryParams[filter.column] = `${filter.operator}${filter.value}`;
|
|
111
|
+
}
|
|
112
|
+
return this.client.request({
|
|
113
|
+
method: 'GET',
|
|
114
|
+
path: `/v1/search/${encodeURIComponent(this.tableName)}`,
|
|
115
|
+
queryParams,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Fetches a single record by its ID.
|
|
120
|
+
*
|
|
121
|
+
* @param id - The unique identifier of the record
|
|
122
|
+
* @returns Promise resolving to the record, or null if not found
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const user = await db.table('users').findById('user-123');
|
|
127
|
+
* if (user) {
|
|
128
|
+
* console.log(user.name);
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
async findById(id) {
|
|
133
|
+
try {
|
|
134
|
+
return await this.client.request({
|
|
135
|
+
method: 'GET',
|
|
136
|
+
path: `/v1/read/${encodeURIComponent(this.tableName)}/${encodeURIComponent(id)}`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
// Return null for 404 errors
|
|
141
|
+
if (error instanceof Error && 'statusCode' in error && error.statusCode === 404) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Inserts a new record or updates an existing one (upsert).
|
|
149
|
+
* The record must have an 'id' field.
|
|
150
|
+
*
|
|
151
|
+
* @param data - The record data to insert
|
|
152
|
+
* @returns Promise resolving to the write result
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* await db.table('users').insert({
|
|
157
|
+
* id: 'user-123',
|
|
158
|
+
* name: 'John Doe',
|
|
159
|
+
* email: 'john@example.com'
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
async insert(data) {
|
|
164
|
+
return this.client.request({
|
|
165
|
+
method: 'POST',
|
|
166
|
+
path: `/v1/write/${encodeURIComponent(this.tableName)}`,
|
|
167
|
+
body: data,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Alias for insert(). Inserts a new record or updates an existing one.
|
|
172
|
+
*
|
|
173
|
+
* @param data - The record data to upsert
|
|
174
|
+
* @returns Promise resolving to the write result
|
|
175
|
+
*/
|
|
176
|
+
async upsert(data) {
|
|
177
|
+
return this.insert(data);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Inserts multiple records with automatic batching.
|
|
181
|
+
* Large arrays are automatically chunked into batches of 1000 records
|
|
182
|
+
* to comply with the server's bulk write limit.
|
|
183
|
+
*
|
|
184
|
+
* @param records - Array of records to insert
|
|
185
|
+
* @returns Promise resolving to the bulk insert result
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const logs = Array.from({ length: 5000 }, (_, i) => ({
|
|
190
|
+
* id: `log-${i}`,
|
|
191
|
+
* message: `Log entry ${i}`,
|
|
192
|
+
* severity: Math.floor(Math.random() * 5)
|
|
193
|
+
* }));
|
|
194
|
+
*
|
|
195
|
+
* const result = await db.table('logs').insertMany(logs);
|
|
196
|
+
* console.log(`Inserted ${result.totalInserted} records in ${result.batchesProcessed} batches`);
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
async insertMany(records) {
|
|
200
|
+
if (records.length === 0) {
|
|
201
|
+
return {
|
|
202
|
+
totalInserted: 0,
|
|
203
|
+
batchesProcessed: 0,
|
|
204
|
+
success: true,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
// Split records into batches of BULK_WRITE_BATCH_SIZE
|
|
208
|
+
const batches = [];
|
|
209
|
+
for (let i = 0; i < records.length; i += BULK_WRITE_BATCH_SIZE) {
|
|
210
|
+
batches.push(records.slice(i, i + BULK_WRITE_BATCH_SIZE));
|
|
211
|
+
}
|
|
212
|
+
let totalInserted = 0;
|
|
213
|
+
let batchesProcessed = 0;
|
|
214
|
+
// Process batches sequentially to avoid overwhelming the server
|
|
215
|
+
for (const batch of batches) {
|
|
216
|
+
const result = await this.client.request({
|
|
217
|
+
method: 'POST',
|
|
218
|
+
path: `/v1/bulk-write/${encodeURIComponent(this.tableName)}`,
|
|
219
|
+
body: batch,
|
|
220
|
+
});
|
|
221
|
+
totalInserted += result.records_inserted;
|
|
222
|
+
batchesProcessed++;
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
totalInserted,
|
|
226
|
+
batchesProcessed,
|
|
227
|
+
success: totalInserted === records.length,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Invalidates the cache for a specific record.
|
|
232
|
+
* This forces the next read to fetch from the database.
|
|
233
|
+
*
|
|
234
|
+
* @param id - The unique identifier of the record to invalidate
|
|
235
|
+
* @returns Promise that resolves when the cache is invalidated
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* // After an external update, invalidate the cache
|
|
240
|
+
* await db.table('users').invalidateCache('user-123');
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
async invalidateCache(id) {
|
|
244
|
+
await this.client.request({
|
|
245
|
+
method: 'DELETE',
|
|
246
|
+
path: `/v1/read/${encodeURIComponent(this.tableName)}/${encodeURIComponent(id)}`,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.TableBuilder = TableBuilder;
|
|
251
|
+
//# sourceMappingURL=table-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-builder.js","sourceRoot":"","sources":["../src/table-builder.ts"],"names":[],"mappings":";;;AASA;;;GAGG;AACH,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,YAAY;IACN,MAAM,CAAiB;IACvB,SAAS,CAAS;IAC3B,OAAO,GAAa,EAAE,CAAC;IAE/B,YAAY,MAAsB,EAAE,SAAiB;QACnD,6DAA6D;QAC7D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IAC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B,EAAE,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC;QAC5D,CAAC;QAED,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,IAAI,gBAAgB,GAAG,CAAC,CAAC;QAEzB,gEAAgE;QAChE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAG,MAAO,IAAI,CAAC,MAAuC,CAAC,OAAO,CAA+C;gBACvH,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAC5D,IAAI,EAAE,KAAK;aACZ,CAAC,CAAC;YAEH,aAAa,IAAI,MAAM,CAAC,gBAAgB,CAAC;YACzC,gBAAgB,EAAE,CAAC;QACrB,CAAC;QAED,OAAO;YACL,aAAa;YACb,gBAAgB;YAChB,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,MAAM;SAC1C,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,eAAe,CAAC,EAAU;QAC9B,MAAO,IAAI,CAAC,MAAuC,CAAC,OAAO,CAAO;YAChE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,EAAE,CAAC,EAAE;SACjF,CAAC,CAAC;IACL,CAAC;CACF;AA9OD,oCA8OC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for the Takyonic client
|
|
3
|
+
*/
|
|
4
|
+
export interface TakyonicConfig {
|
|
5
|
+
/** The base URL of the Takyonic server (e.g., 'http://localhost:8080') */
|
|
6
|
+
endpoint: string;
|
|
7
|
+
/** Bearer token for API authentication */
|
|
8
|
+
token: string;
|
|
9
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Comparison operators for search queries
|
|
14
|
+
* '@' is used for Full-Text Search (FTS)
|
|
15
|
+
*/
|
|
16
|
+
export type ComparisonOperator = '>' | '<' | '>=' | '<=' | '=' | '!=' | '@';
|
|
17
|
+
/**
|
|
18
|
+
* A filter condition for search queries
|
|
19
|
+
*/
|
|
20
|
+
export interface Filter {
|
|
21
|
+
column: string;
|
|
22
|
+
operator: ComparisonOperator;
|
|
23
|
+
value: string | number | boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Base record type - all records must have an id field
|
|
27
|
+
*/
|
|
28
|
+
export interface BaseRecord {
|
|
29
|
+
id: string;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Result of a bulk insert operation
|
|
34
|
+
*/
|
|
35
|
+
export interface BulkInsertResult {
|
|
36
|
+
/** Total number of records successfully inserted */
|
|
37
|
+
totalInserted: number;
|
|
38
|
+
/** Number of batches processed */
|
|
39
|
+
batchesProcessed: number;
|
|
40
|
+
/** Whether all records were inserted successfully */
|
|
41
|
+
success: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of a single write operation
|
|
45
|
+
*/
|
|
46
|
+
export interface WriteResult {
|
|
47
|
+
status: 'ok';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Server statistics response
|
|
51
|
+
*/
|
|
52
|
+
export interface ServerStats {
|
|
53
|
+
cache_hits: number;
|
|
54
|
+
cache_misses: number;
|
|
55
|
+
total_requests: number;
|
|
56
|
+
db_queries: number;
|
|
57
|
+
uptime_seconds: number;
|
|
58
|
+
memory_cache_size: number;
|
|
59
|
+
bloom_filter_size: number;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Column schema information
|
|
64
|
+
*/
|
|
65
|
+
export interface ColumnSchema {
|
|
66
|
+
name: string;
|
|
67
|
+
data_type: string;
|
|
68
|
+
nullable: boolean;
|
|
69
|
+
default_value?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Index information
|
|
73
|
+
*/
|
|
74
|
+
export interface IndexInfo {
|
|
75
|
+
name: string;
|
|
76
|
+
columns: string[];
|
|
77
|
+
unique: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Foreign key information
|
|
81
|
+
*/
|
|
82
|
+
export interface ForeignKeyInfo {
|
|
83
|
+
name: string;
|
|
84
|
+
columns: string[];
|
|
85
|
+
referenced_table: string;
|
|
86
|
+
referenced_columns: string[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Table schema information
|
|
90
|
+
*/
|
|
91
|
+
export interface TableSchema {
|
|
92
|
+
name: string;
|
|
93
|
+
columns: ColumnSchema[];
|
|
94
|
+
indexes?: IndexInfo[];
|
|
95
|
+
foreign_keys?: ForeignKeyInfo[];
|
|
96
|
+
cache_ttl?: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Schema response from the server
|
|
100
|
+
*/
|
|
101
|
+
export interface SchemaResponse {
|
|
102
|
+
tables: TableSchema[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Error response from the server
|
|
106
|
+
*/
|
|
107
|
+
export interface ErrorResponse {
|
|
108
|
+
error: string;
|
|
109
|
+
message?: string;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Internal request options
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
export interface RequestOptions {
|
|
117
|
+
method: 'GET' | 'POST' | 'DELETE';
|
|
118
|
+
path: string;
|
|
119
|
+
body?: unknown;
|
|
120
|
+
queryParams?: Record<string, string>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Configuration options for the Admin client
|
|
124
|
+
*/
|
|
125
|
+
export interface AdminConfig {
|
|
126
|
+
/** The base URL of the Takyonic server (e.g., 'http://localhost:8080') */
|
|
127
|
+
endpoint: string;
|
|
128
|
+
/** Admin secret for privileged operations */
|
|
129
|
+
adminSecret: string;
|
|
130
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
131
|
+
timeout?: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Result of a migration operation
|
|
135
|
+
*/
|
|
136
|
+
export interface MigrationResult {
|
|
137
|
+
/** Status of the migration */
|
|
138
|
+
status: 'ok';
|
|
139
|
+
/** Tables that were created during migration */
|
|
140
|
+
tables_created: string[];
|
|
141
|
+
/** Columns added to existing tables (table name -> column names) */
|
|
142
|
+
columns_added: Record<string, string[]>;
|
|
143
|
+
/** Tables that were updated during migration */
|
|
144
|
+
tables_updated: string[];
|
|
145
|
+
/** Human-readable message about the migration */
|
|
146
|
+
message: string;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACz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AO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,MAAM,EAAE,IAAI,CAAC;IACb,gDAAgD;IAChD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,gDAAgD;IAChD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@takyonic/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official Node.js SDK for Takyonic - A high-performance caching engine",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"dev": "tsc --watch",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"takyonic",
|
|
25
|
+
"cache",
|
|
26
|
+
"database",
|
|
27
|
+
"sdk",
|
|
28
|
+
"typescript"
|
|
29
|
+
],
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.10.0",
|
|
37
|
+
"typescript": "^5.3.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|