@queue-it/fastly 2.0.2 → 2.0.3-beta.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/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export {IntegrationDetails, IntegrationEndpointProvider, IntegrationEndpointCacheConfig, resolveIntegrationDetails} from "./integrationConfigProvider"
2
- export {onQueueITRequest, onQueueITResponse} from "./requestResponseHandler";
3
- export {RequestLogger} from "./helper";
1
+ export {IntegrationDetails, IntegrationEndpointProvider, IntegrationEndpointCacheConfig, resolveIntegrationDetails} from "./integrationConfigProvider"
2
+ export {onQueueITRequest, onQueueITResponse} from "./requestResponseHandler";
3
+ export {RequestLogger} from "./helper";
@@ -1,3 +1,4 @@
1
+ import { ConfigStore } from "fastly:config-store";
1
2
  import { RequestLogger } from "./helper";
2
3
 
3
4
  export async function getIntegrationConfig(
@@ -1,131 +1,129 @@
1
- import { KnownUser } from "./sdk/KnownUser";
2
- import { QueueITHelper } from "./helper";
3
- import { FastlyHttpContextProvider, getHttpHandler } from "./contextProvider";
4
- import {
5
- getIntegrationConfig,
6
- resolveIntegrationDetails,
7
- IntegrationDetails,
8
- QueueItIntegrationEndpointProvider,
9
- } from "./integrationConfigProvider";
10
- import { Utils } from "./sdk/QueueITHelpers";
11
-
12
- const QUEUEIT_FAILED_HEADERNAME = "x-queueit-failed";
13
- let httpProvider: FastlyHttpContextProvider | null = null;
14
-
15
- export async function onQueueITRequest(
16
- req: Request,
17
- conf: IntegrationDetails | null = null
18
- ): Promise<Response | null> {
19
- if (conf == null) {
20
- conf = resolveIntegrationDetails();
21
- }
22
- if (conf == null) {
23
- return new Response("No integration details found.", {
24
- headers: new Headers(),
25
- status: 404,
26
- });
27
- }
28
-
29
- const integrationProvider =
30
- conf.provider == null
31
- ? new QueueItIntegrationEndpointProvider()
32
- : conf.provider;
33
- QueueITHelper.configureKnownUserHashing();
34
- httpProvider = getHttpHandler(req);
35
-
36
- let integrationConfigJson = await getIntegrationConfig(conf, integrationProvider);
37
- const requestUrl: string = conf.resolveWorkerRequestUrl(req.url);
38
-
39
- const queueItToken = Utils.getParameterByName(
40
- requestUrl,
41
- KnownUser.QueueITTokenKey
42
- );
43
- const requestUrlWithoutToken: string = Utils.removeQueueItToken(requestUrl);
44
-
45
- // The requestUrlWithoutToken is used to match Triggers and as the Target url (where to return the users to).
46
- // It is therefor important that this is exactly the url of the users browsers. So, if your webserver is
47
- // behind e.g. a load balancer that modifies the host name or port, reformat requestUrlWithoutToken before proceeding.
48
- const validationResultPair = KnownUser.validateRequestByIntegrationConfig(
49
- requestUrlWithoutToken,
50
- queueItToken,
51
- integrationConfigJson,
52
- conf.customerId,
53
- conf.secretKey,
54
- httpProvider!
55
- );
56
-
57
- if (
58
- validationResultPair.first != null &&
59
- validationResultPair.first!.doRedirect()
60
- ) {
61
- const validationResult = validationResultPair.first!;
62
-
63
- if (validationResult.isAjaxResult) {
64
- let response = new Response(null, {
65
- status: 200,
66
- headers: httpProvider!.getHttpResponse().getHeaders(),
67
- });
68
- // In case of ajax call send the user to the queue by sending a custom queue-it header and redirecting user to queue from javascript
69
- response.headers.set("Access-Control-Expose-Headers", validationResult.getAjaxQueueRedirectHeaderKey());
70
- response.headers.set(
71
- validationResult.getAjaxQueueRedirectHeaderKey(),
72
- QueueITHelper.addKUPlatformVersion(
73
- validationResult.getAjaxRedirectUrl()
74
- )
75
- );
76
- Utils.addNoCacheHeaders(response);
77
- return response;
78
- } else {
79
- let response = new Response(null, {
80
- status: 302,
81
- headers: httpProvider!.getHttpResponse().getHeaders(),
82
- });
83
- // Send the user to the queue - either because hash was missing or because is was invalid
84
- response.headers.set(
85
- "Location",
86
- QueueITHelper.addKUPlatformVersion(validationResult.redirectUrl)
87
- );
88
- Utils.addNoCacheHeaders(response);
89
- return response;
90
- }
91
- } else if (validationResultPair.first != null) {
92
- const validationResult = validationResultPair.first!;
93
- // Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token
94
- // Support mobile scenario adding the condition !validationResult.isAjaxResult
95
- if (
96
- queueItToken != "" &&
97
- !validationResult.isAjaxResult &&
98
- validationResult.actionType == "Queue"
99
- ) {
100
- let response = new Response(null, {
101
- status: 302,
102
- headers: httpProvider!.getHttpResponse().getHeaders(),
103
- });
104
- response.headers.set("Location", requestUrlWithoutToken);
105
- Utils.addNoCacheHeaders(response);
106
- return response;
107
- } else {
108
- // lets caller decide the next step, or just serve the request normally
109
- return null;
110
- }
111
- } else if (validationResultPair.second != null) {
112
- httpProvider!.isError = true;
113
- }
114
-
115
- return null;
116
- }
117
-
118
- //Fill in the Queue-it headers
119
- export function onQueueITResponse(res: Response): void {
120
- const contextHeaders = httpProvider!.getHttpResponse().getHeaders();
121
-
122
- if (httpProvider!.isError) {
123
- res.headers.append(QUEUEIT_FAILED_HEADERNAME, "true");
124
- }
125
- for (const key of contextHeaders.keys()) {
126
- if (key.length == 0) continue;
127
- const value = contextHeaders.get(key);
128
- if (value != null && value.length > 0)
129
- res.headers.append(key, value);
130
- }
131
- }
1
+ import { KnownUser, Utils } from "@queue-it/connector-javascript";
2
+ import { QueueITHelper } from "./helper";
3
+ import { FastlyHttpContextProvider, getHttpHandler } from "./contextProvider";
4
+ import {
5
+ getIntegrationConfig,
6
+ resolveIntegrationDetails,
7
+ IntegrationDetails,
8
+ QueueItIntegrationEndpointProvider,
9
+ } from "./integrationConfigProvider";
10
+
11
+ const QUEUEIT_FAILED_HEADERNAME = "x-queueit-failed";
12
+ let httpProvider: FastlyHttpContextProvider | null = null;
13
+
14
+ export async function onQueueITRequest(
15
+ req: Request,
16
+ conf: IntegrationDetails | null = null
17
+ ): Promise<Response | null> {
18
+ if (conf == null) {
19
+ conf = resolveIntegrationDetails();
20
+ }
21
+ if (conf == null) {
22
+ return new Response("No integration details found.", {
23
+ headers: new Headers(),
24
+ status: 404,
25
+ });
26
+ }
27
+
28
+ const integrationProvider =
29
+ conf.provider == null
30
+ ? new QueueItIntegrationEndpointProvider()
31
+ : conf.provider;
32
+ httpProvider = getHttpHandler(req);
33
+
34
+ let integrationConfigJson = await getIntegrationConfig(conf, integrationProvider);
35
+ const requestUrl: string = conf.resolveWorkerRequestUrl(req.url);
36
+
37
+ const queueItToken = Utils.getParameterByName(
38
+ requestUrl,
39
+ KnownUser.QueueITTokenKey
40
+ );
41
+ const requestUrlWithoutToken: string = Utils.removeQueueItToken(requestUrl);
42
+
43
+ // The requestUrlWithoutToken is used to match Triggers and as the Target url (where to return the users to).
44
+ // It is therefor important that this is exactly the url of the users browsers. So, if your webserver is
45
+ // behind e.g. a load balancer that modifies the host name or port, reformat requestUrlWithoutToken before proceeding.
46
+ const validationResultPair = KnownUser.validateRequestByIntegrationConfig(
47
+ requestUrlWithoutToken,
48
+ queueItToken,
49
+ integrationConfigJson,
50
+ conf.customerId,
51
+ conf.secretKey,
52
+ httpProvider!
53
+ );
54
+
55
+ if (
56
+ validationResultPair.first != null &&
57
+ validationResultPair.first!.doRedirect()
58
+ ) {
59
+ const validationResult = validationResultPair.first!;
60
+
61
+ if (validationResult.isAjaxResult) {
62
+ let response = new Response(null, {
63
+ status: 200,
64
+ headers: httpProvider!.getHttpResponse().getHeaders(),
65
+ });
66
+ // In case of ajax call send the user to the queue by sending a custom queue-it header and redirecting user to queue from javascript
67
+ response.headers.set("Access-Control-Expose-Headers", validationResult.getAjaxQueueRedirectHeaderKey());
68
+ response.headers.set(
69
+ validationResult.getAjaxQueueRedirectHeaderKey(),
70
+ QueueITHelper.addKUPlatformVersion(
71
+ validationResult.getAjaxRedirectUrl()
72
+ )
73
+ );
74
+ Utils.addNoCacheHeaders(response);
75
+ return response;
76
+ } else {
77
+ let response = new Response(null, {
78
+ status: 302,
79
+ headers: httpProvider!.getHttpResponse().getHeaders(),
80
+ });
81
+ // Send the user to the queue - either because hash was missing or because is was invalid
82
+ response.headers.set(
83
+ "Location",
84
+ QueueITHelper.addKUPlatformVersion(validationResult.redirectUrl)
85
+ );
86
+ Utils.addNoCacheHeaders(response);
87
+ return response;
88
+ }
89
+ } else if (validationResultPair.first != null) {
90
+ const validationResult = validationResultPair.first!;
91
+ // Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token
92
+ // Support mobile scenario adding the condition !validationResult.isAjaxResult
93
+ if (
94
+ queueItToken != "" &&
95
+ !validationResult.isAjaxResult &&
96
+ validationResult.actionType == "Queue"
97
+ ) {
98
+ let response = new Response(null, {
99
+ status: 302,
100
+ headers: httpProvider!.getHttpResponse().getHeaders(),
101
+ });
102
+ response.headers.set("Location", requestUrlWithoutToken);
103
+ Utils.addNoCacheHeaders(response);
104
+ return response;
105
+ } else {
106
+ // lets caller decide the next step, or just serve the request normally
107
+ return null;
108
+ }
109
+ } else if (validationResultPair.second != null) {
110
+ httpProvider!.isError = true;
111
+ }
112
+
113
+ return null;
114
+ }
115
+
116
+ //Fill in the Queue-it headers
117
+ export function onQueueITResponse(res: Response): void {
118
+ const contextHeaders = httpProvider!.getHttpResponse().getHeaders();
119
+
120
+ if (httpProvider!.isError) {
121
+ res.headers.append(QUEUEIT_FAILED_HEADERNAME, "true");
122
+ }
123
+ for (const key of contextHeaders.keys()) {
124
+ if (key.length == 0) continue;
125
+ const value = contextHeaders.get(key);
126
+ if (value != null && value.length > 0)
127
+ res.headers.append(key, value);
128
+ }
129
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Queue-it
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,23 +0,0 @@
1
-
2
- export interface IHttpRequest {
3
- getUserAgent(): string;
4
- getHeader(name: string): string;
5
- getAbsoluteUri(): string;
6
- getUserHostAddress(): string;
7
- getCookieValue(cookieKey: string): string;
8
- getRequestBodyAsString(): string;
9
- }
10
-
11
- export interface IHttpResponse {
12
- setCookie(cookieName: string, cookieValue: string, domain: string, expiration: number): void;
13
- getHeaders(): Headers;
14
- }
15
-
16
- export interface IHttpContextProvider {
17
- getHttpRequest(): IHttpRequest;
18
- getHttpResponse(): IHttpResponse;
19
- }
20
-
21
- export interface IDateTimeProvider {
22
- getCurrentTime(): Date
23
- }
@@ -1,57 +0,0 @@
1
- import {
2
- CustomerIntegration,
3
- IntegrationConfigModel,
4
- TriggerModel,
5
- TriggerPart
6
- } from "./IntegrationConfigModel";
7
-
8
- export class CustomerIntegrationDecodingHandler {
9
- static deserialize(integrationsConfigString: string): CustomerIntegration {
10
- const result = new CustomerIntegration();
11
- if (!integrationsConfigString) return result;
12
-
13
- const parsed = JSON.parse(integrationsConfigString);
14
- result.Version = parsed.Version ?? 0;
15
- result.Description = parsed.Description ?? '';
16
-
17
- if (Array.isArray(parsed.Integrations)) {
18
- result.Integrations = parsed.Integrations.map((item: any) => {
19
- const model = new IntegrationConfigModel();
20
- model.Name = item.Name ?? '';
21
- model.EventId = item.EventId ?? '';
22
- model.CookieDomain = item.CookieDomain ?? '';
23
- model.LayoutName = item.LayoutName ?? '';
24
- model.Culture = item.Culture ?? '';
25
- model.ExtendCookieValidity = item.ExtendCookieValidity ?? false;
26
- model.CookieValidityMinute = item.CookieValidityMinute ?? 0;
27
- model.QueueDomain = item.QueueDomain ?? '';
28
- model.RedirectLogic = item.RedirectLogic ?? '';
29
- model.ForcedTargetUrl = item.ForcedTargetUrl ?? '';
30
- model.ActionType = item.ActionType ?? '';
31
-
32
- model.Triggers = (item.Triggers ?? []).map((trigger: any) => {
33
- const t = new TriggerModel();
34
- t.LogicalOperator = trigger.LogicalOperator ?? '';
35
- t.TriggerParts = (trigger.TriggerParts ?? []).map((part: any) => {
36
- const tp = new TriggerPart();
37
- tp.ValidatorType = part.ValidatorType ?? '';
38
- tp.Operator = part.Operator ?? '';
39
- tp.ValueToCompare = part.ValueToCompare ?? '';
40
- tp.ValuesToCompare = part.ValuesToCompare ?? [];
41
- tp.IsNegative = part.IsNegative ?? false;
42
- tp.IsIgnoreCase = part.IsIgnoreCase ?? false;
43
- tp.UrlPart = part.UrlPart ?? '';
44
- tp.CookieName = part.CookieName ?? '';
45
- tp.HttpHeaderName = part.HttpHeaderName ?? '';
46
- return tp;
47
- });
48
- return t;
49
- });
50
-
51
- return model;
52
- });
53
- }
54
-
55
- return result;
56
- }
57
- }
@@ -1,230 +0,0 @@
1
- import * as IntegrationModels from './IntegrationConfigModel'
2
- import {KnownUserException} from '../Models'
3
- import {IHttpRequest} from '../HttpContextProvider'
4
-
5
- export interface IIntegrationEvaluator {
6
- getMatchedIntegrationConfig(
7
- customerIntegration: IntegrationModels.CustomerIntegration,
8
- currentPageUrl: string,
9
- request: IHttpRequest): IntegrationModels.IntegrationConfigModelResult | null;
10
- }
11
-
12
- export class IntegrationEvaluator implements IIntegrationEvaluator {
13
- public getMatchedIntegrationConfig(
14
- customerIntegration: IntegrationModels.CustomerIntegration,
15
- currentPageUrl: string,
16
- request: IHttpRequest | null): IntegrationModels.IntegrationConfigModelResult | null {
17
-
18
- if (request == null)
19
- return new IntegrationModels.IntegrationConfigModelResult(null, new KnownUserException("request is null"));
20
-
21
- if (customerIntegration == null)
22
- return new IntegrationModels.IntegrationConfigModelResult(null, new KnownUserException("customerIntegration is null"));
23
-
24
- for (let i = 0; i < customerIntegration.Integrations.length; i++) {
25
- let integration = customerIntegration.Integrations[i];
26
- for (let t = 0; t < integration.Triggers.length; t++) {
27
- let trigger = integration.Triggers[t];
28
- if (this.evaluateTrigger(trigger, currentPageUrl, request)) {
29
- return new IntegrationModels.IntegrationConfigModelResult(integration, null);
30
- }
31
- }
32
- }
33
- return null;
34
- }
35
-
36
- private evaluateTrigger(trigger: IntegrationModels.TriggerModel, currentPageUrl: string, request: IHttpRequest): boolean {
37
- if (trigger.LogicalOperator == IntegrationModels.LogicalOperatorType.Or) {
38
- for (let i = 0; i < trigger.TriggerParts.length; i++) {
39
- let part = trigger.TriggerParts[i];
40
- if (this.evaluateTriggerPart(part, currentPageUrl, request))
41
- return true;
42
- }
43
- return false;
44
- } else {
45
- for (let i = 0; i < trigger.TriggerParts.length; i++) {
46
- let part = trigger.TriggerParts[i];
47
- let matched = this.evaluateTriggerPart(part, currentPageUrl, request);
48
- if (!matched)
49
- return false;
50
- }
51
- return true;
52
- }
53
- }
54
-
55
- private evaluateTriggerPart(triggerPart: IntegrationModels.TriggerPart, currentPageUrl: string, request: IHttpRequest): boolean {
56
- if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.UrlValidator) {
57
- return UrlValidatorHelper.evaluate(triggerPart, currentPageUrl);
58
- } else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.CookieValidator) {
59
- return CookieValidatorHelper.evaluate(triggerPart, request);
60
- } else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.UserAgentValidator) {
61
- return UserAgentValidatorHelper.evaluate(triggerPart, request.getUserAgent());
62
- } else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.HttpHeaderValidator) {
63
- return HttpHeaderValidatorHelper.evaluate(triggerPart, request.getHeader(triggerPart.HttpHeaderName));
64
- } else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.RequestBodyValidator) {
65
- return RequestBodyValidatorHelper.evaluate(triggerPart, request.getRequestBodyAsString());
66
- } else {
67
- return false;
68
- }
69
- }
70
- }
71
-
72
- export class UrlValidatorHelper {
73
- public static evaluate(triggerPart: IntegrationModels.TriggerPart, url: string): boolean {
74
- let urlpart = this.getUrlPart(triggerPart, url);
75
- return ComparisonOperatorHelper.evaluate(
76
- triggerPart.Operator,
77
- triggerPart.IsNegative,
78
- triggerPart.IsIgnoreCase,
79
- urlpart,
80
- triggerPart.ValueToCompare,
81
- triggerPart.ValuesToCompare);
82
- }
83
-
84
- private static getUrlPart(triggerPart: IntegrationModels.TriggerPart, url: string): string {
85
- if (triggerPart.UrlPart == IntegrationModels.UrlPartType.PagePath) {
86
- return this.getPathFromUrl(url);
87
- } else if (triggerPart.UrlPart == IntegrationModels.UrlPartType.PageUrl) {
88
- return url;
89
- } else if (triggerPart.UrlPart == IntegrationModels.UrlPartType.HostName) {
90
- return this.getHostNameFromUrl(url);
91
- } else {
92
- return "";
93
- }
94
- }
95
-
96
- public static getHostNameFromUrl(url: string): string {
97
- let urlx = new URL(url);
98
- return urlx.host;
99
- }
100
-
101
- public static getPathFromUrl(url: string): string {
102
- let urlx = new URL(url);
103
- return urlx.pathname;
104
- }
105
- }
106
-
107
- export class CookieValidatorHelper {
108
- public static evaluate(triggerPart: IntegrationModels.TriggerPart, request: IHttpRequest): boolean {
109
- return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
110
- triggerPart.IsNegative,
111
- triggerPart.IsIgnoreCase,
112
- this.getCookie(triggerPart.CookieName, request),
113
- triggerPart.ValueToCompare,
114
- triggerPart.ValuesToCompare);
115
- }
116
-
117
- private static getCookie(cookieName: string, request: IHttpRequest): string {
118
- return request.getCookieValue(cookieName);
119
- }
120
- }
121
-
122
- export class UserAgentValidatorHelper {
123
- public static evaluate(triggerPart: IntegrationModels.TriggerPart, userAgent: string): boolean {
124
-
125
- return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
126
- triggerPart.IsNegative,
127
- triggerPart.IsIgnoreCase,
128
- userAgent,
129
- triggerPart.ValueToCompare,
130
- triggerPart.ValuesToCompare);
131
- }
132
- }
133
-
134
- export class RequestBodyValidatorHelper {
135
- public static evaluate(triggerPart: IntegrationModels.TriggerPart, bodyString: string): boolean {
136
-
137
- return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
138
- triggerPart.IsNegative,
139
- triggerPart.IsIgnoreCase,
140
- bodyString,
141
- triggerPart.ValueToCompare,
142
- triggerPart.ValuesToCompare);
143
- }
144
- }
145
-
146
- export class HttpHeaderValidatorHelper {
147
- public static evaluate(triggerPart: IntegrationModels.TriggerPart, headerValue: string): boolean {
148
- return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
149
- triggerPart.IsNegative,
150
- triggerPart.IsIgnoreCase,
151
- headerValue,
152
- triggerPart.ValueToCompare,
153
- triggerPart.ValuesToCompare);
154
- }
155
- }
156
-
157
- export class ComparisonOperatorHelper {
158
- public static evaluate(opt: string,
159
- isNegative: boolean,
160
- isIgnoreCase: boolean,
161
- value: string,
162
- valueToCompare: string,
163
- valuesToCompare: Array<string> | null): boolean {
164
- if (valuesToCompare == null) {
165
- valuesToCompare = new Array<string>();
166
- }
167
- if (opt == IntegrationModels.ComparisonOperatorType.EqualS) {
168
- return ComparisonOperatorHelper.equalS(value, valueToCompare, isNegative, isIgnoreCase);
169
- } else if (opt == IntegrationModels.ComparisonOperatorType.Contains) {
170
- return ComparisonOperatorHelper.contains(value, valueToCompare, isNegative, isIgnoreCase);
171
- } else if (opt == IntegrationModels.ComparisonOperatorType.EqualsAny) {
172
- return ComparisonOperatorHelper.equalsAny(value, valuesToCompare, isNegative, isIgnoreCase);
173
- } else if (opt == IntegrationModels.ComparisonOperatorType.ContainsAny) {
174
- return ComparisonOperatorHelper.containsAny(value, valuesToCompare, isNegative, isIgnoreCase);
175
- } else {
176
- return false;
177
- }
178
- }
179
-
180
- private static contains(value: string, valueToCompare: string, isNegative: boolean, ignoreCase: boolean): boolean {
181
- if (valueToCompare == "*" && value != "")
182
- return true;
183
-
184
- let evaluation = false;
185
-
186
- if (ignoreCase)
187
- evaluation = value.toUpperCase().indexOf(valueToCompare.toUpperCase()) != -1;
188
- else
189
- evaluation = value.indexOf(valueToCompare) != -1;
190
-
191
- if (isNegative)
192
- return !evaluation;
193
- else
194
- return evaluation;
195
- }
196
-
197
- private static equalS(value: string, valueToCompare: string, isNegative: boolean, ignoreCase: boolean): boolean {
198
- let evaluation = false;
199
-
200
- if (ignoreCase)
201
- evaluation = value.toUpperCase() == valueToCompare.toUpperCase();
202
- else
203
- evaluation = value == valueToCompare;
204
-
205
- if (isNegative)
206
- return !evaluation;
207
- else
208
- return evaluation;
209
- }
210
-
211
- private static equalsAny(value: string, valuesToCompare: Array<string>, isNegative: boolean, isIgnoreCase: boolean): boolean {
212
- for (let i = 0; i < valuesToCompare.length; i++) {
213
- let valueToCompare = valuesToCompare[i];
214
- if (ComparisonOperatorHelper.equalS(value, valueToCompare, false, isIgnoreCase))
215
- return !isNegative;
216
- }
217
-
218
- return isNegative;
219
- }
220
-
221
- private static containsAny(value: string, valuesToCompare: Array<string>, isNegative: boolean, isIgnoreCase: boolean): boolean {
222
- for (let i = 0; i < valuesToCompare.length; i++) {
223
- let valueToCompare = valuesToCompare[i];
224
- if (ComparisonOperatorHelper.contains(value, valueToCompare, false, isIgnoreCase))
225
- return !isNegative;
226
- }
227
-
228
- return isNegative;
229
- }
230
- }