@dxos/config 0.8.3 → 0.8.4-main.28f8d3d

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.
Files changed (44) hide show
  1. package/dist/lib/browser/index.mjs +6 -5
  2. package/dist/lib/browser/index.mjs.map +2 -2
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +29 -18
  5. package/dist/lib/node-esm/index.mjs.map +3 -3
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/plugin/node-esm/{chunk-PAFU3TJI.mjs → chunk-C4YHC2RN.mjs} +23 -12
  8. package/dist/plugin/node-esm/chunk-C4YHC2RN.mjs.map +7 -0
  9. package/dist/plugin/node-esm/esbuild-plugin.mjs +2 -2
  10. package/dist/plugin/node-esm/meta.json +1 -1
  11. package/dist/plugin/node-esm/rollup-plugin.mjs +2 -2
  12. package/dist/plugin/node-esm/vite-plugin.mjs +6 -6
  13. package/dist/plugin/node-esm/vite-plugin.mjs.map +3 -3
  14. package/dist/types/src/loaders/index.d.ts.map +1 -1
  15. package/dist/types/src/plugin/definitions.d.ts +3 -3
  16. package/dist/types/src/plugin/definitions.d.ts.map +1 -1
  17. package/dist/types/src/plugin/index.d.ts +1 -1
  18. package/dist/types/src/plugin/index.d.ts.map +1 -1
  19. package/dist/types/src/plugin/types.d.ts +4 -0
  20. package/dist/types/src/plugin/types.d.ts.map +1 -1
  21. package/dist/types/src/plugin/vite-plugin.d.ts +1 -1
  22. package/dist/types/src/plugin/vite-plugin.d.ts.map +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +11 -6
  25. package/src/loaders/index.ts +2 -1
  26. package/src/plugin/definitions.ts +7 -5
  27. package/src/plugin/index.ts +1 -1
  28. package/src/plugin/types.ts +5 -0
  29. package/src/plugin/vite-plugin.ts +9 -5
  30. package/src/testing/build.js +1 -1
  31. package/README.yml +0 -1
  32. package/dist/lib/node/index.cjs +0 -357
  33. package/dist/lib/node/index.cjs.map +0 -7
  34. package/dist/lib/node/meta.json +0 -1
  35. package/dist/plugin/node/chunk-SLXRWZWZ.cjs +0 -249
  36. package/dist/plugin/node/chunk-SLXRWZWZ.cjs.map +0 -7
  37. package/dist/plugin/node/esbuild-plugin.cjs +0 -45
  38. package/dist/plugin/node/esbuild-plugin.cjs.map +0 -7
  39. package/dist/plugin/node/meta.json +0 -1
  40. package/dist/plugin/node/rollup-plugin.cjs +0 -39
  41. package/dist/plugin/node/rollup-plugin.cjs.map +0 -7
  42. package/dist/plugin/node/vite-plugin.cjs +0 -50
  43. package/dist/plugin/node/vite-plugin.cjs.map +0 -7
  44. package/dist/plugin/node-esm/chunk-PAFU3TJI.mjs.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/config",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.28f8d3d",
4
4
  "description": "Config utilities",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -10,6 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
15
  "browser": "./dist/lib/browser/index.mjs",
15
16
  "node": {
@@ -18,16 +19,19 @@
18
19
  }
19
20
  },
20
21
  "./esbuild-plugin": {
22
+ "source": "./src/esbuild-plugin/index.ts",
21
23
  "types": "./dist/types/src/esbuild-plugin/index.d.ts",
22
24
  "import": "./dist/plugin/node-esm/esbuild-plugin.mjs",
23
25
  "require": "./dist/plugin/node/esbuild-plugin.cjs"
24
26
  },
25
27
  "./rollup-plugin": {
28
+ "source": "./src/rollup-plugin/index.ts",
26
29
  "types": "./dist/types/src/rollup-plugin/index.d.ts",
27
30
  "import": "./dist/plugin/node-esm/rollup-plugin.mjs",
28
31
  "require": "./dist/plugin/node/rollup-plugin.cjs"
29
32
  },
30
33
  "./vite-plugin": {
34
+ "source": "./src/vite-plugin/index.ts",
31
35
  "types": "./dist/types/src/vite-plugin/index.d.ts",
32
36
  "import": "./dist/plugin/node-esm/vite-plugin.mjs",
33
37
  "require": "./dist/plugin/node/vite-plugin.cjs"
@@ -65,11 +69,12 @@
65
69
  "lodash.defaultsdeep": "^4.6.1",
66
70
  "lodash.ismatch": "^4.4.0",
67
71
  "pkg-up": "^3.1.0",
68
- "@dxos/log": "0.8.3",
69
- "@dxos/node-std": "0.8.3",
70
- "@dxos/protocols": "0.8.3",
71
- "@dxos/util": "0.8.3",
72
- "@dxos/tracing": "0.8.3"
72
+ "@dxos/invariant": "0.8.4-main.28f8d3d",
73
+ "@dxos/log": "0.8.4-main.28f8d3d",
74
+ "@dxos/node-std": "0.8.4-main.28f8d3d",
75
+ "@dxos/tracing": "0.8.4-main.28f8d3d",
76
+ "@dxos/util": "0.8.4-main.28f8d3d",
77
+ "@dxos/protocols": "0.8.4-main.28f8d3d"
73
78
  },
