@degenerate/generic 0.1.1 → 0.1.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.
- package/dist/application/database/firestore/generics/get-items-from-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-items-from-database.js +0 -3
- package/dist/crypto/seal/seal.d.ts +1 -0
- package/dist/crypto/seal/seal.d.ts.map +1 -0
- package/dist/crypto/seal/seal.js +51 -0
- package/dist/errors/safe/safe-rules-errors.d.ts +72 -0
- package/dist/errors/safe/safe-rules-errors.d.ts.map +1 -1
- package/dist/errors/safe/safe-rules-errors.js +113 -1
- package/dist/models/rules/share-rule-models.d.ts +42 -19
- package/dist/models/rules/share-rule-models.d.ts.map +1 -1
- package/dist/models/rules/share-rule-models.js +9 -8
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-items-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-from-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAKnG;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,GAAU,CAAC,UACzB,MAAM,kBACE,uBAAuB,4BACd,uBAAuB,KACjD,OAAO,CAAC,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"get-items-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-from-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAKnG;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,GAAU,CAAC,UACzB,MAAM,kBACE,uBAAuB,4BACd,uBAAuB,KACjD,OAAO,CAAC,CAAC,EAAE,CAuCb,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -46,7 +46,6 @@ const getItemsFromDatabase = async (userId, getInformation, applicationAuditLogT
|
|
|
46
46
|
const itemsToReturn = await db.runTransaction(async (t) => {
|
|
47
47
|
const databaseItems = [];
|
|
48
48
|
const itemQuery = getInformation.itemColRef;
|
|
49
|
-
console.log('itemQuery', itemQuery);
|
|
50
49
|
// add in the query fields if they are set.
|
|
51
50
|
for (const queryField of getInformation.queryFields) {
|
|
52
51
|
itemQuery.where(queryField.fieldPath, queryField.opStr, queryField.value);
|
|
@@ -62,9 +61,7 @@ const getItemsFromDatabase = async (userId, getInformation, applicationAuditLogT
|
|
|
62
61
|
}
|
|
63
62
|
// set the limit and query the database.
|
|
64
63
|
itemQuery.limit(maxResults);
|
|
65
|
-
console.log('itemQueryAfter', itemQuery.limit);
|
|
66
64
|
const itemSnapshot = await t.get(itemQuery);
|
|
67
|
-
console.log('itemSnapshot', itemSnapshot);
|
|
68
65
|
// get the items from the database.
|
|
69
66
|
for (const docSnap of itemSnapshot.docs) {
|
|
70
67
|
const item = docSnap.data();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/crypto/seal/seal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
;
|
|
3
|
+
(async () => {
|
|
4
|
+
// ES6 or CommonJS
|
|
5
|
+
// import SEAL from 'node-seal'
|
|
6
|
+
// const SEAL = require('node-seal')
|
|
7
|
+
// Using CommonJS for RunKit
|
|
8
|
+
const SEAL = require('node-seal');
|
|
9
|
+
const seal = await SEAL();
|
|
10
|
+
const schemeType = seal.SchemeType.bfv;
|
|
11
|
+
const securityLevel = seal.SecurityLevel.tc128;
|
|
12
|
+
const polyModulusDegree = 4096;
|
|
13
|
+
const bitSizes = [36, 36, 37];
|
|
14
|
+
const bitSize = 20;
|
|
15
|
+
const parms = seal.EncryptionParameters(schemeType);
|
|
16
|
+
// Set the PolyModulusDegree
|
|
17
|
+
parms.setPolyModulusDegree(polyModulusDegree);
|
|
18
|
+
// Create a suitable set of CoeffModulus primes
|
|
19
|
+
parms.setCoeffModulus(seal.CoeffModulus.Create(polyModulusDegree, Int32Array.from(bitSizes)));
|
|
20
|
+
// Set the PlainModulus to a prime of bitSize 20.
|
|
21
|
+
parms.setPlainModulus(seal.PlainModulus.Batching(polyModulusDegree, bitSize));
|
|
22
|
+
const context = seal.Context(parms, // Encryption Parameters
|
|
23
|
+
true, // ExpandModChain
|
|
24
|
+
securityLevel // Enforce a security level
|
|
25
|
+
);
|
|
26
|
+
if (!context.parametersSet()) {
|
|
27
|
+
throw new Error('Could not set the parameters in the given context. Please try different encryption parameters.');
|
|
28
|
+
}
|
|
29
|
+
const encoder = seal.BatchEncoder(context);
|
|
30
|
+
const keyGenerator = seal.KeyGenerator(context);
|
|
31
|
+
const publicKey = keyGenerator.createPublicKey();
|
|
32
|
+
const secretKey = keyGenerator.secretKey();
|
|
33
|
+
const encryptor = seal.Encryptor(context, publicKey);
|
|
34
|
+
const decryptor = seal.Decryptor(context, secretKey);
|
|
35
|
+
const evaluator = seal.Evaluator(context);
|
|
36
|
+
// Create data to be encrypted
|
|
37
|
+
const array = Int32Array.from([1, 2, 3, 4, 5]);
|
|
38
|
+
// Encode the Array
|
|
39
|
+
const plainText = encoder.encode(array);
|
|
40
|
+
// Encrypt the PlainText
|
|
41
|
+
const cipherText = encryptor.encrypt(plainText);
|
|
42
|
+
// Add the CipherText to itself and store it in the destination parameter (itself)
|
|
43
|
+
evaluator.add(cipherText, cipherText, cipherText); // Op (A), Op (B), Op (Dest)
|
|
44
|
+
// Or create return a new cipher with the result (omitting destination parameter)
|
|
45
|
+
// const cipher2x = evaluator.add(cipherText, cipherText)
|
|
46
|
+
// Decrypt the CipherText
|
|
47
|
+
const decryptedPlainText = decryptor.decrypt(cipherText);
|
|
48
|
+
// Decode the PlainText
|
|
49
|
+
const decodedArray = encoder.decode(decryptedPlainText);
|
|
50
|
+
console.log('decodedArray', decodedArray);
|
|
51
|
+
})();
|
|
@@ -27,4 +27,76 @@ export declare class SafeRuleEvaluationSpecialConditionPatternError extends Base
|
|
|
27
27
|
*/
|
|
28
28
|
constructor(dataValue: unknown, conditionValue: unknown);
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* This error is thrown when a rule set has no rule groups
|
|
32
|
+
*/
|
|
33
|
+
export declare class SafeRuleRuleSetNoRuleGroupsError extends BaseError {
|
|
34
|
+
/**
|
|
35
|
+
* This error is thrown when a rule set has no rule groups
|
|
36
|
+
*/
|
|
37
|
+
constructor(name: string, description?: string);
|
|
38
|
+
}
|
|
39
|
+
export declare class SafeRuleConditionNotTypeOfError extends BaseError {
|
|
40
|
+
constructor(conditionType: ConditionType, expectedType: string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* This error is thrown when a rule condition is not an object
|
|
44
|
+
*/
|
|
45
|
+
export declare class SafeRuleConditionNotObjectError extends BaseError {
|
|
46
|
+
constructor(incomingObject: unknown);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* This error is thrown when a rule condition is missing or has an extra property
|
|
50
|
+
*/
|
|
51
|
+
export declare class SafeRuleConditionHasMismatchingProperties extends BaseError {
|
|
52
|
+
constructor(incomingObject: unknown, expectedPropertyCount: number, actualPropertyCount: number);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This error is thrown when the safe condition qualifier is not valid
|
|
56
|
+
*/
|
|
57
|
+
export declare class SafeRuleConditionQualifierError extends BaseError {
|
|
58
|
+
constructor(conditionQualifier: unknown);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* This error is thrown when a rule condition property is missing
|
|
62
|
+
*/
|
|
63
|
+
export declare class SafeRuleConditionPropertyMissingError extends BaseError {
|
|
64
|
+
constructor(missingProperty: string);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* This error is thrown when a rule condition value is not valid
|
|
68
|
+
*/
|
|
69
|
+
export declare class SafeRuleConditionValueWrongType extends BaseError {
|
|
70
|
+
constructor(conditionValue: unknown, expectedType: string);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* This error is thrown when a rule condition type is not valid
|
|
74
|
+
*/
|
|
75
|
+
export declare class SafeRuleConditionTypeNotValidError extends BaseError {
|
|
76
|
+
constructor(conditionType: unknown);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* This error is thrown when a safe rule is not an object
|
|
80
|
+
*/
|
|
81
|
+
export declare class SafeRuleNotObjectError extends BaseError {
|
|
82
|
+
constructor(incomingObject: unknown);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* This error is thrown when a safe rule is missing or has an extra property
|
|
86
|
+
*/
|
|
87
|
+
export declare class SafeRuleHasMismatchingProperties extends BaseError {
|
|
88
|
+
constructor(incomingObject: unknown, expectedPropertyCount: number, actualPropertyCount: number);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* This error is thrown when a safe rule is missing property
|
|
92
|
+
*/
|
|
93
|
+
export declare class SafeRuleHasMissingProperty extends BaseError {
|
|
94
|
+
constructor(incomingObject: unknown, expectedProperty: string);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* This error is thrown when a safe rule property is not valid
|
|
98
|
+
*/
|
|
99
|
+
export declare class SafeRulePropertyValueWrongType extends BaseError {
|
|
100
|
+
constructor(propertyName: string, propertyValue: unknown, expectedType: string);
|
|
101
|
+
}
|
|
30
102
|
//# sourceMappingURL=safe-rules-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-rules-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/safe/safe-rules-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc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AY,EAAE,MAAM;CAGjE;AAGD;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;gBAC9C,cAAc,EAAE,OAAO;CAGtC;AAED;;GAEG;AACH,qBAAa,yCAA0C,SAAQ,SAAS;gBACxD,cAAc,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM;CAGlG;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;gBAC9C,kBAAkB,EAAE,OAAO;CAG1C;AAGD;;GAEG;AACH,qBAAa,qCAAsC,SAAQ,SAAS;gBACpD,eAAe,EAAE,MAAM;CAGtC;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;gBAC9C,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM;CAG5D;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;gBACjD,aAAa,EAAE,OAAO;CAGrC;AAMD;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;gBACrC,cAAc,EAAE,OAAO;CAGtC;AAED;;GAEG;AACH,qBAAa,gCAAiC,SAAQ,SAAS;gBAC/C,cAAc,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM;CAGlG;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;gBACzC,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM;CAGhE;AAED;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,SAAS;gBAC7C,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM;CAGjF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SafeRuleEvaluationSpecialConditionPatternError = exports.SafeRuleEvaluationConditionValueError = exports.SafeRuleEvaluationConditionDataValueError = void 0;
|
|
3
|
+
exports.SafeRulePropertyValueWrongType = exports.SafeRuleHasMissingProperty = exports.SafeRuleHasMismatchingProperties = exports.SafeRuleNotObjectError = exports.SafeRuleConditionTypeNotValidError = exports.SafeRuleConditionValueWrongType = exports.SafeRuleConditionPropertyMissingError = exports.SafeRuleConditionQualifierError = exports.SafeRuleConditionHasMismatchingProperties = exports.SafeRuleConditionNotObjectError = exports.SafeRuleConditionNotTypeOfError = exports.SafeRuleRuleSetNoRuleGroupsError = exports.SafeRuleEvaluationSpecialConditionPatternError = exports.SafeRuleEvaluationConditionValueError = exports.SafeRuleEvaluationConditionDataValueError = void 0;
|
|
4
4
|
const base_error_1 = require("../base-error");
|
|
5
5
|
/**
|
|
6
6
|
* This error is thrown when a evaluation condition data value is not valid
|
|
@@ -38,3 +38,115 @@ class SafeRuleEvaluationSpecialConditionPatternError extends base_error_1.BaseEr
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.SafeRuleEvaluationSpecialConditionPatternError = SafeRuleEvaluationSpecialConditionPatternError;
|
|
41
|
+
/**
|
|
42
|
+
* This error is thrown when a rule set has no rule groups
|
|
43
|
+
*/
|
|
44
|
+
class SafeRuleRuleSetNoRuleGroupsError extends base_error_1.BaseError {
|
|
45
|
+
/**
|
|
46
|
+
* This error is thrown when a rule set has no rule groups
|
|
47
|
+
*/
|
|
48
|
+
constructor(name, description) {
|
|
49
|
+
super(`Share Rule set ${name} with description ${description} has no rule groups`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SafeRuleRuleSetNoRuleGroupsError = SafeRuleRuleSetNoRuleGroupsError;
|
|
53
|
+
//#region Condition Validation Errors
|
|
54
|
+
class SafeRuleConditionNotTypeOfError extends base_error_1.BaseError {
|
|
55
|
+
constructor(conditionType, expectedType) {
|
|
56
|
+
super(`Share Rule condition type ${conditionType} is not of type ${expectedType}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.SafeRuleConditionNotTypeOfError = SafeRuleConditionNotTypeOfError;
|
|
60
|
+
/**
|
|
61
|
+
* This error is thrown when a rule condition is not an object
|
|
62
|
+
*/
|
|
63
|
+
class SafeRuleConditionNotObjectError extends base_error_1.BaseError {
|
|
64
|
+
constructor(incomingObject) {
|
|
65
|
+
super(`Share Rule condition object ${incomingObject} is not an object`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.SafeRuleConditionNotObjectError = SafeRuleConditionNotObjectError;
|
|
69
|
+
/**
|
|
70
|
+
* This error is thrown when a rule condition is missing or has an extra property
|
|
71
|
+
*/
|
|
72
|
+
class SafeRuleConditionHasMismatchingProperties extends base_error_1.BaseError {
|
|
73
|
+
constructor(incomingObject, expectedPropertyCount, actualPropertyCount) {
|
|
74
|
+
super(`Share Rule condition object ${incomingObject} has mismatching properties, expected ${expectedPropertyCount} but got ${actualPropertyCount}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.SafeRuleConditionHasMismatchingProperties = SafeRuleConditionHasMismatchingProperties;
|
|
78
|
+
/**
|
|
79
|
+
* This error is thrown when the safe condition qualifier is not valid
|
|
80
|
+
*/
|
|
81
|
+
class SafeRuleConditionQualifierError extends base_error_1.BaseError {
|
|
82
|
+
constructor(conditionQualifier) {
|
|
83
|
+
super(`Share Rule condition qualifier ${conditionQualifier} is not valid`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.SafeRuleConditionQualifierError = SafeRuleConditionQualifierError;
|
|
87
|
+
/**
|
|
88
|
+
* This error is thrown when a rule condition property is missing
|
|
89
|
+
*/
|
|
90
|
+
class SafeRuleConditionPropertyMissingError extends base_error_1.BaseError {
|
|
91
|
+
constructor(missingProperty) {
|
|
92
|
+
super(`Share Rule condition property ${missingProperty} is missing`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.SafeRuleConditionPropertyMissingError = SafeRuleConditionPropertyMissingError;
|
|
96
|
+
/**
|
|
97
|
+
* This error is thrown when a rule condition value is not valid
|
|
98
|
+
*/
|
|
99
|
+
class SafeRuleConditionValueWrongType extends base_error_1.BaseError {
|
|
100
|
+
constructor(conditionValue, expectedType) {
|
|
101
|
+
super(`Share Rule condition value ${conditionValue} is not of type ${expectedType}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.SafeRuleConditionValueWrongType = SafeRuleConditionValueWrongType;
|
|
105
|
+
/**
|
|
106
|
+
* This error is thrown when a rule condition type is not valid
|
|
107
|
+
*/
|
|
108
|
+
class SafeRuleConditionTypeNotValidError extends base_error_1.BaseError {
|
|
109
|
+
constructor(conditionType) {
|
|
110
|
+
super(`Share Rule condition type ${conditionType} is not valid`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.SafeRuleConditionTypeNotValidError = SafeRuleConditionTypeNotValidError;
|
|
114
|
+
//#endregion Condition Validation Errors
|
|
115
|
+
//#region Rule Validation Errors
|
|
116
|
+
/**
|
|
117
|
+
* This error is thrown when a safe rule is not an object
|
|
118
|
+
*/
|
|
119
|
+
class SafeRuleNotObjectError extends base_error_1.BaseError {
|
|
120
|
+
constructor(incomingObject) {
|
|
121
|
+
super(`Share Rule object ${incomingObject} is not an object`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.SafeRuleNotObjectError = SafeRuleNotObjectError;
|
|
125
|
+
/**
|
|
126
|
+
* This error is thrown when a safe rule is missing or has an extra property
|
|
127
|
+
*/
|
|
128
|
+
class SafeRuleHasMismatchingProperties extends base_error_1.BaseError {
|
|
129
|
+
constructor(incomingObject, expectedPropertyCount, actualPropertyCount) {
|
|
130
|
+
super(`Share Rule object ${incomingObject} has mismatching properties, expected ${expectedPropertyCount} but got ${actualPropertyCount}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.SafeRuleHasMismatchingProperties = SafeRuleHasMismatchingProperties;
|
|
134
|
+
/**
|
|
135
|
+
* This error is thrown when a safe rule is missing property
|
|
136
|
+
*/
|
|
137
|
+
class SafeRuleHasMissingProperty extends base_error_1.BaseError {
|
|
138
|
+
constructor(incomingObject, expectedProperty) {
|
|
139
|
+
super(`Share Rule object ${incomingObject} is missing property ${expectedProperty}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.SafeRuleHasMissingProperty = SafeRuleHasMissingProperty;
|
|
143
|
+
/**
|
|
144
|
+
* This error is thrown when a safe rule property is not valid
|
|
145
|
+
*/
|
|
146
|
+
class SafeRulePropertyValueWrongType extends base_error_1.BaseError {
|
|
147
|
+
constructor(propertyName, propertyValue, expectedType) {
|
|
148
|
+
super(`Share Rule property ${propertyName} with value ${propertyValue} is not of type ${expectedType}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.SafeRulePropertyValueWrongType = SafeRulePropertyValueWrongType;
|
|
152
|
+
//#endregion Rule Validation Errors
|
|
@@ -31,12 +31,12 @@ export interface IRuleEvaluationResults {
|
|
|
31
31
|
/**
|
|
32
32
|
* This contains the interface for the rule set in the share data object
|
|
33
33
|
*/
|
|
34
|
-
export interface
|
|
34
|
+
export interface IShareRuleSet {
|
|
35
|
+
description?: string;
|
|
35
36
|
id: string;
|
|
36
|
-
version: number;
|
|
37
37
|
name: string;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
ruleGroups: IShareRuleGroup[];
|
|
39
|
+
version: number;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* This contains the logical operators for combining rules.
|
|
@@ -50,9 +50,9 @@ export declare enum LogicalOperator {
|
|
|
50
50
|
*
|
|
51
51
|
* A rule group can contain individual rules or nested rule groups.
|
|
52
52
|
*/
|
|
53
|
-
export interface
|
|
53
|
+
export interface IShareRuleGroup {
|
|
54
54
|
operator: LogicalOperator;
|
|
55
|
-
rules: (IShareRuleApplied |
|
|
55
|
+
rules: (IShareRuleApplied | IShareRuleGroup)[];
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* This contains the interface for a share rule in the share data object
|
|
@@ -71,7 +71,7 @@ export interface IShareRuleApplied extends IShareRule {
|
|
|
71
71
|
/**
|
|
72
72
|
* This contains the different types of conditions that can be evaluated.
|
|
73
73
|
*/
|
|
74
|
-
export type ConditionType = ConditionTypeSingle | ConditionTypeRange | ConditionTypeStartsEndsWith | ConditionTypeBoolean |
|
|
74
|
+
export type ConditionType = ConditionTypeSingle | ConditionTypeRange | ConditionTypeStartsEndsWith | ConditionTypeBoolean | ConditionTypeSpecial;
|
|
75
75
|
/**
|
|
76
76
|
* This contains the choices for the type of qualifier.
|
|
77
77
|
*/
|
|
@@ -87,7 +87,8 @@ export declare enum ConditionTypeSingle {
|
|
|
87
87
|
EQUAL = "equal",// the value is equal to the condition value
|
|
88
88
|
CONTAINS = "contains",// the value contains the condition value
|
|
89
89
|
NULL = "null",// the value is null
|
|
90
|
-
EMPTY = "empty"
|
|
90
|
+
EMPTY = "empty",// the value is empty
|
|
91
|
+
SHARE_RULE = "share-rule"
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
94
|
* This contains the choices for the range conditions.
|
|
@@ -118,16 +119,10 @@ export declare enum ConditionTypeBoolean {
|
|
|
118
119
|
export declare enum ConditionTypeSpecial {
|
|
119
120
|
PATTERN = "pattern"
|
|
120
121
|
}
|
|
121
|
-
/**
|
|
122
|
-
* This contains the choices for the combined rule conditions that are a type of object
|
|
123
|
-
*/
|
|
124
|
-
export declare enum ConditionTypeCombinedRules {
|
|
125
|
-
OBJECT = "object"
|
|
126
|
-
}
|
|
127
122
|
/**
|
|
128
123
|
* This is the interface for the conditional information in the checks.
|
|
129
124
|
*/
|
|
130
|
-
export type ICondition = IConditionTypeOf | IConditionEquality | IConditionRange | IConditionContains | IConditionStartsEndsWith | IConditionNull | IConditionBoolean | IConditionEmpty |
|
|
125
|
+
export type ICondition = IConditionTypeOf | IConditionEquality | IConditionRange | IConditionContains | IConditionStartsEndsWith | IConditionNull | IConditionBoolean | IConditionEmpty | IConditionShareRule | IConditionSpecial;
|
|
131
126
|
/**
|
|
132
127
|
* This is the interface for the base condition.
|
|
133
128
|
*/
|
|
@@ -271,10 +266,38 @@ export interface IConditionSpecial extends IConditionBase {
|
|
|
271
266
|
conditionValue: string;
|
|
272
267
|
}
|
|
273
268
|
/**
|
|
274
|
-
* This is the interface for the
|
|
269
|
+
* This is the interface for the share rule condition.
|
|
270
|
+
*
|
|
271
|
+
|
|
272
|
+
const nestedShareRule: IShareRule = {
|
|
273
|
+
ruleId: 'nestedRule',
|
|
274
|
+
currentDataConditions: [
|
|
275
|
+
{
|
|
276
|
+
targettedProperty: 'nestedProperty',
|
|
277
|
+
conditionType: 'equal',
|
|
278
|
+
conditionValue: 'expectedValue',
|
|
279
|
+
conditionTypeQualifier: ConditionTypeQualifier.IS,
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
proposedDataConditions: [
|
|
283
|
+
{
|
|
284
|
+
targettedProperty: 'nestedProperty',
|
|
285
|
+
conditionType: 'equal',
|
|
286
|
+
conditionValue: 'newValue',
|
|
287
|
+
conditionTypeQualifier: ConditionTypeQualifier.IS,
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const conditionWithShareRule: IConditionShareRule = {
|
|
293
|
+
conditionType: ConditionTypeSingle.SHARE_RULE,
|
|
294
|
+
conditionTypeQualifier: ConditionTypeQualifier.IS,
|
|
295
|
+
targettedProperty: 'parentProperty',
|
|
296
|
+
rule: nestedShareRule,
|
|
297
|
+
};
|
|
275
298
|
*/
|
|
276
|
-
export interface
|
|
277
|
-
conditionType:
|
|
278
|
-
conditionValue:
|
|
299
|
+
export interface IConditionShareRule extends IConditionBase {
|
|
300
|
+
conditionType: ConditionTypeSingle.SHARE_RULE;
|
|
301
|
+
conditionValue: IShareRule;
|
|
279
302
|
}
|
|
280
303
|
//# sourceMappingURL=share-rule-models.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-rule-models.d.ts","sourceRoot":"","sources":["../../../src/models/rules/share-rule-models.ts"],"names":[],"mappings":"AACA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,UAAU,EAAE,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,wBAAwB,EAAE,UAAU,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB,EAAE,yBAAyB,EAAE,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,2BAA2B,EAAE,CAAC;IAC5C,eAAe,EAAE,OAAO,CAAC;CAC5B;AAMD;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"share-rule-models.d.ts","sourceRoot":"","sources":["../../../src/models/rules/share-rule-models.ts"],"names":[],"mappings":"AACA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,UAAU,EAAE,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,wBAAwB,EAAE,UAAU,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB,EAAE,yBAAyB,EAAE,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,2BAA2B,EAAE,CAAC;IAC5C,eAAe,EAAE,OAAO,CAAC;CAC5B;AAMD;;GA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AAC;IAC5C,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;CAChD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC5D,aAAa,EAAE,2BAA2B,CAAC;IAC3C,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAe,SAAQ,cAAc;IAClD,aAAa,EAAE,mBAAmB,CAAC,IAAI,CAAC;CAC3C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACrD,aAAa,EAAE,oBAAoB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACnD,aAAa,EAAE,mBAAmB,CAAC,KAAK,CAAC;CAC5C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACrD,aAAa,EAAE,oBAAoB,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACvD,aAAa,EAAE,mBAAmB,CAAC,UAAU,CAAC;IAC9C,cAAc,EAAE,UAAU,CAAC;CAC9B"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* This file contains the models for the rules used in the share data.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ConditionTypeOf = exports.
|
|
6
|
+
exports.ConditionTypeOf = exports.ConditionTypeSpecial = exports.ConditionTypeBoolean = exports.ConditionTypeStartsEndsWith = exports.ConditionTypeRange = exports.ConditionTypeSingle = exports.ConditionTypeQualifier = exports.LogicalOperator = void 0;
|
|
7
7
|
//#endregion RuleSet
|
|
8
8
|
//#region RuleGroup
|
|
9
9
|
/**
|
|
@@ -32,6 +32,7 @@ var ConditionTypeSingle;
|
|
|
32
32
|
ConditionTypeSingle["CONTAINS"] = "contains";
|
|
33
33
|
ConditionTypeSingle["NULL"] = "null";
|
|
34
34
|
ConditionTypeSingle["EMPTY"] = "empty";
|
|
35
|
+
ConditionTypeSingle["SHARE_RULE"] = "share-rule";
|
|
35
36
|
})(ConditionTypeSingle || (exports.ConditionTypeSingle = ConditionTypeSingle = {}));
|
|
36
37
|
/**
|
|
37
38
|
* This contains the choices for the range conditions.
|
|
@@ -66,13 +67,6 @@ var ConditionTypeSpecial;
|
|
|
66
67
|
(function (ConditionTypeSpecial) {
|
|
67
68
|
ConditionTypeSpecial["PATTERN"] = "pattern";
|
|
68
69
|
})(ConditionTypeSpecial || (exports.ConditionTypeSpecial = ConditionTypeSpecial = {}));
|
|
69
|
-
/**
|
|
70
|
-
* This contains the choices for the combined rule conditions that are a type of object
|
|
71
|
-
*/
|
|
72
|
-
var ConditionTypeCombinedRules;
|
|
73
|
-
(function (ConditionTypeCombinedRules) {
|
|
74
|
-
ConditionTypeCombinedRules["OBJECT"] = "object";
|
|
75
|
-
})(ConditionTypeCombinedRules || (exports.ConditionTypeCombinedRules = ConditionTypeCombinedRules = {}));
|
|
76
70
|
/**
|
|
77
71
|
* These are the different choices for the types of data in a condition.
|
|
78
72
|
*/
|
|
@@ -89,4 +83,11 @@ var ConditionTypeOf;
|
|
|
89
83
|
ConditionTypeOf["FUNCTION"] = "function";
|
|
90
84
|
ConditionTypeOf["BIGINT"] = "bigint";
|
|
91
85
|
})(ConditionTypeOf || (exports.ConditionTypeOf = ConditionTypeOf = {}));
|
|
86
|
+
// /**
|
|
87
|
+
// * This is the interface for the combined rule condition.
|
|
88
|
+
// */
|
|
89
|
+
// export interface IConditionCombinedRules extends IConditionBase {
|
|
90
|
+
// conditionType: ConditionTypeCombinedRules; // the type of condition to evaluate
|
|
91
|
+
// conditionValue: IShareRuleGroup; // the value to evaluate the condition against
|
|
92
|
+
// }
|
|
92
93
|
//#endregion Conditions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@degenerate/generic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"firebase-admin": "^12.7.0",
|
|
53
53
|
"firebase-functions": "^6.1.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ee9b867072cfce8557f51507ed7bbb66f77ae52b"
|
|
56
56
|
}
|