@balena/pinejs 15.0.0-true-boolean-911aca4062d3132ad3c34712014739b6849fa13a → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/.dockerignore +4 -0
  2. package/.github/workflows/flowzone.yml +21 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.pinejs-cache.json +1 -0
  5. package/.resinci.yml +1 -0
  6. package/.versionbot/CHANGELOG.yml +9678 -2001
  7. package/CHANGELOG.md +2975 -2
  8. package/Dockerfile +14 -0
  9. package/Gruntfile.ts +3 -6
  10. package/README.md +10 -1
  11. package/VERSION +1 -0
  12. package/build/browser.ts +1 -1
  13. package/build/config.ts +0 -1
  14. package/docker-compose.npm-test.yml +11 -0
  15. package/docs/AdvancedUsage.md +77 -63
  16. package/docs/GettingStarted.md +90 -41
  17. package/docs/Migrations.md +102 -1
  18. package/docs/ProjectConfig.md +12 -21
  19. package/docs/Testing.md +7 -0
  20. package/out/bin/abstract-sql-compiler.js +17 -17
  21. package/out/bin/abstract-sql-compiler.js.map +1 -1
  22. package/out/bin/odata-compiler.js +23 -20
  23. package/out/bin/odata-compiler.js.map +1 -1
  24. package/out/bin/sbvr-compiler.js +22 -22
  25. package/out/bin/sbvr-compiler.js.map +1 -1
  26. package/out/bin/utils.d.ts +2 -2
  27. package/out/bin/utils.js +3 -3
  28. package/out/bin/utils.js.map +1 -1
  29. package/out/config-loader/config-loader.d.ts +9 -8
  30. package/out/config-loader/config-loader.js +135 -78
  31. package/out/config-loader/config-loader.js.map +1 -1
  32. package/out/config-loader/env.d.ts +41 -16
  33. package/out/config-loader/env.js +46 -2
  34. package/out/config-loader/env.js.map +1 -1
  35. package/out/data-server/sbvr-server.d.ts +2 -19
  36. package/out/data-server/sbvr-server.js +44 -38
  37. package/out/data-server/sbvr-server.js.map +1 -1
  38. package/out/database-layer/db.d.ts +32 -14
  39. package/out/database-layer/db.js +120 -41
  40. package/out/database-layer/db.js.map +1 -1
  41. package/out/express-emulator/express.js +10 -11
  42. package/out/express-emulator/express.js.map +1 -1
  43. package/out/http-transactions/transactions.d.ts +2 -18
  44. package/out/http-transactions/transactions.js +29 -21
  45. package/out/http-transactions/transactions.js.map +1 -1
  46. package/out/migrator/async.d.ts +7 -0
  47. package/out/migrator/async.js +168 -0
  48. package/out/migrator/async.js.map +1 -0
  49. package/out/migrator/migrations.sbvr +43 -0
  50. package/out/migrator/sync.d.ts +9 -0
  51. package/out/migrator/sync.js +106 -0
  52. package/out/migrator/sync.js.map +1 -0
  53. package/out/migrator/utils.d.ts +78 -0
  54. package/out/migrator/utils.js +283 -0
  55. package/out/migrator/utils.js.map +1 -0
  56. package/out/odata-metadata/odata-metadata-generator.js +10 -13
  57. package/out/odata-metadata/odata-metadata-generator.js.map +1 -1
  58. package/out/passport-pinejs/passport-pinejs.d.ts +1 -1
  59. package/out/passport-pinejs/passport-pinejs.js +8 -7
  60. package/out/passport-pinejs/passport-pinejs.js.map +1 -1
  61. package/out/pinejs-session-store/pinejs-session-store.d.ts +1 -1
  62. package/out/pinejs-session-store/pinejs-session-store.js +20 -6
  63. package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
  64. package/out/sbvr-api/abstract-sql.d.ts +3 -2
  65. package/out/sbvr-api/abstract-sql.js +9 -9
  66. package/out/sbvr-api/abstract-sql.js.map +1 -1
  67. package/out/sbvr-api/cached-compile.js +1 -1
  68. package/out/sbvr-api/cached-compile.js.map +1 -1
  69. package/out/sbvr-api/common-types.d.ts +6 -5
  70. package/out/sbvr-api/control-flow.d.ts +8 -1
  71. package/out/sbvr-api/control-flow.js +36 -9
  72. package/out/sbvr-api/control-flow.js.map +1 -1
  73. package/out/sbvr-api/errors.d.ts +47 -40
  74. package/out/sbvr-api/errors.js +78 -77
  75. package/out/sbvr-api/errors.js.map +1 -1
  76. package/out/sbvr-api/express-extension.d.ts +4 -0
  77. package/out/sbvr-api/hooks.d.ts +16 -15
  78. package/out/sbvr-api/hooks.js +74 -48
  79. package/out/sbvr-api/hooks.js.map +1 -1
  80. package/out/sbvr-api/odata-response.d.ts +2 -2
  81. package/out/sbvr-api/odata-response.js +28 -30
  82. package/out/sbvr-api/odata-response.js.map +1 -1
  83. package/out/sbvr-api/permissions.d.ts +17 -16
  84. package/out/sbvr-api/permissions.js +369 -304
  85. package/out/sbvr-api/permissions.js.map +1 -1
  86. package/out/sbvr-api/sbvr-utils.d.ts +33 -15
  87. package/out/sbvr-api/sbvr-utils.js +397 -235
  88. package/out/sbvr-api/sbvr-utils.js.map +1 -1
  89. package/out/sbvr-api/translations.d.ts +6 -0
  90. package/out/sbvr-api/translations.js +150 -0
  91. package/out/sbvr-api/translations.js.map +1 -0
  92. package/out/sbvr-api/uri-parser.d.ts +23 -17
  93. package/out/sbvr-api/uri-parser.js +33 -27
  94. package/out/sbvr-api/uri-parser.js.map +1 -1
  95. package/out/sbvr-api/user.sbvr +2 -0
  96. package/out/server-glue/module.d.ts +6 -6
  97. package/out/server-glue/module.js +4 -2
  98. package/out/server-glue/module.js.map +1 -1
  99. package/out/server-glue/server.js +5 -5
  100. package/out/server-glue/server.js.map +1 -1
  101. package/package.json +89 -73
  102. package/pinejs.png +0 -0
  103. package/repo.yml +9 -9
  104. package/src/bin/abstract-sql-compiler.ts +5 -7
  105. package/src/bin/odata-compiler.ts +11 -13
  106. package/src/bin/sbvr-compiler.ts +11 -17
  107. package/src/bin/utils.ts +3 -5
  108. package/src/config-loader/config-loader.ts +167 -53
  109. package/src/config-loader/env.ts +106 -6
  110. package/src/data-server/sbvr-server.js +44 -38
  111. package/src/database-layer/db.ts +205 -64
  112. package/src/express-emulator/express.js +10 -11
  113. package/src/http-transactions/transactions.js +29 -21
  114. package/src/migrator/async.ts +323 -0
  115. package/src/migrator/migrations.sbvr +43 -0
  116. package/src/migrator/sync.ts +152 -0
  117. package/src/migrator/utils.ts +458 -0
  118. package/src/odata-metadata/odata-metadata-generator.ts +12 -15
  119. package/src/passport-pinejs/passport-pinejs.ts +9 -7
  120. package/src/pinejs-session-store/pinejs-session-store.ts +15 -1
  121. package/src/sbvr-api/abstract-sql.ts +17 -14
  122. package/src/sbvr-api/common-types.ts +2 -1
  123. package/src/sbvr-api/control-flow.ts +45 -11
  124. package/src/sbvr-api/errors.ts +82 -77
  125. package/src/sbvr-api/express-extension.ts +6 -1
  126. package/src/sbvr-api/hooks.ts +123 -50
  127. package/src/sbvr-api/odata-response.ts +23 -28
  128. package/src/sbvr-api/permissions.ts +548 -415
  129. package/src/sbvr-api/sbvr-utils.ts +581 -259
  130. package/src/sbvr-api/translations.ts +248 -0
  131. package/src/sbvr-api/uri-parser.ts +63 -49
  132. package/src/sbvr-api/user.sbvr +2 -0
  133. package/src/server-glue/module.ts +16 -10
  134. package/src/server-glue/server.ts +5 -5
  135. package/tsconfig.dev.json +1 -0
  136. package/tsconfig.json +1 -2
  137. package/typings/lf-to-abstract-sql.d.ts +6 -9
  138. package/typings/memoizee.d.ts +1 -1
  139. package/.github/CODEOWNERS +0 -1
  140. package/circle.yml +0 -37
  141. package/docs/todo.txt +0 -22
  142. package/out/migrator/migrator.d.ts +0 -20
  143. package/out/migrator/migrator.js +0 -188
  144. package/out/migrator/migrator.js.map +0 -1
  145. package/src/migrator/migrator.ts +0 -286
