@lpdjs/firestore-repo-service 2.6.57 → 3.0.1

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.
Files changed (64) hide show
  1. package/README.md +45 -27
  2. package/dist/{create-servers-BxkVVkg9.d.cts → create-servers-Cbvzs_ou.d.cts} +5 -5
  3. package/dist/{create-servers-B84cbslf.d.ts → create-servers-aWdDTcSu.d.ts} +5 -5
  4. package/dist/{firebase-auth-DZ8lb2Ec.d.cts → firebase-auth-Ds5P0kXT.d.cts} +1 -1
  5. package/dist/{firebase-auth-DZ8lb2Ec.d.ts → firebase-auth-Ds5P0kXT.d.ts} +1 -1
  6. package/dist/index.cjs +97 -85
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +9 -9
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +97 -85
  11. package/dist/index.js.map +1 -1
  12. package/dist/llms-full.txt +237 -263
  13. package/dist/llms.txt +5 -4
  14. package/dist/{openapi-BpbfjSHK.d.ts → openapi-BTu_1vSc.d.ts} +1 -1
  15. package/dist/{openapi-DG7aQUlX.d.cts → openapi-CoKsSOIU.d.cts} +1 -1
  16. package/dist/{queue-B4uwef6c.d.ts → queue-BQxyuEXb.d.ts} +8 -23
  17. package/dist/{queue-CQyWCQBk.d.cts → queue-CMiKvIW1.d.cts} +8 -23
  18. package/dist/rules-B3b-BZLf.d.cts +30 -0
  19. package/dist/rules-BJMT0N0i.d.ts +30 -0
  20. package/dist/servers/admin/index.d.cts +402 -6
  21. package/dist/servers/admin/index.d.ts +402 -6
  22. package/dist/servers/auth/index.d.cts +1 -1
  23. package/dist/servers/auth/index.d.ts +1 -1
  24. package/dist/servers/crud/index.cjs +2 -2
  25. package/dist/servers/crud/index.cjs.map +1 -1
  26. package/dist/servers/crud/index.d.cts +7 -6
  27. package/dist/servers/crud/index.d.ts +7 -6
  28. package/dist/servers/crud/index.js +2 -2
  29. package/dist/servers/crud/index.js.map +1 -1
  30. package/dist/servers/hono/index.d.cts +3 -3
  31. package/dist/servers/hono/index.d.ts +3 -3
  32. package/dist/servers/index.cjs +106 -94
  33. package/dist/servers/index.cjs.map +1 -1
  34. package/dist/servers/index.d.cts +10 -9
  35. package/dist/servers/index.d.ts +10 -9
  36. package/dist/servers/index.js +106 -94
  37. package/dist/servers/index.js.map +1 -1
  38. package/dist/sync/bigquery.cjs +5 -5
  39. package/dist/sync/bigquery.cjs.map +1 -1
  40. package/dist/sync/bigquery.d.cts +28 -3
  41. package/dist/sync/bigquery.d.ts +28 -3
  42. package/dist/sync/bigquery.js +5 -5
  43. package/dist/sync/bigquery.js.map +1 -1
  44. package/dist/sync/index.cjs +74 -54
  45. package/dist/sync/index.cjs.map +1 -1
  46. package/dist/sync/index.d.cts +63 -17
  47. package/dist/sync/index.d.ts +63 -17
  48. package/dist/sync/index.js +74 -54
  49. package/dist/sync/index.js.map +1 -1
  50. package/dist/sync/meilisearch.cjs +4 -0
  51. package/dist/sync/meilisearch.cjs.map +1 -0
  52. package/dist/sync/meilisearch.d.cts +114 -0
  53. package/dist/sync/meilisearch.d.ts +114 -0
  54. package/dist/sync/meilisearch.js +4 -0
  55. package/dist/sync/meilisearch.js.map +1 -0
  56. package/dist/{types-CE-EfugW.d.cts → types-B2e-T8EM.d.cts} +160 -8
  57. package/dist/{types-B4dMmfet.d.cts → types-BIZz3sxN.d.cts} +1 -1
  58. package/dist/{types-DT7Nypd_.d.ts → types-BbFZ57eK.d.ts} +101 -41
  59. package/dist/{types-DyKJJ9UQ.d.ts → types-DSMiiOrU.d.ts} +1 -1
  60. package/dist/{types-cY03CMya.d.ts → types-XRjVKN9r.d.ts} +160 -8
  61. package/dist/{types-BwH1C-wi.d.cts → types-zFrp8RnM.d.cts} +101 -41
  62. package/package.json +19 -1
  63. package/dist/index-D47y5giY.d.ts +0 -469
  64. package/dist/index-dW_7jrlK.d.cts +0 -469
