@sylphx/lens-server 3.0.0 → 4.0.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { InferRouterContext as InferRouterContext3, MutationDef as MutationDef2, mutation, QueryDef as QueryDef2, query, ResolverContext, ResolverFn, RouterDef as RouterDef3, RouterRoutes, router } from "@sylphx/lens-core";
1
+ import { InferRouterContext as InferRouterContext3, MutationDef as MutationDef2, mutation, QueryDef as QueryDef2, query, RouterDef as RouterDef3, RouterRoutes, router } from "@sylphx/lens-core";
2
2
  import { ContextStore, ContextValue } from "@sylphx/lens-core";
3
3
  /**
4
4
  * Create a typed context reference.
@@ -41,7 +41,7 @@ declare function extendContext<
41
41
  E extends ContextValue
42
42
  >(current: T, extension: E): T & E;
43
43
  import { ContextValue as ContextValue3, InferRouterContext as InferRouterContext2, RouterDef as RouterDef2 } from "@sylphx/lens-core";
44
- import { AnyQueryDef, ContextValue as ContextValue2, EntityDef, InferRouterContext, MutationDef, Observable, OptimisticDSL, QueryDef, Resolvers, RouterDef } from "@sylphx/lens-core";
44
+ import { AnyQueryDef, ContextValue as ContextValue2, InferRouterContext, ModelDef, MutationDef, Observable, OptimisticDSL, QueryDef, Resolvers, RouterDef, SubscriptionDef } from "@sylphx/lens-core";
45
45
  /**
46
46
  * @sylphx/lens-server - Plugin System Types
47
47
  *
@@ -459,7 +459,7 @@ interface SelectionObject {
459
459
  } | NestedSelection;
460
460
  }
461
461
  /** Entity map type */
462
- type EntitiesMap = Record<string, EntityDef<string, any>>;
462
+ type EntitiesMap = Record<string, ModelDef<string, any>>;
463
463
  /** Queries map type */
464
464
  type QueriesMap = Record<string, AnyQueryDef<unknown, unknown>>;
465
465
  /** Mutations map type */
@@ -473,6 +473,11 @@ interface OperationMeta {
473
473
  * Used by client for field-level subscription detection.
474
474
  */
475
475
  returnType?: string;
476
+ /**
477
+ * Indicates this is a live query (Publisher pattern with _subscriber).
478
+ * Client should use streaming transport even though type is "query".
479
+ */
480
+ live?: boolean;
476
481
  }
477
482
  /** Nested operations structure for handshake */
