@scalemule/sdk 0.0.64 → 0.0.68
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 +333 -1
- package/dist/index.d.ts +333 -1
- package/dist/index.js +164 -1
- package/dist/index.mjs +159 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -908,6 +908,8 @@ declare class AuthService extends ServiceModule {
|
|
|
908
908
|
session_id?: string;
|
|
909
909
|
}, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
|
|
910
910
|
login(data: {
|
|
911
|
+
challenge_token?: string;
|
|
912
|
+
challenge_code?: string;
|
|
911
913
|
email: string;
|
|
912
914
|
password: string;
|
|
913
915
|
remember_me?: boolean;
|
|
@@ -4298,6 +4300,226 @@ declare class SchedulerService extends ServiceModule {
|
|
|
4298
4300
|
getStats(jobId: string, options?: RequestOptions): Promise<ApiResponse<JobStats>>;
|
|
4299
4301
|
}
|
|
4300
4302
|
|
|
4303
|
+
/**
|
|
4304
|
+
* Decisions Service Module — ScaleMule Business Logic Plane
|
|
4305
|
+
*
|
|
4306
|
+
* Deterministic, explainable business decisions evaluated on the tenant's
|
|
4307
|
+
* active sealed release. Evaluation returns proposed actions and a signed
|
|
4308
|
+
* receipt; it never dispatches side effects.
|
|
4309
|
+
*
|
|
4310
|
+
* Routes (gateway prefix /v1/decisions, evaluate role):
|
|
4311
|
+
* POST /evaluate/{key} → evaluate one decision
|
|
4312
|
+
* POST /evaluate/batch → up to 100 evaluations
|
|
4313
|
+
* GET /receipts/{id} → signed receipt (audience-gated)
|
|
4314
|
+
* POST /receipts/{id}/verify → verify with the receipt-ring public keys
|
|
4315
|
+
*
|
|
4316
|
+
* Workspace scope: pass `headers: { 'x-requested-account-id': accountId }`
|
|
4317
|
+
* (the gateway validates membership and forwards the effective account),
|
|
4318
|
+
* the same convention as other account-scoped services.
|
|
4319
|
+
*/
|
|
4320
|
+
|
|
4321
|
+
type DecisionOutcome = 'value' | 'denied' | 'unavailable';
|
|
4322
|
+
type DecisionTraceLevel = 'none' | 'summary' | 'full';
|
|
4323
|
+
interface DecisionEvaluateOptions {
|
|
4324
|
+
/** Trace verbosity (audience `max_trace` still applies). */
|
|
4325
|
+
trace?: DecisionTraceLevel;
|
|
4326
|
+
/**
|
|
4327
|
+
* Idempotency key: the same key + same inputs replays the stored receipt
|
|
4328
|
+
* (`replayed: true`); the same key with different inputs is a 409
|
|
4329
|
+
* `IDEMPOTENCY_KEY_REUSED`.
|
|
4330
|
+
*/
|
|
4331
|
+
idempotency_key?: string;
|
|
4332
|
+
}
|
|
4333
|
+
interface DecisionReceipt {
|
|
4334
|
+
id: string;
|
|
4335
|
+
content_hash: string;
|
|
4336
|
+
/** Ed25519 signature, hex, over `SM-DECISION-RECEIPT-v1\0` + content_hash. */
|
|
4337
|
+
signature: string;
|
|
4338
|
+
signature_kid: string;
|
|
4339
|
+
issued_at: string;
|
|
4340
|
+
expires_at: string;
|
|
4341
|
+
has_snapshot: boolean;
|
|
4342
|
+
/** The exact signed document — pass it whole to domain services (bookings). */
|
|
4343
|
+
signed_document: Record<string, unknown>;
|
|
4344
|
+
}
|
|
4345
|
+
interface DecisionVersions {
|
|
4346
|
+
release_id: string;
|
|
4347
|
+
release_number?: number;
|
|
4348
|
+
activation_version?: number;
|
|
4349
|
+
registry_revision: number;
|
|
4350
|
+
schema_revision: number;
|
|
4351
|
+
artifact_hash: string;
|
|
4352
|
+
compiler_version: string;
|
|
4353
|
+
evaluator_semantics_version: string;
|
|
4354
|
+
ir_version?: string;
|
|
4355
|
+
}
|
|
4356
|
+
interface DecisionProposedAction {
|
|
4357
|
+
action_key: string;
|
|
4358
|
+
params: Record<string, unknown>;
|
|
4359
|
+
}
|
|
4360
|
+
interface DecisionResult<TValue = unknown> {
|
|
4361
|
+
decision_key: string;
|
|
4362
|
+
outcome: DecisionOutcome;
|
|
4363
|
+
value: TValue | null;
|
|
4364
|
+
reason_codes: string[];
|
|
4365
|
+
violations: {
|
|
4366
|
+
rule_key: string;
|
|
4367
|
+
reason_codes: string[];
|
|
4368
|
+
}[];
|
|
4369
|
+
recommendations: {
|
|
4370
|
+
rule_key: string;
|
|
4371
|
+
reason_codes: string[];
|
|
4372
|
+
}[];
|
|
4373
|
+
proposed_actions: DecisionProposedAction[];
|
|
4374
|
+
versions: DecisionVersions;
|
|
4375
|
+
facts_hash: string;
|
|
4376
|
+
fact_sources: Record<string, string>;
|
|
4377
|
+
trace: Record<string, unknown> | null;
|
|
4378
|
+
receipt: DecisionReceipt | null;
|
|
4379
|
+
record_class: string;
|
|
4380
|
+
replayed: boolean;
|
|
4381
|
+
diverged: boolean;
|
|
4382
|
+
latency_us: number;
|
|
4383
|
+
resolve_us: number;
|
|
4384
|
+
}
|
|
4385
|
+
interface DecisionBatchItem {
|
|
4386
|
+
decision_key: string;
|
|
4387
|
+
inputs: Record<string, unknown>;
|
|
4388
|
+
options?: DecisionEvaluateOptions;
|
|
4389
|
+
}
|
|
4390
|
+
interface DecisionBatchResult {
|
|
4391
|
+
decision_key: string;
|
|
4392
|
+
success: boolean;
|
|
4393
|
+
data?: DecisionResult;
|
|
4394
|
+
error?: string;
|
|
4395
|
+
}
|
|
4396
|
+
/** `appointment.deposit` (home_services pack) result value. */
|
|
4397
|
+
interface AppointmentDepositValue {
|
|
4398
|
+
required: boolean;
|
|
4399
|
+
percent_bps: number;
|
|
4400
|
+
amount_minor: number;
|
|
4401
|
+
}
|
|
4402
|
+
interface ReceiptVerification {
|
|
4403
|
+
receipt_id: string;
|
|
4404
|
+
verified: boolean;
|
|
4405
|
+
error: string | null;
|
|
4406
|
+
content_hash: string;
|
|
4407
|
+
signature_kid: string;
|
|
4408
|
+
expired: boolean;
|
|
4409
|
+
}
|
|
4410
|
+
declare class DecisionsService extends ServiceModule {
|
|
4411
|
+
protected basePath: string;
|
|
4412
|
+
/**
|
|
4413
|
+
* Evaluate a decision on the tenant's active release.
|
|
4414
|
+
*
|
|
4415
|
+
* @example
|
|
4416
|
+
* const { data } = await sm.decisions.evaluate<AppointmentDepositValue>(
|
|
4417
|
+
* 'appointment.deposit',
|
|
4418
|
+
* { appointment: { quote_id }, customer: { ref: customerRef } },
|
|
4419
|
+
* { idempotency_key: `event:${eventId}` },
|
|
4420
|
+
* { headers: { 'x-requested-account-id': accountId } },
|
|
4421
|
+
* );
|
|
4422
|
+
*/
|
|
4423
|
+
evaluate<TValue = unknown>(decisionKey: string, inputs: Record<string, unknown>, options?: DecisionEvaluateOptions, requestOptions?: RequestOptions): Promise<ApiResponse<DecisionResult<TValue>>>;
|
|
4424
|
+
/** Evaluate up to 100 decisions in one call (per-item success/error). */
|
|
4425
|
+
evaluateBatch(items: DecisionBatchItem[], requestOptions?: RequestOptions): Promise<ApiResponse<DecisionBatchResult[]>>;
|
|
4426
|
+
/** Fetch a stored receipt (end users only see their own). */
|
|
4427
|
+
getReceipt(receiptId: string, requestOptions?: RequestOptions): Promise<ApiResponse<Record<string, unknown>>>;
|
|
4428
|
+
/** Server-side verification of a stored receipt against the receipt ring. */
|
|
4429
|
+
verifyReceipt(receiptId: string, requestOptions?: RequestOptions): Promise<ApiResponse<ReceiptVerification>>;
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
/**
|
|
4433
|
+
* Bookings Service Module — quotes, customer stats and booking completion
|
|
4434
|
+
* (the appointment system of record for Business Logic Plane decisions).
|
|
4435
|
+
*
|
|
4436
|
+
* Routes (gateway prefix /v1/bookings):
|
|
4437
|
+
* POST /quotes → create an offered quote (workspace-scoped)
|
|
4438
|
+
* GET /quotes/{id} → get a quote
|
|
4439
|
+
* POST /quotes/{id}/accept → accept with a verified `appointment.deposit` receipt
|
|
4440
|
+
* GET /customers/{ref}/stats → customer stats projection
|
|
4441
|
+
* POST /dashboard/bookings/{id}/complete → mark completed (host/admin; updates stats)
|
|
4442
|
+
* POST /dashboard/bookings/{id}/no-show → mark no-show (host/admin; updates stats)
|
|
4443
|
+
*
|
|
4444
|
+
* Workspace scope: pass `headers: { 'x-requested-account-id': accountId }`.
|
|
4445
|
+
*/
|
|
4446
|
+
|
|
4447
|
+
type QuoteState = 'draft' | 'offered' | 'accepted' | 'expired' | 'cancelled';
|
|
4448
|
+
interface CreateQuoteInput {
|
|
4449
|
+
/** Customer-space / user reference (opaque; also `customer.ref` for decisions). */
|
|
4450
|
+
customer_ref: string;
|
|
4451
|
+
total_minor: number;
|
|
4452
|
+
/** ISO-4217. */
|
|
4453
|
+
currency: string;
|
|
4454
|
+
event_type_id?: string;
|
|
4455
|
+
location_ref?: string;
|
|
4456
|
+
expires_at?: string;
|
|
4457
|
+
metadata?: Record<string, unknown>;
|
|
4458
|
+
}
|
|
4459
|
+
interface QuoteDeposit {
|
|
4460
|
+
required: boolean;
|
|
4461
|
+
amount_minor: number;
|
|
4462
|
+
percent_bps: number;
|
|
4463
|
+
currency: string;
|
|
4464
|
+
receipt_id: string;
|
|
4465
|
+
receipt_hash: string;
|
|
4466
|
+
decided_at: string;
|
|
4467
|
+
}
|
|
4468
|
+
interface Quote {
|
|
4469
|
+
id: string;
|
|
4470
|
+
account_id: string;
|
|
4471
|
+
event_type_id: string | null;
|
|
4472
|
+
customer_ref: string;
|
|
4473
|
+
location_ref: string | null;
|
|
4474
|
+
total_minor: number;
|
|
4475
|
+
currency: string;
|
|
4476
|
+
state: QuoteState;
|
|
4477
|
+
expires_at: string | null;
|
|
4478
|
+
version: number;
|
|
4479
|
+
decision_receipt_id: string | null;
|
|
4480
|
+
decision_receipt_hash: string | null;
|
|
4481
|
+
metadata: (Record<string, unknown> & {
|
|
4482
|
+
deposit?: QuoteDeposit;
|
|
4483
|
+
}) | null;
|
|
4484
|
+
created_at: string;
|
|
4485
|
+
updated_at: string;
|
|
4486
|
+
}
|
|
4487
|
+
interface AcceptQuoteInput {
|
|
4488
|
+
/** The quote version last seen (optimistic concurrency). */
|
|
4489
|
+
expected_version: number;
|
|
4490
|
+
/** The `receipt` object returned by `sm.decisions.evaluate('appointment.deposit', …)`. */
|
|
4491
|
+
decision_receipt: Pick<DecisionReceipt, 'id' | 'content_hash' | 'signature' | 'signature_kid' | 'signed_document'>;
|
|
4492
|
+
}
|
|
4493
|
+
interface CustomerStats {
|
|
4494
|
+
customer_ref: string;
|
|
4495
|
+
completed_count: number;
|
|
4496
|
+
no_show_count: number;
|
|
4497
|
+
cancelled_count: number;
|
|
4498
|
+
last_completed_at: string | null;
|
|
4499
|
+
}
|
|
4500
|
+
interface BookingCompletionResult {
|
|
4501
|
+
ok: boolean;
|
|
4502
|
+
status: 'completed' | 'no_show';
|
|
4503
|
+
customer_stats: CustomerStats | null;
|
|
4504
|
+
}
|
|
4505
|
+
declare class BookingsService extends ServiceModule {
|
|
4506
|
+
protected basePath: string;
|
|
4507
|
+
/** Create an offered quote for a customer in the active workspace. */
|
|
4508
|
+
createQuote(input: CreateQuoteInput, requestOptions?: RequestOptions): Promise<ApiResponse<Quote>>;
|
|
4509
|
+
getQuote(quoteId: string, requestOptions?: RequestOptions): Promise<ApiResponse<Quote>>;
|
|
4510
|
+
/**
|
|
4511
|
+
* Accept a quote with a verified deposit receipt. Bookings re-verifies the
|
|
4512
|
+
* receipt signature and binding server-side and commits the receipt id/hash
|
|
4513
|
+
* and deposit on the quote.
|
|
4514
|
+
*/
|
|
4515
|
+
acceptQuote(quoteId: string, input: AcceptQuoteInput, requestOptions?: RequestOptions): Promise<ApiResponse<Quote>>;
|
|
4516
|
+
getCustomerStats(customerRef: string, requestOptions?: RequestOptions): Promise<ApiResponse<CustomerStats>>;
|
|
4517
|
+
/** Host/admin: mark a booking completed (maintains the customer stats projection). */
|
|
4518
|
+
completeBooking(bookingId: string, reason?: string, requestOptions?: RequestOptions): Promise<ApiResponse<BookingCompletionResult>>;
|
|
4519
|
+
/** Host/admin: mark a booking as a no-show (maintains the customer stats projection). */
|
|
4520
|
+
markNoShow(bookingId: string, reason?: string, requestOptions?: RequestOptions): Promise<ApiResponse<BookingCompletionResult>>;
|
|
4521
|
+
}
|
|
4522
|
+
|
|
4301
4523
|
/**
|
|
4302
4524
|
* Permissions Service Module
|
|
4303
4525
|
*
|
|
@@ -4863,6 +5085,113 @@ declare class ListingsService extends ServiceModule {
|
|
|
4863
5085
|
getListing(id: string): Promise<ApiResponse<Listing>>;
|
|
4864
5086
|
}
|
|
4865
5087
|
|
|
5088
|
+
/**
|
|
5089
|
+
* Polls Service Module
|
|
5090
|
+
*
|
|
5091
|
+
* Reader polls for any ScaleMule application. A poll can carry text, an image,
|
|
5092
|
+
* a video, or audio on the question and on each choice. Totals are public.
|
|
5093
|
+
* One account, or one device voter key, holds one ballot and may change it.
|
|
5094
|
+
*
|
|
5095
|
+
* Routes:
|
|
5096
|
+
* POST /manage → create
|
|
5097
|
+
* GET /manage → list, including drafts
|
|
5098
|
+
* GET /manage/{id} → staff read
|
|
5099
|
+
* PATCH /manage/{id} → update
|
|
5100
|
+
* POST /manage/{id}/publish → open
|
|
5101
|
+
* POST /manage/{id}/close → close
|
|
5102
|
+
* GET /public → published polls
|
|
5103
|
+
* GET /public/{slug} → one published poll
|
|
5104
|
+
* POST /public/{slug}/votes → cast or change a ballot
|
|
5105
|
+
*/
|
|
5106
|
+
|
|
5107
|
+
type PollMediaKind = 'text' | 'image' | 'video' | 'audio';
|
|
5108
|
+
type PollBallot = 'account' | 'key';
|
|
5109
|
+
type PollStatus = 'draft' | 'open' | 'closed' | 'archived';
|
|
5110
|
+
interface PollMedia {
|
|
5111
|
+
kind: PollMediaKind;
|
|
5112
|
+
url?: string;
|
|
5113
|
+
text?: string;
|
|
5114
|
+
alt?: string;
|
|
5115
|
+
storage_id?: string;
|
|
5116
|
+
duration_ms?: number;
|
|
5117
|
+
}
|
|
5118
|
+
interface PollChoiceInput {
|
|
5119
|
+
id: string;
|
|
5120
|
+
label: string;
|
|
5121
|
+
media?: PollMedia[];
|
|
5122
|
+
}
|
|
5123
|
+
interface PollChoice extends PollChoiceInput {
|
|
5124
|
+
media: PollMedia[];
|
|
5125
|
+
votes: number;
|
|
5126
|
+
}
|
|
5127
|
+
interface Poll {
|
|
5128
|
+
id: string;
|
|
5129
|
+
slug: string;
|
|
5130
|
+
question: string;
|
|
5131
|
+
description?: string;
|
|
5132
|
+
media: PollMedia[];
|
|
5133
|
+
choices: PollChoice[];
|
|
5134
|
+
ballot: PollBallot;
|
|
5135
|
+
status: PollStatus;
|
|
5136
|
+
opens_at?: string;
|
|
5137
|
+
closes_at?: string;
|
|
5138
|
+
subject_type?: string;
|
|
5139
|
+
subject_id?: string;
|
|
5140
|
+
total_votes: number;
|
|
5141
|
+
votable: boolean;
|
|
5142
|
+
my_choice_id?: string;
|
|
5143
|
+
}
|
|
5144
|
+
interface CreatePollInput {
|
|
5145
|
+
slug: string;
|
|
5146
|
+
question: string;
|
|
5147
|
+
description?: string;
|
|
5148
|
+
media?: PollMedia[];
|
|
5149
|
+
choices: PollChoiceInput[];
|
|
5150
|
+
ballot?: PollBallot;
|
|
5151
|
+
opens_at?: string;
|
|
5152
|
+
closes_at?: string;
|
|
5153
|
+
subject_type?: string;
|
|
5154
|
+
subject_id?: string;
|
|
5155
|
+
}
|
|
5156
|
+
interface UpdatePollInput {
|
|
5157
|
+
question?: string;
|
|
5158
|
+
description?: string;
|
|
5159
|
+
media?: PollMedia[];
|
|
5160
|
+
choices?: PollChoiceInput[];
|
|
5161
|
+
opens_at?: string;
|
|
5162
|
+
closes_at?: string;
|
|
5163
|
+
subject_type?: string;
|
|
5164
|
+
subject_id?: string;
|
|
5165
|
+
clear_description?: boolean;
|
|
5166
|
+
clear_schedule?: boolean;
|
|
5167
|
+
clear_subject?: boolean;
|
|
5168
|
+
}
|
|
5169
|
+
interface PollListOptions {
|
|
5170
|
+
status?: PollStatus;
|
|
5171
|
+
subject_type?: string;
|
|
5172
|
+
subject_id?: string;
|
|
5173
|
+
limit?: number;
|
|
5174
|
+
voter_key?: string;
|
|
5175
|
+
}
|
|
5176
|
+
declare class PollsService extends ServiceModule {
|
|
5177
|
+
protected basePath: string;
|
|
5178
|
+
create(data: CreatePollInput, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5179
|
+
list(params?: PollListOptions, options?: RequestOptions): Promise<ApiResponse<Poll[]>>;
|
|
5180
|
+
get(id: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5181
|
+
update(id: string, data: UpdatePollInput, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5182
|
+
publish(id: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5183
|
+
close(id: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5184
|
+
listPublic(params?: PollListOptions, options?: RequestOptions): Promise<ApiResponse<Poll[]>>;
|
|
5185
|
+
getPublic(slug: string, params?: {
|
|
5186
|
+
voter_key?: string;
|
|
5187
|
+
}, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5188
|
+
vote(slug: string, choiceId: string, voterKey?: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5189
|
+
}
|
|
5190
|
+
/** Stable ASCII voter key for `ballot: "key"` polls. Pass it to getPublic and vote. */
|
|
5191
|
+
declare function pollVoterKey(storage?: Pick<Storage, 'getItem' | 'setItem'>): string;
|
|
5192
|
+
/** Whole-number percent from a choice count. The last displayed point can be short of 100. */
|
|
5193
|
+
declare function pollSharePercent(votes: number, total: number): number;
|
|
5194
|
+
|
|
4866
5195
|
/**
|
|
4867
5196
|
* Events Service Module
|
|
4868
5197
|
*
|
|
@@ -7342,6 +7671,8 @@ declare class ScaleMule {
|
|
|
7342
7671
|
readonly communication: CommunicationService;
|
|
7343
7672
|
readonly notifications: NotificationsService;
|
|
7344
7673
|
readonly scheduler: SchedulerService;
|
|
7674
|
+
readonly decisions: DecisionsService;
|
|
7675
|
+
readonly bookings: BookingsService;
|
|
7345
7676
|
readonly permissions: PermissionsService;
|
|
7346
7677
|
readonly workspaces: WorkspacesService;
|
|
7347
7678
|
/** @deprecated Use `workspaces` instead */
|
|
@@ -7356,6 +7687,7 @@ declare class ScaleMule {
|
|
|
7356
7687
|
readonly webhooks: WebhooksService;
|
|
7357
7688
|
readonly leaderboard: LeaderboardService;
|
|
7358
7689
|
readonly listings: ListingsService;
|
|
7690
|
+
readonly polls: PollsService;
|
|
7359
7691
|
readonly events: EventsService;
|
|
7360
7692
|
readonly graph: GraphService;
|
|
7361
7693
|
readonly functions: FunctionsService;
|
|
@@ -7437,4 +7769,4 @@ declare class ScaleMule {
|
|
|
7437
7769
|
getClient(): ScaleMuleClient;
|
|
7438
7770
|
}
|
|
7439
7771
|
|
|
7440
|
-
export { type AccountBalance, type AccountSwitcherPrivacy, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AudioRegisterResult, AudioService, type AudioUploadViaStorageResult, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type ContentPolicy, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateLeadInput, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FileStatus, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, LEGACY_ANONYMOUS_ID_KEYS, type Lead, type Leaderboard, type LeaderboardEntry, LeaderboardService, LeadsService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, MEDIA_PRESETS, type MediaAsset, type MediaKind, type MediaManifest, type MediaManifestOptions, type MediaPolicy, type MediaPreset, type MediaPresetSpec, MediaService, type MediaUploadEvent, type MediaUploadOptions, type MediaUploadPhase, type MediaUploadResult, type MessageCallback, type MessagePin, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type PinnedMessagesResponse, type Pipeline, type PipelineVersion, type Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, STORAGE_KEYS, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SearchUsersParams, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPolicyAction, type SocialPolicyBatchDecisionItem, type SocialPolicyBatchDecisionRequest, type SocialPolicyBatchDecisionResponse, type SocialPolicyBatchDecisionTarget, type SocialPolicyBlockRequest, type SocialPolicyContactRequest, type SocialPolicyContactRequestListItem, type SocialPolicyContactRequestQuery, type SocialPolicyContactRequestRequest, type SocialPolicyContext, type SocialPolicyDecision, type SocialPolicyDecisionLimits, type SocialPolicyDecisionRequest, type SocialPolicyDecisionResponse, type SocialPolicyIdentity, type SocialPolicyIdentityType, type SocialPolicyMuteRequest, type SocialPolicyPolicyPack, type SocialPolicyRelationship, type SocialPolicyRelationshipQuery, type SocialPolicyRelationshipRequest, type SocialPolicyReportRequest, SocialPolicyService, type SocialPolicySettings, type SocialPolicyUnblockRequest, type SocialPolicyUpdateSettingsRequest, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StorageSettings, type StrategyResult, type StylePreset, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type TtsAccessMode, type TtsAudioInfo, type TtsJobStatus, type TtsListVoicesParams, TtsService, type TtsSpeechMetadata, type TtsSpeechProfile, type TtsSynthesizeParams, type TtsSynthesizeQueuedResult, type TtsSynthesizeReadyResult, type TtsSynthesizeResult, type TtsVoice, type TtsVoicesResponse, type UnreadCountResponse, type UpdateFlagRequest, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type VoteState, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type WebrtcStats, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, ensureAnonymousId, extractClientContext, generateAnonymousId, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, readAnonymousId, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
|
7772
|
+
export { type AcceptQuoteInput, type AccountBalance, type AccountSwitcherPrivacy, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type AppointmentDepositValue, type Attachment, type Attendee, type AudioRegisterResult, AudioService, type AudioUploadViaStorageResult, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type BookingCompletionResult, BookingsService, type CacheEntry, CacheService, type CalendarEvent, type CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type ContentPolicy, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateLeadInput, type CreatePollInput, type CreateQuoteInput, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type CustomerStats, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DecisionBatchItem, type DecisionBatchResult, type DecisionEvaluateOptions, type DecisionOutcome, type DecisionProposedAction, type DecisionReceipt, type DecisionResult, type DecisionTraceLevel, type DecisionVersions, DecisionsService, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FileStatus, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, LEGACY_ANONYMOUS_ID_KEYS, type Lead, type Leaderboard, type LeaderboardEntry, LeaderboardService, LeadsService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, MEDIA_PRESETS, type MediaAsset, type MediaKind, type MediaManifest, type MediaManifestOptions, type MediaPolicy, type MediaPreset, type MediaPresetSpec, MediaService, type MediaUploadEvent, type MediaUploadOptions, type MediaUploadPhase, type MediaUploadResult, type MessageCallback, type MessagePin, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type PinnedMessagesResponse, type Pipeline, type PipelineVersion, type Policy, type Poll, type PollBallot, type PollChoice, type PollChoiceInput, type PollListOptions, type PollMedia, type PollMediaKind, type PollStatus, PollsService, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type Quote, type QuoteDeposit, type QuoteState, type ReadStatus, RealtimeService, type ReceiptVerification, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, STORAGE_KEYS, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SearchUsersParams, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPolicyAction, type SocialPolicyBatchDecisionItem, type SocialPolicyBatchDecisionRequest, type SocialPolicyBatchDecisionResponse, type SocialPolicyBatchDecisionTarget, type SocialPolicyBlockRequest, type SocialPolicyContactRequest, type SocialPolicyContactRequestListItem, type SocialPolicyContactRequestQuery, type SocialPolicyContactRequestRequest, type SocialPolicyContext, type SocialPolicyDecision, type SocialPolicyDecisionLimits, type SocialPolicyDecisionRequest, type SocialPolicyDecisionResponse, type SocialPolicyIdentity, type SocialPolicyIdentityType, type SocialPolicyMuteRequest, type SocialPolicyPolicyPack, type SocialPolicyRelationship, type SocialPolicyRelationshipQuery, type SocialPolicyRelationshipRequest, type SocialPolicyReportRequest, SocialPolicyService, type SocialPolicySettings, type SocialPolicyUnblockRequest, type SocialPolicyUpdateSettingsRequest, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StorageSettings, type StrategyResult, type StylePreset, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type TtsAccessMode, type TtsAudioInfo, type TtsJobStatus, type TtsListVoicesParams, TtsService, type TtsSpeechMetadata, type TtsSpeechProfile, type TtsSynthesizeParams, type TtsSynthesizeQueuedResult, type TtsSynthesizeReadyResult, type TtsSynthesizeResult, type TtsVoice, type TtsVoicesResponse, type UnreadCountResponse, type UpdateFlagRequest, type UpdatePollInput, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type VoteState, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type WebrtcStats, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, ensureAnonymousId, extractClientContext, generateAnonymousId, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, pollSharePercent, pollVoterKey, readAnonymousId, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
package/dist/index.d.ts
CHANGED
|
@@ -908,6 +908,8 @@ declare class AuthService extends ServiceModule {
|
|
|
908
908
|
session_id?: string;
|
|
909
909
|
}, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
|
|
910
910
|
login(data: {
|
|
911
|
+
challenge_token?: string;
|
|
912
|
+
challenge_code?: string;
|
|
911
913
|
email: string;
|
|
912
914
|
password: string;
|
|
913
915
|
remember_me?: boolean;
|
|
@@ -4298,6 +4300,226 @@ declare class SchedulerService extends ServiceModule {
|
|
|
4298
4300
|
getStats(jobId: string, options?: RequestOptions): Promise<ApiResponse<JobStats>>;
|
|
4299
4301
|
}
|
|
4300
4302
|
|
|
4303
|
+
/**
|
|
4304
|
+
* Decisions Service Module — ScaleMule Business Logic Plane
|
|
4305
|
+
*
|
|
4306
|
+
* Deterministic, explainable business decisions evaluated on the tenant's
|
|
4307
|
+
* active sealed release. Evaluation returns proposed actions and a signed
|
|
4308
|
+
* receipt; it never dispatches side effects.
|
|
4309
|
+
*
|
|
4310
|
+
* Routes (gateway prefix /v1/decisions, evaluate role):
|
|
4311
|
+
* POST /evaluate/{key} → evaluate one decision
|
|
4312
|
+
* POST /evaluate/batch → up to 100 evaluations
|
|
4313
|
+
* GET /receipts/{id} → signed receipt (audience-gated)
|
|
4314
|
+
* POST /receipts/{id}/verify → verify with the receipt-ring public keys
|
|
4315
|
+
*
|
|
4316
|
+
* Workspace scope: pass `headers: { 'x-requested-account-id': accountId }`
|
|
4317
|
+
* (the gateway validates membership and forwards the effective account),
|
|
4318
|
+
* the same convention as other account-scoped services.
|
|
4319
|
+
*/
|
|
4320
|
+
|
|
4321
|
+
type DecisionOutcome = 'value' | 'denied' | 'unavailable';
|
|
4322
|
+
type DecisionTraceLevel = 'none' | 'summary' | 'full';
|
|
4323
|
+
interface DecisionEvaluateOptions {
|
|
4324
|
+
/** Trace verbosity (audience `max_trace` still applies). */
|
|
4325
|
+
trace?: DecisionTraceLevel;
|
|
4326
|
+
/**
|
|
4327
|
+
* Idempotency key: the same key + same inputs replays the stored receipt
|
|
4328
|
+
* (`replayed: true`); the same key with different inputs is a 409
|
|
4329
|
+
* `IDEMPOTENCY_KEY_REUSED`.
|
|
4330
|
+
*/
|
|
4331
|
+
idempotency_key?: string;
|
|
4332
|
+
}
|
|
4333
|
+
interface DecisionReceipt {
|
|
4334
|
+
id: string;
|
|
4335
|
+
content_hash: string;
|
|
4336
|
+
/** Ed25519 signature, hex, over `SM-DECISION-RECEIPT-v1\0` + content_hash. */
|
|
4337
|
+
signature: string;
|
|
4338
|
+
signature_kid: string;
|
|
4339
|
+
issued_at: string;
|
|
4340
|
+
expires_at: string;
|
|
4341
|
+
has_snapshot: boolean;
|
|
4342
|
+
/** The exact signed document — pass it whole to domain services (bookings). */
|
|
4343
|
+
signed_document: Record<string, unknown>;
|
|
4344
|
+
}
|
|
4345
|
+
interface DecisionVersions {
|
|
4346
|
+
release_id: string;
|
|
4347
|
+
release_number?: number;
|
|
4348
|
+
activation_version?: number;
|
|
4349
|
+
registry_revision: number;
|
|
4350
|
+
schema_revision: number;
|
|
4351
|
+
artifact_hash: string;
|
|
4352
|
+
compiler_version: string;
|
|
4353
|
+
evaluator_semantics_version: string;
|
|
4354
|
+
ir_version?: string;
|
|
4355
|
+
}
|
|
4356
|
+
interface DecisionProposedAction {
|
|
4357
|
+
action_key: string;
|
|
4358
|
+
params: Record<string, unknown>;
|
|
4359
|
+
}
|
|
4360
|
+
interface DecisionResult<TValue = unknown> {
|
|
4361
|
+
decision_key: string;
|
|
4362
|
+
outcome: DecisionOutcome;
|
|
4363
|
+
value: TValue | null;
|
|
4364
|
+
reason_codes: string[];
|
|
4365
|
+
violations: {
|
|
4366
|
+
rule_key: string;
|
|
4367
|
+
reason_codes: string[];
|
|
4368
|
+
}[];
|
|
4369
|
+
recommendations: {
|
|
4370
|
+
rule_key: string;
|
|
4371
|
+
reason_codes: string[];
|
|
4372
|
+
}[];
|
|
4373
|
+
proposed_actions: DecisionProposedAction[];
|
|
4374
|
+
versions: DecisionVersions;
|
|
4375
|
+
facts_hash: string;
|
|
4376
|
+
fact_sources: Record<string, string>;
|
|
4377
|
+
trace: Record<string, unknown> | null;
|
|
4378
|
+
receipt: DecisionReceipt | null;
|
|
4379
|
+
record_class: string;
|
|
4380
|
+
replayed: boolean;
|
|
4381
|
+
diverged: boolean;
|
|
4382
|
+
latency_us: number;
|
|
4383
|
+
resolve_us: number;
|
|
4384
|
+
}
|
|
4385
|
+
interface DecisionBatchItem {
|
|
4386
|
+
decision_key: string;
|
|
4387
|
+
inputs: Record<string, unknown>;
|
|
4388
|
+
options?: DecisionEvaluateOptions;
|
|
4389
|
+
}
|
|
4390
|
+
interface DecisionBatchResult {
|
|
4391
|
+
decision_key: string;
|
|
4392
|
+
success: boolean;
|
|
4393
|
+
data?: DecisionResult;
|
|
4394
|
+
error?: string;
|
|
4395
|
+
}
|
|
4396
|
+
/** `appointment.deposit` (home_services pack) result value. */
|
|
4397
|
+
interface AppointmentDepositValue {
|
|
4398
|
+
required: boolean;
|
|
4399
|
+
percent_bps: number;
|
|
4400
|
+
amount_minor: number;
|
|
4401
|
+
}
|
|
4402
|
+
interface ReceiptVerification {
|
|
4403
|
+
receipt_id: string;
|
|
4404
|
+
verified: boolean;
|
|
4405
|
+
error: string | null;
|
|
4406
|
+
content_hash: string;
|
|
4407
|
+
signature_kid: string;
|
|
4408
|
+
expired: boolean;
|
|
4409
|
+
}
|
|
4410
|
+
declare class DecisionsService extends ServiceModule {
|
|
4411
|
+
protected basePath: string;
|
|
4412
|
+
/**
|
|
4413
|
+
* Evaluate a decision on the tenant's active release.
|
|
4414
|
+
*
|
|
4415
|
+
* @example
|
|
4416
|
+
* const { data } = await sm.decisions.evaluate<AppointmentDepositValue>(
|
|
4417
|
+
* 'appointment.deposit',
|
|
4418
|
+
* { appointment: { quote_id }, customer: { ref: customerRef } },
|
|
4419
|
+
* { idempotency_key: `event:${eventId}` },
|
|
4420
|
+
* { headers: { 'x-requested-account-id': accountId } },
|
|
4421
|
+
* );
|
|
4422
|
+
*/
|
|
4423
|
+
evaluate<TValue = unknown>(decisionKey: string, inputs: Record<string, unknown>, options?: DecisionEvaluateOptions, requestOptions?: RequestOptions): Promise<ApiResponse<DecisionResult<TValue>>>;
|
|
4424
|
+
/** Evaluate up to 100 decisions in one call (per-item success/error). */
|
|
4425
|
+
evaluateBatch(items: DecisionBatchItem[], requestOptions?: RequestOptions): Promise<ApiResponse<DecisionBatchResult[]>>;
|
|
4426
|
+
/** Fetch a stored receipt (end users only see their own). */
|
|
4427
|
+
getReceipt(receiptId: string, requestOptions?: RequestOptions): Promise<ApiResponse<Record<string, unknown>>>;
|
|
4428
|
+
/** Server-side verification of a stored receipt against the receipt ring. */
|
|
4429
|
+
verifyReceipt(receiptId: string, requestOptions?: RequestOptions): Promise<ApiResponse<ReceiptVerification>>;
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
/**
|
|
4433
|
+
* Bookings Service Module — quotes, customer stats and booking completion
|
|
4434
|
+
* (the appointment system of record for Business Logic Plane decisions).
|
|
4435
|
+
*
|
|
4436
|
+
* Routes (gateway prefix /v1/bookings):
|
|
4437
|
+
* POST /quotes → create an offered quote (workspace-scoped)
|
|
4438
|
+
* GET /quotes/{id} → get a quote
|
|
4439
|
+
* POST /quotes/{id}/accept → accept with a verified `appointment.deposit` receipt
|
|
4440
|
+
* GET /customers/{ref}/stats → customer stats projection
|
|
4441
|
+
* POST /dashboard/bookings/{id}/complete → mark completed (host/admin; updates stats)
|
|
4442
|
+
* POST /dashboard/bookings/{id}/no-show → mark no-show (host/admin; updates stats)
|
|
4443
|
+
*
|
|
4444
|
+
* Workspace scope: pass `headers: { 'x-requested-account-id': accountId }`.
|
|
4445
|
+
*/
|
|
4446
|
+
|
|
4447
|
+
type QuoteState = 'draft' | 'offered' | 'accepted' | 'expired' | 'cancelled';
|
|
4448
|
+
interface CreateQuoteInput {
|
|
4449
|
+
/** Customer-space / user reference (opaque; also `customer.ref` for decisions). */
|
|
4450
|
+
customer_ref: string;
|
|
4451
|
+
total_minor: number;
|
|
4452
|
+
/** ISO-4217. */
|
|
4453
|
+
currency: string;
|
|
4454
|
+
event_type_id?: string;
|
|
4455
|
+
location_ref?: string;
|
|
4456
|
+
expires_at?: string;
|
|
4457
|
+
metadata?: Record<string, unknown>;
|
|
4458
|
+
}
|
|
4459
|
+
interface QuoteDeposit {
|
|
4460
|
+
required: boolean;
|
|
4461
|
+
amount_minor: number;
|
|
4462
|
+
percent_bps: number;
|
|
4463
|
+
currency: string;
|
|
4464
|
+
receipt_id: string;
|
|
4465
|
+
receipt_hash: string;
|
|
4466
|
+
decided_at: string;
|
|
4467
|
+
}
|
|
4468
|
+
interface Quote {
|
|
4469
|
+
id: string;
|
|
4470
|
+
account_id: string;
|
|
4471
|
+
event_type_id: string | null;
|
|
4472
|
+
customer_ref: string;
|
|
4473
|
+
location_ref: string | null;
|
|
4474
|
+
total_minor: number;
|
|
4475
|
+
currency: string;
|
|
4476
|
+
state: QuoteState;
|
|
4477
|
+
expires_at: string | null;
|
|
4478
|
+
version: number;
|
|
4479
|
+
decision_receipt_id: string | null;
|
|
4480
|
+
decision_receipt_hash: string | null;
|
|
4481
|
+
metadata: (Record<string, unknown> & {
|
|
4482
|
+
deposit?: QuoteDeposit;
|
|
4483
|
+
}) | null;
|
|
4484
|
+
created_at: string;
|
|
4485
|
+
updated_at: string;
|
|
4486
|
+
}
|
|
4487
|
+
interface AcceptQuoteInput {
|
|
4488
|
+
/** The quote version last seen (optimistic concurrency). */
|
|
4489
|
+
expected_version: number;
|
|
4490
|
+
/** The `receipt` object returned by `sm.decisions.evaluate('appointment.deposit', …)`. */
|
|
4491
|
+
decision_receipt: Pick<DecisionReceipt, 'id' | 'content_hash' | 'signature' | 'signature_kid' | 'signed_document'>;
|
|
4492
|
+
}
|
|
4493
|
+
interface CustomerStats {
|
|
4494
|
+
customer_ref: string;
|
|
4495
|
+
completed_count: number;
|
|
4496
|
+
no_show_count: number;
|
|
4497
|
+
cancelled_count: number;
|
|
4498
|
+
last_completed_at: string | null;
|
|
4499
|
+
}
|
|
4500
|
+
interface BookingCompletionResult {
|
|
4501
|
+
ok: boolean;
|
|
4502
|
+
status: 'completed' | 'no_show';
|
|
4503
|
+
customer_stats: CustomerStats | null;
|
|
4504
|
+
}
|
|
4505
|
+
declare class BookingsService extends ServiceModule {
|
|
4506
|
+
protected basePath: string;
|
|
4507
|
+
/** Create an offered quote for a customer in the active workspace. */
|
|
4508
|
+
createQuote(input: CreateQuoteInput, requestOptions?: RequestOptions): Promise<ApiResponse<Quote>>;
|
|
4509
|
+
getQuote(quoteId: string, requestOptions?: RequestOptions): Promise<ApiResponse<Quote>>;
|
|
4510
|
+
/**
|
|
4511
|
+
* Accept a quote with a verified deposit receipt. Bookings re-verifies the
|
|
4512
|
+
* receipt signature and binding server-side and commits the receipt id/hash
|
|
4513
|
+
* and deposit on the quote.
|
|
4514
|
+
*/
|
|
4515
|
+
acceptQuote(quoteId: string, input: AcceptQuoteInput, requestOptions?: RequestOptions): Promise<ApiResponse<Quote>>;
|
|
4516
|
+
getCustomerStats(customerRef: string, requestOptions?: RequestOptions): Promise<ApiResponse<CustomerStats>>;
|
|
4517
|
+
/** Host/admin: mark a booking completed (maintains the customer stats projection). */
|
|
4518
|
+
completeBooking(bookingId: string, reason?: string, requestOptions?: RequestOptions): Promise<ApiResponse<BookingCompletionResult>>;
|
|
4519
|
+
/** Host/admin: mark a booking as a no-show (maintains the customer stats projection). */
|
|
4520
|
+
markNoShow(bookingId: string, reason?: string, requestOptions?: RequestOptions): Promise<ApiResponse<BookingCompletionResult>>;
|
|
4521
|
+
}
|
|
4522
|
+
|
|
4301
4523
|
/**
|
|
4302
4524
|
* Permissions Service Module
|
|
4303
4525
|
*
|
|
@@ -4863,6 +5085,113 @@ declare class ListingsService extends ServiceModule {
|
|
|
4863
5085
|
getListing(id: string): Promise<ApiResponse<Listing>>;
|
|
4864
5086
|
}
|
|
4865
5087
|
|
|
5088
|
+
/**
|
|
5089
|
+
* Polls Service Module
|
|
5090
|
+
*
|
|
5091
|
+
* Reader polls for any ScaleMule application. A poll can carry text, an image,
|
|
5092
|
+
* a video, or audio on the question and on each choice. Totals are public.
|
|
5093
|
+
* One account, or one device voter key, holds one ballot and may change it.
|
|
5094
|
+
*
|
|
5095
|
+
* Routes:
|
|
5096
|
+
* POST /manage → create
|
|
5097
|
+
* GET /manage → list, including drafts
|
|
5098
|
+
* GET /manage/{id} → staff read
|
|
5099
|
+
* PATCH /manage/{id} → update
|
|
5100
|
+
* POST /manage/{id}/publish → open
|
|
5101
|
+
* POST /manage/{id}/close → close
|
|
5102
|
+
* GET /public → published polls
|
|
5103
|
+
* GET /public/{slug} → one published poll
|
|
5104
|
+
* POST /public/{slug}/votes → cast or change a ballot
|
|
5105
|
+
*/
|
|
5106
|
+
|
|
5107
|
+
type PollMediaKind = 'text' | 'image' | 'video' | 'audio';
|
|
5108
|
+
type PollBallot = 'account' | 'key';
|
|
5109
|
+
type PollStatus = 'draft' | 'open' | 'closed' | 'archived';
|
|
5110
|
+
interface PollMedia {
|
|
5111
|
+
kind: PollMediaKind;
|
|
5112
|
+
url?: string;
|
|
5113
|
+
text?: string;
|
|
5114
|
+
alt?: string;
|
|
5115
|
+
storage_id?: string;
|
|
5116
|
+
duration_ms?: number;
|
|
5117
|
+
}
|
|
5118
|
+
interface PollChoiceInput {
|
|
5119
|
+
id: string;
|
|
5120
|
+
label: string;
|
|
5121
|
+
media?: PollMedia[];
|
|
5122
|
+
}
|
|
5123
|
+
interface PollChoice extends PollChoiceInput {
|
|
5124
|
+
media: PollMedia[];
|
|
5125
|
+
votes: number;
|
|
5126
|
+
}
|
|
5127
|
+
interface Poll {
|
|
5128
|
+
id: string;
|
|
5129
|
+
slug: string;
|
|
5130
|
+
question: string;
|
|
5131
|
+
description?: string;
|
|
5132
|
+
media: PollMedia[];
|
|
5133
|
+
choices: PollChoice[];
|
|
5134
|
+
ballot: PollBallot;
|
|
5135
|
+
status: PollStatus;
|
|
5136
|
+
opens_at?: string;
|
|
5137
|
+
closes_at?: string;
|
|
5138
|
+
subject_type?: string;
|
|
5139
|
+
subject_id?: string;
|
|
5140
|
+
total_votes: number;
|
|
5141
|
+
votable: boolean;
|
|
5142
|
+
my_choice_id?: string;
|
|
5143
|
+
}
|
|
5144
|
+
interface CreatePollInput {
|
|
5145
|
+
slug: string;
|
|
5146
|
+
question: string;
|
|
5147
|
+
description?: string;
|
|
5148
|
+
media?: PollMedia[];
|
|
5149
|
+
choices: PollChoiceInput[];
|
|
5150
|
+
ballot?: PollBallot;
|
|
5151
|
+
opens_at?: string;
|
|
5152
|
+
closes_at?: string;
|
|
5153
|
+
subject_type?: string;
|
|
5154
|
+
subject_id?: string;
|
|
5155
|
+
}
|
|
5156
|
+
interface UpdatePollInput {
|
|
5157
|
+
question?: string;
|
|
5158
|
+
description?: string;
|
|
5159
|
+
media?: PollMedia[];
|
|
5160
|
+
choices?: PollChoiceInput[];
|
|
5161
|
+
opens_at?: string;
|
|
5162
|
+
closes_at?: string;
|
|
5163
|
+
subject_type?: string;
|
|
5164
|
+
subject_id?: string;
|
|
5165
|
+
clear_description?: boolean;
|
|
5166
|
+
clear_schedule?: boolean;
|
|
5167
|
+
clear_subject?: boolean;
|
|
5168
|
+
}
|
|
5169
|
+
interface PollListOptions {
|
|
5170
|
+
status?: PollStatus;
|
|
5171
|
+
subject_type?: string;
|
|
5172
|
+
subject_id?: string;
|
|
5173
|
+
limit?: number;
|
|
5174
|
+
voter_key?: string;
|
|
5175
|
+
}
|
|
5176
|
+
declare class PollsService extends ServiceModule {
|
|
5177
|
+
protected basePath: string;
|
|
5178
|
+
create(data: CreatePollInput, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5179
|
+
list(params?: PollListOptions, options?: RequestOptions): Promise<ApiResponse<Poll[]>>;
|
|
5180
|
+
get(id: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5181
|
+
update(id: string, data: UpdatePollInput, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5182
|
+
publish(id: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5183
|
+
close(id: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5184
|
+
listPublic(params?: PollListOptions, options?: RequestOptions): Promise<ApiResponse<Poll[]>>;
|
|
5185
|
+
getPublic(slug: string, params?: {
|
|
5186
|
+
voter_key?: string;
|
|
5187
|
+
}, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5188
|
+
vote(slug: string, choiceId: string, voterKey?: string, options?: RequestOptions): Promise<ApiResponse<Poll>>;
|
|
5189
|
+
}
|
|
5190
|
+
/** Stable ASCII voter key for `ballot: "key"` polls. Pass it to getPublic and vote. */
|
|
5191
|
+
declare function pollVoterKey(storage?: Pick<Storage, 'getItem' | 'setItem'>): string;
|
|
5192
|
+
/** Whole-number percent from a choice count. The last displayed point can be short of 100. */
|
|
5193
|
+
declare function pollSharePercent(votes: number, total: number): number;
|
|
5194
|
+
|
|
4866
5195
|
/**
|
|
4867
5196
|
* Events Service Module
|
|
4868
5197
|
*
|
|
@@ -7342,6 +7671,8 @@ declare class ScaleMule {
|
|
|
7342
7671
|
readonly communication: CommunicationService;
|
|
7343
7672
|
readonly notifications: NotificationsService;
|
|
7344
7673
|
readonly scheduler: SchedulerService;
|
|
7674
|
+
readonly decisions: DecisionsService;
|
|
7675
|
+
readonly bookings: BookingsService;
|
|
7345
7676
|
readonly permissions: PermissionsService;
|
|
7346
7677
|
readonly workspaces: WorkspacesService;
|
|
7347
7678
|
/** @deprecated Use `workspaces` instead */
|
|
@@ -7356,6 +7687,7 @@ declare class ScaleMule {
|
|
|
7356
7687
|
readonly webhooks: WebhooksService;
|
|
7357
7688
|
readonly leaderboard: LeaderboardService;
|
|
7358
7689
|
readonly listings: ListingsService;
|
|
7690
|
+
readonly polls: PollsService;
|
|
7359
7691
|
readonly events: EventsService;
|
|
7360
7692
|
readonly graph: GraphService;
|
|
7361
7693
|
readonly functions: FunctionsService;
|
|
@@ -7437,4 +7769,4 @@ declare class ScaleMule {
|
|
|
7437
7769
|
getClient(): ScaleMuleClient;
|
|
7438
7770
|
}
|
|
7439
7771
|
|
|
7440
|
-
export { type AccountBalance, type AccountSwitcherPrivacy, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type Attachment, type Attendee, type AudioRegisterResult, AudioService, type AudioUploadViaStorageResult, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type CacheEntry, CacheService, type CalendarEvent, type CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type ContentPolicy, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateLeadInput, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FileStatus, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, LEGACY_ANONYMOUS_ID_KEYS, type Lead, type Leaderboard, type LeaderboardEntry, LeaderboardService, LeadsService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, MEDIA_PRESETS, type MediaAsset, type MediaKind, type MediaManifest, type MediaManifestOptions, type MediaPolicy, type MediaPreset, type MediaPresetSpec, MediaService, type MediaUploadEvent, type MediaUploadOptions, type MediaUploadPhase, type MediaUploadResult, type MessageCallback, type MessagePin, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type PinnedMessagesResponse, type Pipeline, type PipelineVersion, type Policy, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type ReadStatus, RealtimeService, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, STORAGE_KEYS, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SearchUsersParams, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPolicyAction, type SocialPolicyBatchDecisionItem, type SocialPolicyBatchDecisionRequest, type SocialPolicyBatchDecisionResponse, type SocialPolicyBatchDecisionTarget, type SocialPolicyBlockRequest, type SocialPolicyContactRequest, type SocialPolicyContactRequestListItem, type SocialPolicyContactRequestQuery, type SocialPolicyContactRequestRequest, type SocialPolicyContext, type SocialPolicyDecision, type SocialPolicyDecisionLimits, type SocialPolicyDecisionRequest, type SocialPolicyDecisionResponse, type SocialPolicyIdentity, type SocialPolicyIdentityType, type SocialPolicyMuteRequest, type SocialPolicyPolicyPack, type SocialPolicyRelationship, type SocialPolicyRelationshipQuery, type SocialPolicyRelationshipRequest, type SocialPolicyReportRequest, SocialPolicyService, type SocialPolicySettings, type SocialPolicyUnblockRequest, type SocialPolicyUpdateSettingsRequest, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StorageSettings, type StrategyResult, type StylePreset, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type TtsAccessMode, type TtsAudioInfo, type TtsJobStatus, type TtsListVoicesParams, TtsService, type TtsSpeechMetadata, type TtsSpeechProfile, type TtsSynthesizeParams, type TtsSynthesizeQueuedResult, type TtsSynthesizeReadyResult, type TtsSynthesizeResult, type TtsVoice, type TtsVoicesResponse, type UnreadCountResponse, type UpdateFlagRequest, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type VoteState, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type WebrtcStats, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, ensureAnonymousId, extractClientContext, generateAnonymousId, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, readAnonymousId, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
|
7772
|
+
export { type AcceptQuoteInput, type AccountBalance, type AccountSwitcherPrivacy, AccountsService, type ActiveUsers, type ActivityItem, AgentAuthService, AgentModelsService, type AgentProfile, AgentProjectsService, type AgentResponse, type AgentSecurityPolicy, AgentSessionsService, type AgentSigningKey, type AgentToken, type AgentToolEntitlement, AgentToolsService, type Workspace as AgentWorkspace, AgentsService, type AggregateOptions, type AggregateResult, type AnalyticsEvent, AnalyticsService, type ApiError, type ApiKey, type ApiResponse, type Appeal, type Application, type AppointmentDepositValue, type Attachment, type Attendee, type AudioRegisterResult, AudioService, type AudioUploadViaStorageResult, type AuditLog, type AuthRegisterAgentRequest, type AuthRegisterAgentResponse, AuthService, type AuthSession, type AuthUser, type BackupCodes, BillingService, type BookingCompletionResult, BookingsService, type CacheEntry, CacheService, type CalendarEvent, type CallParticipant, type CallSession, type CatalogEntry, CatalogService, type ChatMessage, type ChatReaction, ChatService, type ClaimResult, type Client, type ClientContext, type Collection, type Comment, CommunicationService, type CompletedPart, ComplianceService, type CompressionConfig, ConferenceService, type ConferenceSettings, type ConnectedAccount, type ConnectedAccountSubscription, type ConnectedSetupIntentResponse, type ConnectedSubscriptionListParams, type ConnectionStatus, type ContentFlag, type ContentPolicy, type Conversation, type CostReportDay, type CreateProjectInput as CreateCreatorProjectInput, type CreateFlagRequest, type CreateLeadInput, type CreatePollInput, type CreateQuoteInput, type CreateRuleRequest, type CreateSegmentRequest, type CreateSessionResponse, type CreateVariantRequest, type GenerationJob as CreatorJob, CreatorMakerService, type GenerationOutput as CreatorOutput, type CreatorProject, type CreatorUsage, type Credential, type CredentialScope, type Customer, type CustomerStats, type DataAccessPolicy, type DataExport, DataService, type DataSource, type DeadLetterJob, type DecisionBatchItem, type DecisionBatchResult, type DecisionEvaluateOptions, type DecisionOutcome, type DecisionProposedAction, type DecisionReceipt, type DecisionResult, type DecisionTraceLevel, type DecisionVersions, DecisionsService, type DeviceInfo, type DirectoryUser, type DirectoryUserDetail, type DirectoryUsersListResponse, type Document, type ErrorCode, ErrorCodes, type EventAggregation, EventsService, type FileInfo, type FileStatus, type FlagAuditEntry, type FlagCheck, type FlagCondition, FlagContentService, type FlagDefinition, type FlagDetail, type FlagEnvironment, type FlagEvaluation, type FlagSegment, type FlagVariant, FlagsService, type FollowStatus, type FunctionExecution, type FunctionMetrics, FunctionsService, type Funnel, type FunnelConversion, type GdprRequest, type GenerateInput, type GrantInfo, type GraphEdge, type GraphNode, GraphService, IdentityService, type IdentityType, type IncomingRequestLike, type Invoice, type JobExecution, type JobStats, type JoinCallResponse, type KnownAccount, type KnownAccountDisplay, LEGACY_ANONYMOUS_ID_KEYS, type Lead, type Leaderboard, type LeaderboardEntry, LeaderboardService, LeadsService, type Like, type ListNotificationsParams, type Listing, ListingsService, type LogEntry, type LogInput, type LogQueryParams, type LogQueryResponse, type LogRecord, LoggerService, type LoginActivitySummary, type LoginDeviceInfo, type LoginHistoryEntry, type LoginRiskInfo, MEDIA_PRESETS, type MediaAsset, type MediaKind, type MediaManifest, type MediaManifestOptions, type MediaPolicy, type MediaPreset, type MediaPresetSpec, MediaService, type MediaUploadEvent, type MediaUploadOptions, type MediaUploadPhase, type MediaUploadResult, type MessageCallback, type MessagePin, type MessageStatus, type MetricDataPoint, type MfaStatus, type Model, type ModelEntitlement, type ModelPricing, type ModelProvider, type UsageSummary as ModelUsageSummary, type MultipartCompleteResponse, type MultipartConfig, type MultipartPartUrl, type MultipartPartUrlsResponse, type MultipartStartResponse, type NetworkClass, type Notification, type NotificationListResponse, NotificationsService, type OAuthProvider, type OAuthUrl, OrchestratorService, PHOTO_BREAKPOINTS, type PaginatedResponse, type PaginationMetadata, type PaginationParams, type PartResult, type PartUrl, type Participant, type Payment, type PaymentListParams, type PaymentMethod, type PaymentStatusResponse, type Payout, type PayoutSchedule, type PermissionCheck, type PermissionMatrix, PermissionsService, type PhotoInfo, PhotoService, type PinnedMessagesResponse, type Pipeline, type PipelineVersion, type Policy, type Poll, type PollBallot, type PollChoice, type PollChoiceInput, type PollListOptions, type PollMedia, type PollMediaKind, type PollStatus, PollsService, type PresenceCallback, type PresenceEvent, type PresignedUploadResponse, type Price, type Product, type Project, type ProjectDocument, type ProjectGrant, type ProjectMember, type PushApiFetcher, type PushPreferences, type PushSettings, type PushSubscriptionInfo, type PushToken, type PushTokenAssociationResult, type PushTopic, type QueryFilter, type QueryOptions, type QuerySort, type QueueJob, QueueService, type Quote, type QuoteDeposit, type QuoteState, type ReadStatus, RealtimeService, type ReceiptVerification, type RedeemResult, type ReferralAnalytics, type ReferralCampaign, type ReferralProfile, type ReferralStats, ReferralsService, type Refund, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterPushTokenData, type RequestOptions, type ResolvedReferral, type ResumeSession, type Role, type RuntimeTemplate, type RuntimeTemplateVersion, type S3MultipartOptions, type S3MultipartResult, type S3SingleUploadOptions, type S3SingleUploadResult, type S3UploadProgress, STORAGE_KEYS, ScaleMule, ScaleMuleClient, type ScaleMuleConfig, type SchedulerJob, SchedulerService, type SearchResult, SearchService, type SearchUsersParams, type SecurityLayers, type ServerlessFunction, type ServiceHealth, ServiceModule, type Session, type SessionArtifact, type SessionInfo, type SessionLog, type SessionPoolEntry, type Severity, type ShareLink, type ShortestPathResult, type SignedUrlResponse, type SocialPolicyAction, type SocialPolicyBatchDecisionItem, type SocialPolicyBatchDecisionRequest, type SocialPolicyBatchDecisionResponse, type SocialPolicyBatchDecisionTarget, type SocialPolicyBlockRequest, type SocialPolicyContactRequest, type SocialPolicyContactRequestListItem, type SocialPolicyContactRequestQuery, type SocialPolicyContactRequestRequest, type SocialPolicyContext, type SocialPolicyDecision, type SocialPolicyDecisionLimits, type SocialPolicyDecisionRequest, type SocialPolicyDecisionResponse, type SocialPolicyIdentity, type SocialPolicyIdentityType, type SocialPolicyMuteRequest, type SocialPolicyPolicyPack, type SocialPolicyRelationship, type SocialPolicyRelationshipQuery, type SocialPolicyRelationshipRequest, type SocialPolicyReportRequest, SocialPolicyService, type SocialPolicySettings, type SocialPolicyUnblockRequest, type SocialPolicyUpdateSettingsRequest, type SocialPost, SocialService, type SocialUser, type SsoConfig, type StatusCallback, type StorageAdapter, StorageService, type StorageSettings, type StrategyResult, type StylePreset, type SubmitResult, type Subscription, type TargetingRule, type Task, type TaskAttempt, type TaskTransition, type Team, type TeamInvitation, type TeamMember, TeamsService, type TelemetryPayload, type Tool, type ToolCapability, type ToolIntegration, type TopEvent, type TotpSetup, type Transaction, type TransactionListParams, type TransactionSummary, type TransactionSummaryParams, type Transfer, type TransformOptions, type TransformResult, type TraversalResult, type TtsAccessMode, type TtsAudioInfo, type TtsJobStatus, type TtsListVoicesParams, TtsService, type TtsSpeechMetadata, type TtsSpeechProfile, type TtsSynthesizeParams, type TtsSynthesizeQueuedResult, type TtsSynthesizeReadyResult, type TtsSynthesizeResult, type TtsVoice, type TtsVoicesResponse, type UnreadCountResponse, type UpdateFlagRequest, type UpdatePollInput, type UpdateRuleRequest, type UpdateSegmentRequest, type UpdateVariantRequest, type UploadCompleteResponse, type UploadEngineConfig, type UploadFailureReport, type UploadFailureReportResponse, type UploadOptions, type UploadPlan, UploadResumeStore, type UploadStrategy, UploadTelemetry, type UploadTelemetryConfig, type UploadTelemetryEvent, type UpsertEnvironmentRequest, type UsageRecord, type UsageSummary$1 as UsageSummary, type UserRank, type VideoInfo, VideoService, type VideoUploadOptions, type VoteState, WEB_PUSH_SERVICE_WORKER, WebPushManager, type WebPushManagerOptions, type WebPushSubscriptionData, type Webhook, WebhooksService, type WebrtcStats, type Workflow, type WorkflowExecution, type Workspace$1 as Workspace, type WorkspaceInvitation, type WorkspaceMember, WorkspacesService, buildClientContextHeaders, calculateTotalParts, canPerform, createUploadPlan, ScaleMule as default, detectNetworkClass, ensureAnonymousId, extractClientContext, generateAnonymousId, generateUploadSessionId, getMeasuredBandwidthMbps, getPartRange, hasMinRoleLevel, pollSharePercent, pollVoterKey, readAnonymousId, resolveStrategy, uploadMultipartToS3, uploadSingleToS3, validateIP };
|
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,
|
|
@@ -1223,7 +1228,7 @@ var ScaleMuleClient = class {
|
|
|
1223
1228
|
responseData = { message: text };
|
|
1224
1229
|
}
|
|
1225
1230
|
}
|
|
1226
|
-
if (!response.ok) {
|
|
1231
|
+
if (!response.ok || responseData?.success === false) {
|
|
1227
1232
|
const error = {
|
|
1228
1233
|
code: responseData?.error?.code || responseData?.code || statusToErrorCode(response.status),
|
|
1229
1234
|
message: responseData?.error?.message || responseData?.message || response.statusText,
|
|
@@ -6448,6 +6453,90 @@ var SchedulerService = class extends ServiceModule {
|
|
|
6448
6453
|
}
|
|
6449
6454
|
};
|
|
6450
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
|
+
|
|
6451
6540
|
// src/services/permissions.ts
|
|
6452
6541
|
function canPerform(matrix, resource, action) {
|
|
6453
6542
|
if (!matrix) return false;
|
|
@@ -6808,6 +6897,72 @@ var ListingsService = class extends ServiceModule {
|
|
|
6808
6897
|
}
|
|
6809
6898
|
};
|
|
6810
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
|
+
|
|
6811
6966
|
// src/services/events.ts
|
|
6812
6967
|
var EventsService = class extends ServiceModule {
|
|
6813
6968
|
constructor() {
|
|
@@ -8753,6 +8908,8 @@ var ScaleMule = class {
|
|
|
8753
8908
|
this.communication = new CommunicationService(this._client);
|
|
8754
8909
|
this.notifications = new NotificationsService(this._client);
|
|
8755
8910
|
this.scheduler = new SchedulerService(this._client);
|
|
8911
|
+
this.decisions = new DecisionsService(this._client);
|
|
8912
|
+
this.bookings = new BookingsService(this._client);
|
|
8756
8913
|
this.permissions = new PermissionsService(this._client);
|
|
8757
8914
|
this.workspaces = new WorkspacesService(this._client);
|
|
8758
8915
|
this.accounts = new AccountsService(this._client);
|
|
@@ -8765,6 +8922,7 @@ var ScaleMule = class {
|
|
|
8765
8922
|
this.webhooks = new WebhooksService(this._client);
|
|
8766
8923
|
this.leaderboard = new LeaderboardService(this._client);
|
|
8767
8924
|
this.listings = new ListingsService(this._client);
|
|
8925
|
+
this.polls = new PollsService(this._client);
|
|
8768
8926
|
this.events = new EventsService(this._client);
|
|
8769
8927
|
this.graph = new GraphService(this._client);
|
|
8770
8928
|
this.functions = new FunctionsService(this._client);
|
|
@@ -8918,6 +9076,7 @@ var index_default = ScaleMule;
|
|
|
8918
9076
|
AudioService,
|
|
8919
9077
|
AuthService,
|
|
8920
9078
|
BillingService,
|
|
9079
|
+
BookingsService,
|
|
8921
9080
|
CacheService,
|
|
8922
9081
|
CatalogService,
|
|
8923
9082
|
ChatService,
|
|
@@ -8926,6 +9085,7 @@ var index_default = ScaleMule;
|
|
|
8926
9085
|
ConferenceService,
|
|
8927
9086
|
CreatorMakerService,
|
|
8928
9087
|
DataService,
|
|
9088
|
+
DecisionsService,
|
|
8929
9089
|
ErrorCodes,
|
|
8930
9090
|
EventsService,
|
|
8931
9091
|
FlagContentService,
|
|
@@ -8946,6 +9106,7 @@ var index_default = ScaleMule;
|
|
|
8946
9106
|
PHOTO_BREAKPOINTS,
|
|
8947
9107
|
PermissionsService,
|
|
8948
9108
|
PhotoService,
|
|
9109
|
+
PollsService,
|
|
8949
9110
|
QueueService,
|
|
8950
9111
|
RealtimeService,
|
|
8951
9112
|
ReferralsService,
|
|
@@ -8987,6 +9148,8 @@ var index_default = ScaleMule;
|
|
|
8987
9148
|
isValidE164Phone,
|
|
8988
9149
|
normalizeAndValidatePhone,
|
|
8989
9150
|
normalizePhoneNumber,
|
|
9151
|
+
pollSharePercent,
|
|
9152
|
+
pollVoterKey,
|
|
8990
9153
|
readAnonymousId,
|
|
8991
9154
|
resolveStrategy,
|
|
8992
9155
|
uploadMultipartToS3,
|
package/dist/index.mjs
CHANGED
|
@@ -1119,7 +1119,7 @@ var ScaleMuleClient = class {
|
|
|
1119
1119
|
responseData = { message: text };
|
|
1120
1120
|
}
|
|
1121
1121
|
}
|
|
1122
|
-
if (!response.ok) {
|
|
1122
|
+
if (!response.ok || responseData?.success === false) {
|
|
1123
1123
|
const error = {
|
|
1124
1124
|
code: responseData?.error?.code || responseData?.code || statusToErrorCode(response.status),
|
|
1125
1125
|
message: responseData?.error?.message || responseData?.message || response.statusText,
|
|
@@ -6344,6 +6344,90 @@ var SchedulerService = class extends ServiceModule {
|
|
|
6344
6344
|
}
|
|
6345
6345
|
};
|
|
6346
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
|
+
|
|
6347
6431
|
// src/services/permissions.ts
|
|
6348
6432
|
function canPerform(matrix, resource, action) {
|
|
6349
6433
|
if (!matrix) return false;
|
|
@@ -6704,6 +6788,72 @@ var ListingsService = class extends ServiceModule {
|
|
|
6704
6788
|
}
|
|
6705
6789
|
};
|
|
6706
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
|
+
|
|
6707
6857
|
// src/services/events.ts
|
|
6708
6858
|
var EventsService = class extends ServiceModule {
|
|
6709
6859
|
constructor() {
|
|
@@ -8649,6 +8799,8 @@ var ScaleMule = class {
|
|
|
8649
8799
|
this.communication = new CommunicationService(this._client);
|
|
8650
8800
|
this.notifications = new NotificationsService(this._client);
|
|
8651
8801
|
this.scheduler = new SchedulerService(this._client);
|
|
8802
|
+
this.decisions = new DecisionsService(this._client);
|
|
8803
|
+
this.bookings = new BookingsService(this._client);
|
|
8652
8804
|
this.permissions = new PermissionsService(this._client);
|
|
8653
8805
|
this.workspaces = new WorkspacesService(this._client);
|
|
8654
8806
|
this.accounts = new AccountsService(this._client);
|
|
@@ -8661,6 +8813,7 @@ var ScaleMule = class {
|
|
|
8661
8813
|
this.webhooks = new WebhooksService(this._client);
|
|
8662
8814
|
this.leaderboard = new LeaderboardService(this._client);
|
|
8663
8815
|
this.listings = new ListingsService(this._client);
|
|
8816
|
+
this.polls = new PollsService(this._client);
|
|
8664
8817
|
this.events = new EventsService(this._client);
|
|
8665
8818
|
this.graph = new GraphService(this._client);
|
|
8666
8819
|
this.functions = new FunctionsService(this._client);
|
|
@@ -8813,6 +8966,7 @@ export {
|
|
|
8813
8966
|
AudioService,
|
|
8814
8967
|
AuthService,
|
|
8815
8968
|
BillingService,
|
|
8969
|
+
BookingsService,
|
|
8816
8970
|
CacheService,
|
|
8817
8971
|
CatalogService,
|
|
8818
8972
|
ChatService,
|
|
@@ -8821,6 +8975,7 @@ export {
|
|
|
8821
8975
|
ConferenceService,
|
|
8822
8976
|
CreatorMakerService,
|
|
8823
8977
|
DataService,
|
|
8978
|
+
DecisionsService,
|
|
8824
8979
|
ErrorCodes,
|
|
8825
8980
|
EventsService,
|
|
8826
8981
|
FlagContentService,
|
|
@@ -8841,6 +8996,7 @@ export {
|
|
|
8841
8996
|
PHOTO_BREAKPOINTS,
|
|
8842
8997
|
PermissionsService,
|
|
8843
8998
|
PhotoService,
|
|
8999
|
+
PollsService,
|
|
8844
9000
|
QueueService,
|
|
8845
9001
|
RealtimeService,
|
|
8846
9002
|
ReferralsService,
|
|
@@ -8883,6 +9039,8 @@ export {
|
|
|
8883
9039
|
isValidE164Phone,
|
|
8884
9040
|
normalizeAndValidatePhone,
|
|
8885
9041
|
normalizePhoneNumber,
|
|
9042
|
+
pollSharePercent,
|
|
9043
|
+
pollVoterKey,
|
|
8886
9044
|
readAnonymousId,
|
|
8887
9045
|
resolveStrategy,
|
|
8888
9046
|
uploadMultipartToS3,
|