@powerlines/plugin-env 0.16.62 → 0.16.63
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/babel/plugin.cjs +11 -83
- package/dist/babel/plugin.mjs +11 -83
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +22 -47
- package/dist/components/docs.mjs +22 -47
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +219 -419
- package/dist/components/env-builtin.mjs +219 -419
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/automd-generator.cjs +4 -14
- package/dist/helpers/automd-generator.d.mts +1 -1
- package/dist/helpers/automd-generator.mjs +4 -14
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/create-reflection-resource.cjs +0 -8
- package/dist/helpers/create-reflection-resource.mjs +0 -9
- package/dist/helpers/create-reflection-resource.mjs.map +1 -1
- package/dist/helpers/docs-helper.cjs +0 -8
- package/dist/helpers/docs-helper.mjs +0 -8
- package/dist/helpers/docs-helper.mjs.map +1 -1
- package/dist/helpers/index.cjs +0 -1
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/load.cjs +7 -58
- package/dist/helpers/load.mjs +7 -58
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +1 -108
- package/dist/helpers/persistence.mjs +1 -108
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.cjs +16 -156
- package/dist/helpers/reflect.mjs +17 -156
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/source-file-env.cjs +4 -34
- package/dist/helpers/source-file-env.mjs +4 -34
- package/dist/helpers/source-file-env.mjs.map +1 -1
- package/dist/helpers/template-helpers.cjs +5 -33
- package/dist/helpers/template-helpers.mjs +5 -33
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/index.cjs +2 -12
- package/dist/index.mjs +2 -12
- package/dist/index.mjs.map +1 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +0 -2
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +1 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +0 -4
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +1 -1
- package/dist/types/index.cjs +0 -11
- package/dist/types/index.mjs +1 -4
- package/dist/types/plugin.cjs +0 -137
- package/dist/types/plugin.d.mts +4 -4
- package/dist/types/plugin.mjs +1 -132
- package/dist/types/runtime.cjs +0 -244
- package/dist/types/runtime.mjs +1 -242
- package/package.json +10 -10
- package/dist/types/plugin.mjs.map +0 -1
- package/dist/types/runtime.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/utils\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: workspaceConfig.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput\n) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.mjs","names":["loadEnvBase","loadEnvFileBase"],"sources":["../../src/helpers/load.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/utils\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: workspaceConfig.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput\n) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;AAkCA,eAAe,aACb,SACA,MACA,KACe;CACf,IAAI,MAAM,MAAMA,UAAY,KAAK,KAAK;AACtC,KAAI,QAAQ,mBAAmB,QAAQ,iBAAiB,SAAS,GAAG;EAClE,MAAM,qBAAqB,MAAM,QAAQ,IACvC,QAAQ,gBAAgB,IAAI,OAAM,sBAChCC,YAAgB,mBAAmB,IAAI,CACxC,CACF;AAED,OAAK,MAAM,qBAAqB,mBAC9B,OAAM,KAAK,mBAAmB,IAAI;;AAItC,QAAO,gBAAgB,IAAI;;AAG7B,eAAe,iBAGb,SACA,WACA,MACA,UACA,aACA,iBACe;CACf,MAAM,CAAC,WAAW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AQ,OAAO,OACf,QAAQ,YAAY;EAC3B,EACD,YAAY,SAAS,KAAK,OAAO,IAAI,GACjC,QAAQ,IAAI,MAAM,KAAK,eAAe,CAAC,QACpC,KAAK,SAAS;AACb,MAAI,KAAK,QAAQ,OAAO,KAAK,SAAS,KAAK,iBAAiB;AAC5D,SAAO;IAET,EAAE,CACH,GACD,EAAE,CACP;;AAGH,eAAsB,QAEpB,SAA2B,SAA0C;CACrE,MAAM,CAAC,SAAS,WAAW,UAAU,MAAM,QAAQ,IAAI;EACrD,iBACE,SACA,QAAQ,OAAO,MACf,QAAQ,OAAO,MACf,QAAQ,WACR,QAAQ,aACR,QAAQ,gBACT;EACD,iBACE,SACA,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,QAAQ,WACR,QAAQ,aACR,QAAQ,gBACT;EACD,iBACE,SACA,QAAQ,SAAS,QACjB,QAAQ,OAAO,MACf,QAAQ,WACR,QAAQ,aACR,QAAQ,gBACT;EACF,CAAC;AAEF,QAAO,KACL,mBAAmB,SAAS,QAAQ,IAAI,EACxC,SACA,WACA,OACD"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
3
|
const require_helpers_reflect = require('./reflect.cjs');
|
|
5
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
6
|
-
let powerlines = require("powerlines");
|
|
7
4
|
let _powerlines_deepkit_capnp = require("@powerlines/deepkit/capnp");
|
|
8
5
|
let _powerlines_deepkit_resolve_reflections = require("@powerlines/deepkit/resolve-reflections");
|
|
9
6
|
let _powerlines_deepkit_schemas_reflection = require("@powerlines/deepkit/schemas/reflection");
|
|
7
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
10
8
|
let _stryke_capnp = require("@stryke/capnp");
|
|
11
9
|
_stryke_capnp = require_runtime.__toESM(_stryke_capnp);
|
|
12
10
|
let _stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
@@ -26,14 +24,6 @@ async function resolveRuntimeTypeFile(context) {
|
|
|
26
24
|
if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
|
|
27
25
|
return resolved;
|
|
28
26
|
}
|
|
29
|
-
resolveRuntimeTypeFile.__type = [
|
|
30
|
-
() => powerlines.__ΩUnresolvedContext,
|
|
31
|
-
() => require_types_plugin.__ΩEnvPluginResolvedConfig,
|
|
32
|
-
"context",
|
|
33
|
-
"resolveRuntimeTypeFile",
|
|
34
|
-
"Resolves the runtime type definition file for the environment variables.",
|
|
35
|
-
"Pn\"o!\"2#&`/$?%"
|
|
36
|
-
];
|
|
37
27
|
/**
|
|
38
28
|
* Gets the default type definition for the environment variables.
|
|
39
29
|
*
|
|
@@ -46,14 +36,6 @@ async function getEnvDefaultTypeDefinition(context) {
|
|
|
46
36
|
name: "EnvInterface"
|
|
47
37
|
};
|
|
48
38
|
}
|
|
49
|
-
getEnvDefaultTypeDefinition.__type = [
|
|
50
|
-
() => powerlines.__ΩUnresolvedContext,
|
|
51
|
-
() => require_types_plugin.__ΩEnvPluginResolvedConfig,
|
|
52
|
-
"context",
|
|
53
|
-
"getEnvDefaultTypeDefinition",
|
|
54
|
-
"Gets the default type definition for the environment variables.",
|
|
55
|
-
"Pn\"o!\"2#!`/$?%"
|
|
56
|
-
];
|
|
57
39
|
/** Gets the default type definition for the environment secrets.
|
|
58
40
|
*
|
|
59
41
|
* @param context - The plugin context.
|
|
@@ -65,13 +47,6 @@ async function getSecretsDefaultTypeDefinition(context) {
|
|
|
65
47
|
name: "SecretsInterface"
|
|
66
48
|
};
|
|
67
49
|
}
|
|
68
|
-
getSecretsDefaultTypeDefinition.__type = [
|
|
69
|
-
() => powerlines.__ΩUnresolvedContext,
|
|
70
|
-
() => require_types_plugin.__ΩEnvPluginResolvedConfig,
|
|
71
|
-
"context",
|
|
72
|
-
"getSecretsDefaultTypeDefinition",
|
|
73
|
-
"Pn\"o!\"2#!`/$"
|
|
74
|
-
];
|
|
75
50
|
/**
|
|
76
51
|
* Gets the path to the environment type reflections.
|
|
77
52
|
*
|
|
@@ -82,17 +57,6 @@ getSecretsDefaultTypeDefinition.__type = [
|
|
|
82
57
|
function getEnvTypeReflectionsPath(context, name = "env") {
|
|
83
58
|
return (0, _stryke_path_join_paths.joinPaths)((0, _powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}-types.bin`);
|
|
84
59
|
}
|
|
85
|
-
getEnvTypeReflectionsPath.__type = [
|
|
86
|
-
() => powerlines.__ΩContext,
|
|
87
|
-
() => require_types_plugin.__ΩEnvPluginResolvedConfig,
|
|
88
|
-
"context",
|
|
89
|
-
() => require_types_plugin.__ΩEnvType,
|
|
90
|
-
"name",
|
|
91
|
-
() => "env",
|
|
92
|
-
"getEnvTypeReflectionsPath",
|
|
93
|
-
"Gets the path to the environment type reflections.",
|
|
94
|
-
"Pn\"o!\"2#n$2%>&&/'?("
|
|
95
|
-
];
|
|
96
60
|
/**
|
|
97
61
|
* Reads the environment type reflection from the file system.
|
|
98
62
|
*
|
|
@@ -121,17 +85,6 @@ async function readEnvTypeReflection(context, name = "env") {
|
|
|
121
85
|
context.env.types[name].dataBuffer = buffer;
|
|
122
86
|
return reflection;
|
|
123
87
|
}
|
|
124
|
-
readEnvTypeReflection.__type = [
|
|
125
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
126
|
-
"context",
|
|
127
|
-
() => require_types_plugin.__ΩEnvType,
|
|
128
|
-
"name",
|
|
129
|
-
() => "env",
|
|
130
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
131
|
-
"readEnvTypeReflection",
|
|
132
|
-
"Reads the environment type reflection from the file system.",
|
|
133
|
-
"Pn!2\"n#2$>%P\"7&`/'?("
|
|
134
|
-
];
|
|
135
88
|
/**
|
|
136
89
|
* Writes the environment type reflection to the file system.
|
|
137
90
|
*
|
|
@@ -145,29 +98,9 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
|
|
|
145
98
|
(0, _powerlines_deepkit_capnp.convertToCapnp)(serialized, message.initRoot(_powerlines_deepkit_schemas_reflection.SerializedTypes)._initTypes(serialized.length));
|
|
146
99
|
await (0, _stryke_fs_buffer.writeFileBuffer)(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
|
|
147
100
|
}
|
|
148
|
-
writeEnvTypeReflection.__type = [
|
|
149
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
150
|
-
"context",
|
|
151
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
152
|
-
"reflection",
|
|
153
|
-
() => require_types_plugin.__ΩEnvType,
|
|
154
|
-
"name",
|
|
155
|
-
() => "env",
|
|
156
|
-
"writeEnvTypeReflection",
|
|
157
|
-
"Writes the environment type reflection to the file system.",
|
|
158
|
-
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
159
|
-
];
|
|
160
101
|
function getEnvReflectionsPath(context, name) {
|
|
161
102
|
return (0, _stryke_path_join_paths.joinPaths)((0, _powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}.bin`);
|
|
162
103
|
}
|
|
163
|
-
getEnvReflectionsPath.__type = [
|
|
164
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
165
|
-
"context",
|
|
166
|
-
() => require_types_plugin.__ΩEnvType,
|
|
167
|
-
"name",
|
|
168
|
-
"getEnvReflectionsPath",
|
|
169
|
-
"Pn!2\"n#2$&/%"
|
|
170
|
-
];
|
|
171
104
|
/**
|
|
172
105
|
* Reads the environment reflection data from the file system.
|
|
173
106
|
*
|
|
@@ -205,14 +138,6 @@ async function readEnvReflection(context) {
|
|
|
205
138
|
context.env.used.env.dataBuffer = buffer;
|
|
206
139
|
return reflection;
|
|
207
140
|
}
|
|
208
|
-
readEnvReflection.__type = [
|
|
209
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
210
|
-
"context",
|
|
211
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
212
|
-
"readEnvReflection",
|
|
213
|
-
"Reads the environment reflection data from the file system.",
|
|
214
|
-
"Pn!2\"P\"7#`/$?%"
|
|
215
|
-
];
|
|
216
141
|
/**
|
|
217
142
|
* Reads the secret environment reflection data from the file system.
|
|
218
143
|
*
|
|
@@ -250,14 +175,6 @@ async function readSecretsReflection(context) {
|
|
|
250
175
|
context.env.used.secrets.dataBuffer = buffer;
|
|
251
176
|
return reflection;
|
|
252
177
|
}
|
|
253
|
-
readSecretsReflection.__type = [
|
|
254
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
255
|
-
"context",
|
|
256
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
257
|
-
"readSecretsReflection",
|
|
258
|
-
"Reads the secret environment reflection data from the file system.",
|
|
259
|
-
"Pn!2\"P\"7#`/$?%"
|
|
260
|
-
];
|
|
261
178
|
/**
|
|
262
179
|
* Writes the environment reflection data to the file system.
|
|
263
180
|
*
|
|
@@ -271,18 +188,6 @@ async function writeEnvReflection(context, reflection, name = "env") {
|
|
|
271
188
|
(0, _powerlines_deepkit_capnp.convertToCapnp)(serialized, message.initRoot(_powerlines_deepkit_schemas_reflection.SerializedTypes)._initTypes(serialized.length));
|
|
272
189
|
await (0, _stryke_fs_buffer.writeFileBuffer)(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
273
190
|
}
|
|
274
|
-
writeEnvReflection.__type = [
|
|
275
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
276
|
-
"context",
|
|
277
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
278
|
-
"reflection",
|
|
279
|
-
() => require_types_plugin.__ΩEnvType,
|
|
280
|
-
"name",
|
|
281
|
-
() => "env",
|
|
282
|
-
"writeEnvReflection",
|
|
283
|
-
"Writes the environment reflection data to the file system.",
|
|
284
|
-
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
285
|
-
];
|
|
286
191
|
/**
|
|
287
192
|
* Writes the environment reflection data to the file system.
|
|
288
193
|
*
|
|
@@ -296,18 +201,6 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
|
|
|
296
201
|
(0, _powerlines_deepkit_capnp.convertToCapnp)(serialized, message.initRoot(_powerlines_deepkit_schemas_reflection.SerializedTypes)._initTypes(serialized.length));
|
|
297
202
|
(0, _stryke_fs_buffer.writeFileBufferSync)(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
298
203
|
}
|
|
299
|
-
writeEnvReflectionSync.__type = [
|
|
300
|
-
() => require_types_plugin.__ΩEnvPluginContext,
|
|
301
|
-
"context",
|
|
302
|
-
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
303
|
-
"reflection",
|
|
304
|
-
() => require_types_plugin.__ΩEnvType,
|
|
305
|
-
"name",
|
|
306
|
-
() => "env",
|
|
307
|
-
"writeEnvReflectionSync",
|
|
308
|
-
"Writes the environment reflection data to the file system.",
|
|
309
|
-
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
310
|
-
];
|
|
311
204
|
|
|
312
205
|
//#endregion
|
|
313
206
|
exports.getEnvDefaultTypeDefinition = getEnvDefaultTypeDefinition;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { __ΩEnvPluginContext, __ΩEnvPluginResolvedConfig, __ΩEnvType } from "../types/plugin.mjs";
|
|
2
1
|
import { createEnvReflection } from "./reflect.mjs";
|
|
3
|
-
import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
4
|
-
import { __ΩContext, __ΩUnresolvedContext } from "powerlines";
|
|
5
2
|
import { convertFromCapnp, convertToCapnp } from "@powerlines/deepkit/capnp";
|
|
6
3
|
import { getReflectionsPath } from "@powerlines/deepkit/resolve-reflections";
|
|
7
4
|
import { SerializedTypes } from "@powerlines/deepkit/schemas/reflection";
|
|
5
|
+
import { ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
8
6
|
import * as capnp from "@stryke/capnp";
|
|
9
7
|
import { readFileBuffer, writeFileBuffer, writeFileBufferSync } from "@stryke/fs/buffer";
|
|
10
8
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
@@ -23,14 +21,6 @@ async function resolveRuntimeTypeFile(context) {
|
|
|
23
21
|
if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
|
|
24
22
|
return resolved;
|
|
25
23
|
}
|
|
26
|
-
resolveRuntimeTypeFile.__type = [
|
|
27
|
-
() => __ΩUnresolvedContext,
|
|
28
|
-
() => __ΩEnvPluginResolvedConfig,
|
|
29
|
-
"context",
|
|
30
|
-
"resolveRuntimeTypeFile",
|
|
31
|
-
"Resolves the runtime type definition file for the environment variables.",
|
|
32
|
-
"Pn\"o!\"2#&`/$?%"
|
|
33
|
-
];
|
|
34
24
|
/**
|
|
35
25
|
* Gets the default type definition for the environment variables.
|
|
36
26
|
*
|
|
@@ -43,14 +33,6 @@ async function getEnvDefaultTypeDefinition(context) {
|
|
|
43
33
|
name: "EnvInterface"
|
|
44
34
|
};
|
|
45
35
|
}
|
|
46
|
-
getEnvDefaultTypeDefinition.__type = [
|
|
47
|
-
() => __ΩUnresolvedContext,
|
|
48
|
-
() => __ΩEnvPluginResolvedConfig,
|
|
49
|
-
"context",
|
|
50
|
-
"getEnvDefaultTypeDefinition",
|
|
51
|
-
"Gets the default type definition for the environment variables.",
|
|
52
|
-
"Pn\"o!\"2#!`/$?%"
|
|
53
|
-
];
|
|
54
36
|
/** Gets the default type definition for the environment secrets.
|
|
55
37
|
*
|
|
56
38
|
* @param context - The plugin context.
|
|
@@ -62,13 +44,6 @@ async function getSecretsDefaultTypeDefinition(context) {
|
|
|
62
44
|
name: "SecretsInterface"
|
|
63
45
|
};
|
|
64
46
|
}
|
|
65
|
-
getSecretsDefaultTypeDefinition.__type = [
|
|
66
|
-
() => __ΩUnresolvedContext,
|
|
67
|
-
() => __ΩEnvPluginResolvedConfig,
|
|
68
|
-
"context",
|
|
69
|
-
"getSecretsDefaultTypeDefinition",
|
|
70
|
-
"Pn\"o!\"2#!`/$"
|
|
71
|
-
];
|
|
72
47
|
/**
|
|
73
48
|
* Gets the path to the environment type reflections.
|
|
74
49
|
*
|
|
@@ -79,17 +54,6 @@ getSecretsDefaultTypeDefinition.__type = [
|
|
|
79
54
|
function getEnvTypeReflectionsPath(context, name = "env") {
|
|
80
55
|
return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
|
|
81
56
|
}
|
|
82
|
-
getEnvTypeReflectionsPath.__type = [
|
|
83
|
-
() => __ΩContext,
|
|
84
|
-
() => __ΩEnvPluginResolvedConfig,
|
|
85
|
-
"context",
|
|
86
|
-
() => __ΩEnvType,
|
|
87
|
-
"name",
|
|
88
|
-
() => "env",
|
|
89
|
-
"getEnvTypeReflectionsPath",
|
|
90
|
-
"Gets the path to the environment type reflections.",
|
|
91
|
-
"Pn\"o!\"2#n$2%>&&/'?("
|
|
92
|
-
];
|
|
93
57
|
/**
|
|
94
58
|
* Reads the environment type reflection from the file system.
|
|
95
59
|
*
|
|
@@ -118,17 +82,6 @@ async function readEnvTypeReflection(context, name = "env") {
|
|
|
118
82
|
context.env.types[name].dataBuffer = buffer;
|
|
119
83
|
return reflection;
|
|
120
84
|
}
|
|
121
|
-
readEnvTypeReflection.__type = [
|
|
122
|
-
() => __ΩEnvPluginContext,
|
|
123
|
-
"context",
|
|
124
|
-
() => __ΩEnvType,
|
|
125
|
-
"name",
|
|
126
|
-
() => "env",
|
|
127
|
-
() => ReflectionClass,
|
|
128
|
-
"readEnvTypeReflection",
|
|
129
|
-
"Reads the environment type reflection from the file system.",
|
|
130
|
-
"Pn!2\"n#2$>%P\"7&`/'?("
|
|
131
|
-
];
|
|
132
85
|
/**
|
|
133
86
|
* Writes the environment type reflection to the file system.
|
|
134
87
|
*
|
|
@@ -142,29 +95,9 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
|
|
|
142
95
|
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
143
96
|
await writeFileBuffer(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
|
|
144
97
|
}
|
|
145
|
-
writeEnvTypeReflection.__type = [
|
|
146
|
-
() => __ΩEnvPluginContext,
|
|
147
|
-
"context",
|
|
148
|
-
() => ReflectionClass,
|
|
149
|
-
"reflection",
|
|
150
|
-
() => __ΩEnvType,
|
|
151
|
-
"name",
|
|
152
|
-
() => "env",
|
|
153
|
-
"writeEnvTypeReflection",
|
|
154
|
-
"Writes the environment type reflection to the file system.",
|
|
155
|
-
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
156
|
-
];
|
|
157
98
|
function getEnvReflectionsPath(context, name) {
|
|
158
99
|
return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
|
|
159
100
|
}
|
|
160
|
-
getEnvReflectionsPath.__type = [
|
|
161
|
-
() => __ΩEnvPluginContext,
|
|
162
|
-
"context",
|
|
163
|
-
() => __ΩEnvType,
|
|
164
|
-
"name",
|
|
165
|
-
"getEnvReflectionsPath",
|
|
166
|
-
"Pn!2\"n#2$&/%"
|
|
167
|
-
];
|
|
168
101
|
/**
|
|
169
102
|
* Reads the environment reflection data from the file system.
|
|
170
103
|
*
|
|
@@ -202,14 +135,6 @@ async function readEnvReflection(context) {
|
|
|
202
135
|
context.env.used.env.dataBuffer = buffer;
|
|
203
136
|
return reflection;
|
|
204
137
|
}
|
|
205
|
-
readEnvReflection.__type = [
|
|
206
|
-
() => __ΩEnvPluginContext,
|
|
207
|
-
"context",
|
|
208
|
-
() => ReflectionClass,
|
|
209
|
-
"readEnvReflection",
|
|
210
|
-
"Reads the environment reflection data from the file system.",
|
|
211
|
-
"Pn!2\"P\"7#`/$?%"
|
|
212
|
-
];
|
|
213
138
|
/**
|
|
214
139
|
* Reads the secret environment reflection data from the file system.
|
|
215
140
|
*
|
|
@@ -247,14 +172,6 @@ async function readSecretsReflection(context) {
|
|
|
247
172
|
context.env.used.secrets.dataBuffer = buffer;
|
|
248
173
|
return reflection;
|
|
249
174
|
}
|
|
250
|
-
readSecretsReflection.__type = [
|
|
251
|
-
() => __ΩEnvPluginContext,
|
|
252
|
-
"context",
|
|
253
|
-
() => ReflectionClass,
|
|
254
|
-
"readSecretsReflection",
|
|
255
|
-
"Reads the secret environment reflection data from the file system.",
|
|
256
|
-
"Pn!2\"P\"7#`/$?%"
|
|
257
|
-
];
|
|
258
175
|
/**
|
|
259
176
|
* Writes the environment reflection data to the file system.
|
|
260
177
|
*
|
|
@@ -268,18 +185,6 @@ async function writeEnvReflection(context, reflection, name = "env") {
|
|
|
268
185
|
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
269
186
|
await writeFileBuffer(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
270
187
|
}
|
|
271
|
-
writeEnvReflection.__type = [
|
|
272
|
-
() => __ΩEnvPluginContext,
|
|
273
|
-
"context",
|
|
274
|
-
() => ReflectionClass,
|
|
275
|
-
"reflection",
|
|
276
|
-
() => __ΩEnvType,
|
|
277
|
-
"name",
|
|
278
|
-
() => "env",
|
|
279
|
-
"writeEnvReflection",
|
|
280
|
-
"Writes the environment reflection data to the file system.",
|
|
281
|
-
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
282
|
-
];
|
|
283
188
|
/**
|
|
284
189
|
* Writes the environment reflection data to the file system.
|
|
285
190
|
*
|
|
@@ -293,18 +198,6 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
|
|
|
293
198
|
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
294
199
|
writeFileBufferSync(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
295
200
|
}
|
|
296
|
-
writeEnvReflectionSync.__type = [
|
|
297
|
-
() => __ΩEnvPluginContext,
|
|
298
|
-
"context",
|
|
299
|
-
() => ReflectionClass,
|
|
300
|
-
"reflection",
|
|
301
|
-
() => __ΩEnvType,
|
|
302
|
-
"name",
|
|
303
|
-
() => "env",
|
|
304
|
-
"writeEnvReflectionSync",
|
|
305
|
-
"Writes the environment reflection data to the file system.",
|
|
306
|
-
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
307
|
-
];
|
|
308
201
|
|
|
309
202
|
//#endregion
|
|
310
203
|
export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,eAAiB,uBAAO,SAAA;CACxB,MAAS,WAAA,MAAA,QAA0B,GAAG,QAAQ,uCAAC;eAE7C,OAAA,IAAA,MAAA,0JAAA;AAED,QAAA;;AAED,uBAAuB,SAAM;OAAU;OAA0B;CAAS;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO1E,eAAG,4BA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AA;CAClC,MAAA,aAAY,WAAY,eAAe;CACzC,MAAA,UAAA,IAAA,MAAA,SAAA;AAEA,gBAAS,YADE,QAAS,SAAA,gBAAqB,CAChC,WAAA,WAAA,OAAA,CAAA;AACR,qBAAQ,sBAAsB,SAAA,KAAA,EAAA,QAAA,eAAA,CAAA;;AAEjC,uBAAkB,SAAW;OAAA;CAAA;OAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoDA,eAAsB,uBACpB,SACiB;CACjB,MAAM,WAAW,MAAM,QAAQ,GAAG,QAChC,uCACD;AACD,KAAI,CAAC,SACH,OAAM,IAAI,MACR,0JACD;AAGH,QAAO;;;;;;;;AAST,eAAsB,4BACpB,SACyB;AACzB,QAAO;EACL,MAAM,MAAM,uBAAuB,QAAQ;EAC3C,MAAM;EACP;;;;;;;AAQH,eAAsB,gCACpB,SACyB;AACzB,QAAO;EACL,MAAM,MAAM,uBAAuB,QAAQ;EAC3C,MAAM;EACP;;;;;;;;;AAUH,SAAgB,0BACd,SACA,OAAgB,OACR;AACR,QAAO,UAAU,mBAAmB,QAAQ,EAAE,OAAO,GAAG,KAAK,YA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