@scalemule/sdk 0.0.58 → 0.0.60
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 +50 -0
- package/dist/index.d.mts +241 -1
- package/dist/index.d.ts +241 -1
- package/dist/index.js +116 -1
- package/dist/index.mjs +410 -17
- package/package.json +1 -1
- package/dist/chunk-3FTGBRLU.mjs +0 -158
- package/dist/upload-compression-VOUJRAIM.mjs +0 -97
- package/dist/upload-resume-RXLHBH5E.mjs +0 -6
package/dist/index.js
CHANGED
|
@@ -340,6 +340,7 @@ __export(index_exports, {
|
|
|
340
340
|
SchedulerService: () => SchedulerService,
|
|
341
341
|
SearchService: () => SearchService,
|
|
342
342
|
ServiceModule: () => ServiceModule,
|
|
343
|
+
SocialPolicyService: () => SocialPolicyService,
|
|
343
344
|
SocialService: () => SocialService,
|
|
344
345
|
StorageService: () => StorageService,
|
|
345
346
|
TeamsService: () => TeamsService,
|
|
@@ -1651,7 +1652,7 @@ function asString(parent, key) {
|
|
|
1651
1652
|
return typeof value === "string" ? value : void 0;
|
|
1652
1653
|
}
|
|
1653
1654
|
|
|
1654
|
-
// node_modules
|
|
1655
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1655
1656
|
var PHONE_COUNTRIES = [
|
|
1656
1657
|
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1657
1658
|
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
@@ -5146,6 +5147,118 @@ var SocialService = class extends ServiceModule {
|
|
|
5146
5147
|
}
|
|
5147
5148
|
};
|
|
5148
5149
|
|
|
5150
|
+
// src/services/social-policy.ts
|
|
5151
|
+
var SocialPolicyService = class extends ServiceModule {
|
|
5152
|
+
constructor() {
|
|
5153
|
+
super(...arguments);
|
|
5154
|
+
this.basePath = "/v1/social-policy";
|
|
5155
|
+
}
|
|
5156
|
+
decide(request, options) {
|
|
5157
|
+
return this.post("/decision", withDefaultContext(request), options);
|
|
5158
|
+
}
|
|
5159
|
+
batchDecide(request, options) {
|
|
5160
|
+
return this.post("/decisions/batch", request, options);
|
|
5161
|
+
}
|
|
5162
|
+
decideAction(action, actor, target, options) {
|
|
5163
|
+
return this.decide(
|
|
5164
|
+
{
|
|
5165
|
+
app_key: options?.appKey,
|
|
5166
|
+
account_id: options?.accountId,
|
|
5167
|
+
policy_pack: options?.policyPack,
|
|
5168
|
+
actor,
|
|
5169
|
+
target,
|
|
5170
|
+
action,
|
|
5171
|
+
context: options?.context,
|
|
5172
|
+
metadata: options?.metadata
|
|
5173
|
+
},
|
|
5174
|
+
options?.requestOptions
|
|
5175
|
+
);
|
|
5176
|
+
}
|
|
5177
|
+
decideFollow(actor, target, options) {
|
|
5178
|
+
return this.decideAction("follow", actor, target, options);
|
|
5179
|
+
}
|
|
5180
|
+
decideDirectMessage(actor, target, options) {
|
|
5181
|
+
return this.decideAction("message_direct", actor, target, options);
|
|
5182
|
+
}
|
|
5183
|
+
decideContactRequest(actor, target, options) {
|
|
5184
|
+
return this.decideAction("connect_request", actor, target, options);
|
|
5185
|
+
}
|
|
5186
|
+
getSettings(identityId, options) {
|
|
5187
|
+
return this._get(`/settings/${identityId}`, options);
|
|
5188
|
+
}
|
|
5189
|
+
updateSettings(identityId, request, options) {
|
|
5190
|
+
return this.patch(`/settings/${identityId}`, request, options);
|
|
5191
|
+
}
|
|
5192
|
+
createRelationship(request, options) {
|
|
5193
|
+
return this.post("/relationships", request, options);
|
|
5194
|
+
}
|
|
5195
|
+
listRelationships(params, options) {
|
|
5196
|
+
return this._get(this.withQuery("/relationships", toQueryParams(params)), options);
|
|
5197
|
+
}
|
|
5198
|
+
deleteRelationship(relationshipId, options) {
|
|
5199
|
+
return this.del(`/relationships/${relationshipId}`, options);
|
|
5200
|
+
}
|
|
5201
|
+
createContactRequest(request, options) {
|
|
5202
|
+
return this.post("/contact-requests", request, options);
|
|
5203
|
+
}
|
|
5204
|
+
listContactRequestInbox(params, options) {
|
|
5205
|
+
return this._get(
|
|
5206
|
+
this.withQuery("/contact-requests/inbox", toQueryParams(params)),
|
|
5207
|
+
options
|
|
5208
|
+
);
|
|
5209
|
+
}
|
|
5210
|
+
listContactRequestSent(params, options) {
|
|
5211
|
+
return this._get(
|
|
5212
|
+
this.withQuery("/contact-requests/sent", toQueryParams(params)),
|
|
5213
|
+
options
|
|
5214
|
+
);
|
|
5215
|
+
}
|
|
5216
|
+
acceptContactRequest(requestId, options) {
|
|
5217
|
+
return this.post(`/contact-requests/${requestId}/accept`, void 0, options);
|
|
5218
|
+
}
|
|
5219
|
+
ignoreContactRequest(requestId, options) {
|
|
5220
|
+
return this.post(`/contact-requests/${requestId}/ignore`, void 0, options);
|
|
5221
|
+
}
|
|
5222
|
+
declineContactRequest(requestId, options) {
|
|
5223
|
+
return this.post(`/contact-requests/${requestId}/decline`, void 0, options);
|
|
5224
|
+
}
|
|
5225
|
+
reportContactRequest(requestId, options) {
|
|
5226
|
+
return this.post(`/contact-requests/${requestId}/report`, void 0, options);
|
|
5227
|
+
}
|
|
5228
|
+
block(request, options) {
|
|
5229
|
+
return this.post("/block", request, options);
|
|
5230
|
+
}
|
|
5231
|
+
unblock(request, options) {
|
|
5232
|
+
return this.post("/unblock", request, options);
|
|
5233
|
+
}
|
|
5234
|
+
mute(request, options) {
|
|
5235
|
+
return this.post("/mute", request, options);
|
|
5236
|
+
}
|
|
5237
|
+
unmute(request, options) {
|
|
5238
|
+
return this.post("/unmute", request, options);
|
|
5239
|
+
}
|
|
5240
|
+
report(request, options) {
|
|
5241
|
+
return this.post("/report", request, options);
|
|
5242
|
+
}
|
|
5243
|
+
listPolicyPacks(options) {
|
|
5244
|
+
return this._get("/policy-packs", options);
|
|
5245
|
+
}
|
|
5246
|
+
};
|
|
5247
|
+
function withDefaultContext(request) {
|
|
5248
|
+
return {
|
|
5249
|
+
...request,
|
|
5250
|
+
context: request.context ?? {}
|
|
5251
|
+
};
|
|
5252
|
+
}
|
|
5253
|
+
function toQueryParams(params) {
|
|
5254
|
+
if (!params) return void 0;
|
|
5255
|
+
const query = {};
|
|
5256
|
+
for (const [key, value] of Object.entries(params)) {
|
|
5257
|
+
query[key] = value;
|
|
5258
|
+
}
|
|
5259
|
+
return query;
|
|
5260
|
+
}
|
|
5261
|
+
|
|
5149
5262
|
// src/services/referrals.ts
|
|
5150
5263
|
var ReferralsService = class extends ServiceModule {
|
|
5151
5264
|
constructor() {
|
|
@@ -8462,6 +8575,7 @@ var ScaleMule = class {
|
|
|
8462
8575
|
this.chat = new ChatService(this._client);
|
|
8463
8576
|
this.conference = new ConferenceService(this._client);
|
|
8464
8577
|
this.social = new SocialService(this._client);
|
|
8578
|
+
this.socialPolicy = new SocialPolicyService(this._client);
|
|
8465
8579
|
this.referrals = new ReferralsService(this._client);
|
|
8466
8580
|
this.billing = new BillingService(this._client);
|
|
8467
8581
|
this.analytics = new AnalyticsService(this._client);
|
|
@@ -8670,6 +8784,7 @@ var index_default = ScaleMule;
|
|
|
8670
8784
|
SchedulerService,
|
|
8671
8785
|
SearchService,
|
|
8672
8786
|
ServiceModule,
|
|
8787
|
+
SocialPolicyService,
|
|
8673
8788
|
SocialService,
|
|
8674
8789
|
StorageService,
|
|
8675
8790
|
TeamsService,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,282 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/services/upload-resume.ts
|
|
12
|
+
var upload_resume_exports = {};
|
|
13
|
+
__export(upload_resume_exports, {
|
|
14
|
+
UploadResumeStore: () => UploadResumeStore
|
|
15
|
+
});
|
|
16
|
+
var DB_NAME, STORE_NAME, DB_VERSION, MAX_AGE_MS, UploadResumeStore;
|
|
17
|
+
var init_upload_resume = __esm({
|
|
18
|
+
"src/services/upload-resume.ts"() {
|
|
19
|
+
"use strict";
|
|
20
|
+
DB_NAME = "sm_upload_sessions_v1";
|
|
21
|
+
STORE_NAME = "sessions";
|
|
22
|
+
DB_VERSION = 1;
|
|
23
|
+
MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
24
|
+
UploadResumeStore = class {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.db = null;
|
|
27
|
+
}
|
|
28
|
+
/** Generate a deterministic resume key from upload identity */
|
|
29
|
+
static async generateResumeKey(appId, userId, filename, size, lastModified) {
|
|
30
|
+
const raw = `${appId}:${userId}:${filename}:${size}:${lastModified ?? 0}`;
|
|
31
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
32
|
+
const buffer = new TextEncoder().encode(raw);
|
|
33
|
+
const hash2 = await crypto.subtle.digest("SHA-256", buffer);
|
|
34
|
+
return Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
35
|
+
}
|
|
36
|
+
let hash = 0;
|
|
37
|
+
for (let i = 0; i < raw.length; i++) {
|
|
38
|
+
const chr = raw.charCodeAt(i);
|
|
39
|
+
hash = (hash << 5) - hash + chr;
|
|
40
|
+
hash |= 0;
|
|
41
|
+
}
|
|
42
|
+
return `fallback_${Math.abs(hash).toString(36)}`;
|
|
43
|
+
}
|
|
44
|
+
/** Open the IndexedDB store. No-ops if IndexedDB is unavailable. */
|
|
45
|
+
async open() {
|
|
46
|
+
if (typeof indexedDB === "undefined") return;
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
49
|
+
request.onupgradeneeded = () => {
|
|
50
|
+
const db = request.result;
|
|
51
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
52
|
+
const store = db.createObjectStore(STORE_NAME, { keyPath: "key" });
|
|
53
|
+
store.createIndex("updated_at", "updated_at");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
request.onsuccess = () => {
|
|
57
|
+
this.db = request.result;
|
|
58
|
+
resolve();
|
|
59
|
+
};
|
|
60
|
+
request.onerror = () => {
|
|
61
|
+
reject(request.error);
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Get a resume session by key. Returns null if not found or stale. */
|
|
66
|
+
async get(key) {
|
|
67
|
+
if (!this.db) return null;
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
const tx = this.db.transaction(STORE_NAME, "readonly");
|
|
70
|
+
const store = tx.objectStore(STORE_NAME);
|
|
71
|
+
const request = store.get(key);
|
|
72
|
+
request.onsuccess = () => {
|
|
73
|
+
const entry = request.result;
|
|
74
|
+
if (!entry) {
|
|
75
|
+
resolve(null);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (Date.now() - entry.updated_at > MAX_AGE_MS) {
|
|
79
|
+
this.remove(key).catch(() => {
|
|
80
|
+
});
|
|
81
|
+
resolve(null);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
resolve(entry.session);
|
|
85
|
+
};
|
|
86
|
+
request.onerror = () => resolve(null);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Save a new resume session. */
|
|
90
|
+
async save(key, session) {
|
|
91
|
+
if (!this.db) return;
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
94
|
+
const store = tx.objectStore(STORE_NAME);
|
|
95
|
+
const entry = {
|
|
96
|
+
key,
|
|
97
|
+
session: { ...session, created_at: Date.now() },
|
|
98
|
+
updated_at: Date.now()
|
|
99
|
+
};
|
|
100
|
+
const request = store.put(entry);
|
|
101
|
+
request.onsuccess = () => resolve();
|
|
102
|
+
request.onerror = () => reject(request.error);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** Update a single completed part in an existing session. */
|
|
106
|
+
async updatePart(key, partNumber, etag) {
|
|
107
|
+
if (!this.db) return;
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
110
|
+
const store = tx.objectStore(STORE_NAME);
|
|
111
|
+
const getRequest = store.get(key);
|
|
112
|
+
getRequest.onsuccess = () => {
|
|
113
|
+
const entry = getRequest.result;
|
|
114
|
+
if (!entry) {
|
|
115
|
+
resolve();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const existing = entry.session.completed_parts.find((p) => p.part_number === partNumber);
|
|
119
|
+
if (!existing) {
|
|
120
|
+
entry.session.completed_parts.push({ part_number: partNumber, etag });
|
|
121
|
+
}
|
|
122
|
+
entry.updated_at = Date.now();
|
|
123
|
+
const putRequest = store.put(entry);
|
|
124
|
+
putRequest.onsuccess = () => resolve();
|
|
125
|
+
putRequest.onerror = () => resolve();
|
|
126
|
+
};
|
|
127
|
+
getRequest.onerror = () => resolve();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** Remove a resume session (e.g., after successful completion). */
|
|
131
|
+
async remove(key) {
|
|
132
|
+
if (!this.db) return;
|
|
133
|
+
return new Promise((resolve) => {
|
|
134
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
135
|
+
const store = tx.objectStore(STORE_NAME);
|
|
136
|
+
const request = store.delete(key);
|
|
137
|
+
request.onsuccess = () => resolve();
|
|
138
|
+
request.onerror = () => resolve();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** Purge all stale entries (older than MAX_AGE_MS). */
|
|
142
|
+
async purgeStale() {
|
|
143
|
+
if (!this.db) return 0;
|
|
144
|
+
return new Promise((resolve) => {
|
|
145
|
+
const cutoff = Date.now() - MAX_AGE_MS;
|
|
146
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
147
|
+
const store = tx.objectStore(STORE_NAME);
|
|
148
|
+
const index = store.index("updated_at");
|
|
149
|
+
const range = IDBKeyRange.upperBound(cutoff);
|
|
150
|
+
const request = index.openCursor(range);
|
|
151
|
+
let count = 0;
|
|
152
|
+
request.onsuccess = () => {
|
|
153
|
+
const cursor = request.result;
|
|
154
|
+
if (cursor) {
|
|
155
|
+
cursor.delete();
|
|
156
|
+
count++;
|
|
157
|
+
cursor.continue();
|
|
158
|
+
} else {
|
|
159
|
+
resolve(count);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
request.onerror = () => resolve(0);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** Close the database connection. */
|
|
166
|
+
close() {
|
|
167
|
+
if (this.db) {
|
|
168
|
+
this.db.close();
|
|
169
|
+
this.db = null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// src/services/upload-compression.ts
|
|
177
|
+
var upload_compression_exports = {};
|
|
178
|
+
__export(upload_compression_exports, {
|
|
179
|
+
maybeCompressImage: () => maybeCompressImage
|
|
180
|
+
});
|
|
181
|
+
async function maybeCompressImage(file, userConfig, sessionId, telemetry) {
|
|
182
|
+
const type = file.type?.toLowerCase() || "";
|
|
183
|
+
if (!type.startsWith("image/")) return null;
|
|
184
|
+
if (SKIP_TYPES.has(type)) {
|
|
185
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "format", type });
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (!COMPRESSIBLE_TYPES.has(type)) {
|
|
189
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "unsupported_type", type });
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
if (file.size < MIN_COMPRESS_SIZE) {
|
|
193
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "too_small", size: file.size });
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const networkType = getNetworkEffectiveType();
|
|
197
|
+
const defaultProfile = { maxWidth: 3840, maxHeight: 3840, quality: 0.85, maxSizeMB: 5 };
|
|
198
|
+
const networkProfile = NETWORK_PROFILES[networkType] ?? defaultProfile;
|
|
199
|
+
const config = {
|
|
200
|
+
maxWidth: userConfig?.maxWidth ?? networkProfile.maxWidth,
|
|
201
|
+
maxHeight: userConfig?.maxHeight ?? networkProfile.maxHeight,
|
|
202
|
+
quality: userConfig?.quality ?? networkProfile.quality,
|
|
203
|
+
maxSizeMB: userConfig?.maxSizeMB ?? networkProfile.maxSizeMB
|
|
204
|
+
};
|
|
205
|
+
telemetry?.emit(sessionId, "upload.compression.started", {
|
|
206
|
+
original_size: file.size,
|
|
207
|
+
network: networkType,
|
|
208
|
+
target_quality: config.quality
|
|
209
|
+
});
|
|
210
|
+
try {
|
|
211
|
+
const imageCompression = await loadImageCompression();
|
|
212
|
+
if (!imageCompression) {
|
|
213
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "library_unavailable" });
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const compressed = await imageCompression(file, {
|
|
217
|
+
maxSizeMB: config.maxSizeMB,
|
|
218
|
+
maxWidthOrHeight: Math.max(config.maxWidth, config.maxHeight),
|
|
219
|
+
initialQuality: config.quality,
|
|
220
|
+
useWebWorker: true,
|
|
221
|
+
fileType: type === "image/png" ? "image/webp" : void 0
|
|
222
|
+
});
|
|
223
|
+
if (compressed.size >= file.size * 0.95) {
|
|
224
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", {
|
|
225
|
+
reason: "no_size_reduction",
|
|
226
|
+
original_size: file.size,
|
|
227
|
+
compressed_size: compressed.size
|
|
228
|
+
});
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
telemetry?.emit(sessionId, "upload.compression.completed", {
|
|
232
|
+
original_size: file.size,
|
|
233
|
+
compressed_size: compressed.size,
|
|
234
|
+
ratio: (compressed.size / file.size).toFixed(2)
|
|
235
|
+
});
|
|
236
|
+
return compressed;
|
|
237
|
+
} catch (err) {
|
|
238
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", {
|
|
239
|
+
reason: "error",
|
|
240
|
+
error: err instanceof Error ? err.message : "Unknown compression error"
|
|
241
|
+
});
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function loadImageCompression() {
|
|
246
|
+
if (cachedImport === false) return null;
|
|
247
|
+
if (cachedImport) return cachedImport;
|
|
248
|
+
try {
|
|
249
|
+
const mod = await Function('return import("browser-image-compression")')();
|
|
250
|
+
cachedImport = mod.default || mod;
|
|
251
|
+
return cachedImport;
|
|
252
|
+
} catch {
|
|
253
|
+
cachedImport = false;
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function getNetworkEffectiveType() {
|
|
258
|
+
if (typeof navigator !== "undefined" && "connection" in navigator) {
|
|
259
|
+
const conn = navigator.connection;
|
|
260
|
+
return conn?.effectiveType || "4g";
|
|
261
|
+
}
|
|
262
|
+
return "4g";
|
|
263
|
+
}
|
|
264
|
+
var MIN_COMPRESS_SIZE, COMPRESSIBLE_TYPES, SKIP_TYPES, NETWORK_PROFILES, cachedImport;
|
|
265
|
+
var init_upload_compression = __esm({
|
|
266
|
+
"src/services/upload-compression.ts"() {
|
|
267
|
+
"use strict";
|
|
268
|
+
MIN_COMPRESS_SIZE = 100 * 1024;
|
|
269
|
+
COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/jpg", "image/png", "image/bmp", "image/tiff"]);
|
|
270
|
+
SKIP_TYPES = /* @__PURE__ */ new Set(["image/gif", "image/svg+xml", "image/webp", "image/avif"]);
|
|
271
|
+
NETWORK_PROFILES = {
|
|
272
|
+
"slow-2g": { maxWidth: 1280, maxHeight: 1280, quality: 0.6, maxSizeMB: 0.5 },
|
|
273
|
+
"2g": { maxWidth: 1600, maxHeight: 1600, quality: 0.65, maxSizeMB: 1 },
|
|
274
|
+
"3g": { maxWidth: 2048, maxHeight: 2048, quality: 0.75, maxSizeMB: 2 },
|
|
275
|
+
"4g": { maxWidth: 3840, maxHeight: 3840, quality: 0.85, maxSizeMB: 5 }
|
|
276
|
+
};
|
|
277
|
+
cachedImport = null;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
4
280
|
|
|
5
281
|
// src/types.ts
|
|
6
282
|
var ErrorCodes = {
|
|
@@ -1273,7 +1549,7 @@ function asString(parent, key) {
|
|
|
1273
1549
|
return typeof value === "string" ? value : void 0;
|
|
1274
1550
|
}
|
|
1275
1551
|
|
|
1276
|
-
// node_modules
|
|
1552
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1277
1553
|
var PHONE_COUNTRIES = [
|
|
1278
1554
|
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1279
1555
|
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
@@ -2128,7 +2404,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2128
2404
|
size_bytes: file.size,
|
|
2129
2405
|
content_type: file.type,
|
|
2130
2406
|
strategy: this.shouldUseMultipart(file, options) ? "multipart" : "direct",
|
|
2131
|
-
network_type:
|
|
2407
|
+
network_type: getNetworkEffectiveType2()
|
|
2132
2408
|
});
|
|
2133
2409
|
try {
|
|
2134
2410
|
let uploadFile = file;
|
|
@@ -2344,7 +2620,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2344
2620
|
let resumeData = null;
|
|
2345
2621
|
if (options?.resume !== "off" && typeof window !== "undefined") {
|
|
2346
2622
|
try {
|
|
2347
|
-
const { UploadResumeStore: UploadResumeStore2 } = await
|
|
2623
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2348
2624
|
resumeStore = new UploadResumeStore2();
|
|
2349
2625
|
await resumeStore.open();
|
|
2350
2626
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
@@ -2392,7 +2668,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2392
2668
|
} else {
|
|
2393
2669
|
let clientUploadKey;
|
|
2394
2670
|
try {
|
|
2395
|
-
const { UploadResumeStore: UploadResumeStore2 } = await
|
|
2671
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2396
2672
|
clientUploadKey = await UploadResumeStore2.generateResumeKey(
|
|
2397
2673
|
this.client.getApiKey?.() || "",
|
|
2398
2674
|
this.client.getUserId?.() || "",
|
|
@@ -2425,7 +2701,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2425
2701
|
const { upload_session_id, file_id, part_size_bytes, total_parts } = startData;
|
|
2426
2702
|
if (resumeStore && !resumeData) {
|
|
2427
2703
|
try {
|
|
2428
|
-
const { UploadResumeStore: UploadResumeStore2 } = await
|
|
2704
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2429
2705
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2430
2706
|
this.client.getApiKey?.() || "",
|
|
2431
2707
|
this.client.getUserId?.() || "",
|
|
@@ -2576,7 +2852,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2576
2852
|
telemetry?.emit(sessionId, "upload.multipart.part_completed", { part_number: result.partNum });
|
|
2577
2853
|
if (resumeStore) {
|
|
2578
2854
|
try {
|
|
2579
|
-
const { UploadResumeStore: UploadResumeStore2 } = await
|
|
2855
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2580
2856
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2581
2857
|
this.client.getApiKey?.() || "",
|
|
2582
2858
|
this.client.getUserId?.() || "",
|
|
@@ -2628,7 +2904,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2628
2904
|
);
|
|
2629
2905
|
if (resumeStore) {
|
|
2630
2906
|
try {
|
|
2631
|
-
const { UploadResumeStore: UploadResumeStore2 } = await
|
|
2907
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2632
2908
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2633
2909
|
this.client.getApiKey?.() || "",
|
|
2634
2910
|
this.client.getUserId?.() || "",
|
|
@@ -3267,21 +3543,21 @@ var StorageService = class extends ServiceModule {
|
|
|
3267
3543
|
}
|
|
3268
3544
|
defaultChunkSize(fileSize) {
|
|
3269
3545
|
if (fileSize > 512 * 1024 * 1024) return 16 * 1024 * 1024;
|
|
3270
|
-
const effectiveType =
|
|
3546
|
+
const effectiveType = getNetworkEffectiveType2();
|
|
3271
3547
|
if (effectiveType === "slow-2g" || effectiveType === "2g") return 5 * 1024 * 1024;
|
|
3272
3548
|
if (effectiveType === "3g") return 5 * 1024 * 1024;
|
|
3273
3549
|
return 8 * 1024 * 1024;
|
|
3274
3550
|
}
|
|
3275
3551
|
defaultConcurrency() {
|
|
3276
|
-
const effectiveType =
|
|
3552
|
+
const effectiveType = getNetworkEffectiveType2();
|
|
3277
3553
|
if (effectiveType === "slow-2g" || effectiveType === "2g") return 1;
|
|
3278
3554
|
if (effectiveType === "3g") return 2;
|
|
3279
3555
|
return 4;
|
|
3280
3556
|
}
|
|
3281
3557
|
async maybeCompress(file, config, sessionId, telemetry) {
|
|
3282
3558
|
try {
|
|
3283
|
-
const { maybeCompressImage } = await
|
|
3284
|
-
return await
|
|
3559
|
+
const { maybeCompressImage: maybeCompressImage2 } = await Promise.resolve().then(() => (init_upload_compression(), upload_compression_exports));
|
|
3560
|
+
return await maybeCompressImage2(file, config, sessionId, telemetry);
|
|
3285
3561
|
} catch {
|
|
3286
3562
|
return null;
|
|
3287
3563
|
}
|
|
@@ -3321,10 +3597,10 @@ function getStallTimeout() {
|
|
|
3321
3597
|
return isSlowNetwork() ? SLOW_NETWORK_STALL_TIMEOUT_MS : DEFAULT_STALL_TIMEOUT_MS;
|
|
3322
3598
|
}
|
|
3323
3599
|
function isSlowNetwork() {
|
|
3324
|
-
const effectiveType =
|
|
3600
|
+
const effectiveType = getNetworkEffectiveType2();
|
|
3325
3601
|
return effectiveType === "slow-2g" || effectiveType === "2g" || effectiveType === "3g";
|
|
3326
3602
|
}
|
|
3327
|
-
function
|
|
3603
|
+
function getNetworkEffectiveType2() {
|
|
3328
3604
|
if (typeof navigator !== "undefined" && "connection" in navigator) {
|
|
3329
3605
|
const conn = navigator.connection;
|
|
3330
3606
|
return conn?.effectiveType || "4g";
|
|
@@ -3337,7 +3613,7 @@ function getOnlineStatus() {
|
|
|
3337
3613
|
}
|
|
3338
3614
|
function getUploadEnvironmentDiagnostics() {
|
|
3339
3615
|
const diagnostics = {
|
|
3340
|
-
network_type:
|
|
3616
|
+
network_type: getNetworkEffectiveType2(),
|
|
3341
3617
|
online: getOnlineStatus()
|
|
3342
3618
|
};
|
|
3343
3619
|
if (typeof navigator !== "undefined") {
|
|
@@ -3369,6 +3645,9 @@ function extractS3ErrorCode(body) {
|
|
|
3369
3645
|
return m ? m[1] : void 0;
|
|
3370
3646
|
}
|
|
3371
3647
|
|
|
3648
|
+
// src/index.ts
|
|
3649
|
+
init_upload_resume();
|
|
3650
|
+
|
|
3372
3651
|
// src/services/upload-strategy.ts
|
|
3373
3652
|
var MULTIPART_THRESHOLD2 = 8 * 1024 * 1024;
|
|
3374
3653
|
var MULTIPART_THRESHOLD_SLOW2 = 1 * 1024 * 1024;
|
|
@@ -4765,6 +5044,118 @@ var SocialService = class extends ServiceModule {
|
|
|
4765
5044
|
}
|
|
4766
5045
|
};
|
|
4767
5046
|
|
|
5047
|
+
// src/services/social-policy.ts
|
|
5048
|
+
var SocialPolicyService = class extends ServiceModule {
|
|
5049
|
+
constructor() {
|
|
5050
|
+
super(...arguments);
|
|
5051
|
+
this.basePath = "/v1/social-policy";
|
|
5052
|
+
}
|
|
5053
|
+
decide(request, options) {
|
|
5054
|
+
return this.post("/decision", withDefaultContext(request), options);
|
|
5055
|
+
}
|
|
5056
|
+
batchDecide(request, options) {
|
|
5057
|
+
return this.post("/decisions/batch", request, options);
|
|
5058
|
+
}
|
|
5059
|
+
decideAction(action, actor, target, options) {
|
|
5060
|
+
return this.decide(
|
|
5061
|
+
{
|
|
5062
|
+
app_key: options?.appKey,
|
|
5063
|
+
account_id: options?.accountId,
|
|
5064
|
+
policy_pack: options?.policyPack,
|
|
5065
|
+
actor,
|
|
5066
|
+
target,
|
|
5067
|
+
action,
|
|
5068
|
+
context: options?.context,
|
|
5069
|
+
metadata: options?.metadata
|
|
5070
|
+
},
|
|
5071
|
+
options?.requestOptions
|
|
5072
|
+
);
|
|
5073
|
+
}
|
|
5074
|
+
decideFollow(actor, target, options) {
|
|
5075
|
+
return this.decideAction("follow", actor, target, options);
|
|
5076
|
+
}
|
|
5077
|
+
decideDirectMessage(actor, target, options) {
|
|
5078
|
+
return this.decideAction("message_direct", actor, target, options);
|
|
5079
|
+
}
|
|
5080
|
+
decideContactRequest(actor, target, options) {
|
|
5081
|
+
return this.decideAction("connect_request", actor, target, options);
|
|
5082
|
+
}
|
|
5083
|
+
getSettings(identityId, options) {
|
|
5084
|
+
return this._get(`/settings/${identityId}`, options);
|
|
5085
|
+
}
|
|
5086
|
+
updateSettings(identityId, request, options) {
|
|
5087
|
+
return this.patch(`/settings/${identityId}`, request, options);
|
|
5088
|
+
}
|
|
5089
|
+
createRelationship(request, options) {
|
|
5090
|
+
return this.post("/relationships", request, options);
|
|
5091
|
+
}
|
|
5092
|
+
listRelationships(params, options) {
|
|
5093
|
+
return this._get(this.withQuery("/relationships", toQueryParams(params)), options);
|
|
5094
|
+
}
|
|
5095
|
+
deleteRelationship(relationshipId, options) {
|
|
5096
|
+
return this.del(`/relationships/${relationshipId}`, options);
|
|
5097
|
+
}
|
|
5098
|
+
createContactRequest(request, options) {
|
|
5099
|
+
return this.post("/contact-requests", request, options);
|
|
5100
|
+
}
|
|
5101
|
+
listContactRequestInbox(params, options) {
|
|
5102
|
+
return this._get(
|
|
5103
|
+
this.withQuery("/contact-requests/inbox", toQueryParams(params)),
|
|
5104
|
+
options
|
|
5105
|
+
);
|
|
5106
|
+
}
|
|
5107
|
+
listContactRequestSent(params, options) {
|
|
5108
|
+
return this._get(
|
|
5109
|
+
this.withQuery("/contact-requests/sent", toQueryParams(params)),
|
|
5110
|
+
options
|
|
5111
|
+
);
|
|
5112
|
+
}
|
|
5113
|
+
acceptContactRequest(requestId, options) {
|
|
5114
|
+
return this.post(`/contact-requests/${requestId}/accept`, void 0, options);
|
|
5115
|
+
}
|
|
5116
|
+
ignoreContactRequest(requestId, options) {
|
|
5117
|
+
return this.post(`/contact-requests/${requestId}/ignore`, void 0, options);
|
|
5118
|
+
}
|
|
5119
|
+
declineContactRequest(requestId, options) {
|
|
5120
|
+
return this.post(`/contact-requests/${requestId}/decline`, void 0, options);
|
|
5121
|
+
}
|
|
5122
|
+
reportContactRequest(requestId, options) {
|
|
5123
|
+
return this.post(`/contact-requests/${requestId}/report`, void 0, options);
|
|
5124
|
+
}
|
|
5125
|
+
block(request, options) {
|
|
5126
|
+
return this.post("/block", request, options);
|
|
5127
|
+
}
|
|
5128
|
+
unblock(request, options) {
|
|
5129
|
+
return this.post("/unblock", request, options);
|
|
5130
|
+
}
|
|
5131
|
+
mute(request, options) {
|
|
5132
|
+
return this.post("/mute", request, options);
|
|
5133
|
+
}
|
|
5134
|
+
unmute(request, options) {
|
|
5135
|
+
return this.post("/unmute", request, options);
|
|
5136
|
+
}
|
|
5137
|
+
report(request, options) {
|
|
5138
|
+
return this.post("/report", request, options);
|
|
5139
|
+
}
|
|
5140
|
+
listPolicyPacks(options) {
|
|
5141
|
+
return this._get("/policy-packs", options);
|
|
5142
|
+
}
|
|
5143
|
+
};
|
|
5144
|
+
function withDefaultContext(request) {
|
|
5145
|
+
return {
|
|
5146
|
+
...request,
|
|
5147
|
+
context: request.context ?? {}
|
|
5148
|
+
};
|
|
5149
|
+
}
|
|
5150
|
+
function toQueryParams(params) {
|
|
5151
|
+
if (!params) return void 0;
|
|
5152
|
+
const query = {};
|
|
5153
|
+
for (const [key, value] of Object.entries(params)) {
|
|
5154
|
+
query[key] = value;
|
|
5155
|
+
}
|
|
5156
|
+
return query;
|
|
5157
|
+
}
|
|
5158
|
+
|
|
4768
5159
|
// src/services/referrals.ts
|
|
4769
5160
|
var ReferralsService = class extends ServiceModule {
|
|
4770
5161
|
constructor() {
|
|
@@ -8081,6 +8472,7 @@ var ScaleMule = class {
|
|
|
8081
8472
|
this.chat = new ChatService(this._client);
|
|
8082
8473
|
this.conference = new ConferenceService(this._client);
|
|
8083
8474
|
this.social = new SocialService(this._client);
|
|
8475
|
+
this.socialPolicy = new SocialPolicyService(this._client);
|
|
8084
8476
|
this.referrals = new ReferralsService(this._client);
|
|
8085
8477
|
this.billing = new BillingService(this._client);
|
|
8086
8478
|
this.analytics = new AnalyticsService(this._client);
|
|
@@ -8288,6 +8680,7 @@ export {
|
|
|
8288
8680
|
SchedulerService,
|
|
8289
8681
|
SearchService,
|
|
8290
8682
|
ServiceModule,
|
|
8683
|
+
SocialPolicyService,
|
|
8291
8684
|
SocialService,
|
|
8292
8685
|
StorageService,
|
|
8293
8686
|
TeamsService,
|