@@ -0,0 +1,4 @@
1
+ 'use strict';var c=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});function l(n){if(n.client)return n.client;if(!n.host)throw new Error("MeilisearchAdapter requires either a `client` instance or a `host` option.");try{let{MeiliSearch:e}=c("meilisearch");return new e({host:n.host,apiKey:n.apiKey})}catch(e){throw new Error(`Failed to load the "meilisearch" package. Please install it with:
2
+ bun add meilisearch # or npm install meilisearch
3
+ Original error: ${e?.message??String(e)}`)}}var o=class{constructor(e){this.name="meilisearch";this._client=null;this.options=e,e.client&&(this._client=e.client);}get client(){return this._client||(this._client=l(this.options)),this._client}async targetExists(e){try{return await this.client.getIndex(e),!0}catch(t){if(t?.code==="index_not_found"||t?.statusCode===404||t?.status===404)return false;throw t}}async upsert(e,t,i){if(t.length===0)return;await this.client.index(e).addDocuments(t,{primaryKey:i});}async delete(e,t,i){if(i.length===0)return;await this.client.index(e).deleteDocuments(i);}async ensureTarget(e){let{targetName:t,primaryKey:i}=e;await this.targetExists(t)||await this.client.createIndex(t,{primaryKey:i});let s=this.options.indexesSettings?.[t];s&&await this.client.index(t).updateSettings(s);}async healthCheck(e){let{targetName:t}=e;try{if(!await this.targetExists(t))return {healthy:!1,targetName:t,targetExists:!1,error:`Meilisearch index "${t}" does not exist`};let r=this.client.index(t),s=await r.getStats(),a=typeof r.getRawInfo=="function"?await r.getRawInfo():{};return {healthy:!0,targetName:t,targetExists:!0,error:null,details:{numberOfDocuments:s?.numberOfDocuments??0,isIndexing:s?.isIndexing??!1,fieldDistribution:s?.fieldDistribution??{},primaryKey:a?.primaryKey??e.primaryKey}}}catch(i){return {healthy:false,targetName:t,targetExists:false,error:i?.message??String(i)}}}async checkConnection(){try{let e=!0;if(typeof this.client.isHealthy=="function"){let i=await this.client.isHealthy();e=i?.status==="available"||i===!0;}else if(typeof this.client.health=="function"){let i=await this.client.health();e=i?.status==="available"||i===!0;}let t;return typeof this.client.getVersion=="function"&&(t=(await this.client.getVersion())?.pkgVersion),{healthy:e,version:t}}catch(e){return {healthy:false,error:e?.message??String(e)}}}};exports.MeilisearchAdapter=o;//# sourceMappingURL=meilisearch.cjs.map
4
+ //# sourceMappingURL=meilisearch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sync/adapters/meilisearch.ts"],"names":["loadMeilisearchClient","options","MeiliSearch","err","MeilisearchAdapter","targetName","items","primaryKey","_primaryKey","ids","settings","index","stats","rawInfo","isHealthy","res","version"],"mappings":"sQA2EA,SAASA,CAAAA,CAAsBC,EAAqD,CAClF,GAAIA,EAAQ,MAAA,CAAQ,OAAOA,EAAQ,MAAA,CACnC,GAAI,CAACA,CAAAA,CAAQ,IAAA,CACX,MAAM,IAAI,KAAA,CACR,4EACF,CAAA,CAEF,GAAI,CAEF,GAAM,CAAE,YAAAC,CAAY,CAAA,CAAI,EAAQ,aAAa,CAAA,CAC7C,OAAO,IAAIA,CAAAA,CAAY,CACrB,IAAA,CAAMD,CAAAA,CAAQ,KACd,MAAA,CAAQA,CAAAA,CAAQ,MAClB,CAAC,CACH,OAASE,CAAAA,CAAU,CACjB,MAAM,IAAI,KAAA,CACR,CAAA;AAAA;AAAA,gBAAA,EAEqBA,GAAK,OAAA,EAAW,MAAA,CAAOA,CAAG,CAAC,CAAA,CAClD,CACF,CACF,CAKO,IAAMC,CAAAA,CAAN,KAAgD,CAKrD,WAAA,CAAYH,EAAoC,CAJhD,IAAA,CAAS,KAAO,aAAA,CAChB,IAAA,CAAQ,OAAA,CAAkC,IAAA,CAIxC,KAAK,OAAA,CAAUA,CAAAA,CACXA,EAAQ,MAAA,GACV,IAAA,CAAK,QAAUA,CAAAA,CAAQ,MAAA,EAE3B,CAGA,IAAI,MAAA,EAA0B,CAC5B,OAAK,IAAA,CAAK,UACR,IAAA,CAAK,OAAA,CAAUD,EAAsB,IAAA,CAAK,OAAO,CAAA,CAAA,CAE5C,IAAA,CAAK,OACd,CAMA,MAAM,a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AAA,CAAYC,GAAK,MAAA,GAAW,WAAA,EAAeA,IAAQ,CAAA,EACrD,CACA,IAAIC,CAAAA,CACJ,OAAI,OAAO,IAAA,CAAK,MAAA,CAAO,YAAe,UAAA,GAEpCA,CAAAA,CAAAA,CADU,MAAM,IAAA,CAAK,MAAA,CAAO,YAAW,GAC1B,UAAA,CAAA,CAER,CAAE,OAAA,CAASF,EAAW,OAAA,CAAAE,CAAQ,CACvC,CAAA,MAAS,CAAA,CAAQ,CACf,OAAO,CAAE,QAAS,KAAA,CAAO,KAAA,CAAO,GAAG,OAAA,EAAW,MAAA,CAAO,CAAC,CAAE,CAC1D,CACF,CACF","file":"meilisearch.cjs","sourcesContent":["/**\n * Meilisearch adapter — streams Firestore changes to Meilisearch indexes.\n *\n * @example\n * ```ts\n * import { MeilisearchAdapter } from \"@lpdjs/firestore-repo-service/sync/meilisearch\";\n *\n * const adapter = new MeilisearchAdapter({\n * host: \"http://localhost:7700\",\n * apiKey: \"masterKey\",\n * indexesSettings: {\n * users: {\n * filterableAttributes: [\"role\", \"status\", \"createdAt\"],\n * sortableAttributes: [\"createdAt\", \"name\"],\n * searchableAttributes: [\"name\", \"email\"],\n * },\n * },\n * });\n * ```\n */\n\nimport type { z } from \"zod\";\nimport type { RepoSyncConfig, SyncAdapter, SyncHealthResult } from \"../types\";\n\n/**\n * Minimal structural shape of a Meilisearch client.\n */\nexport interface MeilisearchLike {\n index(indexUid: string): {\n addDocuments(documents: any[], options?: { primaryKey?: string }): Promise<any>;\n deleteDocuments(documentIds: string[] | number[]): Promise<any>;\n getStats(): Promise<any>;\n getRawInfo(): Promise<any>;\n updateSettings(settings: any): Promise<any>;\n [key: string]: any;\n };\n getIndex(indexUid: string): Promise<any>;\n createIndex(indexUid: string, options?: { primaryKey?: string }): Promise<any>;\n isHealthy?(): Promise<any>;\n health?(): Promise<any>;\n getVersion?(): Promise<any>;\n}\n\nexport interface MeilisearchIndexSettings {\n filterableAttributes?: string[];\n sortableAttributes?: string[];\n searchableAttributes?: string[];\n rankingRules?: string[];\n stopWords?: string[];\n synonyms?: Record<string, string[]>;\n distinctAttribute?: string;\n [key: string]: any;\n}\n\nexport interface MeilisearchAdapterOptions {\n /**\n * Host URL of the Meilisearch instance (e.g. `http://localhost:7700` or `https://ms-xxxx.meilisearch.io`).\n * Required if `client` is not provided.\n */\n host?: string;\n /**\n * API Key (e.g. master key or admin key) with permissions to read/write indexes.\n */\n apiKey?: string;\n /**\n * Existing pre-built Meilisearch client instance.\n */\n client?: MeilisearchLike | any;\n /**\n * Custom index settings per target index name (e.g. filterableAttributes, sortableAttributes).\n */\n indexesSettings?: Record<string, MeilisearchIndexSettings>;\n}\n\n/** Lazy-loader for the optional `meilisearch` peer dependency. */\nfunction loadMeilisearchClient(options: MeilisearchAdapterOptions): MeilisearchLike {\n if (options.client) return options.client;\n if (!options.host) {\n throw new Error(\n \"MeilisearchAdapter requires either a `client` instance or a `host` option.\",\n );\n }\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { MeiliSearch } = require(\"meilisearch\");\n return new MeiliSearch({\n host: options.host,\n apiKey: options.apiKey,\n });\n } catch (err: any) {\n throw new Error(\n `Failed to load the \"meilisearch\" package. Please install it with:\\n` +\n ` bun add meilisearch # or npm install meilisearch\\n` +\n `Original error: ${err?.message ?? String(err)}`,\n );\n }\n}\n\n/**\n * SyncAdapter implementation for Meilisearch.\n */\nexport class MeilisearchAdapter implements SyncAdapter {\n readonly name = \"meilisearch\";\n private _client: MeilisearchLike | null = null;\n private readonly options: MeilisearchAdapterOptions;\n\n constructor(options: MeilisearchAdapterOptions) {\n this.options = options;\n if (options.client) {\n this._client = options.client;\n }\n }\n\n /** Resolved Meilisearch client instance. */\n get client(): MeilisearchLike {\n if (!this._client) {\n this._client = loadMeilisearchClient(this.options);\n }\n return this._client;\n }\n\n // ---------------------------------------------------------------------------\n // SyncAdapter Methods\n // ---------------------------------------------------------------------------\n\n async targetExists(targetName: string): Promise<boolean> {\n try {\n await this.client.getIndex(targetName);\n return true;\n } catch (err: any) {\n if (\n err?.code === \"index_not_found\" ||\n err?.statusCode === 404 ||\n err?.status === 404\n ) {\n return false;\n }\n throw err;\n }\n }\n\n async upsert(\n targetName: string,\n items: Record<string, unknown>[],\n primaryKey: string,\n ): Promise<void> {\n if (items.length === 0) return;\n const index = this.client.index(targetName);\n await index.addDocuments(items, { primaryKey });\n }\n\n async delete(\n targetName: string,\n _primaryKey: string,\n ids: string[],\n ): Promise<void> {\n if (ids.length === 0) return;\n const index = this.client.index(targetName);\n await index.deleteDocuments(ids);\n }\n\n async ensureTarget(options: {\n targetName: string;\n primaryKey: string;\n schema?: z.ZodObject<any>;\n exclude?: string[];\n columnMap?: Record<string, string>;\n }): Promise<void> {\n const { targetName, primaryKey } = options;\n const exists = await this.targetExists(targetName);\n if (!exists) {\n await this.client.createIndex(targetName, { primaryKey });\n }\n\n const settings = this.options.indexesSettings?.[targetName];\n if (settings) {\n const index = this.client.index(targetName);\n await index.updateSettings(settings);\n }\n }\n\n async healthCheck(options: {\n targetName: string;\n primaryKey: string;\n schema?: z.ZodObject<any>;\n repoConfig?: RepoSyncConfig<string>;\n }): Promise<SyncHealthResult> {\n const { targetName } = options;\n try {\n const exists = await this.targetExists(targetName);\n if (!exists) {\n return {\n healthy: false,\n targetName,\n targetExists: false,\n error: `Meilisearch index \"${targetName}\" does not exist`,\n };\n }\n const index = this.client.index(targetName);\n const stats = await index.getStats();\n const rawInfo = typeof index.getRawInfo === \"function\" ? await index.getRawInfo() : {};\n\n return {\n healthy: true,\n targetName,\n targetExists: true,\n error: null,\n details: {\n numberOfDocuments: stats?.numberOfDocuments ?? 0,\n isIndexing: stats?.isIndexing ?? false,\n fieldDistribution: stats?.fieldDistribution ?? {},\n primaryKey: rawInfo?.primaryKey ?? options.primaryKey,\n },\n };\n } catch (err: any) {\n return {\n healthy: false,\n targetName,\n targetExists: false,\n error: err?.message ?? String(err),\n };\n }\n }\n\n /** Verify overall connection and connectivity to the Meilisearch instance. */\n async checkConnection(): Promise<{\n healthy: boolean;\n version?: string;\n error?: string;\n }> {\n try {\n let isHealthy = true;\n if (typeof this.client.isHealthy === \"function\") {\n const res = await this.client.isHealthy();\n isHealthy = res?.status === \"available\" || res === true;\n } else if (typeof this.client.health === \"function\") {\n const res = await this.client.health();\n isHealthy = res?.status === \"available\" || res === true;\n }\n let version: string | undefined;\n if (typeof this.client.getVersion === \"function\") {\n const v = await this.client.getVersion();\n version = v?.pkgVersion;\n }\n return { healthy: isHealthy, version };\n } catch (e: any) {\n return { healthy: false, error: e?.message ?? String(e) };\n }\n }\n}\n"]}
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ import { a as SyncAdapter, R as RepoSyncConfig, d as SyncHealthResult } from '../types-zFrp8RnM.cjs';
3
+ import '../firebase-auth-Ds5P0kXT.cjs';
4
+ import 'firebase-functions/v2/firestore';
5
+ import 'firebase-functions/v2/https';
6
+ import 'firebase-functions/v2/pubsub';
7
+
8
+ /**
9
+ * Meilisearch adapter — streams Firestore changes to Meilisearch indexes.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { MeilisearchAdapter } from "@lpdjs/firestore-repo-service/sync/meilisearch";
14
+ *
15
+ * const adapter = new MeilisearchAdapter({
16
+ * host: "http://localhost:7700",
17
+ * apiKey: "masterKey",
18
+ * indexesSettings: {
19
+ * users: {
20
+ * filterableAttributes: ["role", "status", "createdAt"],
21
+ * sortableAttributes: ["createdAt", "name"],
22
+ * searchableAttributes: ["name", "email"],
23
+ * },
24
+ * },
25
+ * });
26
+ * ```
27
+ */
28
+
29
+ /**
30
+ * Minimal structural shape of a Meilisearch client.
31
+ */
32
+ interface MeilisearchLike {
33
+ index(indexUid: string): {
34
+ addDocuments(documents: any[], options?: {
35
+ primaryKey?: string;
36
+ }): Promise<any>;
37
+ deleteDocuments(documentIds: string[] | number[]): Promise<any>;
38
+ getStats(): Promise<any>;
39
+ getRawInfo(): Promise<any>;
40
+ updateSettings(settings: any): Promise<any>;
41
+ [key: string]: any;
42
+ };
43
+ getIndex(indexUid: string): Promise<any>;
44
+ createIndex(indexUid: string, options?: {
45
+ primaryKey?: string;
46
+ }): Promise<any>;
47
+ isHealthy?(): Promise<any>;
48
+ health?(): Promise<any>;
49
+ getVersion?(): Promise<any>;
50
+ }
51
+ interface MeilisearchIndexSettings {
52
+ filterableAttributes?: string[];
53
+ sortableAttributes?: string[];
54
+ searchableAttributes?: string[];
55
+ rankingRules?: string[];
56
+ stopWords?: string[];
57
+ synonyms?: Record<string, string[]>;
58
+ distinctAttribute?: string;
59
+ [key: string]: any;
60
+ }
61
+ interface MeilisearchAdapterOptions {
62
+ /**
63
+ * Host URL of the Meilisearch instance (e.g. `http://localhost:7700` or `https://ms-xxxx.meilisearch.io`).
64
+ * Required if `client` is not provided.
65
+ */
66
+ host?: string;
67
+ /**
68
+ * API Key (e.g. master key or admin key) with permissions to read/write indexes.
69
+ */
70
+ apiKey?: string;
71
+ /**
72
+ * Existing pre-built Meilisearch client instance.
73
+ */
74
+ client?: MeilisearchLike | any;
75
+ /**
76
+ * Custom index settings per target index name (e.g. filterableAttributes, sortableAttributes).
77
+ */
78
+ indexesSettings?: Record<string, MeilisearchIndexSettings>;
79
+ }
80
+ /**
81
+ * SyncAdapter implementation for Meilisearch.
82
+ */
83
+ declare class MeilisearchAdapter implements SyncAdapter {
84
+ readonly name = "meilisearch";
85
+ private _client;
86
+ private readonly options;
87
+ constructor(options: MeilisearchAdapterOptions);
88
+ /** Resolved Meilisearch client instance. */
89
+ get client(): MeilisearchLike;
90
+ targetExists(targetName: string): Promise<boolean>;
91
+ upsert(targetName: string, items: Record<string, unknown>[], primaryKey: string): Promise<void>;
92
+ delete(targetName: string, _primaryKey: string, ids: string[]): Promise<void>;
93
+ ensureTarget(options: {
94
+ targetName: string;
95
+ primaryKey: string;
96
+ schema?: z.ZodObject<any>;
97
+ exclude?: string[];
98
+ columnMap?: Record<string, string>;
99
+ }): Promise<void>;
100
+ healthCheck(options: {
101
+ targetName: string;
102
+ primaryKey: string;
103
+ schema?: z.ZodObject<any>;
104
+ repoConfig?: RepoSyncConfig<string>;
105
+ }): Promise<SyncHealthResult>;
106
+ /** Verify overall connection and connectivity to the Meilisearch instance. */
107
+ checkConnection(): Promise<{
108
+ healthy: boolean;
109
+ version?: string;
110
+ error?: string;
111
+ }>;
112
+ }
113
+
114
+ export { MeilisearchAdapter, type MeilisearchAdapterOptions, type MeilisearchIndexSettings, type MeilisearchLike };
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ import { a as SyncAdapter, R as RepoSyncConfig, d as SyncHealthResult } from '../types-BbFZ57eK.js';
3
+ import '../firebase-auth-Ds5P0kXT.js';
4
+ import 'firebase-functions/v2/firestore';
5
+ import 'firebase-functions/v2/https';
6
+ import 'firebase-functions/v2/pubsub';
7
+
8
+ /**
9
+ * Meilisearch adapter — streams Firestore changes to Meilisearch indexes.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { MeilisearchAdapter } from "@lpdjs/firestore-repo-service/sync/meilisearch";
14
+ *
15
+ * const adapter = new MeilisearchAdapter({
16
+ * host: "http://localhost:7700",
17
+ * apiKey: "masterKey",
18
+ * indexesSettings: {
19
+ * users: {
20
+ * filterableAttributes: ["role", "status", "createdAt"],
21
+ * sortableAttributes: ["createdAt", "name"],
22
+ * searchableAttributes: ["name", "email"],
23
+ * },
24
+ * },
25
+ * });
26
+ * ```
27
+ */
28
+
29
+ /**
30
+ * Minimal structural shape of a Meilisearch client.
31
+ */
32
+ interface MeilisearchLike {
33
+ index(indexUid: string): {
34
+ addDocuments(documents: any[], options?: {
35
+ primaryKey?: string;
36
+ }): Promise<any>;
37
+ deleteDocuments(documentIds: string[] | number[]): Promise<any>;
38
+ getStats(): Promise<any>;
39
+ getRawInfo(): Promise<any>;
40
+ updateSettings(settings: any): Promise<any>;
41
+ [key: string]: any;
42
+ };
43
+ getIndex(indexUid: string): Promise<any>;
44
+ createIndex(indexUid: string, options?: {
45
+ primaryKey?: string;
46
+ }): Promise<any>;
47
+ isHealthy?(): Promise<any>;
48
+ health?(): Promise<any>;
49
+ getVersion?(): Promise<any>;
50
+ }
51
+ interface MeilisearchIndexSettings {
52
+ filterableAttributes?: string[];
53
+ sortableAttributes?: string[];
54
+ searchableAttributes?: string[];
55
+ rankingRules?: string[];
56
+ stopWords?: string[];
57
+ synonyms?: Record<string, string[]>;
58
+ distinctAttribute?: string;
59
+ [key: string]: any;
60
+ }
61
+ interface MeilisearchAdapterOptions {
62
+ /**
63
+ * Host URL of the Meilisearch instance (e.g. `http://localhost:7700` or `https://ms-xxxx.meilisearch.io`).
64
+ * Required if `client` is not provided.
65
+ */
66
+ host?: string;
67
+ /**
68
+ * API Key (e.g. master key or admin key) with permissions to read/write indexes.
69
+ */
70
+ apiKey?: string;
71
+ /**
72
+ * Existing pre-built Meilisearch client instance.
73
+ */
74
+ client?: MeilisearchLike | any;
75
+ /**
76
+ * Custom index settings per target index name (e.g. filterableAttributes, sortableAttributes).
77
+ */
78
+ indexesSettings?: Record<string, MeilisearchIndexSettings>;
79
+ }
80
+ /**
81
+ * SyncAdapter implementation for Meilisearch.
82
+ */
83
+ declare class MeilisearchAdapter implements SyncAdapter {
84
+ readonly name = "meilisearch";
85
+ private _client;
86
+ private readonly options;
87
+ constructor(options: MeilisearchAdapterOptions);
88
+ /** Resolved Meilisearch client instance. */
89
+ get client(): MeilisearchLike;
90
+ targetExists(targetName: string): Promise<boolean>;
91
+ upsert(targetName: string, items: Record<string, unknown>[], primaryKey: string): Promise<void>;
92
+ delete(targetName: string, _primaryKey: string, ids: string[]): Promise<void>;
93
+ ensureTarget(options: {
94
+ targetName: string;
95
+ primaryKey: string;
96
+ schema?: z.ZodObject<any>;
97
+ exclude?: string[];
98
+ columnMap?: Record<string, string>;
99
+ }): Promise<void>;
100
+ healthCheck(options: {
101
+ targetName: string;
102
+ primaryKey: string;
103
+ schema?: z.ZodObject<any>;
104
+ repoConfig?: RepoSyncConfig<string>;
105
+ }): Promise<SyncHealthResult>;
106
+ /** Verify overall connection and connectivity to the Meilisearch instance. */
107
+ checkConnection(): Promise<{
108
+ healthy: boolean;
109
+ version?: string;
110
+ error?: string;
111
+ }>;
112
+ }
113
+
114
+ export { MeilisearchAdapter, type MeilisearchAdapterOptions, type MeilisearchIndexSettings, type MeilisearchLike };
@@ -0,0 +1,4 @@
1
+ var c=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});function l(n){if(n.client)return n.client;if(!n.host)throw new Error("MeilisearchAdapter requires either a `client` instance or a `host` option.");try{let{MeiliSearch:e}=c("meilisearch");return new e({host:n.host,apiKey:n.apiKey})}catch(e){throw new Error(`Failed to load the "meilisearch" package. Please install it with:
2
+ bun add meilisearch # or npm install meilisearch
3
+ Original error: ${e?.message??String(e)}`)}}var o=class{constructor(e){this.name="meilisearch";this._client=null;this.options=e,e.client&&(this._client=e.client);}get client(){return this._client||(this._client=l(this.options)),this._client}async targetExists(e){try{return await this.client.getIndex(e),!0}catch(t){if(t?.code==="index_not_found"||t?.statusCode===404||t?.status===404)return false;throw t}}async upsert(e,t,i){if(t.length===0)return;await this.client.index(e).addDocuments(t,{primaryKey:i});}async delete(e,t,i){if(i.length===0)return;await this.client.index(e).deleteDocuments(i);}async ensureTarget(e){let{targetName:t,primaryKey:i}=e;await this.targetExists(t)||await this.client.createIndex(t,{primaryKey:i});let s=this.options.indexesSettings?.[t];s&&await this.client.index(t).updateSettings(s);}async healthCheck(e){let{targetName:t}=e;try{if(!await this.targetExists(t))return {healthy:!1,targetName:t,targetExists:!1,error:`Meilisearch index "${t}" does not exist`};let r=this.client.index(t),s=await r.getStats(),a=typeof r.getRawInfo=="function"?await r.getRawInfo():{};return {healthy:!0,targetName:t,targetExists:!0,error:null,details:{numberOfDocuments:s?.numberOfDocuments??0,isIndexing:s?.isIndexing??!1,fieldDistribution:s?.fieldDistribution??{},primaryKey:a?.primaryKey??e.primaryKey}}}catch(i){return {healthy:false,targetName:t,targetExists:false,error:i?.message??String(i)}}}async checkConnection(){try{let e=!0;if(typeof this.client.isHealthy=="function"){let i=await this.client.isHealthy();e=i?.status==="available"||i===!0;}else if(typeof this.client.health=="function"){let i=await this.client.health();e=i?.status==="available"||i===!0;}let t;return typeof this.client.getVersion=="function"&&(t=(await this.client.getVersion())?.pkgVersion),{healthy:e,version:t}}catch(e){return {healthy:false,error:e?.message??String(e)}}}};export{o as MeilisearchAdapter};//# sourceMappingURL=meilisearch.js.map
4
+ //# sourceMappingURL=meilisearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sync/adapters/meilisearch.ts"],"names":["loadMeilisearchClient","options","MeiliSearch","err","MeilisearchAdapter","targetName","items","primaryKey","_primaryKey","ids","settings","index","stats","rawInfo","isHealthy","res","version"],"mappings":"yPA2EA,SAASA,CAAAA,CAAsBC,EAAqD,CAClF,GAAIA,EAAQ,MAAA,CAAQ,OAAOA,EAAQ,MAAA,CACnC,GAAI,CAACA,CAAAA,CAAQ,IAAA,CACX,MAAM,IAAI,KAAA,CACR,4EACF,CAAA,CAEF,GAAI,CAEF,GAAM,CAAE,YAAAC,CAAY,CAAA,CAAI,EAAQ,aAAa,CAAA,CAC7C,OAAO,IAAIA,CAAAA,CAAY,CACrB,IAAA,CAAMD,CAAAA,CAAQ,KACd,MAAA,CAAQA,CAAAA,CAAQ,MAClB,CAAC,CACH,OAASE,CAAAA,CAAU,CACjB,MAAM,IAAI,KAAA,CACR,CAAA;AAAA;AAAA,gBAAA,EAEqBA,GAAK,OAAA,EAAW,MAAA,CAAOA,CAAG,CAAC,CAAA,CAClD,CACF,CACF,CAKO,IAAMC,CAAAA,CAAN,KAAgD,CAKrD,WAAA,CAAYH,EAAoC,CAJhD,IAAA,CAAS,KAAO,aAAA,CAChB,IAAA,CAAQ,OAAA,CAAkC,IAAA,CAIxC,KAAK,OAAA,CA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AA,CAAK,MAAA,CAAO,WAAU,CACxCD,CAAAA,CAAYC,GAAK,MAAA,GAAW,WAAA,EAAeA,IAAQ,CAAA,EACrD,CAAA,KAAA,GAAW,OAAO,IAAA,CAAK,MAAA,CAAO,QAAW,UAAA,CAAY,CACnD,IAAMA,CAAAA,CAAM,MAAM,KAAK,MAAA,CAAO,MAAA,EAAO,CACrCD,CAAAA,CAAYC,GAAK,MAAA,GAAW,WAAA,EAAeA,IAAQ,CAAA,EACrD,CACA,IAAIC,CAAAA,CACJ,OAAI,OAAO,IAAA,CAAK,MAAA,CAAO,YAAe,UAAA,GAEpCA,CAAAA,CAAAA,CADU,MAAM,IAAA,CAAK,MAAA,CAAO,YAAW,GAC1B,UAAA,CAAA,CAER,CAAE,OAAA,CAASF,EAAW,OAAA,CAAAE,CAAQ,CACvC,CAAA,MAAS,CAAA,CAAQ,CACf,OAAO,CAAE,QAAS,KAAA,CAAO,KAAA,CAAO,GAAG,OAAA,EAAW,MAAA,CAAO,CAAC,CAAE,CAC1D,CACF,CACF","file":"meilisearch.js","sourcesContent":["/**\n * Meilisearch adapter — streams Firestore changes to Meilisearch indexes.\n *\n * @example\n * ```ts\n * import { MeilisearchAdapter } from \"@lpdjs/firestore-repo-service/sync/meilisearch\";\n *\n * const adapter = new MeilisearchAdapter({\n * host: \"http://localhost:7700\",\n * apiKey: \"masterKey\",\n * indexesSettings: {\n * users: {\n * filterableAttributes: [\"role\", \"status\", \"createdAt\"],\n * sortableAttributes: [\"createdAt\", \"name\"],\n * searchableAttributes: [\"name\", \"email\"],\n * },\n * },\n * });\n * ```\n */\n\nimport type { z } from \"zod\";\nimport type { RepoSyncConfig, SyncAdapter, SyncHealthResult } from \"../types\";\n\n/**\n * Minimal structural shape of a Meilisearch client.\n */\nexport interface MeilisearchLike {\n index(indexUid: string): {\n addDocuments(documents: any[], options?: { primaryKey?: string }): Promise<any>;\n deleteDocuments(documentIds: string[] | number[]): Promise<any>;\n getStats(): Promise<any>;\n getRawInfo(): Promise<any>;\n updateSettings(settings: any): Promise<any>;\n [key: string]: any;\n };\n getIndex(indexUid: string): Promise<any>;\n createIndex(indexUid: string, options?: { primaryKey?: string }): Promise<any>;\n isHealthy?(): Promise<any>;\n health?(): Promise<any>;\n getVersion?(): Promise<any>;\n}\n\nexport interface MeilisearchIndexSettings {\n filterableAttributes?: string[];\n sortableAttributes?: string[];\n searchableAttributes?: string[];\n rankingRules?: string[];\n stopWords?: string[];\n synonyms?: Record<string, string[]>;\n distinctAttribute?: string;\n [key: string]: any;\n}\n\nexport interface MeilisearchAdapterOptions {\n /**\n * Host URL of the Meilisearch instance (e.g. `http://localhost:7700` or `https://ms-xxxx.meilisearch.io`).\n * Required if `client` is not provided.\n */\n host?: string;\n /**\n * API Key (e.g. master key or admin key) with permissions to read/write indexes.\n */\n apiKey?: string;\n /**\n * Existing pre-built Meilisearch client instance.\n */\n client?: MeilisearchLike | any;\n /**\n * Custom index settings per target index name (e.g. filterableAttributes, sortableAttributes).\n */\n indexesSettings?: Record<string, MeilisearchIndexSettings>;\n}\n\n/** Lazy-loader for the optional `meilisearch` peer dependency. */\nfunction loadMeilisearchClient(options: MeilisearchAdapterOptions): MeilisearchLike {\n if (options.client) return options.client;\n if (!options.host) {\n throw new Error(\n \"MeilisearchAdapter requires either a `client` instance or a `host` option.\",\n );\n }\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { MeiliSearch } = require(\"meilisearch\");\n return new MeiliSearch({\n host: options.host,\n apiKey: options.apiKey,\n });\n } catch (err: any) {\n throw new Error(\n `Failed to load the \"meilisearch\" package. Please install it with:\\n` +\n ` bun add meilisearch # or npm install meilisearch\\n` +\n `Original error: ${err?.message ?? String(err)}`,\n );\n }\n}\n\n/**\n * SyncAdapter implementation for Meilisearch.\n */\nexport class MeilisearchAdapter implements SyncAdapter {\n readonly name = \"meilisearch\";\n private _client: MeilisearchLike | null = null;\n private readonly options: MeilisearchAdapterOptions;\n\n constructor(options: MeilisearchAdapterOptions) {\n this.options = options;\n if (options.client) {\n this._client = options.client;\n }\n }\n\n /** Resolved Meilisearch client instance. */\n get client(): MeilisearchLike {\n if (!this._client) {\n this._client = loadMeilisearchClient(this.options);\n }\n return this._client;\n }\n\n // ---------------------------------------------------------------------------\n // SyncAdapter Methods\n // ---------------------------------------------------------------------------\n\n async targetExists(targetName: string): Promise<boolean> {\n try {\n await this.client.getIndex(targetName);\n return true;\n } catch (err: any) {\n if (\n err?.code === \"index_not_found\" ||\n err?.statusCode === 404 ||\n err?.status === 404\n ) {\n return false;\n }\n throw err;\n }\n }\n\n async upsert(\n targetName: string,\n items: Record<string, unknown>[],\n primaryKey: string,\n ): Promise<void> {\n if (items.length === 0) return;\n const index = this.client.index(targetName);\n await index.addDocuments(items, { primaryKey });\n }\n\n async delete(\n targetName: string,\n _primaryKey: string,\n ids: string[],\n ): Promise<void> {\n if (ids.length === 0) return;\n const index = this.client.index(targetName);\n await index.deleteDocuments(ids);\n }\n\n async ensureTarget(options: {\n targetName: string;\n primaryKey: string;\n schema?: z.ZodObject<any>;\n exclude?: string[];\n columnMap?: Record<string, string>;\n }): Promise<void> {\n const { targetName, primaryKey } = options;\n const exists = await this.targetExists(targetName);\n if (!exists) {\n await this.client.createIndex(targetName, { primaryKey });\n }\n\n const settings = this.options.indexesSettings?.[targetName];\n if (settings) {\n const index = this.client.index(targetName);\n await index.updateSettings(settings);\n }\n }\n\n async healthCheck(options: {\n targetName: string;\n primaryKey: string;\n schema?: z.ZodObject<any>;\n repoConfig?: RepoSyncConfig<string>;\n }): Promise<SyncHealthResult> {\n const { targetName } = options;\n try {\n const exists = await this.targetExists(targetName);\n if (!exists) {\n return {\n healthy: false,\n targetName,\n targetExists: false,\n error: `Meilisearch index \"${targetName}\" does not exist`,\n };\n }\n const index = this.client.index(targetName);\n const stats = await index.getStats();\n const rawInfo = typeof index.getRawInfo === \"function\" ? await index.getRawInfo() : {};\n\n return {\n healthy: true,\n targetName,\n targetExists: true,\n error: null,\n details: {\n numberOfDocuments: stats?.numberOfDocuments ?? 0,\n isIndexing: stats?.isIndexing ?? false,\n fieldDistribution: stats?.fieldDistribution ?? {},\n primaryKey: rawInfo?.primaryKey ?? options.primaryKey,\n },\n };\n } catch (err: any) {\n return {\n healthy: false,\n targetName,\n targetExists: false,\n error: err?.message ?? String(err),\n };\n }\n }\n\n /** Verify overall connection and connectivity to the Meilisearch instance. */\n async checkConnection(): Promise<{\n healthy: boolean;\n version?: string;\n error?: string;\n }> {\n try {\n let isHealthy = true;\n if (typeof this.client.isHealthy === \"function\") {\n const res = await this.client.isHealthy();\n isHealthy = res?.status === \"available\" || res === true;\n } else if (typeof this.client.health === \"function\") {\n const res = await this.client.health();\n isHealthy = res?.status === \"available\" || res === true;\n }\n let version: string | undefined;\n if (typeof this.client.getVersion === \"function\") {\n const v = await this.client.getVersion();\n version = v?.pkgVersion;\n }\n return { healthy: isHealthy, version };\n } catch (e: any) {\n return { healthy: false, error: e?.message ?? String(e) };\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { c as AuthUser } from './firebase-auth-DZ8lb2Ec.cjs';
2
- import { H as HonoServerOptions, O as OpenAPIConfig } from './types-B4dMmfet.cjs';
1
+ import { A as AuthUser } from './firebase-auth-Ds5P0kXT.cjs';
2
+ import { H as HonoServerOptions, O as OpenAPIConfig } from './types-BIZz3sxN.cjs';
3
3
  import * as zod from 'zod';
