@decohere/core 0.0.1-dev.20261107.245 → 0.0.1-dev.20261107.250

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.
@@ -0,0 +1,37 @@
1
+ /** Which environment a process with no NODE_ENV, and a package, are for. */ export const DEFAULT_CONFIG_ENV = "production";
2
+ const NAME = /^[A-Za-z0-9_-]+$/;
3
+ const CONFIG_FILE = /^config(?:\.[A-Za-z0-9_-]+){0,2}\.yaml$/;
4
+ /** A valid app or environment name: it fills one part of a config file's name. */ export function isConfigNamePart(name) {
5
+ return NAME.test(name);
6
+ }
7
+ /** True when a file fits `config.{optional app}.{optional env}.yaml`. */ export function isConfigFileName(fileName) {
8
+ return CONFIG_FILE.test(fileName);
9
+ }
10
+ /**
11
+ * The config files for these apps and environments, later ones winning:
12
+ * `config.yaml`, `config.<app>.yaml`, `config.<env>.yaml`, `config.<app>.<env>.yaml`.
13
+ *
14
+ * Names are built from what's given and never parsed, so `config.dev.yaml` can't be misread.
15
+ *
16
+ * @throws if a name can't be part of a file name, or an app has the same name as an environment,
17
+ * since `config.<name>.yaml` would then mean both.
18
+ */ export function configFileNames(apps, envs) {
19
+ for (const name of [
20
+ ...apps,
21
+ ...envs
22
+ ]){
23
+ if (!isConfigNamePart(name)) {
24
+ throw new Error(`${JSON.stringify(name)} can't name a config file: use letters, digits, "-" and "_"`);
25
+ }
26
+ }
27
+ const clash = apps.find((app)=>envs.includes(app));
28
+ if (clash != null) {
29
+ throw new Error(`"${clash}" is both an app and an environment, so config.${clash}.yaml would mean both`);
30
+ }
31
+ return [
32
+ "config.yaml",
33
+ ...apps.map((app)=>`config.${app}.yaml`),
34
+ ...envs.map((env)=>`config.${env}.yaml`),
35
+ ...apps.flatMap((app)=>envs.map((env)=>`config.${app}.${env}.yaml`))
36
+ ];
37
+ }
@@ -1 +1,2 @@
1
+ export * from "./config-files.js";
1
2
  export * from "./configuration.types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/core",
3
- "version": "0.0.1-dev.20261107.245",
3
+ "version": "0.0.1-dev.20261107.250",
4
4
  "description": "The runtime base every Decohere package builds on: reflection, composition, configuration types, extensibility, collections, objects, caching on a Map, and basic file IO. No side effects on import.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -68,7 +68,7 @@
68
68
  "test": "echo \"Error: no test specified\" && exit 1"
69
69
  },
70
70
  "dependencies": {
71
- "@decohere/scribe": "0.0.1-dev.20261107.245",
71
+ "@decohere/scribe": "0.0.1-dev.20261107.250",
72
72
  "reflect-metadata": "^0.2.2"
73
73
  },
74
74
  "devDependencies": {}
@@ -0,0 +1,16 @@
1
+ /** Which environment a process with no NODE_ENV, and a package, are for. */
2
+ export declare const DEFAULT_CONFIG_ENV = "production";
3
+ /** A valid app or environment name: it fills one part of a config file's name. */
4
+ export declare function isConfigNamePart(name: string): boolean;
5
+ /** True when a file fits `config.{optional app}.{optional env}.yaml`. */
6
+ export declare function isConfigFileName(fileName: string): boolean;
7
+ /**
8
+ * The config files for these apps and environments, later ones winning:
9
+ * `config.yaml`, `config.<app>.yaml`, `config.<env>.yaml`, `config.<app>.<env>.yaml`.
10
+ *
11
+ * Names are built from what's given and never parsed, so `config.dev.yaml` can't be misread.
12
+ *
13
+ * @throws if a name can't be part of a file name, or an app has the same name as an environment,
14
+ * since `config.<name>.yaml` would then mean both.
15
+ */
16
+ export declare function configFileNames(apps: readonly string[], envs: readonly string[]): string[];
@@ -1 +1,2 @@
1
+ export * from "./config-files.js";
1
2
  export * from "./configuration.types.js";