@bounded-sh/core 0.0.1 → 0.0.3

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 CHANGED
@@ -63,7 +63,7 @@ function getConfig(): Promise<ClientConfig>;
63
63
  function get(path: string): Promise<any>;
64
64
  function getMany(paths: string[], options?: { bypassCache?: boolean }): Promise<GetManyResult[]>;
65
65
  function set(path: string, data: any, options?: SetOptions): Promise<any>;
66
- function setMany(paths: { [key: string]: any }, options?: SetOptions): Promise<any>;
66
+ function setMany(many: { path: string; document: any }[], options?: SetOptions): Promise<any>;
67
67
  function setFile(path: string, file: File, metadata?: any): Promise<any>;
68
68
  function getFiles(path: string): Promise<any>;
69
69
  function runQuery(queryString: string, variables?: any): Promise<any>;
@@ -75,4 +75,4 @@ function subscribe(path: string, options?: SubscriptionOptions): Promise<() => v
75
75
 
76
76
  ## Contributing
77
77
 
78
- Please see the main repository for contribution guidelines.
78
+ Please see the main repository for contribution guidelines.
@@ -96,7 +96,7 @@ export declare function getWebhookKeysUrl(): string | undefined;
96
96
  /**
97
97
  * True when init() configured a Bounded network (the Cloudflare-native stack).
98
98
  * Synchronous + non-blocking. Used to route reads/writes that behave differently
99
- * on Bounded vs the legacy Tarobase backend (e.g. `count`/`aggregate`, which on
99
+ * on Bounded vs the legacy backend (e.g. `count`/`aggregate`, which on
100
100
  * Bounded must use the deterministic server aggregation, not the legacy AI query).
101
101
  */
102
102
  export declare function isBoundedNetwork(): boolean;
@@ -12,6 +12,31 @@ export type LiveIntentOptions = {
12
12
  */
13
13
  fireAndForget?: boolean;
14
14
  };
