@coreframe/config 0.1.15-next.3 → 0.1.15

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.
@@ -6,7 +6,6 @@ declare const fs: {
6
6
  };
7
7
  declare const process: {
8
8
  cwd: () => string;
9
- env: NodeJS.ProcessEnv;
10
9
  };
11
10
  //#endregion
12
11
  export { fs, process };
@@ -1 +1 @@
1
- import{stat as e}from"node:fs/promises";import t from"node:process";const n={stat:e},r={cwd:t.cwd.bind(t),env:t.env};export{n as fs,r as process};
1
+ import{stat as e}from"node:fs/promises";import t from"node:process";const n={stat:e},r={cwd:t.cwd.bind(t)};export{n as fs,r as process};
package/dist/index.d.ts CHANGED
@@ -3,64 +3,17 @@ import { JsonObject, JsonValue, PrimaryWorkerContributions, PrimaryWorkerEnviron
3
3
  //#region src/index.d.ts
4
4
  type CoreframeConfig = {
5
5
  /** Object storage and public asset delivery settings. */assets?: AssetsConfig; /** Responsive layout breakpoints in logical CSS pixels. */
6
- breakpoints?: BreakpointsConfig; /** Database settings used by local and deployment workflows. */
6
+ breakpoints?: BreakpointsConfig; /** Dashboard build, development, and deployment settings. */
7
+ dashboard?: DashboardConfig; /** Database settings used by local and deployment workflows. */
7
8
  database?: DatabaseConfig; /** Deployment hooks, environments, checks, and release settings. */
8
- deploy?: DeployConfig; /** Explicitly enabled browser-extension lifecycle. */
9
- extension?: ExtensionConfig; /** Local development settings. */
9
+ deploy?: DeployConfig; /** Local development settings. */
10
10
  dev?: DevConfig; /** Translation catalog and locale settings. */
11
11
  i18n?: I18nConfig; /** Local development job inspection and reset settings. */
12
12
  jobs?: JobsConfig; /** Flutter host integration settings. */
13
13
  flutter?: FlutterConfig; /** Local preview server and tunnel settings. */
14
- preview?: PreviewConfig; /** Optional external secret source used by project workflows. */
15
- secrets?: SecretsConfig; /** Worker build and runtime settings. */
14
+ preview?: PreviewConfig; /** Worker build and runtime settings. */
16
15
  worker?: WorkerConfig;
17
16
  };
18
- declare const secretResolutionTargets: readonly ["development", "preview", "staging", "production"];
19
- type SecretResolutionTarget = (typeof secretResolutionTargets)[number];
20
- type SecretResolutionContext = {
21
- /** Project directory whose workflow is resolving secrets. */cwd: string; /** Environment inherited by the Coreframe workflow. */
22
- env: NodeJS.ProcessEnv; /** Lifecycle environment being resolved. */
23
- target: SecretResolutionTarget;
24
- };
25
- type SecretsAdapter = {
26
- /** Stable provider identifier used in value-free diagnostics. */id: string; /** Fetches one fresh target-specific snapshot. */
27
- resolve(context: SecretResolutionContext): Promise<Record<string, string>>;
28
- };
29
- type SecretsConfig = {
30
- /** External secret provider used by Coreframe workflows. */adapter: SecretsAdapter;
31
- };
32
- /** Resolves and validates one fresh provider snapshot when a project has opted in. */
33
- declare function resolveProjectSecrets({
34
- config,
35
- cwd,
36
- env,
37
- target
38
- }: {
39
- config: CoreframeConfig;
40
- cwd?: string;
41
- env?: NodeJS.ProcessEnv;
42
- target: SecretResolutionTarget;
43
- }): Promise<Record<string, string> | undefined>;
44
- type ExtensionStore = "chrome" | "edge" | "firefox";
45
- type ExtensionConfig = {
46
- /** WXT project used for builds and store operations. */wxt: {
47
- /** Project-relative WXT configuration file. */config: string; /** Directory in which WXT writes extension and source ZIPs. */
48
- outputDirectory?: string;
49
- }; /** Stores enabled for this extension. Omitted stores are never contacted. */
50
- stores: {
51
- chrome?: {
52
- extensionId?: string;
53
- publisherId?: string;
54
- };
55
- edge?: {
56
- productId?: string;
57
- };
58
- firefox?: {
59
- channel?: "listed" | "unlisted";
60
- extensionId?: string;
61
- };
62
- };
63
- };
64
17
  /** Named responsive layout breakpoints shared by Panda, web, and Flutter. */
65
18
  type BreakpointsConfig = Readonly<{
66
19
  "2xl": number;
@@ -95,23 +48,14 @@ type AssetsConfig = {
95
48
  region: string; /** Bucket containing original source assets. */
96
49
  sourceBucket: string;
97
50
  };
51
+ type DashboardConfig = {
52
+ /** Whether the project builds, develops, and deploys the Coreframe dashboard. Defaults to true. */enabled?: boolean;
53
+ };
98
54
  type DatabaseDialect = "postgres" | "sqlite";
99
55
  type DatabaseConfig = {
100
- /** Database engine used by project workflows. */dialect: DatabaseDialect; /** Explicit credential references for standalone and deploy-time database migrations. */
101
- environments?: Partial<Record<"staging" | "production", DatabaseEnvironmentConfig>>; /** Project-relative module that seeds the database. */
56
+ /** Database engine used by project workflows. */dialect: DatabaseDialect; /** Project-relative module that seeds the database. */
102
57
  seed?: string;
103
58
  };
104
- type DatabaseEnvironmentConfig = {
105
- /** Environment variable containing the database URL. */urlEnv: string; /** Environment variable containing the libSQL authentication token. */
106
- authTokenEnv?: string; /** PostgreSQL TLS options. URL query parameters remain supported. */
107
- tls?: boolean | DatabaseTlsConfig;
108
- };
109
- type DatabaseTlsConfig = {
110
- caEnv?: string;
111
- certEnv?: string;
112
- keyEnv?: string;
113
- rejectUnauthorized?: boolean;
114
- };
115
59
  type JobsConfig = {
116
60
  /** Project-relative module exporting the local development job administration contract. */entry: string;
117
61
  };
@@ -269,4 +213,4 @@ declare function readProjectConfig({
269
213
  declare function importProjectModule<T>(path: string, cwd?: string): Promise<T>;
270
214
  declare function importProjectDependency<T>(specifier: string, cwd?: string): Promise<T>;
271
215
  //#endregion
272
- export { AssetsConfig, BreakpointsConfig, CoreframeConfig, DatabaseConfig, DatabaseDialect, DatabaseEnvironmentConfig, DatabaseTlsConfig, DeployConfig, DeployContext, DeployEnvironment, DeployEnvironmentConfig, DeployMode, DeploySmokeCheck, DevConfig, DevPlatform, ExtensionConfig, ExtensionStore, FlutterConfig, FlutterDeepLinkConfig, I18nConfig, JobsConfig, JsonObject, JsonValue, PreviewAccessBypassConfig, PreviewAccessConfig, PreviewAccessIpContext, PreviewAccessIpResolver, PreviewConfig, PreviewTunnelConfig, PreviewWorkerConfig, PrimaryWorkerContributions, PrimaryWorkerEnvironment, SecretResolutionContext, SecretResolutionTarget, SecretsAdapter, SecretsConfig, StagingHostnameConfig, WorkerConfig, WorkerDeployEnvironment, WorkerEnvironmentDeclaration, WorkerEnvironmentKind, WorkerEnvironmentVariableConfig, WranglerConfig, breakpointNames, coreframeGeneratedWorkerVariables, coreframeLocalWorkerVariables, coreframeManagedWorkerSecrets, defineConfig, derivePrimaryWorkerConfig, importProjectDependency, importProjectModule, normalizeWorkerEnvironment, primaryWorkerConfigPath, primaryWorkerEnvironments, readProjectBreakpoints, readProjectConfig, resolveProjectSecrets, secretResolutionTargets, validateBreakpoints, validateWorkerInventoryOwnership, workerBindingNames, wranglerEnvironmentNames };
216
+ export { AssetsConfig, BreakpointsConfig, CoreframeConfig, DashboardConfig, DatabaseConfig, DatabaseDialect, DeployConfig, DeployContext, DeployEnvironment, DeployEnvironmentConfig, DeployMode, DeploySmokeCheck, DevConfig, DevPlatform, FlutterConfig, FlutterDeepLinkConfig, I18nConfig, JobsConfig, JsonObject, JsonValue, PreviewAccessBypassConfig, PreviewAccessConfig, PreviewAccessIpContext, PreviewAccessIpResolver, PreviewConfig, PreviewTunnelConfig, PreviewWorkerConfig, PrimaryWorkerContributions, PrimaryWorkerEnvironment, StagingHostnameConfig, WorkerConfig, WorkerDeployEnvironment, WorkerEnvironmentDeclaration, WorkerEnvironmentKind, WorkerEnvironmentVariableConfig, WranglerConfig, breakpointNames, coreframeGeneratedWorkerVariables, coreframeLocalWorkerVariables, coreframeManagedWorkerSecrets, defineConfig, derivePrimaryWorkerConfig, importProjectDependency, importProjectModule, normalizeWorkerEnvironment, primaryWorkerConfigPath, primaryWorkerEnvironments, readProjectBreakpoints, readProjectConfig, validateBreakpoints, validateWorkerInventoryOwnership, workerBindingNames, wranglerEnvironmentNames };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{fs as e,process as t}from"./environment.js";import{coreframeGeneratedWorkerVariables as n,coreframeLocalWorkerVariables as r,coreframeManagedWorkerSecrets as i,derivePrimaryWorkerConfig as a,normalizeWorkerEnvironment as o,primaryWorkerConfigPath as s,primaryWorkerEnvironments as c,validateWorkerInventoryOwnership as l,workerBindingNames as u,wranglerEnvironmentNames as d}from"./worker.js";import{resolve as f}from"node:path";import{pathToFileURL as p}from"node:url";import{resolve as m}from"import-meta-resolve";const h=[`development`,`preview`,`staging`,`production`],g=/^[A-Z][A-Z0-9_]*$/,_=new Set([`COREFRAME_ACCESS_TOKEN_SECRET`,`COREFRAME_LOCAL_POSTGRES`,`COREFRAME_LOCAL_TURSO`,`DOPPLER_TOKEN`]);async function v({config:e,cwd:n=t.cwd(),env:r=t.env,target:i}){let a=e.secrets?.adapter;if(!a)return;if(!a.id?.trim()||typeof a.resolve!=`function`)throw Error(`coreframe.config.ts secrets.adapter must define an id and resolve function.`);let o=await a.resolve({cwd:n,env:r,target:i});if(typeof o!=`object`||!o||Array.isArray(o)||!Object.entries(o).every(([e,t])=>g.test(e)&&typeof t==`string`))throw Error(`${a.id} returned an invalid ${i} secret snapshot.`);let s=Object.keys(o).filter(e=>_.has(e));if(s.length>0)throw Error(`${a.id} returned framework-owned or provider authentication values: ${s.sort().join(`, `)}.`);let c=Object.entries(e.worker?.environment??{}).filter(([e,t])=>e.startsWith(`VITE_`)&&t.kind===`secret`&&o[e]!==void 0).map(([e])=>e);if(c.length>0)throw Error(`Provider Worker secrets cannot use the public VITE_ prefix: ${c.sort().join(`, `)}.`);return{...o}}const y=[`sm`,`md`,`lg`,`xl`,`2xl`];function b(e){return e.breakpoints!==void 0&&x(e.breakpoints),e}function x(e){if(!C(e))throw Error(`coreframe.config.ts must configure breakpoints.sm, md, lg, xl, and 2xl as positive finite numbers.`);let t=Object.keys(e).sort(),n=[...y].sort();if(t.length!==n.length||t.some((e,t)=>e!==n[t]))throw Error(`coreframe.config.ts breakpoints must contain only sm, md, lg, xl, and 2xl.`);let r=0;for(let t of y){let n=e[t];if(typeof n!=`number`||!Number.isFinite(n)||n<=0)throw Error(`coreframe.config.ts breakpoints.${t} must be a positive finite number of logical pixels.`);if(n<=r)throw Error(`coreframe.config.ts breakpoints must increase strictly from sm through 2xl; breakpoints.${t} is not greater than the preceding value.`);r=n}return e}async function S({cwd:e=t.cwd()}={}){let n=await w({cwd:e});if(n.breakpoints===void 0)throw Error(`coreframe.config.ts must configure breakpoints.sm, md, lg, xl, and 2xl as positive finite numbers.`);return x(n.breakpoints)}function C(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}async function w({cwd:n=t.cwd()}={}){let r=f(n,`coreframe.config.ts`),i;try{i=(await e.stat(r,{bigint:!0})).mtimeNs}catch{return{}}let a=p(r);return a.searchParams.set(`modified`,i.toString()),(await import(a.href)).default??{}}async function T(e,n=t.cwd()){return await import(p(f(n,e)).href)}async function E(e,n=t.cwd()){return await import(m(e,p(f(n,`package.json`)).href))}export{y as breakpointNames,n as coreframeGeneratedWorkerVariables,r as coreframeLocalWorkerVariables,i as coreframeManagedWorkerSecrets,b as defineConfig,a as derivePrimaryWorkerConfig,E as importProjectDependency,T as importProjectModule,o as normalizeWorkerEnvironment,s as primaryWorkerConfigPath,c as primaryWorkerEnvironments,S as readProjectBreakpoints,w as readProjectConfig,v as resolveProjectSecrets,h as secretResolutionTargets,x as validateBreakpoints,l as validateWorkerInventoryOwnership,u as workerBindingNames,d as wranglerEnvironmentNames};
1
+ import{fs as e,process as t}from"./environment.js";import{coreframeGeneratedWorkerVariables as n,coreframeLocalWorkerVariables as r,coreframeManagedWorkerSecrets as i,derivePrimaryWorkerConfig as a,normalizeWorkerEnvironment as o,primaryWorkerConfigPath as s,primaryWorkerEnvironments as c,validateWorkerInventoryOwnership as l,workerBindingNames as u,wranglerEnvironmentNames as d}from"./worker.js";import{resolve as f}from"node:path";import{pathToFileURL as p}from"node:url";import{resolve as m}from"import-meta-resolve";const h=[`sm`,`md`,`lg`,`xl`,`2xl`];function g(e){return e.breakpoints!==void 0&&_(e.breakpoints),e}function _(e){if(!y(e))throw Error(`coreframe.config.ts must configure breakpoints.sm, md, lg, xl, and 2xl as positive finite numbers.`);let t=Object.keys(e).sort(),n=[...h].sort();if(t.length!==n.length||t.some((e,t)=>e!==n[t]))throw Error(`coreframe.config.ts breakpoints must contain only sm, md, lg, xl, and 2xl.`);let r=0;for(let t of h){let n=e[t];if(typeof n!=`number`||!Number.isFinite(n)||n<=0)throw Error(`coreframe.config.ts breakpoints.${t} must be a positive finite number of logical pixels.`);if(n<=r)throw Error(`coreframe.config.ts breakpoints must increase strictly from sm through 2xl; breakpoints.${t} is not greater than the preceding value.`);r=n}return e}async function v({cwd:e=t.cwd()}={}){let n=await b({cwd:e});if(n.breakpoints===void 0)throw Error(`coreframe.config.ts must configure breakpoints.sm, md, lg, xl, and 2xl as positive finite numbers.`);return _(n.breakpoints)}function y(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}async function b({cwd:n=t.cwd()}={}){let r=f(n,`coreframe.config.ts`),i;try{i=(await e.stat(r,{bigint:!0})).mtimeNs}catch{return{}}let a=p(r);return a.searchParams.set(`modified`,i.toString()),(await import(a.href)).default??{}}async function x(e,n=t.cwd()){return await import(p(f(n,e)).href)}async function S(e,n=t.cwd()){return await import(m(e,p(f(n,`package.json`)).href))}export{h as breakpointNames,n as coreframeGeneratedWorkerVariables,r as coreframeLocalWorkerVariables,i as coreframeManagedWorkerSecrets,g as defineConfig,a as derivePrimaryWorkerConfig,S as importProjectDependency,x as importProjectModule,o as normalizeWorkerEnvironment,s as primaryWorkerConfigPath,c as primaryWorkerEnvironments,v as readProjectBreakpoints,b as readProjectConfig,_ as validateBreakpoints,l as validateWorkerInventoryOwnership,u as workerBindingNames,d as wranglerEnvironmentNames};
package/dist/worker.d.ts CHANGED
@@ -7,7 +7,7 @@ declare const primaryWorkerConfigPath = "wrangler.jsonc";
7
7
  declare const primaryWorkerEnvironments: readonly ["development", "staging", "production"];
8
8
  declare const coreframeGeneratedWorkerVariables: readonly ["DEPLOY_ENV", "POSTHOG_RELEASE"];
9
9
  declare const coreframeManagedWorkerSecrets: readonly ["COREFRAME_ACCESS_TOKEN_SECRET", "DASHBOARD_PASSWORD"];
10
- declare const coreframeLocalWorkerVariables: readonly ["COREFRAME_DEV_JOBS_TOKEN", "COREFRAME_DEV_SESSION_ID", "PGDATABASE", "PGHOST", "PGPASSWORD", "PGPORT", "PGUSER", "PORTLESS_URL", "TURSO_AUTH_TOKEN", "TURSO_DATABASE_URL"];
10
+ declare const coreframeLocalWorkerVariables: readonly ["COREFRAME_DEV_JOBS_TOKEN", "PGDATABASE", "PGHOST", "PGPASSWORD", "PGPORT", "PGUSER", "PORTLESS_URL", "TURSO_AUTH_TOKEN", "TURSO_DATABASE_URL"];
11
11
  type PrimaryWorkerEnvironment = (typeof primaryWorkerEnvironments)[number];
12
12
  type WorkerDeployEnvironment = Exclude<PrimaryWorkerEnvironment, "development">;
13
13
  type WorkerEnvironmentKind = "secret" | "variable" | "generated";
package/dist/worker.js CHANGED
@@ -1 +1 @@
1
- const e=`wrangler.jsonc`,t=[`development`,`staging`,`production`],n=[`DEPLOY_ENV`,`POSTHOG_RELEASE`],r=[`COREFRAME_ACCESS_TOKEN_SECRET`,`DASHBOARD_PASSWORD`],i=[`COREFRAME_DEV_JOBS_TOKEN`,`COREFRAME_DEV_SESSION_ID`,`PGDATABASE`,`PGHOST`,`PGPASSWORD`,`PGPORT`,`PGUSER`,`PORTLESS_URL`,`TURSO_AUTH_TOKEN`,`TURSO_DATABASE_URL`],a=/^[A-Z][A-Z0-9_]*$/;function o(e){return n.some(t=>t===e)}function s(e){return Object.entries(e??{}).map(([e,t])=>{if(!a.test(e))throw Error(`Invalid Worker environment name ${JSON.stringify(e)} in coreframe.config.ts. Use uppercase letters, numbers, and underscores.`);let n=[...new Set(t.requiredIn??[])];if(t.kind===`generated`&&!o(e))throw Error(`${e} is declared as generated, but Coreframe does not generate it. Use kind "variable" or "secret".`);if(o(e)&&t.kind!==`generated`)throw Error(`${e} is generated by Coreframe and must use kind "generated".`);return{...t,name:e,requiredIn:n}}).sort((e,t)=>e.name.localeCompare(t.name))}function c({config:e,environment:t,contributions:n={}}){let r=structuredClone(e),i=h(r.env,`env`),a=h(i[t],`env.${t}`),o=h(a.vars,`env.${t}.vars`),s=h(a.secrets,`env.${t}.secrets`),c=g(s.required,`env.${t}.secrets.required`),l=n.generatedValues??{},u=[...new Set(n.requiredSecrets??[])].sort();p(`variable`,Object.keys(o),Object.keys(l),t),p(`secret`,c,u,t);let d=n.bindings??{},{env:_,...v}=r,y=m(v,a),b=m(d);p(`binding`,[...y],[...b],t);let x=f(a,d,`env.${t}`);return Object.keys(l).length>0&&(x.vars={...o,...l}),u.length>0&&(x.secrets={...s,required:[...c,...u].sort()}),r.env={...i,[t]:x},r}function l(e){return m(e)}function u(e){let t=m(e),n=e=>{if(!_(e))return;let n=_(e.vars)?e.vars:{};Object.keys(n).forEach(e=>t.add(e));let r=_(e.secrets)?e.secrets:{};(Array.isArray(r.required)?r.required:[]).forEach(e=>{typeof e==`string`&&t.add(e)})};return n(e),_(e.env)&&Object.values(e.env).forEach(n),t}function d(e,t){let n=s(t),r=new Map(n.map(e=>[e.name,e])),i=[...m(e)].filter(e=>r.has(e)).sort(),a=new Set,o=new Set,c=e=>{_(e)&&(_(e.vars)&&Object.keys(e.vars).forEach(e=>{r.get(e)?.kind===`secret`&&a.add(e)}),_(e.secrets)&&Array.isArray(e.secrets.required)&&e.secrets.required.forEach(e=>{typeof e==`string`&&r.get(e)?.kind!==`secret`&&r.has(e)&&o.add(e)}))};c(e),_(e.env)&&Object.values(e.env).forEach(c);let l=[...i.map(e=>`${e} (native binding)`),...[...a].sort().map(e=>`${e} (plain variable)`),...[...o].sort().map(e=>`${e} (required secret)`)];if(l.length>0)throw Error(`Worker inventory ownership conflicts with wrangler.jsonc: ${l.join(`, `)}. Keep string metadata in coreframe.config.ts and native binding topology in wrangler.jsonc.`)}function f(e,t,n){let r={...e};for(let[i,a]of Object.entries(t)){if(i in e)throw Error(`Coreframe cannot contribute ${n}.${i}; wrangler.jsonc already owns it.`);r[i]=structuredClone(a)}return r}function p(e,t,n,r){let i=n.filter(e=>t.includes(e)).sort();if(i.length>0)throw Error(`Coreframe ${e} ownership conflicts in Wrangler environment ${r}: ${i.join(`, `)}. Remove the duplicate declarations from wrangler.jsonc.`)}function m(...e){let t=new Set,n=e=>{if(Array.isArray(e)){e.forEach(n);return}_(e)&&(typeof e.binding==`string`&&t.add(e.binding),Object.values(e).forEach(n))};return e.forEach(n),t}function h(e,t){if(e===void 0)return{};if(!_(e))throw Error(`${t} in wrangler.jsonc must be an object.`);return e}function g(e,t){if(e===void 0)return[];if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`${t} in wrangler.jsonc must be an array of strings.`);return e}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{n as coreframeGeneratedWorkerVariables,i as coreframeLocalWorkerVariables,r as coreframeManagedWorkerSecrets,c as derivePrimaryWorkerConfig,s as normalizeWorkerEnvironment,e as primaryWorkerConfigPath,t as primaryWorkerEnvironments,d as validateWorkerInventoryOwnership,l as workerBindingNames,u as wranglerEnvironmentNames};
1
+ const e=`wrangler.jsonc`,t=[`development`,`staging`,`production`],n=[`DEPLOY_ENV`,`POSTHOG_RELEASE`],r=[`COREFRAME_ACCESS_TOKEN_SECRET`,`DASHBOARD_PASSWORD`],i=[`COREFRAME_DEV_JOBS_TOKEN`,`PGDATABASE`,`PGHOST`,`PGPASSWORD`,`PGPORT`,`PGUSER`,`PORTLESS_URL`,`TURSO_AUTH_TOKEN`,`TURSO_DATABASE_URL`],a=/^[A-Z][A-Z0-9_]*$/;function o(e){return n.some(t=>t===e)}function s(e){return Object.entries(e??{}).map(([e,t])=>{if(!a.test(e))throw Error(`Invalid Worker environment name ${JSON.stringify(e)} in coreframe.config.ts. Use uppercase letters, numbers, and underscores.`);let n=[...new Set(t.requiredIn??[])];if(t.kind===`generated`&&!o(e))throw Error(`${e} is declared as generated, but Coreframe does not generate it. Use kind "variable" or "secret".`);if(o(e)&&t.kind!==`generated`)throw Error(`${e} is generated by Coreframe and must use kind "generated".`);return{...t,name:e,requiredIn:n}}).sort((e,t)=>e.name.localeCompare(t.name))}function c({config:e,environment:t,contributions:n={}}){let r=structuredClone(e),i=h(r.env,`env`),a=h(i[t],`env.${t}`),o=h(a.vars,`env.${t}.vars`),s=h(a.secrets,`env.${t}.secrets`),c=g(s.required,`env.${t}.secrets.required`),l=n.generatedValues??{},u=[...new Set(n.requiredSecrets??[])].sort();p(`variable`,Object.keys(o),Object.keys(l),t),p(`secret`,c,u,t);let d=n.bindings??{},{env:_,...v}=r,y=m(v,a),b=m(d);p(`binding`,[...y],[...b],t);let x=f(a,d,`env.${t}`);return Object.keys(l).length>0&&(x.vars={...o,...l}),u.length>0&&(x.secrets={...s,required:[...c,...u].sort()}),r.env={...i,[t]:x},r}function l(e){return m(e)}function u(e){let t=m(e),n=e=>{if(!_(e))return;let n=_(e.vars)?e.vars:{};Object.keys(n).forEach(e=>t.add(e));let r=_(e.secrets)?e.secrets:{};(Array.isArray(r.required)?r.required:[]).forEach(e=>{typeof e==`string`&&t.add(e)})};return n(e),_(e.env)&&Object.values(e.env).forEach(n),t}function d(e,t){let n=s(t),r=new Map(n.map(e=>[e.name,e])),i=[...m(e)].filter(e=>r.has(e)).sort(),a=new Set,o=new Set,c=e=>{_(e)&&(_(e.vars)&&Object.keys(e.vars).forEach(e=>{r.get(e)?.kind===`secret`&&a.add(e)}),_(e.secrets)&&Array.isArray(e.secrets.required)&&e.secrets.required.forEach(e=>{typeof e==`string`&&r.get(e)?.kind!==`secret`&&r.has(e)&&o.add(e)}))};c(e),_(e.env)&&Object.values(e.env).forEach(c);let l=[...i.map(e=>`${e} (native binding)`),...[...a].sort().map(e=>`${e} (plain variable)`),...[...o].sort().map(e=>`${e} (required secret)`)];if(l.length>0)throw Error(`Worker inventory ownership conflicts with wrangler.jsonc: ${l.join(`, `)}. Keep string metadata in coreframe.config.ts and native binding topology in wrangler.jsonc.`)}function f(e,t,n){let r={...e};for(let[i,a]of Object.entries(t)){if(i in e)throw Error(`Coreframe cannot contribute ${n}.${i}; wrangler.jsonc already owns it.`);r[i]=structuredClone(a)}return r}function p(e,t,n,r){let i=n.filter(e=>t.includes(e)).sort();if(i.length>0)throw Error(`Coreframe ${e} ownership conflicts in Wrangler environment ${r}: ${i.join(`, `)}. Remove the duplicate declarations from wrangler.jsonc.`)}function m(...e){let t=new Set,n=e=>{if(Array.isArray(e)){e.forEach(n);return}_(e)&&(typeof e.binding==`string`&&t.add(e.binding),Object.values(e).forEach(n))};return e.forEach(n),t}function h(e,t){if(e===void 0)return{};if(!_(e))throw Error(`${t} in wrangler.jsonc must be an object.`);return e}function g(e,t){if(e===void 0)return[];if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`${t} in wrangler.jsonc must be an array of strings.`);return e}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{n as coreframeGeneratedWorkerVariables,i as coreframeLocalWorkerVariables,r as coreframeManagedWorkerSecrets,c as derivePrimaryWorkerConfig,s as normalizeWorkerEnvironment,e as primaryWorkerConfigPath,t as primaryWorkerEnvironments,d as validateWorkerInventoryOwnership,l as workerBindingNames,u as wranglerEnvironmentNames};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/config",
3
- "version": "0.1.15-next.3",
3
+ "version": "0.1.15",
4
4
  "description": "Environment and project configuration utilities for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",