@malloydata/malloy 0.0.359 → 0.0.360

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.
@@ -6,7 +6,7 @@ export type ConnectionTypeFactory = (config: ConnectionConfig) => Promise<Connec
6
6
  /**
7
7
  * The type of a connection property value.
8
8
  */
9
- export type ConnectionPropertyType = 'string' | 'number' | 'boolean' | 'password' | 'secret' | 'file' | 'text';
9
+ export type ConnectionPropertyType = 'string' | 'number' | 'boolean' | 'password' | 'secret' | 'file' | 'json' | 'text';
10
10
  /**
11
11
  * Describes a single configuration property for a connection type.
12
12
  */
@@ -35,9 +35,16 @@ export type ValueRef = {
35
35
  env: string;
36
36
  };
37
37
  /**
38
- * The type of a config property value: a literal, an env reference, or undefined.
38
+ * A JSON-compatible value for structured config properties (e.g. SSL options).
39
39
  */
40
- export type ConfigValue = string | number | boolean | ValueRef | undefined;
40
+ export type JsonConfigValue = string | number | boolean | null | JsonConfigValue[] | {
41
+ [key: string]: JsonConfigValue;
42
+ };
43
+ /**
44
+ * The type of a config property value: a literal, an env reference, a JSON
45
+ * object, or undefined.
46
+ */
47
+ export type ConfigValue = string | number | boolean | ValueRef | JsonConfigValue | undefined;
41
48
  /**
42
49
  * Type guard for ValueRef.
43
50
  */
@@ -18,7 +18,11 @@ exports.createConnectionsFromConfig = createConnectionsFromConfig;
18
18
  * Type guard for ValueRef.
19
19
  */
20
20
  function isValueRef(value) {
21
- return typeof value === 'object' && value !== null && 'env' in value;
21
+ return (typeof value === 'object' &&
22
+ value !== null &&
23
+ !Array.isArray(value) &&
24
+ Object.keys(value).length === 1 &&
25
+ 'env' in value);
22
26
  }
23
27
  /**
24
28
  * Resolve a ValueRef to a string by looking up the environment variable.
@@ -115,12 +119,13 @@ function createConnectionsFromConfig(config) {
115
119
  throw new Error(`No registered connection type "${entry.is}" for connection "${connectionName}". ` +
116
120
  'Did you forget to import the connection package?');
117
121
  }
122
+ const jsonKeys = new Set(typeDef.properties.filter(p => p.type === 'json').map(p => p.name));
118
123
  const connConfig = { name: connectionName };
119
124
  for (const [key, value] of Object.entries(entry)) {
120
125
  if (key === 'is')
121
126
  continue;
122
- if (value !== undefined) {
123
- if (isValueRef(value)) {
127
+ if (value !== undefined && value !== null) {
128
+ if (!jsonKeys.has(key) && isValueRef(value)) {
124
129
  const resolved = resolveValue(value);
125
130
  if (resolved !== undefined) {
126
131
  connConfig[key] = resolved;
@@ -47,7 +47,9 @@ export interface InfoConnection {
47
47
  */
48
48
  getDigest(): string;
49
49
  }
50
- export type ConnectionParameterValue = string | number | boolean | Array<ConnectionParameterValue>;
50
+ export type ConnectionParameterValue = string | number | boolean | null | Array<ConnectionParameterValue> | {
51
+ [key: string]: ConnectionParameterValue;
52
+ };
51
53
  export interface ConnectionConfig {
52
54
  name: string;
53
55
  [key: string]: ConnectionParameterValue | undefined;
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export type { QueryOptionsReader, RunSQLOptions } from './run_sql_options';
10
10
  export type { EventStream, ModelString, ModelURL, QueryString, QueryURL, URLReader, InvalidationKey, } from './runtime_types';
11
11
  export type { Connection, ConnectionConfig, ConnectionParameterValue, FetchSchemaOptions, InfoConnection, LookupConnection, PersistSQLResults, PooledConnection, TestableConnection, StreamingConnection, } from './connection/types';
12
12
  export { registerConnectionType, getConnectionProperties, getConnectionTypeDisplayName, getRegisteredConnectionTypes, isValueRef, resolveValue, } from './connection/registry';
13
- export type { ConnectionTypeFactory, ConnectionPropertyType, ConnectionPropertyDefinition, ConnectionTypeDef, ConnectionConfigEntry, ConnectionsConfig, ConfigValue, ValueRef, } from './connection/registry';
13
+ export type { ConnectionTypeFactory, ConnectionPropertyType, ConnectionPropertyDefinition, ConnectionTypeDef, ConnectionConfigEntry, ConnectionsConfig, ConfigValue, JsonConfigValue, ValueRef, } from './connection/registry';
14
14
  export { toAsyncGenerator } from './connection_utils';
15
15
  export { modelDefToModelInfo, sourceDefToSourceInfo } from './to_stable';
16
16
  export * as API from './api';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.359";
1
+ export declare const MALLOY_VERSION = "0.0.360";
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.359';
5
+ exports.MALLOY_VERSION = '0.0.360';
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.359",
3
+ "version": "0.0.360",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -47,9 +47,9 @@
47
47
  "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"
48
48
  },
49
49
  "dependencies": {
50
- "@malloydata/malloy-filter": "0.0.359",
51
- "@malloydata/malloy-interfaces": "0.0.359",
52
- "@malloydata/malloy-tag": "0.0.359",
50
+ "@malloydata/malloy-filter": "0.0.360",
51
+ "@malloydata/malloy-interfaces": "0.0.360",
52
+ "@malloydata/malloy-tag": "0.0.360",
53
53
  "@noble/hashes": "^1.8.0",
54
54
  "antlr4ts": "^0.5.0-alpha.4",
55
55
  "assert": "^2.0.0",