15
+ export type LiveStatusOptions = {
16
+ /** Per-call timeout (ms) for the HTTP request to the realtime worker. */
17
+ timeoutMs?: number;
18
+ /** Extra headers (advanced/testing). */
19
+ headers?: Record<string, string>;
20
+ };
21
+ export type LiveStopReason = 'idle' | 'lifetime' | 'error' | 'manual' | 'evicted' | string;
22
+ export type LiveStatus = {
23
+ available: boolean;
24
+ started: boolean;
25
+ module?: string;
26
+ etag?: string;
27
+ running?: boolean;
28
+ tick?: number;
29
+ lastErr?: string | null;
30
+ stopReason?: LiveStopReason | null;
31
+ lastTickAt?: number | null;
32
+ nextTickAt?: number | null;
33
+ nextAlarmAt?: number | null;
34
+ generation?: number;
35
+ connections?: number;
36
+ startedAtMs?: number | null;
37
+ stoppedAtMs?: number | null;
38
+ reason?: string;
39
+ };
15
40
  export declare class LiveIntentError extends Error {
16
41
  statusCode?: number | undefined;
17
42
  details?: any | undefined;
@@ -33,8 +58,21 @@ export declare class LiveIntentError extends Error {
33
58
  export declare function intent(roomPath: string, intent: unknown, opts?: LiveIntentOptions): Promise<{
34
59
  ok: true;
35
60
  }>;
61
+ /**
62
+ * Fetch the runtime status for a live room.
63
+ *
64
+ * const s = await bounded.live.status('rooms/abc');
65
+ * console.log(s.running, s.stopReason, s.generation, s.etag);
66
+ *
67
+ * This is diagnostic/ops surface. It reports whether the room facet exists,
68
+ * whether it is currently ticking, why it last stopped, which module etag is
69
+ * loaded, and the current generation used after terminal restarts.
70
+ */
71
+ export declare function status(roomPath: string, opts?: LiveStatusOptions): Promise<LiveStatus>;
36
72
  export type SubscribeViewOptions = {
37
- /** Address whose view to read. Defaults to the logged-in user's address. */
73
+ /** User id whose view to read. Defaults to the logged-in user's @user.id. */
74
+ userId?: string;
75
+ /** Legacy alias for wallet-address keyed view docs. Prefer userId for new rooms. */
38
76
  address?: string;
39
77
  /** Called with the latest per-player view document. */
40
78
  onData: (view: any) => void;
@@ -44,10 +82,11 @@ export type SubscribeViewOptions = {
44
82
  /**
45
83
  * Subscribe to YOUR per-player view of a room. Thin sugar over:
46
84
  *
47
- * subscribe('<roomPath>/view/<myAddress>', { onData, onError })
85
+ * subscribe('<roomPath>/view/<myUserId>', { onData, onError })
48
86
  *
49
- * The address defaults to the logged-in user's address (from the session
50
- * token's claims); pass `opts.address` to override. Returns the unsubscribe
87
+ * The view id defaults to the logged-in user's @user.id (from the session token
88
+ * claims); pass `opts.userId` to override. `opts.address` is kept as a legacy
89
+ * alias for older wallet-address keyed policies. Returns the unsubscribe
51
90
  * function (a Promise<() => Promise<void>>, same as `subscribe`).
52
91
  *
53
92
  * Note: this is a browser-first helper (the WS subscription manager is
@@ -57,5 +96,6 @@ export declare function subscribeView(roomPath: string, opts: SubscribeViewOptio
57
96
  /** The `bounded.live` namespace surface. */
58
97
  export declare const live: {
59
98
  intent: typeof intent;
99
+ status: typeof status;
60
100
  subscribeView: typeof subscribeView;
61
101
  };
@@ -91,7 +91,7 @@ export type AggregateOptions = {
91
91
  * Count items in a collection path. Returns a numeric result.
92
92
  *
93
93
  * This uses the AI query engine with a count-specific prompt prefix,
94
- * so TaroBase will generate a $count aggregation pipeline and return
94
+ * so Bounded will generate a $count aggregation pipeline and return
95
95
  * just the count rather than full documents.
96
96
  *
97
97
  * IMPORTANT: This only works for collections where the read policy is "true".
@@ -236,6 +236,13 @@ export declare function runExpressionMany(many: {
236
236
  returnType?: 'Bool' | 'String' | 'Int' | 'UInt';
237
237
  _overrides?: RequestOverrides;
238
238
  }[]): Promise<RunExpressionResult[]>;
239
+ /**
240
+ * Write a document at `path`. Sugar for a one-element {@link setMany}.
241
+ *
242
+ * **Delete:** pass `null` as the document to delete it — `set(path, null)` is
243
+ * the delete (there is no separate `del`/`remove`). It is routed through the
244
+ * collection's policy `delete` rule and broadcasts a delete to subscribers.
245
+ */
239
246
  export declare function set(path: string, document: any, options?: SetOptions): Promise<any>;
240
247
  export declare function setMany(many: {
241
248
  path: string;
@@ -87,6 +87,6 @@ export declare function wsDelete(path: string): Promise<any>;
87
87
  export declare function wsGetMany(paths: string[]): Promise<any>;
88
88
  declare global {
89
89
  interface Window {
90
- CUSTOM_TAROBASE_APP_ID_HEADER?: string;
90
+ CUSTOM_BOUNDED_APP_ID_HEADER?: string;
91
91
  }
92
92
  }
@@ -59,6 +59,6 @@ export declare function getCachedData(path: string, prompt?: string): any | null
59
59
  export declare function reconnectWithNewAuth(): Promise<void>;
60
60
  declare global {
61
61
  interface Window {
62
- CUSTOM_TAROBASE_APP_ID_HEADER?: string;
62
+ CUSTOM_BOUNDED_APP_ID_HEADER?: string;
63
63
  }
64
64
  }
package/dist/index.d.ts CHANGED
@@ -16,14 +16,14 @@ export { getActiveSessionManager } from './utils/session-manager';
16
16
  export type { ClientSessionManager } from './utils/session-manager';
17
17
  export { ServerSessionManager } from './utils/server-session-manager';
18
18
  export { createSessionWithSignature, refreshSession, revokeSession, signSessionCreateMessage, genAuthNonce } from './utils/auth-api';
19
- export { Tarobase as Tarobase6 } from './utils/sol/taro6CvKqwrYrDc16ufYgzQ2NZcyyVKStffbtudrhRuDevnet-program';
20
- export { Tarobase as TarobasePoof } from './utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program';
19
+ export { Tarobase as Bounded6 } from './utils/sol/taro6CvKqwrYrDc16ufYgzQ2NZcyyVKStffbtudrhRuDevnet-program';
20
+ export { Tarobase as BoundedPoof } from './utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program';
21
21
  export { buildSetDocumentsTransaction, convertRemainingAccounts, RemainingAccount, genSolanaMessage } from './utils/sol/sol-utils';
22
22
  export { RealtimeStore, getRealtimeStore, resetRealtimeStore } from './client/realtime-store';
23
23
  export type { StorageTier, SubscriptionStatus, SubscriptionState, SubscribeOptions, DeltaChange } from './client/realtime-store';
24
24
  export { functions, invoke as invokeFunction, FunctionInvokeError } from './client/functions';
25
25
  export type { InvokeOptions } from './client/functions';
26
- export { live, intent as liveIntent, subscribeView as subscribeLiveView, LiveIntentError } from './client/live';
27
- export type { LiveIntentOptions, SubscribeViewOptions } from './client/live';
26
+ export { live, intent as liveIntent, status as liveStatus, subscribeView as subscribeLiveView, LiveIntentError } from './client/live';
27
+ export type { LiveIntentOptions, LiveStatus, LiveStatusOptions, SubscribeViewOptions } from './client/live';
28
28
  export { withEffects, isEffectResult, defineLiveModule, EFFECT_INTENT_ADDRESS } from './client/live-effects';
29
29
  export type { Effect, EffectKind, EffectResult, LiveIntent, LiveTickResult, LiveModule } from './client/live-effects';