rimecms 0.25.2 → 0.25.3

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.
@@ -1,3 +1,4 @@
1
+ import { logger } from '../../logger/index.server.js';
1
2
  export const find = async (args) => {
2
3
  //
3
4
  const { config, event, locale, sort, limit, offset, depth, query, draft, select = [], isSystemOperation } = args;
@@ -45,18 +46,25 @@ export const find = async (args) => {
45
46
  withBlank: !hasSelect
46
47
  });
47
48
  for (const hook of config.$hooks?.beforeRead || []) {
48
- const result = await hook({
49
- doc: document,
50
- config,
51
- operation: 'read',
52
- event,
53
- context
54
- });
55
- context = result.context;
56
- document = result.doc;
49
+ try {
50
+ const result = await hook({
51
+ doc: document,
52
+ config,
53
+ operation: 'read',
54
+ event,
55
+ context
56
+ });
57
+ context = result.context;
58
+ document = result.doc;
59
+ }
60
+ catch (error) {
61
+ // If a beforeRead hook throws an error, we skip processing this document and continue with the next one
62
+ logger.error(error.message, error);
63
+ return null; // Indicate that this document should be filtered out
64
+ }
57
65
  }
58
66
  return document;
59
67
  }
60
68
  const documents = await Promise.all(documentsRaw.map((doc) => processDocument(doc)));
61
- return documents;
69
+ return documents.filter((d) => !!d);
62
70
  };
@@ -1,7 +1,7 @@
1
1
  import type { CollectionWithoutSlug } from '../../collections/config/types.js';
2
+ import type { FieldBuilder } from '../../fields/builders/field-builder.js';
2
3
  import type { Field } from '../../../types.js';
3
4
  import type { Access, AdditionalStaffConfig } from '../types.js';
4
- import type { FieldBuilder } from '../../fields/builders/field-builder.js';
5
5
  export declare const staffCollection: {
6
6
  label: {
7
7
  singular: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "0.25.2",
3
+ "version": "0.25.3",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "scripts": {
6
6
  "dev": "vite dev",