@imbricate/core 3.2.0 → 3.2.1
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/database/schema.d.ts +5 -1
- package/database/schema.js +11 -0
- package/document/property.d.ts +6 -1
- package/document/validate.js +11 -2
- package/package.json +1 -1
package/database/schema.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ import { IMBRICATE_PROPERTY_TYPE } from "../document/property";
|
|
|
7
7
|
export type ImbricateDatabaseSchemaProperty<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
8
8
|
readonly propertyIdentifier: string;
|
|
9
9
|
} & ImbricateDatabaseSchemaPropertyForCreation<T>;
|
|
10
|
+
export type ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase = {
|
|
11
|
+
readonly originUniqueIdentifier: string;
|
|
12
|
+
readonly databaseUniqueIdentifier: string;
|
|
13
|
+
};
|
|
10
14
|
export type ImbricateDatabaseSchemaPropertyOptions<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? {} : T extends IMBRICATE_PROPERTY_TYPE.STRING ? {} : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? {} : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? {} : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? {
|
|
11
15
|
/**
|
|
12
16
|
* Allow multiple references
|
|
@@ -16,7 +20,7 @@ export type ImbricateDatabaseSchemaPropertyOptions<T extends IMBRICATE_PROPERTY_
|
|
|
16
20
|
* Allow references from these databases
|
|
17
21
|
* If empty, allow references from all databases
|
|
18
22
|
*/
|
|
19
|
-
readonly databases:
|
|
23
|
+
readonly databases: ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase[];
|
|
20
24
|
} : never;
|
|
21
25
|
export type ImbricateDatabaseSchemaPropertyForCreation<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
22
26
|
readonly propertyName: string;
|
package/database/schema.js
CHANGED
|
@@ -33,6 +33,17 @@ const validateImbricateSchemaProperty = (property) => {
|
|
|
33
33
|
if (typeof property.propertyOptions.allowMultiple !== "boolean") {
|
|
34
34
|
return "Property options allowMultiple must be a boolean";
|
|
35
35
|
}
|
|
36
|
+
if (!Array.isArray(property.propertyOptions.databases)) {
|
|
37
|
+
return "Property options databases must be an array";
|
|
38
|
+
}
|
|
39
|
+
for (const database of property.propertyOptions.databases) {
|
|
40
|
+
if (typeof database.originUniqueIdentifier !== "string") {
|
|
41
|
+
return "Database originUniqueIdentifier must be a string";
|
|
42
|
+
}
|
|
43
|
+
if (typeof database.databaseUniqueIdentifier !== "string") {
|
|
44
|
+
return "Database databaseUniqueIdentifier must be a string";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
break;
|
|
37
48
|
}
|
|
38
49
|
}
|
package/document/property.d.ts
CHANGED
|
@@ -44,7 +44,12 @@ export type DocumentPropertyValue<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
|
44
44
|
readonly type: T;
|
|
45
45
|
readonly value: DocumentPropertyValueObject<T>;
|
|
46
46
|
};
|
|
47
|
-
export type
|
|
47
|
+
export type DocumentPropertyValueObjectReference = {
|
|
48
|
+
readonly originUniqueIdentifier: string;
|
|
49
|
+
readonly databaseUniqueIdentifier: string;
|
|
50
|
+
readonly documentUniqueIdentifier: string;
|
|
51
|
+
};
|
|
52
|
+
export type DocumentPropertyValueObject<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? boolean : T extends IMBRICATE_PROPERTY_TYPE.STRING ? string : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? number : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? string : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? DocumentPropertyValueObjectReference[] : never;
|
|
48
53
|
/**
|
|
49
54
|
* Edit record type of the document
|
|
50
55
|
*/
|
package/document/validate.js
CHANGED
|
@@ -65,8 +65,17 @@ const validateImbricateProperties = (properties, schema) => {
|
|
|
65
65
|
return `Property ${key} value must be an array of string`;
|
|
66
66
|
}
|
|
67
67
|
for (const reference of value.value) {
|
|
68
|
-
if (typeof reference !== "
|
|
69
|
-
return `Property ${key}
|
|
68
|
+
if (typeof reference !== "object") {
|
|
69
|
+
return `Property ${key} reference must be an object`;
|
|
70
|
+
}
|
|
71
|
+
if (typeof reference.originUniqueIdentifier !== "string") {
|
|
72
|
+
return `Property ${key} reference originUniqueIdentifier must be a string`;
|
|
73
|
+
}
|
|
74
|
+
if (typeof reference.databaseUniqueIdentifier !== "string") {
|
|
75
|
+
return `Property ${key} reference databaseUniqueIdentifier must be a string`;
|
|
76
|
+
}
|
|
77
|
+
if (typeof reference.documentUniqueIdentifier !== "string") {
|
|
78
|
+
return `Property ${key} reference documentUniqueIdentifier must be a string`;
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
break;
|