zubbl-sdk 1.1.6 → 1.1.8
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/zubbl-sdk.cjs.js +26 -3
- package/dist/zubbl-sdk.esm.js +26 -3
- package/dist/zubbl-sdk.umd.js +26 -3
- package/package.json +1 -1
package/dist/zubbl-sdk.cjs.js
CHANGED
|
@@ -37,6 +37,7 @@ function init({
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Identify a user by email (and optional name).
|
|
40
|
+
* Backend will return or generate a valid UUID for external_user_id.
|
|
40
41
|
*/
|
|
41
42
|
async function identifyUser({ email, name }) {
|
|
42
43
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
@@ -60,18 +61,37 @@ async function identifyUser({ email, name }) {
|
|
|
60
61
|
{ email, name },
|
|
61
62
|
{ headers }
|
|
62
63
|
);
|
|
64
|
+
|
|
65
|
+
const { external_user_id } = response.data;
|
|
66
|
+
if (!external_user_id) {
|
|
67
|
+
throw new Error("Backend did not return external_user_id");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ✅ Ensure UUID format
|
|
71
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
72
|
+
if (!uuidRegex.test(external_user_id)) {
|
|
73
|
+
throw new Error(`Invalid external_user_id received: ${external_user_id}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
63
76
|
return response.data;
|
|
64
77
|
}
|
|
65
78
|
|
|
66
79
|
/**
|
|
67
|
-
*
|
|
80
|
+
* Fetch effective tiles for a given user.
|
|
81
|
+
* Requires valid external_user_id (UUID).
|
|
68
82
|
*/
|
|
69
|
-
async function getTiles({ external_user_id }) {
|
|
83
|
+
async function getTiles({ external_user_id, app_id = null }) {
|
|
70
84
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
71
85
|
throw new Error("Zubbl SDK not initialized");
|
|
72
86
|
}
|
|
73
87
|
if (!external_user_id) throw new Error("external_user_id is required");
|
|
74
88
|
|
|
89
|
+
// ✅ Validate UUID format
|
|
90
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
91
|
+
if (!uuidRegex.test(external_user_id)) {
|
|
92
|
+
throw new Error(`Invalid external_user_id: ${external_user_id}. Must be UUID.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
75
95
|
const headers = {
|
|
76
96
|
Authorization: `Bearer ${config.apiKey}`,
|
|
77
97
|
"X-Tenant-Id": config.tenantId,
|
|
@@ -83,8 +103,11 @@ async function getTiles({ external_user_id }) {
|
|
|
83
103
|
headers["X-Zubbl-Internal-Call"] = "true";
|
|
84
104
|
}
|
|
85
105
|
|
|
106
|
+
const params = new URLSearchParams({ external_user_id });
|
|
107
|
+
params.set("app_id", app_id || config.appId);
|
|
108
|
+
|
|
86
109
|
const response = await axios.get(
|
|
87
|
-
`${config.baseUrl}/
|
|
110
|
+
`${config.baseUrl.replace(/\/$/, "")}/tiles/effective?${params.toString()}`,
|
|
88
111
|
{ headers }
|
|
89
112
|
);
|
|
90
113
|
return response.data;
|
package/dist/zubbl-sdk.esm.js
CHANGED
|
@@ -35,6 +35,7 @@ function init({
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Identify a user by email (and optional name).
|
|
38
|
+
* Backend will return or generate a valid UUID for external_user_id.
|
|
38
39
|
*/
|
|
39
40
|
async function identifyUser({ email, name }) {
|
|
40
41
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
@@ -58,18 +59,37 @@ async function identifyUser({ email, name }) {
|
|
|
58
59
|
{ email, name },
|
|
59
60
|
{ headers }
|
|
60
61
|
);
|
|
62
|
+
|
|
63
|
+
const { external_user_id } = response.data;
|
|
64
|
+
if (!external_user_id) {
|
|
65
|
+
throw new Error("Backend did not return external_user_id");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ✅ Ensure UUID format
|
|
69
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
70
|
+
if (!uuidRegex.test(external_user_id)) {
|
|
71
|
+
throw new Error(`Invalid external_user_id received: ${external_user_id}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
61
74
|
return response.data;
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
/**
|
|
65
|
-
*
|
|
78
|
+
* Fetch effective tiles for a given user.
|
|
79
|
+
* Requires valid external_user_id (UUID).
|
|
66
80
|
*/
|
|
67
|
-
async function getTiles({ external_user_id }) {
|
|
81
|
+
async function getTiles({ external_user_id, app_id = null }) {
|
|
68
82
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
69
83
|
throw new Error("Zubbl SDK not initialized");
|
|
70
84
|
}
|
|
71
85
|
if (!external_user_id) throw new Error("external_user_id is required");
|
|
72
86
|
|
|
87
|
+
// ✅ Validate UUID format
|
|
88
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
89
|
+
if (!uuidRegex.test(external_user_id)) {
|
|
90
|
+
throw new Error(`Invalid external_user_id: ${external_user_id}. Must be UUID.`);
|
|
91
|
+
}
|
|
92
|
+
|
|
73
93
|
const headers = {
|
|
74
94
|
Authorization: `Bearer ${config.apiKey}`,
|
|
75
95
|
"X-Tenant-Id": config.tenantId,
|
|
@@ -81,8 +101,11 @@ async function getTiles({ external_user_id }) {
|
|
|
81
101
|
headers["X-Zubbl-Internal-Call"] = "true";
|
|
82
102
|
}
|
|
83
103
|
|
|
104
|
+
const params = new URLSearchParams({ external_user_id });
|
|
105
|
+
params.set("app_id", app_id || config.appId);
|
|
106
|
+
|
|
84
107
|
const response = await axios.get(
|
|
85
|
-
`${config.baseUrl}/
|
|
108
|
+
`${config.baseUrl.replace(/\/$/, "")}/tiles/effective?${params.toString()}`,
|
|
86
109
|
{ headers }
|
|
87
110
|
);
|
|
88
111
|
return response.data;
|
package/dist/zubbl-sdk.umd.js
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Identify a user by email (and optional name).
|
|
42
|
+
* Backend will return or generate a valid UUID for external_user_id.
|
|
42
43
|
*/
|
|
43
44
|
async function identifyUser({ email, name }) {
|
|
44
45
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
@@ -62,18 +63,37 @@
|
|
|
62
63
|
{ email, name },
|
|
63
64
|
{ headers }
|
|
64
65
|
);
|
|
66
|
+
|
|
67
|
+
const { external_user_id } = response.data;
|
|
68
|
+
if (!external_user_id) {
|
|
69
|
+
throw new Error("Backend did not return external_user_id");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ✅ Ensure UUID format
|
|
73
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
74
|
+
if (!uuidRegex.test(external_user_id)) {
|
|
75
|
+
throw new Error(`Invalid external_user_id received: ${external_user_id}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
65
78
|
return response.data;
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
/**
|
|
69
|
-
*
|
|
82
|
+
* Fetch effective tiles for a given user.
|
|
83
|
+
* Requires valid external_user_id (UUID).
|
|
70
84
|
*/
|
|
71
|
-
async function getTiles({ external_user_id }) {
|
|
85
|
+
async function getTiles({ external_user_id, app_id = null }) {
|
|
72
86
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
73
87
|
throw new Error("Zubbl SDK not initialized");
|
|
74
88
|
}
|
|
75
89
|
if (!external_user_id) throw new Error("external_user_id is required");
|
|
76
90
|
|
|
91
|
+
// ✅ Validate UUID format
|
|
92
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
93
|
+
if (!uuidRegex.test(external_user_id)) {
|
|
94
|
+
throw new Error(`Invalid external_user_id: ${external_user_id}. Must be UUID.`);
|
|
95
|
+
}
|
|
96
|
+
|
|
77
97
|
const headers = {
|
|
78
98
|
Authorization: `Bearer ${config.apiKey}`,
|
|
79
99
|
"X-Tenant-Id": config.tenantId,
|
|
@@ -85,8 +105,11 @@
|
|
|
85
105
|
headers["X-Zubbl-Internal-Call"] = "true";
|
|
86
106
|
}
|
|
87
107
|
|
|
108
|
+
const params = new URLSearchParams({ external_user_id });
|
|
109
|
+
params.set("app_id", app_id || config.appId);
|
|
110
|
+
|
|
88
111
|
const response = await axios.get(
|
|
89
|
-
`${config.baseUrl}/
|
|
112
|
+
`${config.baseUrl.replace(/\/$/, "")}/tiles/effective?${params.toString()}`,
|
|
90
113
|
{ headers }
|
|
91
114
|
);
|
|
92
115
|
return response.data;
|