@axinom/mosaic-db-common 0.13.0 → 0.14.0-rc.10

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.
Files changed (41) hide show
  1. package/dist/auth/helpers.d.ts +2 -2
  2. package/dist/auth/helpers.js +3 -3
  3. package/dist/cli/commands/generate-define-func-migration.d.ts +14 -0
  4. package/dist/cli/commands/generate-define-func-migration.d.ts.map +1 -0
  5. package/dist/cli/commands/generate-define-func-migration.js +72 -0
  6. package/dist/cli/commands/generate-define-func-migration.js.map +1 -0
  7. package/dist/cli/commands/generate-vscode-sql-snippets.d.ts.map +1 -1
  8. package/dist/cli/commands/generate-vscode-sql-snippets.js +7 -24
  9. package/dist/cli/commands/generate-vscode-sql-snippets.js.map +1 -1
  10. package/dist/cli/commands/index.d.ts +1 -0
  11. package/dist/cli/commands/index.d.ts.map +1 -1
  12. package/dist/cli/commands/index.js +1 -0
  13. package/dist/cli/commands/index.js.map +1 -1
  14. package/dist/cli/commands/utils.d.ts +13 -0
  15. package/dist/cli/commands/utils.d.ts.map +1 -0
  16. package/dist/cli/commands/utils.js +26 -0
  17. package/dist/cli/commands/utils.js.map +1 -0
  18. package/dist/cli/index.d.ts +2 -1
  19. package/dist/cli/index.d.ts.map +1 -1
  20. package/dist/cli/index.js +7 -11
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/constants/pg-auth-settings-keys.d.ts +3 -3
  23. package/dist/constants/pg-auth-settings-keys.js +4 -4
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/migrations/index.d.ts +0 -1
  29. package/dist/migrations/index.d.ts.map +1 -1
  30. package/dist/migrations/index.js +0 -3
  31. package/dist/migrations/index.js.map +1 -1
  32. package/dist/migrations/utils.d.ts +1 -1
  33. package/dist/migrations/utils.js +1 -1
  34. package/migrations/README.md +14 -11
  35. package/migrations/define/define-functions.sql +6 -6
  36. package/package.json +2 -5
  37. package/bin/mosaic-db.js +0 -3
  38. package/dist/migrations/create-sql-define-functions-migration.d.ts +0 -16
  39. package/dist/migrations/create-sql-define-functions-migration.d.ts.map +0 -1
  40. package/dist/migrations/create-sql-define-functions-migration.js +0 -49
  41. package/dist/migrations/create-sql-define-functions-migration.js.map +0 -1
@@ -34,10 +34,10 @@ 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 or Consumer Application with a dedicated DB Role.
37
+ * Builds a pg settings object for the currently authenticated end-user or end-user 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 or Consumer Application
40
+ * @param subject - Currently Authenticated end-user or end-user application
41
41
  * @param dbRole - The database role to switch to
42
42
  */
43
43
  export declare function buildConsumerAuthPgSettings(subject: PgAuthenticatedConsumer | PgAuthenticatedConsumerApplication | undefined, dbRole: string): Dict<string>;
@@ -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 or Consumer Application with a dedicated DB Role.
27
+ * Builds a pg settings object for the currently authenticated end-user or end-user 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 or Consumer Application
30
+ * @param subject - Currently Authenticated end-user or end-user application
31
31
  * @param dbRole - The database role to switch to
32
32
  */
33
33
  function buildConsumerAuthPgSettings(subject, dbRole) {
@@ -37,7 +37,7 @@ function buildConsumerAuthPgSettings(subject, dbRole) {
37
37
  [constants_1.MOSAIC_AUTH_SUBJECT_NAME]: (_a = subject === null || subject === void 0 ? void 0 : subject.name) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_AUTH_SUBJECT_NAME,
38
38
  [constants_1.MOSAIC_TENANT_ID]: (_b = subject === null || subject === void 0 ? void 0 : subject.tenantId) !== null && _b !== void 0 ? _b : '',
39
39
  [constants_1.MOSAIC_ENVIRONMENT_ID]: (_c = subject === null || subject === void 0 ? void 0 : subject.environmentId) !== null && _c !== void 0 ? _c : '',
40
- [constants_1.MOSAIC_AUTH_CONSUMER_ID]: (_d = subject === null || subject === void 0 ? void 0 : subject.sub) !== null && _d !== void 0 ? _d : '',
40
+ [constants_1.MOSAIC_AUTH_END_USER_ID]: (_d = subject === null || subject === void 0 ? void 0 : subject.sub) !== null && _d !== void 0 ? _d : '',
41
41
  [constants_1.MOSAIC_AUTH_PROFILE_ID]: (_e = subject === null || subject === void 0 ? void 0 : subject.profileId) !== null && _e !== void 0 ? _e : '',
42
42
  };
43
43
  }