@@ -1,8 +1,9 @@
1
1
  # Configuring A Project
2
2
 
3
- The project configuration is placed inside `config.json` that provides all the necessary information to Pine.js regarding the models, the API, and the users. This file should follow a specification based on the example shown below:
3
+ The project configuration is placed inside `config.json` that provides all the necessary information for Pine.js regarding the models, the API, and the users.
4
+ This file should follow a specification based on the example shown below:
4
5
 
5
- ```
6
+ ```json
6
7
  {
7
8
  "models": [{
8
9
  "modelName": "Example",
@@ -54,10 +55,11 @@ Permissions currently work by having a name which defines what the permission co
54
55
  * `@__ACTOR_ID` - This is replaced by the `id` of the currently logged in actor (or `0` if not logged in), or the actor who owns the API key in use.
55
56
 
56
57
  ### Default/Guest User Permissions
57
- All users (including ones who are not logged in) automatically gain any permissions assigned to the account named "guest". You can create this user in the `config.json` as shown in the example above.
58
+ All users (including ones who are not logged in) automatically gain any permissions assigned to the account named "guest".
59
+ You can create this user in the `config.json` as shown in the example above.
58
60
 
59
61
  ### Model
60
- The SBVR model for users can be found at [/src/server/src/sbvr-api/user.sbvr](https://github.com/balena-io/pinejs/blob/master/src/server/src/sbvr-api/user.sbvr)
62
+ The SBVR model for users can be found at [/src/sbvr-api/user.sbvr](https://github.com/balena-io/pinejs/blob/master/src/sbvr-api/user.sbvr)
61
63
 
62
64
  ### Exposing the OData API
63
65
  To expose the user model over the OData API, use the following in your custom server code:
@@ -67,25 +69,14 @@ app.get('/Auth/*', sbvrUtils.runGet)
67
69
  ```
68
70
  This will allow you to access the user model under the `/Auth` entry point as you would any other model, e.g. `GET /Auth/user`.
69
71
 
70
- Alternatively, you can copy the user model vocabulary into your SBVR file, which will expose it under the same entry point as your vocabulary. The benefit to this is that you can add custom attributes for the user vocabulary to your vocabulary and have them be accessible via the API.
71
-
72
+ Alternatively, you can copy the user model vocabulary into your SBVR file, which will expose it under the same entry point as your vocabulary.
73
+ The benefit to this is that you can add custom attributes for the user vocabulary to your vocabulary and have them be accessible via the API.
72
74
 
73
75
  ## Database
74
- You can specify your database url in an environment variable called DATABASE_URL, refer to your OS documentation on how to do this (either on a global level for all programs, or just set it temporarily whilst launching your project).
76
+ You can specify your database url in an environment variable called `DATABASE_URL`,
77
+ refer to your OS documentation on how to do this (either on a global level for all programs, or just set it temporarily whilst launching your project).
75
78
 
76
79
  If you do not specify this environment variable, then the defaults are as follows:
77
80
 
78
- MySQL:
79
-
80
- ```coffee
81
- host: 'localhost'
82
- user: 'root'
83
- password: '.'
84
- database: 'rulemotion'
85
- ```
86
-
87
- PostgresSQL:
88
-
89
- ```coffee
90
- postgres://postgres:.@localhost:5432/postgres
91
- ```
81
+ MySQL: `mysql://mysql:.@localhost:3306`
82
+ PostgresSQL: `postgres://postgres:.@localhost:5432/postgres`
@@ -0,0 +1,7 @@
1
+ ## Test environment
2
+ Pine is a system that needs a database.
3
+ Therefore the `npm run test:compose` is used to test pinejs with a postgres database spin up from a docker compose file: `docker-compose.npm-test.yml`
4
+ This approach guarantees that the node versions are tested by the flowzone test actions on a github pull request.
5
+
6
+ #### Debug pinejs queries
7
+ Specifying the environment variable PINEJS_DEBUG=1 will log debug information of each pine query (This can be a very verbose output.)
@@ -1,41 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("./utils");
4
- const program = require("commander");
4
+ const commander_1 = require("commander");
5
5
  const runCompile = (inputFile, outputFile) => {
6
- const { generateSqlModel, } = require('../sbvr-api/sbvr-utils');
7
- const abstractSql = utils_1.getAbstractSqlModelFromFile(inputFile);
8
- const sqlModel = generateSqlModel(abstractSql, program.opts().engine);
9
- utils_1.writeSqlModel(sqlModel, outputFile);
6
+ const { generateSqlModel } = require('../sbvr-api/sbvr-utils');
7
+ const abstractSql = (0, utils_1.getAbstractSqlModelFromFile)(inputFile);
8
+ const sqlModel = generateSqlModel(abstractSql, commander_1.program.opts().engine);
9
+ (0, utils_1.writeSqlModel)(sqlModel, outputFile);
10
10
  };
11
11
  const generateTypes = (inputFile, outputFile) => {
12
- const { abstractSqlToTypescriptTypes, } = require('@balena/abstract-sql-to-typescript');
13
- const abstractSql = utils_1.getAbstractSqlModelFromFile(inputFile);
12
+ const { abstractSqlToTypescriptTypes } = require('@balena/abstract-sql-to-typescript');
13
+ const abstractSql = (0, utils_1.getAbstractSqlModelFromFile)(inputFile);
14
14
  const types = abstractSqlToTypescriptTypes(abstractSql);
15
- utils_1.writeAll(types, outputFile);
15
+ (0, utils_1.writeAll)(types, outputFile);
16
16
  };
17
- program
17
+ commander_1.program
18
18
  .version(utils_1.version)
19
19
  .option('-e, --engine <engine>', 'The target database engine (postgres|websql|mysql), default: postgres', /postgres|websql|mysql/, 'postgres');
20
- program
20
+ commander_1.program
21
21
  .command('compile <input-file> [output-file]')
22
22
  .description('compile the input AbstractSql model into SQL')
23
23
  .action(runCompile);
24
- program
24
+ commander_1.program
25
25
  .command('compile-schema <input-file> [output-file]')
26
26
  .description('compile the input AbstractSql model into SQL')
27
27
  .action(runCompile);
28
- program
28
+ commander_1.program
29
29
  .command('generate-types <input-file> [output-file]')
30
30
  .description('generate typescript types from the input AbstractSql')
31
31
  .action(generateTypes);
32
- program
32
+ commander_1.program
33
33
  .command('help')
34
34
  .description('print the help')
35
- .action(() => program.help());
36
- program.arguments('<input-file> [output-file]').action(runCompile);
35
+ .action(() => commander_1.program.help());
36
+ commander_1.program.arguments('<input-file> [output-file]').action(runCompile);
37
37
  if (process.argv.length === 2) {
38
- program.help();
38
+ commander_1.program.help();
39
39
  }
40
- program.parse(process.argv);
40
+ commander_1.program.parse(process.argv);
41
41
  //# sourceMappingURL=abstract-sql-compiler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-sql-compiler.js","sourceRoot":"","sources":["../../src/bin/abstract-sql-compiler.ts"],"names":[],"mappings":";;AAAA,mCAKiB;AAIjB,qCAAqC;AAErC,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAE,UAAmB,EAAE,EAAE;IAC7D,MAAM,EACL,gBAAgB,GAChB,GAAG,OAAO,CAAC,wBAAwB,CAAqB,CAAC;IAC1D,MAAM,WAAW,GAAG,mCAA2B,CAAC,SAAS,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;IAEtE,qBAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,UAAmB,EAAE,EAAE;IAChE,MAAM,EACL,4BAA4B,GAC5B,GAAG,OAAO,CAAC,oCAAoC,CAAwD,CAAC;IACzG,MAAM,WAAW,GAAG,mCAA2B,CAAC,SAAS,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,4BAA4B,CAAC,WAAW,CAAC,CAAC;IAExD,gBAAQ,CAAC,KA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K,CAAC,EAAE;IAC9B,mBAAO,CAAC,IAAI,EAAE,CAAC;CACf;AAED,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,33 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("./utils");
4
- const program = require("commander");
4
+ const commander_1 = require("commander");
5
5
  const generateAbstractSqlQuery = (modelFile, odata) => {
6
- const { memoizedParseOdata, translateUri, } = require('../sbvr-api/uri-parser');
6
+ const { memoizedParseOdata, translateUri } = require('../sbvr-api/uri-parser');
7
7
  const odataAST = memoizedParseOdata(odata);
8
+ const vocabulary = '';
8
9
  return translateUri({
9
- engine: program.opts().engine,
10
+ engine: commander_1.program.opts().engine,
10
11
  method: 'GET',
11
12
  url: odata,
12
13
  resourceName: odataAST.tree.resource,
14
+ originalResourceName: odataAST.tree.resource,
13
15
  odataQuery: odataAST.tree,
14
16
  odataBinds: odataAST.binds,
15
17
  values: {},
16
- vocabulary: '',
17
- abstractSqlModel: utils_1.getAbstractSqlModelFromFile(modelFile),
18
+ vocabulary,
19
+ abstractSqlModel: (0, utils_1.getAbstractSqlModelFromFile)(modelFile),
18
20
  custom: {},
21
+ translateVersions: [vocabulary],
19
22
  });
20
23
  };
21
24
  const parseOData = (odata, outputFile) => {
22
- const { memoizedParseOdata, } = require('../sbvr-api/uri-parser');
25
+ const { memoizedParseOdata } = require('../sbvr-api/uri-parser');
23
26
  const result = memoizedParseOdata(odata);
24
27
  const json = JSON.stringify(result, null, 2);
25
- utils_1.writeAll(json, outputFile);
28
+ (0, utils_1.writeAll)(json, outputFile);
26
29
  };
27
30
  const translateOData = (modelFile, odata, outputFile) => {
28
31
  const request = generateAbstractSqlQuery(modelFile, odata);
29
32
  const json = JSON.stringify(request.abstractSqlQuery, null, 2);
30
- utils_1.writeAll(json, outputFile);
33
+ (0, utils_1.writeAll)(json, outputFile);
31
34
  };
32
35
  const formatSqlQuery = (sqlQuery) => {
33
36
  if (Array.isArray(sqlQuery)) {
@@ -42,40 +45,40 @@ Bindings: ${JSON.stringify(sqlQuery.bindings, null, 2)}
42
45
  };
43
46
  const compileOData = (modelFile, odata, outputFile) => {
44
47
  const translatedRequest = generateAbstractSqlQuery(modelFile, odata);
45
- const { compileRequest, } = require('../sbvr-api/abstract-sql');
48
+ const { compileRequest } = require('../sbvr-api/abstract-sql');
46
49
  const compiledRequest = compileRequest(translatedRequest);
47
50
  let output;
48
- if (program.opts().json) {
51
+ if (commander_1.program.opts().json) {
49
52
  output = JSON.stringify(compiledRequest.sqlQuery, null, 2);
50
53
  }
51
54
  else {
52
55
  output = formatSqlQuery(compiledRequest.sqlQuery);
53
56
  }
54
- utils_1.writeAll(output, outputFile);
57
+ (0, utils_1.writeAll)(output, outputFile);
55
58
  };
56
- program
59
+ commander_1.program
57
60
  .version(utils_1.version)
58
61
  .option('-e, --engine <engine>', 'The target database engine (postgres|websql|mysql), default: postgres', /postgres|websql|mysql/, 'postgres')
59
62
  .option('--json', 'Force json output, default: false');
60
- program
63
+ commander_1.program
61
64
  .command('parse <input-url> [output-file]')
62
65
  .description('parse the input OData URL into OData AST')
63
66
  .action(parseOData);
64
- program
67
+ commander_1.program
65
68
  .command('translate <model-file> <input-url> [output-file]')
66
69
  .description('translate the input OData URL into abstract SQL')
67
70
  .action(translateOData);
68
- program
71
+ commander_1.program
69
72
  .command('compile <model-file> <input-url> [output-file]')
70
73
  .description('compile the input OData URL into SQL')
71
74
  .action(compileOData);
72
- program
75
+ commander_1.program
73
76
  .command('help')
74
77
  .description('print the help')
75
- .action(() => program.help());
76
- program.arguments('<sbvr-file> <input-url> [output-file]').action(compileOData);
78
+ .action(() => commander_1.program.help());
79
+ commander_1.program.arguments('<sbvr-file> <input-url> [output-file]').action(compileOData);
77
80
  if (process.argv.length === 2) {
78
- program.help();
81
+ commander_1.program.help();
79
82
  }
80
- program.parse(process.argv);
83
+ commander_1.program.parse(process.argv);
81
84
  //# sourceMappingURL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,gDAAgD,CAAC;KACzD,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,YAAY,CAAC,CAAC;AAEvB,mBAAO;KACL,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,gBAAgB,CAAC;KAC7B,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAE/B,mBAAO,CAAC,SAAS,CAAC,uCAAuC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAEhF,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;IAC9B,mBAAO,CAAC,IAAI,EAAE,CAAC;CACf;AAED,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,64 +1,64 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("./utils");
4
- const program = require("commander");
4
+ const commander_1 = require("commander");
5
5
  const fs = require("fs");
6
6
  const getSE = (inputFile) => fs.readFileSync(inputFile, 'utf8');
7
7
  const parse = (inputFile, outputFile) => {
8
- const { generateLfModel, } = require('../sbvr-api/sbvr-utils');
8
+ const { generateLfModel } = require('../sbvr-api/sbvr-utils');
9
9
  const seModel = getSE(inputFile);
10
10
  const result = generateLfModel(seModel);
11
11
  const json = JSON.stringify(result, null, 2);
12
- utils_1.writeAll(json, outputFile);
12
+ (0, utils_1.writeAll)(json, outputFile);
13
13
  };
14
14
  const transform = (inputFile, outputFile) => {
15
- const { generateLfModel, generateAbstractSqlModel, } = require('../sbvr-api/sbvr-utils');
15
+ const { generateLfModel, generateAbstractSqlModel } = require('../sbvr-api/sbvr-utils');
16
16
  const seModel = getSE(inputFile);
17
17
  const lfModel = generateLfModel(seModel);
18
18
  const result = generateAbstractSqlModel(lfModel);
19
19
  const json = JSON.stringify(result, null, 2);
20
- utils_1.writeAll(json, outputFile);
20
+ (0, utils_1.writeAll)(json, outputFile);
21
21
  };
22
22
  const runCompile = (inputFile, outputFile) => {
23
- const { generateModels, } = require('../sbvr-api/sbvr-utils');
23
+ const { generateModels } = require('../sbvr-api/sbvr-utils');
24
24
  const seModel = getSE(inputFile);
25
- const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, program.opts().engine);
26
- utils_1.writeSqlModel(models.sql, outputFile);
25
+ const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, commander_1.program.opts().engine);
26
+ (0, utils_1.writeSqlModel)(models.sql, outputFile);
27
27
  };
28
28
  const generateTypes = (inputFile, outputFile) => {
29
- const { generateModels, } = require('../sbvr-api/sbvr-utils');
29
+ const { generateModels } = require('../sbvr-api/sbvr-utils');
30
30
  const seModel = getSE(inputFile);
31
- const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, program.opts().engine);
32
- const { abstractSqlToTypescriptTypes, } = require('@balena/abstract-sql-to-typescript');
31
+ const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, commander_1.program.opts().engine);
32
+ const { abstractSqlToTypescriptTypes } = require('@balena/abstract-sql-to-typescript');
33
33
  const types = abstractSqlToTypescriptTypes(models.abstractSql);
34
- utils_1.writeAll(types, outputFile);
34
+ (0, utils_1.writeAll)(types, outputFile);
35
35
  };
36
- program
36
+ commander_1.program
37
37
  .version(utils_1.version)
38
38
  .option('-e, --engine <engine>', 'The target database engine (postgres|websql|mysql), default: postgres', /postgres|websql|mysql/, 'postgres');
39
- program
39
+ commander_1.program
40
40
  .command('parse <input-file> [output-file]')
41
41
  .description('parse the input SBVR file into LF')
42
42
  .action(parse);
43
- program
43
+ commander_1.program
44
44
  .command('transform <input-file> [output-file]')
45
45
  .description('transform the input SBVR file into abstract SQL')
46
46
  .action(transform);
47
- program
47
+ commander_1.program
48
48
  .command('compile <input-file> [output-file]')
49
49
  .description('compile the input SBVR file into SQL')
50
50
  .action(runCompile);
51
- program
51
+ commander_1.program
52
52
  .command('generate-types <input-file> [output-file]')
53
53
  .description('generate typescript types from the input SBVR')
54
54
  .action(generateTypes);
55
- program
55
+ commander_1.program
56
56
  .command('help')
57
57
  .description('print the help')
58
- .action(() => program.help());
59
- program.arguments('<input-file> [output-file]').action(runCompile);
58
+ .action(() => commander_1.program.help());
59
+ commander_1.program.arguments('<input-file> [output-file]').action(runCompile);
60
60
  if (process.argv.length === 2) {
61
- program.help();
61
+ commander_1.program.help();
62
62
  }
63
- program.parse(process.argv);
63
+ commander_1.program.parse(process.argv);
64
64
  //# sourceMappingURL=sbvr-compiler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sbvr-compiler.js","sourceRoot":"","sources":["../../src/bin/sbvr-compiler.ts"],"names":[],"mappings":";;AAAA,mCAA2D;AAI3D,qCAAqC;AACrC,yBAAyB;AAEzB,MAAM,KAAK,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAExE,MAAM,KAAK,GAAG,CAAC,SAAiB,EAAE,UAAmB,EAAE,EAAE;IACxD,MAAM,EACL,eAAe,GACf,GAAG,OAAO,CAAC,wBAAwB,CAAqB,CAAC;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,gBAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,SAAiB,EAAE,UAAmB,EAAE,EAAE;IAC5D,MAAM,EACL,eAAe,EACf,wBAAwB,GACxB,GAAG,OAAO,CAAC,wBAAwB,CAAqB,CAAC;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,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C,mBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAE/B,mBAAO,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAEnE,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;IAC9B,mBAAO,CAAC,IAAI,EAAE,CAAC;CACf;AAED,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -2,6 +2,6 @@ import type { SqlModel } from '@balena/abstract-sql-compiler';
2
2
  import type { AbstractSqlModel } from '@balena/abstract-sql-compiler';
3
3
  import '../server-glue/sbvr-loader';
4
4
  export declare const version: any;
5
- export declare const writeAll: (output: string, outputFile?: string | undefined) => void;
6
- export declare const writeSqlModel: (sqlModel: SqlModel, outputFile?: string | undefined) => void;
5
+ export declare const writeAll: (output: string, outputFile?: string) => void;
6
+ export declare const writeSqlModel: (sqlModel: SqlModel, outputFile?: string) => void;
7
7
  export declare const getAbstractSqlModelFromFile: (modelFile: string) => AbstractSqlModel;
package/out/bin/utils.js CHANGED
@@ -34,7 +34,7 @@ ${sqlModel.rules
34
34
  ${rule.sql}`)
35
35
  .join('\n\n')}
36
36
  `;
37
- exports.writeAll(output, outputFile);
37
+ (0, exports.writeAll)(output, outputFile);
38
38
  };
39
39
  exports.writeSqlModel = writeSqlModel;
40
40
  const getAbstractSqlModelFromFile = (modelFile) => {
@@ -42,7 +42,7 @@ const getAbstractSqlModelFromFile = (modelFile) => {
42
42
  try {
43
43
  fileContents = require(path.resolve(modelFile));
44
44
  }
45
- catch (_a) {
45
+ catch {
46
46
  fileContents = fs.readFileSync(require.resolve(modelFile), 'utf8');
47
47
  }
48
48
  let seModel;
@@ -73,7 +73,7 @@ const getAbstractSqlModelFromFile = (modelFile) => {
73
73
  else {
74
74
  throw new Error('Unrecognised config file');
75
75
  }
76
- const { generateLfModel, generateAbstractSqlModel, } = require('../sbvr-api/sbvr-utils');
76
+ const { generateLfModel, generateAbstractSqlModel } = require('../sbvr-api/sbvr-utils');
77
77
  let lfModel;
78
78
  try {
79
79
  lfModel = generateLfModel(seModel);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/bin/utils.ts"],"names":[],"mappings":";;;AAAA,OAAO,CAAC,GAAG,CAAC,iBAAiB;IAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS,GAAG,qBAAqB,CAAC;AAOpE,yBAAyB;AACzB,6BAA6B;AAC7B,sCAAoC;AAGrB,eAAO,GAAK,IAAI,CAAC,KAAK,CACpC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,CAC9D,SAAC;AAEK,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,UAAmB,EAAQ,EAAE;IACrE,IAAI,UAAU,EAAE;QACf,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;KACrC;SAAM;QACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACpB;AACF,CAAC,CAAC;AANW,QAAA,QAAQ,YAMnB;AAEK,MAAM,aAAa,GAAG,CAC5B,QAAkB,EAClB,UAAmB,EACZ,EAAE;IACT,MAAM,MAAM,GAAG;;;;;EAKd,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;;;;;;EAMlC,QAAQ,CAAC,KAAK;SACd,GAAG,CACH,CAAC,IAAI,EAAE,EAAE,CAAC;KACP,IAAI,CAAC,iBAAiB;EACzB,IAAI,CAAC,GAAG,EAAE,CACV;SACA,IAAI,CAAC,MAAM,CAAC;CACb,CAAC;IACD,gBAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC9B,CAAC,CAAC;AAxBW,QAAA,aAAa,iBAwBxB;AAEK,MAAM,2BAA2B,GAAG,CAC1C,SAAiB,EACE,EAAE;IACrB,IAAI,YAAwD,CAAC;IAC7D,IAA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CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;SAC1E;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC5C;KACD;SAAM;QACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC5C;IACD,MAAM,EAAE,eAAe,EAAE,wBAAwB,EAAE,GAClD,OAAO,CAAC,wBAAwB,CAAqB,CAAC;IACvD,IAAI,OAAO,CAAC;IACZ,IAAI;QACH,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;KACnC;IAAC,OAAO,CAAM,EAAE;QAChB,MAAM,IAAI,KAAK,CACd,QAAQ,CAAC,CAAC,OAAO,8KAA8K,CAC/L,CAAC;KACF;IACD,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AA5CW,QAAA,2BAA2B,+BA4CtC"}
@@ -1,10 +1,11 @@
1
1
  import type * as Express from 'express';
2
- import type { AbstractSqlModel } from '@balena/abstract-sql-compiler';
2
+ import type { AbstractSqlModel, Definition } from '@balena/abstract-sql-compiler';
3
3
  import type { Database } from '../database-layer/db';
4
- import type { Migration } from '../migrator/migrator';
5
- import type { Resolvable } from '../sbvr-api/common-types';
4
+ import type { Dictionary, Resolvable } from '../sbvr-api/common-types';
5
+ import { Migrations } from '../migrator/utils';
6
6
  import * as sbvrUtils from '../sbvr-api/sbvr-utils';
7
- export declare type SetupFunction = (app: Express.Application, sbvrUtilsInstance: typeof sbvrUtils, db: Database) => Resolvable<void>;
7
+ import { AliasValidNodeType } from '../sbvr-api/translations';
8
+ export type SetupFunction = (app: Express.Application, sbvrUtilsInstance: typeof sbvrUtils, db: Database) => Resolvable<void>;
8
9
  export interface Model {
9
10
  apiRoot?: string;
10
11
  modelName?: string;
@@ -12,9 +13,7 @@ export interface Model {
12
13
  modelText?: string;
13
14
  abstractSql?: AbstractSqlModel;
14
15
  migrationsPath?: string;
15
- migrations?: {
16
- [index: string]: Migration;
17
- };
16
+ migrations?: Migrations;
18
17
  initSqlPath?: string;
19
18
  initSql?: string;
20
19
  customServerCode?: string | {
@@ -23,11 +22,13 @@ export interface Model {
23
22
  logging?: {
24
23
  [key in keyof Console | 'default']?: boolean;
25
24
  };
25
+ translateTo?: Model['apiRoot'];
26
+ translations?: Dictionary<Definition | Dictionary<string | AliasValidNodeType>>;
26
27
  }
27
28
  export interface User {
28
29
  username: string;
29
30
  password: string;
30
- permissions: string[];
31
+ permissions?: string[];
31
32
  }
32
33
  export interface Config {
33
34
  models: Model[];