@imbricate/core 3.3.4 → 3.4.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.
- package/database/schema.d.ts +1 -1
- package/document/property/primary.d.ts +8 -0
- package/document/property/primary.js +20 -0
- package/document/property/triage-base.d.ts +1 -0
- package/document/property/triage-base.js +4 -0
- package/document/property.d.ts +6 -1
- package/document/property.js +5 -0
- package/document/validate.js +6 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/origin/search.d.ts +13 -0
- package/package.json +1 -1
package/database/schema.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type ImbricateDatabaseSchemaPropertyOptionsReference = {
|
|
|
33
33
|
*/
|
|
34
34
|
readonly databases: ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase[];
|
|
35
35
|
};
|
|
36
|
-
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.DATE ? {} : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? ImbricateDatabaseSchemaPropertyOptionsLabel : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? ImbricateDatabaseSchemaPropertyOptionsReference : never;
|
|
36
|
+
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.IMBRISCRIPT ? {} : T extends IMBRICATE_PROPERTY_TYPE.DATE ? {} : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? ImbricateDatabaseSchemaPropertyOptionsLabel : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? ImbricateDatabaseSchemaPropertyOptionsReference : never;
|
|
37
37
|
export type ImbricateDatabaseSchemaPropertyForCreation<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
38
38
|
readonly propertyName: string;
|
|
39
39
|
readonly propertyType: T;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Primary
|
|
5
|
+
*/
|
|
6
|
+
import { ImbricateDatabaseSchema } from "../../database/schema";
|
|
7
|
+
import { DocumentProperties, DocumentPropertyValue, IMBRICATE_PROPERTY_TYPE } from "../property";
|
|
8
|
+
export declare const findPrimaryProperty: (schema: ImbricateDatabaseSchema, properties: DocumentProperties) => DocumentPropertyValue<IMBRICATE_PROPERTY_TYPE> | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Document_Property
|
|
5
|
+
* @description Primary
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.findPrimaryProperty = void 0;
|
|
9
|
+
const findPrimaryProperty = (schema, properties) => {
|
|
10
|
+
for (const property of schema.properties) {
|
|
11
|
+
if (property.isPrimaryKey) {
|
|
12
|
+
const value = properties[property.propertyIdentifier];
|
|
13
|
+
if (value) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
exports.findPrimaryProperty = findPrimaryProperty;
|
|
@@ -22,6 +22,7 @@ export declare class ImbricateDocumentPropertyTriageBase<Result> {
|
|
|
22
22
|
forString(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.STRING, Result>): this;
|
|
23
23
|
forNumber(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.NUMBER, Result>): this;
|
|
24
24
|
forMarkdown(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.MARKDOWN, Result>): this;
|
|
25
|
+
forImbriscript(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT, Result>): this;
|
|
25
26
|
forDate(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.DATE, Result>): this;
|
|
26
27
|
forLabel(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.LABEL, Result>): this;
|
|
27
28
|
forReference(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.REFERENCE, Result>): this;
|
|
@@ -41,6 +41,10 @@ class ImbricateDocumentPropertyTriageBase {
|
|
|
41
41
|
this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN, triageFunction);
|
|
42
42
|
return this;
|
|
43
43
|
}
|
|
44
|
+
forImbriscript(triageFunction) {
|
|
45
|
+
this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT, triageFunction);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
44
48
|
forDate(triageFunction) {
|
|
45
49
|
this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.DATE, triageFunction);
|
|
46
50
|
return this;
|
package/document/property.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export declare enum IMBRICATE_PROPERTY_TYPE {
|
|
|
23
23
|
* MARKDOWN - markdown, store as text object unique identifier. Display as markdown
|
|
24
24
|
*/
|
|
25
25
|
MARKDOWN = "MARKDOWN",
|
|
26
|
+
/**
|
|
27
|
+
* IMBRISCRIPT - imbricate script, store as text object unique identifier. Display as imbricate script
|
|
28
|
+
* The script is executed in a sandbox environment, using customized javascript engine
|
|
29
|
+
*/
|
|
30
|
+
IMBRISCRIPT = "IMBRISCRIPT",
|
|
26
31
|
/**
|
|
27
32
|
* DATE - date, store as string in ISO format
|
|
28
33
|
* For example - 2000-01-01T00:00:00.000Z
|
|
@@ -59,7 +64,7 @@ export type DocumentPropertyValueObjectReference = {
|
|
|
59
64
|
readonly databaseUniqueIdentifier: string;
|
|
60
65
|
readonly documentUniqueIdentifier: string;
|
|
61
66
|
};
|
|
62
|
-
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.DATE ? string : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? string[] : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? DocumentPropertyValueObjectReference[] : never;
|
|
67
|
+
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.IMBRISCRIPT ? string : T extends IMBRICATE_PROPERTY_TYPE.DATE ? string : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? string[] : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? DocumentPropertyValueObjectReference[] : never;
|
|
63
68
|
/**
|
|
64
69
|
* Edit record type of the document
|
|
65
70
|
*/
|
package/document/property.js
CHANGED
|
@@ -27,6 +27,11 @@ var IMBRICATE_PROPERTY_TYPE;
|
|
|
27
27
|
* MARKDOWN - markdown, store as text object unique identifier. Display as markdown
|
|
28
28
|
*/
|
|
29
29
|
IMBRICATE_PROPERTY_TYPE["MARKDOWN"] = "MARKDOWN";
|
|
30
|
+
/**
|
|
31
|
+
* IMBRISCRIPT - imbricate script, store as text object unique identifier. Display as imbricate script
|
|
32
|
+
* The script is executed in a sandbox environment, using customized javascript engine
|
|
33
|
+
*/
|
|
34
|
+
IMBRICATE_PROPERTY_TYPE["IMBRISCRIPT"] = "IMBRISCRIPT";
|
|
30
35
|
/**
|
|
31
36
|
* DATE - date, store as string in ISO format
|
|
32
37
|
* For example - 2000-01-01T00:00:00.000Z
|
package/document/validate.js
CHANGED
|
@@ -65,6 +65,12 @@ const validateImbricateProperties = (properties, schema, allowExtraProperties =
|
|
|
65
65
|
}
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
|
+
case property_1.IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT: {
|
|
69
|
+
if (typeof value.value !== "string") {
|
|
70
|
+
return `Property ${key} value must be a string of text object reference`;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
68
74
|
case property_1.IMBRICATE_PROPERTY_TYPE.DATE: {
|
|
69
75
|
if (typeof value.value !== "string") {
|
|
70
76
|
return `Property ${key} value must be a string of date in ISO format`;
|
package/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./document/definition";
|
|
|
11
11
|
export * from "./document/interface";
|
|
12
12
|
export * from "./document/property";
|
|
13
13
|
export * from "./document/property/definition";
|
|
14
|
+
export * from "./document/property/primary";
|
|
14
15
|
export * from "./document/property/triage";
|
|
15
16
|
export * from "./document/property/triage-manager";
|
|
16
17
|
export * from "./document/validate";
|
package/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __exportStar(require("./document/definition"), exports);
|
|
|
27
27
|
__exportStar(require("./document/interface"), exports);
|
|
28
28
|
__exportStar(require("./document/property"), exports);
|
|
29
29
|
__exportStar(require("./document/property/definition"), exports);
|
|
30
|
+
__exportStar(require("./document/property/primary"), exports);
|
|
30
31
|
__exportStar(require("./document/property/triage"), exports);
|
|
31
32
|
__exportStar(require("./document/property/triage-manager"), exports);
|
|
32
33
|
__exportStar(require("./document/validate"), exports);
|
package/origin/search.d.ts
CHANGED
|
@@ -26,7 +26,20 @@ export type ImbricateSearchTarget<T extends IMBRICATE_SEARCH_TARGET_TYPE> = {
|
|
|
26
26
|
export type ImbricateSearchItem = {
|
|
27
27
|
readonly target: ImbricateSearchTarget<IMBRICATE_SEARCH_TARGET_TYPE>;
|
|
28
28
|
readonly primary: string;
|
|
29
|
+
/**
|
|
30
|
+
* @description Source are optional, use for source context
|
|
31
|
+
*/
|
|
32
|
+
readonly sourceDatabaseName?: string;
|
|
33
|
+
readonly sourceDocumentPrimaryKey?: string;
|
|
34
|
+
/**
|
|
35
|
+
* @description Previous are optional, use for previous context on the secondary object
|
|
36
|
+
*/
|
|
37
|
+
readonly secondaryPrevious?: string[];
|
|
29
38
|
readonly secondary: string;
|
|
39
|
+
/**
|
|
40
|
+
* @description Next are optional, use for next context on the secondary object
|
|
41
|
+
*/
|
|
42
|
+
readonly secondaryNext?: string[];
|
|
30
43
|
};
|
|
31
44
|
export type ImbricateSearchResult = {
|
|
32
45
|
readonly items: ImbricateSearchItem[];
|