@vaiftechnologies/vaif-client 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -13
- package/dist/index.d.cts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +35 -13
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -605,17 +605,19 @@ var VaifRealtime = class {
|
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
607
|
const config = this.client.getConfig();
|
|
608
|
-
|
|
609
|
-
url.searchParams.set("apikey", config.apiKey);
|
|
610
|
-
url.searchParams.set("project", config.projectId);
|
|
611
|
-
const token = this.client.getAccessToken();
|
|
612
|
-
if (token) {
|
|
613
|
-
url.searchParams.set("token", token);
|
|
614
|
-
}
|
|
615
|
-
this.socket = new WebSocket(url.toString());
|
|
608
|
+
this.socket = new WebSocket(config.realtimeUrl);
|
|
616
609
|
this.socket.onopen = () => {
|
|
617
610
|
this.client.debug("Realtime connected");
|
|
618
611
|
this.reconnectAttempts = 0;
|
|
612
|
+
this.send({
|
|
613
|
+
topic: "phoenix",
|
|
614
|
+
event: "auth",
|
|
615
|
+
payload: {
|
|
616
|
+
apikey: config.apiKey,
|
|
617
|
+
project: config.projectId,
|
|
618
|
+
token: this.client.getAccessToken() ?? void 0
|
|
619
|
+
}
|
|
620
|
+
});
|
|
619
621
|
if (options.heartbeat !== false) {
|
|
620
622
|
this.startHeartbeat(options.heartbeatInterval ?? 3e4);
|
|
621
623
|
}
|
|
@@ -2151,11 +2153,18 @@ var VaifSchema = class {
|
|
|
2151
2153
|
* ```
|
|
2152
2154
|
*/
|
|
2153
2155
|
async preview(request) {
|
|
2156
|
+
const body = {
|
|
2157
|
+
...request,
|
|
2158
|
+
definition: {
|
|
2159
|
+
schemaVersion: "1.0",
|
|
2160
|
+
...request.definition
|
|
2161
|
+
}
|
|
2162
|
+
};
|
|
2154
2163
|
const response = await this.client.request(
|
|
2155
2164
|
"/schema-engine/preview",
|
|
2156
2165
|
{
|
|
2157
2166
|
method: "POST",
|
|
2158
|
-
body
|
|
2167
|
+
body
|
|
2159
2168
|
}
|
|
2160
2169
|
);
|
|
2161
2170
|
if (response.error) {
|
|
@@ -2204,11 +2213,18 @@ var VaifSchema = class {
|
|
|
2204
2213
|
* ```
|
|
2205
2214
|
*/
|
|
2206
2215
|
async apply(request) {
|
|
2216
|
+
const body = {
|
|
2217
|
+
...request,
|
|
2218
|
+
definition: {
|
|
2219
|
+
schemaVersion: "1.0",
|
|
2220
|
+
...request.definition
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2207
2223
|
const response = await this.client.request(
|
|
2208
2224
|
"/schema-engine/apply",
|
|
2209
2225
|
{
|
|
2210
2226
|
method: "POST",
|
|
2211
|
-
body
|
|
2227
|
+
body
|
|
2212
2228
|
}
|
|
2213
2229
|
);
|
|
2214
2230
|
if (response.error) {
|
|
@@ -2689,7 +2705,7 @@ var VaifAdmin = class {
|
|
|
2689
2705
|
const response = await fetch(url, {
|
|
2690
2706
|
...options,
|
|
2691
2707
|
headers,
|
|
2692
|
-
credentials: "
|
|
2708
|
+
credentials: "same-origin"
|
|
2693
2709
|
});
|
|
2694
2710
|
if (!response.ok) {
|
|
2695
2711
|
const error = await response.json().catch(() => ({ message: "Request failed" }));
|
|
@@ -3803,10 +3819,16 @@ var VaifClient = class {
|
|
|
3803
3819
|
} catch {
|
|
3804
3820
|
}
|
|
3805
3821
|
}
|
|
3806
|
-
/** Log debug messages */
|
|
3822
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
3807
3823
|
debug(...args) {
|
|
3808
3824
|
if (this.config.debug) {
|
|
3809
|
-
|
|
3825
|
+
const safe = args.map((arg) => {
|
|
3826
|
+
if (arg instanceof Error) return arg.message;
|
|
3827
|
+
if (typeof arg === "string") return arg;
|
|
3828
|
+
if (typeof arg === "number" || typeof arg === "boolean") return arg;
|
|
3829
|
+
return "[object]";
|
|
3830
|
+
});
|
|
3831
|
+
console.log("[VAIF]", ...safe);
|
|
3810
3832
|
}
|
|
3811
3833
|
}
|
|
3812
3834
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -2932,14 +2932,14 @@ interface ColumnDefinition {
|
|
|
2932
2932
|
name: string;
|
|
2933
2933
|
type: string;
|
|
2934
2934
|
nullable?: boolean;
|
|
2935
|
-
default?: string;
|
|
2935
|
+
default?: string | number | boolean;
|
|
2936
2936
|
unique?: boolean;
|
|
2937
2937
|
primaryKey?: boolean;
|
|
2938
2938
|
references?: {
|
|
2939
2939
|
table: string;
|
|
2940
|
-
column
|
|
2941
|
-
onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
|
|
2942
|
-
onUpdate?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
|
|
2940
|
+
column?: string;
|
|
2941
|
+
onDelete?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
|
|
2942
|
+
onUpdate?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
|
|
2943
2943
|
};
|
|
2944
2944
|
}
|
|
2945
2945
|
/**
|
|
@@ -2963,6 +2963,7 @@ interface TableDefinition {
|
|
|
2963
2963
|
* Schema definition containing all tables
|
|
2964
2964
|
*/
|
|
2965
2965
|
interface SchemaDefinition {
|
|
2966
|
+
schemaVersion?: '1.0';
|
|
2966
2967
|
tables: TableDefinition[];
|
|
2967
2968
|
}
|
|
2968
2969
|
/**
|
|
@@ -3035,8 +3036,20 @@ interface SchemaIntrospectResult {
|
|
|
3035
3036
|
nullable: boolean;
|
|
3036
3037
|
default?: string;
|
|
3037
3038
|
primaryKey?: boolean;
|
|
3039
|
+
unique?: boolean;
|
|
3038
3040
|
}>;
|
|
3039
3041
|
indexes: string[];
|
|
3042
|
+
indexDetails?: Array<{
|
|
3043
|
+
name: string;
|
|
3044
|
+
columns: string[];
|
|
3045
|
+
unique: boolean;
|
|
3046
|
+
}>;
|
|
3047
|
+
foreignKeys?: Array<{
|
|
3048
|
+
constraintName: string;
|
|
3049
|
+
columnName: string;
|
|
3050
|
+
refTable: string;
|
|
3051
|
+
refColumn: string;
|
|
3052
|
+
}>;
|
|
3040
3053
|
}>;
|
|
3041
3054
|
}
|
|
3042
3055
|
/**
|
|
@@ -4179,7 +4192,7 @@ declare class VaifClient {
|
|
|
4179
4192
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
4180
4193
|
/** Restore session from storage */
|
|
4181
4194
|
private restoreSession;
|
|
4182
|
-
/** Log debug messages */
|
|
4195
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
4183
4196
|
debug(...args: unknown[]): void;
|
|
4184
4197
|
}
|
|
4185
4198
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2932,14 +2932,14 @@ interface ColumnDefinition {
|
|
|
2932
2932
|
name: string;
|
|
2933
2933
|
type: string;
|
|
2934
2934
|
nullable?: boolean;
|
|
2935
|
-
default?: string;
|
|
2935
|
+
default?: string | number | boolean;
|
|
2936
2936
|
unique?: boolean;
|
|
2937
2937
|
primaryKey?: boolean;
|
|
2938
2938
|
references?: {
|
|
2939
2939
|
table: string;
|
|
2940
|
-
column
|
|
2941
|
-
onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
|
|
2942
|
-
onUpdate?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
|
|
2940
|
+
column?: string;
|
|
2941
|
+
onDelete?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
|
|
2942
|
+
onUpdate?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
|
|
2943
2943
|
};
|
|
2944
2944
|
}
|
|
2945
2945
|
/**
|
|
@@ -2963,6 +2963,7 @@ interface TableDefinition {
|
|
|
2963
2963
|
* Schema definition containing all tables
|
|
2964
2964
|
*/
|
|
2965
2965
|
interface SchemaDefinition {
|
|
2966
|
+
schemaVersion?: '1.0';
|
|
2966
2967
|
tables: TableDefinition[];
|
|
2967
2968
|
}
|
|
2968
2969
|
/**
|
|
@@ -3035,8 +3036,20 @@ interface SchemaIntrospectResult {
|
|
|
3035
3036
|
nullable: boolean;
|
|
3036
3037
|
default?: string;
|
|
3037
3038
|
primaryKey?: boolean;
|
|
3039
|
+
unique?: boolean;
|
|
3038
3040
|
}>;
|
|
3039
3041
|
indexes: string[];
|
|
3042
|
+
indexDetails?: Array<{
|
|
3043
|
+
name: string;
|
|
3044
|
+
columns: string[];
|
|
3045
|
+
unique: boolean;
|
|
3046
|
+
}>;
|
|
3047
|
+
foreignKeys?: Array<{
|
|
3048
|
+
constraintName: string;
|
|
3049
|
+
columnName: string;
|
|
3050
|
+
refTable: string;
|
|
3051
|
+
refColumn: string;
|
|
3052
|
+
}>;
|
|
3040
3053
|
}>;
|
|
3041
3054
|
}
|
|
3042
3055
|
/**
|
|
@@ -4179,7 +4192,7 @@ declare class VaifClient {
|
|
|
4179
4192
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
4180
4193
|
/** Restore session from storage */
|
|
4181
4194
|
private restoreSession;
|
|
4182
|
-
/** Log debug messages */
|
|
4195
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
4183
4196
|
debug(...args: unknown[]): void;
|
|
4184
4197
|
}
|
|
4185
4198
|
|
package/dist/index.js
CHANGED
|
@@ -547,17 +547,19 @@ var VaifRealtime = class {
|
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
549
|
const config = this.client.getConfig();
|
|
550
|
-
|
|
551
|
-
url.searchParams.set("apikey", config.apiKey);
|
|
552
|
-
url.searchParams.set("project", config.projectId);
|
|
553
|
-
const token = this.client.getAccessToken();
|
|
554
|
-
if (token) {
|
|
555
|
-
url.searchParams.set("token", token);
|
|
556
|
-
}
|
|
557
|
-
this.socket = new WebSocket(url.toString());
|
|
550
|
+
this.socket = new WebSocket(config.realtimeUrl);
|
|
558
551
|
this.socket.onopen = () => {
|
|
559
552
|
this.client.debug("Realtime connected");
|
|
560
553
|
this.reconnectAttempts = 0;
|
|
554
|
+
this.send({
|
|
555
|
+
topic: "phoenix",
|
|
556
|
+
event: "auth",
|
|
557
|
+
payload: {
|
|
558
|
+
apikey: config.apiKey,
|
|
559
|
+
project: config.projectId,
|
|
560
|
+
token: this.client.getAccessToken() ?? void 0
|
|
561
|
+
}
|
|
562
|
+
});
|
|
561
563
|
if (options.heartbeat !== false) {
|
|
562
564
|
this.startHeartbeat(options.heartbeatInterval ?? 3e4);
|
|
563
565
|
}
|
|
@@ -2093,11 +2095,18 @@ var VaifSchema = class {
|
|
|
2093
2095
|
* ```
|
|
2094
2096
|
*/
|
|
2095
2097
|
async preview(request) {
|
|
2098
|
+
const body = {
|
|
2099
|
+
...request,
|
|
2100
|
+
definition: {
|
|
2101
|
+
schemaVersion: "1.0",
|
|
2102
|
+
...request.definition
|
|
2103
|
+
}
|
|
2104
|
+
};
|
|
2096
2105
|
const response = await this.client.request(
|
|
2097
2106
|
"/schema-engine/preview",
|
|
2098
2107
|
{
|
|
2099
2108
|
method: "POST",
|
|
2100
|
-
body
|
|
2109
|
+
body
|
|
2101
2110
|
}
|
|
2102
2111
|
);
|
|
2103
2112
|
if (response.error) {
|
|
@@ -2146,11 +2155,18 @@ var VaifSchema = class {
|
|
|
2146
2155
|
* ```
|
|
2147
2156
|
*/
|
|
2148
2157
|
async apply(request) {
|
|
2158
|
+
const body = {
|
|
2159
|
+
...request,
|
|
2160
|
+
definition: {
|
|
2161
|
+
schemaVersion: "1.0",
|
|
2162
|
+
...request.definition
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2149
2165
|
const response = await this.client.request(
|
|
2150
2166
|
"/schema-engine/apply",
|
|
2151
2167
|
{
|
|
2152
2168
|
method: "POST",
|
|
2153
|
-
body
|
|
2169
|
+
body
|
|
2154
2170
|
}
|
|
2155
2171
|
);
|
|
2156
2172
|
if (response.error) {
|
|
@@ -2631,7 +2647,7 @@ var VaifAdmin = class {
|
|
|
2631
2647
|
const response = await fetch(url, {
|
|
2632
2648
|
...options,
|
|
2633
2649
|
headers,
|
|
2634
|
-
credentials: "
|
|
2650
|
+
credentials: "same-origin"
|
|
2635
2651
|
});
|
|
2636
2652
|
if (!response.ok) {
|
|
2637
2653
|
const error = await response.json().catch(() => ({ message: "Request failed" }));
|
|
@@ -3745,10 +3761,16 @@ var VaifClient = class {
|
|
|
3745
3761
|
} catch {
|
|
3746
3762
|
}
|
|
3747
3763
|
}
|
|
3748
|
-
/** Log debug messages */
|
|
3764
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
3749
3765
|
debug(...args) {
|
|
3750
3766
|
if (this.config.debug) {
|
|
3751
|
-
|
|
3767
|
+
const safe = args.map((arg) => {
|
|
3768
|
+
if (arg instanceof Error) return arg.message;
|
|
3769
|
+
if (typeof arg === "string") return arg;
|
|
3770
|
+
if (typeof arg === "number" || typeof arg === "boolean") return arg;
|
|
3771
|
+
return "[object]";
|
|
3772
|
+
});
|
|
3773
|
+
console.log("[VAIF]", ...safe);
|
|
3752
3774
|
}
|
|
3753
3775
|
}
|
|
3754
3776
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaiftechnologies/vaif-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Official VAIF Studio client library for JavaScript and TypeScript",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
22
22
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
23
23
|
"lint": "tsc --noEmit",
|
|
24
|
-
"test": "vitest"
|
|
24
|
+
"test": "vitest",
|
|
25
|
+
"prepublishOnly": "pnpm build"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
27
28
|
"vaif",
|