@luxdb/sdk 1.3.0 → 1.4.2
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 +132 -0
- package/dist/cjs/auth.js +504 -0
- package/dist/cjs/browser.js +14 -0
- package/dist/{index.js → cjs/index.js} +46 -7
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/project.js +313 -0
- package/dist/cjs/ssr.js +40 -0
- package/dist/{table.js → cjs/table.js} +55 -43
- package/dist/esm/auth.js +500 -0
- package/dist/esm/browser.js +11 -0
- package/dist/esm/index.js +270 -0
- package/dist/esm/namespaces.js +41 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/project.js +303 -0
- package/dist/esm/realtime.js +84 -0
- package/dist/esm/ssr.js +37 -0
- package/dist/esm/table.js +391 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils.js +12 -0
- package/dist/types/auth.d.ts +163 -0
- package/dist/types/browser.d.ts +4 -0
- package/dist/{index.d.ts → types/index.d.ts} +17 -2
- package/dist/types/project.d.ts +121 -0
- package/dist/types/ssr.d.ts +22 -0
- package/dist/{table.d.ts → types/table.d.ts} +11 -2
- package/package.json +40 -6
- /package/dist/{namespaces.js → cjs/namespaces.js} +0 -0
- /package/dist/{realtime.js → cjs/realtime.js} +0 -0
- /package/dist/{types.js → cjs/types.js} +0 -0
- /package/dist/{utils.js → cjs/utils.js} +0 -0
- /package/dist/{namespaces.d.ts → types/namespaces.d.ts} +0 -0
- /package/dist/{realtime.d.ts → types/realtime.d.ts} +0 -0
- /package/dist/{types.d.ts → types/types.d.ts} +0 -0
- /package/dist/{utils.d.ts → types/utils.d.ts} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { LuxAuthClient, type LuxAuthOptions } from './auth';
|
|
2
|
+
import type { LuxResult } from './types';
|
|
3
|
+
export interface LuxProjectOptions {
|
|
4
|
+
url: string;
|
|
5
|
+
key: string;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
auth?: Omit<LuxAuthOptions, 'httpUrl' | 'apiKey' | 'fetch'>;
|
|
8
|
+
}
|
|
9
|
+
export interface LuxTableColumn {
|
|
10
|
+
name: string;
|
|
11
|
+
type: 'STR' | 'INT' | 'FLOAT' | 'BOOL' | 'TIMESTAMP' | 'UUID';
|
|
12
|
+
primaryKey?: boolean;
|
|
13
|
+
unique?: boolean;
|
|
14
|
+
notNull?: boolean;
|
|
15
|
+
references?: string;
|
|
16
|
+
onDelete?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LuxVectorSearchOptions {
|
|
19
|
+
vector: number[];
|
|
20
|
+
k?: number;
|
|
21
|
+
filter?: string;
|
|
22
|
+
filter_value?: string;
|
|
23
|
+
}
|
|
24
|
+
type QueryValue = string | number | boolean | null;
|
|
25
|
+
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'is';
|
|
26
|
+
interface QueryFilter {
|
|
27
|
+
column: string;
|
|
28
|
+
operator: FilterOperator;
|
|
29
|
+
value: QueryValue;
|
|
30
|
+
}
|
|
31
|
+
interface QueryOrder {
|
|
32
|
+
column: string;
|
|
33
|
+
ascending: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare class LuxProjectClient {
|
|
36
|
+
readonly url: string;
|
|
37
|
+
readonly key: string;
|
|
38
|
+
readonly auth: LuxAuthClient;
|
|
39
|
+
private fetchImpl;
|
|
40
|
+
constructor(options: LuxProjectOptions);
|
|
41
|
+
table<T extends Record<string, unknown> = Record<string, unknown>>(name: string): LuxProjectTable<T>;
|
|
42
|
+
ping(): Promise<LuxResult<unknown>>;
|
|
43
|
+
createTable(name: string, columns: Array<string | LuxTableColumn>): Promise<LuxResult<unknown>>;
|
|
44
|
+
exec(command: string | string[]): Promise<LuxResult<unknown>>;
|
|
45
|
+
vectorSet(key: string, vector: number[], metadata?: Record<string, unknown>): Promise<LuxResult<unknown>>;
|
|
46
|
+
vectorSearch(options: LuxVectorSearchOptions): Promise<LuxResult<unknown>>;
|
|
47
|
+
tsAdd(key: string, value: number, options?: {
|
|
48
|
+
timestamp?: number | '*';
|
|
49
|
+
labels?: Record<string, string>;
|
|
50
|
+
retention?: number;
|
|
51
|
+
}): Promise<LuxResult<unknown>>;
|
|
52
|
+
tsRange(key: string, options?: {
|
|
53
|
+
from?: number | '-';
|
|
54
|
+
to?: number | '+';
|
|
55
|
+
count?: number;
|
|
56
|
+
}): Promise<LuxResult<unknown>>;
|
|
57
|
+
request<T = unknown>(method: string, path: string, body?: unknown): Promise<LuxResult<T>>;
|
|
58
|
+
}
|
|
59
|
+
export declare class LuxProjectTable<T extends Record<string, unknown>> {
|
|
60
|
+
private client;
|
|
61
|
+
private name;
|
|
62
|
+
constructor(client: LuxProjectClient, name: string);
|
|
63
|
+
select(columns?: string): LuxProjectSelectBuilder<T, T[]>;
|
|
64
|
+
insert(row: Partial<T> & Record<string, QueryValue>): LuxProjectInsertBuilder<unknown>;
|
|
65
|
+
insert(rows: Array<Partial<T> & Record<string, QueryValue>>): LuxProjectInsertBuilder<unknown[]>;
|
|
66
|
+
update(patch: Partial<T> & Record<string, QueryValue>): LuxProjectMutationBuilder<unknown>;
|
|
67
|
+
delete(): LuxProjectMutationBuilder<unknown>;
|
|
68
|
+
count(): Promise<LuxResult<number>>;
|
|
69
|
+
}
|
|
70
|
+
declare abstract class LuxProjectThenable<TResult> implements PromiseLike<LuxResult<TResult>> {
|
|
71
|
+
then<TFulfilled = LuxResult<TResult>, TRejected = never>(onfulfilled?: ((value: LuxResult<TResult>) => TFulfilled | PromiseLike<TFulfilled>) | null, onrejected?: ((reason: unknown) => TRejected | PromiseLike<TRejected>) | null): Promise<TFulfilled | TRejected>;
|
|
72
|
+
catch<TRejected = never>(onrejected?: ((reason: unknown) => TRejected | PromiseLike<TRejected>) | null): Promise<LuxResult<TResult> | TRejected>;
|
|
73
|
+
finally(onfinally?: (() => void) | null): Promise<LuxResult<TResult>>;
|
|
74
|
+
abstract execute(): Promise<LuxResult<TResult>>;
|
|
75
|
+
}
|
|
76
|
+
declare abstract class LuxProjectFilterBuilder<TResult, TSelf> extends LuxProjectThenable<TResult> {
|
|
77
|
+
protected client: LuxProjectClient;
|
|
78
|
+
protected tableName: string;
|
|
79
|
+
protected filters: QueryFilter[];
|
|
80
|
+
protected orderBy?: QueryOrder;
|
|
81
|
+
protected limitCount?: number;
|
|
82
|
+
protected offsetCount?: number;
|
|
83
|
+
protected constructor(client: LuxProjectClient, tableName: string);
|
|
84
|
+
eq(column: string, value: QueryValue): TSelf;
|
|
85
|
+
neq(column: string, value: QueryValue): TSelf;
|
|
86
|
+
gt(column: string, value: QueryValue): TSelf;
|
|
87
|
+
gte(column: string, value: QueryValue): TSelf;
|
|
88
|
+
lt(column: string, value: QueryValue): TSelf;
|
|
89
|
+
lte(column: string, value: QueryValue): TSelf;
|
|
90
|
+
is(column: string, value: QueryValue): TSelf;
|
|
91
|
+
protected addFilter(column: string, operator: FilterOperator, value: QueryValue): TSelf;
|
|
92
|
+
protected filteredQueryParams(): URLSearchParams;
|
|
93
|
+
}
|
|
94
|
+
export declare class LuxProjectSelectBuilder<T extends Record<string, unknown>, TResult> extends LuxProjectFilterBuilder<TResult, LuxProjectSelectBuilder<T, TResult>> {
|
|
95
|
+
private columns;
|
|
96
|
+
private expectSingle;
|
|
97
|
+
constructor(client: LuxProjectClient, tableName: string, columns: string);
|
|
98
|
+
order(column: string, options?: {
|
|
99
|
+
ascending?: boolean;
|
|
100
|
+
}): this;
|
|
101
|
+
limit(count: number): this;
|
|
102
|
+
range(from: number, to: number): this;
|
|
103
|
+
single(): LuxProjectSelectBuilder<T, T>;
|
|
104
|
+
execute(): Promise<LuxResult<TResult>>;
|
|
105
|
+
}
|
|
106
|
+
export declare class LuxProjectInsertBuilder<TResult> extends LuxProjectThenable<TResult> {
|
|
107
|
+
private client;
|
|
108
|
+
private tableName;
|
|
109
|
+
private rowOrRows;
|
|
110
|
+
constructor(client: LuxProjectClient, tableName: string, rowOrRows: Record<string, QueryValue> | Array<Record<string, QueryValue>>);
|
|
111
|
+
execute(): Promise<LuxResult<TResult>>;
|
|
112
|
+
}
|
|
113
|
+
export declare class LuxProjectMutationBuilder<TResult> extends LuxProjectFilterBuilder<TResult, LuxProjectMutationBuilder<TResult>> {
|
|
114
|
+
private method;
|
|
115
|
+
private body?;
|
|
116
|
+
constructor(client: LuxProjectClient, tableName: string, method: 'PATCH' | 'DELETE', body?: Record<string, QueryValue> | undefined);
|
|
117
|
+
execute(): Promise<LuxResult<TResult>>;
|
|
118
|
+
}
|
|
119
|
+
export declare function createProjectClient(options: LuxProjectOptions): LuxProjectClient;
|
|
120
|
+
export declare function createClient(url: string, key: string, options?: Omit<LuxProjectOptions, 'url' | 'key'>): LuxProjectClient;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type LuxProjectOptions } from './project';
|
|
2
|
+
export interface LuxCookieOptions {
|
|
3
|
+
domain?: string;
|
|
4
|
+
expires?: Date;
|
|
5
|
+
httpOnly?: boolean;
|
|
6
|
+
maxAge?: number;
|
|
7
|
+
path?: string;
|
|
8
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
9
|
+
secure?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface LuxCookieMethods {
|
|
12
|
+
get(name: string): string | null | undefined | Promise<string | null | undefined>;
|
|
13
|
+
set?(name: string, value: string, options?: LuxCookieOptions): void | Promise<void>;
|
|
14
|
+
remove?(name: string, options?: LuxCookieOptions): void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export interface LuxServerClientOptions extends Omit<LuxProjectOptions, 'url' | 'key' | 'auth'> {
|
|
17
|
+
auth?: Omit<NonNullable<LuxProjectOptions['auth']>, 'storage'> & {
|
|
18
|
+
cookieOptions?: LuxCookieOptions;
|
|
19
|
+
};
|
|
20
|
+
cookies: LuxCookieMethods;
|
|
21
|
+
}
|
|
22
|
+
export declare function createServerClient(url: string, key: string, options: LuxServerClientOptions): import("./project").LuxProjectClient;
|
|
@@ -60,7 +60,16 @@ export declare class TableQueryBuilder<T extends TableRow = TableRow> {
|
|
|
60
60
|
select(columns?: string): this;
|
|
61
61
|
single(): this;
|
|
62
62
|
where(field: string, op: TableWhereOp, value: TableWhereValue): this;
|
|
63
|
+
eq(field: string, value: TableWhereValue): this;
|
|
64
|
+
neq(field: string, value: TableWhereValue): this;
|
|
65
|
+
gt(field: string, value: TableWhereValue): this;
|
|
66
|
+
gte(field: string, value: TableWhereValue): this;
|
|
67
|
+
lt(field: string, value: TableWhereValue): this;
|
|
68
|
+
lte(field: string, value: TableWhereValue): this;
|
|
63
69
|
orderBy(field: string, dir?: 'asc' | 'desc'): this;
|
|
70
|
+
order(field: string, options?: {
|
|
71
|
+
ascending?: boolean;
|
|
72
|
+
}): this;
|
|
64
73
|
limit(n: number): this;
|
|
65
74
|
offset(n: number): this;
|
|
66
75
|
join(table: string, alias: string, onLeft: string, onRight: string): this;
|
|
@@ -73,11 +82,11 @@ export declare class TableQueryBuilder<T extends TableRow = TableRow> {
|
|
|
73
82
|
}): this;
|
|
74
83
|
private parseSimilarityPk;
|
|
75
84
|
run(): Promise<LuxResult<T[] | T>>;
|
|
85
|
+
then<TFulfilled = LuxResult<T[] | T>, TRejected = never>(onfulfilled?: ((value: LuxResult<T[] | T>) => TFulfilled | PromiseLike<TFulfilled>) | null, onrejected?: ((reason: unknown) => TRejected | PromiseLike<TRejected>) | null): Promise<TFulfilled | TRejected>;
|
|
76
86
|
insert(data: Record<string, unknown>): Promise<LuxResult<number>>;
|
|
77
87
|
update(id: number | string, data: Record<string, unknown>): Promise<LuxResult<number>>;
|
|
78
|
-
|
|
88
|
+
update(data: Record<string, unknown>): Promise<LuxResult<number>>;
|
|
79
89
|
delete(...ids: Array<number | string>): Promise<LuxResult<number>>;
|
|
80
|
-
deleteWhere(): Promise<LuxResult<number>>;
|
|
81
90
|
subscribe(): TableSubscription<T>;
|
|
82
91
|
}
|
|
83
92
|
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxdb/sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Lux SDK
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"
|
|
3
|
+
"version": "1.4.2",
|
|
4
|
+
"description": "Official Lux TypeScript SDK for app data, auth, tables, vectors, realtime, and Redis-compatible direct access",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js",
|
|
13
|
+
"default": "./dist/esm/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./project": {
|
|
16
|
+
"types": "./dist/types/project.d.ts",
|
|
17
|
+
"import": "./dist/esm/project.js",
|
|
18
|
+
"require": "./dist/cjs/project.js",
|
|
19
|
+
"default": "./dist/esm/project.js"
|
|
20
|
+
},
|
|
21
|
+
"./auth": {
|
|
22
|
+
"types": "./dist/types/auth.d.ts",
|
|
23
|
+
"import": "./dist/esm/auth.js",
|
|
24
|
+
"require": "./dist/cjs/auth.js",
|
|
25
|
+
"default": "./dist/esm/auth.js"
|
|
26
|
+
},
|
|
27
|
+
"./browser": {
|
|
28
|
+
"types": "./dist/types/browser.d.ts",
|
|
29
|
+
"import": "./dist/esm/browser.js",
|
|
30
|
+
"require": "./dist/cjs/browser.js",
|
|
31
|
+
"default": "./dist/esm/browser.js"
|
|
32
|
+
},
|
|
33
|
+
"./ssr": {
|
|
34
|
+
"types": "./dist/types/ssr.d.ts",
|
|
35
|
+
"import": "./dist/esm/ssr.js",
|
|
36
|
+
"require": "./dist/cjs/ssr.js",
|
|
37
|
+
"default": "./dist/esm/ssr.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
7
40
|
"files": ["dist"],
|
|
8
41
|
"scripts": {
|
|
9
|
-
"build": "
|
|
42
|
+
"build": "bun scripts/build.ts",
|
|
43
|
+
"test": "bun test tests",
|
|
10
44
|
"prepublishOnly": "bun run build"
|
|
11
45
|
},
|
|
12
46
|
"dependencies": {
|
|
@@ -25,5 +59,5 @@
|
|
|
25
59
|
"url": "https://github.com/lux-db/lux",
|
|
26
60
|
"directory": "sdk"
|
|
27
61
|
},
|
|
28
|
-
"keywords": ["lux", "
|
|
62
|
+
"keywords": ["lux", "database", "application-database", "auth", "tables", "vectors", "realtime", "redis", "cache", "queues", "timeseries"]
|
|
29
63
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|