@lpdjs/firestore-repo-service 3.0.1 → 3.0.4
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/{create-servers-aWdDTcSu.d.ts → create-servers-2Hw0pkyz.d.ts} +2 -2
- package/dist/{create-servers-Cbvzs_ou.d.cts → create-servers-ASLcxpiS.d.cts} +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/{queue-CMiKvIW1.d.cts → queue-B9jCT62h.d.cts} +1 -1
- package/dist/{queue-BQxyuEXb.d.ts → queue-BWi6TBmf.d.ts} +1 -1
- package/dist/servers/index.d.cts +3 -3
- package/dist/servers/index.d.ts +3 -3
- package/dist/sync/bigquery.d.cts +1 -1
- package/dist/sync/bigquery.d.ts +1 -1
- package/dist/sync/index.cjs +1 -1
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +4 -4
- package/dist/sync/index.d.ts +4 -4
- package/dist/sync/index.js +1 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/meilisearch.cjs +2 -2
- package/dist/sync/meilisearch.cjs.map +1 -1
- package/dist/sync/meilisearch.d.cts +1 -1
- package/dist/sync/meilisearch.d.ts +1 -1
- package/dist/sync/meilisearch.js +2 -2
- package/dist/sync/meilisearch.js.map +1 -1
- package/dist/{types-BbFZ57eK.d.ts → types-BRPhmKFW.d.ts} +6 -4
- package/dist/{types-zFrp8RnM.d.cts → types-LZ8dyfBz.d.cts} +6 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var c=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e
|
|
1
|
+
'use strict';var c=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):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:t}=c("meilisearch");return new t({host:n.host,apiKey:n.apiKey})}catch(t){throw new Error(`Failed to load the "meilisearch" package. Please install it with:
|
|
2
2
|
bun add meilisearch # or npm install meilisearch
|
|
3
|
-
Original error: ${
|
|
3
|
+
Original error: ${t?.message??String(t)}`)}}var o=class{constructor(t){this.name="meilisearch";this._client=null;this.options=t,t.client&&(this._client=t.client);}get client(){return this._client||(this._client=l(this.options)),this._client}async targetExists(t){try{return await this.client.getIndex(t),!0}catch(e){if(e?.code==="index_not_found"||e?.cause?.code==="index_not_found"||e?.statusCode===404||e?.status===404||e?.response?.status===404||e?.cause?.status===404||e?.cause?.statusCode===404||e?.cause?.response?.status===404)return false;throw e}}async upsert(t,e,i){if(e.length===0)return;await this.client.index(t).addDocuments(e,{primaryKey:i});}async delete(t,e,i){if(i.length===0)return;await this.client.index(t).deleteDocuments(i);}async ensureTarget(t){let{targetName:e,primaryKey:i}=t;await this.targetExists(e)||await this.client.createIndex(e,{primaryKey:i});let r=this.options.indexesSettings?.[e];r&&await this.client.index(e).updateSettings(r);}async healthCheck(t){let{targetName:e}=t;try{if(!await this.targetExists(e))return {healthy:!1,targetName:e,targetExists:!1,error:`Meilisearch index "${e}" does not exist`};let s=this.client.index(e),r=await s.getStats(),a=typeof s.getRawInfo=="function"?await s.getRawInfo():{};return {healthy:!0,targetName:e,targetExists:!0,error:null,details:{numberOfDocuments:r?.numberOfDocuments??0,isIndexing:r?.isIndexing??!1,fieldDistribution:r?.fieldDistribution??{},primaryKey:a?.primaryKey??t.primaryKey}}}catch(i){return {healthy:false,targetName:e,targetExists:false,error:i?.message??String(i)}}}async checkConnection(){try{let t=!0;if(typeof this.client.isHealthy=="function"){let i=await this.client.isHealthy();t=i?.status==="available"||i===!0;}else if(typeof this.client.health=="function"){let i=await this.client.health();t=i?.status==="available"||i===!0;}let e;return typeof this.client.getVersion=="function"&&(e=(await this.client.getVersion())?.pkgVersion),{healthy:t,version:e}}catch(t){return {healthy:false,error:t?.message??String(t)}}}};exports.MeilisearchAdapter=o;//# sourceMappingURL=meilisearch.cjs.map
|
|
4
4
|
//# sourceMappingURL=meilisearch.cjs.map
|
|
@@ -1 +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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AAK,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.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"]}
|
|
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","e"],"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,CAAAA,EAAK,SAAW,MAAA,CAAOA,CAAG,CAAC,CAAA,CAClD,CACF,CACF,CAKO,IAAMC,EAAN,KAAgD,CAKrD,YAAYH,CAAAA,CAAoC,CAJhD,KAAS,IAAA,CAAO,aAAA,CAChB,KAAQ,OAAA,CAAkC,IAAA,CAIxC,KAAK,OAAA,CAAUA,CA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AOA,CAAG,CACnC,CACF,CACF,CAGA,MAAM,eAAA,EAIH,CACD,GAAI,CACF,IAAIW,CAAAA,CAAY,CAAA,CAAA,CAChB,GAAI,OAAO,IAAA,CAAK,OAAO,SAAA,EAAc,UAAA,CAAY,CAC/C,IAAMC,CAAAA,CAAM,MAAM,IAAA,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,GAC9BD,CAAAA,CAAYC,CAAAA,EAAK,SAAW,WAAA,EAAeA,CAAAA,GAAQ,GACrD,CACA,IAAIC,EACJ,OAAI,OAAO,KAAK,MAAA,CAAO,UAAA,EAAe,aAEpCA,CAAAA,CAAAA,CADU,MAAM,KAAK,MAAA,CAAO,UAAA,KACf,UAAA,CAAA,CAER,CAAE,QAASF,CAAAA,CAAW,OAAA,CAAAE,CAAQ,CACvC,CAAA,MAASC,EAAQ,CACf,OAAO,CAAE,OAAA,CAAS,KAAA,CAAO,MAAOA,CAAAA,EAAG,OAAA,EAAW,OAAOA,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?.cause?.code === \"index_not_found\" ||\n err?.statusCode === 404 ||\n err?.status === 404 ||\n err?.response?.status === 404 ||\n err?.cause?.status === 404 ||\n err?.cause?.statusCode === 404 ||\n err?.cause?.response?.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
1
|
import { z } from 'zod';
|
|
2
|
-
import { a as SyncAdapter, R as RepoSyncConfig, d as SyncHealthResult } from '../types-
|
|
2
|
+
import { a as SyncAdapter, R as RepoSyncConfig, d as SyncHealthResult } from '../types-LZ8dyfBz.cjs';
|
|
3
3
|
import '../firebase-auth-Ds5P0kXT.cjs';
|
|
4
4
|
import 'firebase-functions/v2/firestore';
|
|
5
5
|
import 'firebase-functions/v2/https';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { a as SyncAdapter, R as RepoSyncConfig, d as SyncHealthResult } from '../types-
|
|
2
|
+
import { a as SyncAdapter, R as RepoSyncConfig, d as SyncHealthResult } from '../types-BRPhmKFW.js';
|
|
3
3
|
import '../firebase-auth-Ds5P0kXT.js';
|
|
4
4
|
import 'firebase-functions/v2/firestore';
|
|
5
5
|
import 'firebase-functions/v2/https';
|
package/dist/sync/meilisearch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var c=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e
|
|
1
|
+
var c=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):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:t}=c("meilisearch");return new t({host:n.host,apiKey:n.apiKey})}catch(t){throw new Error(`Failed to load the "meilisearch" package. Please install it with:
|
|
2
2
|
bun add meilisearch # or npm install meilisearch
|
|
3
|
-
Original error: ${
|
|
3
|
+
Original error: ${t?.message??String(t)}`)}}var o=class{constructor(t){this.name="meilisearch";this._client=null;this.options=t,t.client&&(this._client=t.client);}get client(){return this._client||(this._client=l(this.options)),this._client}async targetExists(t){try{return await this.client.getIndex(t),!0}catch(e){if(e?.code==="index_not_found"||e?.cause?.code==="index_not_found"||e?.statusCode===404||e?.status===404||e?.response?.status===404||e?.cause?.status===404||e?.cause?.statusCode===404||e?.cause?.response?.status===404)return false;throw e}}async upsert(t,e,i){if(e.length===0)return;await this.client.index(t).addDocuments(e,{primaryKey:i});}async delete(t,e,i){if(i.length===0)return;await this.client.index(t).deleteDocuments(i);}async ensureTarget(t){let{targetName:e,primaryKey:i}=t;await this.targetExists(e)||await this.client.createIndex(e,{primaryKey:i});let r=this.options.indexesSettings?.[e];r&&await this.client.index(e).updateSettings(r);}async healthCheck(t){let{targetName:e}=t;try{if(!await this.targetExists(e))return {healthy:!1,targetName:e,targetExists:!1,error:`Meilisearch index "${e}" does not exist`};let s=this.client.index(e),r=await s.getStats(),a=typeof s.getRawInfo=="function"?await s.getRawInfo():{};return {healthy:!0,targetName:e,targetExists:!0,error:null,details:{numberOfDocuments:r?.numberOfDocuments??0,isIndexing:r?.isIndexing??!1,fieldDistribution:r?.fieldDistribution??{},primaryKey:a?.primaryKey??t.primaryKey}}}catch(i){return {healthy:false,targetName:e,targetExists:false,error:i?.message??String(i)}}}async checkConnection(){try{let t=!0;if(typeof this.client.isHealthy=="function"){let i=await this.client.isHealthy();t=i?.status==="available"||i===!0;}else if(typeof this.client.health=="function"){let i=await this.client.health();t=i?.status==="available"||i===!0;}let e;return typeof this.client.getVersion=="function"&&(e=(await this.client.getVersion())?.pkgVersion),{healthy:t,version:e}}catch(t){return {healthy:false,error:t?.message??String(t)}}}};export{o as MeilisearchAdapter};//# sourceMappingURL=meilisearch.js.map
|
|
4
4
|
//# sourceMappingURL=meilisearch.js.map
|
|
@@ -1 +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,OAAS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AAO,CACL,OAAA,CAAS,MACT,UAAA,CAAAE,CAAAA,CACA,aAAc,KAAA,CACd,KAAA,CAAOF,GAAK,OAAA,EAAW,MAAA,CAAOA,CAAG,CACnC,CACF,CACF,CAGA,MAAM,eAAA,EAIH,CACD,GAAI,CACF,IAAIW,EAAY,CAAA,CAAA,CAChB,GAAI,OAAO,IAAA,CAAK,MAAA,CAAO,WAAc,UAAA,CAAY,CAC/C,IAAMC,CAAAA,CAAM,MAAM,IAAA,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
|
+
{"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","e"],"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,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CAAO,MAAOA,CAAAA,EAAG,OAAA,EAAW,OAAOA,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?.cause?.code === \"index_not_found\" ||\n err?.statusCode === 404 ||\n err?.status === 404 ||\n err?.response?.status === 404 ||\n err?.cause?.status === 404 ||\n err?.cause?.statusCode === 404 ||\n err?.cause?.response?.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"]}
|
|
@@ -234,22 +234,24 @@ type ExtractRepoFields<R> = R extends {
|
|
|
234
234
|
} ? string & keyof S : R extends {
|
|
235
235
|
type: infer T;
|
|
236
236
|
} ? string & keyof T : string;
|
|
237
|
-
/** Keys of repos where `_isGroup` is `true`. */
|
|
237
|
+
/** Keys of repos where `_isGroup` or `isGroup` is `true`. */
|
|
238
238
|
type GroupRepoKeys<M> = {
|
|
239
239
|
[K in string & keyof M]: M[K] extends {
|
|
240
240
|
_isGroup: true;
|
|
241
|
+
} ? K : M[K] extends {
|
|
242
|
+
isGroup: true;
|
|
241
243
|
} ? K : never;
|
|
242
244
|
}[string & keyof M];
|
|
243
245
|
/** Keys of repos where `_isGroup` is NOT `true`. */
|
|
244
246
|
type NonGroupRepoKeys<M> = Exclude<string & keyof M, GroupRepoKeys<M>>;
|
|
245
247
|
/**
|
|
246
248
|
* Typed per-repo sync config map.
|
|
247
|
-
* - Collection-group repos (`isGroup: true`): entry is
|
|
248
|
-
* `triggerPath` is mandatory.
|
|
249
|
+
* - Collection-group repos (`isGroup: true`): entry is optional, but if provided,
|
|
250
|
+
* `triggerPath` is mandatory (since collection groups span multiple paths).
|
|
249
251
|
* - Regular repos: entry is optional, all fields optional.
|
|
250
252
|
*/
|
|
251
253
|
type TypedRepoSyncConfigs<M> = {
|
|
252
|
-
[K in GroupRepoKeys<M>]
|
|
254
|
+
[K in GroupRepoKeys<M>]?: RepoSyncConfig<ExtractRepoFields<M[K]>> & {
|
|
253
255
|
triggerPath: string;
|
|
254
256
|
};
|
|
255
257
|
} & {
|
|
@@ -234,22 +234,24 @@ type ExtractRepoFields<R> = R extends {
|
|
|
234
234
|
} ? string & keyof S : R extends {
|
|
235
235
|
type: infer T;
|
|
236
236
|
} ? string & keyof T : string;
|
|
237
|
-
/** Keys of repos where `_isGroup` is `true`. */
|
|
237
|
+
/** Keys of repos where `_isGroup` or `isGroup` is `true`. */
|
|
238
238
|
type GroupRepoKeys<M> = {
|
|
239
239
|
[K in string & keyof M]: M[K] extends {
|
|
240
240
|
_isGroup: true;
|
|
241
|
+
} ? K : M[K] extends {
|
|
242
|
+
isGroup: true;
|
|
241
243
|
} ? K : never;
|
|
242
244
|
}[string & keyof M];
|
|
243
245
|
/** Keys of repos where `_isGroup` is NOT `true`. */
|
|
244
246
|
type NonGroupRepoKeys<M> = Exclude<string & keyof M, GroupRepoKeys<M>>;
|
|
245
247
|
/**
|
|
246
248
|
* Typed per-repo sync config map.
|
|
247
|
-
* - Collection-group repos (`isGroup: true`): entry is
|
|
248
|
-
* `triggerPath` is mandatory.
|
|
249
|
+
* - Collection-group repos (`isGroup: true`): entry is optional, but if provided,
|
|
250
|
+
* `triggerPath` is mandatory (since collection groups span multiple paths).
|
|
249
251
|
* - Regular repos: entry is optional, all fields optional.
|
|
250
252
|
*/
|
|
251
253
|
type TypedRepoSyncConfigs<M> = {
|
|
252
|
-
[K in GroupRepoKeys<M>]
|
|
254
|
+
[K in GroupRepoKeys<M>]?: RepoSyncConfig<ExtractRepoFields<M[K]>> & {
|
|
253
255
|
triggerPath: string;
|
|
254
256
|
};
|
|
255
257
|
} & {
|