@@ -0,0 +1,14 @@
1
+ import { CommandModule } from 'yargs';
2
+ /**
3
+ * CLI command options object.
4
+ */
5
+ interface GenerateMigrationOptions {
6
+ includeMultitenancyFunctions: boolean;
7
+ currentMigrationFolderPath: string;
8
+ }
9
+ /**
10
+ * Yargs command module definition for `generate-define-func-migration` CLI script.
11
+ */
12
+ export declare const generateDefineFuncMigration: CommandModule<unknown, GenerateMigrationOptions>;
13
+ export {};
14
+ //# sourceMappingURL=generate-define-func-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-define-func-migration.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate-define-func-migration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;GAEG;AACH,UAAU,wBAAwB;IAChC,4BAA4B,EAAE,OAAO,CAAC;IACtC,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAkFD;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,aAAa,CACrD,OAAO,EACP,wBAAwB,CAuBzB,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDefineFuncMigration = void 0;
4
+ /* eslint-disable no-console */
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const utils_1 = require("./utils");
8
+ const ensureEmptyCurrentSql = async (currentMigrationFolderPath) => {
9
+ const dirPath = (0, path_1.join)(process.cwd(), currentMigrationFolderPath);
10
+ const filePath = (0, path_1.join)(dirPath, 'current.sql');
11
+ if ((0, fs_1.existsSync)(filePath)) {
12
+ const currentSql = await fs_1.promises.readFile(filePath, 'utf8');
13
+ const currentSqlWithoutComments = currentSql.replace(/(--.*)|(((\/\*)+?[\w\W]+?(\*\/)+))/gm, '');
14
+ const nonEmptyCurrentSqlLines = currentSqlWithoutComments.match(/^[^\S\r\n]*\S.*$/gm);
15
+ if (nonEmptyCurrentSqlLines !== null &&
16
+ nonEmptyCurrentSqlLines.length > 0) {
17
+ console.error((0, utils_1.getTimestamp)(), (0, utils_1.red)('Please ensure that your current.sql file is empty/only contains comments.'));
18
+ process.exit(-1);
19
+ }
20
+ }
21
+ else if (!(0, fs_1.existsSync)(dirPath)) {
22
+ // File itself is created after contents are generated
23
+ await fs_1.promises.mkdir(dirPath, { recursive: true });
24
+ }
25
+ return filePath;
26
+ };
27
+ const generateContent = async (includeMultitenancyFunctions) => {
28
+ const defineFunctionsPath = (0, path_1.resolve)(__dirname, '../../../migrations/define');
29
+ const defineFunctions = await fs_1.promises.readFile((0, path_1.join)(defineFunctionsPath, 'define-functions.sql'));
30
+ let result = `--! Message: upgrade SQL define functions\n\n${defineFunctions}`;
31
+ if (includeMultitenancyFunctions) {
32
+ const multitenancyDefineFunctions = await fs_1.promises.readFile((0, path_1.join)(defineFunctionsPath, 'define-multitenancy-functions.sql'));
33
+ result = `${result}\n${multitenancyDefineFunctions}`;
34
+ }
35
+ return result;
36
+ };
37
+ /**
38
+ * Reads the latest contents of the SQL functions to easily define tables,
39
+ * indexes, etc... We check that migration file is empty/only contains SQL
40
+ * comments before updating it. If it did not exist - will create it.
41
+ */
42
+ const generate = async ({ includeMultitenancyFunctions, currentMigrationFolderPath, // migrations
43
+ }) => {
44
+ console.log((0, utils_1.getTimestamp)(), (0, utils_1.green)('Starting define functions update migration generation!'));
45
+ const absolutePath = await ensureEmptyCurrentSql(currentMigrationFolderPath);
46
+ const migrationContent = await generateContent(includeMultitenancyFunctions);
47
+ await fs_1.promises.writeFile(absolutePath, migrationContent);
48
+ console.log((0, utils_1.getTimestamp)(), (0, utils_1.green)(`Migration file ${currentMigrationFolderPath} updated!`));
49
+ };
50
+ /**
51
+ * Yargs command module definition for `generate-define-func-migration` CLI script.
52
+ */
53
+ exports.generateDefineFuncMigration = {
54
+ command: 'generate-define-func-migration',
55
+ describe: 'Updates a current.sql migrations file with latest ax_define helper function definitions.',
56
+ builder: (yargs) => yargs
57
+ .option('includeMultitenancyFunctions', {
58
+ alias: 'm',
59
+ describe: 'If set to true, would also include multitenancy define functions.',
60
+ default: false,
61
+ boolean: true,
62
+ hidden: true,
63
+ })
64
+ .option('currentMigrationFolderPath', {
65
+ alias: 'p',
66
+ default: 'migrations',
67
+ describe: 'Relative path from working directory to a folder containing current.sql file, which will be updated with latest ax_define function definitions.',
68
+ string: true,
69
+ }),
70
+ handler: generate,
71
+ };
72
+ //# sourceMappingURL=generate-define-func-migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-define-func-migration.js","sourceRoot":"","sources":["../../../src/cli/commands/generate-define-func-migration.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2BAAiD;AACjD,+BAAqC;AAErC,mCAAmD;AAUnD,MAAM,qBAAqB,GAAG,KAAK,EACjC,0BAAkC,EACjB,EAAE;IACnB,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,0BAA0B,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC9C,IAAI,IAAA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AAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,QAAQ,GAAG,KAAK,EAAE,EACtB,4BAA4B,EAC5B,0BAA0B,EAAE,aAAa;EAChB,EAAiB,EAAE;IAC5C,OAAO,CAAC,GAAG,CACT,IAAA,oBAAY,GAAE,EACd,IAAA,aAAK,EAAC,wDAAwD,CAAC,CAChE,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;IAE7E,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,4BAA4B,CAAC,CAAC;IAE7E,MAAM,aAAG,CAAC,SAAS,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAEpD,OAAO,CAAC,GAAG,CACT,IAAA,oBAAY,GAAE,EACd,IAAA,aAAK,EAAC,kBAAkB,0BAA0B,WAAW,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACU,QAAA,2BAA2B,GAGpC;IACF,OAAO,EAAE,gCAAgC;IACzC,QAAQ,EACN,0FAA0F;IAC5F,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,8BAA8B,EAAE;QACtC,KAAK,EAAE,GAAG;QACV,QAAQ,EACN,mEAAmE;QACrE,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;KACb,CAAC;SACD,MAAM,CAAC,4BAA4B,EAAE;QACpC,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,YAAY;QACrB,QAAQ,EACN,iJAAiJ;QACnJ,MAAM,EAAE,IAAI;KACb,CAAC;IACN,OAAO,EAAE,QAAQ;CAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-vscode-sql-snippets.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate-vscode-sql-snippets.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC;;GAEG;AACH,UAAU,uBAAuB;IAC/B,2BAA2B,EAAE,OAAO,CAAC;IACrC,gCAAgC,EAAE,MAAM,CAAC;CAC1C;AAqMD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CACnD,OAAO,EACP,uBAAuB,CAsBxB,CAAC"}
1
+ {"version":3,"file":"generate-vscode-sql-snippets.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate-vscode-sql-snippets.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;GAEG;AACH,UAAU,uBAAuB;IAC/B,2BAA2B,EAAE,OAAO,CAAC;IACrC,gCAAgC,EAAE,MAAM,CAAC;CAC1C;AA+KD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CACnD,OAAO,EACP,uBAAuB,CAuBxB,CAAC"}
@@ -12,25 +12,7 @@ exports.generateVscodeSqlSnippets = void 0;
12
12
  const fs_1 = require("fs");
