@pacspace-io/sdk 0.2.1 → 0.4.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/client.js +1 -1
- package/dist/errors/index.d.ts +12 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +27 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/balance.d.ts +22 -22
- package/dist/resources/balance.d.ts.map +1 -1
- package/dist/resources/balance.js +169 -56
- package/dist/resources/balance.js.map +1 -1
- package/dist/resources/internal/batch-transport.d.ts +65 -0
- package/dist/resources/internal/batch-transport.d.ts.map +1 -0
- package/dist/resources/internal/batch-transport.js +42 -0
- package/dist/resources/internal/batch-transport.js.map +1 -0
- package/dist/resources/submission.d.ts +5 -5
- package/dist/resources/submission.d.ts.map +1 -1
- package/dist/resources/submission.js +6 -6
- package/dist/resources/submission.js.map +1 -1
- package/dist/types/balance.d.ts +86 -75
- package/dist/types/balance.d.ts.map +1 -1
- package/dist/types/submission.d.ts +3 -3
- package/dist/types/submission.d.ts.map +1 -1
- package/dist/webhooks/types.d.ts +8 -0
- package/dist/webhooks/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/client.js
CHANGED
|
@@ -188,7 +188,7 @@ class HttpClient {
|
|
|
188
188
|
const headers = {
|
|
189
189
|
'X-Api-Key': this.apiKey,
|
|
190
190
|
'Content-Type': 'application/json',
|
|
191
|
-
'User-Agent': '@pacspace-io/sdk/0.
|
|
191
|
+
'User-Agent': '@pacspace-io/sdk/0.4.0',
|
|
192
192
|
};
|
|
193
193
|
const chainId = options?.chainId ?? this.defaultChainId;
|
|
194
194
|
if (chainId !== undefined) {
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -68,6 +68,18 @@ export declare class ServiceUnavailableError extends PacSpaceError {
|
|
|
68
68
|
export declare class ValidationError extends PacSpaceError {
|
|
69
69
|
constructor(message?: string, requestPath?: string);
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Thrown when a request mixes mutually-exclusive scope fields (HTTP 400).
|
|
73
|
+
*/
|
|
74
|
+
export declare class InvalidScopeCombinationError extends PacSpaceError {
|
|
75
|
+
constructor(message?: string, requestPath?: string);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Thrown when the requested scope exceeds the maximum supported window (HTTP 400).
|
|
79
|
+
*/
|
|
80
|
+
export declare class ScopeTooWideError extends PacSpaceError {
|
|
81
|
+
constructor(message?: string, requestPath?: string);
|
|
82
|
+
}
|
|
71
83
|
/**
|
|
72
84
|
* Thrown when a polling operation exceeds the configured timeout.
|
|
73
85
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAG5B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM;CAWvB;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,OAAO,SAA+B,EAAE,WAAW,CAAC,EAAE,MAAM;CAIzE;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,aAAa;gBAEvD,OAAO,SAA4C,EACnD,WAAW,CAAC,EAAE,MAAM;CAKvB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAClC,OAAO,SAAuB,EAAE,WAAW,CAAC,EAAE,MAAM;CAIjE;AAED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MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,aAAa,CAqDf"}
|
package/dist/errors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookVerificationError = exports.TimeoutError = exports.ValidationError = exports.ServiceUnavailableError = exports.CadenceLimitError = exports.RateLimitError = exports.ContractNotDeployedError = exports.NotFoundError = exports.InsufficientCreditsError = exports.InvalidApiKeyError = exports.PacSpaceError = void 0;
|
|
3
|
+
exports.WebhookVerificationError = exports.TimeoutError = exports.ScopeTooWideError = exports.InvalidScopeCombinationError = exports.ValidationError = exports.ServiceUnavailableError = exports.CadenceLimitError = exports.RateLimitError = exports.ContractNotDeployedError = exports.NotFoundError = exports.InsufficientCreditsError = exports.InvalidApiKeyError = exports.PacSpaceError = void 0;
|
|
4
4
|
exports.mapApiError = mapApiError;
|
|
5
5
|
/**
|
|
6
6
|
* Base error class for all PacSpace SDK errors.
|
|
@@ -106,6 +106,26 @@ class ValidationError extends PacSpaceError {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
exports.ValidationError = ValidationError;
|
|
109
|
+
/**
|
|
110
|
+
* Thrown when a request mixes mutually-exclusive scope fields (HTTP 400).
|
|
111
|
+
*/
|
|
112
|
+
class InvalidScopeCombinationError extends PacSpaceError {
|
|
113
|
+
constructor(message = 'Choose either a checkpoint or a time scope for this request.', requestPath) {
|
|
114
|
+
super(message, 400, 'INVALID_SCOPE_COMBINATION', requestPath);
|
|
115
|
+
this.name = 'InvalidScopeCombinationError';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.InvalidScopeCombinationError = InvalidScopeCombinationError;
|
|
119
|
+
/**
|
|
120
|
+
* Thrown when the requested scope exceeds the maximum supported window (HTTP 400).
|
|
121
|
+
*/
|
|
122
|
+
class ScopeTooWideError extends PacSpaceError {
|
|
123
|
+
constructor(message = 'Scope window is too wide for a single request.', requestPath) {
|
|
124
|
+
super(message, 400, 'SCOPE_TOO_WIDE', requestPath);
|
|
125
|
+
this.name = 'ScopeTooWideError';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.ScopeTooWideError = ScopeTooWideError;
|
|
109
129
|
/**
|
|
110
130
|
* Thrown when a polling operation exceeds the configured timeout.
|
|
111
131
|
*/
|
|
@@ -141,6 +161,12 @@ function mapApiError(statusCode, message, requestPath, headers, apiError) {
|
|
|
141
161
|
: null);
|
|
142
162
|
switch (statusCode) {
|
|
143
163
|
case 400:
|
|
164
|
+
if (apiError?.code === 'INVALID_SCOPE_COMBINATION') {
|
|
165
|
+
return new InvalidScopeCombinationError(message, requestPath);
|
|
166
|
+
}
|
|
167
|
+
if (apiError?.code === 'SCOPE_TOO_WIDE') {
|
|
168
|
+
return new ScopeTooWideError(message, requestPath);
|
|
169
|
+
}
|
|
144
170
|
return new ValidationError(message, requestPath);
|
|
145
171
|
case 401:
|
|
146
172
|
return new InvalidApiKeyError(message, requestPath);
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAwMA,kCA+DC;AAvQD;;;GAGG;AACH,MAAa,aAAc,SAAQ,KAAK;IAQtC,YACE,OAAe,EACf,UAAkB,EAClB,IAAY,EACZ,WAAoB;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,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AAuB,CAChC,OAAO,EACP,iBAAiB,EACjB,WAAW,CACZ,CAAC;QACJ,CAAC;QACD;YACE,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -93,9 +93,9 @@ export declare class PacSpace {
|
|
|
93
93
|
}
|
|
94
94
|
export type { PacSpaceConfig, RequestOptions } from './types/config';
|
|
95
95
|
export type { RecordStatus, CheckpointType } from './types/common';
|
|
96
|
-
export type { EmitOptions, EmitAndWaitOptions, EmitResponse, DeriveOptions, DeriveResponse, VerifiedDelta, WindowSummary, CompareOptions, CompareBalances, CompareResponse, DiscrepancyReport, ReceiptResponse, CheckpointOptions, CheckpointResponse, DeltaStatusResponse, WaitForVerifiedOptions, UsageResponse, SequenceGapsOptions, SequenceGapRange, SequenceGapsResponse,
|
|
96
|
+
export type { EmitOptions, EmitAndWaitOptions, EmitResponse, DeriveOptions, DeriveResponse, VerifiedDelta, WindowSummary, CompareOptions, CompareBalances, CompareResponse, DiscrepancyReport, ReceiptResponse, CheckpointOptions, CheckpointResponse, DeltaStatusResponse, WaitForVerifiedOptions, UsageResponse, SequenceGapsOptions, SequenceGapRange, SequenceGapsResponse, ListWebhookDeliveriesOptions, ListWebhookDeliveriesResponse, CustomerRecordSummary, CustomerRecordDetail, CustomerRecordActivity, ListCustomersOptions, ListCustomersResponse, GetCustomerOptions, InvoiceProofOptions, InvoiceProofResponse, InvoiceProofDelta, InvoiceProofWindowSummary, InvoiceProofVerification, VerifyResponse, VerifySummary, VerifyRecord, VerifyVerification, } from './types/balance';
|
|
97
97
|
export type { SubmissionProfile, SubmissionAutomationOptions, CustomerUsageSummary, QueuedUsageSummary, FlushSummariesOptions, SummaryFlushFailure, SummaryFlushResult, SubmissionQueueState, } from './types/submission';
|
|
98
|
-
export { PacSpaceError, InvalidApiKeyError, InsufficientCreditsError, NotFoundError, ContractNotDeployedError, CadenceLimitError, RateLimitError, ServiceUnavailableError, ValidationError, TimeoutError, WebhookVerificationError, } from './errors';
|
|
98
|
+
export { PacSpaceError, InvalidApiKeyError, InsufficientCreditsError, NotFoundError, ContractNotDeployedError, CadenceLimitError, RateLimitError, ServiceUnavailableError, ValidationError, InvalidScopeCombinationError, ScopeTooWideError, TimeoutError, WebhookVerificationError, } from './errors';
|
|
99
99
|
export { Webhooks } from './webhooks/verify';
|
|
100
100
|
export type { VerifyOptions, } from './webhooks/verify';
|
|
101
101
|
export type { KnownWebhookEventType, WebhookEventType, WebhookEvent, WebhookEventMap, WebhookHeaders, DeltaVerifiedPayload, DeltaFailedPayload, } from './webhooks/types';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,QAAQ;IACnB;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAM,GAC3C,QAAQ;IAIX,gBAAgB;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;;OAGG;IACH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AY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,4BAA4B,EAC5B,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EACV,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Webhooks = exports.WebhookVerificationError = exports.TimeoutError = exports.ValidationError = exports.ServiceUnavailableError = exports.RateLimitError = exports.CadenceLimitError = exports.ContractNotDeployedError = exports.NotFoundError = exports.InsufficientCreditsError = exports.InvalidApiKeyError = exports.PacSpaceError = exports.PacSpace = void 0;
|
|
3
|
+
exports.Webhooks = exports.WebhookVerificationError = exports.TimeoutError = exports.ScopeTooWideError = exports.InvalidScopeCombinationError = exports.ValidationError = exports.ServiceUnavailableError = exports.RateLimitError = exports.CadenceLimitError = exports.ContractNotDeployedError = exports.NotFoundError = exports.InsufficientCreditsError = exports.InvalidApiKeyError = exports.PacSpaceError = exports.PacSpace = void 0;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
5
|
const balance_1 = require("./resources/balance");
|
|
6
6
|
const verify_1 = require("./webhooks/verify");
|
|
@@ -159,6 +159,8 @@ Object.defineProperty(exports, "CadenceLimitError", { enumerable: true, get: fun
|
|
|
159
159
|
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
160
160
|
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_1.ServiceUnavailableError; } });
|
|
161
161
|
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
|
|
162
|
+
Object.defineProperty(exports, "InvalidScopeCombinationError", { enumerable: true, get: function () { return errors_1.InvalidScopeCombinationError; } });
|
|
163
|
+
Object.defineProperty(exports, "ScopeTooWideError", { enumerable: true, get: function () { return errors_1.ScopeTooWideError; } });
|
|
162
164
|
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
163
165
|
Object.defineProperty(exports, "WebhookVerificationError", { enumerable: true, get: function () { return errors_1.WebhookVerificationError; } });
|
|
164
166
|
// Webhooks
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,iDAAsD;AACtD,8CAA6C;AAI7C,oCAAoC;AACpC,MAAM,mBAAmB,GAAG,6CAA6C,CAAC;AAE1E,uCAAuC;AACvC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,QAAQ;IACnB;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,MAAc,EACd,UAA0C,EAAE;QAE5C,OAAO,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC9C,CAAC;IAoBD;;;;;;;;;;;OAWG;IACH,YAAY,MAAsB;QAChC,sDAAsD;QACtD,IAAI,CAAC,MAAM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AAC,CAIpD,CAAC;YACF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,GAAG,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAGjC,CAAC;QACF,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;CACF;AAhJD,4BAgJC;AA6DD,SAAS;AACT,mCAckB;AAbhB,uGAAA,aAAa,OAAA;AACb,4GAAA,kBAAkB,OAAA;AAClB,kHAAA,wBAAwB,OAAA;AACxB,uGAAA,aAAa,OAAA;AACb,kHAAA,wBAAwB,OAAA;AACxB,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AACd,iHAAA,uBAAuB,OAAA;AACvB,yGAAA,eAAe,OAAA;AACf,sHAAA,4BAA4B,OAAA;AAC5B,2GAAA,iBAAiB,OAAA;AACjB,sGAAA,YAAY,OAAA;AACZ,kHAAA,wBAAwB,OAAA;AAG1B,WAAW;AACX,4CAA6C;AAApC,kGAAA,QAAQ,OAAA"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { HttpClient } from '../client';
|
|
2
|
-
import type { EmitOptions, EmitAndWaitOptions, EmitResponse, DeriveOptions, DeriveResponse, CompareOptions, CompareBalances, CompareResponse, ReceiptResponse, CheckpointOptions, CheckpointResponse, ListCheckpointsOptions, ListCheckpointsResponse, DeltaStatusResponse, WaitForVerifiedOptions, UsageResponse, SequenceGapsOptions, SequenceGapsResponse,
|
|
2
|
+
import type { EmitOptions, EmitAndWaitOptions, EmitResponse, DeriveOptions, DeriveResponse, CompareOptions, CompareBalances, CompareResponse, ReceiptResponse, CheckpointOptions, CheckpointResponse, ListCheckpointsOptions, ListCheckpointsResponse, DeltaStatusResponse, WaitForVerifiedOptions, UsageResponse, SequenceGapsOptions, SequenceGapsResponse, ListWebhookDeliveriesOptions, ListWebhookDeliveriesResponse, ListCustomersOptions, ListCustomersResponse, GetCustomerOptions, CustomerRecordDetail, InvoiceProofOptions, InvoiceProofResponse } from '../types/balance';
|
|
3
3
|
import type { RequestOptions } from '../types/config';
|
|
4
4
|
import type { CustomerUsageSummary, FlushSummariesOptions, QueuedUsageSummary, SubmissionAutomationOptions, SubmissionQueueState, SummaryFlushResult } from '../types/submission';
|
|
5
5
|
import { SubmissionCoordinator } from './submission';
|
|
6
|
+
type DeriveHelperOptions = RequestOptions & {
|
|
7
|
+
startingBalance?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
12
|
* PacSpace Balance API resource.
|
|
8
13
|
*
|
|
@@ -99,26 +104,6 @@ export declare class BalanceResource {
|
|
|
99
104
|
* Use this to identify gaps and re-emit missing deltas safely.
|
|
100
105
|
*/
|
|
101
106
|
gaps(customerId: string, options?: SequenceGapsOptions): Promise<SequenceGapsResponse>;
|
|
102
|
-
/**
|
|
103
|
-
* Record multiple deltas in a single batch request.
|
|
104
|
-
*
|
|
105
|
-
* Ideal for end-of-day reconciliation or importing historical data.
|
|
106
|
-
* Up to 100 deltas per batch.
|
|
107
|
-
*
|
|
108
|
-
* @param deltas - Array of deltas to record.
|
|
109
|
-
* @param options - Request overrides.
|
|
110
|
-
* @returns Per-delta results with totals.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* const result = await pac.balance.emitBatch([
|
|
115
|
-
* { customerId: 'cust_123', delta: -100, reason: 'usage' },
|
|
116
|
-
* { customerId: 'cust_456', delta: -200, reason: 'usage' },
|
|
117
|
-
* ]);
|
|
118
|
-
* console.log(result.totalQueued); // 2
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
emitBatch(deltas: BulkDelta[], options?: BulkEmitOptions): Promise<BulkEmitResponse>;
|
|
122
107
|
/**
|
|
123
108
|
* Queue one tenant-produced summary for SDK-managed submission.
|
|
124
109
|
*/
|
|
@@ -169,6 +154,21 @@ export declare class BalanceResource {
|
|
|
169
154
|
* ```
|
|
170
155
|
*/
|
|
171
156
|
derive(customerId: string, options?: DeriveOptions): Promise<DeriveResponse>;
|
|
157
|
+
/**
|
|
158
|
+
* Convenience helper for deriving the current UTC month.
|
|
159
|
+
*/
|
|
160
|
+
deriveCurrentMonth(customerId: string, options?: DeriveHelperOptions): Promise<DeriveResponse>;
|
|
161
|
+
/**
|
|
162
|
+
* Convenience helper for deriving a specific UTC month (`YYYY-MM`).
|
|
163
|
+
*/
|
|
164
|
+
deriveForPeriod(customerId: string, period: string, options?: DeriveHelperOptions): Promise<DeriveResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* Convenience helper for deriving a rolling window of recent UTC months.
|
|
167
|
+
*
|
|
168
|
+
* For example, `months = 3` resolves from the start of month N-2 through the
|
|
169
|
+
* end of the current UTC month.
|
|
170
|
+
*/
|
|
171
|
+
deriveMonthsBack(customerId: string, months: number, options?: DeriveHelperOptions): Promise<DeriveResponse>;
|
|
172
172
|
/**
|
|
173
173
|
* Compare balances against neutral truth for dispute resolution.
|
|
174
174
|
*
|
|
@@ -338,7 +338,6 @@ export declare class BalanceResource {
|
|
|
338
338
|
private normalizeCheckpointResponse;
|
|
339
339
|
private normalizeListCheckpointsResponse;
|
|
340
340
|
private normalizeSequenceGapsResponse;
|
|
341
|
-
private normalizeBulkEmitResponse;
|
|
342
341
|
private normalizeListCustomersResponse;
|
|
343
342
|
private normalizeCustomerDetailResponse;
|
|
344
343
|
/**
|
|
@@ -351,4 +350,5 @@ export declare class BalanceResource {
|
|
|
351
350
|
*/
|
|
352
351
|
invoiceProof(customerId: string, options?: InvoiceProofOptions): Promise<InvoiceProofResponse>;
|
|
353
352
|
}
|
|
353
|
+
export {};
|
|
354
354
|
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/resources/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/resources/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,6BAA6B,EAC7B,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,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,gCAAgC;IA6CxC,OAAO,CAAC,6BAA6B;IA6BrC,OAAO,CAAC,8BAA8B;IA8BtC,OAAO,CAAC,+BAA+B;IA8CvC;;;;;;;OAOG;IACG,YAAY,CAChB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;CAGjC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BalanceResource = void 0;
|
|
4
4
|
const polling_1 = require("../utils/polling");
|
|
5
5
|
const submission_1 = require("./submission");
|
|
6
|
+
const batch_transport_1 = require("./internal/batch-transport");
|
|
6
7
|
const toRecordStatus = (status) => {
|
|
7
8
|
const normalized = String(status ?? '').toUpperCase();
|
|
8
9
|
if (normalized === 'PROCESSING')
|
|
@@ -37,7 +38,7 @@ class BalanceResource {
|
|
|
37
38
|
constructor(client, submissionOptions) {
|
|
38
39
|
this.client = client;
|
|
39
40
|
this.submission = new submission_1.SubmissionCoordinator({
|
|
40
|
-
|
|
41
|
+
submitBatch: (deltas) => (0, batch_transport_1.submitInternalBatch)(this.client, deltas),
|
|
41
42
|
options: submissionOptions,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -174,30 +175,6 @@ class BalanceResource {
|
|
|
174
175
|
const response = await this.client.get(path, requestOptions);
|
|
175
176
|
return this.normalizeSequenceGapsResponse(response);
|
|
176
177
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Record multiple deltas in a single batch request.
|
|
179
|
-
*
|
|
180
|
-
* Ideal for end-of-day reconciliation or importing historical data.
|
|
181
|
-
* Up to 100 deltas per batch.
|
|
182
|
-
*
|
|
183
|
-
* @param deltas - Array of deltas to record.
|
|
184
|
-
* @param options - Request overrides.
|
|
185
|
-
* @returns Per-delta results with totals.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```typescript
|
|
189
|
-
* const result = await pac.balance.emitBatch([
|
|
190
|
-
* { customerId: 'cust_123', delta: -100, reason: 'usage' },
|
|
191
|
-
* { customerId: 'cust_456', delta: -200, reason: 'usage' },
|
|
192
|
-
* ]);
|
|
193
|
-
* console.log(result.totalQueued); // 2
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
async emitBatch(deltas, options) {
|
|
197
|
-
const { ...requestOptions } = options ?? {};
|
|
198
|
-
const response = await this.client.post('/api/v1/balance/delta/batch', { deltas }, requestOptions);
|
|
199
|
-
return this.normalizeBulkEmitResponse(response);
|
|
200
|
-
}
|
|
201
178
|
/**
|
|
202
179
|
* Queue one tenant-produced summary for SDK-managed submission.
|
|
203
180
|
*/
|
|
@@ -265,7 +242,7 @@ class BalanceResource {
|
|
|
265
242
|
* ```
|
|
266
243
|
*/
|
|
267
244
|
async derive(customerId, options) {
|
|
268
|
-
const { startingBalance, startingCheckpoint, startingCheckpointType, limit, offset, ...requestOptions } = options ?? {};
|
|
245
|
+
const { startingBalance, startingCheckpoint, startingCheckpointType, limit, offset, period, timePreset, startDate, endDate, ...requestOptions } = options ?? {};
|
|
269
246
|
// Build query string
|
|
270
247
|
const params = new URLSearchParams();
|
|
271
248
|
if (startingBalance !== undefined) {
|
|
@@ -284,11 +261,61 @@ class BalanceResource {
|
|
|
284
261
|
if (offset !== undefined) {
|
|
285
262
|
params.set('offset', String(offset));
|
|
286
263
|
}
|
|
264
|
+
if (period !== undefined) {
|
|
265
|
+
params.set('period', period);
|
|
266
|
+
}
|
|
267
|
+
if (timePreset !== undefined) {
|
|
268
|
+
params.set('timePreset', timePreset);
|
|
269
|
+
}
|
|
270
|
+
if (startDate !== undefined) {
|
|
271
|
+
params.set('startDate', startDate);
|
|
272
|
+
}
|
|
273
|
+
if (endDate !== undefined) {
|
|
274
|
+
params.set('endDate', endDate);
|
|
275
|
+
}
|
|
287
276
|
const query = params.toString();
|
|
288
277
|
const path = `/api/v1/balance/derive/${encodeURIComponent(customerId)}${query ? `?${query}` : ''}`;
|
|
289
278
|
const response = await this.client.get(path, requestOptions);
|
|
290
279
|
return this.normalizeDeriveResponse(response);
|
|
291
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Convenience helper for deriving the current UTC month.
|
|
283
|
+
*/
|
|
284
|
+
async deriveCurrentMonth(customerId, options) {
|
|
285
|
+
return this.derive(customerId, {
|
|
286
|
+
...options,
|
|
287
|
+
timePreset: 'current_month',
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Convenience helper for deriving a specific UTC month (`YYYY-MM`).
|
|
292
|
+
*/
|
|
293
|
+
async deriveForPeriod(customerId, period, options) {
|
|
294
|
+
return this.derive(customerId, {
|
|
295
|
+
...options,
|
|
296
|
+
period,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Convenience helper for deriving a rolling window of recent UTC months.
|
|
301
|
+
*
|
|
302
|
+
* For example, `months = 3` resolves from the start of month N-2 through the
|
|
303
|
+
* end of the current UTC month.
|
|
304
|
+
*/
|
|
305
|
+
async deriveMonthsBack(customerId, months, options) {
|
|
306
|
+
if (!Number.isInteger(months) || months < 1) {
|
|
307
|
+
throw new TypeError('months must be a positive integer');
|
|
308
|
+
}
|
|
309
|
+
const now = new Date();
|
|
310
|
+
const endExclusive = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1));
|
|
311
|
+
const start = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() - (months - 1), 1));
|
|
312
|
+
return this.derive(customerId, {
|
|
313
|
+
...options,
|
|
314
|
+
timePreset: 'custom',
|
|
315
|
+
startDate: start.toISOString(),
|
|
316
|
+
endDate: endExclusive.toISOString(),
|
|
317
|
+
});
|
|
318
|
+
}
|
|
292
319
|
// -------------------------------------------------------------------------
|
|
293
320
|
// Compare
|
|
294
321
|
// -------------------------------------------------------------------------
|
|
@@ -317,7 +344,7 @@ class BalanceResource {
|
|
|
317
344
|
* ```
|
|
318
345
|
*/
|
|
319
346
|
async compare(customerId, balances, options) {
|
|
320
|
-
const { startingBalance = 0, startingCheckpoint, startingCheckpointType, ...requestOptions } = options ?? {};
|
|
347
|
+
const { startingBalance = 0, startingCheckpoint, startingCheckpointType, period, timePreset, startDate, endDate, ...requestOptions } = options ?? {};
|
|
321
348
|
const body = {
|
|
322
349
|
customerId,
|
|
323
350
|
yourBalance: balances.yours,
|
|
@@ -331,6 +358,18 @@ class BalanceResource {
|
|
|
331
358
|
if (apiCheckpointType !== undefined) {
|
|
332
359
|
body.startingCheckpointType = apiCheckpointType;
|
|
333
360
|
}
|
|
361
|
+
if (period !== undefined) {
|
|
362
|
+
body.period = period;
|
|
363
|
+
}
|
|
364
|
+
if (timePreset !== undefined) {
|
|
365
|
+
body.timePreset = timePreset;
|
|
366
|
+
}
|
|
367
|
+
if (startDate !== undefined) {
|
|
368
|
+
body.startDate = startDate;
|
|
369
|
+
}
|
|
370
|
+
if (endDate !== undefined) {
|
|
371
|
+
body.endDate = endDate;
|
|
372
|
+
}
|
|
334
373
|
const response = await this.client.post('/api/v1/balance/compare', body, requestOptions);
|
|
335
374
|
return this.normalizeCompareResponse(response);
|
|
336
375
|
}
|
|
@@ -574,12 +613,14 @@ class BalanceResource {
|
|
|
574
613
|
* ```
|
|
575
614
|
*/
|
|
576
615
|
async customer(customerId, options) {
|
|
577
|
-
const { deltaPage, deltaLimit, ...requestOptions } = options ?? {};
|
|
616
|
+
const { deltaPage, deltaLimit, period, ...requestOptions } = options ?? {};
|
|
578
617
|
const params = new URLSearchParams();
|
|
579
618
|
if (deltaPage !== undefined)
|
|
580
619
|
params.set('deltaPage', String(deltaPage));
|
|
581
620
|
if (deltaLimit !== undefined)
|
|
582
621
|
params.set('deltaLimit', String(deltaLimit));
|
|
622
|
+
if (period !== undefined)
|
|
623
|
+
params.set('period', period);
|
|
583
624
|
const query = params.toString();
|
|
584
625
|
const path = `/api/v1/balance/customers/${encodeURIComponent(customerId)}${query ? `?${query}` : ''}`;
|
|
585
626
|
const response = await this.client.get(path, requestOptions);
|
|
@@ -692,6 +733,30 @@ class BalanceResource {
|
|
|
692
733
|
};
|
|
693
734
|
})
|
|
694
735
|
: [];
|
|
736
|
+
const scope = (data.scope ?? null);
|
|
737
|
+
const monthlyBreakdown = Array.isArray(data.monthlyBreakdown)
|
|
738
|
+
? data.monthlyBreakdown.map((entry) => {
|
|
739
|
+
const item = entry;
|
|
740
|
+
const checkpoint = (item.checkpoint ?? null);
|
|
741
|
+
return {
|
|
742
|
+
period: String(item.period ?? ''),
|
|
743
|
+
periodStart: String(item.periodStart ?? ''),
|
|
744
|
+
periodEndExclusive: String(item.periodEndExclusive ?? ''),
|
|
745
|
+
deltaCount: Number(item.deltaCount ?? 0),
|
|
746
|
+
netDelta: Number(item.netDelta ?? 0),
|
|
747
|
+
runningBalance: Number(item.runningBalance ?? 0),
|
|
748
|
+
checkpoint: checkpoint
|
|
749
|
+
? {
|
|
750
|
+
checkpointId: String(checkpoint.checkpointId ?? ''),
|
|
751
|
+
proofRoot: checkpoint.proofRoot == null
|
|
752
|
+
? null
|
|
753
|
+
: String(checkpoint.proofRoot),
|
|
754
|
+
status: toRecordStatus(checkpoint.status),
|
|
755
|
+
}
|
|
756
|
+
: null,
|
|
757
|
+
};
|
|
758
|
+
})
|
|
759
|
+
: undefined;
|
|
695
760
|
const pagination = (data.pagination ?? {});
|
|
696
761
|
const hint = data._hint;
|
|
697
762
|
return {
|
|
@@ -711,6 +776,26 @@ class BalanceResource {
|
|
|
711
776
|
: String(verificationProof.proofRoot),
|
|
712
777
|
message: String(verificationProof.message ?? ''),
|
|
713
778
|
},
|
|
779
|
+
scope: scope
|
|
780
|
+
? {
|
|
781
|
+
kind: String(scope.kind ?? 'period') === 'custom'
|
|
782
|
+
? 'custom'
|
|
783
|
+
: String(scope.kind ?? 'period') === 'preset'
|
|
784
|
+
? 'preset'
|
|
785
|
+
: 'period',
|
|
786
|
+
periodId: scope.periodId == null ? null : String(scope.periodId),
|
|
787
|
+
preset: scope.preset == null
|
|
788
|
+
? null
|
|
789
|
+
: String(scope.preset),
|
|
790
|
+
startDate: String(scope.startDate ?? ''),
|
|
791
|
+
endDateExclusive: String(scope.endDateExclusive ?? ''),
|
|
792
|
+
label: String(scope.label ?? ''),
|
|
793
|
+
}
|
|
794
|
+
: null,
|
|
795
|
+
monthlyBreakdown,
|
|
796
|
+
cumulativeBalance: data.cumulativeBalance == null
|
|
797
|
+
? undefined
|
|
798
|
+
: Number(data.cumulativeBalance),
|
|
714
799
|
pagination: {
|
|
715
800
|
total: Number(pagination.total ?? deltas.length),
|
|
716
801
|
limit: Number(pagination.limit ?? deltas.length),
|
|
@@ -727,6 +812,30 @@ class BalanceResource {
|
|
|
727
812
|
}
|
|
728
813
|
normalizeCompareResponse(data) {
|
|
729
814
|
const proof = (data.proof ?? {});
|
|
815
|
+
const scope = (data.scope ?? null);
|
|
816
|
+
const monthlyBreakdown = Array.isArray(data.monthlyBreakdown)
|
|
817
|
+
? data.monthlyBreakdown.map((entry) => {
|
|
818
|
+
const item = entry;
|
|
819
|
+
const checkpoint = (item.checkpoint ?? null);
|
|
820
|
+
return {
|
|
821
|
+
period: String(item.period ?? ''),
|
|
822
|
+
periodStart: String(item.periodStart ?? ''),
|
|
823
|
+
periodEndExclusive: String(item.periodEndExclusive ?? ''),
|
|
824
|
+
deltaCount: Number(item.deltaCount ?? 0),
|
|
825
|
+
netDelta: Number(item.netDelta ?? 0),
|
|
826
|
+
runningBalance: Number(item.runningBalance ?? 0),
|
|
827
|
+
checkpoint: checkpoint
|
|
828
|
+
? {
|
|
829
|
+
checkpointId: String(checkpoint.checkpointId ?? ''),
|
|
830
|
+
proofRoot: checkpoint.proofRoot == null
|
|
831
|
+
? null
|
|
832
|
+
: String(checkpoint.proofRoot),
|
|
833
|
+
status: toRecordStatus(checkpoint.status),
|
|
834
|
+
}
|
|
835
|
+
: null,
|
|
836
|
+
};
|
|
837
|
+
})
|
|
838
|
+
: undefined;
|
|
730
839
|
return {
|
|
731
840
|
customerId: String(data.customerId ?? ''),
|
|
732
841
|
yourBalance: Number(data.yourBalance ?? 0),
|
|
@@ -742,6 +851,26 @@ class BalanceResource {
|
|
|
742
851
|
windowSummaries: proof.windowSummaries ??
|
|
743
852
|
[],
|
|
744
853
|
},
|
|
854
|
+
scope: scope
|
|
855
|
+
? {
|
|
856
|
+
kind: String(scope.kind ?? 'period') === 'custom'
|
|
857
|
+
? 'custom'
|
|
858
|
+
: String(scope.kind ?? 'period') === 'preset'
|
|
859
|
+
? 'preset'
|
|
860
|
+
: 'period',
|
|
861
|
+
periodId: scope.periodId == null ? null : String(scope.periodId),
|
|
862
|
+
preset: scope.preset == null
|
|
863
|
+
? null
|
|
864
|
+
: String(scope.preset),
|
|
865
|
+
startDate: String(scope.startDate ?? ''),
|
|
866
|
+
endDateExclusive: String(scope.endDateExclusive ?? ''),
|
|
867
|
+
label: String(scope.label ?? ''),
|
|
868
|
+
}
|
|
869
|
+
: null,
|
|
870
|
+
monthlyBreakdown,
|
|
871
|
+
cumulativeBalance: data.cumulativeBalance == null
|
|
872
|
+
? undefined
|
|
873
|
+
: Number(data.cumulativeBalance),
|
|
745
874
|
};
|
|
746
875
|
}
|
|
747
876
|
normalizeReceiptResponse(data) {
|
|
@@ -882,34 +1011,6 @@ class BalanceResource {
|
|
|
882
1011
|
truncated: Boolean(data.truncated),
|
|
883
1012
|
};
|
|
884
1013
|
}
|
|
885
|
-
normalizeBulkEmitResponse(data) {
|
|
886
|
-
const results = Array.isArray(data.results)
|
|
887
|
-
? data.results.map((entry) => {
|
|
888
|
-
const item = entry;
|
|
889
|
-
return {
|
|
890
|
-
index: Number(item.index ?? 0),
|
|
891
|
-
customerId: String(item.customerId ?? ''),
|
|
892
|
-
delta: Number(item.delta ?? 0),
|
|
893
|
-
recordId: item.recordId == null ? undefined : String(item.recordId),
|
|
894
|
-
itemHash: item.itemHash == null ? undefined : String(item.itemHash),
|
|
895
|
-
receiptId: item.receiptId == null ? undefined : String(item.receiptId),
|
|
896
|
-
referenceId: item.referenceId == null ? undefined : String(item.referenceId),
|
|
897
|
-
sequenceNumber: item.sequenceNumber == null
|
|
898
|
-
? undefined
|
|
899
|
-
: String(item.sequenceNumber),
|
|
900
|
-
idempotent: item.idempotent == null ? undefined : Boolean(item.idempotent),
|
|
901
|
-
status: String(item.status ?? ''),
|
|
902
|
-
error: item.error == null ? undefined : String(item.error),
|
|
903
|
-
};
|
|
904
|
-
})
|
|
905
|
-
: [];
|
|
906
|
-
return {
|
|
907
|
-
totalQueued: Number(data.totalQueued ?? results.length),
|
|
908
|
-
totalFailed: Number(data.totalFailed ?? 0),
|
|
909
|
-
results,
|
|
910
|
-
_efficiency: data._efficiency,
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
1014
|
normalizeListCustomersResponse(data) {
|
|
914
1015
|
const customers = Array.isArray(data.customers)
|
|
915
1016
|
? data.customers.map((entry) => {
|
|
@@ -935,6 +1036,7 @@ class BalanceResource {
|
|
|
935
1036
|
};
|
|
936
1037
|
}
|
|
937
1038
|
normalizeCustomerDetailResponse(data) {
|
|
1039
|
+
const period = (data.period ?? null);
|
|
938
1040
|
return {
|
|
939
1041
|
customerId: String(data.customerId ?? ''),
|
|
940
1042
|
customerReference: String(data.customerReference ?? ''),
|
|
@@ -943,6 +1045,17 @@ class BalanceResource {
|
|
|
943
1045
|
lastDeltaAt: data.lastDeltaAt == null ? null : String(data.lastDeltaAt),
|
|
944
1046
|
customerPartition: String(data.customerPartition ?? ''),
|
|
945
1047
|
computedBalance: Number(data.computedBalance ?? 0),
|
|
1048
|
+
period: period
|
|
1049
|
+
? {
|
|
1050
|
+
id: String(period.id ?? ''),
|
|
1051
|
+
startDate: String(period.startDate ?? ''),
|
|
1052
|
+
endDateExclusive: String(period.endDateExclusive ?? ''),
|
|
1053
|
+
label: String(period.label ?? ''),
|
|
1054
|
+
}
|
|
1055
|
+
: undefined,
|
|
1056
|
+
mostRecentActivePeriod: data.mostRecentActivePeriod == null
|
|
1057
|
+
? null
|
|
1058
|
+
: String(data.mostRecentActivePeriod),
|
|
946
1059
|
latestCheckpoint: data.latestCheckpoint == null ? null : String(data.latestCheckpoint),
|
|
947
1060
|
privacyNote: String(data.privacyNote ?? ''),
|
|
948
1061
|
recentActivity: data.recentActivity ??
|