@lunora/server 1.0.0-alpha.183 → 1.0.0-alpha.184

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.mts CHANGED
@@ -358,9 +358,9 @@ type ComposedOut<Plugins extends ReadonlyArray<unknown>> = Plugins extends reado
358
358
  * `defineSchema` argument so a plugin can ship vector decls alongside its
359
359
  * tables.
360
360
  */
361
- interface SchemaExtension<T extends Record<string, TableDefinition> = Record<string, TableDefinition>> {
362
- /** Stable key identifying the plugin that owns this extension. */
363
- readonly key: string;
361
+ interface SchemaExtension<T extends Record<string, TableDefinition> = Record<string, TableDefinition>, Key extends string = string> {
362
+ /** Stable key identifying the plugin that owns this extension. Kept literal, so `.extend()` adds exactly `<key>_<table>`. */
363
+ readonly key: Key;
364
364
  /**
365
365
  * Extension tables, keyed by **bare** name (e.g. `buckets`). At merge time
366
366
  * each is auto-prefixed with `key` (`ratelimit_buckets`) so it can't
@@ -378,10 +378,10 @@ interface SchemaExtension<T extends Record<string, TableDefinition> = Record<str
378
378
  * Build a {@link SchemaExtension}. The `key` is a runtime tag (used for
379
379
  * error messages on collision) and a type-level brand.
380
380
  */
381
- declare const defineSchemaExtension: <T extends Record<string, TableDefinition>>(key: string, options: {
381
+ declare const defineSchemaExtension: <T extends Record<string, TableDefinition>, const Key extends string = string>(key: Key, options: {
382
382
  tables: T;
383
383
  vectorIndexes?: Record<string, VectorIndexDefinition>;
384
- }) => SchemaExtension<T>;
384
+ }) => SchemaExtension<T, Key>;
385
385
  /**
386
386
  * A plugin packages an optional schema extension and optional middleware.
387
387
  * Both are independently usable: an app can install only the schema (e.g.
@@ -423,10 +423,10 @@ interface DefinePluginOptions<TExtension extends Record<string, TableDefinition>
423
423
  * that carry only middleware.
424
424
  */
425
425
  interface DefinePluginFunction {
426
- <TExtension extends Record<string, TableDefinition>, TContextIn = unknown, TContextOut = TContextIn>(key: string, options: DefinePluginOptions<TExtension, TContextIn, TContextOut> & {
427
- extension: SchemaExtension<TExtension>;
426
+ <TExtension extends Record<string, TableDefinition>, TContextIn = unknown, TContextOut = TContextIn, const Key extends string = string>(key: Key, options: DefinePluginOptions<TExtension, TContextIn, TContextOut> & {
427
+ extension: SchemaExtension<TExtension, Key>;
428
428
  }): Plugin<TExtension, TContextIn, TContextOut> & {
429
- readonly extension: SchemaExtension<TExtension>;
429
+ readonly extension: SchemaExtension<TExtension, Key>;
430
430
  };
431
431
  <TExtension extends Record<string, TableDefinition>, TContextIn = unknown, TContextOut = TContextIn>(key: string, options: DefinePluginOptions<TExtension, TContextIn, TContextOut>): Plugin<TExtension, TContextIn, TContextOut>;
432
432
  }
@@ -1041,6 +1041,8 @@ declare const indexFieldsFromSchema: (schema: Schema) => IndexFieldsByTable;
1041
1041
  declare const defineSchema: <T extends Record<string, TableDefinition>>(tables: T, vectorIndexes?: Record<string, VectorIndexDefinition>, aggregateIndexes?: Record<string, AggregateIndexDefinition>, rankIndexes?: Record<string, RankIndexDefinition>) => ExtendableSchema<T>;
1042
1042
  /** Default lifetime of a cached entry: one hour. */
1043
1043
  declare const DEFAULT_ACTION_CACHE_TTL_MS: number;
1044
+ /** The bare extension key and table name. Prefixing makes the merged table `actionCache_entries`. */
1045
+ declare const ACTION_CACHE_KEY = "actionCache";
1044
1046
  declare const ACTION_CACHE_BARE_TABLE = "entries";
1045
1047
  /**
1046
1048
  * The prefixed table name the extension produces at merge time. The handlers and
@@ -1162,7 +1164,7 @@ type ActionCacheComponent = {
1162
1164
  */
1163
1165
  declare const actionCacheExtension: SchemaExtension<{
1164
1166
  [ACTION_CACHE_BARE_TABLE]: ReturnType<typeof defineTable>;
1165
- }>;
1167
+ }, typeof ACTION_CACHE_KEY>;
1166
1168
  /**
1167
1169
  * Build an action-cache {@link Component} — schema extension, `purgeExpired`, and
1168
1170
  * the `wrap` / `invalidate` / `invalidateAll` helpers — wired to one TTL.
@@ -1397,6 +1399,8 @@ declare const beginDeferredSchedules: (context: DeferredScheduleContext) => ((co
1397
1399
  * secret". Extend it per app rather than relying on this list being complete.
1398
1400
  */
1399
1401
  declare const DEFAULT_REDACTED_FIELDS: ReadonlyArray<string>;
1402
+ /** The bare extension key and table name. Prefixing makes the merged table `documentHistory_versions`. */
1403
+ declare const DOCUMENT_HISTORY_KEY = "documentHistory";
1400
1404
  declare const DOCUMENT_HISTORY_BARE_TABLE = "versions";
1401
1405
  /** The prefixed table name the extension produces at merge time. */
1402
1406
  declare const DOCUMENT_HISTORY_TABLE: "documentHistory_versions";
@@ -1487,7 +1491,7 @@ type DocumentHistoryComponent = {
1487
1491
  */
1488
1492
  declare const documentHistoryExtension: SchemaExtension<{
1489
1493
  [DOCUMENT_HISTORY_BARE_TABLE]: ReturnType<typeof defineTable>;
1490
- }>;
1494
+ }, typeof DOCUMENT_HISTORY_KEY>;
1491
1495
  /**
1492
1496
  * Build a document-history {@link Component} — schema extension, the
1493
1497
  * `.triggers()` recorder, and the `listForDocument` / `vacuum` functions.
@@ -3124,6 +3128,8 @@ interface RegisteredMutator<Args extends ValidatorMap = ValidatorMap, ServerCont
3124
3128
  declare const defineMutator: <Args extends ValidatorMap = ValidatorMap, ServerContext = MutationCtx, ClientTx = unknown, R = unknown>(definition: MutatorDefinition<Args, ServerContext, ClientTx, R>) => RegisteredMutator<Args, ServerContext, ClientTx, R>;
3125
3129
  /** Default time-to-live for a presence row: a heartbeat keeps a member "present" for this long. */
3126
3130
  declare const DEFAULT_TTL_MS = 3e4;
3131
+ /** The bare extension key and table name. Prefixing makes the merged table `presence_present`. */
3132
+ declare const PRESENCE_KEY = "presence";
3127
3133
  declare const PRESENCE_BARE_TABLE = "present";
3128
3134
  /**
3129
3135
  * The prefixed table name the extension produces at merge time. The handlers
@@ -3241,7 +3247,7 @@ type PresenceComponent = Component<{
3241
3247
  */
3242
3248
  declare const presenceExtension: SchemaExtension<{
3243
3249
  [PRESENCE_BARE_TABLE]: ReturnType<typeof defineTable>;
3244
- }>;
3250
+ }, typeof PRESENCE_KEY>;
3245
3251
  /**
3246
3252
  * Build a presence {@link Component} — schema extension + heartbeat / listPresent
3247
3253
  * / sweep functions — wired to a single TTL. Re-export `component.functions`
package/dist/index.d.ts CHANGED
@@ -358,9 +358,9 @@ type ComposedOut<Plugins extends ReadonlyArray<unknown>> = Plugins extends reado
358
358
  * `defineSchema` argument so a plugin can ship vector decls alongside its
359
359
  * tables.
360
360
  */
361
- interface SchemaExtension<T extends Record<string, TableDefinition> = Record<string, TableDefinition>> {
362
- /** Stable key identifying the plugin that owns this extension. */
363
- readonly key: string;
361
+ interface SchemaExtension<T extends Record<string, TableDefinition> = Record<string, TableDefinition>, Key extends string = string> {
362
+ /** Stable key identifying the plugin that owns this extension. Kept literal, so `.extend()` adds exactly `<key>_<table>`. */
363
+ readonly key: Key;
364
364
  /**
365
365
  * Extension tables, keyed by **bare** name (e.g. `buckets`). At merge time
366
366
  * each is auto-prefixed with `key` (`ratelimit_buckets`) so it can't
@@ -378,10 +378,10 @@ interface SchemaExtension<T extends Record<string, TableDefinition> = Record<str
378
378
  * Build a {@link SchemaExtension}. The `key` is a runtime tag (used for
379
379
  * error messages on collision) and a type-level brand.
380
380
  */
381
- declare const defineSchemaExtension: <T extends Record<string, TableDefinition>>(key: string, options: {
381
+ declare const defineSchemaExtension: <T extends Record<string, TableDefinition>, const Key extends string = string>(key: Key, options: {
382
382
  tables: T;
383
383
  vectorIndexes?: Record<string, VectorIndexDefinition>;
384
- }) => SchemaExtension<T>;
384
+ }) => SchemaExtension<T, Key>;
385
385
  /**
386
386
  * A plugin packages an optional schema extension and optional middleware.
387
387
  * Both are independently usable: an app can install only the schema (e.g.
@@ -423,10 +423,10 @@ interface DefinePluginOptions<TExtension extends Record<string, TableDefinition>
423
423
  * that carry only middleware.
424
424
  */
425
425
  interface DefinePluginFunction {
426
- <TExtension extends Record<string, TableDefinition>, TContextIn = unknown, TContextOut = TContextIn>(key: string, options: DefinePluginOptions<TExtension, TContextIn, TContextOut> & {
427
- extension: SchemaExtension<TExtension>;
426
+ <TExtension extends Record<string, TableDefinition>, TContextIn = unknown, TContextOut = TContextIn, const Key extends string = string>(key: Key, options: DefinePluginOptions<TExtension, TContextIn, TContextOut> & {
427
+ extension: SchemaExtension<TExtension, Key>;
428
428
  }): Plugin<TExtension, TContextIn, TContextOut> & {
429
- readonly extension: SchemaExtension<TExtension>;
429
+ readonly extension: SchemaExtension<TExtension, Key>;
430
430
  };
431
431
  <TExtension extends Record<string, TableDefinition>, TContextIn = unknown, TContextOut = TContextIn>(key: string, options: DefinePluginOptions<TExtension, TContextIn, TContextOut>): Plugin<TExtension, TContextIn, TContextOut>;
432
432
  }
@@ -1041,6 +1041,8 @@ declare const indexFieldsFromSchema: (schema: Schema) => IndexFieldsByTable;
1041
1041
  declare const defineSchema: <T extends Record<string, TableDefinition>>(tables: T, vectorIndexes?: Record<string, VectorIndexDefinition>, aggregateIndexes?: Record<string, AggregateIndexDefinition>, rankIndexes?: Record<string, RankIndexDefinition>) => ExtendableSchema<T>;
1042
1042
  /** Default lifetime of a cached entry: one hour. */
1043
1043
  declare const DEFAULT_ACTION_CACHE_TTL_MS: number;
1044
+ /** The bare extension key and table name. Prefixing makes the merged table `actionCache_entries`. */
1045
+ declare const ACTION_CACHE_KEY = "actionCache";
1044
1046
  declare const ACTION_CACHE_BARE_TABLE = "entries";
1045
1047
  /**
1046
1048
  * The prefixed table name the extension produces at merge time. The handlers and
@@ -1162,7 +1164,7 @@ type ActionCacheComponent = {
1162
1164
  */
1163
1165
  declare const actionCacheExtension: SchemaExtension<{
1164
1166
  [ACTION_CACHE_BARE_TABLE]: ReturnType<typeof defineTable>;
1165
- }>;
1167
+ }, typeof ACTION_CACHE_KEY>;
1166
1168
  /**
1167
1169
  * Build an action-cache {@link Component} — schema extension, `purgeExpired`, and
1168
1170
  * the `wrap` / `invalidate` / `invalidateAll` helpers — wired to one TTL.
@@ -1397,6 +1399,8 @@ declare const beginDeferredSchedules: (context: DeferredScheduleContext) => ((co
1397
1399
  * secret". Extend it per app rather than relying on this list being complete.
1398
1400
  */
1399
1401
  declare const DEFAULT_REDACTED_FIELDS: ReadonlyArray<string>;
1402
+ /** The bare extension key and table name. Prefixing makes the merged table `documentHistory_versions`. */
1403
+ declare const DOCUMENT_HISTORY_KEY = "documentHistory";
1400
1404
  declare const DOCUMENT_HISTORY_BARE_TABLE = "versions";
1401
1405
  /** The prefixed table name the extension produces at merge time. */
1402
1406
  declare const DOCUMENT_HISTORY_TABLE: "documentHistory_versions";
@@ -1487,7 +1491,7 @@ type DocumentHistoryComponent = {
1487
1491
  */
1488
1492
  declare const documentHistoryExtension: SchemaExtension<{
1489
1493
  [DOCUMENT_HISTORY_BARE_TABLE]: ReturnType<typeof defineTable>;
1490
- }>;
1494
+ }, typeof DOCUMENT_HISTORY_KEY>;
1491
1495
  /**
1492
1496
  * Build a document-history {@link Component} — schema extension, the
1493
1497
  * `.triggers()` recorder, and the `listForDocument` / `vacuum` functions.
@@ -3124,6 +3128,8 @@ interface RegisteredMutator<Args extends ValidatorMap = ValidatorMap, ServerCont
3124
3128
  declare const defineMutator: <Args extends ValidatorMap = ValidatorMap, ServerContext = MutationCtx, ClientTx = unknown, R = unknown>(definition: MutatorDefinition<Args, ServerContext, ClientTx, R>) => RegisteredMutator<Args, ServerContext, ClientTx, R>;
3125
3129
  /** Default time-to-live for a presence row: a heartbeat keeps a member "present" for this long. */
3126
3130
  declare const DEFAULT_TTL_MS = 3e4;
3131
+ /** The bare extension key and table name. Prefixing makes the merged table `presence_present`. */
3132
+ declare const PRESENCE_KEY = "presence";
3127
3133
  declare const PRESENCE_BARE_TABLE = "present";
3128
3134
  /**
3129
3135
  * The prefixed table name the extension produces at merge time. The handlers
@@ -3241,7 +3247,7 @@ type PresenceComponent = Component<{
3241
3247
  */
3242
3248
  declare const presenceExtension: SchemaExtension<{
3243
3249
  [PRESENCE_BARE_TABLE]: ReturnType<typeof defineTable>;
3244
- }>;
3250
+ }, typeof PRESENCE_KEY>;
3245
3251
  /**
3246
3252
  * Build a presence {@link Component} — schema extension + heartbeat / listPresent
3247
3253
  * / sweep functions — wired to a single TTL. Re-export `component.functions`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/server",
3
- "version": "1.0.0-alpha.183",
3
+ "version": "1.0.0-alpha.184",
4
4
  "description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
5
5
  "keywords": [
6
6
  "backend",