13
13
  const path_1 = require("path");
14
14
  const readdir = require("readdirp");
15
- /**
16
- * Colors the CLI text in green.
17
- */
18
- const green = (text) => `\u001b[32m${text}\u001b[39m`;
19
- /**
20
- * Colors the CLI text in red.
21
- */
22
- const red = (text) => `\u001b[31m${text}\u001b[39m`;
23
- /**
24
- * Returns a readable timestamp in current locale time, e.g. `[2021-05-13 13:02:12.685]`
25
- */
26
- const getTimestamp = () => {
27
- const offset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
28
- const localISOTime = new Date(Date.now() - offset)
29
- .toISOString()
30
- .slice(0, -1)
31
- .replace('T', ' ');
32
- return `[${localISOTime}]`;
33
- };
15
+ const utils_1 = require("./utils");
34
16
  /**
35
17
  * Writes generated snippets object to .vscode folder. Creates a folder if it does not exist.
36
18
  * Returns a success message.
@@ -59,7 +41,7 @@ const parseFunctionName = (line, snippetJson) => {
59
41
  let prefix = `unnamed-snippet-${unparsedSnippetIndex}`;
60
42
  let snippetName = `Unnamed Snippet ${unparsedSnippetIndex}`;
61
43
  if (!match) {
62
- console.log(red(`Unable to parse the name for the following snippet. Naming the snippet ${prefix} instead.`));
44
+ console.log((0, utils_1.red)(`Unable to parse the name for the following snippet. Naming the snippet ${prefix} instead.`));
63
45
  console.log(snippetJson);
64
46
  unparsedSnippetIndex++;
65
47
  }
@@ -126,7 +108,7 @@ const getParsedSnippets = async (dirPath, includeMultitenancySnippets) => {
126
108
  if (!includeMultitenancySnippets && path.includes('multitenancy')) {
127
109
  continue;
128
110
  }
129
- console.log(getTimestamp(), `Parsing ${path}`);
111
+ console.log((0, utils_1.getTimestamp)(), `Parsing ${path}`);
130
112
  await populateSnippets(fullPath, parsedSnippets);
131
113
  }
132
114
  }
@@ -154,7 +136,7 @@ const getCustomSnippets = async (dirPath, includeMultitenancySnippets) => {
154
136
  if (!includeMultitenancySnippets && path.includes('multitenancy')) {
155
137
  continue;
156
138
  }
157
- console.log(getTimestamp(), `Reading ${path}`);
139
+ console.log((0, utils_1.getTimestamp)(), `Reading ${path}`);
158
140
  const fileContents = JSON.parse((0, fs_1.readFileSync)(fullPath, 'utf-8'));
159
141
  customSnippets = Object.assign(Object.assign({}, customSnippets), fileContents);
160
142
  }
@@ -175,12 +157,12 @@ const getCustomSnippets = async (dirPath, includeMultitenancySnippets) => {
175
157
  * Generates or updates a VScode snippets file.
176
158
  */
