@malloydata/malloy 0.0.377 → 0.0.378
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.
|
@@ -121,10 +121,18 @@ function compileConnectionProperty(path, propDef, value, log) {
|
|
|
121
121
|
}
|
|
122
122
|
const ref = asReferenceShape(value);
|
|
123
123
|
if (ref !== undefined) {
|
|
124
|
+
if (propDef.requireLiteralString) {
|
|
125
|
+
log.push(makeWarning(path, 'must be a literal string and cannot use an overlay reference'));
|
|
126
|
+
return { kind: 'value', value };
|
|
127
|
+
}
|
|
124
128
|
return ref;
|
|
125
129
|
}
|
|
126
130
|
const typeError = checkValueType(value, propDef.type);
|
|
127
131
|
if (typeError) {
|
|
132
|
+
if (propDef.requireLiteralString) {
|
|
133
|
+
log.push(makeWarning(path, `must be a literal string, got ${describeConfigValue(value)}`));
|
|
134
|
+
return { kind: 'value', value };
|
|
135
|
+
}
|
|
128
136
|
log.push(makeWarning(path, `${typeError} (expected ${propDef.type})`));
|
|
129
137
|
return undefined;
|
|
130
138
|
}
|
|
@@ -190,6 +198,11 @@ function makeWarning(path, message) {
|
|
|
190
198
|
code: 'config-validation',
|
|
191
199
|
};
|
|
192
200
|
}
|
|
201
|
+
function describeConfigValue(value) {
|
|
202
|
+
if (Array.isArray(value))
|
|
203
|
+
return 'array';
|
|
204
|
+
return typeof value;
|
|
205
|
+
}
|
|
193
206
|
function checkValueType(value, expectedType) {
|
|
194
207
|
switch (expectedType) {
|
|
195
208
|
case 'number':
|
|
@@ -71,6 +71,7 @@ function buildManagedLookup(compiledConnections, overlays, log) {
|
|
|
71
71
|
connConfig[key] = value;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
(0, registry_1.validateConnectionConfigProperties)(connectionName, resolved.is, connConfig);
|
|
74
75
|
const connection = await typeDef.factory(connConfig);
|
|
75
76
|
cache.set(connectionName, connection);
|
|
76
77
|
return connection;
|
|
@@ -28,6 +28,13 @@ export interface ConnectionPropertyDefinition {
|
|
|
28
28
|
description?: string;
|
|
29
29
|
/** For type 'file': extension filters for picker dialogs. */
|
|
30
30
|
fileFilters?: Record<string, string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* For security-sensitive string slots, preserve malformed/reference-shaped
|
|
33
|
+
* raw values so registry lookup can fail closed instead of silently dropping
|
|
34
|
+
* the property during generic compilation. Factories must not rely on this
|
|
35
|
+
* metadata as their only validation layer.
|
|
36
|
+
*/
|
|
37
|
+
requireLiteralString?: true;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
40
|
* A connection type definition: factory plus property metadata.
|
|
@@ -93,6 +100,11 @@ export declare function getRegisteredConnectionTypes(): string[];
|
|
|
93
100
|
* lookup to hand fully-resolved configs to the right factory.
|
|
94
101
|
*/
|
|
95
102
|
export declare function getConnectionTypeDef(typeName: string): ConnectionTypeDef | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Enforce registry-level literal-string requirements after overlay resolution
|
|
105
|
+
* and before a connection factory sees the config.
|
|
106
|
+
*/
|
|
107
|
+
export declare function validateConnectionConfigProperties(connectionName: string, typeName: string, config: ConnectionConfig): void;
|
|
96
108
|
/**
|
|
97
109
|
* Parse a JSON config string into a ConnectionsConfig.
|
|
98
110
|
* Entries without a valid `is` field are silently dropped.
|
|
@@ -10,6 +10,7 @@ exports.getConnectionProperties = getConnectionProperties;
|
|
|
10
10
|
exports.getConnectionTypeDisplayName = getConnectionTypeDisplayName;
|
|
11
11
|
exports.getRegisteredConnectionTypes = getRegisteredConnectionTypes;
|
|
12
12
|
exports.getConnectionTypeDef = getConnectionTypeDef;
|
|
13
|
+
exports.validateConnectionConfigProperties = validateConnectionConfigProperties;
|
|
13
14
|
exports.readConnectionsConfig = readConnectionsConfig;
|
|
14
15
|
exports.writeConnectionsConfig = writeConnectionsConfig;
|
|
15
16
|
exports.createConnectionsFromConfig = createConnectionsFromConfig;
|
|
@@ -66,6 +67,22 @@ function getRegisteredConnectionTypes() {
|
|
|
66
67
|
function getConnectionTypeDef(typeName) {
|
|
67
68
|
return registry.get(typeName);
|
|
68
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Enforce registry-level literal-string requirements after overlay resolution
|
|
72
|
+
* and before a connection factory sees the config.
|
|
73
|
+
*/
|
|
74
|
+
function validateConnectionConfigProperties(connectionName, typeName, config) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const props = (_b = (_a = registry.get(typeName)) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : [];
|
|
77
|
+
for (const prop of props) {
|
|
78
|
+
if (!prop.requireLiteralString)
|
|
79
|
+
continue;
|
|
80
|
+
const value = config[prop.name];
|
|
81
|
+
if (value !== undefined && typeof value !== 'string') {
|
|
82
|
+
throw new Error(`Connection "${connectionName}" property "${prop.name}" must be a literal string`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
69
86
|
/**
|
|
70
87
|
* Parse a JSON config string into a ConnectionsConfig.
|
|
71
88
|
* Entries without a valid `is` field are silently dropped.
|
|
@@ -127,6 +144,7 @@ function createConnectionsFromConfig(config, onConnectionCreated) {
|
|
|
127
144
|
connConfig[key] = value;
|
|
128
145
|
}
|
|
129
146
|
}
|
|
147
|
+
validateConnectionConfigProperties(connectionName, entry.is, connConfig);
|
|
130
148
|
const connection = await typeDef.factory(connConfig);
|
|
131
149
|
if (onConnectionCreated) {
|
|
132
150
|
onConnectionCreated(connectionName, connection);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.378";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.378';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.378",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@malloydata/malloy-filter": "0.0.
|
|
55
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
56
|
-
"@malloydata/malloy-tag": "0.0.
|
|
54
|
+
"@malloydata/malloy-filter": "0.0.378",
|
|
55
|
+
"@malloydata/malloy-interfaces": "0.0.378",
|
|
56
|
+
"@malloydata/malloy-tag": "0.0.378",
|
|
57
57
|
"@noble/hashes": "^1.8.0",
|
|
58
58
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
59
59
|
"assert": "^2.0.0",
|