@balena/pinejs 19.7.2-build-esm-36f468424324d7ef7578ae401fc681c9f8f63e03-3 → 19.7.2-build-update-deps-a909ee054f395de407ec4e1275fd0f5b7514fe29-1
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/.versionbot/CHANGELOG.yml +3 -3
- package/CHANGELOG.md +1 -1
- package/{Gruntfile.cts → Gruntfile.ts} +22 -9
- package/bin/abstract-sql-compiler.js +1 -1
- package/bin/odata-compiler.js +1 -1
- package/bin/sbvr-compiler.js +1 -1
- package/build/{browser.cts → browser.ts} +1 -1
- package/build/{config.cts → config.ts} +1 -5
- package/build/{module.cts → module.ts} +1 -1
- package/build/{server.cts → server.ts} +1 -1
- package/out/bin/abstract-sql-compiler.js +19 -17
- package/out/bin/abstract-sql-compiler.js.map +1 -1
- package/out/bin/odata-compiler.js +21 -19
- package/out/bin/odata-compiler.js.map +1 -1
- package/out/bin/sbvr-compiler.js +54 -19
- package/out/bin/sbvr-compiler.js.map +1 -1
- package/out/bin/utils.d.ts +3 -3
- package/out/bin/utils.js +53 -21
- package/out/bin/utils.js.map +1 -1
- package/out/config-loader/config-loader.d.ts +7 -7
- package/out/config-loader/config-loader.js +63 -23
- package/out/config-loader/config-loader.js.map +1 -1
- package/out/config-loader/env.d.ts +1 -1
- package/out/config-loader/env.js +66 -24
- package/out/config-loader/env.js.map +1 -1
- package/out/data-server/sbvr-server.d.ts +3 -3
- package/out/data-server/sbvr-server.js +42 -5
- package/out/data-server/sbvr-server.js.map +1 -1
- package/out/database-layer/db.d.ts +3 -3
- package/out/database-layer/db.js +83 -37
- package/out/database-layer/db.js.map +1 -1
- package/out/express-emulator/express.js.map +1 -1
- package/out/extended-sbvr-parser/extended-sbvr-parser.js +11 -8
- package/out/extended-sbvr-parser/extended-sbvr-parser.js.map +1 -1
- package/out/http-transactions/transactions.d.ts +2 -2
- package/out/http-transactions/transactions.js +4 -4
- package/out/http-transactions/transactions.js.map +1 -1
- package/out/migrator/async.d.ts +2 -2
- package/out/migrator/async.js +60 -20
- package/out/migrator/async.js.map +1 -1
- package/out/migrator/migrations.js +2 -1
- package/out/migrator/sync.d.ts +6 -6
- package/out/migrator/sync.js +61 -20
- package/out/migrator/sync.js.map +1 -1
- package/out/migrator/utils.d.ts +4 -4
- package/out/migrator/utils.js +97 -42
- package/out/migrator/utils.js.map +1 -1
- package/out/odata-metadata/odata-metadata-generator.js +14 -7
- package/out/odata-metadata/odata-metadata-generator.js.map +1 -1
- package/out/passport-pinejs/mount-login-router.d.ts +1 -1
- package/out/passport-pinejs/mount-login-router.js +41 -4
- package/out/passport-pinejs/mount-login-router.js.map +1 -1
- package/out/passport-pinejs/passport-pinejs.d.ts +3 -3
- package/out/passport-pinejs/passport-pinejs.js +46 -11
- package/out/passport-pinejs/passport-pinejs.js.map +1 -1
- package/out/pinejs-session-store/pinejs-session-store.d.ts +1 -1
- package/out/pinejs-session-store/pinejs-session-store.js +48 -11
- package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
- package/out/sbvr-api/abstract-sql.d.ts +3 -3
- package/out/sbvr-api/abstract-sql.js +65 -22
- package/out/sbvr-api/abstract-sql.js.map +1 -1
- package/out/sbvr-api/cached-compile.js +15 -8
- package/out/sbvr-api/cached-compile.js.map +1 -1
- package/out/sbvr-api/common-types.js +2 -1
- package/out/sbvr-api/control-flow.d.ts +1 -1
- package/out/sbvr-api/control-flow.js +25 -12
- package/out/sbvr-api/control-flow.js.map +1 -1
- package/out/sbvr-api/dev.js +2 -1
- package/out/sbvr-api/errors.d.ts +1 -1
- package/out/sbvr-api/errors.js +95 -47
- package/out/sbvr-api/errors.js.map +1 -1
- package/out/sbvr-api/express-extension.d.ts +2 -2
- package/out/sbvr-api/express-extension.js +2 -1
- package/out/sbvr-api/hooks.d.ts +4 -4
- package/out/sbvr-api/hooks.js +35 -23
- package/out/sbvr-api/hooks.js.map +1 -1
- package/out/sbvr-api/odata-response.d.ts +2 -2
- package/out/sbvr-api/odata-response.js +29 -19
- package/out/sbvr-api/odata-response.js.map +1 -1
- package/out/sbvr-api/permissions.d.ts +9 -9
- package/out/sbvr-api/permissions.js +159 -106
- package/out/sbvr-api/permissions.js.map +1 -1
- package/out/sbvr-api/sbvr-utils.d.ts +18 -40
- package/out/sbvr-api/sbvr-utils.js +285 -222
- package/out/sbvr-api/sbvr-utils.js.map +1 -1
- package/out/sbvr-api/translations.d.ts +1 -1
- package/out/sbvr-api/translations.js +17 -10
- package/out/sbvr-api/translations.js.map +1 -1
- package/out/sbvr-api/uri-parser.d.ts +7 -7
- package/out/sbvr-api/uri-parser.js +84 -39
- package/out/sbvr-api/uri-parser.js.map +1 -1
- package/out/sbvr-api/user.js +2 -1
- package/out/server-glue/global-ext.d.ts +3 -0
- package/out/server-glue/module.d.ts +16 -16
- package/out/server-glue/module.js +59 -20
- package/out/server-glue/module.js.map +1 -1
- package/out/server-glue/sbvr-loader.d.ts +1 -2
- package/out/server-glue/sbvr-loader.js +11 -4
- package/out/server-glue/sbvr-loader.js.map +1 -1
- package/out/server-glue/server.d.ts +2 -2
- package/out/server-glue/server.js +59 -17
- package/out/server-glue/server.js.map +1 -1
- package/out/tasks/common.d.ts +1 -1
- package/out/tasks/common.js +9 -3
- package/out/tasks/common.js.map +1 -1
- package/out/tasks/index.d.ts +8 -8
- package/out/tasks/index.js +63 -25
- package/out/tasks/index.js.map +1 -1
- package/out/tasks/tasks.js +2 -1
- package/out/tasks/worker.d.ts +3 -3
- package/out/tasks/worker.js +51 -14
- package/out/tasks/worker.js.map +1 -1
- package/out/webresource-handler/handlers/NoopHandler.d.ts +1 -1
- package/out/webresource-handler/handlers/NoopHandler.js +5 -1
- package/out/webresource-handler/handlers/NoopHandler.js.map +1 -1
- package/out/webresource-handler/handlers/S3Handler.d.ts +1 -1
- package/out/webresource-handler/handlers/S3Handler.js +24 -17
- package/out/webresource-handler/handlers/S3Handler.js.map +1 -1
- package/out/webresource-handler/handlers/index.d.ts +2 -2
- package/out/webresource-handler/handlers/index.js +18 -2
- package/out/webresource-handler/handlers/index.js.map +1 -1
- package/out/webresource-handler/index.d.ts +3 -3
- package/out/webresource-handler/index.js +85 -35
- package/out/webresource-handler/index.js.map +1 -1
- package/package.json +33 -33
- package/src/bin/abstract-sql-compiler.ts +3 -3
- package/src/bin/odata-compiler.ts +3 -3
- package/src/bin/sbvr-compiler.ts +2 -2
- package/src/bin/utils.ts +15 -23
- package/src/config-loader/config-loader.ts +12 -12
- package/src/config-loader/env.ts +3 -3
- package/src/data-server/sbvr-server.ts +4 -4
- package/src/database-layer/db.ts +11 -18
- package/src/extended-sbvr-parser/extended-sbvr-parser.ts +5 -5
- package/src/http-transactions/transactions.js +4 -4
- package/src/migrator/async.ts +5 -5
- package/src/migrator/sync.ts +8 -8
- package/src/migrator/utils.ts +7 -7
- package/src/odata-metadata/odata-metadata-generator.ts +2 -3
- package/src/passport-pinejs/mount-login-router.ts +3 -3
- package/src/passport-pinejs/passport-pinejs.ts +6 -6
- package/src/pinejs-session-store/pinejs-session-store.ts +4 -4
- package/src/sbvr-api/abstract-sql.ts +6 -6
- package/src/sbvr-api/cached-compile.ts +2 -2
- package/src/sbvr-api/control-flow.ts +1 -1
- package/src/sbvr-api/errors.ts +1 -1
- package/src/sbvr-api/express-extension.ts +2 -2
- package/src/sbvr-api/hooks.ts +5 -5
- package/src/sbvr-api/odata-response.ts +4 -8
- package/src/sbvr-api/permissions.ts +19 -19
- package/src/sbvr-api/sbvr-utils.ts +33 -39
- package/src/sbvr-api/translations.ts +1 -1
- package/src/sbvr-api/uri-parser.ts +10 -10
- package/src/server-glue/global-ext.d.ts +3 -0
- package/src/server-glue/module.ts +20 -20
- package/src/server-glue/sbvr-loader.ts +27 -15
- package/src/server-glue/server.ts +24 -13
- package/src/tasks/common.ts +1 -1
- package/src/tasks/index.ts +14 -14
- package/src/tasks/worker.ts +8 -8
- package/src/webresource-handler/handlers/NoopHandler.ts +1 -5
- package/src/webresource-handler/handlers/S3Handler.ts +1 -1
- package/src/webresource-handler/handlers/index.ts +2 -2
- package/src/webresource-handler/index.ts +10 -10
- package/tsconfig.dev.json +2 -4
- package/tsconfig.json +1 -1
- package/typings/lf-to-abstract-sql.d.ts +2 -2
- package/typings/memoizee.d.ts +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
- commits:
|
2
|
-
- subject:
|
3
|
-
hash:
|
2
|
+
- subject: Update dependencies
|
3
|
+
hash: a909ee054f395de407ec4e1275fd0f5b7514fe29
|
4
4
|
body: ""
|
5
5
|
footer:
|
6
6
|
Change-type: patch
|
@@ -9,7 +9,7 @@
|
|
9
9
|
nested: []
|
10
10
|
version: 19.7.2
|
11
11
|
title: ""
|
12
|
-
date: 2025-01-
|
12
|
+
date: 2025-01-02T16:35:55.788Z
|
13
13
|
- commits:
|
14
14
|
- subject: Use/export explicit functions for loading SBVR files
|
15
15
|
hash: c47a755613fec8293547c7cfb34cc9e707a7c703
|
package/CHANGELOG.md
CHANGED
@@ -3,9 +3,9 @@ import type { WebpackPluginInstance } from 'webpack';
|
|
3
3
|
|
4
4
|
import _ from 'lodash';
|
5
5
|
import TerserPlugin from 'terser-webpack-plugin';
|
6
|
-
import browserConfig from './build/browser
|
7
|
-
import moduleConfig from './build/module
|
8
|
-
import serverConfig from './build/server
|
6
|
+
import browserConfig from './build/browser';
|
7
|
+
import moduleConfig from './build/module';
|
8
|
+
import serverConfig from './build/server';
|
9
9
|
|
10
10
|
const serverConfigs = {
|
11
11
|
browser: browserConfig,
|
@@ -110,18 +110,30 @@ export = (grunt: typeof Grunt) => {
|
|
110
110
|
return renames;
|
111
111
|
})(),
|
112
112
|
|
113
|
-
replace:
|
114
|
-
|
113
|
+
replace: {
|
114
|
+
'pine.js': {
|
115
115
|
src: 'out/pine.js',
|
116
116
|
overwrite: true,
|
117
117
|
replacements: [
|
118
118
|
{
|
119
|
-
from: /
|
120
|
-
to:
|
119
|
+
from: /nodeRequire/g,
|
120
|
+
to: 'require',
|
121
121
|
},
|
122
122
|
],
|
123
|
-
}
|
124
|
-
|
123
|
+
},
|
124
|
+
..._.mapValues(serverConfigs, (_config, task) => {
|
125
|
+
return {
|
126
|
+
src: 'out/pine.js',
|
127
|
+
overwrite: true,
|
128
|
+
replacements: [
|
129
|
+
{
|
130
|
+
from: /sourceMappingURL=pine.js.map/g,
|
131
|
+
to: `sourceMappingURL=pine-${task}-<%= grunt.option('version') %>.js.map`,
|
132
|
+
},
|
133
|
+
],
|
134
|
+
};
|
135
|
+
}),
|
136
|
+
},
|
125
137
|
|
126
138
|
webpack: serverConfigs,
|
127
139
|
|
@@ -155,6 +167,7 @@ export = (grunt: typeof Grunt) => {
|
|
155
167
|
'webpack:' + task,
|
156
168
|
'gitinfo:describe',
|
157
169
|
'version',
|
170
|
+
'replace:pine.js',
|
158
171
|
`replace:${task}`,
|
159
172
|
`concat:${task}`,
|
160
173
|
`rename:${task}`,
|
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
2
|
+
require('../out/bin/abstract-sql-compiler');
|
package/bin/odata-compiler.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
2
|
+
require('../out/bin/odata-compiler');
|
package/bin/sbvr-compiler.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
2
|
+
require('../out/bin/sbvr-compiler');
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as webpack from 'webpack';
|
2
2
|
import type { Configuration } from 'webpack';
|
3
|
-
import sharedConfig from './config
|
3
|
+
import sharedConfig from './config';
|
4
4
|
|
5
5
|
if (typeof sharedConfig.externals !== 'object') {
|
6
6
|
throw new Error('Expected externals to be an object');
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { RequiredField } from '../src/sbvr-api/common-types
|
1
|
+
import type { RequiredField } from '../src/sbvr-api/common-types';
|
2
2
|
|
3
3
|
import * as path from 'path';
|
4
4
|
import * as webpack from 'webpack';
|
@@ -46,10 +46,6 @@ const config: RequiredField<
|
|
46
46
|
},
|
47
47
|
resolve: {
|
48
48
|
extensions: ['.js', '.ts'],
|
49
|
-
extensionAlias: {
|
50
|
-
'.js': ['.ts', '.js'],
|
51
|
-
'.mjs': ['.mts', '.mjs'],
|
52
|
-
},
|
53
49
|
},
|
54
50
|
plugins: [new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })],
|
55
51
|
module: {
|
@@ -1,32 +1,34 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const utils_1 = require("./utils");
|
4
|
+
const commander_1 = require("commander");
|
3
5
|
const runCompile = async (inputFile, outputFile) => {
|
4
6
|
const { generateSqlModel } = await import('../sbvr-api/sbvr-utils.js');
|
5
|
-
const abstractSql =
|
6
|
-
const sqlModel = generateSqlModel(abstractSql, program.opts().engine);
|
7
|
-
writeSqlModel(sqlModel, outputFile);
|
7
|
+
const abstractSql = (0, utils_1.getAbstractSqlModelFromFile)(inputFile, commander_1.program.opts().model);
|
8
|
+
const sqlModel = generateSqlModel(abstractSql, commander_1.program.opts().engine);
|
9
|
+
(0, utils_1.writeSqlModel)(sqlModel, outputFile);
|
8
10
|
};
|
9
11
|
const generateTypes = async (inputFile, options) => {
|
10
12
|
const { abstractSqlToTypescriptTypes } = await import('@balena/abstract-sql-to-typescript/generate');
|
11
|
-
const abstractSql =
|
13
|
+
const abstractSql = (0, utils_1.getAbstractSqlModelFromFile)(inputFile, commander_1.program.opts().model);
|
12
14
|
const types = abstractSqlToTypescriptTypes(abstractSql, {
|
13
15
|
convertSerialToInteger: options.convertSerialToInteger,
|
14
16
|
});
|
15
|
-
writeAll(types, options.outputFile);
|
17
|
+
(0, utils_1.writeAll)(types, options.outputFile);
|
16
18
|
};
|
17
|
-
program
|
18
|
-
.version(version)
|
19
|
+
commander_1.program
|
20
|
+
.version(utils_1.version)
|
19
21
|
.option('-e, --engine <engine>', 'The target database engine (postgres|websql|mysql), default: postgres', /postgres|websql|mysql/, 'postgres')
|
20
22
|
.option('-m, --model <model-name>', 'The target model for config files with multiple models, default: first model');
|
21
|
-
program
|
23
|
+
commander_1.program
|
22
24
|
.command('compile <input-file> [output-file]')
|
23
25
|
.description('compile the input AbstractSql model into SQL')
|
24
26
|
.action(runCompile);
|
25
|
-
program
|
27
|
+
commander_1.program
|
26
28
|
.command('compile-schema <input-file> [output-file]')
|
27
29
|
.description('compile the input AbstractSql model into SQL')
|
28
30
|
.action(runCompile);
|
29
|
-
program
|
31
|
+
commander_1.program
|
30
32
|
.command('generate-types <input-file> [output-file]')
|
31
33
|
.description('generate typescript types from the input AbstractSql')
|
32
34
|
.option('--convert-serial-to-integer', 'Convert serials to integers')
|
@@ -36,13 +38,13 @@ program
|
|
36
38
|
convertSerialToInteger: opts.convertSerialToInteger,
|
37
39
|
});
|
38
40
|
});
|
39
|
-
program
|
41
|
+
commander_1.program
|
40
42
|
.command('help')
|
41
43
|
.description('print the help')
|
42
|
-
.action(() => program.help());
|
43
|
-
program.arguments('<input-file> [output-file]').action(runCompile);
|
44
|
+
.action(() => commander_1.program.help());
|
45
|
+
commander_1.program.arguments('<input-file> [output-file]').action(runCompile);
|
44
46
|
if (process.argv.length === 2) {
|
45
|
-
program.help();
|
47
|
+
commander_1.program.help();
|
46
48
|
}
|
47
|
-
void program.parseAsync(process.argv);
|
49
|
+
void commander_1.program.parseAsync(process.argv);
|
48
50
|
//# 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,
|
1
|
+
{"version":3,"file":"abstract-sql-compiler.js","sourceRoot":"","sources":["../../src/bin/abstract-sql-compiler.ts"],"names":[],"mappings":";;AAAA,mCAKiB;AAEjB,yCAAoC;AAEpC,MAAM,UAAU,GAAG,KAAK,EAAE,SAAiB,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AAO;KACL,OAAO,CAAC,2CAA2C,CAAC;KACpD,WAAW,CAAC,sDAAsD,CAAC;KACnE,MAAM,CAAC,6BAA6B,EAAE,6BAA6B,CAAC;KACpE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;IAC7C,MAAM,aAAa,CAAC,SAAS,EAAE;QAC9B,UAAU;QACV,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;KACnD,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEJ,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,4BAA4B,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAEnE,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC/B,mBAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,KAAK,mBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const utils_1 = require("./utils");
|
4
|
+
const commander_1 = require("commander");
|
3
5
|
const generateAbstractSqlQuery = async (abstractSqlModel, odata) => {
|
4
6
|
const { memoizedParseOdata, translateUri } = await import('../sbvr-api/uri-parser.js');
|
5
7
|
const odataAST = memoizedParseOdata(odata);
|
6
8
|
const vocabulary = '';
|
7
9
|
return translateUri({
|
8
|
-
engine: program.opts().engine,
|
10
|
+
engine: commander_1.program.opts().engine,
|
9
11
|
method: 'GET',
|
10
12
|
url: odata,
|
11
13
|
resourceName: odataAST.tree.resource,
|
@@ -23,12 +25,12 @@ const parseOData = async (odata, outputFile) => {
|
|
23
25
|
const { memoizedParseOdata } = await import('../sbvr-api/uri-parser.js');
|
24
26
|
const result = memoizedParseOdata(odata);
|
25
27
|
const json = JSON.stringify(result, null, 2);
|
26
|
-
writeAll(json, outputFile);
|
28
|
+
(0, utils_1.writeAll)(json, outputFile);
|
27
29
|
};
|
28
30
|
const translateOData = async (modelFile, odata, outputFile) => {
|
29
|
-
const request = await generateAbstractSqlQuery(
|
31
|
+
const request = await generateAbstractSqlQuery((0, utils_1.getAbstractSqlModelFromFile)(modelFile, commander_1.program.opts().model), odata);
|
30
32
|
const json = JSON.stringify(request.abstractSqlQuery, null, 2);
|
31
|
-
writeAll(json, outputFile);
|
33
|
+
(0, utils_1.writeAll)(json, outputFile);
|
32
34
|
};
|
33
35
|
const formatSqlQuery = (sqlQuery) => {
|
34
36
|
if (Array.isArray(sqlQuery)) {
|
@@ -42,43 +44,43 @@ Bindings: ${JSON.stringify(sqlQuery.bindings, null, 2)}
|
|
42
44
|
}
|
43
45
|
};
|
44
46
|
const compileOData = async (modelFile, odata, outputFile) => {
|
45
|
-
const translatedRequest = await generateAbstractSqlQuery(
|
47
|
+
const translatedRequest = await generateAbstractSqlQuery((0, utils_1.getAbstractSqlModelFromFile)(modelFile, commander_1.program.opts().model), odata);
|
46
48
|
const { compileRequest } = await import('../sbvr-api/abstract-sql.js');
|
47
49
|
const compiledRequest = compileRequest(translatedRequest);
|
48
50
|
let output;
|
49
|
-
if (program.opts().json) {
|
51
|
+
if (commander_1.program.opts().json) {
|
50
52
|
output = JSON.stringify(compiledRequest.sqlQuery, null, 2);
|
51
53
|
}
|
52
54
|
else {
|
53
55
|
output = formatSqlQuery(compiledRequest.sqlQuery);
|
54
56
|
}
|
55
|
-
writeAll(output, outputFile);
|
57
|
+
(0, utils_1.writeAll)(output, outputFile);
|
56
58
|
};
|
57
|
-
program
|
58
|
-
.version(version)
|
59
|
+
commander_1.program
|
60
|
+
.version(utils_1.version)
|
59
61
|
.option('-e, --engine <engine>', 'The target database engine (postgres|websql|mysql), default: postgres', /postgres|websql|mysql/, 'postgres')
|
60
62
|
.option('--json', 'Force json output, default: false');
|
61
|
-
program
|
63
|
+
commander_1.program
|
62
64
|
.command('parse <input-url> [output-file]')
|
63
65
|
.description('parse the input OData URL into OData AST')
|
64
66
|
.action(parseOData);
|
65
|
-
program
|
67
|
+
commander_1.program
|
66
68
|
.command('translate <model-file> <input-url> [output-file]')
|
67
69
|
.description('translate the input OData URL into abstract SQL')
|
68
70
|
.option('-m, --model <model-name>', 'The target model for config files with multiple models, default: first model')
|
69
71
|
.action(translateOData);
|
70
|
-
program
|
72
|
+
commander_1.program
|
71
73
|
.command('compile <model-file> <input-url> [output-file]')
|
72
74
|
.description('compile the input OData URL into SQL')
|
73
75
|
.option('-m, --model <model-name>', 'The target model for config files with multiple models, default: first model')
|
74
76
|
.action(compileOData);
|
75
|
-
program
|
77
|
+
commander_1.program
|
76
78
|
.command('help')
|
77
79
|
.description('print the help')
|
78
|
-
.action(() => program.help());
|
79
|
-
program.arguments('<sbvr-file> <input-url> [output-file]').action(compileOData);
|
80
|
+
.action(() => commander_1.program.help());
|
81
|
+
commander_1.program.arguments('<sbvr-file> <input-url> [output-file]').action(compileOData);
|
80
82
|
if (process.argv.length === 2) {
|
81
|
-
program.help();
|
83
|
+
commander_1.program.help();
|
82
84
|
}
|
83
|
-
void program.parseAsync(process.argv);
|
85
|
+
void commander_1.program.parseAsync(process.argv);
|
84
86
|
//# sourceMappingURL=odata-compiler.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"odata-compiler.js","sourceRoot":"","sources":["../../src/bin/odata-compiler.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"odata-compiler.js","sourceRoot":"","sources":["../../src/bin/odata-compiler.ts"],"names":[],"mappings":";;AAAA,mCAAyE;AAMzE,yCAAoC;AAEpC,MAAM,wBAAwB,GAAG,KAAK,EACrC,gBAAkC,EAClC,KAAa,EACZ,EAAE;IACH,MAAM,EAAE,kBAA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AC,CAAC;AAEF,mBAAO;KACL,OAAO,CAAC,eAAO,CAAC;KAChB,MAAM,CACN,uBAAuB,EACvB,uEAAuE,EACvE,uBAAuB,EACvB,UAAU,CACV;KACA,MAAM,CAAC,QAAQ,EAAE,mCAAmC,CAAC,CAAC;AAExD,mBAAO;KACL,OAAO,CAAC,iCAAiC,CAAC;KAC1C,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,UAAU,CAAC,CAAC;AAErB,mBAAO;KACL,OAAO,CAAC,kDAAkD,CAAC;KAC3D,WAAW,CAAC,iDAAiD,CAAC;KAC9D,MAAM,CACN,0BAA0B,EAC1B,8EAA8E,CAC9E;KACA,MAAM,CAAC,cAAc,CAAC,CAAC;AAEzB,mBAAO;KACL,OAAO,CAAC,gDAAgD,CAAC;KACzD,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CACN,0BAA0B,EAC1B,8EAA8E,CAC9E;KACA,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,CAAC;IAC/B,mBAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,KAAK,mBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/out/bin/sbvr-compiler.js
CHANGED
@@ -1,13 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
const utils_1 = require("./utils");
|
37
|
+
const commander_1 = require("commander");
|
38
|
+
const fs = __importStar(require("fs"));
|
4
39
|
const getSE = (inputFile) => fs.readFileSync(inputFile, 'utf8');
|
5
40
|
const parse = async (inputFile, outputFile) => {
|
6
41
|
const { generateLfModel } = await import('../sbvr-api/sbvr-utils.js');
|
7
42
|
const seModel = getSE(inputFile);
|
8
43
|
const result = generateLfModel(seModel);
|
9
44
|
const json = JSON.stringify(result, null, 2);
|
10
|
-
writeAll(json, outputFile);
|
45
|
+
(0, utils_1.writeAll)(json, outputFile);
|
11
46
|
};
|
12
47
|
const transform = async (inputFile, outputFile) => {
|
13
48
|
const { generateLfModel, generateAbstractSqlModel } = await import('../sbvr-api/sbvr-utils.js');
|
@@ -15,13 +50,13 @@ const transform = async (inputFile, outputFile) => {
|
|
15
50
|
const lfModel = generateLfModel(seModel);
|
16
51
|
const result = generateAbstractSqlModel(lfModel);
|
17
52
|
const json = JSON.stringify(result, null, 2);
|
18
|
-
writeAll(json, outputFile);
|
53
|
+
(0, utils_1.writeAll)(json, outputFile);
|
19
54
|
};
|
20
55
|
const runCompile = async (inputFile, outputFile) => {
|
21
56
|
const { generateModels } = await import('../sbvr-api/sbvr-utils.js');
|
22
57
|
const seModel = getSE(inputFile);
|
23
|
-
const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, program.opts().engine);
|
24
|
-
writeSqlModel(models.sql, outputFile);
|
58
|
+
const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, commander_1.program.opts().engine);
|
59
|
+
(0, utils_1.writeSqlModel)(models.sql, outputFile);
|
25
60
|
};
|
26
61
|
const generateTypes = async (inputFile, outputFile) => {
|
27
62
|
const { generateLfModel, generateAbstractSqlModel } = await import('../sbvr-api/sbvr-utils.js');
|
@@ -30,34 +65,34 @@ const generateTypes = async (inputFile, outputFile) => {
|
|
30
65
|
const abstractSql = generateAbstractSqlModel(lfModel);
|
31
66
|
const { abstractSqlToTypescriptTypes } = await import('@balena/abstract-sql-to-typescript/generate');
|
32
67
|
const types = abstractSqlToTypescriptTypes(abstractSql);
|
33
|
-
writeAll(types, outputFile);
|
68
|
+
(0, utils_1.writeAll)(types, outputFile);
|
34
69
|
};
|
35
|
-
program
|
36
|
-
.version(version)
|
70
|
+
commander_1.program
|
71
|
+
.version(utils_1.version)
|
37
72
|
.option('-e, --engine <engine>', 'The target database engine (postgres|websql|mysql), default: postgres', /postgres|websql|mysql/, 'postgres');
|
38
|
-
program
|
73
|
+
commander_1.program
|
39
74
|
.command('parse <input-file> [output-file]')
|
40
75
|
.description('parse the input SBVR file into LF')
|
41
76
|
.action(parse);
|
42
|
-
program
|
77
|
+
commander_1.program
|
43
78
|
.command('transform <input-file> [output-file]')
|
44
79
|
.description('transform the input SBVR file into abstract SQL')
|
45
80
|
.action(transform);
|
46
|
-
program
|
81
|
+
commander_1.program
|
47
82
|
.command('compile <input-file> [output-file]')
|
48
83
|
.description('compile the input SBVR file into SQL')
|
49
84
|
.action(runCompile);
|
50
|
-
program
|
85
|
+
commander_1.program
|
51
86
|
.command('generate-types <input-file> [output-file]')
|
52
87
|
.description('generate typescript types from the input SBVR')
|
53
88
|
.action(generateTypes);
|
54
|
-
program
|
89
|
+
commander_1.program
|
55
90
|
.command('help')
|
56
91
|
.description('print the help')
|
57
|
-
.action(() => program.help());
|
58
|
-
program.arguments('<input-file> [output-file]').action(runCompile);
|
92
|
+
.action(() => commander_1.program.help());
|
93
|
+
commander_1.program.arguments('<input-file> [output-file]').action(runCompile);
|
59
94
|
if (process.argv.length === 2) {
|
60
|
-
program.help();
|
95
|
+
commander_1.program.help();
|
61
96
|
}
|
62
|
-
void program.parseAsync(process.argv);
|
97
|
+
void commander_1.program.parseAsync(process.argv);
|
63
98
|
//# sourceMappingURL=sbvr-compiler.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sbvr-compiler.js","sourceRoot":"","sources":["../../src/bin/sbvr-compiler.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"sbvr-compiler.js","sourceRoot":"","sources":["../../src/bin/sbvr-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA2D;AAC3D,yCAAoC;AACpC,uCAAyB;AAEzB,MAAM,KAAK,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAExE,MAAM,KAAK,GAAG,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AAC;KACf,WAAW,CAAC,gBAAgB,CAAC;KAC7B,MAAM,CAAC,GAAG,EAAE,CAAC,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,CAAC;IAC/B,mBAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,KAAK,mBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/out/bin/utils.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { SqlModel } from '@balena/abstract-sql-compiler';
|
2
2
|
import type { AbstractSqlModel } from '@balena/abstract-sql-compiler';
|
3
|
-
import '../server-glue/sbvr-loader
|
4
|
-
export { version } from '../config-loader/env
|
3
|
+
import '../server-glue/sbvr-loader';
|
4
|
+
export { version } from '../config-loader/env';
|
5
5
|
export declare const writeAll: (output: string, outputFile?: string) => void;
|
6
6
|
export declare const writeSqlModel: (sqlModel: SqlModel, outputFile?: string) => void;
|
7
|
-
export declare const getAbstractSqlModelFromFile: (modelFile: string, modelName: string | undefined) =>
|
7
|
+
export declare const getAbstractSqlModelFromFile: (modelFile: string, modelName: string | undefined) => AbstractSqlModel;
|
package/out/bin/utils.js
CHANGED
@@ -1,13 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.getAbstractSqlModelFromFile = exports.writeSqlModel = exports.writeAll = exports.version = void 0;
|
1
37
|
process.env.PINEJS_CACHE_FILE =
|
2
|
-
process.env.PINEJS_CACHE_FILE ||
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
export { version } from '../config-loader/env.js';
|
10
|
-
export const writeAll = (output, outputFile) => {
|
38
|
+
process.env.PINEJS_CACHE_FILE || __dirname + '/.pinejs-cache.json';
|
39
|
+
const fs = __importStar(require("fs"));
|
40
|
+
const path = __importStar(require("path"));
|
41
|
+
require("../server-glue/sbvr-loader");
|
42
|
+
var env_1 = require("../config-loader/env");
|
43
|
+
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return env_1.version; } });
|
44
|
+
const writeAll = (output, outputFile) => {
|
11
45
|
if (outputFile) {
|
12
46
|
fs.writeFileSync(outputFile, output);
|
13
47
|
}
|
@@ -15,7 +49,8 @@ export const writeAll = (output, outputFile) => {
|
|
15
49
|
console.log(output);
|
16
50
|
}
|
17
51
|
};
|
18
|
-
|
52
|
+
exports.writeAll = writeAll;
|
53
|
+
const writeSqlModel = (sqlModel, outputFile) => {
|
19
54
|
const output = `\
|
20
55
|
--
|
21
56
|
-- Create table statements
|
@@ -33,8 +68,9 @@ ${sqlModel.rules
|
|
33
68
|
${rule.sql}`)
|
34
69
|
.join('\n\n')}
|
35
70
|
`;
|
36
|
-
writeAll(output, outputFile);
|
71
|
+
(0, exports.writeAll)(output, outputFile);
|
37
72
|
};
|
73
|
+
exports.writeSqlModel = writeSqlModel;
|
38
74
|
const getConfigModel = (fileContents, modelName) => {
|
39
75
|
if ('models' in fileContents) {
|
40
76
|
if (fileContents.models.length === 0) {
|
@@ -51,18 +87,13 @@ const getConfigModel = (fileContents, modelName) => {
|
|
51
87
|
}
|
52
88
|
return fileContents;
|
53
89
|
};
|
54
|
-
|
90
|
+
const getAbstractSqlModelFromFile = (modelFile, modelName) => {
|
55
91
|
let fileContents;
|
56
92
|
try {
|
57
|
-
fileContents =
|
93
|
+
fileContents = require(path.resolve(modelFile));
|
58
94
|
}
|
59
95
|
catch {
|
60
|
-
fileContents =
|
61
|
-
try {
|
62
|
-
fileContents = JSON.parse(fileContents);
|
63
|
-
}
|
64
|
-
catch {
|
65
|
-
}
|
96
|
+
fileContents = fs.readFileSync(require.resolve(modelFile), 'utf8');
|
66
97
|
}
|
67
98
|
let seModel;
|
68
99
|
if (fileContents == null) {
|
@@ -83,7 +114,7 @@ export const getAbstractSqlModelFromFile = async (modelFile, modelName) => {
|
|
83
114
|
seModel = configModel.modelText;
|
84
115
|
}
|
85
116
|
else if ('modelFile' in configModel && configModel.modelFile != null) {
|
86
|
-
seModel =
|
117
|
+
seModel = fs.readFileSync(require.resolve(configModel.modelFile), 'utf8');
|
87
118
|
}
|
88
119
|
else {
|
89
120
|
throw new Error('Unrecognized config file');
|
@@ -92,7 +123,7 @@ export const getAbstractSqlModelFromFile = async (modelFile, modelName) => {
|
|
92
123
|
else {
|
93
124
|
throw new Error('Unrecognized config file');
|
94
125
|
}
|
95
|
-
const { generateLfModel, generateAbstractSqlModel } =
|
126
|
+
const { generateLfModel, generateAbstractSqlModel } = require('../sbvr-api/sbvr-utils');
|
96
127
|
let lfModel;
|
97
128
|
try {
|
98
129
|
lfModel = generateLfModel(seModel);
|
@@ -102,4 +133,5 @@ export const getAbstractSqlModelFromFile = async (modelFile, modelName) => {
|
|
102
133
|
}
|
103
134
|
return generateAbstractSqlModel(lfModel);
|
104
135
|
};
|
136
|
+
exports.getAbstractSqlModelFromFile = getAbstractSqlModelFromFile;
|
105
137
|
//# sourceMappingURL=utils.js.map
|
package/out/bin/utils.js.map
CHANGED
@@ -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
|
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,uCAAyB;AACzB,2CAA6B;AAC7B,sCAAoC;AAEpC,4CAA+C;AAAtC,8FAAA,OAAO,OAAA;AAET,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,UAAmB,EAAQ,EAAE;IACrE,IAAI,UAAU,EAAE,CAAC;QAChB,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CA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