177
159
  const generate = async ({ includeMultitenancySnippets, snippetsFileNameWithoutExtension, }) => {
178
- console.log(getTimestamp(), green(`Starting snippets generation!`));
160
+ console.log((0, utils_1.getTimestamp)(), (0, utils_1.green)(`Starting snippets generation!`));
179
161
  const dirPath = (0, path_1.resolve)(__dirname, '../../../migrations');
180
162
  const parsedSnippets = await getParsedSnippets(dirPath, includeMultitenancySnippets);
181
163
  const customSnippets = await getCustomSnippets(dirPath, includeMultitenancySnippets);
182
164
  const writeResult = writeSourceFile(snippetsFileNameWithoutExtension, Object.assign(Object.assign({}, parsedSnippets), customSnippets));
183
- console.log(getTimestamp(), green(writeResult));
165
+ console.log((0, utils_1.getTimestamp)(), (0, utils_1.green)(writeResult));
184
166
  };
185
167
  /**
186
168
  * Yargs command module definition for `generate-vscode-sql-snippets` CLI script.
@@ -194,6 +176,7 @@ exports.generateVscodeSqlSnippets = {
194
176
  describe: 'If set to true, would also include snippets for multitenancy define functions.',
195
177
  default: false,
196
178
  boolean: true,
179
+ hidden: true,
197
180
  })
198
181
  .option('snippetsFileNameWithoutExtension', {
199
182
  alias: 'f',
@@ -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,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EA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,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"}
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;AAEpC,mCAAmD;AAUnD;;;GAGG;AACH,MAAM,eAAe,GAAG,CACtB,gBAAwB,EACxB,QAAiC,EACzB,EAAE;IACV,MAAM,MAAM,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IACzE,IAAI,CAAC,IAAA,eAAU,EAAC,MAAM,CAAC,EAAE;QACvB,IAAA,cAAS,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACxC;IACD,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE,GAAG,gBAAgB,gBAAgB,CAAC,CAAC;IACnE,IAAA,kBAAa,EAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACpE,OAAO,gCAAgC,QAAQ,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF;;GAEG;AACH,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAC7B;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,CACxB,IAAY,EACZ,WAAoC,EACK,EAAE;;IAC3C,MAAM,KAAK,GAAG,MAAA,IAAI,MAAM,CAAC,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BAA+B,CAAC,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAC1D,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAC5C,OAAO,EACP,2BAA2B,CAC5B,CAAC;IACF,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAC5C,OAAO,EACP,2BAA2B,CAC5B,CAAC;IACF,MAAM,WAAW,GAAG,eAAe,CAAC,gCAAgC,kCAC/D,cAAc,GACd,cAAc,EACjB,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,IAAA,oBAAY,GAAE,EAAE,IAAA,aAAK,EAAC,WAAW,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF;;GAEG;AACU,QAAA,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;QACb,MAAM,EAAE,IAAI;KACb,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"}
@@ -1,2 +1,3 @@
1
+ export * from './generate-define-func-migration';
1
2
  export * from './generate-vscode-sql-snippets';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC"}
@@ -10,5 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./generate-define-func-migration"), exports);
13
14
  __exportStar(require("./generate-vscode-sql-snippets"), exports);
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA+C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAAiD;AACjD,iEAA+C"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Colors the CLI text in green.
3
+ */
4
+ export declare const green: (text: string) => string;
5
+ /**
6
+ * Colors the CLI text in red.
7
+ */
8
+ export declare const red: (text: string) => string;
9
+ /**
10
+ * Returns a readable timestamp in current locale time, e.g. `[2021-05-13 13:02:12.685]`
11
+ */
12
+ export declare const getTimestamp: () => string;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,KAAK,SAAU,MAAM,KAAG,MAAuC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,GAAG,SAAU,MAAM,KAAG,MAAuC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,MAO/B,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTimestamp = exports.red = exports.green = void 0;
4
+ /**
5
+ * Colors the CLI text in green.
6
+ */
7
+ const green = (text) => `\u001b[32m${text}\u001b[39m`;
8
+ exports.green = green;
9
+ /**
10
+ * Colors the CLI text in red.
11
+ */
12
+ const red = (text) => `\u001b[31m${text}\u001b[39m`;
13
+ exports.red = red;
14
+ /**
15
+ * Returns a readable timestamp in current locale time, e.g. `[2021-05-13 13:02:12.685]`
16
+ */
17
+ const getTimestamp = () => {
18
+ const offset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
19
+ const localISOTime = new Date(Date.now() - offset)
20
+ .toISOString()
21
+ .slice(0, -1)
22
+ .replace('T', ' ');
23
+ return `[${localISOTime}]`;
24
+ };
25
+ exports.getTimestamp = getTimestamp;
26
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/cli/commands/utils.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,YAAY,CAAC;AAAhE,QAAA,KAAK,SAA2D;AAE7E;;GAEG;AACI,MAAM,GAAG,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,YAAY,CAAC;AAA9D,QAAA,GAAG,OAA2D;AAE3E;;GAEG;AACI,MAAM,YAAY,GAAG,GAAW,EAAE;IACvC,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;AAPW,QAAA,YAAY,gBAOvB"}
@@ -1,2 +1,3 @@
1
- export declare const run: () => void;
1
+ import * as yargs from 'yargs';
2
+ export declare const cliExtension: () => yargs.CommandModule<any, any>[];
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,QAAO,IAOtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,eAAO,MAAM,YAAY,QAAO,MAAM,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAG5D,CAAC"}
package/dist/cli/index.js CHANGED
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- const yargs = require("yargs");
3
+ exports.cliExtension = void 0;
5
4
  const commands_1 = require("./commands");
