@echoxyz/sonar-core 0.13.0 → 0.14.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7101949: All onUnauthorized to be passed into createClient
8
+
9
+ ## 0.14.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Add wrapper function and hook for ReadCommitmentData endpoint
14
+
3
15
  ## 0.13.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -316,6 +316,16 @@ var SonarClient = class {
316
316
  SaleUUID: args.saleUUID
317
317
  });
318
318
  }
319
+ // Public API
320
+ async readCommitmentData(args) {
321
+ return this.postJSON(
322
+ "/sales.ReadCommitmentData",
323
+ {
324
+ SaleUUID: args.saleUUID
325
+ },
326
+ { includeAuth: false }
327
+ );
328
+ }
319
329
  };
320
330
  var APIError = class extends Error {
321
331
  status;
@@ -438,9 +448,14 @@ function createClient(options) {
438
448
  if (onTokenChange) {
439
449
  authSession.onTokenChange(onTokenChange);
440
450
  }
451
+ const onUnauthorized = () => {
452
+ var _a;
453
+ authSession.clear();
454
+ (_a = options == null ? void 0 : options.onUnauthorized) == null ? void 0 : _a.call(options);
455
+ };
441
456
  return new SonarClient({
442
457
  apiURL,
443
- opts: { auth: authSession, fetch, onUnauthorized: () => authSession.clear() }
458
+ opts: { auth: authSession, fetch, onUnauthorized }
444
459
  });
445
460
  }
446
461
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.d.cts CHANGED
@@ -126,6 +126,22 @@ type EntityInvestment = {
126
126
  type EntityInvestmentHistoryResponse = {
127
127
  Investments: EntityInvestment[];
128
128
  };
129
+ type Commitment = {
130
+ CommitmentID: Hex;
131
+ SaleSpecificEntityID: Hex;
132
+ PriceNumerator: string;
133
+ PriceDenominator: string;
134
+ PriceMicroUSD?: string;
135
+ Amounts: WalletTokenAmount[];
136
+ CreatedAt: string;
137
+ ExtraRaw: Hex;
138
+ ExtraDataParsed: unknown;
139
+ };
140
+ type WalletTokenAmount = {
141
+ Wallet: Hex;
142
+ Token: Hex;
143
+ Amount: string;
144
+ };
129
145
 
130
146
  type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
131
147
  type PrePurchaseCheckResponse = {
@@ -148,6 +164,16 @@ type ReadEntityResponse = {
148
164
  type ListAvailableEntitiesResponse = {
149
165
  Entities: EntityDetails[];
150
166
  };
167
+ type ReadCommitmentDataResponse = {
168
+ TotalCommitmentAmount: string;
169
+ ClearingPriceNumerator?: string;
170
+ ClearingPriceDenominator?: string;
171
+ ClearingPriceMicroUSD?: string;
172
+ PaymentTokenDecimals: number;
173
+ OfferedTokenDecimals?: number;
174
+ UniqueCommitmentCount: number;
175
+ Commitments: Commitment[];
176
+ };
151
177
  type TokenResponse = {
152
178
  access_token: string;
153
179
  refresh_token: string;
@@ -205,6 +231,9 @@ declare class SonarClient {
205
231
  listAvailableEntities(args: {
206
232
  saleUUID: string;
207
233
  }): Promise<ListAvailableEntitiesResponse>;
234
+ readCommitmentData(args: {
235
+ saleUUID: string;
236
+ }): Promise<ReadCommitmentDataResponse>;
208
237
  }
209
238
  declare class APIError extends Error {
210
239
  readonly status: number;
@@ -236,7 +265,8 @@ type CreateClientOptions = {
236
265
  tokenKey?: string;
237
266
  onExpire?: () => void;
238
267
  onTokenChange?: (token?: string) => void;
268
+ onUnauthorized?: () => void;
239
269
  };
240
270
  declare function createClient(options?: CreateClientOptions): SonarClient;
241
271
 
242
- export { APIError, type AllocationPermit, type BasicPermit, type BasicPermitV2, type BasicPermitV3, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, type EntityID, type EntityInvestment, type EntityInvestmentHistoryResponse, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type LimitsResponse, type ListAvailableEntitiesResponse, type MyProfileResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
272
+ export { APIError, type AllocationPermit, type BasicPermit, type BasicPermitV2, type BasicPermitV3, type BuildAuthorizationUrlArgs, type ClientOptions, type Commitment, type CreateClientOptions, type EntityDetails, type EntityID, type EntityInvestment, type EntityInvestmentHistoryResponse, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type LimitsResponse, type ListAvailableEntitiesResponse, type MyProfileResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadCommitmentDataResponse, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, type WalletTokenAmount, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.d.ts CHANGED
@@ -126,6 +126,22 @@ type EntityInvestment = {
126
126
  type EntityInvestmentHistoryResponse = {
127
127
  Investments: EntityInvestment[];
128
128
  };
129
+ type Commitment = {
130
+ CommitmentID: Hex;
131
+ SaleSpecificEntityID: Hex;
132
+ PriceNumerator: string;
133
+ PriceDenominator: string;
134
+ PriceMicroUSD?: string;
135
+ Amounts: WalletTokenAmount[];
136
+ CreatedAt: string;
137
+ ExtraRaw: Hex;
138
+ ExtraDataParsed: unknown;
139
+ };
140
+ type WalletTokenAmount = {
141
+ Wallet: Hex;
142
+ Token: Hex;
143
+ Amount: string;
144
+ };
129
145
 
130
146
  type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
131
147
  type PrePurchaseCheckResponse = {
@@ -148,6 +164,16 @@ type ReadEntityResponse = {
148
164
  type ListAvailableEntitiesResponse = {
149
165
  Entities: EntityDetails[];
150
166
  };
167
+ type ReadCommitmentDataResponse = {
168
+ TotalCommitmentAmount: string;
169
+ ClearingPriceNumerator?: string;
170
+ ClearingPriceDenominator?: string;
171
+ ClearingPriceMicroUSD?: string;
172
+ PaymentTokenDecimals: number;
173
+ OfferedTokenDecimals?: number;
174
+ UniqueCommitmentCount: number;
175
+ Commitments: Commitment[];
176
+ };
151
177
  type TokenResponse = {
152
178
  access_token: string;
153
179
  refresh_token: string;
@@ -205,6 +231,9 @@ declare class SonarClient {
205
231
  listAvailableEntities(args: {
206
232
  saleUUID: string;
207
233
  }): Promise<ListAvailableEntitiesResponse>;
234
+ readCommitmentData(args: {
235
+ saleUUID: string;
236
+ }): Promise<ReadCommitmentDataResponse>;
208
237
  }
209
238
  declare class APIError extends Error {
210
239
  readonly status: number;
@@ -236,7 +265,8 @@ type CreateClientOptions = {
236
265
  tokenKey?: string;
237
266
  onExpire?: () => void;
238
267
  onTokenChange?: (token?: string) => void;
268
+ onUnauthorized?: () => void;
239
269
  };
240
270
  declare function createClient(options?: CreateClientOptions): SonarClient;
241
271
 
242
- export { APIError, type AllocationPermit, type BasicPermit, type BasicPermitV2, type BasicPermitV3, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, type EntityID, type EntityInvestment, type EntityInvestmentHistoryResponse, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type LimitsResponse, type ListAvailableEntitiesResponse, type MyProfileResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
272
+ export { APIError, type AllocationPermit, type BasicPermit, type BasicPermitV2, type BasicPermitV3, type BuildAuthorizationUrlArgs, type ClientOptions, type Commitment, type CreateClientOptions, type EntityDetails, type EntityID, type EntityInvestment, type EntityInvestmentHistoryResponse, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type LimitsResponse, type ListAvailableEntitiesResponse, type MyProfileResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadCommitmentDataResponse, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, type WalletTokenAmount, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.js CHANGED
@@ -279,6 +279,16 @@ var SonarClient = class {
279
279
  SaleUUID: args.saleUUID
280
280
  });
281
281
  }
282
+ // Public API
283
+ async readCommitmentData(args) {
284
+ return this.postJSON(
285
+ "/sales.ReadCommitmentData",
286
+ {
287
+ SaleUUID: args.saleUUID
288
+ },
289
+ { includeAuth: false }
290
+ );
291
+ }
282
292
  };
283
293
  var APIError = class extends Error {
284
294
  status;
@@ -401,9 +411,14 @@ function createClient(options) {
401
411
  if (onTokenChange) {
402
412
  authSession.onTokenChange(onTokenChange);
403
413
  }
414
+ const onUnauthorized = () => {
415
+ var _a;
416
+ authSession.clear();
417
+ (_a = options == null ? void 0 : options.onUnauthorized) == null ? void 0 : _a.call(options);
418
+ };
404
419
  return new SonarClient({
405
420
  apiURL,
406
- opts: { auth: authSession, fetch, onUnauthorized: () => authSession.clear() }
421
+ opts: { auth: authSession, fetch, onUnauthorized }
407
422
  });
408
423
  }
409
424
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",