spaps-sdk 1.10.0 → 1.10.1
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/CHANGELOG.md +12 -0
- package/README.md +36 -4
- package/dist/index.d.mts +43 -6
- package/dist/index.d.ts +43 -6
- package/dist/index.js +111 -9
- package/dist/index.mjs +111 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Added issue-reporting screenshot attachment helpers for private upload, list, access URL, delete, and attach-by-ID create/update/reply flows.
|
|
12
|
+
|
|
13
|
+
## [1.10.0] - 2026-05-11
|
|
14
|
+
|
|
15
|
+
- Added usage-control SDK support for authorizing usage and recording immutable usage events against SPAPS.
|
|
16
|
+
|
|
17
|
+
## [1.9.0] - 2026-05-11
|
|
18
|
+
|
|
19
|
+
- Maintenance: align the SDK package version after release automation.
|
|
20
|
+
|
|
9
21
|
## [1.8.0] - 2026-05-11
|
|
10
22
|
|
|
11
23
|
- Maintenance: align the SDK package version after release automation.
|
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ Relevant environment variables:
|
|
|
84
84
|
| `payments` | Checkout sessions, products, prices, subscriptions, and crypto helpers |
|
|
85
85
|
| `sessions` | Session lookup, validation, and lifecycle helpers |
|
|
86
86
|
| `secureMessages` | Secure-message create/list helpers |
|
|
87
|
-
| `issueReporting` | Status, history, create, update, reply,
|
|
87
|
+
| `issueReporting` | Status, history, create, update, reply, voice-token, and private screenshot attachment flows |
|
|
88
88
|
| `appLinks` | Authenticated create and public resolve helpers for application-scoped short links |
|
|
89
89
|
| `email` | Template lookup, preview, and send helpers |
|
|
90
90
|
| `entitlements` | User and resource entitlement queries |
|
|
@@ -124,6 +124,37 @@ const voiceToken = await spaps.issueReporting.createVoiceToken();
|
|
|
124
124
|
console.log(voiceToken.provider, voiceToken.model_id);
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
+
### Issue Reporting Screenshot Attachments
|
|
128
|
+
|
|
129
|
+
Screenshots are uploaded as private pending hosted assets first. Create, update, or reply calls then send only attachment IDs; do not put raw image bytes, data URLs, or base64 payloads in issue notes or target metadata.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
spaps.setAccessToken(accessToken);
|
|
133
|
+
|
|
134
|
+
const file = new File([pngBytes], "protocol-save-failure.png", {
|
|
135
|
+
type: "image/png",
|
|
136
|
+
});
|
|
137
|
+
const attachment = await spaps.issueReporting.uploadAttachment(file);
|
|
138
|
+
|
|
139
|
+
const issue = await spaps.issueReporting.create({
|
|
140
|
+
target: {
|
|
141
|
+
component_key: "patient_protocol_widget",
|
|
142
|
+
component_label: "Patient Protocol Widget",
|
|
143
|
+
page_url: "/patients/123/protocol",
|
|
144
|
+
surface_ref: "daily-log",
|
|
145
|
+
metadata: { section: "daily log" },
|
|
146
|
+
},
|
|
147
|
+
note: "The save action silently fails after I edit today's protocol note.",
|
|
148
|
+
reporter_role_hint: "practitioner",
|
|
149
|
+
attachment_ids: [attachment.id],
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const access = await spaps.issueReporting.getAttachmentAccessUrl(attachment.id);
|
|
153
|
+
console.log(issue.id, access.expires_in_seconds);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
SPAPS accepts PNG, JPEG, and WebP screenshots up to 10 MiB each, with at most 5 retained screenshots per report. The hosted object remains private; callers fetch a short-lived access URL after normal issue-reporting authorization succeeds. SPAPS does not redact screenshot contents, so host apps should warn users when a capture may include sensitive data.
|
|
157
|
+
|
|
127
158
|
### Application Short Links
|
|
128
159
|
|
|
129
160
|
Use `appLinks` when a browser app needs a stable public URL for large local state, such as compressed diagram state.
|
|
@@ -192,8 +223,9 @@ await spaps.usage.record({
|
|
|
192
223
|
});
|
|
193
224
|
```
|
|
194
225
|
|
|
195
|
-
|
|
196
|
-
|
|
226
|
+
For dashboard and policy views, use `spaps.usage.listFeatures()`,
|
|
227
|
+
`spaps.usage.getStatus(...)`, and `spaps.usage.listHistory(...)` from the same
|
|
228
|
+
trusted backend context.
|
|
197
229
|
|
|
198
230
|
### Skill Evals
|
|
199
231
|
|
|
@@ -416,7 +448,7 @@ npm run test:readme
|
|
|
416
448
|
## Metadata
|
|
417
449
|
|
|
418
450
|
- `package_name`: `spaps-sdk`
|
|
419
|
-
- `latest_version`: `1.
|
|
451
|
+
- `latest_version`: `1.10.0`
|
|
420
452
|
- `minimum_runtime`: `Node.js >=14.0.0`
|
|
421
453
|
- `api_base_url`: `https://api.sweetpotato.dev`
|
|
422
454
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as spaps_types from 'spaps-types';
|
|
2
|
-
import { ResourceType, Entitlement, CreateProductRequest, Product, UpdateProductRequest, CreatePriceRequest, Price, ProductSyncResult, CryptoReconcileRequest, CreateSecureMessageRequest, SecureMessage, IssueReportScope, IssueReportStatusResult, IssueReportStatus, IssueReportListResult, IssueReport, CreateIssueReportRequest, IssueReportingVoiceTokenResult, UpdateIssueReportRequest, ReplyIssueReportRequest, CreateAppLinkRequest, AppLink, AuthResponse, User as User$1, CreateCryptoInvoiceRequest, CryptoInvoiceStatusSnapshot, CheckoutSession, X402ResourceStatusResponse, X402ActionResponse, X402ReceiptResponse, X402ReceiptListResponse, X402HandoffVerification, DayrateAvailabilityResponse, DayrateBookingRequest, DayrateBookingResponse, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayrateX402BookingRequest, DayrateX402BookingResponse, DayrateCheckoutStatusResponse, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlRecordRequest, UsageControlRecordResponse, Subscription, VerifyCryptoWebhookSignatureOptions } from 'spaps-types';
|
|
3
|
-
export { AdminPermission, AdminRole, AdminUser, ApiResponse, AppLink, AuthResponse, CheckoutSession, CreateAppLinkRequest, CreateCryptoInvoiceRequest, CreateIssueReportRequest, CreatePriceRequest, CreateProductRequest, CreateSecureMessageInput, CreateSecureMessageRequest, CryptoInvoice, CryptoInvoiceResponse, CryptoInvoiceStatusSnapshot, CryptoReconcileRequest, DayrateAvailabilityResponse, DayrateAvailableSlot, DayrateBookingRequest, DayrateBookingResponse, DayrateCheckoutStatus, DayrateCheckoutStatusBooking, DayrateCheckoutStatusResponse, DayrateDayOfWeek, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayratePriceBreakdown, DayrateSlotType, DayrateX402BookingRequest, DayrateX402BookingResponse, Entitlement, IssueReport, IssueReportListResult, IssueReportStatus, IssueReportStatusResult, IssueReportTarget, IssueReportingInputMode, IssueReportingVoiceProvider, IssueReportingVoiceTokenResult, LinkedIssueReportCase, Price, Product, ProductSyncResult, ReplyIssueReportRequest, ResourceType, SecureMessage, SecureMessageOutput, Subscription, TokenPair, UpdateIssueReportRequest, UpdateProductRequest, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlDecision, UsageControlDimensions, UsageControlError, UsageControlErrorCode, UsageControlLedgerEvent, UsageControlRecordRequest, UsageControlRecordResponse, UsageControlRecordStatus, User, UserProfile, UserRole, UserWallet, VerifyCryptoWebhookSignatureOptions, X402ActionFreeResponse, X402ActionOutcome, X402ActionPendingResponse, X402ActionReplayedResponse, X402ActionResponse, X402ActionSettledResponse, X402ExecuteActionRequest, X402HandoffAuthorization, X402HandoffVerification, X402HandoffVerifyRequest, X402PaymentAccept, X402PaymentRequirement, X402ProjectionStatus, X402Receipt, X402ReceiptListResponse, X402ReceiptResponse, X402ReceiptStatus, X402Resource, X402ResourceStatus, X402ResourceStatusResponse, atomicToMoneyUnits, createSecureMessageRequestSchema, isX402PaymentRequired, isX402ResourceStatus, moneyUnitsToAtomic, roundHalfToPositiveInfinity, secureMessageMetadataSchema, secureMessageSchema, validatePositiveAmountAtomic } from 'spaps-types';
|
|
2
|
+
import { ResourceType, Entitlement, CreateProductRequest, Product, UpdateProductRequest, CreatePriceRequest, Price, ProductSyncResult, CryptoReconcileRequest, CreateSecureMessageRequest, SecureMessage, IssueReportScope, IssueReportStatusResult, IssueReportStatus, IssueReportListResult, IssueReport, CreateIssueReportRequest, IssueReportAttachmentOut, ListIssueReportAttachmentsResponse, IssueReportAttachmentAccessResponse, IssueReportingVoiceTokenResult, UpdateIssueReportRequest, ReplyIssueReportRequest, CreateAppLinkRequest, AppLink, AuthResponse, User as User$1, CreateCryptoInvoiceRequest, CryptoInvoiceStatusSnapshot, CheckoutSession, X402ResourceStatusResponse, X402ActionResponse, X402ReceiptResponse, X402ReceiptListResponse, X402HandoffVerification, DayrateAvailabilityResponse, DayrateBookingRequest, DayrateBookingResponse, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayrateX402BookingRequest, DayrateX402BookingResponse, DayrateCheckoutStatusResponse, UsageControlFeaturesResponse, UsageControlStatusRequest, UsageControlStatusResponse, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlRecordRequest, UsageControlRecordResponse, UsageControlHistoryRequest, UsageControlHistoryResponse, Subscription, VerifyCryptoWebhookSignatureOptions } from 'spaps-types';
|
|
3
|
+
export { AdminPermission, AdminRole, AdminUser, ApiResponse, AppLink, AuthResponse, CheckoutSession, CreateAppLinkRequest, CreateCryptoInvoiceRequest, CreateIssueReportRequest, CreatePriceRequest, CreateProductRequest, CreateSecureMessageInput, CreateSecureMessageRequest, CryptoInvoice, CryptoInvoiceResponse, CryptoInvoiceStatusSnapshot, CryptoReconcileRequest, DayrateAvailabilityResponse, DayrateAvailableSlot, DayrateBookingRequest, DayrateBookingResponse, DayrateCheckoutStatus, DayrateCheckoutStatusBooking, DayrateCheckoutStatusResponse, DayrateDayOfWeek, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayratePriceBreakdown, DayrateSlotType, DayrateX402BookingRequest, DayrateX402BookingResponse, Entitlement, IssueReport, IssueReportAttachmentAccessResponse, IssueReportAttachmentOut, IssueReportListResult, IssueReportStatus, IssueReportStatusResult, IssueReportTarget, IssueReportingInputMode, IssueReportingVoiceProvider, IssueReportingVoiceTokenResult, LinkedIssueReportCase, ListIssueReportAttachmentsResponse, Price, Product, ProductSyncResult, ReplyIssueReportRequest, ResourceType, SecureMessage, SecureMessageOutput, Subscription, TokenPair, UpdateIssueReportRequest, UpdateProductRequest, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlDecision, UsageControlDimensions, UsageControlError, UsageControlErrorCode, UsageControlFeaturesResponse, UsageControlHistoryRequest, UsageControlHistoryResponse, UsageControlLedgerEvent, UsageControlRecordRequest, UsageControlRecordResponse, UsageControlRecordStatus, UsageControlStatusRequest, UsageControlStatusResponse, User, UserProfile, UserRole, UserWallet, VerifyCryptoWebhookSignatureOptions, X402ActionFreeResponse, X402ActionOutcome, X402ActionPendingResponse, X402ActionReplayedResponse, X402ActionResponse, X402ActionSettledResponse, X402ExecuteActionRequest, X402HandoffAuthorization, X402HandoffVerification, X402HandoffVerifyRequest, X402PaymentAccept, X402PaymentRequirement, X402ProjectionStatus, X402Receipt, X402ReceiptListResponse, X402ReceiptResponse, X402ReceiptStatus, X402Resource, X402ResourceStatus, X402ResourceStatusResponse, atomicToMoneyUnits, createSecureMessageRequestSchema, isX402PaymentRequired, isX402ResourceStatus, moneyUnitsToAtomic, roundHalfToPositiveInfinity, secureMessageMetadataSchema, secureMessageSchema, validatePositiveAmountAtomic } from 'spaps-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Permission checking utilities for SPAPS SDK
|
|
@@ -360,6 +360,9 @@ interface IssueReportListParams {
|
|
|
360
360
|
interface IssueReportStatusParams {
|
|
361
361
|
scope?: SupportedIssueReportScope;
|
|
362
362
|
}
|
|
363
|
+
interface IssueReportAttachmentUploadOptions {
|
|
364
|
+
filename?: string;
|
|
365
|
+
}
|
|
363
366
|
declare class X402PaymentRequiredSDKError extends Error {
|
|
364
367
|
readonly paymentRequiredHeader: string;
|
|
365
368
|
readonly response: unknown;
|
|
@@ -730,6 +733,22 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
730
733
|
* Create a new canonical issue report.
|
|
731
734
|
*/
|
|
732
735
|
create: (payload: CreateIssueReportRequest) => Promise<IssueReport>;
|
|
736
|
+
/**
|
|
737
|
+
* Upload one private pending screenshot attachment.
|
|
738
|
+
*/
|
|
739
|
+
uploadAttachment: (file: Blob, options?: IssueReportAttachmentUploadOptions) => Promise<IssueReportAttachmentOut>;
|
|
740
|
+
/**
|
|
741
|
+
* List non-deleted screenshot attachments for one issue report.
|
|
742
|
+
*/
|
|
743
|
+
listAttachments: (issueReportId: string) => Promise<ListIssueReportAttachmentsResponse>;
|
|
744
|
+
/**
|
|
745
|
+
* Return a short-lived private attachment access URL.
|
|
746
|
+
*/
|
|
747
|
+
getAttachmentAccessUrl: (attachmentId: string) => Promise<IssueReportAttachmentAccessResponse>;
|
|
748
|
+
/**
|
|
749
|
+
* Soft-delete one owned screenshot attachment.
|
|
750
|
+
*/
|
|
751
|
+
deleteAttachment: (attachmentId: string) => Promise<void>;
|
|
733
752
|
/**
|
|
734
753
|
* Create a short-lived voice transcription token for issue reporting.
|
|
735
754
|
*/
|
|
@@ -963,7 +982,7 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
963
982
|
updateProductSuperAdmin: (productId: string, updates: any) => Promise<any>;
|
|
964
983
|
deleteProductSuperAdmin: (productId: string) => Promise<any>;
|
|
965
984
|
createProductWithPrice: (payload: any) => Promise<any>;
|
|
966
|
-
createProductWithPriceSuperAdmin: (
|
|
985
|
+
createProductWithPriceSuperAdmin: (applicationId: string, payload: any) => Promise<any>;
|
|
967
986
|
setDefaultPrice: (productId: string, payload: {
|
|
968
987
|
price_id: string;
|
|
969
988
|
}) => Promise<any>;
|
|
@@ -1099,6 +1118,14 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
1099
1118
|
* after work completes.
|
|
1100
1119
|
*/
|
|
1101
1120
|
usage: {
|
|
1121
|
+
/**
|
|
1122
|
+
* List active usage feature definitions for this application.
|
|
1123
|
+
*/
|
|
1124
|
+
listFeatures: () => Promise<UsageControlFeaturesResponse>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Fetch current window usage status without creating an authorization.
|
|
1127
|
+
*/
|
|
1128
|
+
getStatus: (query: UsageControlStatusRequest) => Promise<UsageControlStatusResponse>;
|
|
1102
1129
|
/**
|
|
1103
1130
|
* Authorize proposed usage before a downstream job, inference, or action runs.
|
|
1104
1131
|
*/
|
|
@@ -1107,16 +1134,26 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
1107
1134
|
* Record immutable usage after work completes.
|
|
1108
1135
|
*/
|
|
1109
1136
|
record: (payload: UsageControlRecordRequest) => Promise<UsageControlRecordResponse>;
|
|
1137
|
+
/**
|
|
1138
|
+
* List usage events in deterministic newest-first order.
|
|
1139
|
+
*/
|
|
1140
|
+
listHistory: (query?: UsageControlHistoryRequest) => Promise<UsageControlHistoryResponse>;
|
|
1110
1141
|
};
|
|
1111
1142
|
createCheckoutSession(priceId: string, successUrl: string, cancelUrl?: string): Promise<{
|
|
1112
1143
|
data: CheckoutSession;
|
|
1113
1144
|
}>;
|
|
1114
|
-
getSubscription(): Promise<{
|
|
1145
|
+
getSubscription(subscriptionId?: string): Promise<{
|
|
1146
|
+
data: Subscription | Subscription[];
|
|
1147
|
+
}>;
|
|
1148
|
+
cancelSubscription(subscriptionId?: string, options?: {
|
|
1149
|
+
immediately?: boolean;
|
|
1150
|
+
}): Promise<{
|
|
1115
1151
|
data: Subscription;
|
|
1116
1152
|
}>;
|
|
1117
|
-
cancelSubscription(): Promise<void>;
|
|
1118
1153
|
authorizeUsage(payload: UsageControlAuthorizeRequest): Promise<UsageControlAuthorizeResponse>;
|
|
1119
1154
|
recordUsage(payload: UsageControlRecordRequest): Promise<UsageControlRecordResponse>;
|
|
1155
|
+
getUsageStatus(query: UsageControlStatusRequest): Promise<UsageControlStatusResponse>;
|
|
1156
|
+
listUsageHistory(query?: UsageControlHistoryRequest): Promise<UsageControlHistoryResponse>;
|
|
1120
1157
|
private createSecureMessage;
|
|
1121
1158
|
private listSecureMessages;
|
|
1122
1159
|
/**
|
|
@@ -1298,4 +1335,4 @@ declare function createServerClient(secretKey: string, options?: Omit<SPAPSConfi
|
|
|
1298
1335
|
*/
|
|
1299
1336
|
declare function detectKeyType(key: string): ApiKeyType | null;
|
|
1300
1337
|
|
|
1301
|
-
export { type AdminConfig, type ApiKeyType, type CheckoutLineItem, type CheckoutLineItemPriceData, type CreateCheckoutSessionPayload, type CreateSkillEvalCaseRequest, type CreateSkillEvalGovernanceSnapshotRequest, DEFAULT_ADMIN_ACCOUNTS, type EmailSendOptions, type EmailSendResult, type EmailTemplate, type EmailTemplatePreview, type EntitlementCheckResult, type EntitlementListParams, type FeatureContext, type FeatureDefinition, FeatureEvaluator, type HeaderProvider, type ImportSkillEvalGovernanceOutcomeRequest, type IssueReportListParams, type IssueReportStatusParams, type PermissionCheckResult, PermissionChecker, type RespondToSkillEvalReviewRequest, type RevealSkillEvalEvidenceRequest, RoleHierarchy, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type SPAPSEnvelope, type SkillEvalAccessMode, type SkillEvalActorAccess, type SkillEvalCandidateInput, type SkillEvalCandidateResponse, type SkillEvalCasePolicy, type SkillEvalCaseResponse, type SkillEvalConfidence, type SkillEvalCreateOptions, type SkillEvalDisclosurePolicy, type SkillEvalEligibilitySource, type SkillEvalGovernanceOutcomeResult, type SkillEvalGovernancePurpose, type SkillEvalGovernanceSnapshotResult, type SkillEvalInsight, type SkillEvalInsightsResponse, type SkillEvalModelEffort, type SkillEvalMutationOptions, type SkillEvalPosterResponse, type SkillEvalPosterResponseResult, type SkillEvalRevealField, type SkillEvalRevealResult, type SkillEvalReviewMarkInput, type SkillEvalReviewMarkKind, type SkillEvalReviewResponse, type SkillEvalReviewRoom, type SkillEvalReviewerEligibilityInput, type SkillEvalRewardEvent, type SubmitSkillEvalReviewRequest, type TemplateVariable, TokenManager, WalletUtils, WebSocketAuthHelper, type WebSocketAuthHelperConfig, type X402ExecuteActionOptions, X402PaymentRequiredSDKError, type X402ReceiptListParams, type X402VerifyHandoffOptions, canAccessAdmin, createBrowserClient, createPermissionChecker, createServerClient, SPAPSClient as default, defaultPermissionChecker, detectKeyType, getRoleAwareErrorMessage, getUserDisplay, getUserRole, hasPermission, isAdminAccount, isEnvelope, isErrorEnvelope, isSuccessEnvelope, unwrapEnvelope, unwrapNestedData, verifyCryptoWebhookSignature };
|
|
1338
|
+
export { type AdminConfig, type ApiKeyType, type CheckoutLineItem, type CheckoutLineItemPriceData, type CreateCheckoutSessionPayload, type CreateSkillEvalCaseRequest, type CreateSkillEvalGovernanceSnapshotRequest, DEFAULT_ADMIN_ACCOUNTS, type EmailSendOptions, type EmailSendResult, type EmailTemplate, type EmailTemplatePreview, type EntitlementCheckResult, type EntitlementListParams, type FeatureContext, type FeatureDefinition, FeatureEvaluator, type HeaderProvider, type ImportSkillEvalGovernanceOutcomeRequest, type IssueReportAttachmentUploadOptions, type IssueReportListParams, type IssueReportStatusParams, type PermissionCheckResult, PermissionChecker, type RespondToSkillEvalReviewRequest, type RevealSkillEvalEvidenceRequest, RoleHierarchy, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type SPAPSEnvelope, type SkillEvalAccessMode, type SkillEvalActorAccess, type SkillEvalCandidateInput, type SkillEvalCandidateResponse, type SkillEvalCasePolicy, type SkillEvalCaseResponse, type SkillEvalConfidence, type SkillEvalCreateOptions, type SkillEvalDisclosurePolicy, type SkillEvalEligibilitySource, type SkillEvalGovernanceOutcomeResult, type SkillEvalGovernancePurpose, type SkillEvalGovernanceSnapshotResult, type SkillEvalInsight, type SkillEvalInsightsResponse, type SkillEvalModelEffort, type SkillEvalMutationOptions, type SkillEvalPosterResponse, type SkillEvalPosterResponseResult, type SkillEvalRevealField, type SkillEvalRevealResult, type SkillEvalReviewMarkInput, type SkillEvalReviewMarkKind, type SkillEvalReviewResponse, type SkillEvalReviewRoom, type SkillEvalReviewerEligibilityInput, type SkillEvalRewardEvent, type SubmitSkillEvalReviewRequest, type TemplateVariable, TokenManager, WalletUtils, WebSocketAuthHelper, type WebSocketAuthHelperConfig, type X402ExecuteActionOptions, X402PaymentRequiredSDKError, type X402ReceiptListParams, type X402VerifyHandoffOptions, canAccessAdmin, createBrowserClient, createPermissionChecker, createServerClient, SPAPSClient as default, defaultPermissionChecker, detectKeyType, getRoleAwareErrorMessage, getUserDisplay, getUserRole, hasPermission, isAdminAccount, isEnvelope, isErrorEnvelope, isSuccessEnvelope, unwrapEnvelope, unwrapNestedData, verifyCryptoWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as spaps_types from 'spaps-types';
|
|
2
|
-
import { ResourceType, Entitlement, CreateProductRequest, Product, UpdateProductRequest, CreatePriceRequest, Price, ProductSyncResult, CryptoReconcileRequest, CreateSecureMessageRequest, SecureMessage, IssueReportScope, IssueReportStatusResult, IssueReportStatus, IssueReportListResult, IssueReport, CreateIssueReportRequest, IssueReportingVoiceTokenResult, UpdateIssueReportRequest, ReplyIssueReportRequest, CreateAppLinkRequest, AppLink, AuthResponse, User as User$1, CreateCryptoInvoiceRequest, CryptoInvoiceStatusSnapshot, CheckoutSession, X402ResourceStatusResponse, X402ActionResponse, X402ReceiptResponse, X402ReceiptListResponse, X402HandoffVerification, DayrateAvailabilityResponse, DayrateBookingRequest, DayrateBookingResponse, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayrateX402BookingRequest, DayrateX402BookingResponse, DayrateCheckoutStatusResponse, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlRecordRequest, UsageControlRecordResponse, Subscription, VerifyCryptoWebhookSignatureOptions } from 'spaps-types';
|
|
3
|
-
export { AdminPermission, AdminRole, AdminUser, ApiResponse, AppLink, AuthResponse, CheckoutSession, CreateAppLinkRequest, CreateCryptoInvoiceRequest, CreateIssueReportRequest, CreatePriceRequest, CreateProductRequest, CreateSecureMessageInput, CreateSecureMessageRequest, CryptoInvoice, CryptoInvoiceResponse, CryptoInvoiceStatusSnapshot, CryptoReconcileRequest, DayrateAvailabilityResponse, DayrateAvailableSlot, DayrateBookingRequest, DayrateBookingResponse, DayrateCheckoutStatus, DayrateCheckoutStatusBooking, DayrateCheckoutStatusResponse, DayrateDayOfWeek, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayratePriceBreakdown, DayrateSlotType, DayrateX402BookingRequest, DayrateX402BookingResponse, Entitlement, IssueReport, IssueReportListResult, IssueReportStatus, IssueReportStatusResult, IssueReportTarget, IssueReportingInputMode, IssueReportingVoiceProvider, IssueReportingVoiceTokenResult, LinkedIssueReportCase, Price, Product, ProductSyncResult, ReplyIssueReportRequest, ResourceType, SecureMessage, SecureMessageOutput, Subscription, TokenPair, UpdateIssueReportRequest, UpdateProductRequest, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlDecision, UsageControlDimensions, UsageControlError, UsageControlErrorCode, UsageControlLedgerEvent, UsageControlRecordRequest, UsageControlRecordResponse, UsageControlRecordStatus, User, UserProfile, UserRole, UserWallet, VerifyCryptoWebhookSignatureOptions, X402ActionFreeResponse, X402ActionOutcome, X402ActionPendingResponse, X402ActionReplayedResponse, X402ActionResponse, X402ActionSettledResponse, X402ExecuteActionRequest, X402HandoffAuthorization, X402HandoffVerification, X402HandoffVerifyRequest, X402PaymentAccept, X402PaymentRequirement, X402ProjectionStatus, X402Receipt, X402ReceiptListResponse, X402ReceiptResponse, X402ReceiptStatus, X402Resource, X402ResourceStatus, X402ResourceStatusResponse, atomicToMoneyUnits, createSecureMessageRequestSchema, isX402PaymentRequired, isX402ResourceStatus, moneyUnitsToAtomic, roundHalfToPositiveInfinity, secureMessageMetadataSchema, secureMessageSchema, validatePositiveAmountAtomic } from 'spaps-types';
|
|
2
|
+
import { ResourceType, Entitlement, CreateProductRequest, Product, UpdateProductRequest, CreatePriceRequest, Price, ProductSyncResult, CryptoReconcileRequest, CreateSecureMessageRequest, SecureMessage, IssueReportScope, IssueReportStatusResult, IssueReportStatus, IssueReportListResult, IssueReport, CreateIssueReportRequest, IssueReportAttachmentOut, ListIssueReportAttachmentsResponse, IssueReportAttachmentAccessResponse, IssueReportingVoiceTokenResult, UpdateIssueReportRequest, ReplyIssueReportRequest, CreateAppLinkRequest, AppLink, AuthResponse, User as User$1, CreateCryptoInvoiceRequest, CryptoInvoiceStatusSnapshot, CheckoutSession, X402ResourceStatusResponse, X402ActionResponse, X402ReceiptResponse, X402ReceiptListResponse, X402HandoffVerification, DayrateAvailabilityResponse, DayrateBookingRequest, DayrateBookingResponse, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayrateX402BookingRequest, DayrateX402BookingResponse, DayrateCheckoutStatusResponse, UsageControlFeaturesResponse, UsageControlStatusRequest, UsageControlStatusResponse, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlRecordRequest, UsageControlRecordResponse, UsageControlHistoryRequest, UsageControlHistoryResponse, Subscription, VerifyCryptoWebhookSignatureOptions } from 'spaps-types';
|
|
3
|
+
export { AdminPermission, AdminRole, AdminUser, ApiResponse, AppLink, AuthResponse, CheckoutSession, CreateAppLinkRequest, CreateCryptoInvoiceRequest, CreateIssueReportRequest, CreatePriceRequest, CreateProductRequest, CreateSecureMessageInput, CreateSecureMessageRequest, CryptoInvoice, CryptoInvoiceResponse, CryptoInvoiceStatusSnapshot, CryptoReconcileRequest, DayrateAvailabilityResponse, DayrateAvailableSlot, DayrateBookingRequest, DayrateBookingResponse, DayrateCheckoutStatus, DayrateCheckoutStatusBooking, DayrateCheckoutStatusResponse, DayrateDayOfWeek, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayratePriceBreakdown, DayrateSlotType, DayrateX402BookingRequest, DayrateX402BookingResponse, Entitlement, IssueReport, IssueReportAttachmentAccessResponse, IssueReportAttachmentOut, IssueReportListResult, IssueReportStatus, IssueReportStatusResult, IssueReportTarget, IssueReportingInputMode, IssueReportingVoiceProvider, IssueReportingVoiceTokenResult, LinkedIssueReportCase, ListIssueReportAttachmentsResponse, Price, Product, ProductSyncResult, ReplyIssueReportRequest, ResourceType, SecureMessage, SecureMessageOutput, Subscription, TokenPair, UpdateIssueReportRequest, UpdateProductRequest, UsageControlAuthorizeRequest, UsageControlAuthorizeResponse, UsageControlDecision, UsageControlDimensions, UsageControlError, UsageControlErrorCode, UsageControlFeaturesResponse, UsageControlHistoryRequest, UsageControlHistoryResponse, UsageControlLedgerEvent, UsageControlRecordRequest, UsageControlRecordResponse, UsageControlRecordStatus, UsageControlStatusRequest, UsageControlStatusResponse, User, UserProfile, UserRole, UserWallet, VerifyCryptoWebhookSignatureOptions, X402ActionFreeResponse, X402ActionOutcome, X402ActionPendingResponse, X402ActionReplayedResponse, X402ActionResponse, X402ActionSettledResponse, X402ExecuteActionRequest, X402HandoffAuthorization, X402HandoffVerification, X402HandoffVerifyRequest, X402PaymentAccept, X402PaymentRequirement, X402ProjectionStatus, X402Receipt, X402ReceiptListResponse, X402ReceiptResponse, X402ReceiptStatus, X402Resource, X402ResourceStatus, X402ResourceStatusResponse, atomicToMoneyUnits, createSecureMessageRequestSchema, isX402PaymentRequired, isX402ResourceStatus, moneyUnitsToAtomic, roundHalfToPositiveInfinity, secureMessageMetadataSchema, secureMessageSchema, validatePositiveAmountAtomic } from 'spaps-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Permission checking utilities for SPAPS SDK
|
|
@@ -360,6 +360,9 @@ interface IssueReportListParams {
|
|
|
360
360
|
interface IssueReportStatusParams {
|
|
361
361
|
scope?: SupportedIssueReportScope;
|
|
362
362
|
}
|
|
363
|
+
interface IssueReportAttachmentUploadOptions {
|
|
364
|
+
filename?: string;
|
|
365
|
+
}
|
|
363
366
|
declare class X402PaymentRequiredSDKError extends Error {
|
|
364
367
|
readonly paymentRequiredHeader: string;
|
|
365
368
|
readonly response: unknown;
|
|
@@ -730,6 +733,22 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
730
733
|
* Create a new canonical issue report.
|
|
731
734
|
*/
|
|
732
735
|
create: (payload: CreateIssueReportRequest) => Promise<IssueReport>;
|
|
736
|
+
/**
|
|
737
|
+
* Upload one private pending screenshot attachment.
|
|
738
|
+
*/
|
|
739
|
+
uploadAttachment: (file: Blob, options?: IssueReportAttachmentUploadOptions) => Promise<IssueReportAttachmentOut>;
|
|
740
|
+
/**
|
|
741
|
+
* List non-deleted screenshot attachments for one issue report.
|
|
742
|
+
*/
|
|
743
|
+
listAttachments: (issueReportId: string) => Promise<ListIssueReportAttachmentsResponse>;
|
|
744
|
+
/**
|
|
745
|
+
* Return a short-lived private attachment access URL.
|
|
746
|
+
*/
|
|
747
|
+
getAttachmentAccessUrl: (attachmentId: string) => Promise<IssueReportAttachmentAccessResponse>;
|
|
748
|
+
/**
|
|
749
|
+
* Soft-delete one owned screenshot attachment.
|
|
750
|
+
*/
|
|
751
|
+
deleteAttachment: (attachmentId: string) => Promise<void>;
|
|
733
752
|
/**
|
|
734
753
|
* Create a short-lived voice transcription token for issue reporting.
|
|
735
754
|
*/
|
|
@@ -963,7 +982,7 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
963
982
|
updateProductSuperAdmin: (productId: string, updates: any) => Promise<any>;
|
|
964
983
|
deleteProductSuperAdmin: (productId: string) => Promise<any>;
|
|
965
984
|
createProductWithPrice: (payload: any) => Promise<any>;
|
|
966
|
-
createProductWithPriceSuperAdmin: (
|
|
985
|
+
createProductWithPriceSuperAdmin: (applicationId: string, payload: any) => Promise<any>;
|
|
967
986
|
setDefaultPrice: (productId: string, payload: {
|
|
968
987
|
price_id: string;
|
|
969
988
|
}) => Promise<any>;
|
|
@@ -1099,6 +1118,14 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
1099
1118
|
* after work completes.
|
|
1100
1119
|
*/
|
|
1101
1120
|
usage: {
|
|
1121
|
+
/**
|
|
1122
|
+
* List active usage feature definitions for this application.
|
|
1123
|
+
*/
|
|
1124
|
+
listFeatures: () => Promise<UsageControlFeaturesResponse>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Fetch current window usage status without creating an authorization.
|
|
1127
|
+
*/
|
|
1128
|
+
getStatus: (query: UsageControlStatusRequest) => Promise<UsageControlStatusResponse>;
|
|
1102
1129
|
/**
|
|
1103
1130
|
* Authorize proposed usage before a downstream job, inference, or action runs.
|
|
1104
1131
|
*/
|
|
@@ -1107,16 +1134,26 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
1107
1134
|
* Record immutable usage after work completes.
|
|
1108
1135
|
*/
|
|
1109
1136
|
record: (payload: UsageControlRecordRequest) => Promise<UsageControlRecordResponse>;
|
|
1137
|
+
/**
|
|
1138
|
+
* List usage events in deterministic newest-first order.
|
|
1139
|
+
*/
|
|
1140
|
+
listHistory: (query?: UsageControlHistoryRequest) => Promise<UsageControlHistoryResponse>;
|
|
1110
1141
|
};
|
|
1111
1142
|
createCheckoutSession(priceId: string, successUrl: string, cancelUrl?: string): Promise<{
|
|
1112
1143
|
data: CheckoutSession;
|
|
1113
1144
|
}>;
|
|
1114
|
-
getSubscription(): Promise<{
|
|
1145
|
+
getSubscription(subscriptionId?: string): Promise<{
|
|
1146
|
+
data: Subscription | Subscription[];
|
|
1147
|
+
}>;
|
|
1148
|
+
cancelSubscription(subscriptionId?: string, options?: {
|
|
1149
|
+
immediately?: boolean;
|
|
1150
|
+
}): Promise<{
|
|
1115
1151
|
data: Subscription;
|
|
1116
1152
|
}>;
|
|
1117
|
-
cancelSubscription(): Promise<void>;
|
|
1118
1153
|
authorizeUsage(payload: UsageControlAuthorizeRequest): Promise<UsageControlAuthorizeResponse>;
|
|
1119
1154
|
recordUsage(payload: UsageControlRecordRequest): Promise<UsageControlRecordResponse>;
|
|
1155
|
+
getUsageStatus(query: UsageControlStatusRequest): Promise<UsageControlStatusResponse>;
|
|
1156
|
+
listUsageHistory(query?: UsageControlHistoryRequest): Promise<UsageControlHistoryResponse>;
|
|
1120
1157
|
private createSecureMessage;
|
|
1121
1158
|
private listSecureMessages;
|
|
1122
1159
|
/**
|
|
@@ -1298,4 +1335,4 @@ declare function createServerClient(secretKey: string, options?: Omit<SPAPSConfi
|
|
|
1298
1335
|
*/
|
|
1299
1336
|
declare function detectKeyType(key: string): ApiKeyType | null;
|
|
1300
1337
|
|
|
1301
|
-
export { type AdminConfig, type ApiKeyType, type CheckoutLineItem, type CheckoutLineItemPriceData, type CreateCheckoutSessionPayload, type CreateSkillEvalCaseRequest, type CreateSkillEvalGovernanceSnapshotRequest, DEFAULT_ADMIN_ACCOUNTS, type EmailSendOptions, type EmailSendResult, type EmailTemplate, type EmailTemplatePreview, type EntitlementCheckResult, type EntitlementListParams, type FeatureContext, type FeatureDefinition, FeatureEvaluator, type HeaderProvider, type ImportSkillEvalGovernanceOutcomeRequest, type IssueReportListParams, type IssueReportStatusParams, type PermissionCheckResult, PermissionChecker, type RespondToSkillEvalReviewRequest, type RevealSkillEvalEvidenceRequest, RoleHierarchy, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type SPAPSEnvelope, type SkillEvalAccessMode, type SkillEvalActorAccess, type SkillEvalCandidateInput, type SkillEvalCandidateResponse, type SkillEvalCasePolicy, type SkillEvalCaseResponse, type SkillEvalConfidence, type SkillEvalCreateOptions, type SkillEvalDisclosurePolicy, type SkillEvalEligibilitySource, type SkillEvalGovernanceOutcomeResult, type SkillEvalGovernancePurpose, type SkillEvalGovernanceSnapshotResult, type SkillEvalInsight, type SkillEvalInsightsResponse, type SkillEvalModelEffort, type SkillEvalMutationOptions, type SkillEvalPosterResponse, type SkillEvalPosterResponseResult, type SkillEvalRevealField, type SkillEvalRevealResult, type SkillEvalReviewMarkInput, type SkillEvalReviewMarkKind, type SkillEvalReviewResponse, type SkillEvalReviewRoom, type SkillEvalReviewerEligibilityInput, type SkillEvalRewardEvent, type SubmitSkillEvalReviewRequest, type TemplateVariable, TokenManager, WalletUtils, WebSocketAuthHelper, type WebSocketAuthHelperConfig, type X402ExecuteActionOptions, X402PaymentRequiredSDKError, type X402ReceiptListParams, type X402VerifyHandoffOptions, canAccessAdmin, createBrowserClient, createPermissionChecker, createServerClient, SPAPSClient as default, defaultPermissionChecker, detectKeyType, getRoleAwareErrorMessage, getUserDisplay, getUserRole, hasPermission, isAdminAccount, isEnvelope, isErrorEnvelope, isSuccessEnvelope, unwrapEnvelope, unwrapNestedData, verifyCryptoWebhookSignature };
|
|
1338
|
+
export { type AdminConfig, type ApiKeyType, type CheckoutLineItem, type CheckoutLineItemPriceData, type CreateCheckoutSessionPayload, type CreateSkillEvalCaseRequest, type CreateSkillEvalGovernanceSnapshotRequest, DEFAULT_ADMIN_ACCOUNTS, type EmailSendOptions, type EmailSendResult, type EmailTemplate, type EmailTemplatePreview, type EntitlementCheckResult, type EntitlementListParams, type FeatureContext, type FeatureDefinition, FeatureEvaluator, type HeaderProvider, type ImportSkillEvalGovernanceOutcomeRequest, type IssueReportAttachmentUploadOptions, type IssueReportListParams, type IssueReportStatusParams, type PermissionCheckResult, PermissionChecker, type RespondToSkillEvalReviewRequest, type RevealSkillEvalEvidenceRequest, RoleHierarchy, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type SPAPSEnvelope, type SkillEvalAccessMode, type SkillEvalActorAccess, type SkillEvalCandidateInput, type SkillEvalCandidateResponse, type SkillEvalCasePolicy, type SkillEvalCaseResponse, type SkillEvalConfidence, type SkillEvalCreateOptions, type SkillEvalDisclosurePolicy, type SkillEvalEligibilitySource, type SkillEvalGovernanceOutcomeResult, type SkillEvalGovernancePurpose, type SkillEvalGovernanceSnapshotResult, type SkillEvalInsight, type SkillEvalInsightsResponse, type SkillEvalModelEffort, type SkillEvalMutationOptions, type SkillEvalPosterResponse, type SkillEvalPosterResponseResult, type SkillEvalRevealField, type SkillEvalRevealResult, type SkillEvalReviewMarkInput, type SkillEvalReviewMarkKind, type SkillEvalReviewResponse, type SkillEvalReviewRoom, type SkillEvalReviewerEligibilityInput, type SkillEvalRewardEvent, type SubmitSkillEvalReviewRequest, type TemplateVariable, TokenManager, WalletUtils, WebSocketAuthHelper, type WebSocketAuthHelperConfig, type X402ExecuteActionOptions, X402PaymentRequiredSDKError, type X402ReceiptListParams, type X402VerifyHandoffOptions, canAccessAdmin, createBrowserClient, createPermissionChecker, createServerClient, SPAPSClient as default, defaultPermissionChecker, detectKeyType, getRoleAwareErrorMessage, getUserDisplay, getUserRole, hasPermission, isAdminAccount, isEnvelope, isErrorEnvelope, isSuccessEnvelope, unwrapEnvelope, unwrapNestedData, verifyCryptoWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -757,6 +757,61 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
757
757
|
);
|
|
758
758
|
return this.unwrapApiResponse(res, "Failed to create issue report");
|
|
759
759
|
},
|
|
760
|
+
/**
|
|
761
|
+
* Upload one private pending screenshot attachment.
|
|
762
|
+
*/
|
|
763
|
+
uploadAttachment: async (file, options) => {
|
|
764
|
+
if (typeof FormData === "undefined") {
|
|
765
|
+
throw new Error("FormData is required to upload issue report attachments");
|
|
766
|
+
}
|
|
767
|
+
const formData = new FormData();
|
|
768
|
+
const fileWithOptionalName = file;
|
|
769
|
+
const inferredFilename = typeof fileWithOptionalName.name === "string" ? fileWithOptionalName.name : void 0;
|
|
770
|
+
const filename = options?.filename ?? inferredFilename;
|
|
771
|
+
if (filename) {
|
|
772
|
+
formData.append("file", file, filename);
|
|
773
|
+
} else {
|
|
774
|
+
formData.append("file", file);
|
|
775
|
+
}
|
|
776
|
+
const res = await this.client.post(
|
|
777
|
+
"/api/v1/issue-reports/attachments",
|
|
778
|
+
formData,
|
|
779
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
780
|
+
);
|
|
781
|
+
return this.unwrapApiResponse(res, "Failed to upload issue report attachment");
|
|
782
|
+
},
|
|
783
|
+
/**
|
|
784
|
+
* List non-deleted screenshot attachments for one issue report.
|
|
785
|
+
*/
|
|
786
|
+
listAttachments: async (issueReportId) => {
|
|
787
|
+
const res = await this.client.get(
|
|
788
|
+
`/api/v1/issue-reports/${encodeURIComponent(issueReportId)}/attachments`,
|
|
789
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
790
|
+
);
|
|
791
|
+
return this.unwrapApiResponse(res, "Failed to list issue report attachments");
|
|
792
|
+
},
|
|
793
|
+
/**
|
|
794
|
+
* Return a short-lived private attachment access URL.
|
|
795
|
+
*/
|
|
796
|
+
getAttachmentAccessUrl: async (attachmentId) => {
|
|
797
|
+
const res = await this.client.get(
|
|
798
|
+
`/api/v1/issue-reports/attachments/${encodeURIComponent(attachmentId)}/access`,
|
|
799
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
800
|
+
);
|
|
801
|
+
return this.unwrapApiResponse(
|
|
802
|
+
res,
|
|
803
|
+
"Failed to get issue report attachment access URL"
|
|
804
|
+
);
|
|
805
|
+
},
|
|
806
|
+
/**
|
|
807
|
+
* Soft-delete one owned screenshot attachment.
|
|
808
|
+
*/
|
|
809
|
+
deleteAttachment: async (attachmentId) => {
|
|
810
|
+
await this.client.delete(
|
|
811
|
+
`/api/v1/issue-reports/attachments/${encodeURIComponent(attachmentId)}`,
|
|
812
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
813
|
+
);
|
|
814
|
+
},
|
|
760
815
|
/**
|
|
761
816
|
* Create a short-lived voice transcription token for issue reporting.
|
|
762
817
|
*/
|
|
@@ -1295,9 +1350,9 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1295
1350
|
const res = await this.client.post("/api/stripe/products/with-price", payload, { headers: { Authorization: `Bearer ${this.accessToken}` } });
|
|
1296
1351
|
return this.unwrapApiResponse(res, "Failed to create product with price");
|
|
1297
1352
|
},
|
|
1298
|
-
createProductWithPriceSuperAdmin: async (
|
|
1353
|
+
createProductWithPriceSuperAdmin: async (applicationId, payload) => {
|
|
1299
1354
|
if (!this.accessToken) throw new Error("Authentication required. Please authenticate first.");
|
|
1300
|
-
const res = await this.client.post(`/api/stripe/products/super-admin/${
|
|
1355
|
+
const res = await this.client.post(`/api/stripe/products/super-admin/${applicationId}/with-price`, payload, { headers: { Authorization: `Bearer ${this.accessToken}` } });
|
|
1301
1356
|
return this.unwrapApiResponse(res, "Failed to create product with price (super admin)");
|
|
1302
1357
|
},
|
|
1303
1358
|
setDefaultPrice: async (productId, payload) => {
|
|
@@ -1625,6 +1680,25 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1625
1680
|
* after work completes.
|
|
1626
1681
|
*/
|
|
1627
1682
|
usage = {
|
|
1683
|
+
/**
|
|
1684
|
+
* List active usage feature definitions for this application.
|
|
1685
|
+
*/
|
|
1686
|
+
listFeatures: async () => {
|
|
1687
|
+
const res = await this.client.get("/api/usage/features");
|
|
1688
|
+
return this.unwrapApiResponse(res, "Failed to list usage features");
|
|
1689
|
+
},
|
|
1690
|
+
/**
|
|
1691
|
+
* Fetch current window usage status without creating an authorization.
|
|
1692
|
+
*/
|
|
1693
|
+
getStatus: async (query) => {
|
|
1694
|
+
const q = new URLSearchParams();
|
|
1695
|
+
q.set("feature_key", query.feature_key);
|
|
1696
|
+
q.set("resource_type", query.resource_type);
|
|
1697
|
+
if (query.resource_id) q.set("resource_id", query.resource_id);
|
|
1698
|
+
if (query.subject_user_id) q.set("subject_user_id", query.subject_user_id);
|
|
1699
|
+
const res = await this.client.get(`/api/usage/status?${q.toString()}`);
|
|
1700
|
+
return this.unwrapApiResponse(res, "Failed to get usage status");
|
|
1701
|
+
},
|
|
1628
1702
|
/**
|
|
1629
1703
|
* Authorize proposed usage before a downstream job, inference, or action runs.
|
|
1630
1704
|
*/
|
|
@@ -1638,21 +1712,43 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1638
1712
|
record: async (payload) => {
|
|
1639
1713
|
const res = await this.client.post("/api/usage/record", payload);
|
|
1640
1714
|
return this.unwrapApiResponse(res, "Failed to record usage");
|
|
1715
|
+
},
|
|
1716
|
+
/**
|
|
1717
|
+
* List usage events in deterministic newest-first order.
|
|
1718
|
+
*/
|
|
1719
|
+
listHistory: async (query = {}) => {
|
|
1720
|
+
const q = new URLSearchParams();
|
|
1721
|
+
if (query.feature_key) q.set("feature_key", query.feature_key);
|
|
1722
|
+
if (query.resource_type) q.set("resource_type", query.resource_type);
|
|
1723
|
+
if (query.resource_id) q.set("resource_id", query.resource_id);
|
|
1724
|
+
if (query.subject_user_id) q.set("subject_user_id", query.subject_user_id);
|
|
1725
|
+
if (query.limit) q.set("limit", String(query.limit));
|
|
1726
|
+
if (typeof query.offset === "number") q.set("offset", String(query.offset));
|
|
1727
|
+
const suffix = q.toString() ? `?${q.toString()}` : "";
|
|
1728
|
+
const res = await this.client.get(`/api/usage/history${suffix}`);
|
|
1729
|
+
return this.unwrapApiResponse(res, "Failed to list usage history");
|
|
1641
1730
|
}
|
|
1642
1731
|
};
|
|
1643
1732
|
// Stripe Methods
|
|
1644
1733
|
async createCheckoutSession(priceId, successUrl, cancelUrl) {
|
|
1645
|
-
return this.client.post("/api/stripe/
|
|
1646
|
-
|
|
1734
|
+
return this.client.post("/api/stripe/checkout-sessions", {
|
|
1735
|
+
mode: "payment",
|
|
1736
|
+
line_items: [{ price_id: priceId, quantity: 1 }],
|
|
1647
1737
|
success_url: successUrl,
|
|
1648
|
-
cancel_url: cancelUrl
|
|
1738
|
+
cancel_url: cancelUrl ?? successUrl
|
|
1649
1739
|
});
|
|
1650
1740
|
}
|
|
1651
|
-
async getSubscription() {
|
|
1652
|
-
|
|
1741
|
+
async getSubscription(subscriptionId) {
|
|
1742
|
+
if (subscriptionId) {
|
|
1743
|
+
return this.client.get(`/api/stripe/subscription/${subscriptionId}`);
|
|
1744
|
+
}
|
|
1745
|
+
return this.client.get("/api/stripe/subscriptions");
|
|
1653
1746
|
}
|
|
1654
|
-
async cancelSubscription() {
|
|
1655
|
-
|
|
1747
|
+
async cancelSubscription(subscriptionId, options = {}) {
|
|
1748
|
+
if (!subscriptionId) {
|
|
1749
|
+
throw new Error("subscriptionId is required to cancel a subscription.");
|
|
1750
|
+
}
|
|
1751
|
+
return this.client.post(`/api/stripe/subscription/${subscriptionId}/cancel`, options);
|
|
1656
1752
|
}
|
|
1657
1753
|
// Usage Methods
|
|
1658
1754
|
async authorizeUsage(payload) {
|
|
@@ -1661,6 +1757,12 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1661
1757
|
async recordUsage(payload) {
|
|
1662
1758
|
return this.usage.record(payload);
|
|
1663
1759
|
}
|
|
1760
|
+
async getUsageStatus(query) {
|
|
1761
|
+
return this.usage.getStatus(query);
|
|
1762
|
+
}
|
|
1763
|
+
async listUsageHistory(query = {}) {
|
|
1764
|
+
return this.usage.listHistory(query);
|
|
1765
|
+
}
|
|
1664
1766
|
// Secure Messaging Methods
|
|
1665
1767
|
async createSecureMessage(payload) {
|
|
1666
1768
|
const response = await this.client.post("/api/secure-messages", payload);
|
package/dist/index.mjs
CHANGED
|
@@ -722,6 +722,61 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
722
722
|
);
|
|
723
723
|
return this.unwrapApiResponse(res, "Failed to create issue report");
|
|
724
724
|
},
|
|
725
|
+
/**
|
|
726
|
+
* Upload one private pending screenshot attachment.
|
|
727
|
+
*/
|
|
728
|
+
uploadAttachment: async (file, options) => {
|
|
729
|
+
if (typeof FormData === "undefined") {
|
|
730
|
+
throw new Error("FormData is required to upload issue report attachments");
|
|
731
|
+
}
|
|
732
|
+
const formData = new FormData();
|
|
733
|
+
const fileWithOptionalName = file;
|
|
734
|
+
const inferredFilename = typeof fileWithOptionalName.name === "string" ? fileWithOptionalName.name : void 0;
|
|
735
|
+
const filename = options?.filename ?? inferredFilename;
|
|
736
|
+
if (filename) {
|
|
737
|
+
formData.append("file", file, filename);
|
|
738
|
+
} else {
|
|
739
|
+
formData.append("file", file);
|
|
740
|
+
}
|
|
741
|
+
const res = await this.client.post(
|
|
742
|
+
"/api/v1/issue-reports/attachments",
|
|
743
|
+
formData,
|
|
744
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
745
|
+
);
|
|
746
|
+
return this.unwrapApiResponse(res, "Failed to upload issue report attachment");
|
|
747
|
+
},
|
|
748
|
+
/**
|
|
749
|
+
* List non-deleted screenshot attachments for one issue report.
|
|
750
|
+
*/
|
|
751
|
+
listAttachments: async (issueReportId) => {
|
|
752
|
+
const res = await this.client.get(
|
|
753
|
+
`/api/v1/issue-reports/${encodeURIComponent(issueReportId)}/attachments`,
|
|
754
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
755
|
+
);
|
|
756
|
+
return this.unwrapApiResponse(res, "Failed to list issue report attachments");
|
|
757
|
+
},
|
|
758
|
+
/**
|
|
759
|
+
* Return a short-lived private attachment access URL.
|
|
760
|
+
*/
|
|
761
|
+
getAttachmentAccessUrl: async (attachmentId) => {
|
|
762
|
+
const res = await this.client.get(
|
|
763
|
+
`/api/v1/issue-reports/attachments/${encodeURIComponent(attachmentId)}/access`,
|
|
764
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
765
|
+
);
|
|
766
|
+
return this.unwrapApiResponse(
|
|
767
|
+
res,
|
|
768
|
+
"Failed to get issue report attachment access URL"
|
|
769
|
+
);
|
|
770
|
+
},
|
|
771
|
+
/**
|
|
772
|
+
* Soft-delete one owned screenshot attachment.
|
|
773
|
+
*/
|
|
774
|
+
deleteAttachment: async (attachmentId) => {
|
|
775
|
+
await this.client.delete(
|
|
776
|
+
`/api/v1/issue-reports/attachments/${encodeURIComponent(attachmentId)}`,
|
|
777
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
778
|
+
);
|
|
779
|
+
},
|
|
725
780
|
/**
|
|
726
781
|
* Create a short-lived voice transcription token for issue reporting.
|
|
727
782
|
*/
|
|
@@ -1260,9 +1315,9 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1260
1315
|
const res = await this.client.post("/api/stripe/products/with-price", payload, { headers: { Authorization: `Bearer ${this.accessToken}` } });
|
|
1261
1316
|
return this.unwrapApiResponse(res, "Failed to create product with price");
|
|
1262
1317
|
},
|
|
1263
|
-
createProductWithPriceSuperAdmin: async (
|
|
1318
|
+
createProductWithPriceSuperAdmin: async (applicationId, payload) => {
|
|
1264
1319
|
if (!this.accessToken) throw new Error("Authentication required. Please authenticate first.");
|
|
1265
|
-
const res = await this.client.post(`/api/stripe/products/super-admin/${
|
|
1320
|
+
const res = await this.client.post(`/api/stripe/products/super-admin/${applicationId}/with-price`, payload, { headers: { Authorization: `Bearer ${this.accessToken}` } });
|
|
1266
1321
|
return this.unwrapApiResponse(res, "Failed to create product with price (super admin)");
|
|
1267
1322
|
},
|
|
1268
1323
|
setDefaultPrice: async (productId, payload) => {
|
|
@@ -1590,6 +1645,25 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1590
1645
|
* after work completes.
|
|
1591
1646
|
*/
|
|
1592
1647
|
usage = {
|
|
1648
|
+
/**
|
|
1649
|
+
* List active usage feature definitions for this application.
|
|
1650
|
+
*/
|
|
1651
|
+
listFeatures: async () => {
|
|
1652
|
+
const res = await this.client.get("/api/usage/features");
|
|
1653
|
+
return this.unwrapApiResponse(res, "Failed to list usage features");
|
|
1654
|
+
},
|
|
1655
|
+
/**
|
|
1656
|
+
* Fetch current window usage status without creating an authorization.
|
|
1657
|
+
*/
|
|
1658
|
+
getStatus: async (query) => {
|
|
1659
|
+
const q = new URLSearchParams();
|
|
1660
|
+
q.set("feature_key", query.feature_key);
|
|
1661
|
+
q.set("resource_type", query.resource_type);
|
|
1662
|
+
if (query.resource_id) q.set("resource_id", query.resource_id);
|
|
1663
|
+
if (query.subject_user_id) q.set("subject_user_id", query.subject_user_id);
|
|
1664
|
+
const res = await this.client.get(`/api/usage/status?${q.toString()}`);
|
|
1665
|
+
return this.unwrapApiResponse(res, "Failed to get usage status");
|
|
1666
|
+
},
|
|
1593
1667
|
/**
|
|
1594
1668
|
* Authorize proposed usage before a downstream job, inference, or action runs.
|
|
1595
1669
|
*/
|
|
@@ -1603,21 +1677,43 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1603
1677
|
record: async (payload) => {
|
|
1604
1678
|
const res = await this.client.post("/api/usage/record", payload);
|
|
1605
1679
|
return this.unwrapApiResponse(res, "Failed to record usage");
|
|
1680
|
+
},
|
|
1681
|
+
/**
|
|
1682
|
+
* List usage events in deterministic newest-first order.
|
|
1683
|
+
*/
|
|
1684
|
+
listHistory: async (query = {}) => {
|
|
1685
|
+
const q = new URLSearchParams();
|
|
1686
|
+
if (query.feature_key) q.set("feature_key", query.feature_key);
|
|
1687
|
+
if (query.resource_type) q.set("resource_type", query.resource_type);
|
|
1688
|
+
if (query.resource_id) q.set("resource_id", query.resource_id);
|
|
1689
|
+
if (query.subject_user_id) q.set("subject_user_id", query.subject_user_id);
|
|
1690
|
+
if (query.limit) q.set("limit", String(query.limit));
|
|
1691
|
+
if (typeof query.offset === "number") q.set("offset", String(query.offset));
|
|
1692
|
+
const suffix = q.toString() ? `?${q.toString()}` : "";
|
|
1693
|
+
const res = await this.client.get(`/api/usage/history${suffix}`);
|
|
1694
|
+
return this.unwrapApiResponse(res, "Failed to list usage history");
|
|
1606
1695
|
}
|
|
1607
1696
|
};
|
|
1608
1697
|
// Stripe Methods
|
|
1609
1698
|
async createCheckoutSession(priceId, successUrl, cancelUrl) {
|
|
1610
|
-
return this.client.post("/api/stripe/
|
|
1611
|
-
|
|
1699
|
+
return this.client.post("/api/stripe/checkout-sessions", {
|
|
1700
|
+
mode: "payment",
|
|
1701
|
+
line_items: [{ price_id: priceId, quantity: 1 }],
|
|
1612
1702
|
success_url: successUrl,
|
|
1613
|
-
cancel_url: cancelUrl
|
|
1703
|
+
cancel_url: cancelUrl ?? successUrl
|
|
1614
1704
|
});
|
|
1615
1705
|
}
|
|
1616
|
-
async getSubscription() {
|
|
1617
|
-
|
|
1706
|
+
async getSubscription(subscriptionId) {
|
|
1707
|
+
if (subscriptionId) {
|
|
1708
|
+
return this.client.get(`/api/stripe/subscription/${subscriptionId}`);
|
|
1709
|
+
}
|
|
1710
|
+
return this.client.get("/api/stripe/subscriptions");
|
|
1618
1711
|
}
|
|
1619
|
-
async cancelSubscription() {
|
|
1620
|
-
|
|
1712
|
+
async cancelSubscription(subscriptionId, options = {}) {
|
|
1713
|
+
if (!subscriptionId) {
|
|
1714
|
+
throw new Error("subscriptionId is required to cancel a subscription.");
|
|
1715
|
+
}
|
|
1716
|
+
return this.client.post(`/api/stripe/subscription/${subscriptionId}/cancel`, options);
|
|
1621
1717
|
}
|
|
1622
1718
|
// Usage Methods
|
|
1623
1719
|
async authorizeUsage(payload) {
|
|
@@ -1626,6 +1722,12 @@ var SPAPSClient = class _SPAPSClient {
|
|
|
1626
1722
|
async recordUsage(payload) {
|
|
1627
1723
|
return this.usage.record(payload);
|
|
1628
1724
|
}
|
|
1725
|
+
async getUsageStatus(query) {
|
|
1726
|
+
return this.usage.getStatus(query);
|
|
1727
|
+
}
|
|
1728
|
+
async listUsageHistory(query = {}) {
|
|
1729
|
+
return this.usage.listHistory(query);
|
|
1730
|
+
}
|
|
1629
1731
|
// Secure Messaging Methods
|
|
1630
1732
|
async createSecureMessage(payload) {
|
|
1631
1733
|
const response = await this.client.post("/api/secure-messages", payload);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spaps-sdk",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Sweet Potato Authentication & Payment Service SDK - Zero-config client with built-in permission checking, role-based access control, and dayrate scheduling",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"axios": "^1.15.1",
|
|
53
53
|
"cross-fetch": "^4.0.0",
|
|
54
|
-
"spaps-types": "^1.
|
|
54
|
+
"spaps-types": "^1.4.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^20.10.0",
|