6
- const run = () => {
7
- yargs
8
- .scriptName('mosaic-db')
9
- .command(commands_1.generateVscodeSqlSnippets)
10
- .demandCommand()
11
- .help()
12
- .epilog(`For more information, visit https://portal.axinom.com.`).argv;
13
- };
14
- exports.run = run;
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ const cliExtension = () => [
7
+ commands_1.generateVscodeSqlSnippets,
8
+ commands_1.generateDefineFuncMigration,
9
+ ];
10
+ exports.cliExtension = cliExtension;
15
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,yCAAuD;AAEhD,MAAM,GAAG,GAAG,GAAS,EAAE;IAC5B,KAAK;SACF,UAAU,CAAC,WAAW,CAAC;SACvB,OAAO,CAAC,oCAAyB,CAAC;SAClC,aAAa,EAAE;SACf,IAAI,EAAE;SACN,MAAM,CAAC,wDAAwD,CAAC,CAAC,IAAI,CAAC;AAC3E,CAAC,CAAC;AAPW,QAAA,GAAG,OAOd"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AACA,yCAGoB;AAEpB,8DAA8D;AACvD,MAAM,YAAY,GAAG,GAAoC,EAAE,CAAC;IACjE,oCAAyB;IACzB,sCAA2B;CAC5B,CAAC;AAHW,QAAA,YAAY,gBAGvB"}
@@ -14,8 +14,8 @@ export declare const DEFAULT_AUTH_SUBJECT_NAME = "Anonymous";
14
14
  export declare const DEFAULT_DB_USERNAME = "Unknown";
15
15
  /** Default username for system-related DB requests, e.g. seed data operations. */
16
16
  export declare const DEFAULT_SYSTEM_USERNAME = "System";
17
- /** PgSettings key to set the PostgreSQL parameter for storing authenticated consumer's user ID */
18
- export declare const MOSAIC_AUTH_CONSUMER_ID = "mosaic.auth.user_id";
19
- /** PgSettings key to set the PostgreSQL parameter for storing authenticated consumer's profile ID */
17
+ /** PgSettings key to set the PostgreSQL parameter for storing authenticated end-user's user ID */
18
+ export declare const MOSAIC_AUTH_END_USER_ID = "mosaic.auth.user_id";
19
+ /** PgSettings key to set the PostgreSQL parameter for storing authenticated end-user's profile ID */
20
20
  export declare const MOSAIC_AUTH_PROFILE_ID = "mosaic.auth.profile_id";
21
21
  //# sourceMappingURL=pg-auth-settings-keys.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MOSAIC_AUTH_PROFILE_ID = exports.MOSAIC_AUTH_CONSUMER_ID = exports.DEFAULT_SYSTEM_USERNAME = exports.DEFAULT_DB_USERNAME = exports.DEFAULT_AUTH_SUBJECT_NAME = exports.MOSAIC_ENVIRONMENT_ID = exports.MOSAIC_TENANT_ID = exports.MOSAIC_AUTH_TAGS = exports.MOSAIC_AUTH_PERMISSIONS = exports.MOSAIC_AUTH_SUBJECT_NAME = void 0;
3
+ exports.MOSAIC_AUTH_PROFILE_ID = exports.MOSAIC_AUTH_END_USER_ID = exports.DEFAULT_SYSTEM_USERNAME = exports.DEFAULT_DB_USERNAME = exports.DEFAULT_AUTH_SUBJECT_NAME = exports.MOSAIC_ENVIRONMENT_ID = exports.MOSAIC_TENANT_ID = exports.MOSAIC_AUTH_TAGS = exports.MOSAIC_AUTH_PERMISSIONS = exports.MOSAIC_AUTH_SUBJECT_NAME = void 0;
4
4
  /** PgSettings key to set the PostgreSQL parameter for storing authentication subject name. */
5
5
  exports.MOSAIC_AUTH_SUBJECT_NAME = 'mosaic.auth.subject_name';
6
6
  /** PgSettings key to set the PostgreSQL parameter for storing authentication token permissions. */
@@ -17,8 +17,8 @@ exports.DEFAULT_AUTH_SUBJECT_NAME = 'Anonymous';
17
17
  exports.DEFAULT_DB_USERNAME = 'Unknown';
18
18
  /** Default username for system-related DB requests, e.g. seed data operations. */
19
19
  exports.DEFAULT_SYSTEM_USERNAME = 'System';
