@extravirgin/payload-plugin-meilisearch 0.0.1-1 → 0.0.1-10

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 (51) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/indexCollections.d.ts +3 -0
  4. package/dist/indexCollections.js +393 -0
  5. package/dist/indexCollections.js.map +1 -0
  6. package/dist/mocks/mockFile.d.ts +1 -0
  7. package/dist/mocks/mockFile.js +3 -0
  8. package/dist/mocks/mockFile.js.map +1 -0
  9. package/dist/onInitExtension.d.ts +3 -0
  10. package/dist/onInitExtension.js +17 -0
  11. package/dist/onInitExtension.js.map +1 -0
  12. package/dist/plugin.d.ts +3 -0
  13. package/dist/plugin.js +103 -0
  14. package/dist/plugin.js.map +1 -0
  15. package/dist/types.d.ts +18 -0
  16. package/dist/types.js +3 -0
  17. package/dist/types.js.map +1 -0
  18. package/dist/webpack.d.ts +3 -0
  19. package/dist/webpack.js +32 -0
  20. package/dist/webpack.js.map +1 -0
  21. package/package.json +4 -1
  22. package/.editorconfig +0 -10
  23. package/.eslintrc.js +0 -17
  24. package/.github/workflows/test.yml +0 -19
  25. package/.prettierrc.js +0 -8
  26. package/dev/.env.example +0 -2
  27. package/dev/Dockerfile +0 -27
  28. package/dev/docker-compose.yml +0 -31
  29. package/dev/jest.config.js +0 -12
  30. package/dev/nodemon.json +0 -6
  31. package/dev/package.json +0 -35
  32. package/dev/plugin.spec.ts +0 -30
  33. package/dev/src/collections/Examples.ts +0 -17
  34. package/dev/src/collections/Users.ts +0 -15
  35. package/dev/src/mocks/fileStub.js +0 -1
  36. package/dev/src/payload.config.ts +0 -44
  37. package/dev/src/server.ts +0 -29
  38. package/dev/tsconfig.json +0 -34
  39. package/eslint-config/index.js +0 -15
  40. package/eslint-config/rules/import.js +0 -38
  41. package/eslint-config/rules/prettier.js +0 -7
  42. package/eslint-config/rules/style.js +0 -21
  43. package/eslint-config/rules/typescript.js +0 -628
  44. package/src/index.ts +0 -3
  45. package/src/indexCollections.ts +0 -155
  46. package/src/mocks/mockFile.js +0 -1
  47. package/src/onInitExtension.ts +0 -16
  48. package/src/plugin.ts +0 -67
  49. package/src/types.ts +0 -20
  50. package/src/webpack.ts +0 -28
  51. package/tsconfig.json +0 -23
