@dnax/core 0.52.3 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,8 @@ async function connectToMongo(t: Tenant) {
13
13
  await client
14
14
  .connect()
15
15
  .then((e) => {
16
- //consola.log(`[${t.id}] : Connected to db ✅`.green);
16
+ console.log("\n");
17
+ consola.success(`DB connected : [${t.id}] ✅`.green);
17
18
  t.database.isConnected = true;
18
19
  t.database.client = client;
19
20
  t.database.db = client.db();
package/lib/collection.ts CHANGED
@@ -73,19 +73,54 @@ async function syncCollectionDatabase() {
73
73
  if (collections?.length) {
74
74
  // searchEngine Section
75
75
  if (t?.searchEngine?.meilisearch?.enabled) {
76
+ let allIndex_ = await t?.searchEngine?.meilisearch?.client
77
+ ?.getIndexes()
78
+ .then((e) => e.results)
79
+ .catch((err) => []);
80
+
76
81
  for await (let c of collections) {
77
82
  if (c?.searchEngine?.meilisearch?.index) {
78
83
  if (c?.searchEngine?.meilisearch?.dispatchAction) {
79
84
  c.searchEngine.meilisearch.dispatchAction = "auto";
80
85
  }
81
- await t.searchEngine.meilisearch.client
82
- ?.createIndex(c?.searchEngine?.meilisearch?.index, {
83
- primaryKey:
84
- c?.searchEngine?.meilisearch?.primaryKey || "_id",
85
- })
86
- .catch((err) => {
87
- //consola.error(err?.message);
88
- });
86
+
87
+ let indexExist = allIndex_?.find(
88
+ (index) => index?.uid == c?.searchEngine?.meilisearch?.index
89
+ );
90
+ if (!indexExist) {
91
+ await t.searchEngine.meilisearch.client
92
+ ?.createIndex(c?.searchEngine?.meilisearch?.index, {
93
+ primaryKey:
94
+ c?.searchEngine?.meilisearch?.primaryKey || "_id",
95
+ })
96
+ .catch((err) => {
97
+ //consola.error(err?.message);
98
+ });
99
+ }
100
+
101
+ let attributes = await t?.searchEngine?.meilisearch?.client
102
+ ?.index(c?.searchEngine?.meilisearch?.index)
103
+ .getFilterableAttributes()
104
+ .catch();
105
+
106
+ if (
107
+ c?.searchEngine?.meilisearch?.filterableAttributes?.length
108
+ ) {
109
+ let s = false;
110
+ if (
111
+ !deepEqual(
112
+ attributes,
113
+ c?.searchEngine?.meilisearch?.filterableAttributes
114
+ )
115
+ ) {
116
+ await t?.searchEngine?.meilisearch?.client
117
+ ?.index(c?.searchEngine?.meilisearch?.index)
118
+ .updateFilterableAttributes(
119
+ c?.searchEngine?.meilisearch?.filterableAttributes
120
+ )
121
+ .catch();
122
+ }
123
+ }
89
124
  }
90
125
  }
91
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.52.3",
3
+ "version": "0.53.0",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -314,6 +314,7 @@ export type Collection = {
314
314
  * default value :auto
315
315
  */
316
316
  dispatchAction: "auto" | "manual";
317
+ filterableAttributes?: Array<string>;
317
318
  };
318
319
  };
319
320
  /**