478
483
  type OperationsMap = {
@@ -597,8 +602,8 @@ interface LensServer {
597
602
  */
598
603
  getPluginManager(): PluginManager;
599
604
  }
600
- type InferInput<T> = T extends QueryDef<infer I, any> ? I : T extends MutationDef<infer I, any> ? I : never;
601
- type InferOutput<T> = T extends QueryDef<any, infer O> ? O : T extends MutationDef<any, infer O> ? O : T extends FieldType<infer F> ? F : never;
605
+ type InferInput<T> = T extends QueryDef<infer I, any> ? I : T extends MutationDef<infer I, any> ? I : T extends SubscriptionDef<infer I, any> ? I : never;
606
+ type InferOutput<T> = T extends QueryDef<any, infer O> ? O : T extends MutationDef<any, infer O> ? O : T extends SubscriptionDef<any, infer O> ? O : T extends FieldType<infer F> ? F : never;
602
607
  type InferApi<T> = T extends {
603
608
  _types: infer Types;
604
609
  } ? Types : never;
@@ -1010,6 +1015,7 @@ interface WSHandlerOptions {
1010
1015
  * Logger for debugging.
1011
1016
  */
1012
1017
  logger?: {
1018
+ debug?: (message: string, ...args: unknown[]) => void;
1013
1019
  info?: (message: string, ...args: unknown[]) => void;
1014
1020
  warn?: (message: string, ...args: unknown[]) => void;
1015
1021
  error?: (message: string, ...args: unknown[]) => void;
@@ -1434,7 +1440,7 @@ type OptimisticPlugin = OptimisticPluginMarker & ServerPlugin;
1434
1440
  * .input(z.object({ id: z.string(), name: z.string() }))
1435
1441
  * .returns(User)
1436
1442
  * .optimistic('merge')
1437
- * .resolve(({ input }) => db.user.update(input));
1443
+ * .resolve(({ args }) => db.user.update(args));
1438
1444
  *
1439
1445
  * const server = createApp({ router, plugins });
1440
1446
  * ```
@@ -1522,6 +1528,9 @@ declare class OperationLog {
1522
1528
  cleanup(): void;
1523
1529
  /**
1524
1530
  * Remove oldest entry and update tracking.
1531
+ *
1532
+ * IMPORTANT: After entries.shift(), ALL indices must be decremented by 1
1533
+ * to maintain correctness of entityIndex lookups.
1525
1534
  */
1526
1535
  private removeOldest;
1527
1536
  /**
@@ -1717,4 +1726,4 @@ declare function toBasicLogger(structuredLogger: StructuredLogger): {
1717
1726
  warn: (message: string, ...args: unknown[]) => void;
1718
1727
  error: (message: string, ...args: unknown[]) => void;
1719
1728
  };
1720
- export { useContext, tryUseContext, toBasicLogger, runWithContextAsync, runWithContext, router, query, prettyOutput, optimisticPlugin, opLog, mutation, memoryStorage, jsonOutput, isOptimisticPlugin, isOpLogPlugin, hasContext, handleWebSSE, handleWebQuery, handleWebMutation, extendContext, estimatePatchSize, createWSHandler, createStructuredLogger, createServerClientProxy, createSSEHandler, createPluginManager, createHandler, createHTTPHandler, createFrameworkHandler, createContext, createApp, coalescePatches, WebSocketLike, WebSocketContext, WSHandlerOptions, WSHandlerConfig, WSHandler, UnsubscribeContext, SubscribeContext, StructuredLoggerOptions, StructuredLogger, StoredPatchEntry, StoredEntityState, ServerPlugin, ServerMetadata, LensServerConfig as ServerConfig, SelectionObject, SSEHandlerConfig as SSEHandlerOptions, SSEHandlerConfig, SSEHandler, SSEClient, RouterRoutes, RouterDef3 as RouterDef, ResolverFn, ResolverContext, RequestContext, QueryDef2 as QueryDef, QueriesMap, PluginManager, PerformanceContext, OptimisticPluginOptions, OperationsMap, OperationMeta, OperationLog, OpLogStorageConfig, OpLogStorage, OpLogPlugin, OpLogOptions, MutationsMap, MutationDef2 as MutationDef, LogOutput, LogLevel, LogEntry, LogContext, LensServer, LensResult, LensOperation, InferRouterContext3 as InferRouterContext, InferOutput, InferInput, InferApi, HandlerOptions, Handler, HTTPHandlerOptions, HTTPHandler, FrameworkHandlerOptions, ErrorContext, EntitiesMap, EnhanceOperationMetaContext, EmitResult, DisconnectContext, DEFAULT_WS_HANDLER_CONFIG, DEFAULT_STORAGE_CONFIG, ConnectContext, ClientSendFn, BroadcastResult, BeforeSendContext, BeforeMutationContext, AfterSendContext, AfterMutationContext };
1729
+ export { useContext, tryUseContext, toBasicLogger, runWithContextAsync, runWithContext, router, query, prettyOutput, optimisticPlugin, opLog, mutation, memoryStorage, jsonOutput, isOptimisticPlugin, isOpLogPlugin, hasContext, handleWebSSE, handleWebQuery, handleWebMutation, extendContext, estimatePatchSize, createWSHandler, createStructuredLogger, createServerClientProxy, createSSEHandler, createPluginManager, createHandler, createHTTPHandler, createFrameworkHandler, createContext, createApp, coalescePatches, WebSocketLike, WebSocketContext, WSHandlerOptions, WSHandlerConfig, WSHandler, UnsubscribeContext, SubscribeContext, StructuredLoggerOptions, StructuredLogger, StoredPatchEntry, StoredEntityState, ServerPlugin, ServerMetadata, LensServerConfig as ServerConfig, SelectionObject, SSEHandlerConfig as SSEHandlerOptions, SSEHandlerConfig, SSEHandler, SSEClient, RouterRoutes, RouterDef3 as RouterDef, RequestContext, QueryDef2 as QueryDef, QueriesMap, PluginManager, PerformanceContext, OptimisticPluginOptions, OperationsMap, OperationMeta, OperationLog, OpLogStorageConfig, OpLogStorage, OpLogPlugin, OpLogOptions, MutationsMap, MutationDef2 as MutationDef, LogOutput, LogLevel, LogEntry, LogContext, LensServer, LensResult, LensOperation, InferRouterContext3 as InferRouterContext, InferOutput, InferInput, InferApi, HandlerOptions, Handler, HTTPHandlerOptions, HTTPHandler, FrameworkHandlerOptions, ErrorContext, EntitiesMap, EnhanceOperationMetaContext, EmitResult, DisconnectContext, DEFAULT_WS_HANDLER_CONFIG, DEFAULT_STORAGE_CONFIG, ConnectContext, ClientSendFn, BroadcastResult, BeforeSendContext, BeforeMutationContext, AfterSendContext, AfterMutationContext };