@@ -0,0 +1,2 @@
1
+ export { meilisearchPlugin } from './plugin';
2
+ export type { PluginTypes } from './types';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAAnC,2GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,3 @@
1
+ import { CollectionConfig } from "payload/dist/exports/types";
2
+ import { PluginTypes } from "./types";
3
+ export declare const indexCollections: (collections: CollectionConfig[], config: PluginTypes) => CollectionConfig[];
@@ -0,0 +1,393 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
57
+ };
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.indexCollections = void 0;
60
+ var meilisearch_1 = require("meilisearch");
61
+ var html_to_text_1 = require("html-to-text");
62
+ var richtext_lexical_1 = require("@payloadcms/richtext-lexical");
63
+ var indexCollections = function (collections, config) {
64
+ var getIndexName = function (collectionSlug) { var _a; return "".concat((_a = config === null || config === void 0 ? void 0 : config.indexPrefix) !== null && _a !== void 0 ? _a : '').concat(collectionSlug); };
65
+ return collections.map(function (collection) {
66
+ var _a, _b;
67
+ var collectionConfig = config.collections && (config === null || config === void 0 ? void 0 : config.collections.find(function (c) { return c.slug === collection.slug; }));
68
+ if (!collectionConfig) {
69
+ return collection;
70
+ }
71
+ return __assign(__assign({}, collection), { hooks: __assign(__assign({}, (collection.hooks || {})), { afterChange: __spreadArray(__spreadArray([], (((_a = collection.hooks) === null || _a === void 0 ? void 0 : _a.afterChange) || []), true), [
72
+ function (_a) {
73
+ var doc = _a.doc, previousDoc = _a.previousDoc, req = _a.req;
74
+ return __awaiter(void 0, void 0, void 0, function () {
75
+ var baseDoc, payload, client, index, documents, _b, locales, defaultLocale, fallback, _i, locales_1, locale, localizedDoc, _c, documentId, shouldIndex, transformedDoc, _d, documentId, shouldIndex, transformedDoc, _e, error_1;
76
+ var _f, _g, _h, _j, _k, _l;
77
+ return __generator(this, function (_m) {
78
+ switch (_m.label) {
79
+ case 0:
80
+ _m.trys.push([0, 19, , 20]);
81
+ baseDoc = doc;
82
+ payload = req.payload;
83
+ client = getMeilisearchClient(config);
84
+ return [4 /*yield*/, upsertIndex(client, getIndexName(collection.slug))];
85
+ case 1:
86
+ _m.sent();
87
+ index = client.index(getIndexName(collection.slug));
88
+ documents = [];
89
+ if (!(((_f = payload.config) === null || _f === void 0 ? void 0 : _f.localization) && ((_g = payload.config.localization.locales) === null || _g === void 0 ? void 0 : _g.length) > 1)) return [3 /*break*/, 13];
90
+ _b = payload.config.localization, locales = _b.locales, defaultLocale = _b.defaultLocale, fallback = _b.fallback;
91
+ _i = 0, locales_1 = locales;
92
+ _m.label = 2;
93
+ case 2:
94
+ if (!(_i < locales_1.length)) return [3 /*break*/, 10];
95
+ locale = locales_1[_i];
96
+ if (!(req.locale === locale.code)) return [3 /*break*/, 3];
97
+ _c = doc;
98
+ return [3 /*break*/, 5];
99
+ case 3: return [4 /*yield*/, req.payload.findByID({
100
+ collection: collection.slug,
101
+ id: doc.id,
102
+ locale: locale,
103
+ fallbackLocale: locale.fallbackLocale || defaultLocale,
104
+ })];
105
+ case 4:
106
+ _c = _m.sent();
107
+ _m.label = 5;
108
+ case 5:
109
+ localizedDoc = _c;
110
+ documentId = doc.id + "_".concat(locale.code);
111
+ shouldIndex = (_j = (_h = collectionConfig.shouldIndex) === null || _h === void 0 ? void 0 : _h.call(collectionConfig, localizedDoc, previousDoc, locale.code)) !== null && _j !== void 0 ? _j : 'index';
112
+ if (!(shouldIndex === 'index')) return [3 /*break*/, 7];
113
+ _d = [{}];
114
+ return [4 /*yield*/, transformDocumentForMeilisearch(localizedDoc, collection.fields, req)];
115
+ case 6:
116
+ transformedDoc = __assign.apply(void 0, [__assign.apply(void 0, _d.concat([_m.sent()])), { id: documentId, documentId: doc.id, locale: locale.code }]);
117
+ documents.push(transformedDoc);
118
+ return [3 /*break*/, 9];
119
+ case 7:
120
+ if (!(shouldIndex === 'delete')) return [3 /*break*/, 9];
121
+ return [4 /*yield*/, index.deleteDocument(documentId)];
122
+ case 8:
123
+ _m.sent();
124
+ _m.label = 9;
125
+ case 9:
126
+ _i++;
127
+ return [3 /*break*/, 2];
128
+ case 10:
129
+ if (!(documents.length > 0)) return [3 /*break*/, 12];
130
+ return [4 /*yield*/, index.addDocuments(documents)];
131
+ case 11:
132
+ _m.sent();
133
+ _m.label = 12;
134
+ case 12: return [3 /*break*/, 18];
135
+ case 13:
136
+ documentId = doc.id;
137
+ shouldIndex = (_l = (_k = collectionConfig.shouldIndex) === null || _k === void 0 ? void 0 : _k.call(collectionConfig, doc, previousDoc)) !== null && _l !== void 0 ? _l : 'index';
138
+ if (!(shouldIndex === 'index')) return [3 /*break*/, 16];
139
+ _e = [{}];
140
+ return [4 /*yield*/, transformDocumentForMeilisearch(doc, collection.fields, req)];
141
+ case 14:
142
+ transformedDoc = __assign.apply(void 0, [__assign.apply(void 0, _e.concat([_m.sent()])), { id: documentId, documentId: doc.id }]);
143
+ return [4 /*yield*/, index.addDocuments([transformedDoc])];
144
+ case 15:
145
+ _m.sent();
146
+ return [3 /*break*/, 18];
147
+ case 16:
148
+ if (!(shouldIndex === 'delete')) return [3 /*break*/, 18];
149
+ return [4 /*yield*/, index.deleteDocument(documentId)];
150
+ case 17:
151
+ _m.sent();
152
+ _m.label = 18;
153
+ case 18: return [3 /*break*/, 20];
154
+ case 19:
155
+ error_1 = _m.sent();
156
+ console.error('Meilisearch indexing error:', error_1);
157
+ return [3 /*break*/, 20];
158
+ case 20: return [2 /*return*/];
159
+ }
160
+ });
161
+ });
162
+ },
163
+ ], false), afterDelete: __spreadArray(__spreadArray([], (((_b = collection.hooks) === null || _b === void 0 ? void 0 : _b.afterDelete) || []), true), [
164
+ function (_a) {
165
+ var doc = _a.doc, req = _a.req;
166
+ return __awaiter(void 0, void 0, void 0, function () {
167
+ var client, index, payload, locales, _i, locales_2, locale, documentId, error_2;
168
+ var _b, _c;
169
+ return __generator(this, function (_d) {
170
+ switch (_d.label) {
171
+ case 0:
172
+ _d.trys.push([0, 9, , 10]);
173
+ console.log('afterDelete', doc);
174
+ client = getMeilisearchClient(config);
175
+ return [4 /*yield*/, upsertIndex(client, getIndexName(collection.slug))];
176
+ case 1:
177
+ _d.sent();
178
+ index = client.index(getIndexName(collection.slug));
179
+ payload = req;
180
+ if (!(((_b = payload.config) === null || _b === void 0 ? void 0 : _b.localization) && ((_c = payload.config.localization.locales) === null || _c === void 0 ? void 0 : _c.length) > 1)) return [3 /*break*/, 6];
181
+ locales = payload.config.localization.locales;
182
+ _i = 0, locales_2 = locales;
183
+ _d.label = 2;
184
+ case 2:
185
+ if (!(_i < locales_2.length)) return [3 /*break*/, 5];
186
+ locale = locales_2[_i];
187
+ documentId = doc.id + "_".concat(locale.code);
188
+ console.log('deleting document', { documentId: documentId });
189
+ return [4 /*yield*/, index.deleteDocument(documentId)];
190
+ case 3:
191
+ _d.sent();
192
+ _d.label = 4;
193
+ case 4:
194
+ _i++;
195
+ return [3 /*break*/, 2];
196
+ case 5: return [3 /*break*/, 8];
197
+ case 6:
198
+ console.log('deleting document-2', { documentId: doc.id });
199
+ return [4 /*yield*/, index.deleteDocument(doc.id)];
200
+ case 7:
201
+ _d.sent();
202
+ _d.label = 8;
203
+ case 8: return [3 /*break*/, 10];
204
+ case 9:
205
+ error_2 = _d.sent();
206
+ console.error('Meilisearch indexing error:', error_2);
207
+ return [3 /*break*/, 10];
208
+ case 10: return [2 /*return*/];
209
+ }
210
+ });
211
+ });
212
+ },
213
+ ], false) }) });
214
+ });
215
+ };
216
+ exports.indexCollections = indexCollections;
217
+ var meilisearch;
218
+ function getMeilisearchClient(config) {
219
+ if (!meilisearch) {
220
+ meilisearch = new meilisearch_1.MeiliSearch({
221
+ host: config.host,
222
+ apiKey: config.apiKey,
223
+ });
224
+ }
225
+ return meilisearch;
226
+ }
227
+ function upsertIndex(client, indexUID) {
228
+ var _a;
229
+ return __awaiter(this, void 0, void 0, function () {
230
+ var error_3;
231
+ return __generator(this, function (_b) {
232
+ switch (_b.label) {
233
+ case 0:
234
+ _b.trys.push([0, 2, , 6]);
235
+ // Attempt to retrieve the index
236
+ return [4 /*yield*/, client.getIndex(indexUID)];
237
+ case 1:
238
+ // Attempt to retrieve the index
239
+ _b.sent();
240
+ return [3 /*break*/, 6];
241
+ case 2:
242
+ error_3 = _b.sent();
243
+ if (!(((_a = error_3 === null || error_3 === void 0 ? void 0 : error_3.cause) === null || _a === void 0 ? void 0 : _a.code) === 'index_not_found')) return [3 /*break*/, 4];
244
+ // Index doesn't exist; create it
245
+ return [4 /*yield*/, client.createIndex(indexUID, {
246
+ primaryKey: 'id',
247
+ })];
248
+ case 3:
249
+ // Index doesn't exist; create it
250
+ _b.sent();
251
+ console.log("Index '".concat(indexUID, "' has been created."));
252
+ return [3 /*break*/, 5];
253
+ case 4:
254
+ // Rethrow any other errors
255
+ throw error_3;
256
+ case 5: return [3 /*break*/, 6];
257
+ case 6: return [2 /*return*/];
258
+ }
259
+ });
260
+ });
261
+ }
262
+ var options = {
263
+ wordwrap: 130,
264
+ // ...
265
+ };
266
+ var compiledConvert = (0, html_to_text_1.compile)(options);
267
+ // Helper function to extract text from HTML in nodejs
268
+ function extractTextFromHTML(html) {
269
+ return compiledConvert(html);
270
+ }
271
+ // Helper function to transform a document for Meilisearch indexing
272
+ function transformDocumentForMeilisearch(doc, fields, req) {
273
+ return __awaiter(this, void 0, void 0, function () {
274
+ var transformedDoc;
275
+ var _this = this;
276
+ return __generator(this, function (_a) {
277
+ switch (_a.label) {
278
+ case 0:
279
+ transformedDoc = {};
280
+ return [4 /*yield*/, Promise.all(fields.map(function (field) { return __awaiter(_this, void 0, void 0, function () {
281
+ var lexicalAdapter, sanitizedServerEditorConfig, html, _a, _b, _c, _d, _e, _f;
282
+ var _this = this;
283
+ var _g;
284
+ return __generator(this, function (_h) {
285
+ switch (_h.label) {
286
+ case 0:
287
+ if (!(field.type === 'richText')) return [3 /*break*/, 2];
288
+ lexicalAdapter = field.editor;
289
+ sanitizedServerEditorConfig = lexicalAdapter.editorConfig;
290
+ return [4 /*yield*/, (0, richtext_lexical_1.convertLexicalToHTML)({
291
+ converters: (0, richtext_lexical_1.consolidateHTMLConverters)({ editorConfig: sanitizedServerEditorConfig }),
292
+ data: doc[field.name],
293
+ })];
294
+ case 1:
295
+ html = _h.sent();
296
+ transformedDoc[field.name] = extractTextFromHTML(html);
297
+ return [3 /*break*/, 11];
298
+ case 2:
299
+ if (!(field.type === 'array' && field.fields)) return [3 /*break*/, 4];
300
+ // For array fields, transform each item
301
+ _a = transformedDoc;
302
+ _b = field.name;
303
+ return [4 /*yield*/, Promise.all((doc[field.name] || []).map(function (item) {
304
+ return transformDocumentForMeilisearch(item, field.fields, req);
305
+ }))];
306
+ case 3:
307
+ // For array fields, transform each item
308
+ _a[_b] = _h.sent();
309
+ return [3 /*break*/, 11];
310
+ case 4:
311
+ if (!(field.type === 'tabs')) return [3 /*break*/, 6];
312
+ return [4 /*yield*/, Promise.all(field.tabs.map(function (tab, index) { return __awaiter(_this, void 0, void 0, function () {
313
+ return __generator(this, function (_a) {
314
+ switch (_a.label) {
315
+ case 0: return [4 /*yield*/, transformDocumentForMeilisearch(doc, tab.fields, req)];
316
+ case 1: return [2 /*return*/, _a.sent()];
317
+ }
318
+ });
319
+ }); }))];
320
+ case 5:
321
+ // For tab fields, transform each tab
322
+ (_h.sent()).forEach(function (t) { return Object.assign(transformedDoc, t); });
323
+ return [3 /*break*/, 11];
324
+ case 6:
325
+ if (!(field.type === 'blocks')) return [3 /*break*/, 8];
326
+ // For block fields, transform each block
327
+ _c = transformedDoc;
328
+ _d = field.name;
329
+ return [4 /*yield*/, Promise.all((doc[field.name] || []).map(function (block) { return __awaiter(_this, void 0, void 0, function () {
330
+ var fields;
331
+ var _a;
332
+ var _b;
333
+ return __generator(this, function (_c) {
334
+ switch (_c.label) {
335
+ case 0:
336
+ fields = (_b = field.blocks.find(function (b) { return b.slug === block.blockType; })) === null || _b === void 0 ? void 0 : _b.fields;
337
+ if (!fields) {
338
+ return [2 /*return*/, {
339
+ type: block.blockType,
340
+ data: "",
341
+ }];
342
+ }
343
+ _a = {
344
+ type: block.blockType
345
+ };
346
+ return [4 /*yield*/, transformDocumentForMeilisearch(block, fields, req)];
347
+ case 1: return [2 /*return*/, (_a.data = _c.sent(),
348
+ _a)];
349
+ }
350
+ });
351
+ }); }))];
352
+ case 7:
353
+ // For block fields, transform each block
354
+ _c[_d] = _h.sent();
355
+ return [3 /*break*/, 11];
356
+ case 8:
357
+ if (!(field.type === 'group' && field.fields)) return [3 /*break*/, 10];
358
+ // For group fields, transform the nested fields
359
+ _e = transformedDoc;
360
+ _f = field.name;
361
+ return [4 /*yield*/, transformDocumentForMeilisearch(doc[field.name], field.fields, req)];
362
+ case 9:
363
+ // For group fields, transform the nested fields
364
+ _e[_f] = _h.sent();
365
+ return [3 /*break*/, 11];
366
+ case 10:
367
+ if (field.type === 'relationship' || field.type === 'upload') {
368
+ // For relationship and upload fields, just include the ID
369
+ transformedDoc[field.name] = ((_g = doc[field.name]) === null || _g === void 0 ? void 0 : _g.id) || doc[field.name];
370
+ }
371
+ else {
372
+ // For other field types, include as-is
373
+ try {
374
+ // @ts-ignore
375
+ transformedDoc[field.name] = doc[field.name];
376
+ }
377
+ catch (err) {
378
+ console.log(err, field, doc);
379
+ }
380
+ }
381
+ _h.label = 11;
382
+ case 11: return [2 /*return*/];
383
+ }
384
+ });
385
+ }); }))];
386
+ case 1:
387
+ _a.sent();
388
+ return [2 /*return*/, transformedDoc];
389
+ }
390
+ });
391
+ });
392
+ }
393
+ //# sourceMappingURL=indexCollections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexCollections.js","sourceRoot":"","sources":["../src/indexCollections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2CAA0C;AAC1C,6CAAwC;AACxC,iEAIsC;AAG/B,IAAM,gBAAgB,GAAG,UAAC,WAA+B,EAAE,MAAmB;IAEnF,IAAM,YAAY,GAAG,UAAC,cAAsB,YAAK,OAAA,UAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,mCAAI,EAAE,SAAG,cAAc,CAAE,CAAA,EAAA,CAAC;IAEjG,OAAO,WAAW,CAAC,GAAG,CAAC,UAAC,UAAU;;QAEhC,IAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,KAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAA1B,CAA0B,CAAC,CAAA,CAAC;QAEzG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;;;6BACF,CAAC,CAAC,EAAA;;oBAlEH,SAkEG,CAAC;oBAEJ,sBAAO,cAAc,EAAC;;;;CACvB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ module.exports = {};
3
+ //# sourceMappingURL=mockFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockFile.js","sourceRoot":"","sources":["../../src/mocks/mockFile.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Payload } from 'payload/dist/payload';
2
+ import type { PluginTypes } from './types';
3
+ export declare const onInitExtension: (pluginOptions: PluginTypes, payload: Payload) => void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onInitExtension = void 0;
4
+ var onInitExtension = function (pluginOptions, payload) {
5
+ var app = payload.express;
6
+ if (!app)
7
+ return;
8
+ try {
9
+ // You can use the existing express app here to add middleware, routes, etc.
10
+ // app.use(...)
11
+ }
12
+ catch (err) {
13
+ payload.logger.error({ msg: 'Error in onInitExtension', err: err });
14
+ }
15
+ };
16
+ exports.onInitExtension = onInitExtension;
17
+ //# sourceMappingURL=onInitExtension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onInitExtension.js","sourceRoot":"","sources":["../src/onInitExtension.ts"],"names":[],"mappings":";;;AAIO,IAAM,eAAe,GAAG,UAAC,aAA0B,EAAE,OAAgB;IAClE,IAAS,GAAG,GAAK,OAAO,QAAZ,CAAY;IAEhC,IAAI,CAAC,GAAG;QAAE,OAAM;IAEhB,IAAI;QACF,4EAA4E;QAC5E,eAAe;KAChB;IAAC,OAAO,GAAY,EAAE;QACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,0BAA0B,EAAE,GAAG,KAAA,EAAE,CAAC,CAAA;KAC/D;AACH,CAAC,CAAA;AAXY,QAAA,eAAe,mBAW3B"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'payload/config';
2
+ import type { PluginTypes } from './types';
3
+ export declare const meilisearchPlugin: (pluginOptions: PluginTypes) => Plugin;
package/dist/plugin.js ADDED
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
57
+ };
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.meilisearchPlugin = void 0;
60
+ var onInitExtension_1 = require("./onInitExtension");
61
+ var webpack_1 = require("./webpack");
62
+ var indexCollections_1 = require("./indexCollections");
63
+ var meilisearchPlugin = function (pluginOptions) {
64
+ return function (incomingConfig) {
65
+ var config = __assign({}, incomingConfig);
66
+ // If you need to add a webpack alias, use this function to extend the webpack config
67
+ var webpack = (0, webpack_1.extendWebpackConfig)(incomingConfig);
68
+ config.admin = __assign(__assign({}, (config.admin || {})), {
69
+ // If you extended the webpack config, add it back in here
70
+ // If you did not extend the webpack config, you can remove this line
71
+ webpack: webpack });
72
+ // If the plugin is disabled, return the config without modifying it
73
+ // The order of this check is important, we still want any webpack extensions to be applied even if the plugin is disabled
74
+ if (pluginOptions.enabled === false) {
75
+ return config;
76
+ }
77
+ config.collections = __spreadArray([], ((0, indexCollections_1.indexCollections)(config.collections || [], pluginOptions)), true);
78
+ config.endpoints = __spreadArray([], (config.endpoints || []), true);
79
+ config.globals = __spreadArray([], (config.globals || []), true);
80
+ config.hooks = __assign({}, (config.hooks || {}));
81
+ config.onInit = function (payload) { return __awaiter(void 0, void 0, void 0, function () {
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0:
85
+ if (!incomingConfig.onInit) return [3 /*break*/, 2];
86
+ return [4 /*yield*/, incomingConfig.onInit(payload)
87
+ // Add additional onInit code by using the onInitExtension function
88
+ ];
89
+ case 1:
90
+ _a.sent();
91
+ _a.label = 2;
92
+ case 2:
93
+ // Add additional onInit code by using the onInitExtension function
94
+ (0, onInitExtension_1.onInitExtension)(pluginOptions, payload);
95
+ return [2 /*return*/];
96
+ }
97
+ });
98
+ }); };
99
+ return config;
100
+ };
101
+ };
102
+ exports.meilisearchPlugin = meilisearchPlugin;
103
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAmD;AAEnD,qCAA+C;AAC/C,uDAAqD;AAI9C,IAAM,iBAAiB,GAC5B,UAAC,aAA0B;IACzB,OAAA,UAAC,cAAc;QACb,IAAI,MAAM,gBAAQ,cAAc,CAAE,CAAA;QAElC,qFAAqF;QACrF,IAAM,OAAO,GAAG,IAAA,6BAAmB,EAAC,cAAc,CAAC,CAAA;QAEnD,MAAM,CAAC,KAAK,yBACP,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;YACvB,0DAA0D;YAC1D,qEAAqE;YACrE,OAAO,SAAA,GAGR,CAAA;QAED,oEAAoE;QACpE,0HAA0H;QAC1H,IAAI,aAAa,CAAC,OAAO,KAAK,KAAK,EAAE;YACnC,OAAO,MAAM,CAAA;SACd;QAED,MAAM,CAAC,WAAW,qBACb,CAAC,IAAA,mCAAgB,EAAC,MAAM,CAAC,WAAW,IAAI,EAAE,EAAE,aAAa,CAAC,CAAC,OAC/D,CAAA;QAED,MAAM,CAAC,SAAS,qBACX,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,OAU5B,CAAA;QAED,MAAM,CAAC,OAAO,qBACT,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,OAE1B,CAAA;QAED,MAAM,CAAC,KAAK,gBACP,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAExB,CAAA;QAED,MAAM,CAAC,MAAM,GAAG,UAAM,OAAO;;;;6BACvB,cAAc,CAAC,MAAM,EAArB,wBAAqB;wBAAE,qBAAM,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;4BAC/D,mEAAmE;0BADJ;;wBAApC,SAAoC,CAAA;;;wBAC/D,mEAAmE;wBACnE,IAAA,iCAAe,EAAC,aAAa,EAAE,OAAO,CAAC,CAAA;;;;aACxC,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC;AAvDD,CAuDC,CAAA;AAzDQ,QAAA,iBAAiB,qBAyDzB"}
@@ -0,0 +1,18 @@
1
+ export interface PluginTypes {
2
+ /**
3
+ * Enable or disable plugin
4
+ * @default false
5
+ */
6
+ enabled?: boolean;
7
+ host: string;
8
+ apiKey: string;
9
+ indexPrefix?: string;
10
+ collections?: PluginCollectionConfig[];
11
+ }
12
+ export interface PluginCollectionConfig {
13
+ slug: string;
14
+ shouldIndex?: (doc: any, previousDoc: any, locale?: string) => 'index' | 'delete' | 'ignore';
15
+ }
16
+ export interface NewCollectionTypes {
17
+ title: string;
18
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { Config } from 'payload/config';
2
+ import type { Configuration as WebpackConfig } from 'webpack';
3
+ export declare const extendWebpackConfig: (config: Config) => (webpackConfig: WebpackConfig) => WebpackConfig;