@haakco/custd-sdk 3.77.1 → 3.78.0
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/admin-email-relay.d.ts +1 -0
- package/dist/browser-manifest.json +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/storefront.d.ts +145 -0
- package/dist/storefront.js +83 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { SiteInsightsAdminClient } from "./admin-site-insights-tasks.js";
|
|
|
11
11
|
import { SubjectExportClient } from "./admin-subject-exports.js";
|
|
12
12
|
import { TenantStorageClient } from "./admin-tenant-storage.js";
|
|
13
13
|
import { type CustdDownloadStream } from "./download-stream.js";
|
|
14
|
+
import { StorefrontClient } from "./storefront.js";
|
|
14
15
|
export { AUTH_PROJECT_DOMAIN_CONVERGENCES, AUTH_PROJECT_DOMAIN_IMAGE_COMPONENTS, AUTH_PROJECT_DOMAIN_IMAGE_SOURCES, AUTH_PROJECT_DOMAIN_LIFECYCLES, AUTH_PROJECT_DOMAIN_STATUSES, type AuthProjectAppLink, type AuthProjectAppLinkList, type AuthProjectBrandLogo, type AuthProjectDomainBinding, type AuthProjectDomainBindRequest, type AuthProjectDomainConvergence, type AuthProjectDomainDNSProof, type AuthProjectDomainImageComponent, type AuthProjectDomainImageOverride, type AuthProjectDomainImageOverrideRequest, type AuthProjectDomainImageSet, type AuthProjectDomainImageSource, type AuthProjectDomainImages, type AuthProjectDomainLifecycle, type AuthProjectDomainMintRequest, type AuthProjectDomainStatus, } from "./admin-auth-project-domain.js";
|
|
15
16
|
export { ADMIN_USER_GLOBAL_STATES, ADMIN_USER_MEMBERSHIP_STATES, ADMIN_USER_ROLES, type AdminUser, AdminUserAdminClient, type AdminUserCreateRequest, type AdminUserDisableRequest, type AdminUserEnableRequest, type AdminUserGlobalState, type AdminUserListQuery, type AdminUserListResponse, type AdminUserMembershipCreateRequest, type AdminUserMembershipState, type AdminUserPasswordReset, type AdminUserRemovalRequest, type AdminUserRole, type AdminUserScope, type AdminUserUpdateRequest, } from "./admin-users.js";
|
|
16
17
|
export { WORKFLOW_TIMING_FACT_KINDS, WORKFLOW_TIMING_STATES, WorkflowTimingAdminClient, type WorkflowTimingAttempt, type WorkflowTimingBatchResult, type WorkflowTimingContribution, type WorkflowTimingDeclaration, type WorkflowTimingDefinition, type WorkflowTimingDefinitionList, type WorkflowTimingDimensionDefinition, type WorkflowTimingDurationHistory, type WorkflowTimingDurationHistoryEntry, type WorkflowTimingDurationProjection, type WorkflowTimingEvaluation, type WorkflowTimingEvaluationArtifact, type WorkflowTimingExcludedStep, type WorkflowTimingExpectation, type WorkflowTimingFact, type WorkflowTimingFactKind, type WorkflowTimingObservation, type WorkflowTimingObservationResult, type WorkflowTimingOutcomeCounts, type WorkflowTimingPrediction, type WorkflowTimingProjectionStatus, type WorkflowTimingProvenance, type WorkflowTimingRebuildResult, type WorkflowTimingReconcileResult, type WorkflowTimingRevision, type WorkflowTimingRun, type WorkflowTimingRunDuration, type WorkflowTimingRunFact, type WorkflowTimingRunList, type WorkflowTimingRunListQuery, type WorkflowTimingRunProjection, type WorkflowTimingRunSummary, type WorkflowTimingRunTiming, type WorkflowTimingState, type WorkflowTimingStepDeclaration, type WorkflowTimingStepDefinition, type WorkflowTimingStepDuration, type WorkflowTimingStepFact, } from "./admin-workflow-timings.js";
|
|
@@ -1900,6 +1901,7 @@ export declare class CustdClient {
|
|
|
1900
1901
|
readonly measurement: MeasurementClient;
|
|
1901
1902
|
readonly ingestOperations: IngestOperationsClient;
|
|
1902
1903
|
readonly publicReads: PublicReadClient;
|
|
1904
|
+
readonly storefronts: StorefrontClient;
|
|
1903
1905
|
private baseUrl;
|
|
1904
1906
|
private getToken;
|
|
1905
1907
|
private fetchImpl;
|
|
@@ -2348,3 +2350,4 @@ export * from "./reporting-catalogue.js";
|
|
|
2348
2350
|
export type { EventSchemaDocument, EventSchemaRegisterRequest, EventSchemaStateResult, EventSchemaVersion, EventSchemaVersionList, RegisteredEventType, RegisteredEventTypeList, } from "./schema-registry.js";
|
|
2349
2351
|
export { SiteAIOwnerSession, type SiteAIOwnerSettings, type SiteAIOwnerTransport } from "./site-ai-owner.js";
|
|
2350
2352
|
export * from "./site-monitor-reports.js";
|
|
2353
|
+
export * from "./storefront.js";
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { SubjectExportClient } from "./admin-subject-exports.js";
|
|
|
12
12
|
import { TenantStorageClient } from "./admin-tenant-storage.js";
|
|
13
13
|
import { responseDownloadStream } from "./download-stream.js";
|
|
14
14
|
import { isLocalHostname } from "./secure-url.js";
|
|
15
|
+
import { StorefrontClient } from "./storefront.js";
|
|
15
16
|
export { AUTH_PROJECT_DOMAIN_CONVERGENCES, AUTH_PROJECT_DOMAIN_IMAGE_COMPONENTS, AUTH_PROJECT_DOMAIN_IMAGE_SOURCES, AUTH_PROJECT_DOMAIN_LIFECYCLES, AUTH_PROJECT_DOMAIN_STATUSES, } from "./admin-auth-project-domain.js";
|
|
16
17
|
export { ADMIN_USER_GLOBAL_STATES, ADMIN_USER_MEMBERSHIP_STATES, ADMIN_USER_ROLES, AdminUserAdminClient, } from "./admin-users.js";
|
|
17
18
|
export { WORKFLOW_TIMING_FACT_KINDS, WORKFLOW_TIMING_STATES, WorkflowTimingAdminClient, } from "./admin-workflow-timings.js";
|
|
@@ -257,6 +258,7 @@ export class CustdClient {
|
|
|
257
258
|
this.admin = new AdminNamespace((method, path, body, options) => this.adminRequest(method, path, body, options), (method, path, body, options) => this.apiRequest(method, path, body, options), (path, options) => this.offboardingDownload(path, options), (path, options) => this.auditExportDownload(path, options));
|
|
258
259
|
this.provisioning = new ProvisioningNamespace((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
259
260
|
this.reporting = new ReportingNamespace((method, path, body, options) => this.apiRequest(method, path, body, options), (path, options) => this.apiDownload(path, options));
|
|
261
|
+
this.storefronts = new StorefrontClient((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
260
262
|
this.schemas = new SchemaNamespace((method, path, body) => this.apiRequest(method, path, body));
|
|
261
263
|
this.analytics = new AnalyticsEventClient((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
262
264
|
this.parsers = new ParserClient((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
@@ -2240,3 +2242,4 @@ export * from "./public-reads.js";
|
|
|
2240
2242
|
export * from "./reporting-catalogue.js";
|
|
2241
2243
|
export { SiteAIOwnerSession } from "./site-ai-owner.js";
|
|
2242
2244
|
export * from "./site-monitor-reports.js";
|
|
2245
|
+
export * from "./storefront.js";
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
type StorefrontRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
3
|
+
/** An exact signed minor-unit count encoded as a decimal string. */
|
|
4
|
+
export type StorefrontMoney = {
|
|
5
|
+
currency: string;
|
|
6
|
+
amountMinor: string;
|
|
7
|
+
};
|
|
8
|
+
export type StorefrontUnitPrice = {
|
|
9
|
+
currency: string;
|
|
10
|
+
amount: string;
|
|
11
|
+
};
|
|
12
|
+
export type StorefrontPriceRevision = {
|
|
13
|
+
priceRevisionUuid: string;
|
|
14
|
+
revision: number;
|
|
15
|
+
unitPrice: StorefrontUnitPrice;
|
|
16
|
+
taxTreatment: string;
|
|
17
|
+
taxRate: string;
|
|
18
|
+
taxLabel: string;
|
|
19
|
+
effectiveFrom: string;
|
|
20
|
+
};
|
|
21
|
+
export type StorefrontOffer = {
|
|
22
|
+
offerUuid: string;
|
|
23
|
+
name: string;
|
|
24
|
+
billingInterval: string;
|
|
25
|
+
priceRevision: StorefrontPriceRevision;
|
|
26
|
+
};
|
|
27
|
+
export type StorefrontCatalogue = {
|
|
28
|
+
offers: StorefrontOffer[];
|
|
29
|
+
canPublish: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type StorefrontPublishOffer = {
|
|
32
|
+
offerUuid?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
billingInterval: "" | "month";
|
|
35
|
+
unitPrice: StorefrontUnitPrice;
|
|
36
|
+
taxRate: string;
|
|
37
|
+
taxLabel: string;
|
|
38
|
+
effectiveFrom?: string;
|
|
39
|
+
};
|
|
40
|
+
export type StorefrontCartLine = {
|
|
41
|
+
offerUuid: string;
|
|
42
|
+
priceRevisionUuid: string;
|
|
43
|
+
quantity: string;
|
|
44
|
+
};
|
|
45
|
+
export type StorefrontCart = {
|
|
46
|
+
cartUuid: string;
|
|
47
|
+
revision: number;
|
|
48
|
+
status: "open" | "checked_out";
|
|
49
|
+
currency: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
lines: StorefrontCartLine[];
|
|
52
|
+
};
|
|
53
|
+
/** Set an exact decimal quantity. Use "0" to remove the line. */
|
|
54
|
+
export type StorefrontLineQuantity = {
|
|
55
|
+
quantity: string;
|
|
56
|
+
};
|
|
57
|
+
export type StorefrontTotals = {
|
|
58
|
+
netTotal: StorefrontMoney;
|
|
59
|
+
taxTotal: StorefrontMoney;
|
|
60
|
+
grossTotal: StorefrontMoney;
|
|
61
|
+
};
|
|
62
|
+
export type StorefrontTax = {
|
|
63
|
+
label: string;
|
|
64
|
+
rate: string;
|
|
65
|
+
rounding: string;
|
|
66
|
+
roundingPoint: string;
|
|
67
|
+
amount: StorefrontMoney;
|
|
68
|
+
};
|
|
69
|
+
export type StorefrontServicePeriod = {
|
|
70
|
+
start: string;
|
|
71
|
+
endExclusive: string;
|
|
72
|
+
};
|
|
73
|
+
export type StorefrontQuoteLine = {
|
|
74
|
+
lineNumber: number;
|
|
75
|
+
offerUuid: string;
|
|
76
|
+
priceRevisionUuid: string;
|
|
77
|
+
description: string;
|
|
78
|
+
quantity: string;
|
|
79
|
+
unitPrice: StorefrontUnitPrice;
|
|
80
|
+
extensionRounding: string;
|
|
81
|
+
servicePeriod: StorefrontServicePeriod;
|
|
82
|
+
netAmount: StorefrontMoney;
|
|
83
|
+
tax: StorefrontTax;
|
|
84
|
+
grossAmount: StorefrontMoney;
|
|
85
|
+
};
|
|
86
|
+
export type StorefrontQuote = {
|
|
87
|
+
quoteUuid: string;
|
|
88
|
+
cartUuid: string;
|
|
89
|
+
cartRevision: number;
|
|
90
|
+
issuedAt: string;
|
|
91
|
+
expiresAt: string;
|
|
92
|
+
lines: StorefrontQuoteLine[];
|
|
93
|
+
totals: StorefrontTotals;
|
|
94
|
+
};
|
|
95
|
+
export type StorefrontInvoiceStatus = "open" | "paid";
|
|
96
|
+
export type StorefrontPaymentStatus = "pending" | "settled" | "failed";
|
|
97
|
+
export type StorefrontCheckoutState = "creating" | "ready" | "review_required";
|
|
98
|
+
export type StorefrontReceiptDelivery = {
|
|
99
|
+
channel: string;
|
|
100
|
+
notificationSourceKey: string;
|
|
101
|
+
status: string;
|
|
102
|
+
};
|
|
103
|
+
export type StorefrontReceipt = {
|
|
104
|
+
receiptUuid: string;
|
|
105
|
+
receiptNumber: string;
|
|
106
|
+
invoiceUuid: string;
|
|
107
|
+
paymentUuid: string;
|
|
108
|
+
issuedAt: string;
|
|
109
|
+
amountReceived: StorefrontMoney;
|
|
110
|
+
delivery: StorefrontReceiptDelivery;
|
|
111
|
+
};
|
|
112
|
+
export type StorefrontCreditNote = {
|
|
113
|
+
creditNoteUuid: string;
|
|
114
|
+
creditNoteNumber: string;
|
|
115
|
+
totals: StorefrontTotals;
|
|
116
|
+
};
|
|
117
|
+
export type StorefrontPurchase = {
|
|
118
|
+
invoiceUuid: string;
|
|
119
|
+
invoiceNumber: string;
|
|
120
|
+
status: StorefrontInvoiceStatus;
|
|
121
|
+
totals: StorefrontTotals;
|
|
122
|
+
checkoutState?: StorefrontCheckoutState;
|
|
123
|
+
paymentStatus?: StorefrontPaymentStatus;
|
|
124
|
+
paymentUrl?: string;
|
|
125
|
+
receipt?: StorefrontReceipt;
|
|
126
|
+
creditNote?: StorefrontCreditNote;
|
|
127
|
+
};
|
|
128
|
+
/** Browse a seller's offers and check out using the current buyer identity. */
|
|
129
|
+
export declare class StorefrontClient {
|
|
130
|
+
private readonly request;
|
|
131
|
+
constructor(request: StorefrontRequester);
|
|
132
|
+
listOffers(storefront: string, options?: RequestOptions): Promise<StorefrontCatalogue>;
|
|
133
|
+
publishOffer(storefront: string, offer: StorefrontPublishOffer, options?: RequestOptions): Promise<StorefrontOffer>;
|
|
134
|
+
createCart(storefront: string, options?: RequestOptions): Promise<StorefrontCart>;
|
|
135
|
+
getCart(storefront: string, cartUuid: string, options?: RequestOptions): Promise<StorefrontCart>;
|
|
136
|
+
updateLine(storefront: string, cartUuid: string, offerUuid: string, quantity: StorefrontLineQuantity, options?: RequestOptions): Promise<StorefrontCart>;
|
|
137
|
+
createQuote(storefront: string, cartUuid: string, options?: RequestOptions): Promise<StorefrontQuote>;
|
|
138
|
+
getQuote(storefront: string, quoteUuid: string, options?: RequestOptions): Promise<StorefrontQuote>;
|
|
139
|
+
/** Start or resume the purchase for an accepted quote. */
|
|
140
|
+
checkout(storefront: string, quoteUuid: string, options?: RequestOptions): Promise<StorefrontPurchase>;
|
|
141
|
+
getPurchase(storefront: string, invoiceUuid: string, options?: RequestOptions): Promise<StorefrontPurchase>;
|
|
142
|
+
/** Resume or retry payment for the same invoice. */
|
|
143
|
+
startPayment(storefront: string, invoiceUuid: string, options?: RequestOptions): Promise<StorefrontPurchase>;
|
|
144
|
+
}
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** Browse a seller's offers and check out using the current buyer identity. */
|
|
2
|
+
export class StorefrontClient {
|
|
3
|
+
constructor(request) {
|
|
4
|
+
this.request = request;
|
|
5
|
+
}
|
|
6
|
+
listOffers(storefront, options) {
|
|
7
|
+
return this.request("GET", storefrontPath(storefront, "offers"), undefined, options);
|
|
8
|
+
}
|
|
9
|
+
publishOffer(storefront, offer, options) {
|
|
10
|
+
return this.request("POST", storefrontPath(storefront, "offers"), offer, options);
|
|
11
|
+
}
|
|
12
|
+
createCart(storefront, options) {
|
|
13
|
+
return this.request("POST", storefrontPath(storefront, "carts"), undefined, options);
|
|
14
|
+
}
|
|
15
|
+
getCart(storefront, cartUuid, options) {
|
|
16
|
+
return this.request("GET", storefrontPath(storefront, "carts", cartUuid), undefined, options);
|
|
17
|
+
}
|
|
18
|
+
updateLine(storefront, cartUuid, offerUuid, quantity, options) {
|
|
19
|
+
return this.request("PUT", storefrontPath(storefront, "carts", cartUuid, "lines", offerUuid), { quantity: quantity.quantity }, options);
|
|
20
|
+
}
|
|
21
|
+
async createQuote(storefront, cartUuid, options) {
|
|
22
|
+
return validateQuote(await this.request("POST", storefrontPath(storefront, "carts", cartUuid, "quotes"), undefined, options));
|
|
23
|
+
}
|
|
24
|
+
async getQuote(storefront, quoteUuid, options) {
|
|
25
|
+
return validateQuote(await this.request("GET", storefrontPath(storefront, "quotes", quoteUuid), undefined, options));
|
|
26
|
+
}
|
|
27
|
+
/** Start or resume the purchase for an accepted quote. */
|
|
28
|
+
async checkout(storefront, quoteUuid, options) {
|
|
29
|
+
return validatePurchase(await this.request("POST", storefrontPath(storefront, "quotes", quoteUuid, "checkout"), undefined, options));
|
|
30
|
+
}
|
|
31
|
+
async getPurchase(storefront, invoiceUuid, options) {
|
|
32
|
+
return validatePurchase(await this.request("GET", storefrontPath(storefront, "purchases", invoiceUuid), undefined, options));
|
|
33
|
+
}
|
|
34
|
+
/** Resume or retry payment for the same invoice. */
|
|
35
|
+
async startPayment(storefront, invoiceUuid, options) {
|
|
36
|
+
return validatePurchase(await this.request("POST", storefrontPath(storefront, "purchases", invoiceUuid, "payment"), undefined, options));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function storefrontPath(...parts) {
|
|
40
|
+
const segments = parts.map((part) => {
|
|
41
|
+
if (part === "" || part === "." || part === ".." || /[\\/]/.test(part)) {
|
|
42
|
+
throw new Error("custd: invalid storefront path segment");
|
|
43
|
+
}
|
|
44
|
+
return encodeURIComponent(part);
|
|
45
|
+
});
|
|
46
|
+
return `/storefronts/${segments.join("/")}`;
|
|
47
|
+
}
|
|
48
|
+
function validateMoney(value) {
|
|
49
|
+
if (typeof value?.currency !== "string" ||
|
|
50
|
+
!/^[A-Z]{3}$/.test(value.currency) ||
|
|
51
|
+
typeof value.amountMinor !== "string" ||
|
|
52
|
+
!/^(0|-?[1-9][0-9]{0,18})$/.test(value.amountMinor)) {
|
|
53
|
+
throw new Error("custd: invalid storefront money");
|
|
54
|
+
}
|
|
55
|
+
const amount = BigInt(value.amountMinor);
|
|
56
|
+
if (amount < -9223372036854775808n || amount > 9223372036854775807n) {
|
|
57
|
+
throw new Error("custd: storefront money overflows int64");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function validateTotals(totals) {
|
|
61
|
+
validateMoney(totals.netTotal);
|
|
62
|
+
validateMoney(totals.taxTotal);
|
|
63
|
+
validateMoney(totals.grossTotal);
|
|
64
|
+
}
|
|
65
|
+
function validateQuote(quote) {
|
|
66
|
+
validateTotals(quote.totals);
|
|
67
|
+
for (const line of quote.lines) {
|
|
68
|
+
validateMoney(line.netAmount);
|
|
69
|
+
validateMoney(line.tax.amount);
|
|
70
|
+
validateMoney(line.grossAmount);
|
|
71
|
+
}
|
|
72
|
+
return quote;
|
|
73
|
+
}
|
|
74
|
+
function validatePurchase(purchase) {
|
|
75
|
+
validateTotals(purchase.totals);
|
|
76
|
+
if (purchase.receipt) {
|
|
77
|
+
validateMoney(purchase.receipt.amountReceived);
|
|
78
|
+
}
|
|
79
|
+
if (purchase.creditNote) {
|
|
80
|
+
validateTotals(purchase.creditNote.totals);
|
|
81
|
+
}
|
|
82
|
+
return purchase;
|
|
83
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* VERSION and scripts/bump-version.sh updates it, so a release cannot leave it
|
|
4
4
|
* behind.
|
|
5
5
|
*/
|
|
6
|
-
export declare const SDK_VERSION = "3.
|
|
6
|
+
export declare const SDK_VERSION = "3.78.0";
|
|
7
7
|
/** Product named in X-Custd-Sdk, so Custd can report which callers use which release. */
|
|
8
8
|
export declare const SDK_PRODUCT = "js";
|
|
9
9
|
/** Value sent in the X-Custd-Sdk header. */
|
|
10
|
-
export declare const SDK_IDENTITY = "js/3.
|
|
10
|
+
export declare const SDK_IDENTITY = "js/3.78.0";
|
package/dist/version.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* VERSION and scripts/bump-version.sh updates it, so a release cannot leave it
|
|
4
4
|
* behind.
|
|
5
5
|
*/
|
|
6
|
-
export const SDK_VERSION = "3.
|
|
6
|
+
export const SDK_VERSION = "3.78.0";
|
|
7
7
|
/** Product named in X-Custd-Sdk, so Custd can report which callers use which release. */
|
|
8
8
|
export const SDK_PRODUCT = "js";
|
|
9
9
|
/** Value sent in the X-Custd-Sdk header. */
|