@proteinjs/db-settings 1.0.12 → 1.0.14
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/.eslintrc.js +20 -0
- package/.prettierignore +3 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +11 -17
- package/LICENSE +21 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/Settings.d.ts.map +1 -1
- package/dist/src/Settings.js +3 -2
- package/dist/src/Settings.js.map +1 -1
- package/dist/src/tables/SettingTable.d.ts.map +1 -1
- package/dist/src/tables/SettingTable.js +0 -1
- package/dist/src/tables/SettingTable.js.map +1 -1
- package/dist/src/tables/tables.d.ts.map +1 -1
- package/dist/src/tables/tables.js.map +1 -1
- package/generated/index.ts +5 -8
- package/index.ts +1 -1
- package/jest.config.js +8 -17
- package/package.json +45 -39
- package/src/Settings.ts +4 -3
- package/src/services/SettingsService.ts +1 -1
- package/src/tables/SettingTable.ts +6 -6
- package/src/tables/tables.ts +1 -1
- package/tsconfig.json +18 -22
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'prettier'],
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
plugins: ['@typescript-eslint', 'prettier'],
|
|
5
|
+
root: true,
|
|
6
|
+
ignorePatterns: ['**/dist/*', '**/node_modules/*'],
|
|
7
|
+
|
|
8
|
+
rules: {
|
|
9
|
+
'prettier/prettier': ['warn'],
|
|
10
|
+
curly: ['warn'],
|
|
11
|
+
'eol-last': ['warn', 'always'],
|
|
12
|
+
'keyword-spacing': ['warn', { before: true }],
|
|
13
|
+
'no-undef': 'off',
|
|
14
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
15
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
16
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
17
|
+
'@typescript-eslint/prefer-as-const': 'off',
|
|
18
|
+
'@typescript-eslint/ban-types': 'off',
|
|
19
|
+
},
|
|
20
|
+
};
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -3,49 +3,43 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [1.0.
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @proteinjs/db-settings
|
|
9
|
-
|
|
6
|
+
## [1.0.14](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.13...@proteinjs/db-settings@1.0.14) (2024-05-10)
|
|
10
7
|
|
|
11
8
|
|
|
9
|
+
### Bug Fixes
|
|
12
10
|
|
|
11
|
+
* add linting and lint all files ([f9859a3](https://github.com/brentbahry/db/commit/f9859a39882376fe7b93aa3b4281b22b2c02b7d5))
|
|
13
12
|
|
|
14
|
-
## [1.0.10](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.9...@proteinjs/db-settings@1.0.10) (2024-05-02)
|
|
15
13
|
|
|
16
|
-
**Note:** Version bump only for package @proteinjs/db-settings
|
|
17
14
|
|
|
18
15
|
|
|
19
16
|
|
|
17
|
+
## [1.0.13](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.12...@proteinjs/db-settings@1.0.13) (2024-05-09)
|
|
20
18
|
|
|
19
|
+
**Note:** Version bump only for package @proteinjs/db-settings
|
|
21
20
|
|
|
22
|
-
## [1.0.
|
|
21
|
+
## [1.0.11](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.10...@proteinjs/db-settings@1.0.11) (2024-05-03)
|
|
23
22
|
|
|
24
23
|
**Note:** Version bump only for package @proteinjs/db-settings
|
|
25
24
|
|
|
25
|
+
## [1.0.10](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.9...@proteinjs/db-settings@1.0.10) (2024-05-02)
|
|
26
26
|
|
|
27
|
+
**Note:** Version bump only for package @proteinjs/db-settings
|
|
27
28
|
|
|
29
|
+
## [1.0.7](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.6...@proteinjs/db-settings@1.0.7) (2024-04-26)
|
|
28
30
|
|
|
31
|
+
**Note:** Version bump only for package @proteinjs/db-settings
|
|
29
32
|
|
|
30
33
|
## [1.0.6](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.5...@proteinjs/db-settings@1.0.6) (2024-04-26)
|
|
31
34
|
|
|
32
|
-
|
|
33
35
|
### Bug Fixes
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
- `SchemaMetadata.tableExists` include condition to query `TABLE_SCHEMA` by default for mysql ([b4e6d22](https://github.com/brentbahry/db/commit/b4e6d224d93db75c83ad75160b83346f2b12d166))
|
|
40
38
|
|
|
41
39
|
## [1.0.2](https://github.com/brentbahry/db/compare/@proteinjs/db-settings@1.0.1...@proteinjs/db-settings@1.0.2) (2024-04-19)
|
|
42
40
|
|
|
43
41
|
**Note:** Version bump only for package @proteinjs/db-settings
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
43
|
## 1.0.1 (2024-04-19)
|
|
50
44
|
|
|
51
45
|
**Note:** Version bump only for package @proteinjs/db-settings
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Brent Bahry
|
|
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.
|
package/dist/generated/index.js
CHANGED
|
@@ -21,7 +21,7 @@ require("@proteinjs/service");
|
|
|
21
21
|
require("@proteinjs/util");
|
|
22
22
|
require("moment");
|
|
23
23
|
/** Generate Source Graph */
|
|
24
|
-
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/db-settings/Settings\",\"value\":{\"packageName\":\"@proteinjs/db-settings\",\"name\":\"Settings\",\"filePath\":\"/
|
|
24
|
+
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/db-settings/Settings\",\"value\":{\"packageName\":\"@proteinjs/db-settings\",\"name\":\"Settings\",\"filePath\":\"/home/runner/work/db/db/packages/settings/src/Settings.ts\",\"qualifiedName\":\"@proteinjs/db-settings/Settings\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"serviceMetadata\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"get\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"defaultValue\",\"type\":{\"packageName\":\"\",\"name\":\"T\",\"filePath\":null,\"qualifiedName\":\"/T\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"set\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"value\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/db-settings\",\"name\":\"SettingsService\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db-settings/SettingsService\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/db-settings/SettingsService\",\"value\":{\"packageName\":\"@proteinjs/db-settings\",\"name\":\"SettingsService\",\"filePath\":\"/home/runner/work/db/db/packages/settings/src/services/SettingsService.ts\",\"qualifiedName\":\"@proteinjs/db-settings/SettingsService\",\"properties\":[],\"methods\":[{\"name\":\"get\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<T>\",\"filePath\":null,\"qualifiedName\":\"/Promise<T>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":true,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"defaultValue\",\"type\":{\"packageName\":\"\",\"name\":\"T\",\"filePath\":null,\"qualifiedName\":\"/T\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"set\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":true,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"value\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/service\",\"name\":\"Service\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/service/Service\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/service/Service\"},{\"v\":\"@proteinjs/db-settings/Setting\",\"value\":{\"packageName\":\"@proteinjs/db-settings\",\"name\":\"Setting\",\"filePath\":\"/home/runner/work/db/db/packages/settings/src/tables/SettingTable.ts\",\"qualifiedName\":\"@proteinjs/db-settings/Setting\",\"properties\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"value\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"Record\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/Record\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/db/Record\"},{\"v\":\"@proteinjs/db-settings/SettingTable\",\"value\":{\"packageName\":\"@proteinjs/db-settings\",\"name\":\"SettingTable\",\"filePath\":\"/home/runner/work/db/db/packages/settings/src/tables/SettingTable.ts\",\"qualifiedName\":\"@proteinjs/db-settings/SettingTable\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"name\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"auth\",\"type\":{\"packageName\":\"\",\"name\":\"Table<Setting>['auth']\",\"filePath\":null,\"qualifiedName\":\"/Table<Setting>['auth']\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"columns\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParentInterfaces\":[],\"directParentClasses\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"Table\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/Table\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[],\"methods\":[],\"typeParameters\":[\"@proteinjs/db-settings/Setting\"],\"directParentInterfaces\":[],\"directParentClasses\":[]}],\"sourceType\":2}},{\"v\":\"@proteinjs/db/Table\"}],\"edges\":[{\"v\":\"@proteinjs/db-settings/Settings\",\"w\":\"@proteinjs/db-settings/SettingsService\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/db-settings/SettingsService\",\"w\":\"@proteinjs/service/Service\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/db-settings/Setting\",\"w\":\"@proteinjs/db/Record\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/db-settings/SettingTable\",\"w\":\"@proteinjs/db/Table\",\"value\":\"extends class\"}]}";
|
|
25
25
|
/** Generate Source Links */
|
|
26
26
|
var Settings_1 = require("../src/Settings");
|
|
27
27
|
var SettingTable_1 = require("../src/tables/SettingTable");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,yBAAuB;AACvB,iCAA+B;AAC/B,8BAA4B;AAC5B,2BAAyB;AACzB,kBAAgB;AAGhB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,yBAAuB;AACvB,iCAA+B;AAC/B,8BAA4B;AAC5B,2BAAyB;AACzB,kBAAgB;AAGhB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,woNAAwoN,CAAC;AAG7pN,4BAA4B;AAE5B,4CAA2C;AAC3C,2DAA0D;AAE1D,IAAM,WAAW,GAAG;IACnB,iCAAiC,EAAE,mBAAQ;IAC3C,qCAAqC,EAAE,2BAAY;CACnD,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.d.ts","sourceRoot":"","sources":["../../src/Settings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAsB,MAAM,4BAA4B,CAAC;AAGjF,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Settings.d.ts","sourceRoot":"","sources":["../../src/Settings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAsB,MAAM,4BAA4B,CAAC;AAGjF,eAAO,MAAM,WAAW,gBAA4F,CAAC;AAErH,qBAAa,QAAS,YAAW,eAAe;IAC9C,OAAO,CAAC,MAAM,CAAqC;IAC5C,eAAe;;;;MAIpB;IAEI,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;IAUrC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;CAQnC"}
|
package/dist/src/Settings.js
CHANGED
|
@@ -41,7 +41,7 @@ var db_1 = require("@proteinjs/db");
|
|
|
41
41
|
var util_1 = require("@proteinjs/util");
|
|
42
42
|
var SettingsService_1 = require("./services/SettingsService");
|
|
43
43
|
var tables_1 = require("./tables/tables");
|
|
44
|
-
var getSettings = function () { return typeof self === 'undefined' ? new Settings() : (0, SettingsService_1.getSettingsService)(); };
|
|
44
|
+
var getSettings = function () { return (typeof self === 'undefined' ? new Settings() : (0, SettingsService_1.getSettingsService)()); };
|
|
45
45
|
exports.getSettings = getSettings;
|
|
46
46
|
var Settings = /** @class */ (function () {
|
|
47
47
|
function Settings() {
|
|
@@ -62,8 +62,9 @@ var Settings = /** @class */ (function () {
|
|
|
62
62
|
return [4 /*yield*/, db.get(tables_1.tables.Setting, { name: name })];
|
|
63
63
|
case 1:
|
|
64
64
|
setting = _a.sent();
|
|
65
|
-
if (!setting)
|
|
65
|
+
if (!setting) {
|
|
66
66
|
return [2 /*return*/, defaultValue];
|
|
67
|
+
}
|
|
67
68
|
return [2 /*return*/, setting.value];
|
|
68
69
|
}
|
|
69
70
|
});
|
package/dist/src/Settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../src/Settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,wCAAyC;AACzC,8DAAiF;AACjF,0CAAyC;AAElC,IAAM,WAAW,GAAG,cAAM,OAAA,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../src/Settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,wCAAyC;AACzC,8DAAiF;AACjF,0CAAyC;AAElC,IAAM,WAAW,GAAG,cAAM,OAAA,CAAC,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAE,IAAA,oCAAkB,GAAe,CAAC,EAAnF,CAAmF,CAAC;AAAxG,QAAA,WAAW,eAA6F;AAErH;IAAA;QACU,WAAM,GAAG,IAAI,aAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,oBAAe,GAAG;YACvB,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;IAoBJ,CAAC;IAlBO,sBAAG,GAAT,UAAa,IAAY,EAAE,YAAgB;;;;;;wBACnC,EAAE,GAAG,IAAA,UAAK,GAAE,CAAC;wBACH,qBAAM,EAAE,CAAC,GAAG,CAAC,eAAM,CAAC,OAAO,EAAE,EAAE,IAAI,MAAA,EAAE,CAAC,EAAA;;wBAAhD,OAAO,GAAG,SAAsC;wBACtD,IAAI,CAAC,OAAO,EAAE;4BACZ,sBAAO,YAAY,EAAC;yBACrB;wBAED,sBAAO,OAAO,CAAC,KAAK,EAAC;;;;KACtB;IAEK,sBAAG,GAAT,UAAU,IAAY,EAAE,KAAU;;;;;;wBAC1B,EAAE,GAAG,IAAA,UAAK,GAAE,CAAC;wBACC,qBAAM,EAAE,CAAC,MAAM,CAAC,eAAM,CAAC,OAAO,EAAE,EAAE,KAAK,OAAA,EAAE,EAAE,EAAE,IAAI,MAAA,EAAE,CAAC,EAAA;;wBAAlE,WAAW,GAAG,SAAoD;6BACpE,CAAA,WAAW,IAAI,CAAC,CAAA,EAAhB,wBAAgB;wBAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAyB,IAAI,CAAE,CAAC,CAAC;wBAClD,qBAAM,EAAE,CAAC,MAAM,CAAC,eAAM,CAAC,OAAO,EAAE,EAAE,IAAI,MAAA,EAAE,KAAK,OAAA,EAAE,CAAC,EAAA;;wBAAhD,SAAgD,CAAC;;;;;;KAEpD;IACH,eAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,4BAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingTable.d.ts","sourceRoot":"","sources":["../../../src/tables/SettingTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAmC,MAAM,eAAe,CAAC;AAE7F,MAAM,WAAW,OAAQ,SAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"SettingTable.d.ts","sourceRoot":"","sources":["../../../src/tables/SettingTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAmC,MAAM,eAAe,CAAC;AAE7F,MAAM,WAAW,OAAQ,SAAQ,MAAM;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,qBAAa,YAAa,SAAQ,KAAK,CAAC,OAAO,CAAC;IACvC,IAAI,SAAa;IACjB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAOjC;IACK,OAAO;;;;;;;;;MAGX;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingTable.js","sourceRoot":"","sources":["../../../src/tables/SettingTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oCAA6F;AAO7F;IAAkC,gCAAc;IAAhD;QAAA,qEAcC;
|
|
1
|
+
{"version":3,"file":"SettingTable.js","sourceRoot":"","sources":["../../../src/tables/SettingTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oCAA6F;AAO7F;IAAkC,gCAAc;IAAhD;QAAA,qEAcC;QAbQ,UAAI,GAAG,SAAS,CAAC;QACjB,UAAI,GAA2B;YACpC,EAAE,EAAE;gBACF,GAAG,EAAE,eAAe;aACrB;YACD,OAAO,EAAE;gBACP,GAAG,EAAE,eAAe;aACrB;SACF,CAAC;QACK,aAAO,GAAG,IAAA,sBAAiB,EAAU;YAC1C,IAAI,EAAE,IAAI,iBAAY,CAAC,MAAM,CAAC;YAC9B,KAAK,EAAE,IAAI,iBAAY,CAAC,OAAO,CAAC;SACjC,CAAC,CAAC;;IACL,CAAC;IAAD,mBAAC;AAAD,CAAC,AAdD,CAAkC,UAAK,GActC;AAdY,oCAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/tables/tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAgB,MAAM,gBAAgB,CAAC;AAEvD,eAAO,MAAM,MAAM;;CAElB,
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/tables/tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAgB,MAAM,gBAAgB,CAAC;AAEvD,eAAO,MAAM,MAAM;;CAElB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/tables/tables.ts"],"names":[],"mappings":";;;AACA,+CAAuD;AAE1C,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,IAAI,2BAAY,EAAoB;CAC9C,
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/tables/tables.ts"],"names":[],"mappings":";;;AACA,+CAAuD;AAE1C,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,IAAI,2BAAY,EAAoB;CAC9C,CAAC"}
|
package/generated/index.ts
CHANGED
|
@@ -6,11 +6,10 @@ import '@proteinjs/service';
|
|
|
6
6
|
import '@proteinjs/util';
|
|
7
7
|
import 'moment';
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
/** Generate Source Graph */
|
|
11
10
|
|
|
12
|
-
const sourceGraph =
|
|
13
|
-
|
|
11
|
+
const sourceGraph =
|
|
12
|
+
'{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-settings/Settings","value":{"packageName":"@proteinjs/db-settings","name":"Settings","filePath":"/home/runner/work/db/db/packages/settings/src/Settings.ts","qualifiedName":"@proteinjs/db-settings/Settings","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"serviceMetadata","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"get","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"defaultValue","type":{"packageName":"","name":"T","filePath":null,"qualifiedName":"/T","typeParameters":null,"directParents":null}}]},{"name":"set","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"value","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db-settings","name":"SettingsService","filePath":null,"qualifiedName":"@proteinjs/db-settings/SettingsService","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db-settings/SettingsService","value":{"packageName":"@proteinjs/db-settings","name":"SettingsService","filePath":"/home/runner/work/db/db/packages/settings/src/services/SettingsService.ts","qualifiedName":"@proteinjs/db-settings/SettingsService","properties":[],"methods":[{"name":"get","returnType":{"packageName":"","name":"Promise<T>","filePath":null,"qualifiedName":"/Promise<T>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":true,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"defaultValue","type":{"packageName":"","name":"T","filePath":null,"qualifiedName":"/T","typeParameters":null,"directParents":null}}]},{"name":"set","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":true,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"value","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParents":[{"packageName":"@proteinjs/service","name":"Service","filePath":null,"qualifiedName":"@proteinjs/service/Service","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"sourceType":3}},{"v":"@proteinjs/service/Service"},{"v":"@proteinjs/db-settings/Setting","value":{"packageName":"@proteinjs/db-settings","name":"Setting","filePath":"/home/runner/work/db/db/packages/settings/src/tables/SettingTable.ts","qualifiedName":"@proteinjs/db-settings/Setting","properties":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"value","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[],"typeParameters":[],"directParents":[{"packageName":"@proteinjs/db","name":"Record","filePath":null,"qualifiedName":"@proteinjs/db/Record","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"sourceType":3}},{"v":"@proteinjs/db/Record"},{"v":"@proteinjs/db-settings/SettingTable","value":{"packageName":"@proteinjs/db-settings","name":"SettingTable","filePath":"/home/runner/work/db/db/packages/settings/src/tables/SettingTable.ts","qualifiedName":"@proteinjs/db-settings/SettingTable","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"name","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"auth","type":{"packageName":"","name":"Table<Setting>[\'auth\']","filePath":null,"qualifiedName":"/Table<Setting>[\'auth\']","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"columns","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[{"packageName":"@proteinjs/db","name":"Table","filePath":null,"qualifiedName":"@proteinjs/db/Table","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[],"typeParameters":["@proteinjs/db-settings/Setting"],"directParentInterfaces":[],"directParentClasses":[]}],"sourceType":2}},{"v":"@proteinjs/db/Table"}],"edges":[{"v":"@proteinjs/db-settings/Settings","w":"@proteinjs/db-settings/SettingsService","value":"implements interface"},{"v":"@proteinjs/db-settings/SettingsService","w":"@proteinjs/service/Service","value":"extends interface"},{"v":"@proteinjs/db-settings/Setting","w":"@proteinjs/db/Record","value":"extends interface"},{"v":"@proteinjs/db-settings/SettingTable","w":"@proteinjs/db/Table","value":"extends class"}]}';
|
|
14
13
|
|
|
15
14
|
/** Generate Source Links */
|
|
16
15
|
|
|
@@ -18,15 +17,13 @@ import { Settings } from '../src/Settings';
|
|
|
18
17
|
import { SettingTable } from '../src/tables/SettingTable';
|
|
19
18
|
|
|
20
19
|
const sourceLinks = {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
'@proteinjs/db-settings/Settings': Settings,
|
|
21
|
+
'@proteinjs/db-settings/SettingTable': SettingTable,
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
|
|
26
24
|
/** Load Source Graph and Links */
|
|
27
25
|
|
|
28
26
|
import { SourceRepository } from '@proteinjs/reflection';
|
|
29
27
|
SourceRepository.merge(sourceGraph, sourceLinks);
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
export * from '../index';
|
|
29
|
+
export * from '../index';
|
package/index.ts
CHANGED
package/jest.config.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"ts",
|
|
11
|
-
"tsx",
|
|
12
|
-
"js",
|
|
13
|
-
"jsx",
|
|
14
|
-
"json",
|
|
15
|
-
"node"
|
|
16
|
-
],
|
|
17
|
-
"testEnvironment": "node"
|
|
18
|
-
}
|
|
2
|
+
roots: ['<rootDir>/test'],
|
|
3
|
+
transform: {
|
|
4
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
5
|
+
},
|
|
6
|
+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
|
|
7
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
8
|
+
testEnvironment: 'node',
|
|
9
|
+
};
|
package/package.json
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
2
|
+
"name": "@proteinjs/db-settings",
|
|
3
|
+
"version": "1.0.14",
|
|
4
|
+
"description": "Db settings",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/brentbahry/db.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/brentbahry/db/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/brentbahry/db#readme",
|
|
16
|
+
"author": "Brent Bahry",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rm -rf dist/ node_modules/ generated/",
|
|
20
|
+
"build": "reflection-build && tsc",
|
|
21
|
+
"watch": "reflection-watch"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@proteinjs/db": "^1.0.16",
|
|
25
|
+
"@proteinjs/reflection": "1.1.1",
|
|
26
|
+
"@proteinjs/service": "1.0.9",
|
|
27
|
+
"@proteinjs/util": "1.1.0",
|
|
28
|
+
"moment": "2.29.4"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@proteinjs/reflection-build": "1.0.16",
|
|
32
|
+
"@types/jest": "29.5.5",
|
|
33
|
+
"@types/node": "14.0.27",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
35
|
+
"@typescript-eslint/parser": "7.8.0",
|
|
36
|
+
"eslint": "8.57.0",
|
|
37
|
+
"eslint-config-prettier": "9.1.0",
|
|
38
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
39
|
+
"jest": "29.7.0",
|
|
40
|
+
"ts-jest": "29.1.1",
|
|
41
|
+
"typescript": "5.2.2"
|
|
42
|
+
},
|
|
43
|
+
"main": "./dist/generated/index.js",
|
|
44
|
+
"types": "./dist/generated/index.d.ts",
|
|
45
|
+
"gitHead": "e9b7e3b3073e7a68c97b218444208d2c84f9197d"
|
|
46
|
+
}
|
package/src/Settings.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Logger } from '@proteinjs/util';
|
|
|
3
3
|
import { SettingsService, getSettingsService } from './services/SettingsService';
|
|
4
4
|
import { tables } from './tables/tables';
|
|
5
5
|
|
|
6
|
-
export const getSettings = () => typeof self === 'undefined' ? new Settings() : getSettingsService() as Settings;
|
|
6
|
+
export const getSettings = () => (typeof self === 'undefined' ? new Settings() : (getSettingsService() as Settings));
|
|
7
7
|
|
|
8
8
|
export class Settings implements SettingsService {
|
|
9
9
|
private logger = new Logger(this.constructor.name);
|
|
@@ -16,8 +16,9 @@ export class Settings implements SettingsService {
|
|
|
16
16
|
async get<T>(name: string, defaultValue?: T) {
|
|
17
17
|
const db = getDb();
|
|
18
18
|
const setting = await db.get(tables.Setting, { name });
|
|
19
|
-
if (!setting)
|
|
19
|
+
if (!setting) {
|
|
20
20
|
return defaultValue;
|
|
21
|
+
}
|
|
21
22
|
|
|
22
23
|
return setting.value;
|
|
23
24
|
}
|
|
@@ -30,4 +31,4 @@ export class Settings implements SettingsService {
|
|
|
30
31
|
await db.insert(tables.Setting, { name, value });
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
}
|
|
34
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Table, StringColumn, Record, withRecordColumns, ObjectColumn } from '@proteinjs/db';
|
|
2
2
|
|
|
3
3
|
export interface Setting extends Record {
|
|
4
|
-
|
|
4
|
+
name: string;
|
|
5
5
|
value: any;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export class SettingTable extends Table<Setting> {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
public name = 'setting';
|
|
10
|
+
public auth: Table<Setting>['auth'] = {
|
|
11
11
|
db: {
|
|
12
12
|
all: 'authenticated',
|
|
13
13
|
},
|
|
@@ -15,8 +15,8 @@ export class SettingTable extends Table<Setting> {
|
|
|
15
15
|
all: 'authenticated',
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
public columns = withRecordColumns<Setting>({
|
|
19
19
|
name: new StringColumn('name'),
|
|
20
20
|
value: new ObjectColumn('value'),
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
});
|
|
22
|
+
}
|
package/src/tables/tables.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"node", "jest"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "./",
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"outDir": "./dist/",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noImplicitAny": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"typeRoots": ["./node_modules/@types"],
|
|
17
|
+
"types": ["node", "jest"]
|
|
18
|
+
}
|
|
19
|
+
}
|