@scalemule/sdk 0.0.63 → 0.0.67
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 +353 -2
- package/dist/index.d.ts +353 -2
- package/dist/index.js +173 -1
- package/dist/index.mjs +168 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -304,6 +304,7 @@ __export(index_exports, {
|
|
|
304
304
|
AudioService: () => AudioService,
|
|
305
305
|
AuthService: () => AuthService,
|
|
306
306
|
BillingService: () => BillingService,
|
|
307
|
+
BookingsService: () => BookingsService,
|
|
307
308
|
CacheService: () => CacheService,
|
|
308
309
|
CatalogService: () => CatalogService,
|
|
309
310
|
ChatService: () => ChatService,
|
|
@@ -312,6 +313,7 @@ __export(index_exports, {
|
|
|
312
313
|
ConferenceService: () => ConferenceService,
|
|
313
314
|
CreatorMakerService: () => CreatorMakerService,
|
|
314
315
|
DataService: () => DataService,
|
|
316
|
+
DecisionsService: () => DecisionsService,
|
|
315
317
|
ErrorCodes: () => ErrorCodes,
|
|
316
318
|
EventsService: () => EventsService,
|
|
317
319
|
FlagContentService: () => FlagContentService,
|
|
@@ -332,6 +334,7 @@ __export(index_exports, {
|
|
|
332
334
|
PHOTO_BREAKPOINTS: () => PHOTO_BREAKPOINTS,
|
|
333
335
|
PermissionsService: () => PermissionsService,
|
|
334
336
|
PhotoService: () => PhotoService,
|
|
337
|
+
PollsService: () => PollsService,
|
|
335
338
|
QueueService: () => QueueService,
|
|
336
339
|
RealtimeService: () => RealtimeService,
|
|
337
340
|
ReferralsService: () => ReferralsService,
|
|
@@ -374,6 +377,8 @@ __export(index_exports, {
|
|
|
374
377
|
isValidE164Phone: () => isValidE164Phone,
|
|
375
378
|
normalizeAndValidatePhone: () => normalizeAndValidatePhone,
|
|
376
379
|
normalizePhoneNumber: () => normalizePhoneNumber,
|
|
380
|
+
pollSharePercent: () => pollSharePercent,
|
|
381
|
+
pollVoterKey: () => pollVoterKey,
|
|
377
382
|
readAnonymousId: () => readAnonymousId,
|
|
378
383
|
resolveStrategy: () => resolveStrategy,
|
|
379
384
|
uploadMultipartToS3: () => uploadMultipartToS3,
|
|
@@ -1230,6 +1235,15 @@ var ScaleMuleClient = class {
|
|
|
1230
1235
|
status: response.status,
|
|
1231
1236
|
details: responseData?.error?.details || responseData?.details
|
|
1232
1237
|
};
|
|
1238
|
+
const field = responseData?.error?.field;
|
|
1239
|
+
if (field !== void 0) error.field = field;
|
|
1240
|
+
const requestId = responseData?.meta?.request_id ?? response.headers.get("x-request-id") ?? void 0;
|
|
1241
|
+
if (requestId !== void 0) error.requestId = requestId;
|
|
1242
|
+
const traceId = responseData?.meta?.trace_id;
|
|
1243
|
+
if (traceId !== void 0) error.traceId = traceId;
|
|
1244
|
+
const retryable = responseData?.error?.retryable;
|
|
1245
|
+
if (retryable !== void 0) error.retryable = retryable;
|
|
1246
|
+
if (responseData?.error !== void 0) error.problem = responseData.error;
|
|
1233
1247
|
if (response.status === 401 && this.sessionToken && !init.isAutoRefresh) {
|
|
1234
1248
|
if (this.debug) console.log("[ScaleMule] 401 received, attempting auto-refresh...");
|
|
1235
1249
|
let isPrimaryRefresh = false;
|
|
@@ -1656,7 +1670,7 @@ function asString(parent, key) {
|
|
|
1656
1670
|
return typeof value === "string" ? value : void 0;
|
|
1657
1671
|
}
|
|
1658
1672
|
|
|
1659
|
-
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1673
|
+
// ../../../Users/squid/Inventions/CodeBase/agent/scalemule/agent5/scalemule-repos/sdks/sdk/node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1660
1674
|
var PHONE_COUNTRIES = [
|
|
1661
1675
|
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1662
1676
|
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
@@ -6439,6 +6453,90 @@ var SchedulerService = class extends ServiceModule {
|
|
|
6439
6453
|
}
|
|
6440
6454
|
};
|
|
6441
6455
|
|
|
6456
|
+
// src/services/decisions.ts
|
|
6457
|
+
var DecisionsService = class extends ServiceModule {
|
|
6458
|
+
constructor() {
|
|
6459
|
+
super(...arguments);
|
|
6460
|
+
this.basePath = "/v1/decisions";
|
|
6461
|
+
}
|
|
6462
|
+
/**
|
|
6463
|
+
* Evaluate a decision on the tenant's active release.
|
|
6464
|
+
*
|
|
6465
|
+
* @example
|
|
6466
|
+
* const { data } = await sm.decisions.evaluate<AppointmentDepositValue>(
|
|
6467
|
+
* 'appointment.deposit',
|
|
6468
|
+
* { appointment: { quote_id }, customer: { ref: customerRef } },
|
|
6469
|
+
* { idempotency_key: `event:${eventId}` },
|
|
6470
|
+
* { headers: { 'x-requested-account-id': accountId } },
|
|
6471
|
+
* );
|
|
6472
|
+
*/
|
|
6473
|
+
async evaluate(decisionKey, inputs, options, requestOptions) {
|
|
6474
|
+
return this.post(
|
|
6475
|
+
`/evaluate/${encodeURIComponent(decisionKey)}`,
|
|
6476
|
+
{ inputs, options: options ?? {} },
|
|
6477
|
+
requestOptions
|
|
6478
|
+
);
|
|
6479
|
+
}
|
|
6480
|
+
/** Evaluate up to 100 decisions in one call (per-item success/error). */
|
|
6481
|
+
async evaluateBatch(items, requestOptions) {
|
|
6482
|
+
return this.post("/evaluate/batch", { items }, requestOptions);
|
|
6483
|
+
}
|
|
6484
|
+
/** Fetch a stored receipt (end users only see their own). */
|
|
6485
|
+
async getReceipt(receiptId, requestOptions) {
|
|
6486
|
+
return this._get(`/receipts/${encodeURIComponent(receiptId)}`, requestOptions);
|
|
6487
|
+
}
|
|
6488
|
+
/** Server-side verification of a stored receipt against the receipt ring. */
|
|
6489
|
+
async verifyReceipt(receiptId, requestOptions) {
|
|
6490
|
+
return this.post(
|
|
6491
|
+
`/receipts/${encodeURIComponent(receiptId)}/verify`,
|
|
6492
|
+
void 0,
|
|
6493
|
+
requestOptions
|
|
6494
|
+
);
|
|
6495
|
+
}
|
|
6496
|
+
};
|
|
6497
|
+
|
|
6498
|
+
// src/services/bookings.ts
|
|
6499
|
+
var BookingsService = class extends ServiceModule {
|
|
6500
|
+
constructor() {
|
|
6501
|
+
super(...arguments);
|
|
6502
|
+
this.basePath = "/v1/bookings";
|
|
6503
|
+
}
|
|
6504
|
+
/** Create an offered quote for a customer in the active workspace. */
|
|
6505
|
+
async createQuote(input, requestOptions) {
|
|
6506
|
+
return this.post("/quotes", input, requestOptions);
|
|
6507
|
+
}
|
|
6508
|
+
async getQuote(quoteId, requestOptions) {
|
|
6509
|
+
return this._get(`/quotes/${encodeURIComponent(quoteId)}`, requestOptions);
|
|
6510
|
+
}
|
|
6511
|
+
/**
|
|
6512
|
+
* Accept a quote with a verified deposit receipt. Bookings re-verifies the
|
|
6513
|
+
* receipt signature and binding server-side and commits the receipt id/hash
|
|
6514
|
+
* and deposit on the quote.
|
|
6515
|
+
*/
|
|
6516
|
+
async acceptQuote(quoteId, input, requestOptions) {
|
|
6517
|
+
return this.post(`/quotes/${encodeURIComponent(quoteId)}/accept`, input, requestOptions);
|
|
6518
|
+
}
|
|
6519
|
+
async getCustomerStats(customerRef, requestOptions) {
|
|
6520
|
+
return this._get(`/customers/${encodeURIComponent(customerRef)}/stats`, requestOptions);
|
|
6521
|
+
}
|
|
6522
|
+
/** Host/admin: mark a booking completed (maintains the customer stats projection). */
|
|
6523
|
+
async completeBooking(bookingId, reason, requestOptions) {
|
|
6524
|
+
return this.post(
|
|
6525
|
+
`/dashboard/bookings/${encodeURIComponent(bookingId)}/complete`,
|
|
6526
|
+
{ reason },
|
|
6527
|
+
requestOptions
|
|
6528
|
+
);
|
|
6529
|
+
}
|
|
6530
|
+
/** Host/admin: mark a booking as a no-show (maintains the customer stats projection). */
|
|
6531
|
+
async markNoShow(bookingId, reason, requestOptions) {
|
|
6532
|
+
return this.post(
|
|
6533
|
+
`/dashboard/bookings/${encodeURIComponent(bookingId)}/no-show`,
|
|
6534
|
+
{ reason },
|
|
6535
|
+
requestOptions
|
|
6536
|
+
);
|
|
6537
|
+
}
|
|
6538
|
+
};
|
|
6539
|
+
|
|
6442
6540
|
// src/services/permissions.ts
|
|
6443
6541
|
function canPerform(matrix, resource, action) {
|
|
6444
6542
|
if (!matrix) return false;
|
|
@@ -6799,6 +6897,72 @@ var ListingsService = class extends ServiceModule {
|
|
|
6799
6897
|
}
|
|
6800
6898
|
};
|
|
6801
6899
|
|
|
6900
|
+
// src/services/polls.ts
|
|
6901
|
+
var PollsService = class extends ServiceModule {
|
|
6902
|
+
constructor() {
|
|
6903
|
+
super(...arguments);
|
|
6904
|
+
this.basePath = "/v1/polls";
|
|
6905
|
+
}
|
|
6906
|
+
async create(data, options) {
|
|
6907
|
+
return this.post("/manage", data, options);
|
|
6908
|
+
}
|
|
6909
|
+
async list(params, options) {
|
|
6910
|
+
return this._get(this.withQuery("/manage", params), options);
|
|
6911
|
+
}
|
|
6912
|
+
async get(id, options) {
|
|
6913
|
+
return this._get(`/manage/${encodeURIComponent(id)}`, options);
|
|
6914
|
+
}
|
|
6915
|
+
async update(id, data, options) {
|
|
6916
|
+
return this.patch(`/manage/${encodeURIComponent(id)}`, data, options);
|
|
6917
|
+
}
|
|
6918
|
+
async publish(id, options) {
|
|
6919
|
+
return this.post(`/manage/${encodeURIComponent(id)}/publish`, {}, options);
|
|
6920
|
+
}
|
|
6921
|
+
async close(id, options) {
|
|
6922
|
+
return this.post(`/manage/${encodeURIComponent(id)}/close`, {}, options);
|
|
6923
|
+
}
|
|
6924
|
+
async listPublic(params, options) {
|
|
6925
|
+
return this._get(this.withQuery("/public", params), options);
|
|
6926
|
+
}
|
|
6927
|
+
async getPublic(slug, params, options) {
|
|
6928
|
+
return this._get(
|
|
6929
|
+
this.withQuery(`/public/${encodeURIComponent(slug)}`, params),
|
|
6930
|
+
options
|
|
6931
|
+
);
|
|
6932
|
+
}
|
|
6933
|
+
async vote(slug, choiceId, voterKey, options) {
|
|
6934
|
+
return this.post(
|
|
6935
|
+
`/public/${encodeURIComponent(slug)}/votes`,
|
|
6936
|
+
{
|
|
6937
|
+
choice_id: choiceId,
|
|
6938
|
+
voter_key: voterKey
|
|
6939
|
+
},
|
|
6940
|
+
options
|
|
6941
|
+
);
|
|
6942
|
+
}
|
|
6943
|
+
};
|
|
6944
|
+
var VOTER_KEY_STORAGE = "sm_poll_voter_key";
|
|
6945
|
+
function pollVoterKey(storage) {
|
|
6946
|
+
const target = storage ?? (typeof localStorage === "undefined" ? void 0 : localStorage);
|
|
6947
|
+
const existing = target?.getItem(VOTER_KEY_STORAGE);
|
|
6948
|
+
if (existing && /^[A-Za-z0-9_-]{32,128}$/.test(existing)) return existing;
|
|
6949
|
+
const bytes = new Uint8Array(32);
|
|
6950
|
+
const cryptoRef = typeof crypto !== "undefined" ? crypto : void 0;
|
|
6951
|
+
if (!cryptoRef?.getRandomValues) {
|
|
6952
|
+
throw new Error("A browser crypto source is required to create a voter key.");
|
|
6953
|
+
}
|
|
6954
|
+
cryptoRef.getRandomValues(bytes);
|
|
6955
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
6956
|
+
let key = "";
|
|
6957
|
+
for (const byte of bytes) key += alphabet[byte % alphabet.length];
|
|
6958
|
+
target?.setItem(VOTER_KEY_STORAGE, key);
|
|
6959
|
+
return key;
|
|
6960
|
+
}
|
|
6961
|
+
function pollSharePercent(votes, total) {
|
|
6962
|
+
if (!Number.isFinite(votes) || !Number.isFinite(total) || total <= 0 || votes <= 0) return 0;
|
|
6963
|
+
return Math.floor(votes * 100 / total);
|
|
6964
|
+
}
|
|
6965
|
+
|
|
6802
6966
|
// src/services/events.ts
|
|
6803
6967
|
var EventsService = class extends ServiceModule {
|
|
6804
6968
|
constructor() {
|
|
@@ -8744,6 +8908,8 @@ var ScaleMule = class {
|
|
|
8744
8908
|
this.communication = new CommunicationService(this._client);
|
|
8745
8909
|
this.notifications = new NotificationsService(this._client);
|
|
8746
8910
|
this.scheduler = new SchedulerService(this._client);
|
|
8911
|
+
this.decisions = new DecisionsService(this._client);
|
|
8912
|
+
this.bookings = new BookingsService(this._client);
|
|
8747
8913
|
this.permissions = new PermissionsService(this._client);
|
|
8748
8914
|
this.workspaces = new WorkspacesService(this._client);
|
|
8749
8915
|
this.accounts = new AccountsService(this._client);
|
|
@@ -8756,6 +8922,7 @@ var ScaleMule = class {
|
|
|
8756
8922
|
this.webhooks = new WebhooksService(this._client);
|
|
8757
8923
|
this.leaderboard = new LeaderboardService(this._client);
|
|
8758
8924
|
this.listings = new ListingsService(this._client);
|
|
8925
|
+
this.polls = new PollsService(this._client);
|
|
8759
8926
|
this.events = new EventsService(this._client);
|
|
8760
8927
|
this.graph = new GraphService(this._client);
|
|
8761
8928
|
this.functions = new FunctionsService(this._client);
|
|
@@ -8909,6 +9076,7 @@ var index_default = ScaleMule;
|
|
|
8909
9076
|
AudioService,
|
|
8910
9077
|
AuthService,
|
|
8911
9078
|
BillingService,
|
|
9079
|
+
BookingsService,
|
|
8912
9080
|
CacheService,
|
|
8913
9081
|
CatalogService,
|
|
8914
9082
|
ChatService,
|
|
@@ -8917,6 +9085,7 @@ var index_default = ScaleMule;
|
|
|
8917
9085
|
ConferenceService,
|
|
8918
9086
|
CreatorMakerService,
|
|
8919
9087
|
DataService,
|
|
9088
|
+
DecisionsService,
|
|
8920
9089
|
ErrorCodes,
|
|
8921
9090
|
EventsService,
|
|
8922
9091
|
FlagContentService,
|
|
@@ -8937,6 +9106,7 @@ var index_default = ScaleMule;
|
|
|
8937
9106
|
PHOTO_BREAKPOINTS,
|
|
8938
9107
|
PermissionsService,
|
|
8939
9108
|
PhotoService,
|
|
9109
|
+
PollsService,
|
|
8940
9110
|
QueueService,
|
|
8941
9111
|
RealtimeService,
|
|
8942
9112
|
ReferralsService,
|
|
@@ -8978,6 +9148,8 @@ var index_default = ScaleMule;
|
|
|
8978
9148
|
isValidE164Phone,
|
|
8979
9149
|
normalizeAndValidatePhone,
|
|
8980
9150
|
normalizePhoneNumber,
|
|
9151
|
+
pollSharePercent,
|
|
9152
|
+
pollVoterKey,
|
|
8981
9153
|
readAnonymousId,
|
|
8982
9154
|
resolveStrategy,
|
|
8983
9155
|
uploadMultipartToS3,
|
package/dist/index.mjs
CHANGED
|
@@ -1126,6 +1126,15 @@ var ScaleMuleClient = class {
|
|
|
1126
1126
|
status: response.status,
|
|
1127
1127
|
details: responseData?.error?.details || responseData?.details
|
|
1128
1128
|
};
|
|
1129
|
+
const field = responseData?.error?.field;
|
|
1130
|
+
if (field !== void 0) error.field = field;
|
|
1131
|
+
const requestId = responseData?.meta?.request_id ?? response.headers.get("x-request-id") ?? void 0;
|
|
1132
|
+
if (requestId !== void 0) error.requestId = requestId;
|
|
1133
|
+
const traceId = responseData?.meta?.trace_id;
|
|
1134
|
+
if (traceId !== void 0) error.traceId = traceId;
|
|
1135
|
+
const retryable = responseData?.error?.retryable;
|
|
1136
|
+
if (retryable !== void 0) error.retryable = retryable;
|
|
1137
|
+
if (responseData?.error !== void 0) error.problem = responseData.error;
|
|
1129
1138
|
if (response.status === 401 && this.sessionToken && !init.isAutoRefresh) {
|
|
1130
1139
|
if (this.debug) console.log("[ScaleMule] 401 received, attempting auto-refresh...");
|
|
1131
1140
|
let isPrimaryRefresh = false;
|
|
@@ -1552,7 +1561,7 @@ function asString(parent, key) {
|
|
|
1552
1561
|
return typeof value === "string" ? value : void 0;
|
|
1553
1562
|
}
|
|
1554
1563
|
|
|
1555
|
-
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1564
|
+
// ../../../Users/squid/Inventions/CodeBase/agent/scalemule/agent5/scalemule-repos/sdks/sdk/node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1556
1565
|
var PHONE_COUNTRIES = [
|
|
1557
1566
|
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1558
1567
|
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
@@ -6335,6 +6344,90 @@ var SchedulerService = class extends ServiceModule {
|
|
|
6335
6344
|
}
|
|
6336
6345
|
};
|
|
6337
6346
|
|
|
6347
|
+
// src/services/decisions.ts
|
|
6348
|
+
var DecisionsService = class extends ServiceModule {
|
|
6349
|
+
constructor() {
|
|
6350
|
+
super(...arguments);
|
|
6351
|
+
this.basePath = "/v1/decisions";
|
|
6352
|
+
}
|
|
6353
|
+
/**
|
|
6354
|
+
* Evaluate a decision on the tenant's active release.
|
|
6355
|
+
*
|
|
6356
|
+
* @example
|
|
6357
|
+
* const { data } = await sm.decisions.evaluate<AppointmentDepositValue>(
|
|
6358
|
+
* 'appointment.deposit',
|
|
6359
|
+
* { appointment: { quote_id }, customer: { ref: customerRef } },
|
|
6360
|
+
* { idempotency_key: `event:${eventId}` },
|
|
6361
|
+
* { headers: { 'x-requested-account-id': accountId } },
|
|
6362
|
+
* );
|
|
6363
|
+
*/
|
|
6364
|
+
async evaluate(decisionKey, inputs, options, requestOptions) {
|
|
6365
|
+
return this.post(
|
|
6366
|
+
`/evaluate/${encodeURIComponent(decisionKey)}`,
|
|
6367
|
+
{ inputs, options: options ?? {} },
|
|
6368
|
+
requestOptions
|
|
6369
|
+
);
|
|
6370
|
+
}
|
|
6371
|
+
/** Evaluate up to 100 decisions in one call (per-item success/error). */
|
|
6372
|
+
async evaluateBatch(items, requestOptions) {
|
|
6373
|
+
return this.post("/evaluate/batch", { items }, requestOptions);
|
|
6374
|
+
}
|
|
6375
|
+
/** Fetch a stored receipt (end users only see their own). */
|
|
6376
|
+
async getReceipt(receiptId, requestOptions) {
|
|
6377
|
+
return this._get(`/receipts/${encodeURIComponent(receiptId)}`, requestOptions);
|
|
6378
|
+
}
|
|
6379
|
+
/** Server-side verification of a stored receipt against the receipt ring. */
|
|
6380
|
+
async verifyReceipt(receiptId, requestOptions) {
|
|
6381
|
+
return this.post(
|
|
6382
|
+
`/receipts/${encodeURIComponent(receiptId)}/verify`,
|
|
6383
|
+
void 0,
|
|
6384
|
+
requestOptions
|
|
6385
|
+
);
|
|
6386
|
+
}
|
|
6387
|
+
};
|
|
6388
|
+
|
|
6389
|
+
// src/services/bookings.ts
|
|
6390
|
+
var BookingsService = class extends ServiceModule {
|
|
6391
|
+
constructor() {
|
|
6392
|
+
super(...arguments);
|
|
6393
|
+
this.basePath = "/v1/bookings";
|
|
6394
|
+
}
|
|
6395
|
+
/** Create an offered quote for a customer in the active workspace. */
|
|
6396
|
+
async createQuote(input, requestOptions) {
|
|
6397
|
+
return this.post("/quotes", input, requestOptions);
|
|
6398
|
+
}
|
|
6399
|
+
async getQuote(quoteId, requestOptions) {
|
|
6400
|
+
return this._get(`/quotes/${encodeURIComponent(quoteId)}`, requestOptions);
|
|
6401
|
+
}
|
|
6402
|
+
/**
|
|
6403
|
+
* Accept a quote with a verified deposit receipt. Bookings re-verifies the
|
|
6404
|
+
* receipt signature and binding server-side and commits the receipt id/hash
|
|
6405
|
+
* and deposit on the quote.
|
|
6406
|
+
*/
|
|
6407
|
+
async acceptQuote(quoteId, input, requestOptions) {
|
|
6408
|
+
return this.post(`/quotes/${encodeURIComponent(quoteId)}/accept`, input, requestOptions);
|
|
6409
|
+
}
|
|
6410
|
+
async getCustomerStats(customerRef, requestOptions) {
|
|
6411
|
+
return this._get(`/customers/${encodeURIComponent(customerRef)}/stats`, requestOptions);
|
|
6412
|
+
}
|
|
6413
|
+
/** Host/admin: mark a booking completed (maintains the customer stats projection). */
|
|
6414
|
+
async completeBooking(bookingId, reason, requestOptions) {
|
|
6415
|
+
return this.post(
|
|
6416
|
+
`/dashboard/bookings/${encodeURIComponent(bookingId)}/complete`,
|
|
6417
|
+
{ reason },
|
|
6418
|
+
requestOptions
|
|
6419
|
+
);
|
|
6420
|
+
}
|
|
6421
|
+
/** Host/admin: mark a booking as a no-show (maintains the customer stats projection). */
|
|
6422
|
+
async markNoShow(bookingId, reason, requestOptions) {
|
|
6423
|
+
return this.post(
|
|
6424
|
+
`/dashboard/bookings/${encodeURIComponent(bookingId)}/no-show`,
|
|
6425
|
+
{ reason },
|
|
6426
|
+
requestOptions
|
|
6427
|
+
);
|
|
6428
|
+
}
|
|
6429
|
+
};
|
|
6430
|
+
|
|
6338
6431
|
// src/services/permissions.ts
|
|
6339
6432
|
function canPerform(matrix, resource, action) {
|
|
6340
6433
|
if (!matrix) return false;
|
|
@@ -6695,6 +6788,72 @@ var ListingsService = class extends ServiceModule {
|
|
|
6695
6788
|
}
|
|
6696
6789
|
};
|
|
6697
6790
|
|
|
6791
|
+
// src/services/polls.ts
|
|
6792
|
+
var PollsService = class extends ServiceModule {
|
|
6793
|
+
constructor() {
|
|
6794
|
+
super(...arguments);
|
|
6795
|
+
this.basePath = "/v1/polls";
|
|
6796
|
+
}
|
|
6797
|
+
async create(data, options) {
|
|
6798
|
+
return this.post("/manage", data, options);
|
|
6799
|
+
}
|
|
6800
|
+
async list(params, options) {
|
|
6801
|
+
return this._get(this.withQuery("/manage", params), options);
|
|
6802
|
+
}
|
|
6803
|
+
async get(id, options) {
|
|
6804
|
+
return this._get(`/manage/${encodeURIComponent(id)}`, options);
|
|
6805
|
+
}
|
|
6806
|
+
async update(id, data, options) {
|
|
6807
|
+
return this.patch(`/manage/${encodeURIComponent(id)}`, data, options);
|
|
6808
|
+
}
|
|
6809
|
+
async publish(id, options) {
|
|
6810
|
+
return this.post(`/manage/${encodeURIComponent(id)}/publish`, {}, options);
|
|
6811
|
+
}
|
|
6812
|
+
async close(id, options) {
|
|
6813
|
+
return this.post(`/manage/${encodeURIComponent(id)}/close`, {}, options);
|
|
6814
|
+
}
|
|
6815
|
+
async listPublic(params, options) {
|
|
6816
|
+
return this._get(this.withQuery("/public", params), options);
|
|
6817
|
+
}
|
|
6818
|
+
async getPublic(slug, params, options) {
|
|
6819
|
+
return this._get(
|
|
6820
|
+
this.withQuery(`/public/${encodeURIComponent(slug)}`, params),
|
|
6821
|
+
options
|
|
6822
|
+
);
|
|
6823
|
+
}
|
|
6824
|
+
async vote(slug, choiceId, voterKey, options) {
|
|
6825
|
+
return this.post(
|
|
6826
|
+
`/public/${encodeURIComponent(slug)}/votes`,
|
|
6827
|
+
{
|
|
6828
|
+
choice_id: choiceId,
|
|
6829
|
+
voter_key: voterKey
|
|
6830
|
+
},
|
|
6831
|
+
options
|
|
6832
|
+
);
|
|
6833
|
+
}
|
|
6834
|
+
};
|
|
6835
|
+
var VOTER_KEY_STORAGE = "sm_poll_voter_key";
|
|
6836
|
+
function pollVoterKey(storage) {
|
|
6837
|
+
const target = storage ?? (typeof localStorage === "undefined" ? void 0 : localStorage);
|
|
6838
|
+
const existing = target?.getItem(VOTER_KEY_STORAGE);
|
|
6839
|
+
if (existing && /^[A-Za-z0-9_-]{32,128}$/.test(existing)) return existing;
|
|
6840
|
+
const bytes = new Uint8Array(32);
|
|
6841
|
+
const cryptoRef = typeof crypto !== "undefined" ? crypto : void 0;
|
|
6842
|
+
if (!cryptoRef?.getRandomValues) {
|
|
6843
|
+
throw new Error("A browser crypto source is required to create a voter key.");
|
|
6844
|
+
}
|
|
6845
|
+
cryptoRef.getRandomValues(bytes);
|
|
6846
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
6847
|
+
let key = "";
|
|
6848
|
+
for (const byte of bytes) key += alphabet[byte % alphabet.length];
|
|
6849
|
+
target?.setItem(VOTER_KEY_STORAGE, key);
|
|
6850
|
+
return key;
|
|
6851
|
+
}
|
|
6852
|
+
function pollSharePercent(votes, total) {
|
|
6853
|
+
if (!Number.isFinite(votes) || !Number.isFinite(total) || total <= 0 || votes <= 0) return 0;
|
|
6854
|
+
return Math.floor(votes * 100 / total);
|
|
6855
|
+
}
|
|
6856
|
+
|
|
6698
6857
|
// src/services/events.ts
|
|
6699
6858
|
var EventsService = class extends ServiceModule {
|
|
6700
6859
|
constructor() {
|
|
@@ -8640,6 +8799,8 @@ var ScaleMule = class {
|
|
|
8640
8799
|
this.communication = new CommunicationService(this._client);
|
|
8641
8800
|
this.notifications = new NotificationsService(this._client);
|
|
8642
8801
|
this.scheduler = new SchedulerService(this._client);
|
|
8802
|
+
this.decisions = new DecisionsService(this._client);
|
|
8803
|
+
this.bookings = new BookingsService(this._client);
|
|
8643
8804
|
this.permissions = new PermissionsService(this._client);
|
|
8644
8805
|
this.workspaces = new WorkspacesService(this._client);
|
|
8645
8806
|
this.accounts = new AccountsService(this._client);
|
|
@@ -8652,6 +8813,7 @@ var ScaleMule = class {
|
|
|
8652
8813
|
this.webhooks = new WebhooksService(this._client);
|
|
8653
8814
|
this.leaderboard = new LeaderboardService(this._client);
|
|
8654
8815
|
this.listings = new ListingsService(this._client);
|
|
8816
|
+
this.polls = new PollsService(this._client);
|
|
8655
8817
|
this.events = new EventsService(this._client);
|
|
8656
8818
|
this.graph = new GraphService(this._client);
|
|
8657
8819
|
this.functions = new FunctionsService(this._client);
|
|
@@ -8804,6 +8966,7 @@ export {
|
|
|
8804
8966
|
AudioService,
|
|
8805
8967
|
AuthService,
|
|
8806
8968
|
BillingService,
|
|
8969
|
+
BookingsService,
|
|
8807
8970
|
CacheService,
|
|
8808
8971
|
CatalogService,
|
|
8809
8972
|
ChatService,
|
|
@@ -8812,6 +8975,7 @@ export {
|
|
|
8812
8975
|
ConferenceService,
|
|
8813
8976
|
CreatorMakerService,
|
|
8814
8977
|
DataService,
|
|
8978
|
+
DecisionsService,
|
|
8815
8979
|
ErrorCodes,
|
|
8816
8980
|
EventsService,
|
|
8817
8981
|
FlagContentService,
|
|
@@ -8832,6 +8996,7 @@ export {
|
|
|
8832
8996
|
PHOTO_BREAKPOINTS,
|
|
8833
8997
|
PermissionsService,
|
|
8834
8998
|
PhotoService,
|
|
8999
|
+
PollsService,
|
|
8835
9000
|
QueueService,
|
|
8836
9001
|
RealtimeService,
|
|
8837
9002
|
ReferralsService,
|
|
@@ -8874,6 +9039,8 @@ export {
|
|
|
8874
9039
|
isValidE164Phone,
|
|
8875
9040
|
normalizeAndValidatePhone,
|
|
8876
9041
|
normalizePhoneNumber,
|
|
9042
|
+
pollSharePercent,
|
|
9043
|
+
pollVoterKey,
|
|
8877
9044
|
readAnonymousId,
|
|
8878
9045
|
resolveStrategy,
|
|
8879
9046
|
uploadMultipartToS3,
|