Skip to content

Commit

Permalink
Jh/bug filter by null (#285)
Browse files Browse the repository at this point in the history
* chore: use openssl legacy provider for node build

* fix: allow users to filter string field types by null

* chore: address new lint errors

* chore: update release please version

* chore: release 1.0.0

Release-As: 1.0.0
  • Loading branch information
jonnyhork authored Jun 13, 2024
1 parent 47547a3 commit eb62f2b
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-builder-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-builder-ui:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-common:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-data-view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-data-view:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-model:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion packages/soql-builder-ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"@lwc/lwc/no-async-operation": "off",
"@lwc/lwc/no-inner-html": "warn",
"@lwc/lwc/no-document-query": "warn",
"no-underscore-dangle": "off"
"no-underscore-dangle": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "[api|track]"
}
]
}
}
2 changes: 1 addition & 1 deletion packages/soql-builder-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"license": "BSD-3-Clause",
"main": "dist/",
"scripts": {
"build": "lwc-services build -w webpack.config.js -m production",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && lwc-services build -w webpack.config.js -m production",
"clean": "shx rm -rf package-lock.json && shx rm -rf dist && shx rm -rf node_modules",
"publish:lwc": "npm publish .",
"lint": "eslint ./src",
Expand Down
19 changes: 10 additions & 9 deletions packages/soql-builder-ui/src/modules/querybuilder/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { LightningElement, track } from 'lwc';
import { JsonMap } from '@salesforce/ts-types';
import { ToolingSDK } from '../services/toolingSDK';
import { MessageServiceFactory } from '../services/message/messageServiceFactory';

Expand Down Expand Up @@ -176,7 +177,7 @@ export default class App extends LightningElement {
}

/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return*/
public inspectUnsupported(unsupported): any {
public inspectUnsupported(unsupported: JsonMap[]): any {
const filteredUnsupported = unsupported
// this reason is often associated with a parse error, so snuffing it out instead of double notifications
.filter(
Expand All @@ -189,7 +190,7 @@ export default class App extends LightningElement {
return filteredUnsupported;
}
/* ---- SOBJECT HANDLERS ---- */
public handleObjectChange(e): void {
public handleObjectChange(e: CustomEvent): void {
const selectedSObjectName = e.detail.selectedSobject;
this.onSObjectChanged(selectedSObjectName);
// when triggered by the ui, send message
Expand All @@ -204,7 +205,7 @@ export default class App extends LightningElement {
}
}
/* ---- FIELD HANDLERS ---- */
public handleFieldSelected(e): void {
public handleFieldSelected(e: CustomEvent): void {
this.modelService.setFields(e.detail.fields);
}
public handleFieldSelectAll(): void {
Expand All @@ -215,24 +216,24 @@ export default class App extends LightningElement {
}

/* ---- ORDER BY HANDLERS ---- */
public handleOrderBySelected(e): void {
public handleOrderBySelected(e: CustomEvent): void {
this.modelService.addUpdateOrderByField(e.detail);
}
public handleOrderByRemoved(e): void {
public handleOrderByRemoved(e: CustomEvent): void {
this.modelService.removeOrderByField(e.detail.field);
}
/* ---- LIMIT HANDLERS ---- */
public handleLimitChanged(e): void {
public handleLimitChanged(e: CustomEvent): void {
this.modelService.changeLimit(e.detail.limit);
}
/* ---- WHERE HANDLERS ---- */
public handleWhereSelection(e): void {
public handleWhereSelection(e: CustomEvent): void {
this.modelService.upsertWhereFieldExpr(e.detail);
}
public handleAndOrSelection(e): void {
public handleAndOrSelection(e: CustomEvent): void {
this.modelService.setAndOr(e.detail);
}
public handleRemoveWhereCondition(e): void {
public handleRemoveWhereCondition(e: CustomEvent): void {
this.modelService.removeWhereFieldCondition(e.detail);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Fields extends LightningElement {
public selectPlaceHolderText = 'Search fields...'; // TODO: i18n
public _displayFields: string[];

public handleFieldSelection(e): void {
public handleFieldSelection(e: CustomEvent): void {
e.preventDefault();
if (e.detail && e.detail.value) {
let selection = [];
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class Fields extends LightningElement {
}
}

public handleFieldRemoved(e): void {
public handleFieldRemoved(e: Event): void {
e.preventDefault();
const fieldRemovedEvent = new CustomEvent('fields__selected', {
detail: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class From extends LightningElement {
}

/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment */
public handleSobjectSelection(e): void {
public handleSobjectSelection(e: CustomEvent): void {
e.preventDefault();
const selectedSobject = e.detail.value;
if (selectedSobject && selectedSobject.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class Limit extends LightningElement {
@api public limit;

/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access */
public handleLimitChange(e): void {
public handleLimitChange(e: Event): void {
e.preventDefault();
const limit = e.target.value;
const sObjectSelected = new CustomEvent('limit__changed', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class OrderBy extends LightningElement {
}

/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment */
public handleOrderBySelected(e): void {
public handleOrderBySelected(e: Event): void {
e.preventDefault();
const orderbyFieldEl = this.template.querySelector(
'querybuilder-custom-select'
Expand All @@ -44,7 +44,7 @@ export default class OrderBy extends LightningElement {
}
}

public handleOrderByRemoved(e): void {
public handleOrderByRemoved(e: Event): void {
e.preventDefault();
const orderByRemovedEvent = new CustomEvent('orderby__removed', {
detail: { field: e.target.dataset.field }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class Where extends LightningElement {
}
}

public handleModifierGroupSelection(e): void {
public handleModifierGroupSelection(e: Event): void {
e.preventDefault();
// eslint-disable-next-line camelcase
const where__group_selectionEvent = new CustomEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @lwc/lwc/prefer-custom-event */
/* eslint-disable @lwc/lwc/no-inner-html */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
Expand Down
1 change: 1 addition & 0 deletions packages/soql-builder-ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
8 changes: 8 additions & 0 deletions packages/soql-model/src/validators/stringValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ describe('StringValidator should', () => {
const validator = new StringValidator({ type: SObjectFieldType.String });
const validResult = { isValid: true };
const notValidResult = { isValid: false, message: Messages.error_fieldInput_string };

it('return valid result for string in single quotes', () => {
expect(validator.validate("'foo'")).toEqual(validResult);
});

it('return valid result when user input is NULL or null', () => {
expect(validator.validate("'null'")).toEqual(validResult);
expect(validator.validate("'NULL'")).toEqual(validResult);
});

it('return not valid result for non-string value', () => {
expect(validator.validate('foo')).toEqual(notValidResult);
});

it('return not valid result for string ending in escaped quote', () => {
expect(validator.validate("'foo\\'")).toEqual(notValidResult);
});
Expand Down
9 changes: 5 additions & 4 deletions packages/soql-model/src/validators/stringValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { ValidateResult, Validator } from './validator';
export class StringValidator extends Validator {
public validate(input: string): ValidateResult {
const isValid =
input.length >= 2 &&
input.startsWith("'") &&
input.endsWith("'") &&
!this.isEscaped(input.substring(1, input.length - 1));
(input.length >= 2 &&
input.startsWith("'") &&
input.endsWith("'") &&
!this.isEscaped(input.substring(1, input.length - 1))) ||
input.toLowerCase() === 'null';
const message = isValid ? undefined : Messages.error_fieldInput_string;
return { isValid, message };
}
Expand Down

0 comments on commit eb62f2b

Please sign in to comment.