@aweave/config-core 0.1.0
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.
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +3 -0
- package/dist/loader.js +102 -0
- package/dist/loader.js.map +1 -0
- package/dist/migrate.d.ts +2 -0
- package/dist/migrate.js +65 -0
- package/dist/migrate.js.map +1 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.js +25 -0
- package/dist/paths.js.map +1 -0
- package/dist/projection.d.ts +2 -0
- package/dist/projection.js +7 -0
- package/dist/projection.js.map +1 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +62 -0
- package/dist/schema.js.map +1 -0
- package/dist/sync.d.ts +3 -0
- package/dist/sync.js +48 -0
- package/dist/sync.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.js +43 -0
- package/dist/types.js.map +1 -0
- package/package.json +21 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { getConfigRoot, getDomainConfigDir, getUserConfigPath } from './paths';
|
|
2
|
+
export { deepMerge, loadConfig } from './loader';
|
|
3
|
+
export { listDefaultConfigs, syncDefaultConfigs } from './sync';
|
|
4
|
+
export { migrateFromLegacy } from './migrate';
|
|
5
|
+
export { validateConfig } from './schema';
|
|
6
|
+
export { projectClientConfig } from './projection';
|
|
7
|
+
export type { ConfigFile, ConfigSchema, LoadConfigOptions, MigrateOptions, MigrateResult, SchemaField, SyncOptions, SyncResult, ValidationIssue, } from './types';
|
|
8
|
+
export { ConfigDefaultsMissingError, ConfigParseError, ConfigValidationError, } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigValidationError = exports.ConfigParseError = exports.ConfigDefaultsMissingError = exports.projectClientConfig = exports.validateConfig = exports.migrateFromLegacy = exports.syncDefaultConfigs = exports.listDefaultConfigs = exports.loadConfig = exports.deepMerge = exports.getUserConfigPath = exports.getDomainConfigDir = exports.getConfigRoot = void 0;
|
|
4
|
+
var paths_1 = require("./paths");
|
|
5
|
+
Object.defineProperty(exports, "getConfigRoot", { enumerable: true, get: function () { return paths_1.getConfigRoot; } });
|
|
6
|
+
Object.defineProperty(exports, "getDomainConfigDir", { enumerable: true, get: function () { return paths_1.getDomainConfigDir; } });
|
|
7
|
+
Object.defineProperty(exports, "getUserConfigPath", { enumerable: true, get: function () { return paths_1.getUserConfigPath; } });
|
|
8
|
+
var loader_1 = require("./loader");
|
|
9
|
+
Object.defineProperty(exports, "deepMerge", { enumerable: true, get: function () { return loader_1.deepMerge; } });
|
|
10
|
+
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return loader_1.loadConfig; } });
|
|
11
|
+
var sync_1 = require("./sync");
|
|
12
|
+
Object.defineProperty(exports, "listDefaultConfigs", { enumerable: true, get: function () { return sync_1.listDefaultConfigs; } });
|
|
13
|
+
Object.defineProperty(exports, "syncDefaultConfigs", { enumerable: true, get: function () { return sync_1.syncDefaultConfigs; } });
|
|
14
|
+
var migrate_1 = require("./migrate");
|
|
15
|
+
Object.defineProperty(exports, "migrateFromLegacy", { enumerable: true, get: function () { return migrate_1.migrateFromLegacy; } });
|
|
16
|
+
var schema_1 = require("./schema");
|
|
17
|
+
Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return schema_1.validateConfig; } });
|
|
18
|
+
var projection_1 = require("./projection");
|
|
19
|
+
Object.defineProperty(exports, "projectClientConfig", { enumerable: true, get: function () { return projection_1.projectClientConfig; } });
|
|
20
|
+
var types_1 = require("./types");
|
|
21
|
+
Object.defineProperty(exports, "ConfigDefaultsMissingError", { enumerable: true, get: function () { return types_1.ConfigDefaultsMissingError; } });
|
|
22
|
+
Object.defineProperty(exports, "ConfigParseError", { enumerable: true, get: function () { return types_1.ConfigParseError; } });
|
|
23
|
+
Object.defineProperty(exports, "ConfigValidationError", { enumerable: true, get: function () { return types_1.ConfigValidationError; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAKA,iCAA+E;AAAtE,sGAAA,aAAa,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAAE,0GAAA,iBAAiB,OAAA;AAG7D,mCAAiD;AAAxC,mGAAA,SAAS,OAAA;AAAE,oGAAA,UAAU,OAAA;AAG9B,+BAAgE;AAAvD,0GAAA,kBAAkB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAG/C,qCAA8C;AAArC,4GAAA,iBAAiB,OAAA;AAG1B,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AAGvB,2CAAmD;AAA1C,iHAAA,mBAAmB,OAAA;AAc5B,iCAIiB;AAHf,mHAAA,0BAA0B,OAAA;AAC1B,yGAAA,gBAAgB,OAAA;AAChB,8GAAA,qBAAqB,OAAA"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ConfigFile, type LoadConfigOptions } from './types';
|
|
2
|
+
export declare function loadConfig<T extends ConfigFile = ConfigFile>(options: LoadConfigOptions): T;
|
|
3
|
+
export declare function deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = loadConfig;
|
|
7
|
+
exports.deepMerge = deepMerge;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
11
|
+
const paths_1 = require("./paths");
|
|
12
|
+
const types_1 = require("./types");
|
|
13
|
+
function loadConfig(options) {
|
|
14
|
+
const { domain, name, defaultsDir, envOverrides } = options;
|
|
15
|
+
const defaultConfig = loadDefaultConfig(defaultsDir, name);
|
|
16
|
+
const userConfigPath = (0, paths_1.getUserConfigPath)(domain, name);
|
|
17
|
+
const userConfig = loadYamlFile(userConfigPath, false);
|
|
18
|
+
const merged = deepMerge(defaultConfig, userConfig);
|
|
19
|
+
if (envOverrides) {
|
|
20
|
+
applyEnvOverrides(merged, envOverrides);
|
|
21
|
+
}
|
|
22
|
+
return merged;
|
|
23
|
+
}
|
|
24
|
+
function loadDefaultConfig(defaultsDir, name) {
|
|
25
|
+
if (!node_fs_1.default.existsSync(defaultsDir)) {
|
|
26
|
+
throw new types_1.ConfigDefaultsMissingError(defaultsDir);
|
|
27
|
+
}
|
|
28
|
+
const filePath = node_path_1.default.join(defaultsDir, `${name}.yaml`);
|
|
29
|
+
return loadYamlFile(filePath, true);
|
|
30
|
+
}
|
|
31
|
+
function loadYamlFile(filePath, required) {
|
|
32
|
+
if (!node_fs_1.default.existsSync(filePath)) {
|
|
33
|
+
if (required) {
|
|
34
|
+
throw new types_1.ConfigParseError(filePath, new Error('File does not exist'));
|
|
35
|
+
}
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
const raw = node_fs_1.default.readFileSync(filePath, 'utf-8');
|
|
39
|
+
if (raw.trim().length === 0) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const parsed = yaml_1.default.parse(raw);
|
|
44
|
+
if (parsed == null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
45
|
+
throw new Error('Config file must contain a YAML mapping (object) at top level');
|
|
46
|
+
}
|
|
47
|
+
return parsed;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof yaml_1.default.YAMLParseError) {
|
|
51
|
+
const pos = error.linePos?.[0];
|
|
52
|
+
throw new types_1.ConfigParseError(filePath, error, pos?.line, pos?.col);
|
|
53
|
+
}
|
|
54
|
+
throw new types_1.ConfigParseError(filePath, error instanceof Error ? error : new Error(String(error)));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function deepMerge(target, source) {
|
|
58
|
+
const result = { ...target };
|
|
59
|
+
for (const key of Object.keys(source)) {
|
|
60
|
+
const sourceVal = source[key];
|
|
61
|
+
const targetVal = result[key];
|
|
62
|
+
if (isPlainObject(sourceVal) && isPlainObject(targetVal)) {
|
|
63
|
+
result[key] = deepMerge(targetVal, sourceVal);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
result[key] = sourceVal;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
function isPlainObject(value) {
|
|
72
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
73
|
+
}
|
|
74
|
+
function applyEnvOverrides(config, overrides) {
|
|
75
|
+
for (const [dotPath, envVar] of Object.entries(overrides)) {
|
|
76
|
+
const envValue = process.env[envVar];
|
|
77
|
+
if (envValue === undefined)
|
|
78
|
+
continue;
|
|
79
|
+
const keys = dotPath.split('.');
|
|
80
|
+
let current = config;
|
|
81
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
82
|
+
const key = keys[i];
|
|
83
|
+
if (!isPlainObject(current[key])) {
|
|
84
|
+
current[key] = {};
|
|
85
|
+
}
|
|
86
|
+
current = current[key];
|
|
87
|
+
}
|
|
88
|
+
const lastKey = keys[keys.length - 1];
|
|
89
|
+
current[lastKey] = coerceValue(envValue);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function coerceValue(value) {
|
|
93
|
+
if (value === 'true')
|
|
94
|
+
return true;
|
|
95
|
+
if (value === 'false')
|
|
96
|
+
return false;
|
|
97
|
+
const num = Number(value);
|
|
98
|
+
if (!Number.isNaN(num) && value.trim().length > 0)
|
|
99
|
+
return num;
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;;;AA4BA,gCAqBC;AAsED,8BAqBC;AA5ID,sDAAyB;AACzB,0DAA6B;AAE7B,gDAAwB;AAExB,mCAA4C;AAC5C,mCAKiB;AAiBjB,SAAgB,UAAU,CACxB,OAA0B;IAE1B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAG5D,MAAM,aAAa,GAAG,iBAAiB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAG3D,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAGvD,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAGpD,IAAI,YAAY,EAAE,CAAC;QACjB,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC;AAMD,SAAS,iBAAiB,CACxB,WAAmB,EACnB,IAAY;IAEZ,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,kCAA0B,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;IACxD,OAAO,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAOD,SAAS,YAAY,CACnB,QAAgB,EAChB,Q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AAC,CAAC;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACpB,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,GAAG,CAA4B,CAAC;QACpD,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAEpC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAE9D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.migrateFromLegacy = migrateFromLegacy;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
10
|
+
const paths_1 = require("./paths");
|
|
11
|
+
function migrateFromLegacy(options) {
|
|
12
|
+
const { domain, legacyFiles } = options;
|
|
13
|
+
if (!legacyFiles || Object.keys(legacyFiles).length === 0) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const destDir = (0, paths_1.getDomainConfigDir)(domain);
|
|
17
|
+
node_fs_1.default.mkdirSync(destDir, { recursive: true });
|
|
18
|
+
const results = [];
|
|
19
|
+
for (const [legacyPath, newName] of Object.entries(legacyFiles)) {
|
|
20
|
+
const expandedPath = expandHome(legacyPath);
|
|
21
|
+
const destPath = node_path_1.default.join(destDir, `${newName}.yaml`);
|
|
22
|
+
if (!node_fs_1.default.existsSync(expandedPath)) {
|
|
23
|
+
results.push({
|
|
24
|
+
legacyPath: expandedPath,
|
|
25
|
+
newPath: destPath,
|
|
26
|
+
action: 'not_found',
|
|
27
|
+
message: `Legacy file not found: ${expandedPath}`,
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (node_fs_1.default.existsSync(destPath)) {
|
|
32
|
+
results.push({
|
|
33
|
+
legacyPath: expandedPath,
|
|
34
|
+
newPath: destPath,
|
|
35
|
+
action: 'skipped',
|
|
36
|
+
message: `Target already exists: ${destPath} (legacy file preserved at ${expandedPath})`,
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const raw = node_fs_1.default.readFileSync(expandedPath, 'utf-8');
|
|
41
|
+
let content;
|
|
42
|
+
if (expandedPath.endsWith('.json')) {
|
|
43
|
+
const parsed = JSON.parse(raw);
|
|
44
|
+
content = yaml_1.default.stringify(parsed);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
content = raw;
|
|
48
|
+
}
|
|
49
|
+
node_fs_1.default.writeFileSync(destPath, content, 'utf-8');
|
|
50
|
+
results.push({
|
|
51
|
+
legacyPath: expandedPath,
|
|
52
|
+
newPath: destPath,
|
|
53
|
+
action: 'migrated',
|
|
54
|
+
message: `Migrated ${expandedPath} → ${destPath}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return results;
|
|
58
|
+
}
|
|
59
|
+
function expandHome(filePath) {
|
|
60
|
+
if (filePath.startsWith('~/') || filePath === '~') {
|
|
61
|
+
return node_path_1.default.join(process.env.HOME || process.env.USERPROFILE || '', filePath.slice(1));
|
|
62
|
+
}
|
|
63
|
+
return filePath;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":";;;;;AAqBA,8CA2DC;AAhFD,sDAAyB;AACzB,0DAA6B;AAE7B,gDAAwB;AAExB,mCAA6C;AAgB7C,SAAgB,iBAAiB,CAAC,OAAuB;IACvD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAExC,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,0BAAkB,EAAC,MAAM,CAAC,CAAC;IAC3C,iBAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAChE,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,OAAO,CAAC,CAAC;QAEvD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC;gBACX,UAAU,EAAE,YAAY;gBACxB,OAAO,EAAE,QAAQ;gBACjB,MAAM,EAAE,WAAW;gBACnB,OAAO,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KAAK,CAAC,CAAC,CAAC,CAClB,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/paths.d.ts
ADDED
package/dist/paths.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getConfigRoot = getConfigRoot;
|
|
7
|
+
exports.getDomainConfigDir = getDomainConfigDir;
|
|
8
|
+
exports.getUserConfigPath = getUserConfigPath;
|
|
9
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const CONFIG_ROOT_DIR = '.aweave';
|
|
12
|
+
const CONFIG_SUB_DIR = 'config';
|
|
13
|
+
function getConfigRoot() {
|
|
14
|
+
if (process.env.AWEAVE_CONFIG_ROOT) {
|
|
15
|
+
return process.env.AWEAVE_CONFIG_ROOT;
|
|
16
|
+
}
|
|
17
|
+
return node_path_1.default.join(node_os_1.default.homedir(), CONFIG_ROOT_DIR, CONFIG_SUB_DIR);
|
|
18
|
+
}
|
|
19
|
+
function getDomainConfigDir(domain) {
|
|
20
|
+
return node_path_1.default.join(getConfigRoot(), domain);
|
|
21
|
+
}
|
|
22
|
+
function getUserConfigPath(domain, name) {
|
|
23
|
+
return node_path_1.default.join(getDomainConfigDir(domain), `${name}.yaml`);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;;;AAgBA,sCAMC;AAMD,gDAEC;AAMD,8CAEC;AAtCD,sDAAyB;AACzB,0DAA6B;AAM7B,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAQhC,SAAgB,aAAa;IAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACxC,CAAC;IAED,OAAO,mBAAI,CAAC,IAAI,CAAC,iBAAE,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;AAClE,CAAC;AAMD,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,mBAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC;AAMD,SAAgB,iBAAiB,CAAC,MAAc,EAAE,IAAY;IAC5D,OAAO,mBAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":";;AAoBA,kDAIC;AAJD,SAAgB,mBAAmB,CACjC,MAAS;IAET,OAAO,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/schema.d.ts
ADDED
package/dist/schema.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConfig = validateConfig;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
function validateConfig(config, schema, filePath) {
|
|
6
|
+
const issues = [];
|
|
7
|
+
if (schema.configVersion != null) {
|
|
8
|
+
const actual = config.configVersion;
|
|
9
|
+
if (actual != null && actual !== schema.configVersion) {
|
|
10
|
+
issues.push({
|
|
11
|
+
path: 'configVersion',
|
|
12
|
+
message: `Expected version ${schema.configVersion}, got ${actual}`,
|
|
13
|
+
expected: String(schema.configVersion),
|
|
14
|
+
actual: String(actual),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (const [fieldPath, fieldDef] of Object.entries(schema.fields)) {
|
|
19
|
+
const value = getNestedValue(config, fieldPath);
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
if (fieldDef.required) {
|
|
22
|
+
issues.push({
|
|
23
|
+
path: fieldPath,
|
|
24
|
+
message: `Required field is missing`,
|
|
25
|
+
expected: fieldDef.type,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const actualType = getValueType(value);
|
|
31
|
+
if (actualType !== fieldDef.type) {
|
|
32
|
+
issues.push({
|
|
33
|
+
path: fieldPath,
|
|
34
|
+
message: `Expected type "${fieldDef.type}", got "${actualType}"`,
|
|
35
|
+
expected: fieldDef.type,
|
|
36
|
+
actual: actualType,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (issues.length > 0) {
|
|
41
|
+
throw new types_1.ConfigValidationError(filePath, issues);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getNestedValue(obj, dotPath) {
|
|
45
|
+
const keys = dotPath.split('.');
|
|
46
|
+
let current = obj;
|
|
47
|
+
for (const key of keys) {
|
|
48
|
+
if (current === null || typeof current !== 'object') {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
current = current[key];
|
|
52
|
+
}
|
|
53
|
+
return current;
|
|
54
|
+
}
|
|
55
|
+
function getValueType(value) {
|
|
56
|
+
if (Array.isArray(value))
|
|
57
|
+
return 'array';
|
|
58
|
+
if (value === null)
|
|
59
|
+
return 'null';
|
|
60
|
+
return typeof value;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":";;AAkBA,wCAiDC;AAnED,mCAIiB;AAcj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CAAC,IAAI;gBACvB,MAAM,EAAE,UAAU;aACnB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,6BAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAUD,SAAS,cAAc,CACrB,GAA4B,EAC5B,OAAe;IAEf,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,OAAO,GAAY,GAAG,CAAC;IAE3B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACpD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,OAAO,OAAO,KAAK,CAAC;AACtB,CAAC"}
|
package/dist/sync.d.ts
ADDED
package/dist/sync.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.syncDefaultConfigs = syncDefaultConfigs;
|
|
7
|
+
exports.listDefaultConfigs = listDefaultConfigs;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const paths_1 = require("./paths");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
function syncDefaultConfigs(options) {
|
|
13
|
+
const { domain, defaultsDir, force = false } = options;
|
|
14
|
+
if (!node_fs_1.default.existsSync(defaultsDir)) {
|
|
15
|
+
throw new types_1.ConfigDefaultsMissingError(defaultsDir);
|
|
16
|
+
}
|
|
17
|
+
const destDir = (0, paths_1.getDomainConfigDir)(domain);
|
|
18
|
+
node_fs_1.default.mkdirSync(destDir, { recursive: true });
|
|
19
|
+
const yamlFiles = node_fs_1.default
|
|
20
|
+
.readdirSync(defaultsDir)
|
|
21
|
+
.filter((f) => f.endsWith('.yaml') || f.endsWith('.yml'));
|
|
22
|
+
const results = [];
|
|
23
|
+
for (const file of yamlFiles) {
|
|
24
|
+
const srcPath = node_path_1.default.join(defaultsDir, file);
|
|
25
|
+
const destPath = node_path_1.default.join(destDir, file);
|
|
26
|
+
const exists = node_fs_1.default.existsSync(destPath);
|
|
27
|
+
if (exists && !force) {
|
|
28
|
+
results.push({ file, action: 'skipped', destination: destPath });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
node_fs_1.default.copyFileSync(srcPath, destPath);
|
|
32
|
+
results.push({
|
|
33
|
+
file,
|
|
34
|
+
action: exists ? 'overwritten' : 'created',
|
|
35
|
+
destination: destPath,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
function listDefaultConfigs(defaultsDir) {
|
|
41
|
+
if (!node_fs_1.default.existsSync(defaultsDir)) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return node_fs_1.default
|
|
45
|
+
.readdirSync(defaultsDir)
|
|
46
|
+
.filter((f) => f.endsWith('.yaml') || f.endsWith('.yml'));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.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AC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC;YACX,IAAI;YACJ,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YAC1C,WAAW,EAAE,QAAQ;SACtB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAMD,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,iBAAE;SACN,WAAW,CAAC,WAAW,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface LoadConfigOptions {
|
|
2
|
+
domain: string;
|
|
3
|
+
name: string;
|
|
4
|
+
defaultsDir: string;
|
|
5
|
+
envOverrides?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export interface SyncOptions {
|
|
8
|
+
domain: string;
|
|
9
|
+
defaultsDir: string;
|
|
10
|
+
force?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SyncResult {
|
|
13
|
+
file: string;
|
|
14
|
+
action: 'created' | 'skipped' | 'overwritten';
|
|
15
|
+
destination: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MigrateOptions {
|
|
18
|
+
domain: string;
|
|
19
|
+
legacyFiles?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export interface MigrateResult {
|
|
22
|
+
legacyPath: string;
|
|
23
|
+
newPath: string;
|
|
24
|
+
action: 'migrated' | 'skipped' | 'not_found';
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ConfigFile {
|
|
28
|
+
configVersion?: number;
|
|
29
|
+
server?: Record<string, unknown>;
|
|
30
|
+
clientPublic?: Record<string, unknown>;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface SchemaField {
|
|
34
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
35
|
+
required?: boolean;
|
|
36
|
+
description?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ConfigSchema {
|
|
39
|
+
configVersion?: number;
|
|
40
|
+
fields: Record<string, SchemaField>;
|
|
41
|
+
}
|
|
42
|
+
export interface ValidationIssue {
|
|
43
|
+
path: string;
|
|
44
|
+
message: string;
|
|
45
|
+
expected?: string;
|
|
46
|
+
actual?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class ConfigParseError extends Error {
|
|
49
|
+
readonly filePath: string;
|
|
50
|
+
readonly cause: Error;
|
|
51
|
+
readonly line?: number | undefined;
|
|
52
|
+
readonly column?: number | undefined;
|
|
53
|
+
constructor(filePath: string, cause: Error, line?: number | undefined, column?: number | undefined);
|
|
54
|
+
}
|
|
55
|
+
export declare class ConfigValidationError extends Error {
|
|
56
|
+
readonly filePath: string;
|
|
57
|
+
readonly issues: ValidationIssue[];
|
|
58
|
+
constructor(filePath: string, issues: ValidationIssue[]);
|
|
59
|
+
}
|
|
60
|
+
export declare class ConfigDefaultsMissingError extends Error {
|
|
61
|
+
readonly defaultsDir: string;
|
|
62
|
+
constructor(defaultsDir: string);
|
|
63
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigDefaultsMissingError = exports.ConfigValidationError = exports.ConfigParseError = void 0;
|
|
4
|
+
class ConfigParseError extends Error {
|
|
5
|
+
filePath;
|
|
6
|
+
cause;
|
|
7
|
+
line;
|
|
8
|
+
column;
|
|
9
|
+
constructor(filePath, cause, line, column) {
|
|
10
|
+
const location = line != null
|
|
11
|
+
? ` at line ${line}` + (column != null ? `, column ${column}` : '')
|
|
12
|
+
: '';
|
|
13
|
+
super(`Failed to parse config file "${filePath}"${location}: ${cause.message}`);
|
|
14
|
+
this.filePath = filePath;
|
|
15
|
+
this.cause = cause;
|
|
16
|
+
this.line = line;
|
|
17
|
+
this.column = column;
|
|
18
|
+
this.name = 'ConfigParseError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ConfigParseError = ConfigParseError;
|
|
22
|
+
class ConfigValidationError extends Error {
|
|
23
|
+
filePath;
|
|
24
|
+
issues;
|
|
25
|
+
constructor(filePath, issues) {
|
|
26
|
+
const summary = issues.map((i) => ` - ${i.path}: ${i.message}`).join('\n');
|
|
27
|
+
super(`Config validation failed for "${filePath}":\n${summary}`);
|
|
28
|
+
this.filePath = filePath;
|
|
29
|
+
this.issues = issues;
|
|
30
|
+
this.name = 'ConfigValidationError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ConfigValidationError = ConfigValidationError;
|
|
34
|
+
class ConfigDefaultsMissingError extends Error {
|
|
35
|
+
defaultsDir;
|
|
36
|
+
constructor(defaultsDir) {
|
|
37
|
+
super(`Defaults directory not found: "${defaultsDir}"`);
|
|
38
|
+
this.defaultsDir = defaultsDir;
|
|
39
|
+
this.name = 'ConfigDefaultsMissingError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ConfigDefaultsMissingError = ConfigDefaultsMissingError;
|
|
43
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuFA,MAAa,gBAAiB,SAAQ,KAAK;IAEvB;IACA;IACA;IACA;IAJlB,YACkB,QAAgB,EAChB,KAAY,EACZ,IAAa,EACb,MAAe;QAE/B,MAAM,QAAQ,GACZ,IAAI,IAAI,IAAI;YACV,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1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"yaml": "^2.7.0"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/node": "^22.10.7",
|
|
11
|
+
"typescript": "^5.7.3"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"lint": "eslint .",
|
|
19
|
+
"lint:fix": "eslint . --fix"
|
|
20
|
+
}
|
|
21
|
+
}
|