Skip to content

Commit

Permalink
chore(decoratormanager) API backwards compat (#715)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman authored Sep 13, 2023
1 parent bf34b28 commit 2ba977d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/concerto-core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Concerto {
class DecoratorManager {
+ ModelManager decorateModels(ModelManager,decoratorCommandSet,object?,boolean?,boolean?)
+ void validateCommand(ModelManager,command)
+ Boolean falsyOrEqual(string|,string[])
+ Boolean falsyOrEqual(string|,string|)
+ void applyDecorator(decorated,string,newDecorator)
+ void executeCommand(string,declaration,command)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/concerto-core/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Note that the latest public API is documented using JSDocs and is available in api.txt.
#

Version 3.12.5 {ea967f943046b2792fe3863943a6b2ba} 2023-09-08
Version 3.12.5 {ced48c7ab94de207be87584468517f3e} 2023-09-08
- Update DecoratorManager to support multiple value compare

Version 3.12.4 {7738d5490ea8438677e1d21d704bb5aa} 2023-08-31
Expand Down
6 changes: 4 additions & 2 deletions packages/concerto-core/lib/decoratormanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ class DecoratorManager {
* Compares two values. If the first argument is falsy
* the function returns true.
* @param {string | null} test the value to test (lhs)
* @param {string[]} values the values to compare (rhs)
* @param {string|string[]} values the values to compare (rhs)
* @returns {Boolean} true if the lhs is falsy or values.includes(test)
*/
static falsyOrEqual(test, values) {
return test ? values.includes(test) : true;
return test
? Array.isArray(values) ? values.includes(test) : test === values
: true;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions packages/concerto-core/test/decoratormanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ describe('DecoratorManager', () => {
DecoratorManager.falsyOrEqual( 'one', 'one').should.be.true;
});

it('should match token', async function() {
DecoratorManager.falsyOrEqual( 'one', ['one']).should.be.true;
});

it('should not match token', async function() {
DecoratorManager.falsyOrEqual( 'one', 'two').should.be.false;
});

it('should not match token', async function() {
DecoratorManager.falsyOrEqual( 'one', ['two']).should.be.false;
});
});

describe('#decorateModels', function() {
Expand Down
6 changes: 3 additions & 3 deletions packages/concerto-core/types/lib/decoratormanager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ declare class DecoratorManager {
* Compares two values. If the first argument is falsy
* the function returns true.
* @param {string | null} test the value to test (lhs)
* @param {string} value the value to compare (rhs)
* @returns {Boolean} true if the lhs is falsy or test === value
* @param {string|string[]} values the values to compare (rhs)
* @returns {Boolean} true if the lhs is falsy or values.includes(test)
*/
static falsyOrEqual(test: string | null, value: string): boolean;
static falsyOrEqual(test: string | null, values: string | string[]): boolean;
/**
* Applies a decorator to a decorated model element.
* @param {*} decorated the type to apply the decorator to
Expand Down

0 comments on commit 2ba977d

Please sign in to comment.