74
79
  "devDependencies": {
75
80
  "@types/js-yaml": "^4.0.5",
@@ -2,10 +2,11 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import yaml from 'js-yaml';
6
5
  import fs from 'node:fs';
7
6
  import path from 'node:path';
8
7
 
8
+ import yaml from 'js-yaml';
9
+
9
10
  import { log } from '@dxos/log';
10
11
  import { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';
11
12
 
@@ -2,18 +2,21 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import yaml from 'js-yaml';
6
5
  import { execSync } from 'node:child_process';
7
6
  import { readFileSync } from 'node:fs';
8
7
  import { resolve } from 'node:path';
8
+
9
+ import yaml from 'js-yaml';
9
10
  import pkgUp from 'pkg-up';
10
11
 
12
+ import { invariant } from '@dxos/invariant';
11
13
  import { log } from '@dxos/log';
12
14
  import { setDeep } from '@dxos/util';
13
15
 
14
- import { type ConfigPluginOpts } from './types';
15
16
  import { mapFromKeyValues } from '../config';
16
17
 
18
+ import { type ConfigPluginOpts } from './types';
19
+
17
20
  const CWD = process.cwd();
18
21
 
19
22
  export const definitions = ({
@@ -28,15 +31,14 @@ export const definitions = ({
28
31
  __CONFIG_DEFAULTS__: configPath?.length ? configPath : resolve(CWD, 'dx.yml'),
29
32
  __CONFIG_ENVS__: envPath?.length ? envPath : resolve(CWD, 'dx-env.yml'),
30
33
  } as { [key: string]: string };
31
-
32
34
  if (mode !== 'production') {
33
35
  KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? resolve(CWD, 'dx-local.yml');
34
36
  }
35
37
 
36
38
  return Object.entries(KEYS_TO_FILE).reduce(
37
39
  (prev, [key, value]) => {
40
+ invariant(key);
38
41
  let content = {};
39
-
40
42
  try {
41
43
  content = yaml.load(readFileSync(value, 'utf-8')) as any;
42
44
 
@@ -85,10 +87,10 @@ export const definitions = ({
85
87
  };
86
88
  },
87
89
  {
88
- __DXOS_CONFIG__: { dynamic: mode === 'production', publicUrl },
89
90
  __CONFIG_DEFAULTS__: {},
90
91
  __CONFIG_ENVS__: {},
91
92
  __CONFIG_LOCAL__: {},
93
+ __DXOS_CONFIG__: { dynamic: mode === 'production', publicUrl },
92
94
  },
93
95
  );
94
96
  };
@@ -3,4 +3,4 @@
3
3
  //
4
4
 
5
5
  export * from './definitions';
6
- export * from './types';
6
+ export type * from './types';
@@ -3,6 +3,11 @@
3
3
  //
4
4
 
5
5
  export interface ConfigPluginOpts {
6
+ /**
7
+ * Root directory of the project.
8
+ */
9
+ root?: string;
10
+
6
11
  /**
7
12
  * Path to the DX config files, defaults to current working directory.
8
13
  */
@@ -3,17 +3,21 @@
3
3
  //
4
4
 
5
5
  import { resolve } from 'node:path';
6
- import type { Plugin } from 'vite';
6
+
7
+ import { type Plugin } from 'vite';
7
8
 
8
9
  import { definitions } from './definitions';
9
10
  import { type ConfigPluginOpts } from './types';
10
11
 
11
12
  export const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => ({
12
13
  name: 'dxos-config',
13
- config: ({ root }) => {
14
- const configPath = root && resolve(root, options.configPath ?? 'dx.yml');
15
- const envPath = root && resolve(root, options.envPath ?? 'dx-env.yml');
16
- const devPath = root && resolve(root, options.devPath ?? 'dx-local.yml');
14
+ config: () => {
15
+ // Update paths.
16
+ const configPath = options.root && resolve(options.root, options.configPath ?? 'dx.yml');
17
+ const envPath = options.root && resolve(options.root, options.envPath ?? 'dx-env.yml');
18
+ // TODO(burdon): Change to dx-dev.yml?
19
+ const devPath = options.root && resolve(options.root, options.devPath ?? 'dx-local.yml');
20
+
17
21
  const define = Object.entries(definitions({ ...options, configPath, envPath, devPath })).reduce(
18
22
  (define, [key, value]) => {
19
23
  define[key] = JSON.stringify(value);
@@ -17,5 +17,5 @@ void build({
17
17
  outdir: join(__dirname, '../../out'),
18
18
  write: true,
19
19
  bundle: true,
20
- plugins: [ConfigPlugin()],
20
+ plugins: [ConfigPlugin({ root: __dirname })],
21
21
  });
package/README.yml DELETED
@@ -1 +0,0 @@
1
- apiReferenceUrl: https://docs.dxos.org/api/@dxos/config
@@ -1,357 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var node_exports = {};
30
- __export(node_exports, {
31
- Config: () => Config,
32
- ConfigResource: () => ConfigResource,
33
- Defaults: () => Defaults,
34
- Dynamics: () => Dynamics,
35
- Envs: () => Envs,
36
- FILE_DEFAULTS: () => FILE_DEFAULTS,
37
- FILE_DYNAMICS: () => FILE_DYNAMICS,
38
- FILE_ENVS: () => FILE_ENVS,
39
- Local: () => Local,
40
- Profile: () => Profile,
41
- Remote: () => Remote,
42
- SaveConfig: () => SaveConfig,
43
- Storage: () => Storage,
44
- definitions: () => definitions,
45
- defs: () => defs,
46
- mapFromKeyValues: () => mapFromKeyValues,
47
- mapToKeyValues: () => mapToKeyValues,
48
- validateConfig: () => validateConfig
49
- });
50
- module.exports = __toCommonJS(node_exports);
51
- var defs = __toESM(require("@dxos/protocols/proto/dxos/config"));
52
- var import_boolean = require("boolean");
53
- var import_lodash = __toESM(require("lodash.defaultsdeep"));
54
- var import_lodash2 = __toESM(require("lodash.ismatch"));
55
- var import_protocols = require("@dxos/protocols");
56
- var import_proto = require("@dxos/protocols/proto");
57
- var import_tracing = require("@dxos/tracing");
58
- var import_util = require("@dxos/util");
59
- var import_js_yaml = __toESM(require("js-yaml"));
60
- var import_node_fs = __toESM(require("node:fs"));
61
- var import_node_path = __toESM(require("node:path"));
62
- var import_log = require("@dxos/log");
63
- var import_js_yaml2 = __toESM(require("js-yaml"));
64
- var import_node_child_process = require("node:child_process");
65
- var import_node_fs2 = require("node:fs");
66
- var import_node_path2 = require("node:path");
67
- var import_pkg_up = __toESM(require("pkg-up"));
68
- var import_log2 = require("@dxos/log");
69
- var import_util2 = require("@dxos/util");
70
- function _ts_decorate(decorators, target, key, desc) {
71
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
72
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
73
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
74
- return c > 3 && r && Object.defineProperty(target, key, r), r;
75
- }
76
- var configRootType = import_proto.schema.getCodecForType("dxos.config.Config");
77
- var mapFromKeyValues = (spec, values) => {
78
- const config = {};
79
- for (const [key, { path: path2, type }] of Object.entries(spec)) {
80
- let value = values[key];
81
- if (value !== void 0) {
82
- if (type) {
83
- switch (type) {
84
- case "boolean": {
85
- value = (0, import_boolean.boolean)(value);
86
- break;
87
- }
88
- case "number": {
89
- value = Number(value);
90
- break;
91
- }
92
- case "string": {
93
- break;
94
- }
95
- case "json": {
96
- value = value ? JSON.parse(value) : null;
97
- break;
98
- }
99
- default: {
100
- throw new Error(`Invalid type: ${type}`);
101
- }
102
- }
103
- }
104
- (0, import_util.setDeep)(config, path2.split("."), value);
105
- }
106
- }
107
- return config;
108
- };
109
- var mapToKeyValues = (spec, values) => {
110
- const config = {};
111
- for (const [key, { path: path2, type }] of Object.entries(spec)) {
112
- const value = (0, import_util.getDeep)(values, path2.split("."));
113
- if (value !== void 0) {
114
- switch (type) {
115
- case "json":
116
- config[key] = JSON.stringify(value);
117
- break;
118
- default:
119
- config[key] = value;
120
- }
121
- }
122
- }
123
- return config;
124
- };
125
- var validateConfig = (config) => {
126
- if (!("version" in config)) {
127
- throw new import_protocols.InvalidConfigError("Version not specified");
128
- }
129
- if (config?.version !== 1) {
130
- throw new import_protocols.InvalidConfigError(`Invalid config version: ${config.version}`);
131
- }
132
- const error = configRootType.protoType.verify(config);
133
- if (error) {
134
- throw new import_protocols.InvalidConfigError(error);
135
- }
136
- return config;
137
- };
138
- var ConfigResource = Symbol.for("dxos.resource.Config");
139
- var Config = class {
140
- /**
141
- * Creates an immutable instance.
142
- * @constructor
143
- */
144
- constructor(config = {}, ...objects) {
145
- this._config = validateConfig((0, import_lodash.default)(config, ...objects, {
146
- version: 1
147
- }));
148
- }
149
- /**
150
- * Returns an immutable config JSON object.
151
- */
152
- get values() {
153
- return this._config;
154
- }
155
- /**
156
- * Returns the given config property.
157
- *
158
- * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.
159
- * @param defaultValue Default value to return if option is not present in the config.
160
- * @returns The config value or undefined if the option is not present.
161
- */
162
- get(key, defaultValue) {
163
- return (0, import_util.getDeep)(this._config, key.split(".")) ?? defaultValue;
164
- }
165
- /**
166
- * Get unique key.
167
- */
168
- find(path2, test) {
169
- const values = (0, import_util.getDeep)(this._config, path2.split("."));
170
- if (!Array.isArray(values)) {
171
- return;
172
- }
173
- return values.find((value) => (0, import_lodash2.default)(value, test));
174
- }
175
- /**
176
- * Returns the given config property or throw if it doesn't exist.
177
- *
178
- * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.
179
- */
180
- getOrThrow(key) {
181
- const value = (0, import_util.getDeep)(this._config, key.split("."));
182
- if (!value) {
183
- throw new Error(`Config option not present: ${key}`);
184
- }
185
- return value;
186
- }
187
- };
188
- Config = _ts_decorate([
189
- import_tracing.trace.resource({
190
- annotation: ConfigResource
191
- })
192
- ], Config);
193
- var FILE_DEFAULTS = "defaults.yml";
194
- var FILE_ENVS = "envs-map.yml";
195
- var FILE_DYNAMICS = "config.yml";
196
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/config/src/loaders/index.ts";
197
- var DEFAULT_BASE_PATH = import_node_path.default.resolve(process.cwd(), "config");
198
- var maybeLoadFile = (file) => {
199
- try {
200
- return import_js_yaml.default.load(import_node_fs.default.readFileSync(file, {
201
- encoding: "utf8"
202
- }));
203
- } catch (err) {
204
- }
205
- };
206
- var Profile = (profile = "default") => {
207
- const configFile = import_node_path.default.join(process.env.HOME ?? "~", `.config/dx/profile/${profile}.yml`);
208
- return maybeLoadFile(configFile);
209
- };
210
- var Local = () => ({});
211
- var Dynamics = () => ({});
212
- var Envs = (basePath = DEFAULT_BASE_PATH) => {
213
- const content = maybeLoadFile(import_node_path.default.resolve(basePath, FILE_ENVS));
214
- return content ? mapFromKeyValues(content, process.env) : {};
215
- };
216
- var Defaults = (basePath = DEFAULT_BASE_PATH) => maybeLoadFile(import_node_path.default.resolve(basePath, FILE_DEFAULTS)) ?? {};
217
- var Storage = async () => ({});
218
- var Remote = (target, authenticationToken) => {
219
- if (!target) {
220
- return {};
221
- }
222
- try {
223
- const url = new URL(target);
224
- const protocol = url.protocol.slice(0, -1);
225
- return {
226
- runtime: {
227
- client: {
228
- // TODO(burdon): Remove vault.html.
229
- remoteSource: url.origin + (protocol.startsWith("http") ? "/vault.html" : ""),
230
- remoteSourceAuthenticationToken: authenticationToken
231
- }
232
- }
233
- };
234
- } catch (err) {
235
- import_log.log.catch(err, void 0, {
236
- F: __dxlog_file,
237
- L: 87,
238
- S: void 0,
239
- C: (f, a) => f(...a)
240
- });
241
- return {};
242
- }
243
- };
244
- var SaveConfig = async (_) => {
245
- };
246
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/config/src/plugin/definitions.ts";
247
- var CWD = process.cwd();
248
- var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV, publicUrl = "", env }) => {
249
- const KEYS_TO_FILE = {
250
- __CONFIG_DEFAULTS__: configPath?.length ? configPath : (0, import_node_path2.resolve)(CWD, "dx.yml"),
251
- __CONFIG_ENVS__: envPath?.length ? envPath : (0, import_node_path2.resolve)(CWD, "dx-env.yml")
252
- };
253
- if (mode !== "production") {
254
- KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? (0, import_node_path2.resolve)(CWD, "dx-local.yml");
255
- }
256
- return Object.entries(KEYS_TO_FILE).reduce((prev, [key, value]) => {
257
- let content = {};
258
- try {
259
- content = import_js_yaml2.default.load((0, import_node_fs2.readFileSync)(value, "utf-8"));
260
- if (key === "__CONFIG_ENVS__") {
261
- content = mapFromKeyValues(content, process.env);
262
- }
263
- if (key === "__CONFIG_DEFAULTS__") {
264
- Object.entries(process.env).forEach(([key2, value2]) => {
265
- if (key2.startsWith("DX_") || env?.includes(key2)) {
266
- (0, import_util2.setDeep)(content, [
267
- "runtime",
268
- "app",
269
- "env",
270
- key2
271
- ], value2);
272
- }
273
- });
274
- try {
275
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
276
- const commitHash = process.env.DX_COMMIT_HASH ?? (0, import_node_child_process.execSync)("git rev-parse --short HEAD", {
277
- encoding: "utf-8"
278
- }).replace("\n", "");
279
- const packagePath = import_pkg_up.default.sync();
280
- const packageJson = packagePath && JSON.parse((0, import_node_fs2.readFileSync)(packagePath, "utf-8"));
281
- (0, import_util2.setDeep)(content, [
282
- "runtime",
283
- "app",
284
- "build",
285
- "timestamp"
286
- ], timestamp);
287
- (0, import_util2.setDeep)(content, [
288
- "runtime",
289
- "app",
290
- "build",
291
- "commitHash"
292
- ], commitHash);
293
- (0, import_util2.setDeep)(content, [
294
- "runtime",
295
- "app",
296
- "build",
297
- "version"
298
- ], packageJson?.version);
299
- } catch {
300
- }
301
- }
302
- } catch (err) {
303
- if (err.message.includes("YAMLException")) {
304
- import_log2.log.error(`Failed to parse file ${value}:`, err, {
305
- F: __dxlog_file2,
306
- L: 71,
307
- S: void 0,
308
- C: (f, a) => f(...a)
309
- });
310
- } else {
311
- (0, import_log2.log)(`Failed to load file ${value}:`, err, {
312
- F: __dxlog_file2,
313
- L: 73,
314
- S: void 0,
315
- C: (f, a) => f(...a)
316
- });
317
- }
318
- if (key === "__CONFIG_DEFAULTS__") {
319
- throw new Error(`Failed to load default config file from ${value}`);
320
- }
321
- }
322
- return {
323
- ...prev,
324
- [key]: content
325
- };
326
- }, {
327
- __DXOS_CONFIG__: {
328
- dynamic: mode === "production",
329
- publicUrl
330
- },
331
- __CONFIG_DEFAULTS__: {},
332
- __CONFIG_ENVS__: {},
333
- __CONFIG_LOCAL__: {}
334
- });
335
- };
336
- // Annotate the CommonJS export names for ESM import in node:
337
- 0 && (module.exports = {
338
- Config,
339
- ConfigResource,
340
- Defaults,
341
- Dynamics,
342
- Envs,
343
- FILE_DEFAULTS,
344
- FILE_DYNAMICS,
345
- FILE_ENVS,
346
- Local,
347
- Profile,
348
- Remote,
349
- SaveConfig,
350
- Storage,
351
- definitions,
352
- defs,
353
- mapFromKeyValues,
354
- mapToKeyValues,
355
- validateConfig
356
- });
357
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/config.ts", "../../../src/loaders/index.ts", "../../../src/types.ts", "../../../src/savers/index.ts", "../../../src/plugin/definitions.ts"],
4
- "sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\n// TODO(burdon): Why is this exported? (Rename).\nexport * as defs from '@dxos/protocols/proto/dxos/config';\n\nexport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nexport * from './config';\nexport * from './loaders';\nexport * from './savers';\nexport * from './plugin';\nexport * from './types';\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { boolean } from 'boolean';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport isMatch from 'lodash.ismatch';\n\nimport { InvalidConfigError } from '@dxos/protocols';\nimport { schema } from '@dxos/protocols/proto';\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\nimport { trace } from '@dxos/tracing';\nimport { getDeep, setDeep } from '@dxos/util';\n\nimport { type ConfigKey, type DeepIndex, type ParseKey } from './types';\n\ntype MappingSpec = Record<string, { path: string; type?: string }>;\nconst configRootType = schema.getCodecForType('dxos.config.Config');\n\n/**\n * Maps the given objects onto a flattened set of (key x values).\n *\n * Expects parsed yaml content of the form:\n *\n * ```\n * ENV_VAR:\n * path: config.selector.path\n * ```\n *\n * @param {object} spec\n * @param {object} values\n * @return {object}\n */\nexport const mapFromKeyValues = (spec: MappingSpec, values: Record<string, any>) => {\n const config = {};\n\n for (const [key, { path, type }] of Object.entries(spec)) {\n let value = values[key];\n\n if (value !== undefined) {\n if (type) {\n switch (type) {\n case 'boolean': {\n value = boolean(value);\n break;\n }\n\n case 'number': {\n value = Number(value);\n break;\n }\n\n case 'string': {\n break;\n }\n\n case 'json': {\n value = value ? JSON.parse(value) : null;\n break;\n }\n\n default: {\n throw new Error(`Invalid type: ${type}`);\n }\n }\n }\n\n setDeep(config, path.split('.'), value);\n }\n }\n\n return config;\n};\n\n/**\n * Maps the given flattend set of (key x values) onto a JSON object.\n * @param {object} spec\n * @param {object} values\n */\nexport const mapToKeyValues = (spec: MappingSpec, values: any) => {\n const config: Record<string, any> = {};\n\n for (const [key, { path, type }] of Object.entries(spec)) {\n const value = getDeep(values, path.split('.'));\n if (value !== undefined) {\n switch (type) {\n case 'json':\n config[key] = JSON.stringify(value);\n break;\n default:\n config[key] = value;\n }\n }\n }\n\n return config;\n};\n\n/**\n * Validate config object.\n */\nexport const validateConfig = (config: ConfigProto): ConfigProto => {\n if (!('version' in config)) {\n throw new InvalidConfigError('Version not specified');\n }\n\n if (config?.version !== 1) {\n throw new InvalidConfigError(`Invalid config version: ${config.version}`);\n }\n\n const error = configRootType.protoType.verify(config);\n if (error) {\n throw new InvalidConfigError(error);\n }\n\n return config;\n};\n\nexport const ConfigResource = Symbol.for('dxos.resource.Config');\n\n/**\n * Global configuration object.\n * NOTE: Config objects are immutable.\n */\n@trace.resource({ annotation: ConfigResource })\nexport class Config {\n private readonly _config: any;\n\n /**\n * Creates an immutable instance.\n * @constructor\n */\n constructor(config: ConfigProto = {}, ...objects: ConfigProto[]) {\n this._config = validateConfig(defaultsDeep(config, ...objects, { version: 1 }));\n }\n\n /**\n * Returns an immutable config JSON object.\n */\n get values(): ConfigProto {\n return this._config;\n }\n\n /**\n * Returns the given config property.\n *\n * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.\n * @param defaultValue Default value to return if option is not present in the config.\n * @returns The config value or undefined if the option is not present.\n */\n get<K extends ConfigKey>(\n key: K,\n defaultValue?: DeepIndex<ConfigProto, ParseKey<K>>,\n ): DeepIndex<ConfigProto, ParseKey<K>> | undefined {\n return getDeep(this._config, key.split('.')) ?? defaultValue;\n }\n\n /**\n * Get unique key.\n */\n find<T = any>(path: string, test: object): T | undefined {\n const values = getDeep(this._config, path.split('.'));\n if (!Array.isArray(values)) {\n return;\n }\n\n return values.find((value) => isMatch(value, test));\n }\n\n /**\n * Returns the given config property or throw if it doesn't exist.\n *\n * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.\n */\n getOrThrow<K extends ConfigKey>(key: K): Exclude<DeepIndex<ConfigProto, ParseKey<K>>, undefined> {\n const value: DeepIndex<ConfigProto, ParseKey<K>> | undefined = getDeep(this._config, key.split('.'));\n if (!value) {\n throw new Error(`Config option not present: ${key}`);\n }\n return value;\n }\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport yaml from 'js-yaml';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { log } from '@dxos/log';\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nimport { mapFromKeyValues } from '../config';\nimport { FILE_DEFAULTS, FILE_ENVS } from '../types';\n\n// TODO(burdon): Move code out of index file.\n\nconst DEFAULT_BASE_PATH = path.resolve(process.cwd(), 'config');\n\nconst maybeLoadFile = (file: string): any => {\n try {\n return yaml.load(fs.readFileSync(file, { encoding: 'utf8' }));\n } catch (err: any) {\n // Ignored.\n }\n};\n\n//\n// NOTE: Export LocalStorage and Dynamics for typescript to typecheck browser code (see ConfigPlugin).\n//\n\n/**\n * Profile\n */\nexport const Profile = (profile = 'default') => {\n const configFile = path.join(process.env.HOME ?? '~', `.config/dx/profile/${profile}.yml`);\n return maybeLoadFile(configFile) as ConfigProto;\n};\n\n/**\n * Development config.\n */\n// TODO(burdon): Rename or reconcile with Profile above?\nexport const Local = (): Partial<ConfigProto> => ({});\n\n/**\n * Provided dynamically by server.\n */\nexport const Dynamics = (): Partial<ConfigProto> => ({});\n\n/**\n * ENV variable (key/value) map.\n */\nexport const Envs = (basePath = DEFAULT_BASE_PATH): Partial<ConfigProto> => {\n const content = maybeLoadFile(path.resolve(basePath, FILE_ENVS));\n return content ? mapFromKeyValues(content, process.env) : {};\n};\n\n/**\n * JSON config.\n */\nexport const Defaults = (basePath = DEFAULT_BASE_PATH): Partial<ConfigProto> =>\n maybeLoadFile(path.resolve(basePath, FILE_DEFAULTS)) ?? {};\n\n/**\n * Load config from storage.\n */\nexport const Storage = async (): Promise<Partial<ConfigProto>> => ({});\n\nexport const Remote = (target: string | undefined, authenticationToken?: string): Partial<ConfigProto> => {\n if (!target) {\n return {};\n }\n\n try {\n const url = new URL(target);\n const protocol = url.protocol.slice(0, -1);\n return {\n runtime: {\n client: {\n // TODO(burdon): Remove vault.html.\n remoteSource: url.origin + (protocol.startsWith('http') ? '/vault.html' : ''),\n remoteSourceAuthenticationToken: authenticationToken,\n },\n },\n };\n } catch (err) {\n log.catch(err);\n return {};\n }\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nexport const FILE_DEFAULTS = 'defaults.yml';\nexport const FILE_ENVS = 'envs-map.yml';\nexport const FILE_DYNAMICS = 'config.yml';\n\ntype DotPrefix<T extends string> = T extends '' ? '' : `.${T}`;\n\n/**\n * Returns all dot-separated nested keys for an object.\n *\n * Read more: https://stackoverflow.com/a/68404823.\n */\ntype DotNestedKeys<T> = (\n T extends object\n ? {\n [K in Exclude<keyof T, symbol>]: `${K}${DotPrefix<DotNestedKeys<T[K]>>}`;\n }[Exclude<keyof T, symbol>]\n : ''\n) extends infer D\n ? Extract<D, string>\n : never;\n\n/**\n * Parse a dot separated nested key into an array of keys.\n *\n * Example: 'services.signal.server' -> ['services', 'signal', 'server'].\n */\nexport type ParseKey<K extends string> = K extends `${infer L}.${infer Rest}` ? [L, ...ParseKey<Rest>] : [K];\n\n/**\n * Array of types that can act as an object key.\n */\ntype Keys = (keyof any)[];\n\n/**\n * Retrieves a property type in a series of nested objects.\n *\n * Read more: https://stackoverflow.com/a/61648690.\n */\nexport type DeepIndex<T, KS extends Keys, Fail = undefined> = KS extends [infer F, ...infer R]\n ? F extends keyof Exclude<T, undefined>\n ? R extends Keys\n ? DeepIndex<Exclude<T, undefined>[F], R, Fail>\n : Fail\n : Fail\n : T;\n\n/**\n * Any nested dot separated key that can be in config.\n */\n// TODO(egorgripasov): Clean once old config deprecated.\nexport type ConfigKey = DotNestedKeys<ConfigProto>;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nexport const SaveConfig = async (_: ConfigProto) => {};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport yaml from 'js-yaml';\nimport { execSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport pkgUp from 'pkg-up';\n\nimport { log } from '@dxos/log';\nimport { setDeep } from '@dxos/util';\n\nimport { type ConfigPluginOpts } from './types';\nimport { mapFromKeyValues } from '../config';\n\nconst CWD = process.cwd();\n\nexport const definitions = ({\n configPath,\n envPath,\n devPath,\n mode = process.env.NODE_ENV,\n publicUrl = '',\n env,\n}: ConfigPluginOpts) => {\n const KEYS_TO_FILE = {\n __CONFIG_DEFAULTS__: configPath?.length ? configPath : resolve(CWD, 'dx.yml'),\n __CONFIG_ENVS__: envPath?.length ? envPath : resolve(CWD, 'dx-env.yml'),\n } as { [key: string]: string };\n\n if (mode !== 'production') {\n KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? resolve(CWD, 'dx-local.yml');\n }\n\n return Object.entries(KEYS_TO_FILE).reduce(\n (prev, [key, value]) => {\n let content = {};\n\n try {\n content = yaml.load(readFileSync(value, 'utf-8')) as any;\n\n // Map environment variables to config values.\n if (key === '__CONFIG_ENVS__') {\n content = mapFromKeyValues(content, process.env);\n }\n\n if (key === '__CONFIG_DEFAULTS__') {\n // Load app environment variables into default config.\n Object.entries(process.env).forEach(([key, value]) => {\n if (key.startsWith('DX_') || env?.includes(key)) {\n setDeep(content, ['runtime', 'app', 'env', key], value);\n }\n });\n\n // Set build info automatically if available.\n try {\n const timestamp = new Date().toISOString();\n const commitHash =\n process.env.DX_COMMIT_HASH ??\n execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).replace('\\n', '');\n const packagePath = pkgUp.sync();\n const packageJson = packagePath && JSON.parse(readFileSync(packagePath, 'utf-8'));\n setDeep(content, ['runtime', 'app', 'build', 'timestamp'], timestamp);\n setDeep(content, ['runtime', 'app', 'build', 'commitHash'], commitHash);\n setDeep(content, ['runtime', 'app', 'build', 'version'], packageJson?.version);\n } catch {}\n }\n } catch (err: any) {\n if (err.message.includes('YAMLException')) {\n log.error(`Failed to parse file ${value}:`, err);\n } else {\n log(`Failed to load file ${value}:`, err);\n }\n\n if (key === '__CONFIG_DEFAULTS__') {\n // Default config is required.\n throw new Error(`Failed to load default config file from ${value}`);\n }\n }\n\n return {\n ...prev,\n [key]: content,\n };\n },\n {\n __DXOS_CONFIG__: { dynamic: mode === 'production', publicUrl },\n __CONFIG_DEFAULTS__: {},\n __CONFIG_ENVS__: {},\n __CONFIG_LOCAL__: {},\n },\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,WAAsB;ACDtB,qBAAwB;AACxB,oBAAyB;AACzB,IAAAA,iBAAoB;AAEpB,uBAAmC;AACnC,mBAAuB;AAEvB,qBAAsB;AACtB,kBAAiC;ACRjC,qBAAiB;AACjB,qBAAe;AACf,uBAAiB;AAEjB,iBAAoB;AGJpB,IAAAC,kBAAiB;AACjB,gCAAyB;AACzB,IAAAC,kBAA6B;AAC7B,IAAAC,oBAAwB;AACxB,oBAAkB;AAElB,IAAAC,cAAoB;AACpB,IAAAC,eAAwB;;;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A,CAAA;AACxEjG,2BAAAA,SAAQqD,SAAS;YAAC;YAAW;YAAO;YAAS;aAAcqC,SAAAA;AAC3D1F,2BAAAA,SAAQqD,SAAS;YAAC;YAAW;YAAO;YAAS;aAAewC,UAAAA;AAC5D7F,2BAAAA,SAAQqD,SAAS;YAAC;YAAW;YAAO;YAAS;aAAY+C,aAAa7F,OAAAA;QACxE,QAAQ;QAAC;MACX;IACF,SAASmC,KAAU;AACjB,UAAIA,IAAI2D,QAAQZ,SAAS,eAAA,GAAkB;AACzCpB,oBAAAA,IAAI7D,MAAM,wBAAwBf,KAAAA,KAAUiD,KAAAA;;;;;;MAC9C,OAAO;AACL2B,wBAAAA,KAAI,uBAAuB5E,KAAAA,KAAUiD,KAAAA;;;;;;MACvC;AAEA,UAAItD,QAAQ,uBAAuB;AAEjC,cAAM,IAAIW,MAAM,2CAA2CN,KAAAA,EAAO;MACpE;IACF;AAEA,WAAO;MACL,GAAG8F;MACH,CAACnG,GAAAA,GAAMiE;IACT;EACF,GACA;IACEiD,iBAAiB;MAAEC,SAASzB,SAAS;MAAcE;IAAU;IAC7DE,qBAAqB,CAAC;IACtBE,iBAAiB,CAAC;IAClBC,kBAAkB,CAAC;EACrB,CAAA;AAEJ;",
6
- "names": ["import_lodash", "import_js_yaml", "import_node_fs", "import_node_path", "import_log", "import_util", "configRootType", "schema", "getCodecForType", "mapFromKeyValues", "spec", "values", "config", "key", "path", "type", "Object", "entries", "value", "undefined", "boolean", "Number", "JSON", "parse", "Error", "setDeep", "split", "mapToKeyValues", "getDeep", "stringify", "validateConfig", "InvalidConfigError", "version", "error", "protoType", "verify", "ConfigResource", "Symbol", "for", "Config", "objects", "_config", "defaultsDeep", "get", "defaultValue", "find", "test", "Array", "isArray", "isMatch", "getOrThrow", "resource", "annotation", "FILE_DEFAULTS", "FILE_ENVS", "FILE_DYNAMICS", "DEFAULT_BASE_PATH", "resolve", "process", "cwd", "maybeLoadFile", "file", "yaml", "load", "fs", "readFileSync", "encoding", "err", "Profile", "profile", "configFile", "join", "env", "HOME", "Local", "Dynamics", "Envs", "basePath", "content", "Defaults", "Storage", "Remote", "target", "authenticationToken", "url", "URL", "protocol", "slice", "runtime", "client", "remoteSource", "origin", "startsWith", "remoteSourceAuthenticationToken", "log", "catch", "SaveConfig", "_", "CWD", "definitions", "configPath", "envPath", "devPath", "mode", "NODE_ENV", "publicUrl", "KEYS_TO_FILE", "__CONFIG_DEFAULTS__", "length", "__CONFIG_ENVS__", "__CONFIG_LOCAL__", "reduce", "prev", "forEach", "includes", "timestamp", "Date", "toISOString", "commitHash", "DX_COMMIT_HASH", "execSync", "replace", "packagePath", "pkgUp", "sync", "packageJson", "message", "__DXOS_CONFIG__", "dynamic"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"packages/sdk/config/src/config.ts":{"bytes":15747,"imports":[{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/config/src/types.ts":{"bytes":2748,"imports":[],"format":"esm"},"packages/sdk/config/src/loaders/index.ts":{"bytes":8259,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/sdk/config/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/sdk/config/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/sdk/config/src/savers/index.ts":{"bytes":679,"imports":[],"format":"esm"},"packages/sdk/config/src/plugin/definitions.ts":{"bytes":11670,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/sdk/config/src/config.ts","kind":"import-statement","original":"../config"}],"format":"esm"},"packages/sdk/config/src/plugin/types.ts":{"bytes":1498,"imports":[],"format":"esm"},"packages/sdk/config/src/plugin/index.ts":{"bytes":558,"imports":[{"path":"packages/sdk/config/src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"},{"path":"packages/sdk/config/src/plugin/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/sdk/config/src/index.ts":{"bytes":1229,"imports":[{"path":"@dxos/protocols/proto/dxos/config","kind":"import-statement","external":true},{"path":"packages/sdk/config/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/sdk/config/src/loaders/index.ts","kind":"import-statement","original":"./loaders"},{"path":"packages/sdk/config/src/savers/index.ts","kind":"import-statement","original":"./savers"},{"path":"packages/sdk/config/src/plugin/index.ts","kind":"import-statement","original":"./plugin"},{"path":"packages/sdk/config/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"}},"outputs":{"packages/sdk/config/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":19800},"packages/sdk/config/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/protocols/proto/dxos/config","kind":"import-statement","external":true},{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Config","ConfigResource","Defaults","Dynamics","Envs","FILE_DEFAULTS","FILE_DYNAMICS","FILE_ENVS","Local","Profile","Remote","SaveConfig","Storage","definitions","defs","mapFromKeyValues","mapToKeyValues","validateConfig"],"entryPoint":"packages/sdk/config/src/index.ts","inputs":{"packages/sdk/config/src/index.ts":{"bytesInOutput":59},"packages/sdk/config/src/config.ts":{"bytesInOutput":3991},"packages/sdk/config/src/loaders/index.ts":{"bytesInOutput":1562},"packages/sdk/config/src/types.ts":{"bytesInOutput":102},"packages/sdk/config/src/savers/index.ts":{"bytesInOutput":35},"packages/sdk/config/src/plugin/definitions.ts":{"bytesInOutput":3059},"packages/sdk/config/src/plugin/index.ts":{"bytesInOutput":0}},"bytes":9390}}}