@malloydata/malloy 0.0.342 → 0.0.343

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.
@@ -65,6 +65,10 @@ export declare class Malloy {
65
65
  * Get the property definitions for a registered connection type.
66
66
  */
67
67
  static getConnectionProperties(typeName: string): ConnectionPropertyDefinition[] | undefined;
68
+ /**
69
+ * Get the human-readable display name for a registered connection type.
70
+ */
71
+ static getConnectionTypeDisplayName(typeName: string): string | undefined;
68
72
  /**
69
73
  * Get the names of all registered connection types.
70
74
  */
@@ -57,6 +57,12 @@ class Malloy {
57
57
  static getConnectionProperties(typeName) {
58
58
  return (0, registry_1.getConnectionProperties)(typeName);
59
59
  }
60
+ /**
61
+ * Get the human-readable display name for a registered connection type.
62
+ */
63
+ static getConnectionTypeDisplayName(typeName) {
64
+ return (0, registry_1.getConnectionTypeDisplayName)(typeName);
65
+ }
60
66
  /**
61
67
  * Get the names of all registered connection types.
62
68
  */
@@ -2,7 +2,7 @@ import type { Connection, ConnectionConfig, LookupConnection } from './types';
2
2
  /**
3
3
  * A factory function that creates a Connection from a config object.
4
4
  */
5
- export type ConnectionTypeFactory = (config: ConnectionConfig) => Connection;
5
+ export type ConnectionTypeFactory = (config: ConnectionConfig) => Promise<Connection>;
6
6
  /**
7
7
  * The type of a connection property value.
8
8
  */
@@ -24,27 +24,35 @@ export interface ConnectionPropertyDefinition {
24
24
  * A connection type definition: factory plus property metadata.
25
25
  */
26
26
  export interface ConnectionTypeDef {
27
+ displayName: string;
27
28
  factory: ConnectionTypeFactory;
28
29
  properties: ConnectionPropertyDefinition[];
29
30
  }
30
31
  /**
31
- * A sensitive value in a config file. Either a plain string (already resolved)
32
- * or an environment variable reference.
32
+ * An environment variable reference in a config file.
33
33
  */
34
- export type SecretValue = string | {
34
+ export type ValueRef = {
35
35
  env: string;
36
36
  };
37
37
  /**
38
- * Resolve a sensitive value. Plain strings pass through, {env: "X"} looks up
39
- * process.env["X"], anything else returns undefined.
38
+ * The type of a config property value: a literal, an env reference, or undefined.
39
+ */
40
+ export type ConfigValue = string | number | boolean | ValueRef | undefined;
41
+ /**
42
+ * Type guard for ValueRef.
43
+ */
44
+ export declare function isValueRef(value: ConfigValue): value is ValueRef;
45
+ /**
46
+ * Resolve a ValueRef to a string by looking up the environment variable.
47
+ * Returns undefined if the env var is not set.
40
48
  */
41
- export declare function resolveSecret(value: unknown): string | undefined;
49
+ export declare function resolveValue(vr: ValueRef): string | undefined;
42
50
  /**
43
51
  * A single connection entry in a JSON config.
44
52
  */
45
53
  export interface ConnectionConfigEntry {
46
54
  is: string;
47
- [key: string]: string | number | boolean | SecretValue | undefined;
55
+ [key: string]: ConfigValue;
48
56
  }
49
57
  /**
50
58
  * The editable intermediate representation of a connections config file.
@@ -66,6 +74,13 @@ export declare function registerConnectionType(typeName: string, def: Connection
66
74
  * @returns The property definitions, or undefined if the type is not registered.
67
75
  */
68
76
  export declare function getConnectionProperties(typeName: string): ConnectionPropertyDefinition[] | undefined;
77
+ /**
78
+ * Get the display name for a registered connection type.
79
+ *
80
+ * @param typeName The connection type name.
81
+ * @returns The human-readable display name, or undefined if the type is not registered.
82
+ */
83
+ export declare function getConnectionTypeDisplayName(typeName: string): string | undefined;
69
84
  /**
70
85
  * Get the names of all registered connection types.
71
86
  */
@@ -4,26 +4,27 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.resolveSecret = resolveSecret;
7
+ exports.isValueRef = isValueRef;
8
+ exports.resolveValue = resolveValue;
8
9
  exports.registerConnectionType = registerConnectionType;
9
10
  exports.getConnectionProperties = getConnectionProperties;
11
+ exports.getConnectionTypeDisplayName = getConnectionTypeDisplayName;
10
12
  exports.getRegisteredConnectionTypes = getRegisteredConnectionTypes;
11
13
  exports.readConnectionsConfig = readConnectionsConfig;
12
14
  exports.writeConnectionsConfig = writeConnectionsConfig;
13
15
  exports.createConnectionsFromConfig = createConnectionsFromConfig;
14
16
  /**
15
- * Resolve a sensitive value. Plain strings pass through, {env: "X"} looks up
16
- * process.env["X"], anything else returns undefined.
17
+ * Type guard for ValueRef.
17
18
  */
18
- function resolveSecret(value) {
19
- if (typeof value === 'string')
20
- return value;
21
- if (value !== null && typeof value === 'object' && 'env' in value) {
22
- const envName = value.env;
23
- if (typeof envName === 'string')
24
- return process.env[envName];
25
- }
26
- return undefined;
19
+ function isValueRef(value) {
20
+ return typeof value === 'object' && value !== null && 'env' in value;
21
+ }
22
+ /**
23
+ * Resolve a ValueRef to a string by looking up the environment variable.
24
+ * Returns undefined if the env var is not set.
25
+ */
26
+ function resolveValue(vr) {
27
+ return process.env[vr.env];
27
28
  }
28
29
  // Module-level registry
29
30
  const registry = new Map();
@@ -46,6 +47,16 @@ function getConnectionProperties(typeName) {
46
47
  var _a;
47
48
  return (_a = registry.get(typeName)) === null || _a === void 0 ? void 0 : _a.properties;
48
49
  }
50
+ /**
51
+ * Get the display name for a registered connection type.
52
+ *
53
+ * @param typeName The connection type name.
54
+ * @returns The human-readable display name, or undefined if the type is not registered.
55
+ */
56
+ function getConnectionTypeDisplayName(typeName) {
57
+ var _a;
58
+ return (_a = registry.get(typeName)) === null || _a === void 0 ? void 0 : _a.displayName;
59
+ }
49
60
  /**
50
61
  * Get the names of all registered connection types.
51
62
  */
@@ -104,26 +115,23 @@ function createConnectionsFromConfig(config) {
104
115
  throw new Error(`No registered connection type "${entry.is}" for connection "${connectionName}". ` +
105
116
  'Did you forget to import the connection package?');
106
117
  }
107
- const sensitiveProps = new Set(typeDef.properties
108
- .filter(p => p.type === 'password' || p.type === 'secret')
109
- .map(p => p.name));
110
118
  const connConfig = { name: connectionName };
111
119
  for (const [key, value] of Object.entries(entry)) {
112
120
  if (key === 'is')
113
121
  continue;
114
122
  if (value !== undefined) {
115
- if (sensitiveProps.has(key)) {
116
- const resolved = resolveSecret(value);
123
+ if (isValueRef(value)) {
124
+ const resolved = resolveValue(value);
117
125
  if (resolved !== undefined) {
118
126
  connConfig[key] = resolved;
119
127
  }
120
128
  }
121
- else if (typeof value !== 'object') {
129
+ else {
122
130
  connConfig[key] = value;
123
131
  }
124
132
  }
125
133
  }
126
- const connection = typeDef.factory(connConfig);
134
+ const connection = await typeDef.factory(connConfig);
127
135
  cache.set(connectionName, connection);
128
136
  return connection;
129
137
  },
package/dist/index.d.ts CHANGED
@@ -9,8 +9,8 @@ export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, Sorta
9
9
  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
- export { registerConnectionType, getConnectionProperties, getRegisteredConnectionTypes, readConnectionsConfig, writeConnectionsConfig, createConnectionsFromConfig, resolveSecret, } from './connection/registry';
13
- export type { ConnectionTypeFactory, ConnectionPropertyType, ConnectionPropertyDefinition, ConnectionTypeDef, ConnectionConfigEntry, ConnectionsConfig, SecretValue, } from './connection/registry';
12
+ export { registerConnectionType, getConnectionProperties, getConnectionTypeDisplayName, getRegisteredConnectionTypes, readConnectionsConfig, writeConnectionsConfig, createConnectionsFromConfig, isValueRef, resolveValue, } from './connection/registry';
13
+ export type { ConnectionTypeFactory, ConnectionPropertyType, ConnectionPropertyDefinition, ConnectionTypeDef, ConnectionConfigEntry, ConnectionsConfig, ConfigValue, 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/index.js CHANGED
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Runtime = exports.Malloy = exports.Model = exports.MalloyTranslator = exports.malloyToQuery = exports.constantExprToSQL = exports.isDateUnit = exports.isTimestampUnit = exports.composeSQLExpr = exports.indent = exports.expressionIsUngroupedAggregate = exports.expressionIsScalar = exports.expressionIsCalculation = exports.expressionIsAnalytic = exports.expressionIsAggregate = exports.mkFieldDef = exports.mkArrayDef = exports.isBasicArray = exports.isRepeatedRecord = exports.isSamplingRows = exports.isSamplingPercent = exports.isSamplingEnable = exports.isJoinedSource = exports.isJoined = exports.isCompoundArrayData = exports.isBasicAtomic = exports.isAtomic = exports.isSourceDef = exports.TinyParser = exports.Dialect = exports.spread = exports.literal = exports.variadicParam = exports.param = exports.makeParam = exports.sql = exports.maxScalar = exports.minAggregate = exports.anyExprType = exports.minScalar = exports.overload = exports.qtz = exports.arg = exports.registerDialect = exports.MySQLDialect = exports.SnowflakeDialect = exports.PostgresDialect = exports.TrinoDialect = exports.StandardSQLDialect = exports.DuckDBDialect = void 0;
37
- exports.makeDigest = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.resolveSecret = exports.createConnectionsFromConfig = exports.writeConnectionsConfig = exports.readConnectionsConfig = exports.getRegisteredConnectionTypes = exports.getConnectionProperties = exports.registerConnectionType = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = void 0;
37
+ exports.makeDigest = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.resolveValue = exports.isValueRef = exports.createConnectionsFromConfig = exports.writeConnectionsConfig = exports.readConnectionsConfig = exports.getRegisteredConnectionTypes = exports.getConnectionTypeDisplayName = exports.getConnectionProperties = exports.registerConnectionType = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = void 0;
38
38
  /*
39
39
  * Copyright 2023 Google LLC
40
40
  *
@@ -138,11 +138,13 @@ Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function
138
138
  var registry_1 = require("./connection/registry");
139
139
  Object.defineProperty(exports, "registerConnectionType", { enumerable: true, get: function () { return registry_1.registerConnectionType; } });
140
140
  Object.defineProperty(exports, "getConnectionProperties", { enumerable: true, get: function () { return registry_1.getConnectionProperties; } });
141
+ Object.defineProperty(exports, "getConnectionTypeDisplayName", { enumerable: true, get: function () { return registry_1.getConnectionTypeDisplayName; } });
141
142
  Object.defineProperty(exports, "getRegisteredConnectionTypes", { enumerable: true, get: function () { return registry_1.getRegisteredConnectionTypes; } });
142
143
  Object.defineProperty(exports, "readConnectionsConfig", { enumerable: true, get: function () { return registry_1.readConnectionsConfig; } });
143
144
  Object.defineProperty(exports, "writeConnectionsConfig", { enumerable: true, get: function () { return registry_1.writeConnectionsConfig; } });
144
145
  Object.defineProperty(exports, "createConnectionsFromConfig", { enumerable: true, get: function () { return registry_1.createConnectionsFromConfig; } });
145
- Object.defineProperty(exports, "resolveSecret", { enumerable: true, get: function () { return registry_1.resolveSecret; } });
146
+ Object.defineProperty(exports, "isValueRef", { enumerable: true, get: function () { return registry_1.isValueRef; } });
147
+ Object.defineProperty(exports, "resolveValue", { enumerable: true, get: function () { return registry_1.resolveValue; } });
146
148
  var connection_utils_1 = require("./connection_utils");
147
149
  Object.defineProperty(exports, "toAsyncGenerator", { enumerable: true, get: function () { return connection_utils_1.toAsyncGenerator; } });
148
150
  var to_stable_1 = require("./to_stable");
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.342";
1
+ export declare const MALLOY_VERSION = "0.0.343";
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.342';
5
+ exports.MALLOY_VERSION = '0.0.343';
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.342",
3
+ "version": "0.0.343",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -45,9 +45,9 @@
45
45
  "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"
46
46
  },
47
47
  "dependencies": {
48
- "@malloydata/malloy-filter": "0.0.342",
49
- "@malloydata/malloy-interfaces": "0.0.342",
50
- "@malloydata/malloy-tag": "0.0.342",
48
+ "@malloydata/malloy-filter": "0.0.343",
49
+ "@malloydata/malloy-interfaces": "0.0.343",
50
+ "@malloydata/malloy-tag": "0.0.343",
51
51
  "@noble/hashes": "^1.8.0",
52
52
  "antlr4ts": "^0.5.0-alpha.4",
53
53
  "assert": "^2.0.0",