@bisondesk/commons-sdk 1.0.56 → 1.0.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/commons-sdk",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
4
4
  "scripts": {
5
5
  "build": "npx tsc --build",
6
6
  "clean": "rm -rf lib *.tsbuildinfo",
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUPPORTED_LANGUAGES = exports.AppRoles = void 0;
4
+ //
5
+ // STATIC ROLES
6
+ //
7
+ var AppRoles;
8
+ (function (AppRoles) {
9
+ AppRoles["Accountant"] = "accountant";
10
+ AppRoles["Admin"] = "admins";
11
+ AppRoles["Administrative"] = "administrative";
12
+ AppRoles["Commercial"] = "commercial";
13
+ AppRoles["Manager"] = "manager";
14
+ })(AppRoles = exports.AppRoles || (exports.AppRoles = {}));
15
+ //
16
+ // I18N
17
+ //
18
+ exports.SUPPORTED_LANGUAGES = ['en', 'fr', 'nl'];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/src/ids.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateId = exports.Alphabet = void 0;
4
+ const nanoid_1 = require("nanoid");
5
+ var Alphabet;
6
+ (function (Alphabet) {
7
+ Alphabet["Full"] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
8
+ Alphabet["Alphanumeric"] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
9
+ Alphabet["Lowercase"] = "abcdefghijklmnopqrstuvwxyz";
10
+ Alphabet["LowerAlphanumeric"] = "0123456789abcdefghijklmnopqrstuvwxyz";
11
+ })(Alphabet = exports.Alphabet || (exports.Alphabet = {}));
12
+ // The ID can contain only alphabets and numbers and underscore.
13
+ // The ID should start with an alphabet and should not have two consecutive underscores or end with an underscore.
14
+ const generateId = (idLength = 15, alphabet = Alphabet.Full) => {
15
+ const nanoid = nanoid_1.customAlphabet(alphabet, idLength);
16
+ while (true) {
17
+ const id = nanoid();
18
+ if (isValid(id)) {
19
+ return id;
20
+ }
21
+ }
22
+ };
23
+ exports.generateId = generateId;
24
+ const isValid = (id) => {
25
+ if (!Number.isNaN(Number.parseInt(id[0]))) {
26
+ return false;
27
+ }
28
+ if (id.endsWith('_') || id.startsWith('_')) {
29
+ return false;
30
+ }
31
+ if (id.includes('__')) {
32
+ return false;
33
+ }
34
+ return true;
35
+ };
package/src/types.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Region = void 0;
4
+ var Region;
5
+ (function (Region) {
6
+ Region["euWest1"] = "eu-west-1";
7
+ })(Region = exports.Region || (exports.Region = {}));