@reptilianhq/chain-data-client 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/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # `@reptilianhq/chain-data-client`
2
+
3
+ Typed Fetch client for Reptilian's authenticated, persisted-operation
4
+ chain-data gateway. It contains no Foundation product policy and depends only
5
+ on the versioned `@reptilianhq/chain-data-contract` package.
6
+
7
+ ## Purpose
8
+
9
+ Provide typed browser and server access to the authenticated Reptilian chain-data API.
10
+
11
+ ## Owns
12
+
13
+ - persisted-operation request transport
14
+ - bounded per-wallet portfolio balance and liquidity-position reads
15
+ - stable client errors and timeouts
16
+ - Reptilian browser-session JWT exchange, expiry caching, and refresh coalescing
17
+ - compatibility constructor aliases during migration
18
+
19
+ ## Does Not Own
20
+
21
+ - GraphQL schema, operations, or indexed data
22
+ - Foundation product policy or authentication
23
+ - API credentials or endpoint configuration
24
+
25
+ ## Import Examples
26
+
27
+ ```ts
28
+ import { createReptilianChainDataClient } from '@reptilianhq/chain-data-client';
29
+
30
+ const chainData = createReptilianChainDataClient({
31
+ endpoint: 'https://reptilian-api.example/api/v1/chain-data/graphql',
32
+ deploymentId: process.env.CHAIN_DATA_DEPLOYMENT_ID!,
33
+ headers: () => ({ 'x-api-key': process.env.REPTILIAN_API_KEY! }),
34
+ });
35
+
36
+ const launches = await chainData.getLaunchFeed({ first: 20 });
37
+ const balances = await chainData.getPortfolioWalletBalances({ wallet: '0x…', first: 100 });
38
+ const liquidity = await chainData.getPortfolioWalletLiquidityPositions({ wallet: '0x…', first: 100 });
39
+ ```
40
+
41
+ Browser applications can compose `createReptilianBrowserTokenProvider()` with
42
+ the client to send short-lived bearer tokens directly to the public gateway.
43
+ API keys remain server-side. Callers can pass an `AbortSignal` or per-request timeout.
44
+ Responses are streamed through a configurable size limit that defaults to 1 MiB.
45
+
46
+ The package exports generated operation/result types, the persisted-operation
47
+ transport, stable `ChainDataClientError` failures, and compatibility aliases
48
+ for the former `@reptilianhq/foundation-graphql` constructor names.
49
+
50
+ ## Verification
51
+
52
+ ```sh
53
+ pnpm --filter @reptilianhq/chain-data-client test
54
+ pnpm --filter @reptilianhq/chain-data-client test:packed
55
+ ```
56
+
57
+ ## Dependency Direction
58
+
59
+ This client depends on the exact published chain-data contract. Applications
60
+ and compatibility facades may depend on this client; the contract and indexer
61
+ must not depend on it.
62
+
63
+ ## Publishing
64
+
65
+ After the version commit reaches `main`, push
66
+ `chain-data-client-v<version>`. The checked workflow verifies the packed client
67
+ and publishes the exact tagged bytes to the public npm registry via OIDC
68
+ trusted publishing — no long-lived npm token is stored in this repository.
@@ -0,0 +1,75 @@
1
+ import { type ChainDataFreshness, type ChainDataLaunchConnection, type ChainDataLaunchDetail, type ChainDataLaunchPhaseInput, type ChainDataLaunchPriceSeriesConnection, type ChainDataLiquidityBookPositionDetail, type ChainDataOperationData, type ChainDataOperationName, type ChainDataOperationVariables, type ChainDataPriceVenueInput, type ChainDataPortfolioWalletBalanceResult, type ChainDataPortfolioWalletLiquidityPositionResult, type ChainDataProtocolStats, type ChainDataTrendingResult, type ChainDataWalletLaunchPositionResult, type ChainDataWalletLiquidityBookPositionResult } from './contract.js';
2
+ import { type PersistedGraphqlExecuteOptions } from './transport.js';
3
+ export type RobinhoodLaunchPhase = ChainDataLaunchPhaseInput;
4
+ export type RobinhoodLaunchSummary = ChainDataLaunchConnection['nodes'][number];
5
+ export type RobinhoodLaunchFeed = ChainDataLaunchConnection;
6
+ export type RobinhoodChainDataFreshness = ChainDataFreshness;
7
+ export interface ChainDataLaunchFeedInput {
8
+ phase?: ChainDataLaunchPhaseInput;
9
+ first?: number;
10
+ after?: string;
11
+ }
12
+ export interface ChainDataPriceSeriesInput {
13
+ token: string;
14
+ venue?: ChainDataPriceVenueInput;
15
+ first?: number;
16
+ after?: string;
17
+ }
18
+ export interface ChainDataWalletPositionsInput {
19
+ wallet: string;
20
+ first?: number;
21
+ after?: string;
22
+ }
23
+ export interface ChainDataWalletLiquidityBookPositionsInput {
24
+ wallet: string;
25
+ first?: number;
26
+ after?: string;
27
+ }
28
+ export interface ChainDataLiquidityBookPositionInput {
29
+ wallet: string;
30
+ pool: string;
31
+ binFirst?: number;
32
+ binsAfter?: string;
33
+ }
34
+ export type ChainDataRequestOptions = PersistedGraphqlExecuteOptions;
35
+ /** @deprecated Use ChainDataRequestOptions. */
36
+ export type FoundationGraphqlRequestOptions = ChainDataRequestOptions;
37
+ /** Variables supplied by callers; the client owns and injects the read deployment scope. */
38
+ export type ChainDataClientOperationVariables<Name extends ChainDataOperationName> = Omit<ChainDataOperationVariables<Name>, 'deploymentId'>;
39
+ export interface ChainDataApi {
40
+ execute<Name extends ChainDataOperationName>(operationName: Name, variables: ChainDataClientOperationVariables<Name>, requestOptions?: ChainDataRequestOptions): Promise<ChainDataOperationData<Name>>;
41
+ getLaunchFeed(input?: ChainDataLaunchFeedInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataLaunchConnection>;
42
+ getLaunchDetail(token: string, requestOptions?: ChainDataRequestOptions): Promise<ChainDataLaunchDetail | null>;
43
+ getTrendingLaunches(first?: number, requestOptions?: ChainDataRequestOptions): Promise<ChainDataTrendingResult>;
44
+ getLaunchPriceSeries(input: ChainDataPriceSeriesInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataLaunchPriceSeriesConnection>;
45
+ getWalletLaunchPositions(input: string | ChainDataWalletPositionsInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataWalletLaunchPositionResult>;
46
+ getPortfolioWalletBalances(input: ChainDataWalletPositionsInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataPortfolioWalletBalanceResult>;
47
+ getWalletLiquidityBookPositions(input: ChainDataWalletLiquidityBookPositionsInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataWalletLiquidityBookPositionResult>;
48
+ getPortfolioWalletLiquidityPositions(input: ChainDataWalletLiquidityBookPositionsInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataPortfolioWalletLiquidityPositionResult>;
49
+ getLiquidityBookPosition(input: ChainDataLiquidityBookPositionInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataLiquidityBookPositionDetail | null>;
50
+ getProtocolStats(requestOptions?: ChainDataRequestOptions): Promise<ChainDataProtocolStats>;
51
+ getFreshness(requestOptions?: ChainDataRequestOptions): Promise<ChainDataFreshness>;
52
+ getRobinhoodLaunchFeed(input?: ChainDataLaunchFeedInput, requestOptions?: ChainDataRequestOptions): Promise<ChainDataLaunchConnection>;
53
+ getRobinhoodFreshness(requestOptions?: ChainDataRequestOptions): Promise<ChainDataFreshness>;
54
+ }
55
+ export interface ChainDataClientOptions {
56
+ /** Exact persisted-operation endpoint, including /api/v1/chain-data/graphql. */
57
+ endpoint: string;
58
+ /** Opaque read scope obtained from the launchpad deployment registry. */
59
+ deploymentId: string;
60
+ /** Resolve credentials at request time. API keys must remain server-side. */
61
+ headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
62
+ credentials?: RequestCredentials;
63
+ fetch?: typeof globalThis.fetch;
64
+ /** Include the full checked-in query text as an additional hash-integrity check. */
65
+ includeQuery?: boolean;
66
+ /** Request timeout in milliseconds. Defaults to 15 seconds; set to 0 to disable. */
67
+ defaultTimeoutMs?: number;
68
+ /** Maximum response body size in bytes. Defaults to 1 MiB. */
69
+ maxResponseBytes?: number;
70
+ }
71
+ export declare function createReptilianChainDataClient(options: ChainDataClientOptions): ChainDataApi;
72
+ export declare const createChainDataClient: typeof createReptilianChainDataClient;
73
+ /** @deprecated Use createReptilianChainDataClient. */
74
+ export declare const createFoundationGraphqlClient: typeof createReptilianChainDataClient;
75
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC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B,8BAA8B,CAAC,OAAO,EAAE,sBAAsB,GAAG,YAAY,CA2B5F;AAED,eAAO,MAAM,qBAAqB,uCAAiC,CAAC;AACpE,sDAAsD;AACtD,eAAO,MAAM,6BAA6B,uCAAiC,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,99 @@
1
+ import { CHAIN_DATA_OPERATIONS, } from './contract.js';
2
+ import { createPersistedGraphqlClient, } from './transport.js';
3
+ export function createReptilianChainDataClient(options) {
4
+ const deploymentId = options.deploymentId.trim();
5
+ if (!deploymentId)
6
+ throw new TypeError('deploymentId is required');
7
+ const transport = createPersistedGraphqlClient({
8
+ endpoint: options.endpoint.replace(/\/+$/, ''),
9
+ operations: CHAIN_DATA_OPERATIONS,
10
+ headers: options.headers,
11
+ credentials: options.credentials,
12
+ fetch: options.fetch,
13
+ includeQuery: options.includeQuery ?? false,
14
+ defaultTimeoutMs: options.defaultTimeoutMs,
15
+ maxResponseBytes: options.maxResponseBytes,
16
+ });
17
+ return createApi((operationName, variables, requestOptions) => {
18
+ const scopedVariables = operationName === 'EthUsdPrice'
19
+ ? variables
20
+ : { ...variables, deploymentId };
21
+ return transport.execute(operationName, scopedVariables, requestOptions);
22
+ });
23
+ }
24
+ export const createChainDataClient = createReptilianChainDataClient;
25
+ /** @deprecated Use createReptilianChainDataClient. */
26
+ export const createFoundationGraphqlClient = createReptilianChainDataClient;
27
+ function createApi(execute) {
28
+ const getLaunchFeed = async (input = {}, requestOptions) => {
29
+ const data = await execute('LaunchFeed', {
30
+ first: input.first ?? 20,
31
+ ...(input.phase ? { phase: input.phase } : {}),
32
+ ...(input.after ? { after: input.after } : {}),
33
+ }, requestOptions);
34
+ return data.launches;
35
+ };
36
+ const getFreshness = async (requestOptions) => (await execute('ChainDataFreshness', {}, requestOptions)).chainDataFreshness;
37
+ return {
38
+ execute,
39
+ getLaunchFeed,
40
+ async getLaunchDetail(token, requestOptions) {
41
+ return (await execute('LaunchDetail', { token }, requestOptions)).launch;
42
+ },
43
+ async getTrendingLaunches(first = 10, requestOptions) {
44
+ return (await execute('TrendingLaunches', { first }, requestOptions)).trendingLaunches;
45
+ },
46
+ async getLaunchPriceSeries(input, requestOptions) {
47
+ return (await execute('LaunchPriceSeries', {
48
+ token: input.token,
49
+ venue: input.venue ?? 'CANONICAL',
50
+ first: input.first ?? 250,
51
+ ...(input.after ? { after: input.after } : {}),
52
+ }, requestOptions)).launchPriceSeries;
53
+ },
54
+ async getWalletLaunchPositions(input, requestOptions) {
55
+ const values = typeof input === 'string' ? { wallet: input } : input;
56
+ return (await execute('WalletLaunchPositions', {
57
+ wallet: values.wallet,
58
+ first: values.first ?? 100,
59
+ ...(values.after ? { after: values.after } : {}),
60
+ }, requestOptions)).walletLaunchPositions;
61
+ },
62
+ async getPortfolioWalletBalances(input, requestOptions) {
63
+ return (await execute('PortfolioWalletBalances', {
64
+ wallet: input.wallet,
65
+ first: input.first ?? 100,
66
+ ...(input.after ? { after: input.after } : {}),
67
+ }, requestOptions)).walletLaunchPositions;
68
+ },
69
+ async getWalletLiquidityBookPositions(input, requestOptions) {
70
+ return (await execute('WalletLiquidityBookPositions', {
71
+ wallet: input.wallet,
72
+ first: input.first ?? 100,
73
+ ...(input.after ? { after: input.after } : {}),
74
+ }, requestOptions)).walletLiquidityBookPositions;
75
+ },
76
+ async getPortfolioWalletLiquidityPositions(input, requestOptions) {
77
+ return (await execute('PortfolioWalletLiquidityPositions', {
78
+ wallet: input.wallet,
79
+ first: input.first ?? 100,
80
+ ...(input.after ? { after: input.after } : {}),
81
+ }, requestOptions)).walletLiquidityBookPositions;
82
+ },
83
+ async getLiquidityBookPosition(input, requestOptions) {
84
+ return (await execute('LiquidityBookPosition', {
85
+ wallet: input.wallet,
86
+ pool: input.pool,
87
+ binFirst: input.binFirst ?? 250,
88
+ ...(input.binsAfter ? { binsAfter: input.binsAfter } : {}),
89
+ }, requestOptions)).liquidityBookPosition;
90
+ },
91
+ async getProtocolStats(requestOptions) {
92
+ return (await execute('ProtocolStats', {}, requestOptions)).protocolStats;
93
+ },
94
+ getFreshness,
95
+ getRobinhoodLaunchFeed: getLaunchFeed,
96
+ getRobinhoodFreshness: getFreshness,
97
+ };
98
+ }
99
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAkBtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,4BAA4B,GAG7B,MAAM,gBAAgB,CAAC;AAqFxB,MAAM,UAAU,8BAA8B,CAAC,OAA+B;IAC5E,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,4BAA4B,CAAwB;QACpE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9C,UAAU,EAAE,qBAAqB;QACjC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;QAC3C,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;KACoB,CAAC,CAAC;IAClE,OAAO,SAAS,CAAC,CACf,aAAmB,EACnB,SAAkD,EAClD,cAAwC,EACxC,EAAE;QACF,MAAM,eAAe,GAAG,aAAa,KAAK,aAAa;YACrD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,YAAY,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC,OAAO,CACtB,aAAa,EACb,eAAwB,EACxB,cAAc,CAC0B,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC;AAED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;QACD,KAAK,CAAC,gBAAgB,CAAC,cAAc;YACnC,OAAO,CAAC,MAAM,OAAO,CAAC,eAAe,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC;QAC5E,CAAC;QACD,YAAY;QACZ,sBAAsB,EAAE,aAAa;QACrC,qBAAqB,EAAE,YAAY;KACpC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from '@reptilianhq/chain-data-contract';
2
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from '@reptilianhq/chain-data-contract';
2
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,19 @@
1
+ export interface ChainDataClientErrorOptions {
2
+ status: number;
3
+ code?: string;
4
+ details?: unknown;
5
+ }
6
+ export declare class ChainDataClientError extends Error {
7
+ readonly status: number;
8
+ readonly code?: string;
9
+ readonly details?: unknown;
10
+ constructor(message: string, options: ChainDataClientErrorOptions);
11
+ }
12
+ export declare function isChainDataClientError(error: unknown): error is ChainDataClientError;
13
+ /** @deprecated Use ChainDataClientError. */
14
+ export declare const FoundationGraphqlError: typeof ChainDataClientError;
15
+ /** @deprecated Use ChainDataClientErrorOptions. */
16
+ export type FoundationGraphqlErrorOptions = ChainDataClientErrorOptions;
17
+ /** @deprecated Use isChainDataClientError. */
18
+ export declare const isFoundationGraphqlError: typeof isChainDataClientError;
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,2BAA2B;CAOlE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF;AAED,4CAA4C;AAC5C,eAAO,MAAM,sBAAsB,6BAAuB,CAAC;AAC3D,mDAAmD;AACnD,MAAM,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AACxE,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,+BAAyB,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,17 @@
1
+ export class ChainDataClientError extends Error {
2
+ constructor(message, options) {
3
+ super(message);
4
+ this.name = 'ChainDataClientError';
5
+ this.status = options.status;
6
+ this.code = options.code;
7
+ this.details = options.details;
8
+ }
9
+ }
10
+ export function isChainDataClientError(error) {
11
+ return error instanceof ChainDataClientError;
12
+ }
13
+ /** @deprecated Use ChainDataClientError. */
14
+ export const FoundationGraphqlError = ChainDataClientError;
15
+ /** @deprecated Use isChainDataClientError. */
16
+ export const isFoundationGraphqlError = isChainDataClientError;
17
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAK7C,YAAY,OAAe,EAAE,OAAoC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,KAAK,YAAY,oBAAoB,CAAC;AAC/C,CAAC;AAED,4CAA4C;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAG3D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './client.js';
2
+ export * from './contract.js';
3
+ export * from './errors.js';
4
+ export * from './replay-fixtures.js';
5
+ export * from './reptilianAuth.js';
6
+ export * from './transport.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from './client.js';
2
+ export * from './contract.js';
3
+ export * from './errors.js';
4
+ export * from './replay-fixtures.js';
5
+ export * from './reptilianAuth.js';
6
+ export * from './transport.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ROBINHOOD_TESTNET_GEN9_REPLAY_FIXTURE, assertRobinhoodTestnetGen9Deployment, assertRobinhoodTestnetGen9ReplaySnapshot, type ChainDataReplayDeploymentIdentity, type ChainDataReplaySnapshot, } from '@reptilianhq/chain-data-contract/replay-fixtures';
2
+ //# sourceMappingURL=replay-fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-fixtures.d.ts","sourceRoot":"","sources":["../src/replay-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,EACrC,oCAAoC,EACpC,wCAAwC,EACxC,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,GAC7B,MAAM,kDAAkD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ROBINHOOD_TESTNET_GEN9_REPLAY_FIXTURE, assertRobinhoodTestnetGen9Deployment, assertRobinhoodTestnetGen9ReplaySnapshot, } from '@reptilianhq/chain-data-contract/replay-fixtures';
2
+ //# sourceMappingURL=replay-fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-fixtures.js","sourceRoot":"","sources":["../src/replay-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,EACrC,oCAAoC,EACpC,wCAAwC,GAGzC,MAAM,kDAAkD,CAAC"}
@@ -0,0 +1,14 @@
1
+ export interface ReptilianBrowserTokenProviderOptions {
2
+ tokenEndpoint: string;
3
+ fetch?: typeof globalThis.fetch;
4
+ credentials?: RequestCredentials;
5
+ refreshLeewayMs?: number;
6
+ }
7
+ export interface ReptilianBrowserTokenProvider {
8
+ getToken(): Promise<string>;
9
+ getAuthorizationHeaders(): Promise<HeadersInit>;
10
+ clear(): void;
11
+ }
12
+ /** Exchanges a Reptilian browser session for a short-lived chain-data JWT. */
13
+ export declare function createReptilianBrowserTokenProvider(options: ReptilianBrowserTokenProviderOptions): ReptilianBrowserTokenProvider;
14
+ //# sourceMappingURL=reptilianAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reptilianAuth.d.ts","sourceRoot":"","sources":["../src/reptilianAuth.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oCAAoC;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,uBAAuB,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAChD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,8EAA8E;AAC9E,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,oCAAoC,GAC5C,6BAA6B,CA2E/B"}
@@ -0,0 +1,97 @@
1
+ import { ChainDataClientError } from './errors.js';
2
+ /** Exchanges a Reptilian browser session for a short-lived chain-data JWT. */
3
+ export function createReptilianBrowserTokenProvider(options) {
4
+ const endpoint = options.tokenEndpoint.trim();
5
+ if (!endpoint)
6
+ throw new TypeError('tokenEndpoint is required');
7
+ const request = (options.fetch ?? globalThis.fetch)?.bind(globalThis);
8
+ if (!request)
9
+ throw new Error('A fetch implementation is required');
10
+ const refreshLeewayMs = options.refreshLeewayMs ?? 30000;
11
+ if (!Number.isFinite(refreshLeewayMs) || refreshLeewayMs < 0) {
12
+ throw new TypeError('refreshLeewayMs must be a non-negative finite number');
13
+ }
14
+ let cached;
15
+ let pending;
16
+ let generation = 0;
17
+ const fetchToken = async (requestGeneration) => {
18
+ let response;
19
+ try {
20
+ response = await request(endpoint, {
21
+ method: 'GET',
22
+ credentials: options.credentials ?? 'include',
23
+ headers: { accept: 'application/json' },
24
+ });
25
+ }
26
+ catch (error) {
27
+ if (requestGeneration !== generation)
28
+ throw new TokenGenerationChanged();
29
+ throw error;
30
+ }
31
+ if (requestGeneration !== generation)
32
+ throw new TokenGenerationChanged();
33
+ const payload = await response.json().catch(() => undefined);
34
+ if (requestGeneration !== generation)
35
+ throw new TokenGenerationChanged();
36
+ if (!response.ok || typeof payload?.token !== 'string' || !payload.token.trim()) {
37
+ throw new ChainDataClientError(typeof payload?.message === 'string'
38
+ ? payload.message
39
+ : 'Unable to acquire a Reptilian chain-data token', { status: response.status || 401, code: 'CHAIN_DATA_TOKEN_UNAVAILABLE' });
40
+ }
41
+ const token = payload.token.trim();
42
+ const expiresAt = readJwtExpiry(token);
43
+ cached = {
44
+ token,
45
+ refreshAt: expiresAt === undefined
46
+ ? Date.now()
47
+ : Math.max(Date.now(), expiresAt - refreshLeewayMs),
48
+ };
49
+ return token;
50
+ };
51
+ const getToken = async () => {
52
+ while (true) {
53
+ if (cached && Date.now() < cached.refreshAt)
54
+ return cached.token;
55
+ const active = pending ?? fetchToken(generation);
56
+ pending = active;
57
+ try {
58
+ return await active;
59
+ }
60
+ catch (error) {
61
+ if (!(error instanceof TokenGenerationChanged))
62
+ throw error;
63
+ }
64
+ finally {
65
+ if (pending === active)
66
+ pending = undefined;
67
+ }
68
+ }
69
+ };
70
+ return {
71
+ getToken,
72
+ async getAuthorizationHeaders() {
73
+ return { authorization: `Bearer ${await getToken()}` };
74
+ },
75
+ clear() {
76
+ generation += 1;
77
+ cached = undefined;
78
+ },
79
+ };
80
+ }
81
+ class TokenGenerationChanged extends Error {
82
+ }
83
+ function readJwtExpiry(token) {
84
+ const payload = token.split('.')[1];
85
+ if (!payload)
86
+ return undefined;
87
+ try {
88
+ const normalized = payload.replace(/-/g, '+').replace(/_/g, '/');
89
+ const decoded = globalThis.atob(normalized.padEnd(Math.ceil(normalized.length / 4) * 4, '='));
90
+ const exp = JSON.parse(decoded).exp;
91
+ return typeof exp === 'number' && Number.isFinite(exp) ? exp * 1000 : undefined;
92
+ }
93
+ catch {
94
+ return undefined;
95
+ }
96
+ }
97
+ //# sourceMappingURL=reptilianAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reptilianAuth.js","sourceRoot":"","sources":["../src/reptilianAuth.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AAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACnF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ export interface PersistedGraphqlOperationDefinition {
2
+ sha256Hash: string;
3
+ document?: string;
4
+ }
5
+ export type PersistedGraphqlOperationName<OperationMap> = Extract<keyof OperationMap, string>;
6
+ export type PersistedGraphqlOperationVariables<OperationMap, Name extends PersistedGraphqlOperationName<OperationMap>> = OperationMap[Name] extends {
7
+ variables: infer Variables;
8
+ } ? Variables : never;
9
+ export type PersistedGraphqlOperationData<OperationMap, Name extends PersistedGraphqlOperationName<OperationMap>> = OperationMap[Name] extends {
10
+ data: infer Data;
11
+ } ? Data : never;
12
+ export interface PersistedGraphqlExtensions {
13
+ cache?: 'hit' | 'miss' | 'stale';
14
+ requestId?: string;
15
+ [key: string]: unknown;
16
+ }
17
+ export interface PersistedGraphqlExecution<Data> {
18
+ data: Data;
19
+ extensions?: PersistedGraphqlExtensions;
20
+ }
21
+ export interface PersistedGraphqlExecuteOptions {
22
+ /** Abort this request when the signal fires. */
23
+ signal?: AbortSignal;
24
+ /** Override the client timeout for this request. Set to 0 to disable it. */
25
+ timeoutMs?: number;
26
+ }
27
+ export interface PersistedGraphqlClientOptions<OperationMap> {
28
+ endpoint: string;
29
+ operations: Record<PersistedGraphqlOperationName<OperationMap>, PersistedGraphqlOperationDefinition>;
30
+ /** Resolve credentials at request time. API keys must remain server-side. */
31
+ headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
32
+ credentials?: RequestCredentials;
33
+ fetch?: typeof globalThis.fetch;
34
+ /** Include the operation document as an additional hash-integrity check. */
35
+ includeQuery?: boolean;
36
+ /** Request timeout in milliseconds. Defaults to 15 seconds; set to 0 to disable. */
37
+ defaultTimeoutMs?: number;
38
+ /** Maximum response body size in bytes. Defaults to 1 MiB. */
39
+ maxResponseBytes?: number;
40
+ }
41
+ export interface PersistedGraphqlClient<OperationMap> {
42
+ execute<Name extends PersistedGraphqlOperationName<OperationMap>>(operationName: Name, variables: PersistedGraphqlOperationVariables<OperationMap, Name>, options?: PersistedGraphqlExecuteOptions): Promise<PersistedGraphqlOperationData<OperationMap, Name>>;
43
+ executeEnvelope<Name extends PersistedGraphqlOperationName<OperationMap>>(operationName: Name, variables: PersistedGraphqlOperationVariables<OperationMap, Name>, options?: PersistedGraphqlExecuteOptions): Promise<PersistedGraphqlExecution<PersistedGraphqlOperationData<OperationMap, Name>>>;
44
+ }
45
+ /**
46
+ * Contract-neutral persisted-operation transport. Product packages can retain their own operation
47
+ * map while sharing Reptilian's request envelope, error handling, and response metadata behavior.
48
+ */
49
+ export declare function createPersistedGraphqlClient<OperationMap>(options: PersistedGraphqlClientOptions<OperationMap>): PersistedGraphqlClient<OperationMap>;
50
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,6BAA6B,CAAC,YAAY,IAAI,OAAO,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;AAC9F,MAAM,MAAM,kCAAkC,CAC5C,YAAY,EACZ,IAAI,SAAS,6BAA6B,CAAC,YAAY,CAAC,IACtD,YAAY,CAAC,IAAI,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,SAAS,CAAA;CAAE,GAAG,SAAS,GAAG,KAAK,CAAC;AAClF,MAAM,MAAM,6BAA6B,CACvC,YAAY,EACZ,IAAI,SAAS,6BAA6B,CAAC,YAAY,CAAC,IACtD,YAAY,CAAC,IAAI,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,IAA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,CAAC,CAAC;IAC9D,eAAe,CAAC,IAAI,SAAS,6BAA6B,CAAC,YAAY,CAAC,EACtE,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,kCAAkC,CAAC,YAAY,EAAE,IAAI,CAAC,EACjE,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC,yBAAyB,CAAC,6BAA6B,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CAC1F;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EACvD,OAAO,EAAE,6BAA6B,CAAC,YAAY,CAAC,GACnD,sBAAsB,CAAC,YAAY,CAAC,CAsFtC"}
@@ -0,0 +1,224 @@
1
+ import { ChainDataClientError } from './errors.js';
2
+ /**
3
+ * Contract-neutral persisted-operation transport. Product packages can retain their own operation
4
+ * map while sharing Reptilian's request envelope, error handling, and response metadata behavior.
5
+ */
6
+ export function createPersistedGraphqlClient(options) {
7
+ if (!options.endpoint.trim())
8
+ throw new Error('GraphQL endpoint is required');
9
+ const fetchImplementation = bindFetch(options.fetch);
10
+ const endpoint = options.endpoint.replace(/\/+$/, '');
11
+ const defaultTimeoutMs = validateTimeoutMs(options.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS, 'defaultTimeoutMs');
12
+ const maxResponseBytes = validateMaxResponseBytes(options.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES);
13
+ const executeEnvelope = async (operationName, variables, executeOptions = {}) => {
14
+ const operation = options.operations[operationName];
15
+ if (!operation)
16
+ throw new Error(`Unknown persisted GraphQL operation: ${operationName}`);
17
+ const timeoutMs = validateTimeoutMs(executeOptions.timeoutMs ?? defaultTimeoutMs, 'timeoutMs');
18
+ const requestSignal = createRequestSignal(executeOptions.signal, timeoutMs);
19
+ try {
20
+ throwIfAborted(requestSignal.signal);
21
+ const configuredHeaders = typeof options.headers === 'function' ? options.headers() : options.headers;
22
+ const headers = new Headers(await waitForSignal(configuredHeaders, requestSignal.signal));
23
+ if (!headers.has('content-type'))
24
+ headers.set('content-type', 'application/json');
25
+ if (!headers.has('accept'))
26
+ headers.set('accept', 'application/graphql-response+json, application/json');
27
+ // This package owns the explicit Fetch transport boundary for persisted chain-data operations.
28
+ const response = await fetchImplementation(endpoint, {
29
+ method: 'POST',
30
+ credentials: options.credentials,
31
+ headers,
32
+ signal: requestSignal.signal,
33
+ body: JSON.stringify({
34
+ operationName,
35
+ variables,
36
+ ...(options.includeQuery && operation.document ? { query: operation.document } : {}),
37
+ extensions: {
38
+ persistedQuery: {
39
+ version: 1,
40
+ sha256Hash: operation.sha256Hash,
41
+ },
42
+ },
43
+ }),
44
+ });
45
+ const payload = await parseResponse(response, requestSignal.signal, maxResponseBytes);
46
+ const firstError = payload.errors?.[0];
47
+ if (!response.ok || firstError || payload.data === undefined || payload.data === null) {
48
+ const requestId = firstError?.extensions?.requestId
49
+ ?? payload.extensions?.requestId
50
+ ?? response.headers.get('x-request-id')
51
+ ?? undefined;
52
+ throw new ChainDataClientError(firstError?.message ?? `GraphQL request failed with HTTP ${response.status}`, {
53
+ status: response.status,
54
+ code: firstError?.extensions?.code,
55
+ details: { requestId, errors: payload.errors },
56
+ });
57
+ }
58
+ return {
59
+ data: payload.data,
60
+ extensions: payload.extensions,
61
+ };
62
+ }
63
+ catch (error) {
64
+ if (requestSignal.didTimeout()) {
65
+ throw new ChainDataClientError(`GraphQL request timed out after ${timeoutMs}ms`, {
66
+ status: 408,
67
+ code: 'REQUEST_TIMEOUT',
68
+ details: { timeoutMs },
69
+ });
70
+ }
71
+ throw error;
72
+ }
73
+ finally {
74
+ requestSignal.dispose();
75
+ }
76
+ };
77
+ return {
78
+ execute: async (operationName, variables, executeOptions) => (await executeEnvelope(operationName, variables, executeOptions)).data,
79
+ executeEnvelope,
80
+ };
81
+ }
82
+ async function parseResponse(response, signal, maxResponseBytes) {
83
+ try {
84
+ const declaredLength = Number(response.headers.get('content-length') ?? '0');
85
+ if (Number.isFinite(declaredLength) && declaredLength > maxResponseBytes) {
86
+ await response.body?.cancel().catch(() => undefined);
87
+ throw responseTooLarge(response, maxResponseBytes);
88
+ }
89
+ const body = await readBoundedBody(response, signal, maxResponseBytes);
90
+ return JSON.parse(body);
91
+ }
92
+ catch (error) {
93
+ if (error instanceof ChainDataClientError)
94
+ throw error;
95
+ if (signal?.aborted)
96
+ throw signal.reason ?? error;
97
+ throw new ChainDataClientError('GraphQL endpoint returned a non-JSON response', {
98
+ status: response.status,
99
+ details: { requestId: response.headers.get('x-request-id') ?? undefined },
100
+ });
101
+ }
102
+ }
103
+ async function readBoundedBody(response, signal, maxResponseBytes) {
104
+ if (!response.body)
105
+ return '';
106
+ const reader = response.body.getReader();
107
+ const decoder = new TextDecoder();
108
+ let bytesRead = 0;
109
+ let body = '';
110
+ try {
111
+ while (true) {
112
+ throwIfAborted(signal);
113
+ const chunk = await reader.read();
114
+ if (chunk.done)
115
+ break;
116
+ bytesRead += chunk.value.byteLength;
117
+ if (bytesRead > maxResponseBytes) {
118
+ await reader.cancel().catch(() => undefined);
119
+ throw responseTooLarge(response, maxResponseBytes);
120
+ }
121
+ body += decoder.decode(chunk.value, { stream: true });
122
+ }
123
+ return body + decoder.decode();
124
+ }
125
+ finally {
126
+ reader.releaseLock();
127
+ }
128
+ }
129
+ function responseTooLarge(response, maxResponseBytes) {
130
+ return new ChainDataClientError('GraphQL response exceeded configured size limit', {
131
+ status: response.ok ? 502 : response.status,
132
+ code: 'RESPONSE_TOO_LARGE',
133
+ details: {
134
+ maxResponseBytes,
135
+ requestId: response.headers.get('x-request-id') ?? undefined,
136
+ },
137
+ });
138
+ }
139
+ function bindFetch(fetchImplementation = globalThis.fetch) {
140
+ if (!fetchImplementation)
141
+ throw new Error('A fetch implementation is required');
142
+ return fetchImplementation.bind(globalThis);
143
+ }
144
+ const DEFAULT_TIMEOUT_MS = 15000;
145
+ const MAX_TIMEOUT_MS = 2147483647;
146
+ const DEFAULT_MAX_RESPONSE_BYTES = 1048576;
147
+ const MAX_RESPONSE_BYTES = 67108864;
148
+ function validateTimeoutMs(timeoutMs, optionName) {
149
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > MAX_TIMEOUT_MS) {
150
+ throw new RangeError(`${optionName} must be an integer between 0 and ${MAX_TIMEOUT_MS}`);
151
+ }
152
+ return timeoutMs;
153
+ }
154
+ function validateMaxResponseBytes(maxResponseBytes) {
155
+ if (!Number.isInteger(maxResponseBytes) || maxResponseBytes < 1 || maxResponseBytes > MAX_RESPONSE_BYTES) {
156
+ throw new RangeError(`maxResponseBytes must be an integer between 1 and ${MAX_RESPONSE_BYTES}`);
157
+ }
158
+ return maxResponseBytes;
159
+ }
160
+ function createRequestSignal(externalSignal, timeoutMs) {
161
+ if (timeoutMs === 0) {
162
+ return {
163
+ signal: externalSignal,
164
+ didTimeout: () => false,
165
+ dispose: () => undefined,
166
+ };
167
+ }
168
+ const controller = new AbortController();
169
+ let firstCause;
170
+ let timeout;
171
+ const forwardAbort = () => {
172
+ if (firstCause)
173
+ return;
174
+ firstCause = 'caller';
175
+ if (timeout)
176
+ clearTimeout(timeout);
177
+ controller.abort(externalSignal?.reason);
178
+ };
179
+ if (externalSignal?.aborted) {
180
+ forwardAbort();
181
+ }
182
+ else {
183
+ externalSignal?.addEventListener('abort', forwardAbort, { once: true });
184
+ timeout = setTimeout(() => {
185
+ if (firstCause)
186
+ return;
187
+ firstCause = 'timeout';
188
+ externalSignal?.removeEventListener('abort', forwardAbort);
189
+ controller.abort();
190
+ }, timeoutMs);
191
+ }
192
+ return {
193
+ signal: controller.signal,
194
+ didTimeout: () => firstCause === 'timeout',
195
+ dispose: () => {
196
+ if (timeout)
197
+ clearTimeout(timeout);
198
+ externalSignal?.removeEventListener('abort', forwardAbort);
199
+ },
200
+ };
201
+ }
202
+ function throwIfAborted(signal) {
203
+ if (signal?.aborted)
204
+ throw signal.reason;
205
+ }
206
+ async function waitForSignal(value, signal) {
207
+ if (!signal)
208
+ return await value;
209
+ throwIfAborted(signal);
210
+ return await new Promise((resolve, reject) => {
211
+ let settled = false;
212
+ const settle = (callback) => {
213
+ if (settled)
214
+ return;
215
+ settled = true;
216
+ signal.removeEventListener('abort', onAbort);
217
+ callback();
218
+ };
219
+ const onAbort = () => settle(() => reject(signal.reason));
220
+ signal.addEventListener('abort', onAbort, { once: true });
221
+ Promise.resolve(value).then((result) => settle(() => resolve(result)), (error) => settle(() => reject(error)));
222
+ });
223
+ }
224
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAkEnD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAoD;IAEpD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC9E,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,OAAO,CAAC,gBAAgB,IAAI,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;IAC/G,MAAM,gBAAgB,GAAG,wBAAwB,CAC/C,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CACvD,CAAC;IAEF,MAAM,eAAe,GAA4D,KAAK,EACpF,aAAa,EACb,SAAS,EACT,cAAc,GAAG,EAAE,EACnB,EAAE;QACF,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,aAAa,EAAE,CAAC,CAAC;QACzF,MAAM,SAAS,GAAG,iBAAiB,CAAC,cAAc,CAAC,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,KAAK,UAAU,aAAa,CAAI,KAAyB,EAAE,MAA+B;IACxF,IAAI,CAAC,MAAM;QAAE,OAAO,MAAM,KAAK,CAAC;IAChC,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,MAAM,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,CAAC,QAAoB,EAAE,EAAE;YACtC,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CACzB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EACzC,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAChD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@reptilianhq/chain-data-client",
3
+ "version": "0.4.0",
4
+ "description": "Typed persisted-operation client for the Reptilian chain-data API",
5
+ "license": "UNLICENSED",
6
+ "engines": {
7
+ "node": ">=18"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ReptilianHQ/dlmm-site.git",
12
+ "directory": "packages/chain-data-client"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./client": {
33
+ "types": "./dist/client.d.ts",
34
+ "import": "./dist/client.js",
35
+ "default": "./dist/client.js"
36
+ },
37
+ "./contract": {
38
+ "types": "./dist/contract.d.ts",
39
+ "import": "./dist/contract.js",
40
+ "default": "./dist/contract.js"
41
+ },
42
+ "./errors": {
43
+ "types": "./dist/errors.d.ts",
44
+ "import": "./dist/errors.js",
45
+ "default": "./dist/errors.js"
46
+ },
47
+ "./replay-fixtures": {
48
+ "types": "./dist/replay-fixtures.d.ts",
49
+ "import": "./dist/replay-fixtures.js",
50
+ "default": "./dist/replay-fixtures.js"
51
+ },
52
+ "./reptilian-auth": {
53
+ "types": "./dist/reptilianAuth.d.ts",
54
+ "import": "./dist/reptilianAuth.js",
55
+ "default": "./dist/reptilianAuth.js"
56
+ },
57
+ "./transport": {
58
+ "types": "./dist/transport.d.ts",
59
+ "import": "./dist/transport.js",
60
+ "default": "./dist/transport.js"
61
+ }
62
+ },
63
+ "scripts": {
64
+ "clean": "rm -rf dist",
65
+ "build": "pnpm clean && tsc -p tsconfig.build.json",
66
+ "check": "tsc --noEmit",
67
+ "test": "pnpm build && node scripts/client.test.mjs",
68
+ "test:packed": "node scripts/packed-client.test.mjs",
69
+ "prepack": "pnpm build"
70
+ },
71
+ "dependencies": {
72
+ "@reptilianhq/chain-data-contract": "0.10.0"
73
+ },
74
+ "devDependencies": {
75
+ "typescript": "catalog:"
76
+ }
77
+ }