4
4
  import { z } from 'zod';
5
5
  import { HttpsOptions } from 'firebase-functions/v2/https';
@@ -609,6 +609,75 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
609
609
  history?: HistoryMethods<T["type"], Parameters<T["documentRef"]>>;
610
610
  };
611
611
 
612
+ interface PageOptions {
613
+ title: string;
614
+ breadcrumb?: {
615
+ label: string;
616
+ href?: string;
617
+ }[];
618
+ flash?: {
619
+ type: "success" | "error" | "warning";
620
+ message: string;
621
+ /** Optional call-to-action button rendered next to the message */
622
+ action?: {
623
+ href: string;
624
+ label: string;
625
+ external?: boolean;
626
+ };
627
+ };
628
+ basePath?: string;
629
+ }
630
+ /** Firestore WHERE operator */
631
+ type WhereOp = "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
632
+ /** One active filter — serialized in URL as fv_{field} + fo_{field} */
633
+ interface FilterState {
634
+ field: string;
635
+ op: WhereOp;
636
+ value: string;
637
+ }
638
+ /** Per-column metadata used to render appropriate filter inputs/operators */
639
+ interface ColumnMeta {
640
+ name: string;
641
+ /** Innermost Zod type name, e.g. "ZodString", "ZodNumber" */
642
+ zodType: string;
643
+ /** True if the field schema is wrapped in ZodOptional or ZodNullable */
644
+ nullable?: boolean;
645
+ /** For ZodEnum / ZodNativeEnum / ZodLiteral: the allowed values */
646
+ enumValues?: readonly string[];
647
+ }
648
+ /** Active sort state for the list view */
649
+ interface SortState {
650
+ field: string;
651
+ dir: "asc" | "desc";
652
+ }
653
+ /**
654
+ * Metadata for one relational action column appended to the list table.
655
+ * Each entry produces a dedicated button column (not a cell replacement).
656
+ */
657
+ /** Query error state displayed at the top of the list page. */
658
+ interface QueryError {
659
+ /** "index" = missing composite index; "error" = generic query failure */
660
+ type: "index" | "error";
661
+ message: string;
662
+ /** Firebase Console URL to create the missing index (always present for "index" type) */
663
+ indexUrl?: string;
664
+ }
665
+ interface RelationalFieldMeta {
666
+ /** Field in this document whose value is used to build the link */
667
+ key: string;
668
+ /** Column header label, e.g. "Posts" or "Author" */
669
+ column: string;
670
+ /** Name of the target repository in the admin registry */
671
+ targetRepo: string;
672
+ /** Field name on the target repo used for the lookup */
673
+ targetKey: string;
674
+ /**
675
+ * - "one" → doc[key] = docId on the target → link to edit page
676
+ * - "many" → doc[key] = filter value on the target → link to filtered list
677
+ */
678
+ type: "one" | "many";
679
+ }
680
+
612
681
  /**
613
682
  * Default security-headers middleware for the bundled HTTP servers.
614
683
  *
@@ -829,6 +898,42 @@ interface CrudRepoConfig<TRepo extends ConfiguredRepository<any> = ConfiguredRep
829
898
  */
