@magda/typescript-common 1.1.0-arm64.0 → 1.2.0-alpha.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/dist/AspectBuilder.d.ts +7 -0
- package/dist/AspectBuilder.js +3 -0
- package/dist/AspectBuilder.js.map +1 -0
- package/dist/AspectCreationFailure.d.ts +5 -0
- package/dist/AspectCreationFailure.js +10 -0
- package/dist/AspectCreationFailure.js.map +1 -0
- package/dist/AsyncPage.d.ts +18 -0
- package/dist/AsyncPage.js +140 -0
- package/dist/AsyncPage.js.map +1 -0
- package/dist/ConnectionResult.d.ts +16 -0
- package/dist/ConnectionResult.js +77 -0
- package/dist/ConnectionResult.js.map +1 -0
- package/dist/ConnectorRecordId.d.ts +15 -0
- package/dist/ConnectorRecordId.js +46 -0
- package/dist/ConnectorRecordId.js.map +1 -0
- package/dist/JsonConnector.d.ts +195 -0
- package/dist/JsonConnector.js +427 -0
- package/dist/JsonConnector.js.map +1 -0
- package/dist/JsonTransformer.d.ts +112 -0
- package/dist/JsonTransformer.js +225 -0
- package/dist/JsonTransformer.js.map +1 -0
- package/dist/OpaCompileResponseParser.d.ts +480 -0
- package/dist/OpaCompileResponseParser.js +1134 -0
- package/dist/OpaCompileResponseParser.js.map +1 -0
- package/dist/RecordCreationFailure.d.ts +7 -0
- package/dist/RecordCreationFailure.js +11 -0
- package/dist/RecordCreationFailure.js.map +1 -0
- package/dist/SimpleOpaSQLTranslator.d.ts +14 -0
- package/dist/SimpleOpaSQLTranslator.js +79 -0
- package/dist/SimpleOpaSQLTranslator.js.map +1 -0
- package/dist/addTrailingSlash.d.ts +1 -0
- package/dist/addTrailingSlash.js +15 -0
- package/dist/addTrailingSlash.js.map +1 -0
- package/dist/appendUrlSegments.d.ts +2 -0
- package/dist/appendUrlSegments.js +18 -0
- package/dist/appendUrlSegments.js.map +1 -0
- package/dist/authorization-api/AccessControlError.d.ts +4 -0
- package/dist/authorization-api/AccessControlError.js +13 -0
- package/dist/authorization-api/AccessControlError.js.map +1 -0
- package/dist/authorization-api/ApiClient.d.ts +141 -0
- package/dist/authorization-api/ApiClient.js +335 -0
- package/dist/authorization-api/ApiClient.js.map +1 -0
- package/dist/authorization-api/AuthError.d.ts +4 -0
- package/dist/authorization-api/AuthError.js +13 -0
- package/dist/authorization-api/AuthError.js.map +1 -0
- package/dist/authorization-api/GenericError.d.ts +9 -0
- package/dist/authorization-api/GenericError.js +17 -0
- package/dist/authorization-api/GenericError.js.map +1 -0
- package/dist/authorization-api/authMiddleware.d.ts +7 -0
- package/dist/authorization-api/authMiddleware.js +52 -0
- package/dist/authorization-api/authMiddleware.js.map +1 -0
- package/dist/authorization-api/model.d.ts +99 -0
- package/dist/authorization-api/model.js +3 -0
- package/dist/authorization-api/model.js.map +1 -0
- package/dist/coerceJson.d.ts +2 -0
- package/dist/coerceJson.js +13 -0
- package/dist/coerceJson.js.map +1 -0
- package/dist/createServiceError.d.ts +19 -0
- package/dist/createServiceError.js +45 -0
- package/dist/createServiceError.js.map +1 -0
- package/dist/delay.d.ts +2 -0
- package/dist/delay.js +9 -0
- package/dist/delay.js.map +1 -0
- package/dist/express/status.d.ts +30 -0
- package/dist/express/status.js +180 -0
- package/dist/express/status.js.map +1 -0
- package/dist/formatServiceError.d.ts +1 -0
- package/dist/formatServiceError.js +23 -0
- package/dist/formatServiceError.js.map +1 -0
- package/dist/generated/registry/api.d.ts +596 -0
- package/dist/generated/registry/api.js +2060 -0
- package/dist/generated/registry/api.js.map +1 -0
- package/dist/getAbsoluteUrl.d.ts +12 -0
- package/dist/getAbsoluteUrl.js +35 -0
- package/dist/getAbsoluteUrl.js.map +1 -0
- package/dist/getBasePathFromUrl.d.ts +10 -0
- package/dist/getBasePathFromUrl.js +27 -0
- package/dist/getBasePathFromUrl.js.map +1 -0
- package/dist/markdownToHtml.d.ts +3 -0
- package/dist/markdownToHtml.js +38 -0
- package/dist/markdownToHtml.js.map +1 -0
- package/dist/opa/OpaTypes.d.ts +41 -0
- package/dist/opa/OpaTypes.js +3 -0
- package/dist/opa/OpaTypes.js.map +1 -0
- package/dist/opa/getAuthDecision.d.ts +19 -0
- package/dist/opa/getAuthDecision.js +94 -0
- package/dist/opa/getAuthDecision.js.map +1 -0
- package/dist/opa/queryOpa.d.ts +1 -0
- package/dist/opa/queryOpa.js +41 -0
- package/dist/opa/queryOpa.js.map +1 -0
- package/dist/registry/AuthorizedRegistryClient.d.ts +29 -0
- package/dist/registry/AuthorizedRegistryClient.js +115 -0
- package/dist/registry/AuthorizedRegistryClient.js.map +1 -0
- package/dist/registry/RegistryClient.d.ts +36 -0
- package/dist/registry/RegistryClient.js +59 -0
- package/dist/registry/RegistryClient.js.map +1 -0
- package/dist/registry/TenantConsts.d.ts +31 -0
- package/dist/registry/TenantConsts.js +35 -0
- package/dist/registry/TenantConsts.js.map +1 -0
- package/dist/registry-manual/api.d.ts +9 -0
- package/dist/registry-manual/api.js +10 -0
- package/dist/registry-manual/api.js.map +1 -0
- package/dist/request.d.ts +3 -0
- package/dist/request.js +19 -0
- package/dist/request.js.map +1 -0
- package/dist/retry.d.ts +1 -0
- package/dist/retry.js +21 -0
- package/dist/retry.js.map +1 -0
- package/dist/retryBackoff.d.ts +1 -0
- package/dist/retryBackoff.js +21 -0
- package/dist/retryBackoff.js.map +1 -0
- package/dist/runLater.d.ts +1 -0
- package/dist/runLater.js +16 -0
- package/dist/runLater.js.map +1 -0
- package/dist/session/GetUserId.d.ts +5 -0
- package/dist/session/GetUserId.js +41 -0
- package/dist/session/GetUserId.js.map +1 -0
- package/dist/session/GetUserSession.d.ts +3 -0
- package/dist/session/GetUserSession.js +22 -0
- package/dist/session/GetUserSession.js.map +1 -0
- package/dist/session/addJwtSecretFromEnvVar.d.ts +14 -0
- package/dist/session/addJwtSecretFromEnvVar.js +23 -0
- package/dist/session/addJwtSecretFromEnvVar.js.map +1 -0
- package/dist/session/buildJwt.d.ts +1 -0
- package/dist/session/buildJwt.js +8 -0
- package/dist/session/buildJwt.js.map +1 -0
- package/dist/session/cookieUtils.d.ts +16 -0
- package/dist/session/cookieUtils.js +19 -0
- package/dist/session/cookieUtils.js.map +1 -0
- package/dist/session/destroySession.d.ts +10 -0
- package/dist/session/destroySession.js +44 -0
- package/dist/session/destroySession.js.map +1 -0
- package/dist/session/getSessionId.d.ts +2 -0
- package/dist/session/getSessionId.js +28 -0
- package/dist/session/getSessionId.js.map +1 -0
- package/dist/tenant-api/AuthorizedTenantClient.d.ts +25 -0
- package/dist/tenant-api/AuthorizedTenantClient.js +61 -0
- package/dist/tenant-api/AuthorizedTenantClient.js.map +1 -0
- package/dist/tenant-api/Tenant.d.ts +17 -0
- package/dist/tenant-api/Tenant.js +10 -0
- package/dist/tenant-api/Tenant.js.map +1 -0
- package/dist/test/JsonConnector.spec.d.ts +1 -0
- package/dist/test/JsonConnector.spec.js +352 -0
- package/dist/test/JsonConnector.spec.js.map +1 -0
- package/dist/test/JsonTransformer.spec.d.ts +1 -0
- package/dist/test/JsonTransformer.spec.js +98 -0
- package/dist/test/JsonTransformer.spec.js.map +1 -0
- package/dist/test/arbitraries.d.ts +98 -0
- package/dist/test/arbitraries.js +264 -0
- package/dist/test/arbitraries.js.map +1 -0
- package/dist/test/aspect-templates/organization-details.d.ts +4 -0
- package/dist/test/aspect-templates/organization-details.js +11 -0
- package/dist/test/aspect-templates/organization-details.js.map +1 -0
- package/dist/test/buildApiClient.spec.d.ts +1 -0
- package/dist/test/buildApiClient.spec.js +177 -0
- package/dist/test/buildApiClient.spec.js.map +1 -0
- package/dist/test/buildAuthorizedTenantClient.spec.d.ts +1 -0
- package/dist/test/buildAuthorizedTenantClient.spec.js +60 -0
- package/dist/test/buildAuthorizedTenantClient.spec.js.map +1 -0
- package/dist/test/connectors/MockExpressServer.d.ts +5 -0
- package/dist/test/connectors/MockExpressServer.js +28 -0
- package/dist/test/connectors/MockExpressServer.js.map +1 -0
- package/dist/test/connectors/MockRegistry.d.ts +7 -0
- package/dist/test/connectors/MockRegistry.js +93 -0
- package/dist/test/connectors/MockRegistry.js.map +1 -0
- package/dist/test/connectors/runConnectorTest.d.ts +5 -0
- package/dist/test/connectors/runConnectorTest.js +106 -0
- package/dist/test/connectors/runConnectorTest.js.map +1 -0
- package/dist/test/db/getTestDBConfig.d.ts +7 -0
- package/dist/test/db/getTestDBConfig.js +13 -0
- package/dist/test/db/getTestDBConfig.js.map +1 -0
- package/dist/test/db/runMigrationSql.d.ts +9 -0
- package/dist/test/db/runMigrationSql.js +82 -0
- package/dist/test/db/runMigrationSql.js.map +1 -0
- package/dist/test/express/status.spec.d.ts +1 -0
- package/dist/test/express/status.spec.js +160 -0
- package/dist/test/express/status.spec.js.map +1 -0
- package/dist/test/fakeArgv.d.ts +2 -0
- package/dist/test/fakeArgv.js +7 -0
- package/dist/test/fakeArgv.js.map +1 -0
- package/dist/test/getAuthDecision.spec.d.ts +1 -0
- package/dist/test/getAuthDecision.spec.js +22 -0
- package/dist/test/getAuthDecision.spec.js.map +1 -0
- package/dist/test/getBasePathFromUrl.spec.d.ts +1 -0
- package/dist/test/getBasePathFromUrl.spec.js +25 -0
- package/dist/test/getBasePathFromUrl.spec.js.map +1 -0
- package/dist/test/jsverify.d.ts +2 -0
- package/dist/test/jsverify.js +8 -0
- package/dist/test/jsverify.js.map +1 -0
- package/dist/test/mockAuthApiHost.d.ts +14 -0
- package/dist/test/mockAuthApiHost.js +174 -0
- package/dist/test/mockAuthApiHost.js.map +1 -0
- package/dist/test/mockAuthorization.d.ts +3 -0
- package/dist/test/mockAuthorization.js +24 -0
- package/dist/test/mockAuthorization.js.map +1 -0
- package/dist/test/mockTenantDataStore.d.ts +8 -0
- package/dist/test/mockTenantDataStore.js +41 -0
- package/dist/test/mockTenantDataStore.js.map +1 -0
- package/dist/test/mockUserDataStore.d.ts +11 -0
- package/dist/test/mockUserDataStore.js +56 -0
- package/dist/test/mockUserDataStore.js.map +1 -0
- package/dist/test/registry/buildAuthorizedClient.spec.d.ts +1 -0
- package/dist/test/registry/buildAuthorizedClient.spec.js +101 -0
- package/dist/test/registry/buildAuthorizedClient.spec.js.map +1 -0
- package/dist/test/sampleOpaResponse.json +480 -0
- package/dist/test/sampleOpaResponseSimple.json +173 -0
- package/dist/test/sampleOpaResponseUnconditionalTrue.json +193 -0
- package/dist/test/sampleOpaResponseUnconditionalTrueWithDefaultRule.json +303 -0
- package/dist/test/sampleOpaResponseWithDefaultRule.json +303 -0
- package/dist/test/session/buildJwt.spec.d.ts +1 -0
- package/dist/test/session/buildJwt.spec.js +50 -0
- package/dist/test/session/buildJwt.spec.js.map +1 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaGroupsAndOwnerTest.spec.d.ts +1 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaGroupsAndOwnerTest.spec.js +64 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaGroupsAndOwnerTest.spec.js.map +1 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaGroupsTest.spec.d.ts +1 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaGroupsTest.spec.js +52 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaGroupsTest.spec.js.map +1 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaOwnerTest.spec.d.ts +1 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaOwnerTest.spec.js +36 -0
- package/dist/test/session/buildJwtForRegistryEsriOpaOwnerTest.spec.js.map +1 -0
- package/dist/test/testAsyncPage.spec.d.ts +1 -0
- package/dist/test/testAsyncPage.spec.js +463 -0
- package/dist/test/testAsyncPage.spec.js.map +1 -0
- package/dist/test/testOpaCompileResponseParser.spec.d.ts +1 -0
- package/dist/test/testOpaCompileResponseParser.spec.js +148 -0
- package/dist/test/testOpaCompileResponseParser.spec.js.map +1 -0
- package/dist/test/util.d.ts +1 -0
- package/dist/test/util.js +8 -0
- package/dist/test/util.js.map +1 -0
- package/dist/util/arrayToMaybe.d.ts +2 -0
- package/dist/util/arrayToMaybe.js +8 -0
- package/dist/util/arrayToMaybe.js.map +1 -0
- package/dist/util/cleanOrgTitle.d.ts +1 -0
- package/dist/util/cleanOrgTitle.js +13 -0
- package/dist/util/cleanOrgTitle.js.map +1 -0
- package/dist/util/escapeRegExp.d.ts +2 -0
- package/dist/util/escapeRegExp.js +5 -0
- package/dist/util/escapeRegExp.js.map +1 -0
- package/dist/util/getMinikubeIP.d.ts +1 -0
- package/dist/util/getMinikubeIP.js +13 -0
- package/dist/util/getMinikubeIP.js.map +1 -0
- package/dist/util/isUuid.d.ts +2 -0
- package/dist/util/isUuid.js +6 -0
- package/dist/util/isUuid.js.map +1 -0
- package/dist/util/unionToThrowable.d.ts +1 -0
- package/dist/util/unionToThrowable.js +12 -0
- package/dist/util/unionToThrowable.js.map +1 -0
- package/dist/utilityTypes.d.ts +1 -0
- package/dist/utilityTypes.js +3 -0
- package/dist/utilityTypes.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
export declare type RegoValue = string | boolean | number | Array<any> | Object;
|
|
2
|
+
export interface RegoRuleOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
fullName: string;
|
|
5
|
+
isDefault: boolean;
|
|
6
|
+
value: RegoValue;
|
|
7
|
+
expressions: RegoExp[];
|
|
8
|
+
isCompleteEvaluated?: boolean;
|
|
9
|
+
parser: OpaCompileResponseParser;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @class RegoRule
|
|
13
|
+
* @export
|
|
14
|
+
*
|
|
15
|
+
* RegoRule represents [Rule](https://www.openpolicyagent.org/docs/latest/how-do-i-write-policies/#rules) concept in Rego language.
|
|
16
|
+
* - A simple rule is made up of Rule head, Rule value & Rule body
|
|
17
|
+
* - The Rule value defines the final result of the rule if the rule is matched (i.e. all expressions in rule body are true)
|
|
18
|
+
* - If you didn't sepcify the rule value, it will be assume as boolean value `true`
|
|
19
|
+
* - The rule body is made up of one of more rego expressions (see @class RegoExp) and each of the expression is made up of terms (see @class RegoTerm)
|
|
20
|
+
* - The rule is considered as matched if all expressions in rule body are `true`
|
|
21
|
+
* You can opt to define a `default` rule. A default rule has no rule body and will only considered as matched if all other rules are not matched.
|
|
22
|
+
*/
|
|
23
|
+
export declare class RegoRule {
|
|
24
|
+
/**
|
|
25
|
+
* the local name of the rule. i.e. doesn't include full package path
|
|
26
|
+
* e.g. `allow`
|
|
27
|
+
*
|
|
28
|
+
* @type {string}
|
|
29
|
+
* @memberof RegoRule
|
|
30
|
+
*/
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* Full name of the rule. Includes fulle package path
|
|
34
|
+
* e.g. `data.object.content.allowRead`
|
|
35
|
+
*
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @memberof RegoRule
|
|
38
|
+
*/
|
|
39
|
+
fullName: string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a rule is a default Rule
|
|
42
|
+
* Its value only be used if any other residual rules are not matched (or no other residual rules)
|
|
43
|
+
*
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
* @memberof RegoRule
|
|
46
|
+
*/
|
|
47
|
+
isDefault: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Rule value. Rule value is this value if all expression in rule body are true
|
|
50
|
+
* It can be any type. e.g. can be object or array etc. But a simple policy normally outputs a boolean true or false
|
|
51
|
+
*
|
|
52
|
+
* @type {RegoValue}
|
|
53
|
+
* @memberof RegoRule
|
|
54
|
+
*/
|
|
55
|
+
value: RegoValue;
|
|
56
|
+
/**
|
|
57
|
+
* All Rego expressions in this rule's rule body. @see RegoExp
|
|
58
|
+
*
|
|
59
|
+
* @type {RegoExp[]}
|
|
60
|
+
* @memberof RegoRule
|
|
61
|
+
*/
|
|
62
|
+
expressions: RegoExp[];
|
|
63
|
+
/**
|
|
64
|
+
* If the rule is matched or not
|
|
65
|
+
* Default to undefined
|
|
66
|
+
* Its value is only set when `isCompleteEvaluated` is true
|
|
67
|
+
*
|
|
68
|
+
* @type {boolean}
|
|
69
|
+
* @memberof RegoRule
|
|
70
|
+
*/
|
|
71
|
+
isMatched?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* If the rule is fully evaluate
|
|
74
|
+
* Default to false
|
|
75
|
+
*
|
|
76
|
+
* @type {boolean}
|
|
77
|
+
* @memberof RegoRule
|
|
78
|
+
*/
|
|
79
|
+
isCompleteEvaluated: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Reference to OpaParser
|
|
82
|
+
*
|
|
83
|
+
* @private
|
|
84
|
+
* @type {OpaCompileResponseParser}
|
|
85
|
+
* @memberof RegoRule
|
|
86
|
+
*/
|
|
87
|
+
private parser;
|
|
88
|
+
constructor(options: RegoRuleOptions);
|
|
89
|
+
clone(options?: Partial<RegoRuleOptions>): RegoRule;
|
|
90
|
+
/**
|
|
91
|
+
* Re-evaluate this rule
|
|
92
|
+
* If fully evaluated, this.isCompleteEvaluated will be set to true
|
|
93
|
+
*
|
|
94
|
+
* @returns
|
|
95
|
+
* @memberof RegoRule
|
|
96
|
+
*/
|
|
97
|
+
evaluate(): this;
|
|
98
|
+
/**
|
|
99
|
+
* Generate Human Readable string of this rule
|
|
100
|
+
* If it's fully evaluated, the output will be true or false (or actual rule value)
|
|
101
|
+
* Otherwise, will generate expressions concate with `AND`
|
|
102
|
+
*
|
|
103
|
+
* @returns {string}
|
|
104
|
+
* @memberof RegoRule
|
|
105
|
+
*/
|
|
106
|
+
toHumanReadableString(): string;
|
|
107
|
+
/**
|
|
108
|
+
* Create RegoRule from Opa response data
|
|
109
|
+
*
|
|
110
|
+
* @static
|
|
111
|
+
* @param {*} r
|
|
112
|
+
* @param {string} packageName
|
|
113
|
+
* @param {OpaCompileResponseParser} parser
|
|
114
|
+
* @returns {RegoRule}
|
|
115
|
+
* @memberof RegoRule
|
|
116
|
+
*/
|
|
117
|
+
static parseFromData(r: any, packageName: string, parser: OpaCompileResponseParser): RegoRule;
|
|
118
|
+
static createExpressionsFromRuleBodyData(data: any, parser: OpaCompileResponseParser): RegoExp[];
|
|
119
|
+
static randomRuleName(prefix: string): string;
|
|
120
|
+
static createFromValue(val: RegoValue, parser: OpaCompileResponseParser): RegoRule;
|
|
121
|
+
}
|
|
122
|
+
export interface RegoRefPart {
|
|
123
|
+
type: string;
|
|
124
|
+
value: string;
|
|
125
|
+
}
|
|
126
|
+
export declare const RegoOperators: {
|
|
127
|
+
[k: string]: string;
|
|
128
|
+
};
|
|
129
|
+
export declare type RegoTermValue = RegoRef | RegoValue;
|
|
130
|
+
/**
|
|
131
|
+
* RegoTerm represent the basic elements that creates an expressions.
|
|
132
|
+
* e.g. An expression `a > 4` is made up of 3 terms
|
|
133
|
+
* - Reference Term: `a`
|
|
134
|
+
* - Operator Term `>`
|
|
135
|
+
* - Value Term: `4`
|
|
136
|
+
*
|
|
137
|
+
* @export
|
|
138
|
+
* @class RegoTerm
|
|
139
|
+
*/
|
|
140
|
+
export declare class RegoTerm {
|
|
141
|
+
type: string;
|
|
142
|
+
value: RegoTermValue;
|
|
143
|
+
private parser;
|
|
144
|
+
constructor(type: string, value: RegoTermValue, parser: OpaCompileResponseParser);
|
|
145
|
+
clone(): RegoTerm;
|
|
146
|
+
/**
|
|
147
|
+
* If it's a reference term, return its full string representation
|
|
148
|
+
*
|
|
149
|
+
* @returns
|
|
150
|
+
* @memberof RegoTerm
|
|
151
|
+
*/
|
|
152
|
+
asString(): number | Object;
|
|
153
|
+
/**
|
|
154
|
+
* If it's a reference term. A operator is an Reference term as well
|
|
155
|
+
*
|
|
156
|
+
* @returns {boolean}
|
|
157
|
+
* @memberof RegoTerm
|
|
158
|
+
*/
|
|
159
|
+
isRef(): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Return RegoRef instance if this term is a RegoRef.
|
|
162
|
+
*
|
|
163
|
+
* @returns {RegoRef}
|
|
164
|
+
* @memberof RegoTerm
|
|
165
|
+
*/
|
|
166
|
+
getRef(): RegoRef;
|
|
167
|
+
/**
|
|
168
|
+
* If the term is a reference and it contains any collection lookup
|
|
169
|
+
* e.g.
|
|
170
|
+
* - objectA.propB.collectionC[_]
|
|
171
|
+
* - objectA.propB.collectionC[_].ABC[_].name
|
|
172
|
+
* - objectA.propB.collectionC[_].id
|
|
173
|
+
*
|
|
174
|
+
* @returns {boolean}
|
|
175
|
+
* @memberof RegoTerm
|
|
176
|
+
*/
|
|
177
|
+
hasCollectionLookup(): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* The term is not only a Reference but a reference contains simple collection lookup
|
|
180
|
+
* i.e. only contains one collection lookup and the whole ref ends with the only collection lookup
|
|
181
|
+
* e.g. objectA.propB.collectionC[_]
|
|
182
|
+
* Note: objectA.propB.collectionC[_].name is not a simple collection lookup as it resolve to single value (`name` property)
|
|
183
|
+
* rather than a collection
|
|
184
|
+
*
|
|
185
|
+
* @returns {boolean}
|
|
186
|
+
* @memberof RegoTerm
|
|
187
|
+
*/
|
|
188
|
+
isSimpleCollectionLookup(): boolean;
|
|
189
|
+
/**
|
|
190
|
+
*
|
|
191
|
+
*
|
|
192
|
+
* @returns {boolean}
|
|
193
|
+
* @memberof RegoTerm
|
|
194
|
+
*/
|
|
195
|
+
isResolveAsCollectionValue(): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* If it's a reference term, return its full string representation
|
|
198
|
+
* Otherwise, throw exception
|
|
199
|
+
*
|
|
200
|
+
* @param {string[]} [removalPrefixs=[]]
|
|
201
|
+
* @returns {string}
|
|
202
|
+
* @memberof RegoTerm
|
|
203
|
+
*/
|
|
204
|
+
fullRefString(removalPrefixs?: string[]): string;
|
|
205
|
+
/**
|
|
206
|
+
* If it's a reference term, return its string representation (not include ending [_])
|
|
207
|
+
* Otherwise, throw exception
|
|
208
|
+
*
|
|
209
|
+
* @param {string[]} [removalPrefixs=[]]
|
|
210
|
+
* @returns {string}
|
|
211
|
+
* @memberof RegoTerm
|
|
212
|
+
*/
|
|
213
|
+
refString(removalPrefixs?: string[]): string;
|
|
214
|
+
/**
|
|
215
|
+
* Return term as operator string e.g. `=`, `>=` etc.
|
|
216
|
+
*
|
|
217
|
+
* @returns {string}
|
|
218
|
+
* @memberof RegoTerm
|
|
219
|
+
*/
|
|
220
|
+
asOperator(): string;
|
|
221
|
+
/**
|
|
222
|
+
* If it's a operator term
|
|
223
|
+
*
|
|
224
|
+
* @returns {boolean}
|
|
225
|
+
* @memberof RegoTerm
|
|
226
|
+
*/
|
|
227
|
+
isOperator(): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Tried to determine the value of the term
|
|
230
|
+
*
|
|
231
|
+
* @returns {RegoValue}
|
|
232
|
+
* @memberof RegoTerm
|
|
233
|
+
*/
|
|
234
|
+
getValue(): RegoValue;
|
|
235
|
+
static parseFromData(data: any, parser: OpaCompileResponseParser): RegoTerm;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Represents Rego expression
|
|
239
|
+
*
|
|
240
|
+
* @export
|
|
241
|
+
* @class RegoExp
|
|
242
|
+
*/
|
|
243
|
+
export declare class RegoExp {
|
|
244
|
+
/**
|
|
245
|
+
* All RegoTerms belongs to this expression
|
|
246
|
+
*
|
|
247
|
+
* @type {RegoTerm[]}
|
|
248
|
+
* @memberof RegoExp
|
|
249
|
+
*/
|
|
250
|
+
terms: RegoTerm[];
|
|
251
|
+
/**
|
|
252
|
+
* Whether this expression is a negative expression
|
|
253
|
+
* i.e. it's final evaluation result should be `false` if result is `true`
|
|
254
|
+
*
|
|
255
|
+
* @type {boolean}
|
|
256
|
+
* @memberof RegoExp
|
|
257
|
+
*/
|
|
258
|
+
isNegated: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* If it's complete evaluated
|
|
261
|
+
*
|
|
262
|
+
* @type {boolean}
|
|
263
|
+
* @memberof RegoExp
|
|
264
|
+
*/
|
|
265
|
+
isCompleteEvaluated: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* The value of the expression
|
|
268
|
+
*
|
|
269
|
+
* @type {RegoValue}
|
|
270
|
+
* @memberof RegoExp
|
|
271
|
+
*/
|
|
272
|
+
value: RegoValue;
|
|
273
|
+
/**
|
|
274
|
+
* Ref to Opa Parser
|
|
275
|
+
*
|
|
276
|
+
* @private
|
|
277
|
+
* @type {OpaCompileResponseParser}
|
|
278
|
+
* @memberof RegoExp
|
|
279
|
+
*/
|
|
280
|
+
private parser;
|
|
281
|
+
constructor(terms: RegoTerm[], isNegated: boolean, isCompleteEvaluated: boolean, value: RegoValue, parser: OpaCompileResponseParser);
|
|
282
|
+
clone(): RegoExp;
|
|
283
|
+
/**
|
|
284
|
+
* For debug usage, print terms as easy to ready short string
|
|
285
|
+
*
|
|
286
|
+
* @returns
|
|
287
|
+
* @memberof RegoExp
|
|
288
|
+
*/
|
|
289
|
+
termsAsString(): (number | Object)[];
|
|
290
|
+
/**
|
|
291
|
+
* Output human readable string
|
|
292
|
+
*
|
|
293
|
+
* @returns {string}
|
|
294
|
+
* @memberof RegoExp
|
|
295
|
+
*/
|
|
296
|
+
toHumanReadableString(): string;
|
|
297
|
+
/**
|
|
298
|
+
* Try to determins its value
|
|
299
|
+
*
|
|
300
|
+
* @returns
|
|
301
|
+
* @memberof RegoExp
|
|
302
|
+
*/
|
|
303
|
+
getValue(): number | Object;
|
|
304
|
+
isMatch(): boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Convert operator term to string and put rest operands into an array.
|
|
307
|
+
* And then return a [Operator, Operands] structure
|
|
308
|
+
*
|
|
309
|
+
* @returns {[string, RegoTerm[]]}
|
|
310
|
+
* @memberof RegoExp
|
|
311
|
+
*/
|
|
312
|
+
toOperatorOperandsArray(): [string, RegoTerm[]];
|
|
313
|
+
/**
|
|
314
|
+
* Try to evaluate the expression
|
|
315
|
+
*
|
|
316
|
+
* @returns
|
|
317
|
+
* @memberof RegoExp
|
|
318
|
+
*/
|
|
319
|
+
evaluate(): this;
|
|
320
|
+
static parseFromData(expData: any, parser: OpaCompileResponseParser): RegoExp;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Represents a special Rego Term type: reference term
|
|
324
|
+
* You shouldn't use this class directly
|
|
325
|
+
*
|
|
326
|
+
* @export
|
|
327
|
+
* @class RegoRef
|
|
328
|
+
*/
|
|
329
|
+
export declare class RegoRef {
|
|
330
|
+
parts: RegoRefPart[];
|
|
331
|
+
constructor(parts: RegoRefPart[]);
|
|
332
|
+
clone(): RegoRef;
|
|
333
|
+
static parseFromData(data: any): RegoRef;
|
|
334
|
+
static convertToFullRefString(parts: RegoRefPart[]): string;
|
|
335
|
+
removeAllPrefixs(str: string, removalPrefixs?: string[]): string;
|
|
336
|
+
fullRefString(removalPrefixs?: string[]): string;
|
|
337
|
+
refString(removalPrefixs?: string[]): string;
|
|
338
|
+
asCollectionRefs(removalPrefixs?: string[]): string[];
|
|
339
|
+
isOperator(): boolean;
|
|
340
|
+
hasCollectionLookup(): boolean;
|
|
341
|
+
isSimpleCollectionLookup(): boolean;
|
|
342
|
+
isResolveAsCollectionValue(): boolean;
|
|
343
|
+
asOperator(): string;
|
|
344
|
+
}
|
|
345
|
+
export interface CompleteRuleResult {
|
|
346
|
+
fullName: string;
|
|
347
|
+
name: string;
|
|
348
|
+
value: RegoValue;
|
|
349
|
+
isCompleteEvaluated: boolean;
|
|
350
|
+
residualRules?: RegoRule[];
|
|
351
|
+
}
|
|
352
|
+
export declare function value2String(value: RegoValue): string;
|
|
353
|
+
/**
|
|
354
|
+
* OPA result Parser
|
|
355
|
+
*
|
|
356
|
+
* @export
|
|
357
|
+
* @class OpaCompileResponseParser
|
|
358
|
+
*/
|
|
359
|
+
export default class OpaCompileResponseParser {
|
|
360
|
+
/**
|
|
361
|
+
* If a warning is produced during the parsing
|
|
362
|
+
*
|
|
363
|
+
* @type {boolean}
|
|
364
|
+
* @memberof OpaCompileResponseParser
|
|
365
|
+
*/
|
|
366
|
+
hasWarns: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Any warnings produced during the parsing
|
|
369
|
+
*
|
|
370
|
+
* @type {string[]}
|
|
371
|
+
* @memberof OpaCompileResponseParser
|
|
372
|
+
*/
|
|
373
|
+
warns: string[];
|
|
374
|
+
private data;
|
|
375
|
+
/**
|
|
376
|
+
* Inital Rules parsed from result
|
|
377
|
+
* Only for debug purpose
|
|
378
|
+
*
|
|
379
|
+
* @type {RegoRule[]}
|
|
380
|
+
* @memberof OpaCompileResponseParser
|
|
381
|
+
*/
|
|
382
|
+
originalRules: RegoRule[];
|
|
383
|
+
/**
|
|
384
|
+
* Parsed, compressed & evaluated rules
|
|
385
|
+
*
|
|
386
|
+
* @type {RegoRule[]}
|
|
387
|
+
* @memberof OpaCompileResponseParser
|
|
388
|
+
*/
|
|
389
|
+
rules: RegoRule[];
|
|
390
|
+
queries: RegoExp[];
|
|
391
|
+
/**
|
|
392
|
+
* A cache of all resolved rule result
|
|
393
|
+
*
|
|
394
|
+
* @type {{
|
|
395
|
+
* [fullName: string]: CompleteRuleResult;
|
|
396
|
+
* }}
|
|
397
|
+
* @memberof OpaCompileResponseParser
|
|
398
|
+
*/
|
|
399
|
+
completeRuleResults: {
|
|
400
|
+
[fullName: string]: CompleteRuleResult;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* The pseudo query rule name
|
|
404
|
+
* The parser will assign a random pseudo rule name to the query expressions you submit.
|
|
405
|
+
*
|
|
406
|
+
* @type {string}
|
|
407
|
+
* @memberof OpaCompileResponseParser
|
|
408
|
+
*/
|
|
409
|
+
readonly pseudoQueryRuleName: string;
|
|
410
|
+
private setQueryRuleResult;
|
|
411
|
+
/**
|
|
412
|
+
* Parse OPA result Response
|
|
413
|
+
*
|
|
414
|
+
* @param {*} json
|
|
415
|
+
* @returns {RegoRule[]}
|
|
416
|
+
* @memberof OpaCompileResponseParser
|
|
417
|
+
*/
|
|
418
|
+
parse(json: any): RegoRule[];
|
|
419
|
+
/**
|
|
420
|
+
* Tried to merge rules outcome so that the ref value can be established easier
|
|
421
|
+
* After this step, any rules doesn't involve unknown should be merged to one value
|
|
422
|
+
* This will help to generate more concise query later.
|
|
423
|
+
* `CompleteRule` rule involves no `unknowns`
|
|
424
|
+
*
|
|
425
|
+
* Only for internal usage
|
|
426
|
+
*
|
|
427
|
+
* @private
|
|
428
|
+
* @memberof OpaCompileResponseParser
|
|
429
|
+
*/
|
|
430
|
+
private calculateCompleteRuleResult;
|
|
431
|
+
/**
|
|
432
|
+
* Only for internal usage
|
|
433
|
+
*
|
|
434
|
+
* @returns
|
|
435
|
+
* @private
|
|
436
|
+
* @memberof OpaCompileResponseParser
|
|
437
|
+
*/
|
|
438
|
+
private reduceDependencies;
|
|
439
|
+
/**
|
|
440
|
+
* Call to evaluate a rule
|
|
441
|
+
*
|
|
442
|
+
* @param {string} fullName
|
|
443
|
+
* @returns {CompleteRuleResult}
|
|
444
|
+
* @memberof OpaCompileResponseParser
|
|
445
|
+
*/
|
|
446
|
+
evaluateRule(fullName: string): CompleteRuleResult | null;
|
|
447
|
+
/**
|
|
448
|
+
* Shortcut to evalute query result directly
|
|
449
|
+
*
|
|
450
|
+
* @returns {CompleteRuleResult}
|
|
451
|
+
* @memberof OpaCompileResponseParser
|
|
452
|
+
*/
|
|
453
|
+
evaluate(): CompleteRuleResult;
|
|
454
|
+
/**
|
|
455
|
+
* evaluate a rule and returned as human readable string
|
|
456
|
+
*
|
|
457
|
+
* @param {string} fullName
|
|
458
|
+
* @returns {string}
|
|
459
|
+
* @memberof OpaCompileResponseParser
|
|
460
|
+
*/
|
|
461
|
+
evaluateRuleAsHumanReadableString(fullName: string): string;
|
|
462
|
+
/**
|
|
463
|
+
* Shortcut to evalute query result directly and returned as human readable string
|
|
464
|
+
*
|
|
465
|
+
* @returns {string}
|
|
466
|
+
* @memberof OpaCompileResponseParser
|
|
467
|
+
*/
|
|
468
|
+
evaluateAsHumanReadableString(): string;
|
|
469
|
+
/**
|
|
470
|
+
* Only for internal usage
|
|
471
|
+
*
|
|
472
|
+
* @param {RegoRule} rule
|
|
473
|
+
* @returns {CompleteRuleResult}
|
|
474
|
+
* @private
|
|
475
|
+
* @memberof OpaCompileResponseParser
|
|
476
|
+
*/
|
|
477
|
+
private createCompleteRuleResult;
|
|
478
|
+
reportWarns(msg: string): void;
|
|
479
|
+
}
|
|
480
|
+
export declare function unknown2Ref(unknown: string): string;
|