20
- /** PgSettings key to set the PostgreSQL parameter for storing authenticated consumer's user ID */
21
- exports.MOSAIC_AUTH_CONSUMER_ID = 'mosaic.auth.user_id';
22
- /** PgSettings key to set the PostgreSQL parameter for storing authenticated consumer's profile ID */
20
+ /** PgSettings key to set the PostgreSQL parameter for storing authenticated end-user's user ID */
21
+ exports.MOSAIC_AUTH_END_USER_ID = 'mosaic.auth.user_id';
22
+ /** PgSettings key to set the PostgreSQL parameter for storing authenticated end-user's profile ID */
23
23
  exports.MOSAIC_AUTH_PROFILE_ID = 'mosaic.auth.profile_id';
24
24
  //# sourceMappingURL=pg-auth-settings-keys.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './auth';
2
+ export * from './cli';
2
3
  export * from './common';
3
4
  export * from './constants';
4
5
  export * from './messaging';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./auth"), exports);
14
+ __exportStar(require("./cli"), exports);
14
15
  __exportStar(require("./common"), exports);
15
16
  __exportStar(require("./constants"), exports);
16
17
  __exportStar(require("./messaging"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B"}
@@ -1,4 +1,3 @@
1
1
  export * from './create-migrations-logger';
2
- export { createSqlDefineFunctionsMigration } from './create-sql-define-functions-migration';
3
2
  export * from './utils';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAC5F,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC"}
@@ -10,9 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.createSqlDefineFunctionsMigration = void 0;
14
13
  __exportStar(require("./create-migrations-logger"), exports);
15
- var create_sql_define_functions_migration_1 = require("./create-sql-define-functions-migration");
16
- Object.defineProperty(exports, "createSqlDefineFunctionsMigration", { enumerable: true, get: function () { return create_sql_define_functions_migration_1.createSqlDefineFunctionsMigration; } });
17
14
  __exportStar(require("./utils"), exports);
18
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,iGAA4F;AAAnF,0JAAA,iCAAiC,OAAA;AAC1C,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA2C;AAC3C,0CAAwB"}
@@ -4,7 +4,7 @@ import { DbLogger } from '../common';
4
4
  * Executes all .sql files located in a specified directory.
5
5
  *
6
6
  * @param settings - graphile-migrate settings object
7
- * @param dirPath - relative path from root of consumer project to a folder with sql scripts in it, e.g. 'migrations/after-reset'
7
+ * @param dirPath - relative path from the root of a project to a folder with sql scripts in it, e.g. 'migrations/after-reset'
8
8
  */
9
9
  export declare const runSqlScripts: (settings: Settings, dirPath: string, logger: DbLogger) => Promise<void>;
10
10
  /**
@@ -17,7 +17,7 @@ const readdir = require("readdirp");
17
17
  * Executes all .sql files located in a specified directory.
18
18
  *
19
19
  * @param settings - graphile-migrate settings object
20
- * @param dirPath - relative path from root of consumer project to a folder with sql scripts in it, e.g. 'migrations/after-reset'
20
+ * @param dirPath - relative path from the root of a project to a folder with sql scripts in it, e.g. 'migrations/after-reset'
21
21
  */
22
22
  const runSqlScripts = async (settings, dirPath, logger) => {
23
23
  var e_1, _a;
@@ -65,10 +65,14 @@ https://code.visualstudio.com/docs/editor/userdefinedsnippets
65
65
 
66
66
  From this perspective, the following steps can be performed by the developer:
67
67
 
68
- - install or update `@axinom/mosaic-db-common`
69
- - run the cli command: `yarn mosaic-db generate-vscode-sql-snippets`
68
+ - install or update `@axinom/mosaic-db-common` and `@axinom/mosaic-cli`
69
+ - if .mosaic file does not exist in monorepo root, run the cli command:
70
+ `mosaic create-extension-config`
71
+ - This is a one-time setup to create a `.mosaic` config file to allow
72
+ inclusion of modular CLI commands into the mosaic CLI.
73
+ - run the cli command: `yarn mosaic generate-vscode-sql-snippets`
70
74
  - if it's a multitenant service - run
71
- `yarn mosaic-db generate-vscode-sql-snippets -m` to include multitenancy
75
+ `yarn mosaic generate-vscode-sql-snippets -m` to include multitenancy
72
76
  snippets
73
77
  - This generates or updates a `.vscode/mosaic-sql-migrations.code-snippets`
74
78
  file, which contains all sql migration code snippets that are supported by the
@@ -187,8 +191,8 @@ The way to develop and test the snippets code would look like this:
187
191
  - If only sql or code-snippets files are modified - no need to keep the lib
188
192
  running.
189
193
  - Once adjustments are made - save them and run
190
- `yarn mosaic-db generate-vscode-sql-snippets -m` in some backend service in
191
- Navy repository (that has `@axinom/mosaic-db-common` dependency) or from Navy
194
+ `yarn mosaic generate-vscode-sql-snippets -m` in some backend service in Navy
195
+ repository (that has `@axinom/mosaic-db-common` dependency) or from Navy
192
196
  repository root.
193
197
  - `.vscode/mosaic-sql-migrations.code-snippets` will be updated
194
198
  - go to any `.sql` file in monorepo (preferably `migrations/current.sql` in one
@@ -196,9 +200,8 @@ The way to develop and test the snippets code would look like this:
196
200
 
197
201
  When maintaining comment snippet sections of sql functions, it's good to keep in
198
202
  mind, that they are fed into `JSON.Parse` as is, and therefore must be valid
199
- json objects. This means that if
200
- `yarn mosaic-db generate-vscode-sql-snippets -m` fails - chances are - json
201
- object is not valid.
203
+ json objects. This means that if `yarn mosaic generate-vscode-sql-snippets -m`
204
+ fails - chances are - json object is not valid.
202
205
 
203
206
  For example:
204
207
 
@@ -241,8 +244,8 @@ DROP FUNCTION IF EXISTS ax_utils.function_name(TEXT, TEXT, TEXT);
241
244
  ```
242
245
 
243
246
  The TODO comment is added to signify when this drop statement can be removed.
244
- Assumption is that one year is enough for for a library to be updated at least
245
- once for this statement to be executed in consuming services.
247
+ Assumption is that one year is enough for a library to be updated at least once
248
+ for this statement to be executed in consuming services.
246
249
 
247
250
  Worse case scenario:
248
251
 
@@ -262,7 +265,7 @@ Also, some notes about the contents of snippets comment section:
262
265
  sections with more text, while keeping it all on the screen.
263
266
  - If text contents are short - both can be changed from arrays of strings to
264
267
  just strings.
265
- - Snippets will be displayed differently depending on existance of `\n` inside
268
+ - Snippets will be displayed differently depending on existence of `\n` inside
266
269
  of the `description`.
267
270
  - If it exists - line break will be added, but it is possible that text might
268
271
  not be visible, curring it at the border of the window with `...`. In this
@@ -984,7 +984,7 @@ $$;
984
984
  /*-snippet
985
985
  {
986
986
  "body": [
987
- "SELECT ax_define.define_consumer_authentication('${1:table_name}', '${2:app_public}');"
987
+ "SELECT ax_define.define_end_user_authentication('${1:table_name}', '${2:app_public}');"
988
988
  ],
989
989
  "description": [
990
990
  "Defines RLS policy for user_id column in a given table",
@@ -992,19 +992,19 @@ $$;
992
992
  ]
993
993
  }
994
994
  snippet-*/
995
- CREATE OR REPLACE FUNCTION ax_define.define_consumer_authentication(tablename text, schemaname text)
995
+ CREATE OR REPLACE FUNCTION ax_define.define_end_user_authentication(tablename text, schemaname text)
996
996
  RETURNS void
997
997
  LANGUAGE plpgsql
998
998
  AS $function$
999
999
  DECLARE
1000
- consumer_rls_string TEXT := '((user_id = ax_utils.current_user_id() OR ax_utils.current_user_id() = uuid_nil()))';
1000
+ end_user_rls_string TEXT := '((user_id = ax_utils.current_user_id() OR ax_utils.current_user_id() = uuid_nil()))';
1001
1001
  BEGIN
1002
1002
  EXECUTE 'ALTER TABLE ' || schemaName || '.' || tableName || ' ENABLE ROW LEVEL SECURITY;';
1003
- EXECUTE 'DROP POLICY IF EXISTS ' || tableName || '_consumer_authorization ON ' || schemaName || '.' || tableName || ';';
1003
+ EXECUTE 'DROP POLICY IF EXISTS ' || tableName || '_end_user_authorization ON ' || schemaName || '.' || tableName || ';';
1004
1004
 
1005
1005
 
1006
- EXECUTE 'CREATE POLICY ' || tableName || '_consumer_authorization ON ' || schemaName || '.' || tableName || ' AS RESTRICTIVE FOR ALL
1007
- USING (' || consumer_rls_string || ');';
1006
+ EXECUTE 'CREATE POLICY ' || tableName || '_end_user_authorization ON ' || schemaName || '.' || tableName || ' AS RESTRICTIVE FOR ALL
1007
+ USING (' || end_user_rls_string || ');';
1008
1008
 
1009
1009
 
1010
1010
  END;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-db-common",
3
- "version": "0.13.0",
3
+ "version": "0.14.0-rc.10",
4
4
  "description": "This library encapsulates database-related functionality to develop Mosaic based services.",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -9,9 +9,6 @@
9
9
  "mosaic",
10
10
  "axinom mosaic"
11
11
  ],
12
- "bin": {
13
- "mosaic-db": "./bin/mosaic-db.js"
14
- },
15
12
  "files": [
16
13
  "dist",
17
14
  "migrations"
@@ -51,5 +48,5 @@
51
48
  "publishConfig": {
52
49
  "access": "public"
53
50
  },
54
- "gitHead": "2f3085cfbf61f629644f119e67b08e400fb14350"
51
+ "gitHead": "ecac44c80f0c76c1a93393e380e35e9e376041f9"
55
52
  }
package/bin/mosaic-db.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('../dist/cli').run();
@@ -1,16 +0,0 @@
1
- /**
2
- * Reads the latest contents of the SQL functions to easily define tables, indexes, ...
3
- * It will create a new current.sql file in that location. If a current.sql file already
4
- * exists we check that this file is empty/only contains SQL comments before overwriting it.
5
- *
6
- * @param migrationFolderPath - the path to the migration folder path where the current.sql file should be created.
7
- * @param postfixContent - content that should be added to the end. Useful for adding your own define functions.
8
- */
9
- export declare const createSqlDefineFunctionsMigration: (migrationFolderPath: string, postfixContent?: string) => Promise<void>;
10
- /**
11
- * This is a Mosaic internal function for multitenancy enabled tables.
12
- *
13
- * @param migrationFolderPath - the path to the migration folder path where the current.sql file should be created.
14
- */
15
- export declare const createSqlMultitenancyDefineFunctionsMigration: (migrationFolderPath: string) => Promise<void>;
16
- //# sourceMappingURL=create-sql-define-functions-migration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-sql-define-functions-migration.d.ts","sourceRoot":"","sources":["../../src/migrations/create-sql-define-functions-migration.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,wBACvB,MAAM,8BAE1B,QAAQ,IAAI,CAiCd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6CAA6C,wBACnC,MAAM,KAC1B,QAAQ,IAAI,CASd,CAAC"}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSqlMultitenancyDefineFunctionsMigration = exports.createSqlDefineFunctionsMigration = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const getPathToDefinitionsFolder = () => {
7
- return (0, path_1.resolve)(__dirname, '..', '..', 'migrations', 'define');
8
- };
9
- /**
10
- * Reads the latest contents of the SQL functions to easily define tables, indexes, ...
11
- * It will create a new current.sql file in that location. If a current.sql file already
12
- * exists we check that this file is empty/only contains SQL comments before overwriting it.
13
- *
14
- * @param migrationFolderPath - the path to the migration folder path where the current.sql file should be created.
15
- * @param postfixContent - content that should be added to the end. Useful for adding your own define functions.
16
- */
17
- const createSqlDefineFunctionsMigration = async (migrationFolderPath, postfixContent = '') => {
18
- const currentSqlFile = (0, path_1.join)(migrationFolderPath, 'current.sql');
19
- let currentSql = '';
20
- if ((0, fs_1.existsSync)(currentSqlFile)) {
21
- currentSql = await fs_1.promises.readFile(currentSqlFile, 'utf8');
22
- const currentSqlWithoutComments = currentSql.replace(/(--.*)|(((\/\*)+?[\w\W]+?(\*\/)+))/gm, '');
23
- const nonEmptyCurrentSqlLines = currentSqlWithoutComments.match(/^[^\S\r\n]*\S.*$/gm);
24
- if (nonEmptyCurrentSqlLines !== null &&
25
- nonEmptyCurrentSqlLines.length > 0) {
26
- throw new Error('Please ensure that your current.sql file is empty/only contains comments.');
27
- }
28
- }
29
- const defineFunctions = await fs_1.promises.readFile((0, path_1.join)(getPathToDefinitionsFolder(), 'define-functions.sql'), 'utf8');
30
- const migrationContent = `--! Message: upgrade SQL define functions
31
-
32
- ${defineFunctions}
33
-
34
- ${postfixContent}
35
- `;
36
- await fs_1.promises.writeFile(currentSqlFile, migrationContent);
37
- };
38
- exports.createSqlDefineFunctionsMigration = createSqlDefineFunctionsMigration;
39
- /**
40
- * This is a Mosaic internal function for multitenancy enabled tables.
41
- *
42
- * @param migrationFolderPath - the path to the migration folder path where the current.sql file should be created.
43
- */
44
- const createSqlMultitenancyDefineFunctionsMigration = async (migrationFolderPath) => {
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
- };
48
- exports.createSqlMultitenancyDefineFunctionsMigration = createSqlMultitenancyDefineFunctionsMigration;
49
- //# sourceMappingURL=create-sql-define-functions-migration.js.map
@@ -1 +0,0 @@
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;AAChE,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,iCAAiC,GAAG,KAAK,EACpD,mBAA2B,EAC3B,cAAc,GAAG,EAAE,EACJ,EAAE;IACjB,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IAChE,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,IAAA,eAAU,EAAC,cAAc,CAAC,EAAE;QAC9B,UAAU,GAAG,MAAM,aAAG,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,CAClD,sCAAsC,EACtC,EAAE,CACH,CAAC;QACF,MAAM,uBAAuB,GAC3B,yBAAyB,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAExD,IACE,uBAAuB,KAAK,IAAI;YAChC,uBAAuB,CAAC,MAAM,GAAG,CAAC,EAClC;YACA,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;SACH;KACF;IACD,MAAM,eAAe,GAAG,MAAM,aAAG,CAAC,QAAQ,CACxC,IAAA,WAAI,EAAC,0BAA0B,EAAE,EAAE,sBAAsB,CAAC,EAC1D,MAAM,CACP,CAAC;IAEF,MAAM,gBAAgB,GAAG;;EAEzB,eAAe;;EAEf,cAAc;CACf,CAAC;IACA,MAAM,aAAG,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACxD,CAAC,CAAC;AApCW,QAAA,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