spaps-sdk 1.6.1 → 1.6.3
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 +87 -0
- package/LICENSE +21 -0
- package/PERMISSIONS.md +390 -0
- package/README.md +133 -349
- package/dist/index.d.mts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +73 -0
- package/dist/index.mjs +73 -0
- package/package.json +8 -4
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, AuthResponse, User as User$1, CreateCryptoInvoiceRequest, CryptoInvoiceStatusSnapshot, CheckoutSession, DayrateAvailabilityResponse, DayrateBookingRequest, DayrateBookingResponse, DayrateMultiBookingRequest, DayrateMultiBookingResponse, Subscription, UsageBalance, VerifyCryptoWebhookSignatureOptions } from 'spaps-types';
|
|
3
|
-
export { AdminPermission, AdminRole, AdminUser, ApiResponse, AuthResponse, CheckoutSession, CreateCryptoInvoiceRequest, CreatePriceRequest, CreateProductRequest, CreateSecureMessageInput, CreateSecureMessageRequest, CryptoInvoice, CryptoInvoiceResponse, CryptoInvoiceStatusSnapshot, CryptoReconcileRequest, DayrateAvailabilityResponse, DayrateAvailableSlot, DayrateBookingRequest, DayrateBookingResponse, DayrateDayOfWeek, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayratePriceBreakdown, DayrateSlotType, Entitlement, Price, Product, ProductSyncResult, ResourceType, SecureMessage, SecureMessageOutput, Subscription, TokenPair, UpdateProductRequest, UsageBalance, User, UserProfile, UserRole, UserWallet, VerifyCryptoWebhookSignatureOptions, createSecureMessageRequestSchema, secureMessageMetadataSchema, secureMessageSchema } from 'spaps-types';
|
|
2
|
+
import { ResourceType, Entitlement, CreateProductRequest, Product, UpdateProductRequest, CreatePriceRequest, Price, ProductSyncResult, CryptoReconcileRequest, CreateSecureMessageRequest, SecureMessage, IssueReportStatusResult, IssueReportStatus, IssueReportListResult, IssueReport, CreateIssueReportRequest, UpdateIssueReportRequest, ReplyIssueReportRequest, AuthResponse, User as User$1, CreateCryptoInvoiceRequest, CryptoInvoiceStatusSnapshot, CheckoutSession, DayrateAvailabilityResponse, DayrateBookingRequest, DayrateBookingResponse, DayrateMultiBookingRequest, DayrateMultiBookingResponse, Subscription, UsageBalance, VerifyCryptoWebhookSignatureOptions } from 'spaps-types';
|
|
3
|
+
export { AdminPermission, AdminRole, AdminUser, ApiResponse, AuthResponse, CheckoutSession, CreateCryptoInvoiceRequest, CreateIssueReportRequest, CreatePriceRequest, CreateProductRequest, CreateSecureMessageInput, CreateSecureMessageRequest, CryptoInvoice, CryptoInvoiceResponse, CryptoInvoiceStatusSnapshot, CryptoReconcileRequest, DayrateAvailabilityResponse, DayrateAvailableSlot, DayrateBookingRequest, DayrateBookingResponse, DayrateDayOfWeek, DayrateMultiBookingRequest, DayrateMultiBookingResponse, DayratePriceBreakdown, DayrateSlotType, Entitlement, IssueReport, IssueReportListResult, IssueReportStatus, IssueReportStatusResult, IssueReportTarget, LinkedIssueReportCase, Price, Product, ProductSyncResult, ReplyIssueReportRequest, ResourceType, SecureMessage, SecureMessageOutput, Subscription, TokenPair, UpdateIssueReportRequest, UpdateProductRequest, UsageBalance, User, UserProfile, UserRole, UserWallet, VerifyCryptoWebhookSignatureOptions, createSecureMessageRequestSchema, secureMessageMetadataSchema, secureMessageSchema } from 'spaps-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Permission checking utilities for SPAPS SDK
|
|
@@ -344,6 +344,11 @@ interface EntitlementCheckResult {
|
|
|
344
344
|
/** The matching entitlement, if any */
|
|
345
345
|
entitlement?: Entitlement;
|
|
346
346
|
}
|
|
347
|
+
interface IssueReportListParams {
|
|
348
|
+
status?: IssueReportStatus;
|
|
349
|
+
limit?: number;
|
|
350
|
+
offset?: number;
|
|
351
|
+
}
|
|
347
352
|
|
|
348
353
|
declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Record<string, any>> {
|
|
349
354
|
private client;
|
|
@@ -429,6 +434,35 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
|
|
|
429
434
|
*/
|
|
430
435
|
listByResource: (resourceType: ResourceType, resourceId?: string) => Promise<Entitlement[]>;
|
|
431
436
|
};
|
|
437
|
+
/**
|
|
438
|
+
* Issue reporting namespace for authenticated end-user issue flows.
|
|
439
|
+
*/
|
|
440
|
+
issueReporting: {
|
|
441
|
+
/**
|
|
442
|
+
* Return canonical issue-report summary for the shared floating entrypoint.
|
|
443
|
+
*/
|
|
444
|
+
getStatus: () => Promise<IssueReportStatusResult>;
|
|
445
|
+
/**
|
|
446
|
+
* List the caller's issue reports inside the active application scope.
|
|
447
|
+
*/
|
|
448
|
+
list: (params?: IssueReportListParams) => Promise<IssueReportListResult>;
|
|
449
|
+
/**
|
|
450
|
+
* Hydrate one canonical issue report by ID.
|
|
451
|
+
*/
|
|
452
|
+
get: (issueReportId: string) => Promise<IssueReport>;
|
|
453
|
+
/**
|
|
454
|
+
* Create a new canonical issue report.
|
|
455
|
+
*/
|
|
456
|
+
create: (payload: CreateIssueReportRequest) => Promise<IssueReport>;
|
|
457
|
+
/**
|
|
458
|
+
* Update the note for an unresolved issue report.
|
|
459
|
+
*/
|
|
460
|
+
update: (issueReportId: string, payload: UpdateIssueReportRequest) => Promise<IssueReport>;
|
|
461
|
+
/**
|
|
462
|
+
* Reply to a resolved or ignored issue report and reopen the linked case.
|
|
463
|
+
*/
|
|
464
|
+
reply: (issueReportId: string, payload: ReplyIssueReportRequest) => Promise<IssueReport>;
|
|
465
|
+
};
|
|
432
466
|
constructor(config?: SPAPSConfig);
|
|
433
467
|
/** Raw API request helper that returns an ApiResponse-like shape */
|
|
434
468
|
request<T = any>(method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH', url: string, data?: any, requiresAuth?: boolean): Promise<{
|
|
@@ -895,4 +929,4 @@ declare function createServerClient(secretKey: string, options?: Omit<SPAPSConfi
|
|
|
895
929
|
*/
|
|
896
930
|
declare function detectKeyType(key: string): ApiKeyType | null;
|
|
897
931
|
|
|
898
|
-
export { type AdminConfig, type ApiKeyType, type CheckoutLineItem, type CheckoutLineItemPriceData, type CreateCheckoutSessionPayload, DEFAULT_ADMIN_ACCOUNTS, type EmailSendOptions, type EmailSendResult, type EmailTemplate, type EmailTemplatePreview, type EntitlementCheckResult, type EntitlementListParams, type FeatureContext, type FeatureDefinition, FeatureEvaluator, type PermissionCheckResult, PermissionChecker, RoleHierarchy, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type TemplateVariable, TokenManager, WalletUtils, WebSocketAuthHelper, type WebSocketAuthHelperConfig, canAccessAdmin, createBrowserClient, createPermissionChecker, createServerClient, SPAPSClient as default, defaultPermissionChecker, detectKeyType, getRoleAwareErrorMessage, getUserDisplay, getUserRole, hasPermission, isAdminAccount, verifyCryptoWebhookSignature };
|
|
932
|
+
export { type AdminConfig, type ApiKeyType, type CheckoutLineItem, type CheckoutLineItemPriceData, type CreateCheckoutSessionPayload, DEFAULT_ADMIN_ACCOUNTS, type EmailSendOptions, type EmailSendResult, type EmailTemplate, type EmailTemplatePreview, type EntitlementCheckResult, type EntitlementListParams, type FeatureContext, type FeatureDefinition, FeatureEvaluator, type IssueReportListParams, type PermissionCheckResult, PermissionChecker, RoleHierarchy, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type TemplateVariable, TokenManager, WalletUtils, WebSocketAuthHelper, type WebSocketAuthHelperConfig, canAccessAdmin, createBrowserClient, createPermissionChecker, createServerClient, SPAPSClient as default, defaultPermissionChecker, detectKeyType, getRoleAwareErrorMessage, getUserDisplay, getUserRole, hasPermission, isAdminAccount, verifyCryptoWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -630,6 +630,79 @@ var SPAPSClient = class {
|
|
|
630
630
|
return payload;
|
|
631
631
|
}
|
|
632
632
|
};
|
|
633
|
+
/**
|
|
634
|
+
* Issue reporting namespace for authenticated end-user issue flows.
|
|
635
|
+
*/
|
|
636
|
+
issueReporting = {
|
|
637
|
+
/**
|
|
638
|
+
* Return canonical issue-report summary for the shared floating entrypoint.
|
|
639
|
+
*/
|
|
640
|
+
getStatus: async () => {
|
|
641
|
+
const res = await this.client.get(
|
|
642
|
+
"/api/v1/issue-reports/status",
|
|
643
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
644
|
+
);
|
|
645
|
+
return this.unwrapApiResponse(res, "Failed to get issue report status");
|
|
646
|
+
},
|
|
647
|
+
/**
|
|
648
|
+
* List the caller's issue reports inside the active application scope.
|
|
649
|
+
*/
|
|
650
|
+
list: async (params) => {
|
|
651
|
+
const q = new URLSearchParams();
|
|
652
|
+
if (params?.status) q.append("status", params.status);
|
|
653
|
+
if (params?.limit !== void 0) q.append("limit", String(params.limit));
|
|
654
|
+
if (params?.offset !== void 0) q.append("offset", String(params.offset));
|
|
655
|
+
const qs = q.toString();
|
|
656
|
+
const res = await this.client.get(
|
|
657
|
+
`/api/v1/issue-reports${qs ? `?${qs}` : ""}`,
|
|
658
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
659
|
+
);
|
|
660
|
+
return this.unwrapApiResponse(res, "Failed to list issue reports");
|
|
661
|
+
},
|
|
662
|
+
/**
|
|
663
|
+
* Hydrate one canonical issue report by ID.
|
|
664
|
+
*/
|
|
665
|
+
get: async (issueReportId) => {
|
|
666
|
+
const res = await this.client.get(
|
|
667
|
+
`/api/v1/issue-reports/${issueReportId}`,
|
|
668
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
669
|
+
);
|
|
670
|
+
return this.unwrapApiResponse(res, "Failed to get issue report");
|
|
671
|
+
},
|
|
672
|
+
/**
|
|
673
|
+
* Create a new canonical issue report.
|
|
674
|
+
*/
|
|
675
|
+
create: async (payload) => {
|
|
676
|
+
const res = await this.client.post(
|
|
677
|
+
"/api/v1/issue-reports",
|
|
678
|
+
payload,
|
|
679
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
680
|
+
);
|
|
681
|
+
return this.unwrapApiResponse(res, "Failed to create issue report");
|
|
682
|
+
},
|
|
683
|
+
/**
|
|
684
|
+
* Update the note for an unresolved issue report.
|
|
685
|
+
*/
|
|
686
|
+
update: async (issueReportId, payload) => {
|
|
687
|
+
const res = await this.client.patch(
|
|
688
|
+
`/api/v1/issue-reports/${issueReportId}`,
|
|
689
|
+
payload,
|
|
690
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
691
|
+
);
|
|
692
|
+
return this.unwrapApiResponse(res, "Failed to update issue report");
|
|
693
|
+
},
|
|
694
|
+
/**
|
|
695
|
+
* Reply to a resolved or ignored issue report and reopen the linked case.
|
|
696
|
+
*/
|
|
697
|
+
reply: async (issueReportId, payload) => {
|
|
698
|
+
const res = await this.client.post(
|
|
699
|
+
`/api/v1/issue-reports/${issueReportId}/replies`,
|
|
700
|
+
payload,
|
|
701
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
702
|
+
);
|
|
703
|
+
return this.unwrapApiResponse(res, "Failed to reply to issue report");
|
|
704
|
+
}
|
|
705
|
+
};
|
|
633
706
|
constructor(config = {}) {
|
|
634
707
|
const apiUrl = config.apiUrl || process.env.SPAPS_API_URL || process.env.NEXT_PUBLIC_SPAPS_API_URL;
|
|
635
708
|
const isBrowser = typeof window !== "undefined";
|
package/dist/index.mjs
CHANGED
|
@@ -600,6 +600,79 @@ var SPAPSClient = class {
|
|
|
600
600
|
return payload;
|
|
601
601
|
}
|
|
602
602
|
};
|
|
603
|
+
/**
|
|
604
|
+
* Issue reporting namespace for authenticated end-user issue flows.
|
|
605
|
+
*/
|
|
606
|
+
issueReporting = {
|
|
607
|
+
/**
|
|
608
|
+
* Return canonical issue-report summary for the shared floating entrypoint.
|
|
609
|
+
*/
|
|
610
|
+
getStatus: async () => {
|
|
611
|
+
const res = await this.client.get(
|
|
612
|
+
"/api/v1/issue-reports/status",
|
|
613
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
614
|
+
);
|
|
615
|
+
return this.unwrapApiResponse(res, "Failed to get issue report status");
|
|
616
|
+
},
|
|
617
|
+
/**
|
|
618
|
+
* List the caller's issue reports inside the active application scope.
|
|
619
|
+
*/
|
|
620
|
+
list: async (params) => {
|
|
621
|
+
const q = new URLSearchParams();
|
|
622
|
+
if (params?.status) q.append("status", params.status);
|
|
623
|
+
if (params?.limit !== void 0) q.append("limit", String(params.limit));
|
|
624
|
+
if (params?.offset !== void 0) q.append("offset", String(params.offset));
|
|
625
|
+
const qs = q.toString();
|
|
626
|
+
const res = await this.client.get(
|
|
627
|
+
`/api/v1/issue-reports${qs ? `?${qs}` : ""}`,
|
|
628
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
629
|
+
);
|
|
630
|
+
return this.unwrapApiResponse(res, "Failed to list issue reports");
|
|
631
|
+
},
|
|
632
|
+
/**
|
|
633
|
+
* Hydrate one canonical issue report by ID.
|
|
634
|
+
*/
|
|
635
|
+
get: async (issueReportId) => {
|
|
636
|
+
const res = await this.client.get(
|
|
637
|
+
`/api/v1/issue-reports/${issueReportId}`,
|
|
638
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
639
|
+
);
|
|
640
|
+
return this.unwrapApiResponse(res, "Failed to get issue report");
|
|
641
|
+
},
|
|
642
|
+
/**
|
|
643
|
+
* Create a new canonical issue report.
|
|
644
|
+
*/
|
|
645
|
+
create: async (payload) => {
|
|
646
|
+
const res = await this.client.post(
|
|
647
|
+
"/api/v1/issue-reports",
|
|
648
|
+
payload,
|
|
649
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
650
|
+
);
|
|
651
|
+
return this.unwrapApiResponse(res, "Failed to create issue report");
|
|
652
|
+
},
|
|
653
|
+
/**
|
|
654
|
+
* Update the note for an unresolved issue report.
|
|
655
|
+
*/
|
|
656
|
+
update: async (issueReportId, payload) => {
|
|
657
|
+
const res = await this.client.patch(
|
|
658
|
+
`/api/v1/issue-reports/${issueReportId}`,
|
|
659
|
+
payload,
|
|
660
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
661
|
+
);
|
|
662
|
+
return this.unwrapApiResponse(res, "Failed to update issue report");
|
|
663
|
+
},
|
|
664
|
+
/**
|
|
665
|
+
* Reply to a resolved or ignored issue report and reopen the linked case.
|
|
666
|
+
*/
|
|
667
|
+
reply: async (issueReportId, payload) => {
|
|
668
|
+
const res = await this.client.post(
|
|
669
|
+
`/api/v1/issue-reports/${issueReportId}/replies`,
|
|
670
|
+
payload,
|
|
671
|
+
this.accessToken ? { headers: { Authorization: `Bearer ${this.accessToken}` } } : void 0
|
|
672
|
+
);
|
|
673
|
+
return this.unwrapApiResponse(res, "Failed to reply to issue report");
|
|
674
|
+
}
|
|
675
|
+
};
|
|
603
676
|
constructor(config = {}) {
|
|
604
677
|
const apiUrl = config.apiUrl || process.env.SPAPS_API_URL || process.env.NEXT_PUBLIC_SPAPS_API_URL;
|
|
605
678
|
const isBrowser = typeof window !== "undefined";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spaps-sdk",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
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",
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"build": "tsup --tsconfig tsconfig.json src/index.ts --format cjs,esm --dts --clean",
|
|
21
21
|
"dev": "tsup --tsconfig tsconfig.json src/index.ts --format cjs,esm --dts --watch",
|
|
22
22
|
"test": "vitest run",
|
|
23
|
+
"test:readme": "vitest run test/readme-snippets.test.ts",
|
|
24
|
+
"typecheck:readme": "tsc -p tsconfig.readme.json --noEmit",
|
|
23
25
|
"smoke-test": "npm run build && node smoke-test.js",
|
|
24
26
|
"prepublishOnly": "npm run build && npm run smoke-test"
|
|
25
27
|
},
|
|
@@ -36,10 +38,10 @@
|
|
|
36
38
|
"scheduling"
|
|
37
39
|
],
|
|
38
40
|
"author": "buildooor",
|
|
39
|
-
"license": "
|
|
41
|
+
"license": "MIT",
|
|
40
42
|
"repository": {
|
|
41
43
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/build000r"
|
|
44
|
+
"url": "https://github.com/build000r/sweet-potato"
|
|
43
45
|
},
|
|
44
46
|
"homepage": "https://www.buildooor.com/services",
|
|
45
47
|
"bugs": {
|
|
@@ -66,7 +68,9 @@
|
|
|
66
68
|
},
|
|
67
69
|
"files": [
|
|
68
70
|
"dist",
|
|
69
|
-
"README.md"
|
|
71
|
+
"README.md",
|
|
72
|
+
"CHANGELOG.md",
|
|
73
|
+
"PERMISSIONS.md"
|
|
70
74
|
],
|
|
71
75
|
"publishConfig": {
|
|
72
76
|
"access": "public",
|