custom fields (#744)

---------

Co-authored-by: Carlos Valente <carlosvalente@pm.me>
This commit is contained in:
Alex Christoffer Rasmussen
2024-02-17 21:55:46 +01:00
committed by GitHub
parent 1a420a1ddd
commit c1377544a0
17 changed files with 347 additions and 6 deletions
@@ -5,7 +5,7 @@ import { OSCSettings } from './core/OscSettings.type.js';
import { Settings } from './core/Settings.type.js';
import { UserFields } from './core/UserFields.type.js';
import { ViewSettings } from './core/Views.type.js';
import { HttpSettings } from '../index.js';
import { CustomFields, HttpSettings } from '../index.js';
export type DatabaseModel = {
rundown: OntimeRundown;
@@ -14,6 +14,7 @@ export type DatabaseModel = {
viewSettings: ViewSettings;
aliases: Alias[];
userFields: UserFields;
customFields: CustomFields;
osc: OSCSettings;
http: HttpSettings;
};
@@ -0,0 +1,6 @@
export type CustomField = {
type: string;
label: string;
};
export type CustomFields = Record<string, CustomField>;
+3
View File
@@ -30,6 +30,9 @@ export type { Alias } from './definitions/core/Alias.type.js';
// ---> User Fields
export type { UserFields } from './definitions/core/UserFields.type.js';
// ---> Custom Fields
export type { CustomFields, CustomField } from './definitions/core/CustomFields.type.js';
// ---> Integration, Subscription
export type { OSCSettings, OscSubscription } from './definitions/core/OscSettings.type.js';
export type { HttpSettings, HttpSubscription } from './definitions/core/HttpSettings.type.js';
+1
View File
@@ -42,6 +42,7 @@ export {
removeSeconds,
removeTrailingZero,
} from './src/date-utils/timeFormatting.js';
export { isAlphanumeric } from './src/regex-utils/isAlphanumeric.js';
export { isColourHex } from './src/regex-utils/isColourHex.js';
// time utils
@@ -0,0 +1,17 @@
import { isAlphanumeric } from './isAlphanumeric';
describe('test isAlphanumeric() function', () => {
it('it OK strings', () => {
const ts = ['abcdefghijklmnopqrstuvwxyz', '0123456798', '123asd'];
for (const s of ts) {
expect(isAlphanumeric(s)).toBe(true);
}
});
it('it bad strings', () => {
const ts = ['!abcd1234', 'åøæ', '*'];
for (const s of ts) {
expect(isAlphanumeric(s)).toBe(false);
}
});
});
@@ -0,0 +1,8 @@
/**
* @description Validates a alphanumeric string
* @returns {boolean}
*/
export const isAlphanumeric = (text: string): boolean => {
const regex = /^[a-z0-9]+$/i;
return regex.test(text);
};