@scalemule/sdk 0.0.27 → 0.0.29
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.d.mts +236 -1
- package/dist/index.d.ts +236 -1
- package/dist/index.js +408 -14
- package/dist/index.mjs +397 -14
- package/package.json +3 -6
package/dist/index.mjs
CHANGED
|
@@ -107,6 +107,7 @@ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
|
|
|
107
107
|
var ANONYMOUS_ID_STORAGE_KEY = "scalemule_anonymous_id";
|
|
108
108
|
var SESSION_POOL_KEY = "scalemule_session_pool";
|
|
109
109
|
var ACTIVE_ACCOUNT_KEY = "scalemule_active_account";
|
|
110
|
+
var KNOWN_ACCOUNTS_KEY = "scalemule_known_accounts";
|
|
110
111
|
var GATEWAY_URLS = {
|
|
111
112
|
dev: "https://api-dev.scalemule.com",
|
|
112
113
|
prod: "https://api.scalemule.com"
|
|
@@ -156,6 +157,54 @@ function statusToErrorCode(status) {
|
|
|
156
157
|
return status >= 500 ? "internal_error" : `http_${status}`;
|
|
157
158
|
}
|
|
158
159
|
}
|
|
160
|
+
var MAX_KNOWN_ACCOUNTS = 10;
|
|
161
|
+
function maskEmail(email) {
|
|
162
|
+
const parts = email.split("@");
|
|
163
|
+
const local = parts[0] ?? "";
|
|
164
|
+
const domain = parts[1];
|
|
165
|
+
if (!domain) return "***@***.***";
|
|
166
|
+
const tldDot = domain.lastIndexOf(".");
|
|
167
|
+
const tld = tldDot > 0 ? domain.slice(tldDot) : "";
|
|
168
|
+
const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
|
|
169
|
+
return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
|
|
170
|
+
}
|
|
171
|
+
function stableColorIndex(userId) {
|
|
172
|
+
let hash = 0;
|
|
173
|
+
for (let i = 0; i < userId.length; i++) {
|
|
174
|
+
hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
|
|
175
|
+
}
|
|
176
|
+
return Math.abs(hash) % 8;
|
|
177
|
+
}
|
|
178
|
+
function applyPrivacy(account, privacy) {
|
|
179
|
+
switch (privacy) {
|
|
180
|
+
case "full":
|
|
181
|
+
return {
|
|
182
|
+
userId: account.userId,
|
|
183
|
+
email: account.email,
|
|
184
|
+
fullName: account.fullName,
|
|
185
|
+
avatarUrl: account.avatarUrl,
|
|
186
|
+
provider: account.provider,
|
|
187
|
+
lastActiveAt: account.lastActiveAt
|
|
188
|
+
};
|
|
189
|
+
case "masked":
|
|
190
|
+
return {
|
|
191
|
+
userId: account.userId,
|
|
192
|
+
email: account.email ? maskEmail(account.email) : void 0,
|
|
193
|
+
fullName: account.fullName && account.fullName.length > 0 ? `${account.fullName[0].toUpperCase()}.` : void 0,
|
|
194
|
+
provider: account.provider,
|
|
195
|
+
lastActiveAt: account.lastActiveAt,
|
|
196
|
+
colorIndex: stableColorIndex(account.userId)
|
|
197
|
+
};
|
|
198
|
+
case "minimal":
|
|
199
|
+
return {
|
|
200
|
+
userId: account.userId,
|
|
201
|
+
provider: account.provider,
|
|
202
|
+
lastActiveAt: account.lastActiveAt,
|
|
203
|
+
displayLabel: "Account",
|
|
204
|
+
colorIndex: stableColorIndex(account.userId)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
159
208
|
function createDefaultStorage() {
|
|
160
209
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
161
210
|
return {
|
|
@@ -302,6 +351,7 @@ var ScaleMuleClient = class {
|
|
|
302
351
|
this.workspaceId = null;
|
|
303
352
|
this.anonymousId = null;
|
|
304
353
|
this.sessionPool = /* @__PURE__ */ new Map();
|
|
354
|
+
this.knownAccounts = /* @__PURE__ */ new Map();
|
|
305
355
|
this.apiKey = config.apiKey;
|
|
306
356
|
this.applicationId = config.applicationId || null;
|
|
307
357
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
@@ -318,6 +368,8 @@ var ScaleMuleClient = class {
|
|
|
318
368
|
this.offlineQueue.setOnlineCallback(() => this.syncOfflineQueue());
|
|
319
369
|
}
|
|
320
370
|
this.multiSessionEnabled = config.enableMultiSession || false;
|
|
371
|
+
this.accountSwitcherEnabled = config.enableAccountSwitcher || false;
|
|
372
|
+
this.accountSwitcherPrivacy = config.accountSwitcherPrivacy || "full";
|
|
321
373
|
}
|
|
322
374
|
// --------------------------------------------------------------------------
|
|
323
375
|
// Session Management
|
|
@@ -360,6 +412,27 @@ var ScaleMuleClient = class {
|
|
|
360
412
|
this.userId = activeId;
|
|
361
413
|
}
|
|
362
414
|
}
|
|
415
|
+
if (this.accountSwitcherEnabled) {
|
|
416
|
+
const knownJson = await this.storage.getItem(KNOWN_ACCOUNTS_KEY);
|
|
417
|
+
if (knownJson) {
|
|
418
|
+
try {
|
|
419
|
+
const entries = JSON.parse(knownJson);
|
|
420
|
+
this.knownAccounts = new Map(Object.entries(entries));
|
|
421
|
+
let changed = false;
|
|
422
|
+
for (const [userId2, entry] of this.knownAccounts) {
|
|
423
|
+
const normalized = applyPrivacy(entry, this.accountSwitcherPrivacy);
|
|
424
|
+
if (JSON.stringify(normalized) !== JSON.stringify(entry)) {
|
|
425
|
+
this.knownAccounts.set(userId2, normalized);
|
|
426
|
+
changed = true;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (changed) {
|
|
430
|
+
await this.persistKnownAccounts();
|
|
431
|
+
}
|
|
432
|
+
} catch {
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
363
436
|
if (this.debug)
|
|
364
437
|
console.log(
|
|
365
438
|
"[ScaleMule] Initialized, session:",
|
|
@@ -367,7 +440,9 @@ var ScaleMuleClient = class {
|
|
|
367
440
|
"anonymousId:",
|
|
368
441
|
anonId,
|
|
369
442
|
"poolSize:",
|
|
370
|
-
this.sessionPool.size
|
|
443
|
+
this.sessionPool.size,
|
|
444
|
+
"knownAccounts:",
|
|
445
|
+
this.knownAccounts.size
|
|
371
446
|
);
|
|
372
447
|
}
|
|
373
448
|
async setSession(token, userId) {
|
|
@@ -491,6 +566,57 @@ var ScaleMuleClient = class {
|
|
|
491
566
|
}
|
|
492
567
|
await this.storage.setItem(SESSION_POOL_KEY, JSON.stringify(obj));
|
|
493
568
|
}
|
|
569
|
+
// --------------------------------------------------------------------------
|
|
570
|
+
// Account Switcher (Secure — metadata only, no tokens)
|
|
571
|
+
// --------------------------------------------------------------------------
|
|
572
|
+
isAccountSwitcherEnabled() {
|
|
573
|
+
return this.accountSwitcherEnabled;
|
|
574
|
+
}
|
|
575
|
+
getAccountSwitcherPrivacy() {
|
|
576
|
+
return this.accountSwitcherPrivacy;
|
|
577
|
+
}
|
|
578
|
+
/** Get all known accounts that have logged in on this device (privacy-transformed) */
|
|
579
|
+
getKnownAccounts() {
|
|
580
|
+
return Array.from(this.knownAccounts.values());
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Record an account as "known" on this device.
|
|
584
|
+
* Applies privacy transforms before storing — full email is never persisted
|
|
585
|
+
* in masked/minimal modes. Evicts oldest accounts if over the cap.
|
|
586
|
+
* Called automatically after successful login/register when account switcher is enabled.
|
|
587
|
+
*/
|
|
588
|
+
async addKnownAccount(account) {
|
|
589
|
+
const display = applyPrivacy(account, this.accountSwitcherPrivacy);
|
|
590
|
+
this.knownAccounts.set(account.userId, display);
|
|
591
|
+
if (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS) {
|
|
592
|
+
const sorted = Array.from(this.knownAccounts.entries()).sort(
|
|
593
|
+
(a, b) => (a[1].lastActiveAt || "").localeCompare(b[1].lastActiveAt || "")
|
|
594
|
+
);
|
|
595
|
+
while (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS && sorted.length > 0) {
|
|
596
|
+
const oldest = sorted.shift();
|
|
597
|
+
this.knownAccounts.delete(oldest[0]);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
await this.persistKnownAccounts();
|
|
601
|
+
}
|
|
602
|
+
/** Remove a specific account from the known accounts list ("forget this account") */
|
|
603
|
+
async removeKnownAccount(userId) {
|
|
604
|
+
this.knownAccounts.delete(userId);
|
|
605
|
+
await this.persistKnownAccounts();
|
|
606
|
+
}
|
|
607
|
+
/** Clear all known accounts ("forget all accounts on this device") */
|
|
608
|
+
async clearKnownAccounts() {
|
|
609
|
+
this.knownAccounts.clear();
|
|
610
|
+
await this.storage.removeItem(KNOWN_ACCOUNTS_KEY);
|
|
611
|
+
}
|
|
612
|
+
/** Persist known accounts to storage */
|
|
613
|
+
async persistKnownAccounts() {
|
|
614
|
+
const obj = {};
|
|
615
|
+
for (const [k, v] of this.knownAccounts) {
|
|
616
|
+
obj[k] = v;
|
|
617
|
+
}
|
|
618
|
+
await this.storage.setItem(KNOWN_ACCOUNTS_KEY, JSON.stringify(obj));
|
|
619
|
+
}
|
|
494
620
|
getBaseUrl() {
|
|
495
621
|
return this.baseUrl;
|
|
496
622
|
}
|
|
@@ -985,18 +1111,138 @@ function asString(parent, key) {
|
|
|
985
1111
|
return typeof value === "string" ? value : void 0;
|
|
986
1112
|
}
|
|
987
1113
|
|
|
988
|
-
//
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1114
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1115
|
+
var PHONE_COUNTRIES = [
|
|
1116
|
+
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1117
|
+
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
1118
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44" },
|
|
1119
|
+
{ code: "AU", name: "Australia", dialCode: "+61" },
|
|
1120
|
+
{ code: "DE", name: "Germany", dialCode: "+49" },
|
|
1121
|
+
{ code: "FR", name: "France", dialCode: "+33" },
|
|
1122
|
+
{ code: "IT", name: "Italy", dialCode: "+39" },
|
|
1123
|
+
{ code: "ES", name: "Spain", dialCode: "+34" },
|
|
1124
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31" },
|
|
1125
|
+
{ code: "BE", name: "Belgium", dialCode: "+32" },
|
|
1126
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41" },
|
|
1127
|
+
{ code: "AT", name: "Austria", dialCode: "+43" },
|
|
1128
|
+
{ code: "SE", name: "Sweden", dialCode: "+46" },
|
|
1129
|
+
{ code: "NO", name: "Norway", dialCode: "+47" },
|
|
1130
|
+
{ code: "DK", name: "Denmark", dialCode: "+45" },
|
|
1131
|
+
{ code: "FI", name: "Finland", dialCode: "+358" },
|
|
1132
|
+
{ code: "IE", name: "Ireland", dialCode: "+353" },
|
|
1133
|
+
{ code: "PT", name: "Portugal", dialCode: "+351" },
|
|
1134
|
+
{ code: "PL", name: "Poland", dialCode: "+48" },
|
|
1135
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420" },
|
|
1136
|
+
{ code: "GR", name: "Greece", dialCode: "+30" },
|
|
1137
|
+
{ code: "RU", name: "Russia", dialCode: "+7" },
|
|
1138
|
+
{ code: "JP", name: "Japan", dialCode: "+81" },
|
|
1139
|
+
{ code: "KR", name: "South Korea", dialCode: "+82" },
|
|
1140
|
+
{ code: "CN", name: "China", dialCode: "+86" },
|
|
1141
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852" },
|
|
1142
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886" },
|
|
1143
|
+
{ code: "SG", name: "Singapore", dialCode: "+65" },
|
|
1144
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60" },
|
|
1145
|
+
{ code: "TH", name: "Thailand", dialCode: "+66" },
|
|
1146
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84" },
|
|
1147
|
+
{ code: "PH", name: "Philippines", dialCode: "+63" },
|
|
1148
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62" },
|
|
1149
|
+
{ code: "IN", name: "India", dialCode: "+91" },
|
|
1150
|
+
{ code: "PK", name: "Pakistan", dialCode: "+92" },
|
|
1151
|
+
{ code: "BD", name: "Bangladesh", dialCode: "+880" },
|
|
1152
|
+
{ code: "AE", name: "UAE", dialCode: "+971" },
|
|
1153
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966" },
|
|
1154
|
+
{ code: "IL", name: "Israel", dialCode: "+972" },
|
|
1155
|
+
{ code: "TR", name: "Turkey", dialCode: "+90" },
|
|
1156
|
+
{ code: "EG", name: "Egypt", dialCode: "+20" },
|
|
1157
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27" },
|
|
1158
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234" },
|
|
1159
|
+
{ code: "KE", name: "Kenya", dialCode: "+254" },
|
|
1160
|
+
{ code: "BR", name: "Brazil", dialCode: "+55" },
|
|
1161
|
+
{ code: "MX", name: "Mexico", dialCode: "+52" },
|
|
1162
|
+
{ code: "AR", name: "Argentina", dialCode: "+54" },
|
|
1163
|
+
{ code: "CL", name: "Chile", dialCode: "+56" },
|
|
1164
|
+
{ code: "CO", name: "Colombia", dialCode: "+57" },
|
|
1165
|
+
{ code: "PE", name: "Peru", dialCode: "+51" },
|
|
1166
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64" }
|
|
1167
|
+
];
|
|
1168
|
+
var E164_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
1169
|
+
function isValidE164Phone(input) {
|
|
1170
|
+
return E164_REGEX.test(input);
|
|
1171
|
+
}
|
|
1172
|
+
function normalizePhoneNumber(input) {
|
|
1173
|
+
if (typeof input !== "string") return "";
|
|
1174
|
+
const trimmed = input.trim();
|
|
1175
|
+
if (!trimmed) return "";
|
|
1176
|
+
const digitsOnly = trimmed.replace(/\D/g, "");
|
|
1177
|
+
if (!digitsOnly) return "";
|
|
1178
|
+
if (trimmed.startsWith("+")) {
|
|
1179
|
+
return `+${digitsOnly}`;
|
|
1180
|
+
}
|
|
1181
|
+
if (trimmed.startsWith("00") && digitsOnly.length > 2) {
|
|
1182
|
+
return `+${digitsOnly.slice(2)}`;
|
|
1183
|
+
}
|
|
1184
|
+
return `+${digitsOnly}`;
|
|
1185
|
+
}
|
|
1186
|
+
function normalizeAndValidatePhone(input) {
|
|
1187
|
+
const normalized = normalizePhoneNumber(input);
|
|
1188
|
+
if (!normalized) {
|
|
1189
|
+
return {
|
|
1190
|
+
input,
|
|
1191
|
+
normalized: null,
|
|
1192
|
+
valid: false,
|
|
1193
|
+
error: "Phone number is required"
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
if (!E164_REGEX.test(normalized)) {
|
|
1197
|
+
return {
|
|
1198
|
+
input,
|
|
1199
|
+
normalized,
|
|
1200
|
+
valid: false,
|
|
1201
|
+
error: "Phone number must be in E.164 format (+[country code][number])"
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
return {
|
|
1205
|
+
input,
|
|
1206
|
+
normalized,
|
|
1207
|
+
valid: true,
|
|
1208
|
+
error: null
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
function composePhoneNumber(countryDialCode, localNumber) {
|
|
1212
|
+
const normalizedDial = normalizePhoneNumber(countryDialCode);
|
|
1213
|
+
if (!normalizedDial) return "";
|
|
1214
|
+
const localDigits = typeof localNumber === "string" ? localNumber.replace(/\D/g, "") : "";
|
|
1215
|
+
if (!localDigits) return "";
|
|
1216
|
+
return `${normalizedDial}${localDigits}`;
|
|
1217
|
+
}
|
|
1218
|
+
function findPhoneCountryByCode(code) {
|
|
1219
|
+
if (!code) return void 0;
|
|
1220
|
+
const upperCode = code.toUpperCase();
|
|
1221
|
+
return PHONE_COUNTRIES.find((country) => country.code === upperCode);
|
|
1222
|
+
}
|
|
1223
|
+
function findPhoneCountryByDialCode(dialCode) {
|
|
1224
|
+
if (!dialCode) return void 0;
|
|
1225
|
+
const normalized = dialCode.startsWith("+") ? dialCode : `+${dialCode}`;
|
|
1226
|
+
return PHONE_COUNTRIES.find((country) => country.dialCode === normalized);
|
|
1227
|
+
}
|
|
1228
|
+
var DIAL_CODES_DESC = [...PHONE_COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
1229
|
+
function detectCountryFromE164(e164) {
|
|
1230
|
+
if (!e164 || !e164.startsWith("+")) return null;
|
|
1231
|
+
const normalized = "+" + e164.slice(1).replace(/\D/g, "");
|
|
1232
|
+
for (const country of DIAL_CODES_DESC) {
|
|
1233
|
+
const prefix = country.dialCode;
|
|
1234
|
+
if (normalized.startsWith(prefix)) {
|
|
1235
|
+
const local = normalized.slice(prefix.length);
|
|
1236
|
+
if (local.length > 0) {
|
|
1237
|
+
return { country, local };
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
function countryFlag(code) {
|
|
1244
|
+
return [...code.toUpperCase()].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
|
|
1245
|
+
}
|
|
1000
1246
|
|
|
1001
1247
|
// src/services/auth.ts
|
|
1002
1248
|
function collectDeviceFingerprint() {
|
|
@@ -1127,6 +1373,16 @@ var AuthService = class extends ServiceModule {
|
|
|
1127
1373
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1128
1374
|
});
|
|
1129
1375
|
}
|
|
1376
|
+
if (result.data && this.client.isAccountSwitcherEnabled()) {
|
|
1377
|
+
await this.client.addKnownAccount({
|
|
1378
|
+
userId: result.data.user.id,
|
|
1379
|
+
email: result.data.user.email,
|
|
1380
|
+
fullName: result.data.user.full_name,
|
|
1381
|
+
avatarUrl: result.data.user.avatar_url,
|
|
1382
|
+
provider: "email",
|
|
1383
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1130
1386
|
return result;
|
|
1131
1387
|
}
|
|
1132
1388
|
async login(data, options) {
|
|
@@ -1147,6 +1403,16 @@ var AuthService = class extends ServiceModule {
|
|
|
1147
1403
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1148
1404
|
});
|
|
1149
1405
|
}
|
|
1406
|
+
if (result.data && this.client.isAccountSwitcherEnabled()) {
|
|
1407
|
+
await this.client.addKnownAccount({
|
|
1408
|
+
userId: result.data.user.id,
|
|
1409
|
+
email: result.data.user.email,
|
|
1410
|
+
fullName: result.data.user.full_name,
|
|
1411
|
+
avatarUrl: result.data.user.avatar_url,
|
|
1412
|
+
provider: "email",
|
|
1413
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1150
1416
|
return result;
|
|
1151
1417
|
}
|
|
1152
1418
|
async logout(options) {
|
|
@@ -1288,7 +1554,18 @@ var AuthService = class extends ServiceModule {
|
|
|
1288
1554
|
}
|
|
1289
1555
|
async handleOAuthCallback(data, options) {
|
|
1290
1556
|
const { provider, ...rest } = data;
|
|
1291
|
-
|
|
1557
|
+
const result = await this._get(this.withQuery(`/oauth/${provider}/callback`, rest), options);
|
|
1558
|
+
if (result.data && this.client.isAccountSwitcherEnabled()) {
|
|
1559
|
+
await this.client.addKnownAccount({
|
|
1560
|
+
userId: result.data.user.id,
|
|
1561
|
+
email: result.data.user.email,
|
|
1562
|
+
fullName: result.data.user.full_name,
|
|
1563
|
+
avatarUrl: result.data.user.avatar_url,
|
|
1564
|
+
provider,
|
|
1565
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
return result;
|
|
1292
1569
|
}
|
|
1293
1570
|
async listOAuthProviders(options) {
|
|
1294
1571
|
return this._get("/oauth/providers", options);
|
|
@@ -5528,6 +5805,73 @@ var FlagContentService = class extends ServiceModule {
|
|
|
5528
5805
|
}
|
|
5529
5806
|
};
|
|
5530
5807
|
|
|
5808
|
+
// src/services/creator-maker.ts
|
|
5809
|
+
var CreatorMakerService = class extends ServiceModule {
|
|
5810
|
+
constructor() {
|
|
5811
|
+
super(...arguments);
|
|
5812
|
+
this.basePath = "/v1/creator-maker";
|
|
5813
|
+
}
|
|
5814
|
+
/** Submit a generation job. */
|
|
5815
|
+
async generate(data, options) {
|
|
5816
|
+
return this.post("/jobs", data, options);
|
|
5817
|
+
}
|
|
5818
|
+
/** Get a generation job by ID. */
|
|
5819
|
+
async getJob(jobId, options) {
|
|
5820
|
+
return this._get(`/jobs/${jobId}`, options);
|
|
5821
|
+
}
|
|
5822
|
+
/** Long-poll for job completion (server holds up to 30s). */
|
|
5823
|
+
async pollJob(jobId, options) {
|
|
5824
|
+
return this._get(`/jobs/${jobId}/poll`, {
|
|
5825
|
+
...options,
|
|
5826
|
+
timeout: 35e3
|
|
5827
|
+
});
|
|
5828
|
+
}
|
|
5829
|
+
/** List the current user's generation jobs. */
|
|
5830
|
+
async listJobs(params, options) {
|
|
5831
|
+
return this._list("/jobs", params, options);
|
|
5832
|
+
}
|
|
5833
|
+
/** Cancel a pending or queued job. */
|
|
5834
|
+
async cancelJob(jobId, options) {
|
|
5835
|
+
return this.post(`/jobs/${jobId}/cancel`, void 0, options);
|
|
5836
|
+
}
|
|
5837
|
+
/** Retry a failed job. */
|
|
5838
|
+
async retryJob(jobId, options) {
|
|
5839
|
+
return this.post(`/jobs/${jobId}/retry`, void 0, options);
|
|
5840
|
+
}
|
|
5841
|
+
/** Generate variations of a completed job. */
|
|
5842
|
+
async generateVariations(jobId, options) {
|
|
5843
|
+
return this.post(`/jobs/${jobId}/variations`, void 0, options);
|
|
5844
|
+
}
|
|
5845
|
+
/** List available style presets, optionally filtered by mode. */
|
|
5846
|
+
async listPresets(params, options) {
|
|
5847
|
+
return this._get(this.withQuery("/presets", params), options);
|
|
5848
|
+
}
|
|
5849
|
+
/** Get a style preset by slug. */
|
|
5850
|
+
async getPreset(slug, options) {
|
|
5851
|
+
return this._get(`/presets/${slug}`, options);
|
|
5852
|
+
}
|
|
5853
|
+
/** Create a project. */
|
|
5854
|
+
async createProject(data, options) {
|
|
5855
|
+
return this.post("/projects", data, options);
|
|
5856
|
+
}
|
|
5857
|
+
/** List the current user's projects. */
|
|
5858
|
+
async listProjects(params, options) {
|
|
5859
|
+
return this._list("/projects", params, options);
|
|
5860
|
+
}
|
|
5861
|
+
/** Get generation usage and credit balance. */
|
|
5862
|
+
async getUsage(options) {
|
|
5863
|
+
return this._get("/usage", options);
|
|
5864
|
+
}
|
|
5865
|
+
/** Get a generation output by ID. */
|
|
5866
|
+
async getOutput(outputId, options) {
|
|
5867
|
+
return this._get(`/outputs/${outputId}`, options);
|
|
5868
|
+
}
|
|
5869
|
+
/** Get a download URL for a generation output. */
|
|
5870
|
+
async getDownloadUrl(outputId, options) {
|
|
5871
|
+
return this._get(`/outputs/${outputId}/download`, options);
|
|
5872
|
+
}
|
|
5873
|
+
};
|
|
5874
|
+
|
|
5531
5875
|
// src/services/agent-auth.ts
|
|
5532
5876
|
var AgentAuthService = class extends ServiceModule {
|
|
5533
5877
|
constructor() {
|
|
@@ -5734,6 +6078,13 @@ var AgentProjectsService = class extends ServiceModule {
|
|
|
5734
6078
|
options
|
|
5735
6079
|
);
|
|
5736
6080
|
}
|
|
6081
|
+
async startTask(taskId, agentId, applicationId, options) {
|
|
6082
|
+
return this.post(
|
|
6083
|
+
this.withAppId(`/tasks/${taskId}/start`, applicationId),
|
|
6084
|
+
{ agent_id: agentId },
|
|
6085
|
+
options
|
|
6086
|
+
);
|
|
6087
|
+
}
|
|
5737
6088
|
async submit(taskId, data, applicationId, options) {
|
|
5738
6089
|
return this.post(this.withAppId(`/tasks/${taskId}/submit`, applicationId), data, options);
|
|
5739
6090
|
}
|
|
@@ -6040,6 +6391,7 @@ var ScaleMule = class {
|
|
|
6040
6391
|
this.functions = new FunctionsService(this._client);
|
|
6041
6392
|
this.photo = new PhotoService(this._client);
|
|
6042
6393
|
this.flagContent = new FlagContentService(this._client);
|
|
6394
|
+
this.creatorMaker = new CreatorMakerService(this._client);
|
|
6043
6395
|
this.compliance = new ComplianceService(this._client);
|
|
6044
6396
|
this.orchestrator = new OrchestratorService(this._client);
|
|
6045
6397
|
this.agentAuth = new AgentAuthService(this._client);
|
|
@@ -6119,6 +6471,36 @@ var ScaleMule = class {
|
|
|
6119
6471
|
async clearAllAccounts() {
|
|
6120
6472
|
return this._client.clearAllAccounts();
|
|
6121
6473
|
}
|
|
6474
|
+
// --------------------------------------------------------------------------
|
|
6475
|
+
// Account Switcher (Secure — metadata only, re-auth required)
|
|
6476
|
+
// --------------------------------------------------------------------------
|
|
6477
|
+
/** Whether the account switcher is enabled */
|
|
6478
|
+
isAccountSwitcherEnabled() {
|
|
6479
|
+
return this._client.isAccountSwitcherEnabled();
|
|
6480
|
+
}
|
|
6481
|
+
/** The configured privacy level for the account switcher */
|
|
6482
|
+
getAccountSwitcherPrivacy() {
|
|
6483
|
+
return this._client.getAccountSwitcherPrivacy();
|
|
6484
|
+
}
|
|
6485
|
+
/**
|
|
6486
|
+
* Get all accounts that have previously logged in on this device.
|
|
6487
|
+
* Returns privacy-transformed display data — no raw PII in masked/minimal modes.
|
|
6488
|
+
* Requires `enableAccountSwitcher: true` in config.
|
|
6489
|
+
*/
|
|
6490
|
+
getKnownAccounts() {
|
|
6491
|
+
return this._client.getKnownAccounts();
|
|
6492
|
+
}
|
|
6493
|
+
/**
|
|
6494
|
+
* Forget a specific account — removes it from the known accounts list.
|
|
6495
|
+
* Does NOT affect any active session.
|
|
6496
|
+
*/
|
|
6497
|
+
async removeKnownAccount(userId) {
|
|
6498
|
+
return this._client.removeKnownAccount(userId);
|
|
6499
|
+
}
|
|
6500
|
+
/** Forget all known accounts on this device. */
|
|
6501
|
+
async clearKnownAccounts() {
|
|
6502
|
+
return this._client.clearKnownAccounts();
|
|
6503
|
+
}
|
|
6122
6504
|
/** The base URL being used for API requests. */
|
|
6123
6505
|
getBaseUrl() {
|
|
6124
6506
|
return this._client.getBaseUrl();
|
|
@@ -6157,6 +6539,7 @@ export {
|
|
|
6157
6539
|
ChatService,
|
|
6158
6540
|
CommunicationService,
|
|
6159
6541
|
ComplianceService,
|
|
6542
|
+
CreatorMakerService,
|
|
6160
6543
|
DataService,
|
|
6161
6544
|
ErrorCodes,
|
|
6162
6545
|
EventsService,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalemule/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "Official TypeScript/JavaScript SDK for ScaleMule Backend-as-a-Service",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"LICENSE"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "tsup
|
|
26
|
+
"build": "tsup",
|
|
27
27
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
28
28
|
"test": "vitest run",
|
|
29
29
|
"test:watch": "vitest",
|
|
@@ -62,16 +62,13 @@
|
|
|
62
62
|
"node": ">=18.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
+
"@scalemule/ui": ">=0.0.1",
|
|
65
66
|
"semver": "^7.7.4"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"@scalemule/ui": ">=0.0.1",
|
|
69
69
|
"browser-image-compression": ">=2.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
|
-
"@scalemule/ui": {
|
|
73
|
-
"optional": false
|
|
74
|
-
},
|
|
75
72
|
"browser-image-compression": {
|
|
76
73
|
"optional": true
|
|
77
74
|
}
|