rimecms 0.23.19 → 0.23.20
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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RelationValue } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a relation field's value is populated with full documents.
|
|
4
|
+
*
|
|
5
|
+
* A relation is considered populated if it is an array of objects that do not
|
|
6
|
+
* contain only the relation identifiers (`id`, `relationTo`, `documentId`).
|
|
7
|
+
* If the value is a string or an array of relation identifier objects,
|
|
8
|
+
* it is considered not populated.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Returns: false
|
|
12
|
+
* isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd');
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Returns: false
|
|
16
|
+
* isRelationPopulated([]);
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Returns: false
|
|
20
|
+
* isRelationPopulated([
|
|
21
|
+
* {
|
|
22
|
+
* id: '7674e91b-598a-4a72-a5cd-9594736a34dd',
|
|
23
|
+
* relationTo: 'articles',
|
|
24
|
+
* documentId: 'b674e91b-598a-4a72-a5cd-9594736a34dd'
|
|
25
|
+
* }
|
|
26
|
+
* ]);
|
|
27
|
+
*/
|
|
28
|
+
export declare const isRelationPopulated: <T>(value: RelationValue<T>) => value is T[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { hasProps, isObjectLiteral } from '../../util/object';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a relation field's value is populated with full documents.
|
|
4
|
+
*
|
|
5
|
+
* A relation is considered populated if it is an array of objects that do not
|
|
6
|
+
* contain only the relation identifiers (`id`, `relationTo`, `documentId`).
|
|
7
|
+
* If the value is a string or an array of relation identifier objects,
|
|
8
|
+
* it is considered not populated.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Returns: false
|
|
12
|
+
* isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd');
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Returns: false
|
|
16
|
+
* isRelationPopulated([]);
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Returns: false
|
|
20
|
+
* isRelationPopulated([
|
|
21
|
+
* {
|
|
22
|
+
* id: '7674e91b-598a-4a72-a5cd-9594736a34dd',
|
|
23
|
+
* relationTo: 'articles',
|
|
24
|
+
* documentId: 'b674e91b-598a-4a72-a5cd-9594736a34dd'
|
|
25
|
+
* }
|
|
26
|
+
* ]);
|
|
27
|
+
*/
|
|
28
|
+
export const isRelationPopulated = (value) => {
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
if (value.length === 0)
|
|
31
|
+
return false;
|
|
32
|
+
return value.every((v) => {
|
|
33
|
+
return isObjectLiteral(v) && !hasProps(['id', 'relationTo', 'documentId'], v);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return typeof value !== 'string';
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.20",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -70,6 +70,10 @@
|
|
|
70
70
|
"types": "./dist/fields/rich-text/client.d.ts",
|
|
71
71
|
"import": "./dist/fields/rich-text/client.js"
|
|
72
72
|
},
|
|
73
|
+
"./fields/relation": {
|
|
74
|
+
"types": "./dist/fields/relation/client.d.ts",
|
|
75
|
+
"import": "./dist/fields/relation/client.js"
|
|
76
|
+
},
|
|
73
77
|
"./i18n": {
|
|
74
78
|
"types": "./dist/core/i18n/index.d.ts",
|
|
75
79
|
"import": "./dist/core/i18n/index.js"
|