@bounded-sh/core 0.0.53 → 0.0.54
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/config.d.ts +16 -0
- package/dist/client/create-client.d.ts +103 -0
- package/dist/client/operations.d.ts +14 -16
- package/dist/{index-DE-xgEvG.js → index-BXvTkFw2.js} +250 -61
- package/dist/index-BXvTkFw2.js.map +1 -0
- package/dist/{index-CbTo1jKG.mjs → index-qcTp-5Mt.mjs} +249 -62
- package/dist/index-qcTp-5Mt.mjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{realtime-store-DLErbHL_.mjs → realtime-store-BzKEmyxq.mjs} +2 -2
- package/dist/{realtime-store-DLErbHL_.mjs.map → realtime-store-BzKEmyxq.mjs.map} +1 -1
- package/dist/{realtime-store-B_Zaa1FL.js → realtime-store-DmzboN-H.js} +2 -2
- package/dist/{realtime-store-B_Zaa1FL.js.map → realtime-store-DmzboN-H.js.map} +1 -1
- package/dist/{sol-utils-v8cCs2pm.mjs → sol-utils-BhjxvQUj.mjs} +3 -5
- package/dist/sol-utils-BhjxvQUj.mjs.map +1 -0
- package/dist/{sol-utils-Dni65Z63.js → sol-utils-oBMCMbe_.js} +3 -5
- package/dist/sol-utils-oBMCMbe_.js.map +1 -0
- package/dist/{solana-message-C5nbu9zb.js → solana-message-I9w1TbAj.js} +2 -2
- package/dist/{solana-message-C5nbu9zb.js.map → solana-message-I9w1TbAj.js.map} +1 -1
- package/dist/{solana-message-CSjZx5xE.mjs → solana-message-XxVgbtp2.mjs} +2 -2
- package/dist/{solana-message-CSjZx5xE.mjs.map → solana-message-XxVgbtp2.mjs.map} +1 -1
- package/dist/{solana-operations-Dtsk6xFc.js → solana-operations-BUJkyVxN.js} +4 -9
- package/dist/solana-operations-BUJkyVxN.js.map +1 -0
- package/dist/{solana-operations-Bx91DDCy.mjs → solana-operations-ehEsfO5g.mjs} +4 -9
- package/dist/solana-operations-ehEsfO5g.mjs.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/utils/api.d.ts +3 -0
- package/dist/utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpDevnet-program.d.ts +1215 -321
- package/dist/utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program.d.ts +1215 -321
- package/package.json +2 -2
- package/dist/index-CbTo1jKG.mjs.map +0 -1
- package/dist/index-DE-xgEvG.js.map +0 -1
- package/dist/sol-utils-Dni65Z63.js.map +0 -1
- package/dist/sol-utils-v8cCs2pm.mjs.map +0 -1
- package/dist/solana-operations-Bx91DDCy.mjs.map +0 -1
- package/dist/solana-operations-Dtsk6xFc.js.map +0 -1
package/dist/client/config.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ export interface ClientConfig {
|
|
|
125
125
|
runtimeAddresses?: Record<string, string>;
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
+
export declare const DEFAULT_CLIENT_CONFIG: ClientConfig;
|
|
128
129
|
export declare let clientConfig: ClientConfig;
|
|
129
130
|
type BoundedEndpoints = Pick<ClientConfig, 'wsApiUrl' | 'apiUrl' | 'authApiUrl' | 'humanAuthApiUrl' | 'functionsUrl' | 'devApiUrl'>;
|
|
130
131
|
export declare const BOUNDED_NETWORKS: Record<string, BoundedEndpoints>;
|
|
@@ -147,6 +148,21 @@ export declare function getWebhookKeysUrl(): string | undefined;
|
|
|
147
148
|
* Bounded must use the deterministic server aggregation, not the legacy AI query).
|
|
148
149
|
*/
|
|
149
150
|
export declare function isBoundedNetwork(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Config-scoped variant of {@link isBoundedNetwork}: reports whether a SPECIFIC
|
|
153
|
+
* config (e.g. a scoped `createClient()` instance's) targets a Bounded network,
|
|
154
|
+
* rather than the module global. Used so a scoped client routes count/aggregate
|
|
155
|
+
* by its OWN network, not the global one.
|
|
156
|
+
*/
|
|
157
|
+
export declare function isBoundedNetworkConfig(config: ClientConfig): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Merge a partial config over a base config, applying the Bounded endpoint
|
|
160
|
+
* precedence rule used everywhere: defaults (or `base`) < network preset <
|
|
161
|
+
* explicit fields. Pure - never touches module state. Shared by `init` (base =
|
|
162
|
+
* the current global) and `createClient` (base = the pristine defaults) so both
|
|
163
|
+
* resolve endpoints identically. Throws on an unsupported `network`.
|
|
164
|
+
*/
|
|
165
|
+
export declare function resolveClientConfig(base: ClientConfig, newConfig: Partial<ClientConfig>): ClientConfig;
|
|
150
166
|
export declare function init(newConfig: Partial<ClientConfig>): Promise<void>;
|
|
151
167
|
export declare function getConfig(): Promise<ClientConfig>;
|
|
152
168
|
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scoped multi-app client factory.
|
|
3
|
+
*
|
|
4
|
+
* `createClient()` returns an isolated, READ-ONLY client bound to one Bounded
|
|
5
|
+
* app, independent of the module-global `init()` client. It exists so a single
|
|
6
|
+
* frontend can hold its normal authenticated client for its own app AND a
|
|
7
|
+
* read-only client for a SECOND Bounded app (e.g. a shared steward/runtime app),
|
|
8
|
+
* with live subscriptions on both and zero interference between them.
|
|
9
|
+
*
|
|
10
|
+
* Each instance carries its OWN fully-resolved config (endpoints + appId) and
|
|
11
|
+
* routes through the SAME shared transport/subscription implementation as the
|
|
12
|
+
* global path - it never forks that code. Isolation comes from threading the
|
|
13
|
+
* instance config (and a read-only marker) through the existing per-request /
|
|
14
|
+
* per-subscription override channel, plus the websocket layer already keying
|
|
15
|
+
* connections by appId.
|
|
16
|
+
*
|
|
17
|
+
* ## v1 scope: read-only, unauthenticated
|
|
18
|
+
*
|
|
19
|
+
* A scoped instance is UNAUTHENTICATED. It sends no auth, never reads or
|
|
20
|
+
* refreshes the global session, and connects to its app's realtime endpoint
|
|
21
|
+
* anonymously. It is therefore only useful against collections a Bounded app
|
|
22
|
+
* exposes with a public read rule (`read: true`) - private/per-user reads will
|
|
23
|
+
* be denied by the target app's policy, exactly as an anonymous caller would be.
|
|
24
|
+
*
|
|
25
|
+
* Writes and any auth-requiring surface are NOT supported on a scoped instance
|
|
26
|
+
* and throw a clear error. Per-instance authentication is a planned follow-up.
|
|
27
|
+
*/
|
|
28
|
+
import { type GetOptions, type SearchOptions, type CountOptions, type AggregateOptions, type QueryAggregateOptions, type RunQueryOptions, type AggregateOperation, type AggregateResult, type AggregateRow, type AggregateSpec, type GetManyResult, type RequestOverrides } from './operations';
|
|
29
|
+
import { type ClientConfig } from './config';
|
|
30
|
+
import type { SubscriptionOptions } from '../types';
|
|
31
|
+
/** Config accepted by {@link createClient}. Only `appId` is required; `network`
|
|
32
|
+
* (or explicit endpoint fields) selects the target Bounded backend. */
|
|
33
|
+
export type CreateClientConfig = Partial<ClientConfig> & {
|
|
34
|
+
appId: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A read-only client scoped to a single Bounded app, isolated from the global
|
|
38
|
+
* `init()` client. Read methods mirror the global surface; writes and auth throw.
|
|
39
|
+
*/
|
|
40
|
+
export interface BoundedClient {
|
|
41
|
+
/** The app id this instance is bound to. */
|
|
42
|
+
readonly appId: string;
|
|
43
|
+
/** A snapshot of this instance's fully-resolved config (endpoints + appId). */
|
|
44
|
+
getConfig(): ClientConfig;
|
|
45
|
+
/** Read a document or collection. See the global `get`. */
|
|
46
|
+
get(path: string, opts?: GetOptions): Promise<any>;
|
|
47
|
+
/** Batch-read up to 30 documents. See the global `getMany`. */
|
|
48
|
+
getMany(paths: string[], opts?: {
|
|
49
|
+
cache?: boolean;
|
|
50
|
+
bypassCache?: boolean;
|
|
51
|
+
_overrides?: RequestOverrides;
|
|
52
|
+
}): Promise<GetManyResult[]>;
|
|
53
|
+
/** Full-text search a collection declared with `search`. */
|
|
54
|
+
search(path: string, query: string, opts?: SearchOptions): Promise<any>;
|
|
55
|
+
/** Structured, grouped aggregation over a collection. */
|
|
56
|
+
queryAggregate(path: string, spec: AggregateSpec, opts?: QueryAggregateOptions): Promise<AggregateRow[]>;
|
|
57
|
+
/** Count matching documents (deterministic on Bounded). */
|
|
58
|
+
count(path: string, opts?: CountOptions): Promise<AggregateResult>;
|
|
59
|
+
/** Single-scalar aggregate (count/sum/avg/min/max/uniqueCount). */
|
|
60
|
+
aggregate(path: string, operation: AggregateOperation, opts?: AggregateOptions): Promise<AggregateResult>;
|
|
61
|
+
/** Run a named/computed query defined by the app's policy. */
|
|
62
|
+
runQuery(absolutePath: string, queryName: string, queryArgs: any, opts?: RunQueryOptions): Promise<any>;
|
|
63
|
+
/** Batch variant of {@link runQuery}. */
|
|
64
|
+
runQueryMany(many: {
|
|
65
|
+
absolutePath: string;
|
|
66
|
+
queryName: string;
|
|
67
|
+
queryArgs: any;
|
|
68
|
+
}[], opts?: RunQueryOptions): Promise<any[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Subscribe to realtime updates for a path on THIS app's realtime endpoint.
|
|
71
|
+
* Anonymous (read-only): the collection must be publicly readable. Returns an
|
|
72
|
+
* unsubscribe function. Subscriptions on this instance are fully independent
|
|
73
|
+
* of the global client and of any other scoped instance.
|
|
74
|
+
*/
|
|
75
|
+
subscribe(path: string, options: SubscriptionOptions | ((data: any) => void)): Promise<() => Promise<void>>;
|
|
76
|
+
/** Not supported on a read-only scoped instance - always throws {@link ScopedClientReadOnlyError}. */
|
|
77
|
+
set(path: string, document: any): Promise<never>;
|
|
78
|
+
/** Not supported on a read-only scoped instance - always throws {@link ScopedClientReadOnlyError}. */
|
|
79
|
+
setMany(many: {
|
|
80
|
+
path: string;
|
|
81
|
+
document: any;
|
|
82
|
+
}[]): Promise<never>;
|
|
83
|
+
}
|
|
84
|
+
/** Error thrown when an unsupported (write / auth-requiring) call is made on a
|
|
85
|
+
* read-only scoped client. */
|
|
86
|
+
export declare class ScopedClientReadOnlyError extends Error {
|
|
87
|
+
constructor(operation: string);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a read-only client scoped to a single Bounded app.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* // Global client stays the venue's own authenticated app:
|
|
95
|
+
* await init({ appId: VENUE_APP, network: 'bounded-production', authMethod: 'email' });
|
|
96
|
+
*
|
|
97
|
+
* // A second, read-only client for the steward runtime app:
|
|
98
|
+
* const steward = createClient({ appId: STEWARD_APP, network: 'bounded-production' });
|
|
99
|
+
* const state = await steward.get('runtime/current');
|
|
100
|
+
* const stop = await steward.subscribe('runtime/current', (d) => render(d));
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function createClient(config: CreateClientConfig): BoundedClient;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AuthProvider } from '../types';
|
|
2
|
+
import { type ClientConfig } from './config';
|
|
2
3
|
import type { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
4
|
import { type EvmTransactionPolicy } from '../utils/evm/evm-transaction-validation';
|
|
4
5
|
/** Internal overrides for per-request auth and headers. */
|
|
@@ -13,6 +14,19 @@ export type RequestOverrides = {
|
|
|
13
14
|
signal?: AbortSignal;
|
|
14
15
|
/** @internal trusted runtime/chain binding for an explicit wallet client. */
|
|
15
16
|
_evmTransactionPolicy?: EvmTransactionPolicy;
|
|
17
|
+
/**
|
|
18
|
+
* @internal Fully-resolved config for a scoped `createClient()` instance. When
|
|
19
|
+
* present, the request targets THIS config's endpoints + appId instead of the
|
|
20
|
+
* module-global `init()` config. Threaded internally by the scoped client;
|
|
21
|
+
* app code never sets it.
|
|
22
|
+
*/
|
|
23
|
+
_config?: ClientConfig;
|
|
24
|
+
/**
|
|
25
|
+
* @internal Read-only scoped instance marker. The request omits auth entirely,
|
|
26
|
+
* never reads or refreshes the ambient global session, and never populates the
|
|
27
|
+
* shared read cache. Threaded internally by the scoped read-only client.
|
|
28
|
+
*/
|
|
29
|
+
_readOnly?: boolean;
|
|
16
30
|
};
|
|
17
31
|
export type SetOptions = {
|
|
18
32
|
shouldSubmitTx?: boolean;
|
|
@@ -109,22 +123,6 @@ export type AggregateOptions = {
|
|
|
109
123
|
field?: string;
|
|
110
124
|
_overrides?: RequestOverrides;
|
|
111
125
|
};
|
|
112
|
-
/**
|
|
113
|
-
* Count items in a collection path. Returns a numeric result.
|
|
114
|
-
*
|
|
115
|
-
* This uses the AI query engine with a count-specific prompt prefix,
|
|
116
|
-
* so Bounded will generate a $count aggregation pipeline and return
|
|
117
|
-
* just the count rather than full documents.
|
|
118
|
-
*
|
|
119
|
-
* IMPORTANT: This only works for collections where the read policy is "true".
|
|
120
|
-
* If the read policy requires per-document checks, the server will return
|
|
121
|
-
* an error because aggregate counts cannot be performed without pulling all
|
|
122
|
-
* documents for access control evaluation.
|
|
123
|
-
*
|
|
124
|
-
* @param path - Collection path (e.g., "posts", "users/abc/comments")
|
|
125
|
-
* @param opts - Optional filter prompt and overrides
|
|
126
|
-
* @returns AggregateResult with the count value
|
|
127
|
-
*/
|
|
128
126
|
export declare function count(path: string, opts?: CountOptions): Promise<AggregateResult>;
|
|
129
127
|
/**
|
|
130
128
|
* Run an aggregate operation on a collection path. Returns a numeric result.
|