@stacksjs/orm 0.70.322 → 0.70.324

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.
@@ -33,6 +33,20 @@ export declare function withoutEvents<T>(fn: () => T | Promise<T>): Promise<T>;
33
33
  * ```
34
34
  */
35
35
  export declare function withoutValidation<T>(fn: () => T | Promise<T>): Promise<T>;
36
+ /**
37
+ * Standalone projection helper (#1891) — used by both the lifecycle
38
+ * sync and the bulk-reindex path so the document shape stays
39
+ * consistent. Mirrors the closure inside `buildSearchHooks` but
40
+ * lives at module scope so the static-helpers code can reach it.
41
+ */
42
+ /**
43
+ * Project a whole chunk at once.
44
+ *
45
+ * The entry point for every bulk indexing path. `shapeMany` gets the batch and
46
+ * decides for itself how many queries that costs; without it this falls back to
47
+ * projecting each row, which is what a column-rearranging `shape` wants anyway.
48
+ */
49
+ export declare function projectDocumentsFromTrait(models: any[], config: SearchableTraitConfig): Promise<Record<string, unknown>[]>;
36
50
  export declare function defineModel<const TDef extends ModelDefinition>(definition: TDef): StacksModelStatic<TDef>;
37
51
  /**
38
52
  * Normalize a ModelInstance (or array of them, or already-plain row) into
@@ -77,6 +91,23 @@ declare interface StacksModelDefinition extends Omit<BQBModelDefinition, 'attrib
77
91
  }
78
92
  [key: string]: any
79
93
  }
94
+ /**
95
+ * Scout-style search index sync when `traits.useSearch` is set.
96
+ * Indexes on create/update and removes on delete without requiring `observe: true`.
97
+ */
98
+ /**
99
+ * Per-model search-trait config (stacksjs/stacks#1891). Accepts
100
+ * either `true` (legacy boolean — uses the model's
101
+ * `toSearchableObject()` if defined) OR a declarative object that
102
+ * spells out index name, document projection, and whether to
103
+ * dispatch the sync via a queued job.
104
+ */
105
+ declare interface SearchableTraitConfig {
106
+ index?: string
107
+ shape?: (model: any) => Record<string, unknown> | null | undefined | Promise<Record<string, unknown> | null | undefined>
108
+ shapeMany?: (models: any[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>
109
+ queueable?: boolean
110
+ }
80
111
  export declare interface TraitMethods {
81
112
  _taggable?: ReturnType<typeof createTaggableMethods>
82
113
  _categorizable?: ReturnType<typeof createCategorizableMethods>