@axinom/mosaic-db-common 0.11.0-rc.6 → 0.11.0
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/CHANGELOG.md +12 -0
- package/dist/auth/authentication-subject.d.ts +13 -0
- package/dist/auth/authentication-subject.d.ts.map +1 -1
- package/dist/auth/authentication-subject.js +1 -0
- package/dist/auth/authentication-subject.js.map +1 -1
- package/dist/auth/helpers.d.ts +4 -4
- package/dist/auth/helpers.d.ts.map +1 -1
- package/dist/auth/helpers.js +4 -4
- package/dist/auth/helpers.js.map +1 -1
- package/dist/cli/commands/generate-vscode-sql-snippets.js +8 -8
- package/dist/cli/commands/generate-vscode-sql-snippets.js.map +1 -1
- package/dist/messaging/messaging-counter.js +5 -5
- package/dist/messaging/messaging-counter.js.map +1 -1
- package/dist/migrations/create-sql-define-functions-migration.js +6 -6
- package/dist/migrations/create-sql-define-functions-migration.js.map +1 -1
- package/dist/migrations/utils.js +10 -10
- package/dist/migrations/utils.js.map +1 -1
- package/dist/zapatos/transaction-with-context.js +4 -4
- package/dist/zapatos/transaction-with-context.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
## [0.11.0](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-db-common@0.10.0&targetVersion=GT@axinom/mosaic-db-common@0.11.0) (2022-02-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* anonymous consumer token WIP ([280a075](https://dev.azure.com/axinom/CMS/_git/Navy/commit/280a075d4da97b24915c6a2c6a71158a1f4c03c5))
|
|
12
|
+
* rebase with master branch ([fe969fa](https://dev.azure.com/axinom/CMS/_git/Navy/commit/fe969fac8a5e64c98174faefd61288907e10eefd))
|
|
13
|
+
* set default ts version ([16ce926](https://dev.azure.com/axinom/CMS/_git/Navy/commit/16ce92627bec279b93f5b21fe6ae830361f201a8))
|
|
14
|
+
* sql snippets generation cli implemented ([164fe2a](https://dev.azure.com/axinom/CMS/_git/Navy/commit/164fe2ad61411f91b5d919f7b4d643d723e60208)), closes [#33834](https://dev.azure.com/axinom/CMS/_workitems/edit/33834)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [0.10.0](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-db-common@0.9.0&targetVersion=GT@axinom/mosaic-db-common@0.10.0) (2022-01-19)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -27,4 +27,17 @@ export interface PgAuthenticatedConsumer {
|
|
|
27
27
|
name: string;
|
|
28
28
|
profileId: string;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* This interface represents an authenticated consumer application.
|
|
32
|
+
* These will be tokens issued by the User Service.
|
|
33
|
+
*
|
|
34
|
+
* Having name and profileId is not mandatory for these tokens.
|
|
35
|
+
*/
|
|
36
|
+
export interface PgAuthenticatedConsumerApplication {
|
|
37
|
+
tenantId: string;
|
|
38
|
+
environmentId: string;
|
|
39
|
+
sub: string;
|
|
40
|
+
name: string;
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}
|
|
30
43
|
//# sourceMappingURL=authentication-subject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-subject.d.ts","sourceRoot":"","sources":["../../src/auth/authentication-subject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authentication-subject.d.ts","sourceRoot":"","sources":["../../src/auth/authentication-subject.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-subject.js","sourceRoot":"","sources":["../../src/auth/authentication-subject.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"authentication-subject.js","sourceRoot":"","sources":["../../src/auth/authentication-subject.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
|
package/dist/auth/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dict } from '../common';
|
|
2
|
-
import { PgAuthenticatedConsumer, PgAuthenticatedManagementSubject } from './authentication-subject';
|
|
2
|
+
import { PgAuthenticatedConsumer, PgAuthenticatedConsumerApplication, PgAuthenticatedManagementSubject } from './authentication-subject';
|
|
3
3
|
/**
|
|
4
4
|
* Builds a pg settings object for the currently authenticated management subject.
|
|
5
5
|
* Used for RLS authentication in both PostGraphile and zapatos.
|
|
@@ -34,11 +34,11 @@ export declare function buildAuthPgSettings(subject: PgAuthenticatedManagementSu
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function buildAuthPgSettings(subject: PgAuthenticatedManagementSubject | undefined): Dict<string>;
|
|
36
36
|
/**
|
|
37
|
-
* Builds a pg settings object for the currently authenticated Consumer with a dedicated DB Role.
|
|
37
|
+
* Builds a pg settings object for the currently authenticated Consumer or Consumer Application with a dedicated DB Role.
|
|
38
38
|
* Used for End User RLS authentication in both PostGraphile and zapatos.
|
|
39
39
|
*
|
|
40
|
-
* @param subject - Currently Authenticated Consumer
|
|
40
|
+
* @param subject - Currently Authenticated Consumer or Consumer Application
|
|
41
41
|
* @param dbRole - The database role to switch to
|
|
42
42
|
*/
|
|
43
|
-
export declare function buildConsumerAuthPgSettings(subject: PgAuthenticatedConsumer | undefined, dbRole: string): Dict<string>;
|
|
43
|
+
export declare function buildConsumerAuthPgSettings(subject: PgAuthenticatedConsumer | PgAuthenticatedConsumerApplication | undefined, dbRole: string): Dict<string>;
|
|
44
44
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAYjC,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EACjC,MAAM,0BAA0B,CAAC;AAElC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,IAAI,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,MAAM,CAAC,CAAC;AAShB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,SAAS,EAAE,MAAM,GAChB,IAAI,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gCAAgC,GAAG,SAAS,GACpD,IAAI,CAAC,MAAM,CAAC,CAAC;AAmBhB;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAYjC,OAAO,EACL,uBAAuB,EACvB,kCAAkC,EAClC,gCAAgC,EACjC,MAAM,0BAA0B,CAAC;AAElC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,IAAI,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,MAAM,CAAC,CAAC;AAShB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,SAAS,EAAE,MAAM,GAChB,IAAI,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gCAAgC,GAAG,SAAS,GACpD,IAAI,CAAC,MAAM,CAAC,CAAC;AAmBhB;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EACH,uBAAuB,GACvB,kCAAkC,GAClC,SAAS,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,MAAM,CAAC,CASd"}
|
package/dist/auth/helpers.js
CHANGED
|
@@ -9,12 +9,12 @@ function buildPgSettings(...args) {
|
|
|
9
9
|
exports.buildPgSettings = buildPgSettings;
|
|
10
10
|
function buildAuthPgSettings(...args) {
|
|
11
11
|
var _a, _b, _c, _d, _e, _f;
|
|
12
|
-
const pgSettings = Object.assign(Object.assign({ [constants_1.MOSAIC_AUTH_SUBJECT_NAME]: (_b = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_AUTH_SUBJECT_NAME, [constants_1.MOSAIC_TENANT_ID]: (_d = (_c = args[0]) === null || _c === void 0 ? void 0 : _c.tenantId) !== null && _d !== void 0 ? _d : '', [constants_1.MOSAIC_ENVIRONMENT_ID]: (_f = (_e = args[0]) === null || _e === void 0 ? void 0 : _e.environmentId) !== null && _f !== void 0 ? _f : '' }, zapatos_1.optional(args[1], () => {
|
|
12
|
+
const pgSettings = Object.assign(Object.assign({ [constants_1.MOSAIC_AUTH_SUBJECT_NAME]: (_b = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_AUTH_SUBJECT_NAME, [constants_1.MOSAIC_TENANT_ID]: (_d = (_c = args[0]) === null || _c === void 0 ? void 0 : _c.tenantId) !== null && _d !== void 0 ? _d : '', [constants_1.MOSAIC_ENVIRONMENT_ID]: (_f = (_e = args[0]) === null || _e === void 0 ? void 0 : _e.environmentId) !== null && _f !== void 0 ? _f : '' }, (0, zapatos_1.optional)(args[1], () => {
|
|
13
13
|
var _a, _b, _c, _d;
|
|
14
14
|
return ({
|
|
15
15
|
[constants_1.MOSAIC_AUTH_TAGS]: (_d = (_c = (_b = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.tags) === null || _b === void 0 ? void 0 : _b.join) === null || _c === void 0 ? void 0 : _c.call(_b, ',')) !== null && _d !== void 0 ? _d : '',
|
|
16
16
|
});
|
|
17
|
-
})), zapatos_1.optional(args[1], (serviceId) => {
|
|
17
|
+
})), (0, zapatos_1.optional)(args[1], (serviceId) => {
|
|
18
18
|
var _a, _b, _c, _d, _e;
|
|
19
19
|
return ({
|
|
20
20
|
[constants_1.MOSAIC_AUTH_PERMISSIONS]: (_e = (_d = (_c = (_b = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b[serviceId]) === null || _c === void 0 ? void 0 : _c.join) === null || _d === void 0 ? void 0 : _d.call(_c, ',')) !== null && _e !== void 0 ? _e : '',
|
|
@@ -24,10 +24,10 @@ function buildAuthPgSettings(...args) {
|
|
|
24
24
|
}
|
|
25
25
|
exports.buildAuthPgSettings = buildAuthPgSettings;
|
|
26
26
|
/**
|
|
27
|
-
* Builds a pg settings object for the currently authenticated Consumer with a dedicated DB Role.
|
|
27
|
+
* Builds a pg settings object for the currently authenticated Consumer or Consumer Application with a dedicated DB Role.
|
|
28
28
|
* Used for End User RLS authentication in both PostGraphile and zapatos.
|
|
29
29
|
*
|
|
30
|
-
* @param subject - Currently Authenticated Consumer
|
|
30
|
+
* @param subject - Currently Authenticated Consumer or Consumer Application
|
|
31
31
|
* @param dbRole - The database role to switch to
|
|
32
32
|
*/
|
|
33
33
|
function buildConsumerAuthPgSettings(subject, dbRole) {
|
package/dist/auth/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":";;;AAEA,4CASsB;AACtB,wCAAsC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":";;;AAEA,4CASsB;AACtB,wCAAsC;AAiCtC,SAAgB,eAAe,CAAC,GAAG,IAAW;IAC5C,uBACE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IACV,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EACxC;AACJ,CAAC;AALD,0CAKC;AAyBD,SAAgB,mBAAmB,CAAC,GAAG,IAAW;;IAChD,MAAM,UAAU,iCACd,CAAC,oCAAwB,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,mCAAI,qCAAyB,EACtE,CAAC,4BAA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uBAAP,OAAO,CAAE,GAAG,mCAAI,EAAE;QAC7C,CAAC,kCAAsB,CAAC,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,EAAE;KACnD,CAAC;AACJ,CAAC;AAfD,kEAeC"}
|
|
@@ -36,12 +36,12 @@ const getTimestamp = () => {
|
|
|
36
36
|
* Returns a success message.
|
|
37
37
|
*/
|
|
38
38
|
const writeSourceFile = (snippetsFileName, contents) => {
|
|
39
|
-
const outDir = path_1.join(process.env.PROJECT_CWD || process.cwd(), '.vscode');
|
|
40
|
-
if (!fs_1.existsSync(outDir)) {
|
|
41
|
-
fs_1.mkdirSync(outDir, { recursive: true });
|
|
39
|
+
const outDir = (0, path_1.join)(process.env.PROJECT_CWD || process.cwd(), '.vscode');
|
|
40
|
+
if (!(0, fs_1.existsSync)(outDir)) {
|
|
41
|
+
(0, fs_1.mkdirSync)(outDir, { recursive: true });
|
|
42
42
|
}
|
|
43
|
-
const filePath = path_1.join(outDir, `${snippetsFileName}.code-snippets`);
|
|
44
|
-
fs_1.writeFileSync(filePath, JSON.stringify(contents, null, 2), 'utf-8');
|
|
43
|
+
const filePath = (0, path_1.join)(outDir, `${snippetsFileName}.code-snippets`);
|
|
44
|
+
(0, fs_1.writeFileSync)(filePath, JSON.stringify(contents, null, 2), 'utf-8');
|
|
45
45
|
return `Success! Snippets file path: ${filePath}`;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
@@ -80,7 +80,7 @@ const parseFunctionName = (line, snippetJson) => {
|
|
|
80
80
|
* Depends on comment conventions to work properly.
|
|
81
81
|
*/
|
|
82
82
|
const populateSnippets = async (filePath, snippetsObject) => {
|
|
83
|
-
const contents = fs_1.readFileSync(filePath, 'utf-8').split('\n').filter(Boolean);
|
|
83
|
+
const contents = (0, fs_1.readFileSync)(filePath, 'utf-8').split('\n').filter(Boolean);
|
|
84
84
|
const startTag = '/*-snippet';
|
|
85
85
|
const endTag = 'snippet-*/';
|
|
86
86
|
const funcLine = 'create or replace function';
|
|
@@ -155,7 +155,7 @@ const getCustomSnippets = async (dirPath, includeMultitenancySnippets) => {
|
|
|
155
155
|
continue;
|
|
156
156
|
}
|
|
157
157
|
console.log(getTimestamp(), `Reading ${path}`);
|
|
158
|
-
const fileContents = JSON.parse(fs_1.readFileSync(fullPath, 'utf-8'));
|
|
158
|
+
const fileContents = JSON.parse((0, fs_1.readFileSync)(fullPath, 'utf-8'));
|
|
159
159
|
customSnippets = Object.assign(Object.assign({}, customSnippets), fileContents);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -176,7 +176,7 @@ const getCustomSnippets = async (dirPath, includeMultitenancySnippets) => {
|
|
|
176
176
|
*/
|
|
177
177
|
const generate = async ({ includeMultitenancySnippets, snippetsFileNameWithoutExtension, }) => {
|
|
178
178
|
console.log(getTimestamp(), green(`Starting snippets generation!`));
|
|
179
|
-
const dirPath = path_1.resolve(__dirname, '../../../migrations');
|
|
179
|
+
const dirPath = (0, path_1.resolve)(__dirname, '../../../migrations');
|
|
180
180
|
const parsedSnippets = await getParsedSnippets(dirPath, includeMultitenancySnippets);
|
|
181
181
|
const customSnippets = await getCustomSnippets(dirPath, includeMultitenancySnippets);
|
|
182
182
|
const writeResult = writeSourceFile(snippetsFileNameWithoutExtension, Object.assign(Object.assign({}, parsedSnippets), customSnippets));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-vscode-sql-snippets.js","sourceRoot":"","sources":["../../../src/cli/commands/generate-vscode-sql-snippets.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,+BAA+B;AAC/B,2BAAwE;AACxE,+BAAqC;AACrC,oCAAoC;AAWpC;;GAEG;AACH,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,YAAY,CAAC;AAEtE;;GAEG;AACH,MAAM,GAAG,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,YAAY,CAAC;AAEpE;;GAEG;AACH,MAAM,YAAY,GAAG,GAAW,EAAE;IAChC,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC,CAAC,wBAAwB;IAC/E,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;SAC/C,WAAW,EAAE;SACb,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACZ,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrB,OAAO,IAAI,YAAY,GAAG,CAAC;AAC7B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,eAAe,GAAG,CACtB,gBAAwB,EACxB,QAAiC,EACzB,EAAE;IACV,MAAM,MAAM,GAAG,WAAI,
|
|
1
|
+
{"version":3,"file":"generate-vscode-sql-snippets.js","sourceRoot":"","sources":["../../../src/cli/commands/generate-vscode-sql-snippets.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,+BAA+B;AAC/B,2BAAwE;AACxE,+BAAqC;AACrC,oCAAoC;AAWpC;;GAEG;AACH,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,YAAY,CAAC;AAEtE;;GAEG;AACH,MAAM,GAAG,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,YAAY,CAAC;AAEpE;;GAEG;AACH,MAAM,YAAY,GAAG,GAAW,EAAE;IAChC,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC,CAAC,wBAAwB;IAC/E,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;SAC/C,WAAW,EAAE;SACb,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACZ,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrB,OAAO,IAAI,YAAY,GAAG,CAAC;AAC7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,yBAAyB,GAGlC;IACF,OAAO,EAAE,8BAA8B;IACvC,QAAQ,EACN,yGAAyG;IAC3G,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,6BAA6B,EAAE;QACrC,KAAK,EAAE,GAAG;QACV,QAAQ,EACN,gFAAgF;QAClF,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,CAAC,kCAAkC,EAAE;QAC1C,KAAK,EAAE,GAAG;QACV,QAAQ,EACN,qHAAqH;QACvH,OAAO,EAAE,uBAAuB;QAChC,MAAM,EAAE,IAAI;KACb,CAAC;IACN,OAAO,EAAE,QAAQ;CAClB,CAAC"}
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initMessagingCounter = exports.cleanupExpiredMessagingCounters = void 0;
|
|
4
4
|
const db_1 = require("zapatos/db");
|
|
5
5
|
const incrementAndGetCounter = async (key, ownerPool) => {
|
|
6
|
-
return db_1.transaction(ownerPool, db_1.IsolationLevel.Serializable, async (txnClient) => {
|
|
6
|
+
return (0, db_1.transaction)(ownerPool, db_1.IsolationLevel.Serializable, async (txnClient) => {
|
|
7
7
|
const counterKey = {
|
|
8
8
|
key: key,
|
|
9
9
|
};
|
|
10
|
-
const [{ counter }] = await db_1.sql `
|
|
10
|
+
const [{ counter }] = await (0, db_1.sql) `
|
|
11
11
|
INSERT INTO app_private.messaging_counter (key)
|
|
12
|
-
VALUES (${db_1.vals(counterKey)})
|
|
12
|
+
VALUES (${(0, db_1.vals)(counterKey)})
|
|
13
13
|
ON CONFLICT (key)
|
|
14
14
|
DO UPDATE
|
|
15
15
|
SET counter = app_private.messaging_counter.counter + 1,
|
|
@@ -25,14 +25,14 @@ const incrementAndGetCounter = async (key, ownerPool) => {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
const deleteExpiredMessagingCounters = async (txnClient) => {
|
|
28
|
-
await db_1.sql `DELETE FROM app_private.messaging_counter WHERE expiration_date < current_timestamp`.run(txnClient);
|
|
28
|
+
await (0, db_1.sql) `DELETE FROM app_private.messaging_counter WHERE expiration_date < current_timestamp`.run(txnClient);
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* This method can be called from a CRON job/task scheduler to regularly cleanup expired messages.
|
|
32
32
|
* @param ownerPool database pool with select and delete permissions to `app_private.messaging_counter`
|
|
33
33
|
*/
|
|
34
34
|
const cleanupExpiredMessagingCounters = async (ownerPool) => {
|
|
35
|
-
await db_1.transaction(ownerPool, db_1.IsolationLevel.Serializable, async (txnClient) => {
|
|
35
|
+
await (0, db_1.transaction)(ownerPool, db_1.IsolationLevel.Serializable, async (txnClient) => {
|
|
36
36
|
await deleteExpiredMessagingCounters(txnClient);
|
|
37
37
|
});
|
|
38
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging-counter.js","sourceRoot":"","sources":["../../src/messaging/messaging-counter.ts"],"names":[],"mappings":";;;AACA,mCAA+E;AAE/E,MAAM,sBAAsB,GAAG,KAAK,EAClC,GAAW,EACX,SAAe,EACE,EAAE;IACnB,OAAO,gBAAW,
|
|
1
|
+
{"version":3,"file":"messaging-counter.js","sourceRoot":"","sources":["../../src/messaging/messaging-counter.ts"],"names":[],"mappings":";;;AACA,mCAA+E;AAE/E,MAAM,sBAAsB,GAAG,KAAK,EAClC,GAAW,EACX,SAAe,EACE,EAAE;IACnB,OAAO,IAAA,gBAAW,EAChB,SAAS,EACT,mBAAc,CAAC,YAAY,EAC3B,KAAK,EAAE,SAAS,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG;YACjB,GAAG,EAAE,GAAG;SACT,CAAC;QACF,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,IAAA,QAAG,EAAA;;oBAEjB,IAAA,SAAI,EAAC,UAAU,CAAC;;;;;;OAM7B,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEjB,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-4,7 +4,7 @@ exports.createSqlMultitenancyDefineFunctionsMigration = exports.createSqlDefineF
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const getPathToDefinitionsFolder = () => {
|
|
7
|
-
return path_1.resolve(__dirname, '..', '..', 'migrations', 'define');
|
|
7
|
+
return (0, path_1.resolve)(__dirname, '..', '..', 'migrations', 'define');
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* Reads the latest contents of the SQL functions to easily define tables, indexes, ...
|
|
@@ -15,9 +15,9 @@ const getPathToDefinitionsFolder = () => {
|
|
|
15
15
|
* @param postfixContent - content that should be added to the end. Useful for adding your own define functions.
|
|
16
16
|
*/
|
|
17
17
|
const createSqlDefineFunctionsMigration = async (migrationFolderPath, postfixContent = '') => {
|
|
18
|
-
const currentSqlFile = path_1.join(migrationFolderPath, 'current.sql');
|
|
18
|
+
const currentSqlFile = (0, path_1.join)(migrationFolderPath, 'current.sql');
|
|
19
19
|
let currentSql = '';
|
|
20
|
-
if (fs_1.existsSync(currentSqlFile)) {
|
|
20
|
+
if ((0, fs_1.existsSync)(currentSqlFile)) {
|
|
21
21
|
currentSql = await fs_1.promises.readFile(currentSqlFile, 'utf8');
|
|
22
22
|
const currentSqlWithoutComments = currentSql.replace(/(--.*)|(((\/\*)+?[\w\W]+?(\*\/)+))/gm, '');
|
|
23
23
|
const nonEmptyCurrentSqlLines = currentSqlWithoutComments.match(/^[^\S\r\n]*\S.*$/gm);
|
|
@@ -26,7 +26,7 @@ const createSqlDefineFunctionsMigration = async (migrationFolderPath, postfixCon
|
|
|
26
26
|
throw new Error('Please ensure that your current.sql file is empty/only contains comments.');
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
const defineFunctions = await fs_1.promises.readFile(path_1.join(getPathToDefinitionsFolder(), 'define-functions.sql'), 'utf8');
|
|
29
|
+
const defineFunctions = await fs_1.promises.readFile((0, path_1.join)(getPathToDefinitionsFolder(), 'define-functions.sql'), 'utf8');
|
|
30
30
|
const migrationContent = `--! Message: upgrade SQL define functions
|
|
31
31
|
|
|
32
32
|
${defineFunctions}
|
|
@@ -42,8 +42,8 @@ exports.createSqlDefineFunctionsMigration = createSqlDefineFunctionsMigration;
|
|
|
42
42
|
* @param migrationFolderPath - the path to the migration folder path where the current.sql file should be created.
|
|
43
43
|
*/
|
|
44
44
|
const createSqlMultitenancyDefineFunctionsMigration = async (migrationFolderPath) => {
|
|
45
|
-
const multitenancyDefineFunctions = await fs_1.promises.readFile(path_1.join(getPathToDefinitionsFolder(), 'define-multitenancy-functions.sql'), 'utf8');
|
|
46
|
-
await exports.createSqlDefineFunctionsMigration(migrationFolderPath, multitenancyDefineFunctions);
|
|
45
|
+
const multitenancyDefineFunctions = await fs_1.promises.readFile((0, path_1.join)(getPathToDefinitionsFolder(), 'define-multitenancy-functions.sql'), 'utf8');
|
|
46
|
+
await (0, exports.createSqlDefineFunctionsMigration)(migrationFolderPath, multitenancyDefineFunctions);
|
|
47
47
|
};
|
|
48
48
|
exports.createSqlMultitenancyDefineFunctionsMigration = createSqlMultitenancyDefineFunctionsMigration;
|
|
49
49
|
//# sourceMappingURL=create-sql-define-functions-migration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-sql-define-functions-migration.js","sourceRoot":"","sources":["../../src/migrations/create-sql-define-functions-migration.ts"],"names":[],"mappings":";;;AAAA,2BAAiD;AACjD,+BAAqC;AAErC,MAAM,0BAA0B,GAAG,GAAW,EAAE;IAC9C,OAAO,cAAO,
|
|
1
|
+
{"version":3,"file":"create-sql-define-functions-migration.js","sourceRoot":"","sources":["../../src/migrations/create-sql-define-functions-migration.ts"],"names":[],"mappings":";;;AAAA,2BAAiD;AACjD,+BAAqC;AAErC,MAAM,0BAA0B,GAAG,GAAW,EAAE;IAC9C,OAAO,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AA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;AACJ,CAAC,CAAC;AAXW,QAAA,6CAA6C,iDAWxD"}
|
package/dist/migrations/utils.js
CHANGED
|
@@ -25,10 +25,10 @@ const runSqlScripts = async (settings, dirPath, logger) => {
|
|
|
25
25
|
try {
|
|
26
26
|
for (var sortedList_1 = __asyncValues(sortedList), sortedList_1_1; sortedList_1_1 = await sortedList_1.next(), !sortedList_1_1.done;) {
|
|
27
27
|
const { path } = sortedList_1_1.value;
|
|
28
|
-
const scriptPath = path_1.join(dirPath, path);
|
|
28
|
+
const scriptPath = (0, path_1.join)(dirPath, path);
|
|
29
29
|
const content = await fs_1.promises.readFile(scriptPath, 'utf8');
|
|
30
30
|
logger.debug(`Running Script: '${scriptPath}'`);
|
|
31
|
-
await graphile_migrate_1.run(settings, content, path);
|
|
31
|
+
await (0, graphile_migrate_1.run)(settings, content, path);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -49,7 +49,7 @@ const runCurrentSql = async (settings, logger) => {
|
|
|
49
49
|
const path = 'migrations/current.sql';
|
|
50
50
|
const content = await fs_1.promises.readFile(path, 'utf8');
|
|
51
51
|
logger.debug(`Running Script: '${path}'`);
|
|
52
|
-
await graphile_migrate_1.run(settings, content, path);
|
|
52
|
+
await (0, graphile_migrate_1.run)(settings, content, path);
|
|
53
53
|
};
|
|
54
54
|
exports.runCurrentSql = runCurrentSql;
|
|
55
55
|
/**
|
|
@@ -68,11 +68,11 @@ exports.runCurrentSql = runCurrentSql;
|
|
|
68
68
|
```
|
|
69
69
|
*/
|
|
70
70
|
const getBeforeMigrationScripts = async () => {
|
|
71
|
-
const executionPath = path_1.join(process.cwd(), 'migrations');
|
|
72
|
-
const dirPath = path_1.resolve(__dirname, '..', '..', 'migrations', 'before-migration');
|
|
71
|
+
const executionPath = (0, path_1.join)(process.cwd(), 'migrations');
|
|
72
|
+
const dirPath = (0, path_1.resolve)(__dirname, '..', '..', 'migrations', 'before-migration');
|
|
73
73
|
return (await readdir.promise(dirPath, { fileFilter: '*.sql' }))
|
|
74
74
|
.sort((a, b) => a.path.localeCompare(b.path))
|
|
75
|
-
.map((file) => path_1.relative(executionPath, file.fullPath));
|
|
75
|
+
.map((file) => (0, path_1.relative)(executionPath, file.fullPath));
|
|
76
76
|
};
|
|
77
77
|
exports.getBeforeMigrationScripts = getBeforeMigrationScripts;
|
|
78
78
|
/**
|
|
@@ -86,15 +86,15 @@ const getGraphileBuildPgWatchFixturesPath = () => {
|
|
|
86
86
|
// Directory structure is traversed manually, because we want to first check project node_modules, and then repository node_modules.
|
|
87
87
|
// require.resolve is not useful here, because it will resolve a path to `graphile-build-pg` which is installed in this lib, and not in target project (which can be different).
|
|
88
88
|
while (lastPath !== startPath) {
|
|
89
|
-
const lookupPath = path_1.join(startPath, 'node_modules', 'graphile-build-pg', 'res', 'watch-fixtures.sql');
|
|
90
|
-
if (fs_1.existsSync(lookupPath)) {
|
|
91
|
-
return path_1.relative(path_1.join(process.cwd(), 'migrations'), lookupPath);
|
|
89
|
+
const lookupPath = (0, path_1.join)(startPath, 'node_modules', 'graphile-build-pg', 'res', 'watch-fixtures.sql');
|
|
90
|
+
if ((0, fs_1.existsSync)(lookupPath)) {
|
|
91
|
+
return (0, path_1.relative)((0, path_1.join)(process.cwd(), 'migrations'), lookupPath);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
// Preserve currently checked path for while condition comparison
|
|
95
95
|
lastPath = startPath;
|
|
96
96
|
// Remove last segment from path
|
|
97
|
-
startPath = path_1.normalize(path_1.join(startPath, '..'));
|
|
97
|
+
startPath = (0, path_1.normalize)((0, path_1.join)(startPath, '..'));
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
throw Error('`node_modules\\graphile-build-pg\\res\\watch-fixtures.sql` file not found. Please make sure that `graphile-build-pg` is installed.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/migrations/utils.ts"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AC,IAAA,eAAQ,EAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC;AAZW,QAAA,yBAAyB,6BAYpC;AAEF;;;;GAIG;AACI,MAAM,mCAAmC,GAAG,GAAW,EAAE;IAC9D,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,oIAAoI;IACpI,gLAAgL;IAChL,OAAO,QAAQ,KAAK,SAAS,EAAE;QAC7B,MAAM,UAAU,GAAG,IAAA,WAAI,EACrB,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,oBAAoB,CACrB,CAAC;QACF,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE;YAC1B,OAAO,IAAA,eAAQ,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,EAAE,UAAU,CAAC,CAAC;SAChE;aAAM;YACL,iEAAiE;YACjE,QAAQ,GAAG,SAAS,CAAC;YACrB,gCAAgC;YAChC,SAAS,GAAG,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;SAC9C;KACF;IACD,MAAM,KAAK,CACT,oIAAoI,CACrI,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,mCAAmC,uCAyB9C"}
|
|
@@ -10,14 +10,14 @@ const db_1 = require("zapatos/db");
|
|
|
10
10
|
* @param callback - Callback where queries are executed.
|
|
11
11
|
*/
|
|
12
12
|
const transactionWithContext = async (pool, isolationLevel, pgSettings = {}, callback) => {
|
|
13
|
-
return db_1.transaction(pool, isolationLevel, async (ctx) => {
|
|
13
|
+
return (0, db_1.transaction)(pool, isolationLevel, async (ctx) => {
|
|
14
14
|
for (const property in pgSettings) {
|
|
15
15
|
if (!Object.prototype.hasOwnProperty.call(pgSettings, property)) {
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
|
-
const key = db_1.param(property);
|
|
19
|
-
const val = db_1.param(pgSettings[property]);
|
|
20
|
-
await db_1.sql `SELECT set_config(${key}, ${val}, TRUE)`.run(ctx);
|
|
18
|
+
const key = (0, db_1.param)(property);
|
|
19
|
+
const val = (0, db_1.param)(pgSettings[property]);
|
|
20
|
+
await (0, db_1.sql) `SELECT set_config(${key}, ${val}, TRUE)`.run(ctx);
|
|
21
21
|
}
|
|
22
22
|
return callback(ctx);
|
|
23
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-with-context.js","sourceRoot":"","sources":["../../src/zapatos/transaction-with-context.ts"],"names":[],"mappings":";;;AACA,mCAAgF;AAIhF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAAc,EACd,cAA8B,EAC9B,aAEI,EAAE,EACN,QAA2D,EAC/C,EAAE;IACd,OAAO,gBAAW,
|
|
1
|
+
{"version":3,"file":"transaction-with-context.js","sourceRoot":"","sources":["../../src/zapatos/transaction-with-context.ts"],"names":[],"mappings":";;;AACA,mCAAgF;AAIhF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAAc,EACd,cAA8B,EAC9B,aAEI,EAAE,EACN,QAA2D,EAC/C,EAAE;IACd,OAAO,IAAA,gBAAW,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrD,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE;gBAC/D,SAAS;aACV;YAED,MAAM,GAAG,GAAG,IAAA,UAAK,EAAC,QAAQ,CAAC,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAA,UAAK,EAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YACxC,MAAM,IAAA,QAAG,EAAA,qBAAqB,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC7D;QACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,sBAAsB,0BAoBjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-db-common",
|
|
3
|
-
"version": "0.11.0
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "This library encapsulates database-related functionality to develop Mosaic based services.",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"jest": "26.6.0",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
47
47
|
"ts-node": "^8.9.0",
|
|
48
|
-
"typescript": "^4.
|
|
48
|
+
"typescript": "^4.5.4"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f80cb6c17c7fe9993994473b513b568c7ae718d8"
|
|
54
54
|
}
|