830
899
  rules?: CrudRules<TRepo>;
831
900
  }
901
+ /** Return type of a diff computation comparing before and after states. */
902
+ interface DeepDiffReturn<T> {
903
+ /** Complete state before modification */
904
+ before: T;
905
+ /** Projected state after applying changes */
906
+ after: T;
907
+ /** Subset of keys whose value actually changed */
908
+ changes: Partial<T>;
909
+ }
910
+ /**
911
+ * Result returned by an authorization or before-rule.
912
+ * - `boolean`: `true` allows the operation, `false` rejects with HTTP 403 "Forbidden".
913
+ * - `string`: rejects with HTTP 403 and the given error reason.
914
+ * - `{ allowed: boolean; reason?: string }`: `allowed === true` permits, `allowed === false` rejects with HTTP 403 and `reason`.
915
+ */
916
+ type RuleResult = boolean | string | {
917
+ allowed: boolean;
918
+ reason?: string;
919
+ } | void;
920
+ /**
921
+ * A business rule attached to a specific field of model `T`.
922
+ */
923
+ interface Rule<T> {
924
+ description: string;
925
+ rule: (args: {
926
+ diff: DeepDiffReturn<T>;
927
+ key: keyof T;
928
+ user?: AuthUser;
929
+ /** Alias for `user` for backwards compatibility with legacy rules */
930
+ authenticatedUser?: AuthUser;
931
+ }) => boolean | void | Promise<boolean | void>;
932
+ }
933
+ /**
934
+ * Map of rules per field for model `T`.
935
+ */
936
+ type RulesMap<T> = Partial<Record<keyof T, Rule<T>[]>>;
832
937
  /** Context passed to {@link CrudRules.list}. */
833
938
  interface CrudListRuleContext {
834
939
  user: AuthUser;
@@ -853,6 +958,8 @@ interface CrudUpdateRuleContext<T = Record<string, unknown>> {
853
958
  doc: T;
854
959
  body: Partial<T>;
855
960
  params: Record<string, string>;
961
+ /** Computed diff between existing document (before) and submitted changes (after) */
962
+ diff: DeepDiffReturn<T>;
856
963
  }
857
964
  /** Context passed to {@link CrudRules.delete}. */
858
965
  interface CrudDeleteRuleContext<T = Record<string, unknown>> {
@@ -871,11 +978,11 @@ interface CrudFilterRuleContext<T = Record<string, unknown>> {
871
978
  * @template TRepo - The configured repository (used to type `doc` and `body`).
872
979
  */
873
980
  interface CrudRules<TRepo extends ConfiguredRepository<any> = ConfiguredRepository<any>> {
874
- list?: (ctx: CrudListRuleContext) => boolean | Promise<boolean>;
875
- get?: (ctx: CrudGetRuleContext<RepoModelType<TRepo>>) => boolean | Promise<boolean>;
876
- create?: (ctx: CrudCreateRuleContext<RepoModelType<TRepo>>) => boolean | Promise<boolean>;
877
- update?: (ctx: CrudUpdateRuleContext<RepoModelType<TRepo>>) => boolean | Promise<boolean>;
878
- delete?: (ctx: CrudDeleteRuleContext<RepoModelType<TRepo>>) => boolean | Promise<boolean>;
981
+ list?: (ctx: CrudListRuleContext) => RuleResult | Promise<RuleResult>;
982
+ get?: (ctx: CrudGetRuleContext<RepoModelType<TRepo>>) => RuleResult | Promise<RuleResult>;
983
+ create?: (ctx: CrudCreateRuleContext<RepoModelType<TRepo>>) => RuleResult | Promise<RuleResult>;
984
+ update?: (ctx: CrudUpdateRuleContext<RepoModelType<TRepo>>) => RuleResult | Promise<RuleResult>;
985
+ delete?: (ctx: CrudDeleteRuleContext<RepoModelType<TRepo>>) => RuleResult | Promise<RuleResult>;
879
986
  /** Row-level filter applied to every doc returned by `list` / `query` / `get`. */
880
987
  filter?: (ctx: CrudFilterRuleContext<RepoModelType<TRepo>>) => boolean | Promise<boolean>;
881
988
  }
@@ -983,7 +1090,52 @@ interface CrudServerOptions<TRepos extends Record<string, ConfiguredRepository<a
983
1090
  * ```
984
1091
  */
985
1092
  httpsOptions?: HttpsOptions;
1093
+ /**
1094
+ * Callback invoked whenever a missing Firestore composite index error is detected.
1095
+ * Useful for logging or writing the missing index URL into a Firestore collection for alerting / auto-provisioning.
1096
+ *
1097
+ * @example
1098
+ * ```ts
1099
+ * createCrudServer({
1100
+ * indexesError: async ({ indexUrl, repoName, path }) => {
1101
+ * await db.collection("missing_indexes").add({ indexUrl, repoName, path, createdAt: new Date() });
1102
+ * },
1103
+ * repos: { ... },
1104
+ * })
1105
+ * ```
1106
+ */
1107
+ indexesError?: IndexErrorCallback;
1108
+ /**
1109
+ * Alias for {@link indexesError}.
1110
+ */
1111
+ onIndexError?: IndexErrorCallback;
986
1112
  }
1113
+ /**
1114
+ * Context provided to the `indexesError` callback when a Firestore query fails due to a missing composite index.
1115
+ */
1116
+ interface IndexErrorContext {
1117
+ /** The generated or extracted Firebase Console URL to create the required index */
1118
+ indexUrl: string;
1119
+ /** Name of the repository where the index error occurred */
1120
+ repoName: string;
1121
+ /** Firestore collection path */
1122
+ path: string;
1123
+ /** Whether the query was on a collection-group */
1124
+ isGroup: boolean;
1125
+ /** Active query filters when the error occurred */
1126
+ filters: FilterState[];
1127
+ /** Active sort / orderBy when the error occurred */
1128
+ sort?: SortState;
1129
+ /** Original raw error object thrown by Firestore */
1130
+ error: unknown;
1131
+ /** Hono Context (provides access to req, headers, auth user, etc.) */
1132
+ c?: any;
1133
+ }
1134
+ /**
1135
+ * Callback invoked when a missing Firestore index error occurs.
1136
+ * Can be asynchronous (e.g. to write the index link into a Firestore collection).
1137
+ */
1138
+ type IndexErrorCallback = (ctx: IndexErrorContext) => void | Promise<void>;
987
1139
  /**
988
1140
  * Standard API response wrapper.
989
1141
  */
@@ -1094,4 +1246,4 @@ interface QueryRequestBody {
1094
1246
  withTotal?: boolean;
1095
1247
  }
1096
1248
 
1097
- export { type ApiResponse as A, type ConfiguredRepository as C, DEFAULT_HTML_CSP as D, type ExtractDocumentRefSignature as E, type FieldRole as F, type GetOptions as G, type IncludeConfigTyped as I, type ListResponseData as L, type OpenAPISpecOptions as O, type PaginationOptions as P, type QueryRequestBody as Q, type RepoFieldPath as R, type SecurityHeadersOptions as S, type UserFieldPath as U, type WhereClause as W, type CrudServerOptions as a, type CrudRepoConfig as b, type CrudRepoEntry as c, type CrudRepoRegistry as d, type RepoRelationKeys as e, type RepositoryConfig as f, type FieldPath as g, type QueryOptions as h, type RelationConfig as i, type ExtractUpdateSignature as j, type GetResult as k, type RelationalKeys as l, createPaginationIterator as m, executePaginatedQuery as n, type PaginationResult as o, type SystemBackfillFailure as p, type SystemBackfillOptions as q, type SystemBackfillResult as r, securityHeaders as s, type GenerateGetMethods as t, type GenerateQueryMethods as u, type PaginationWithIncludeOptionsTyped as v, type PopulateOptionsTyped as w };
1249
+ export { type ApiResponse as A, createPaginationIterator as B, type ConfiguredRepository as C, type DeepDiffReturn as D, type ExtractDocumentRefSignature as E, type FieldRole as F, type GetOptions as G, executePaginatedQuery as H, type IndexErrorCallback as I, type PaginationResult as J, type SystemBackfillFailure as K, type ListResponseData as L, type SystemBackfillOptions as M, type SystemBackfillResult as N, type OpenAPISpecOptions as O, type PageOptions as P, type QueryRequestBody as Q, type RepoFieldPath as R, type SecurityHeadersOptions as S, type GenerateGetMethods as T, type UserFieldPath as U, type GenerateQueryMethods as V, type WhereClause as W, type IncludeConfigTyped as X, type PaginationWithIncludeOptionsTyped as Y, type PopulateOptionsTyped as Z, type CrudServerOptions as a, type CrudRepoConfig as b, type CrudRepoEntry as c, type CrudRepoRegistry as d, type CrudRules as e, type CrudUpdateRuleContext as f, type IndexErrorContext as g, type RepoRelationKeys as h, type Rule as i, type RuleResult as j, type RulesMap as k, type RepositoryConfig as l, type RelationalFieldMeta as m, type FieldPath as n, type ColumnMeta as o, type FilterState as p, type SortState as q, type QueryError as r, DEFAULT_HTML_CSP as s, securityHeaders as t, type QueryOptions as u, type PaginationOptions as v, type RelationConfig as w, type ExtractUpdateSignature as x, type GetResult as y, type RelationalKeys as z };
@@ -1,6 +1,6 @@
1
1
  import { z, ZodError } from 'zod';
2
2
  import { Env, Context, MiddlewareHandler } from 'hono';
3
- import { F as FirebaseAdminAuthLike, D as DecodedIdTokenLike } from './firebase-auth-DZ8lb2Ec.cjs';
3
+ import { F as FirebaseAdminAuthLike, D as DecodedIdTokenLike } from './firebase-auth-Ds5P0kXT.cjs';
4
4
 
5
5
  /**
6
6
  * Global DI services container for the Hono server.