@coreframe/config 0.0.0 → 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/environment.d.ts +11 -0
- package/dist/environment.js +1 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.js +1 -0
- package/dist/worker.d.ts +46 -0
- package/dist/worker.js +1 -0
- package/package.json +33 -10
- package/readme.md +0 -1
|
@@ -0,0 +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)};export{n as fs,r as process};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { JsonObject, JsonValue, PrimaryWorkerContributions, PrimaryWorkerEnvironment, WorkerConfig, WorkerDeployEnvironment, WorkerEnvironmentDeclaration, WorkerEnvironmentKind, WorkerEnvironmentVariableConfig, WranglerConfig, coreframeGeneratedWorkerVariables, coreframeLocalWorkerVariables, coreframeManagedWorkerSecrets, derivePrimaryWorkerConfig, normalizeWorkerEnvironment, primaryWorkerConfigPath, primaryWorkerEnvironments, validateWorkerInventoryOwnership, workerBindingNames, wranglerEnvironmentNames } from "./worker.js";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type CoreframeConfig = {
|
|
5
|
+
assets?: AssetsConfig;
|
|
6
|
+
database?: DatabaseConfig;
|
|
7
|
+
deploy?: DeployConfig;
|
|
8
|
+
dev?: DevConfig;
|
|
9
|
+
i18n?: I18nConfig;
|
|
10
|
+
flutter?: FlutterConfig;
|
|
11
|
+
worker?: WorkerConfig;
|
|
12
|
+
};
|
|
13
|
+
type FlutterConfig = {
|
|
14
|
+
deepLink: FlutterDeepLinkConfig;
|
|
15
|
+
};
|
|
16
|
+
type FlutterDeepLinkConfig = {
|
|
17
|
+
host: string;
|
|
18
|
+
scheme: string;
|
|
19
|
+
};
|
|
20
|
+
type AssetsConfig = {
|
|
21
|
+
credentialProfile: string;
|
|
22
|
+
endpoint: string;
|
|
23
|
+
projectId: string;
|
|
24
|
+
publicBaseUrl: string;
|
|
25
|
+
publicBucket: string;
|
|
26
|
+
region: string;
|
|
27
|
+
sourceBucket: string;
|
|
28
|
+
};
|
|
29
|
+
type DatabaseDialect = "postgres" | "sqlite";
|
|
30
|
+
type DatabaseConfig = {
|
|
31
|
+
dialect: DatabaseDialect;
|
|
32
|
+
seed?: string;
|
|
33
|
+
};
|
|
34
|
+
type DevPlatform = "android" | "desktop" | "ios" | "macos" | "web" | "webext";
|
|
35
|
+
type DevConfig = {
|
|
36
|
+
platforms?: DevPlatform[];
|
|
37
|
+
};
|
|
38
|
+
type I18nConfig = {
|
|
39
|
+
catalogs: string[];
|
|
40
|
+
directory?: string;
|
|
41
|
+
generator?: {
|
|
42
|
+
args?: string[];
|
|
43
|
+
command: string;
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
46
|
+
locales: string[];
|
|
47
|
+
sourceLocale: string;
|
|
48
|
+
};
|
|
49
|
+
type DeployEnvironment = "staging" | "production";
|
|
50
|
+
type DeployContext = {
|
|
51
|
+
environment: DeployEnvironment;
|
|
52
|
+
releaseName: string;
|
|
53
|
+
url: string;
|
|
54
|
+
version: string;
|
|
55
|
+
};
|
|
56
|
+
type TauriReleasePlatform = "macos" | "windows" | "linux" | "ios" | "android";
|
|
57
|
+
type TauriReleasePlatformConfig = {
|
|
58
|
+
artifactGlobs?: string[];
|
|
59
|
+
buildArgs?: string[];
|
|
60
|
+
targetTriple?: string;
|
|
61
|
+
updatePlatform?: string;
|
|
62
|
+
};
|
|
63
|
+
type TauriReleaseConfig = {
|
|
64
|
+
artifactDownloadDir?: string;
|
|
65
|
+
b2Bucket?: string;
|
|
66
|
+
latestManifestPath?: string;
|
|
67
|
+
localPlatforms?: TauriReleasePlatform[];
|
|
68
|
+
platform?: Partial<Record<TauriReleasePlatform, TauriReleasePlatformConfig>>;
|
|
69
|
+
publicBaseUrl?: string;
|
|
70
|
+
publicPathPrefix?: string;
|
|
71
|
+
releaseNotesPath?: string;
|
|
72
|
+
releasePath?: string;
|
|
73
|
+
releaseUploadDir?: string;
|
|
74
|
+
workflowPlatforms?: TauriReleasePlatform[];
|
|
75
|
+
workflowName?: string;
|
|
76
|
+
workflowPollIntervalMs?: number;
|
|
77
|
+
workflowRef?: string;
|
|
78
|
+
workflowTimeoutMs?: number;
|
|
79
|
+
};
|
|
80
|
+
type DeploySmokeCheck = {
|
|
81
|
+
name: string;
|
|
82
|
+
path?: string;
|
|
83
|
+
url?: string;
|
|
84
|
+
expectedStatus?: "2xx" | number | number[];
|
|
85
|
+
};
|
|
86
|
+
type DeployEnvironmentConfig = {
|
|
87
|
+
url?: string;
|
|
88
|
+
};
|
|
89
|
+
type StagingHostnameConfig = {
|
|
90
|
+
managedLabelPrefix: string;
|
|
91
|
+
parentHostname: string;
|
|
92
|
+
workerService: string;
|
|
93
|
+
};
|
|
94
|
+
type DeployConfig = {
|
|
95
|
+
afterDeploy?: (context: DeployContext) => Promise<void> | void;
|
|
96
|
+
afterWorkerDeploy?: (context: DeployContext) => Promise<void> | void;
|
|
97
|
+
environments?: Partial<Record<DeployEnvironment, DeployEnvironmentConfig>>;
|
|
98
|
+
smokeChecks?: DeploySmokeCheck[];
|
|
99
|
+
stagingHostname?: StagingHostnameConfig;
|
|
100
|
+
tauriRelease?: TauriReleaseConfig;
|
|
101
|
+
};
|
|
102
|
+
declare function defineConfig(config: CoreframeConfig): CoreframeConfig;
|
|
103
|
+
declare function readProjectConfig({
|
|
104
|
+
cwd
|
|
105
|
+
}?: {
|
|
106
|
+
cwd?: string;
|
|
107
|
+
}): Promise<CoreframeConfig>;
|
|
108
|
+
declare function importProjectModule<T>(path: string): Promise<T>;
|
|
109
|
+
declare function importProjectDependency<T>(specifier: string, cwd?: string): Promise<T>;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { AssetsConfig, CoreframeConfig, DatabaseConfig, DatabaseDialect, DeployConfig, DeployContext, DeployEnvironment, DeployEnvironmentConfig, DeploySmokeCheck, DevConfig, DevPlatform, FlutterConfig, FlutterDeepLinkConfig, I18nConfig, JsonObject, JsonValue, PrimaryWorkerContributions, PrimaryWorkerEnvironment, StagingHostnameConfig, TauriReleaseConfig, TauriReleasePlatform, TauriReleasePlatformConfig, WorkerConfig, WorkerDeployEnvironment, WorkerEnvironmentDeclaration, WorkerEnvironmentKind, WorkerEnvironmentVariableConfig, WranglerConfig, coreframeGeneratedWorkerVariables, coreframeLocalWorkerVariables, coreframeManagedWorkerSecrets, defineConfig, derivePrimaryWorkerConfig, importProjectDependency, importProjectModule, normalizeWorkerEnvironment, primaryWorkerConfigPath, primaryWorkerEnvironments, readProjectConfig, validateWorkerInventoryOwnership, workerBindingNames, wranglerEnvironmentNames };
|
package/dist/index.js
ADDED
|
@@ -0,0 +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";function h(e){return e}async function g({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 _(e){return await import(p(f(t.cwd(),e)).href)}async function v(e,n=t.cwd()){return await import(m(e,p(f(n,`package.json`)).href))}export{n as coreframeGeneratedWorkerVariables,r as coreframeLocalWorkerVariables,i as coreframeManagedWorkerSecrets,h as defineConfig,a as derivePrimaryWorkerConfig,v as importProjectDependency,_ as importProjectModule,o as normalizeWorkerEnvironment,s as primaryWorkerConfigPath,c as primaryWorkerEnvironments,g as readProjectConfig,l as validateWorkerInventoryOwnership,u as workerBindingNames,d as wranglerEnvironmentNames};
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/worker.d.ts
|
|
2
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
|
|
3
|
+
type JsonObject = {
|
|
4
|
+
[key: string]: JsonValue;
|
|
5
|
+
};
|
|
6
|
+
declare const primaryWorkerConfigPath = "wrangler.jsonc";
|
|
7
|
+
declare const primaryWorkerEnvironments: readonly ["development", "staging", "production"];
|
|
8
|
+
declare const coreframeGeneratedWorkerVariables: readonly ["DEPLOY_ENV", "POSTHOG_RELEASE"];
|
|
9
|
+
declare const coreframeManagedWorkerSecrets: readonly ["COREFRAME_ACCESS_TOKEN_SECRET", "DASHBOARD_PASSWORD"];
|
|
10
|
+
declare const coreframeLocalWorkerVariables: readonly ["PGDATABASE", "PGHOST", "PGPASSWORD", "PGPORT", "PGUSER", "PORTLESS_URL", "TURSO_AUTH_TOKEN", "TURSO_DATABASE_URL"];
|
|
11
|
+
type PrimaryWorkerEnvironment = (typeof primaryWorkerEnvironments)[number];
|
|
12
|
+
type WorkerDeployEnvironment = Exclude<PrimaryWorkerEnvironment, "development">;
|
|
13
|
+
type WorkerEnvironmentKind = "secret" | "variable" | "generated";
|
|
14
|
+
type WorkerEnvironmentVariableConfig = {
|
|
15
|
+
description: string;
|
|
16
|
+
kind: WorkerEnvironmentKind;
|
|
17
|
+
requiredIn?: WorkerDeployEnvironment[];
|
|
18
|
+
};
|
|
19
|
+
type WorkerConfig = {
|
|
20
|
+
environment?: Record<string, WorkerEnvironmentVariableConfig>;
|
|
21
|
+
};
|
|
22
|
+
type WorkerEnvironmentDeclaration = WorkerEnvironmentVariableConfig & {
|
|
23
|
+
name: string;
|
|
24
|
+
requiredIn: WorkerDeployEnvironment[];
|
|
25
|
+
};
|
|
26
|
+
type WranglerConfig = JsonObject;
|
|
27
|
+
type PrimaryWorkerContributions = {
|
|
28
|
+
bindings?: JsonObject;
|
|
29
|
+
generatedValues?: Readonly<Record<string, string>>;
|
|
30
|
+
requiredSecrets?: readonly string[];
|
|
31
|
+
};
|
|
32
|
+
declare function normalizeWorkerEnvironment(environment: WorkerConfig["environment"]): WorkerEnvironmentDeclaration[];
|
|
33
|
+
declare function derivePrimaryWorkerConfig({
|
|
34
|
+
config,
|
|
35
|
+
environment,
|
|
36
|
+
contributions
|
|
37
|
+
}: {
|
|
38
|
+
config: WranglerConfig;
|
|
39
|
+
environment: PrimaryWorkerEnvironment;
|
|
40
|
+
contributions?: PrimaryWorkerContributions;
|
|
41
|
+
}): WranglerConfig;
|
|
42
|
+
declare function workerBindingNames(config: WranglerConfig): Set<string>;
|
|
43
|
+
declare function wranglerEnvironmentNames(config: WranglerConfig): Set<string>;
|
|
44
|
+
declare function validateWorkerInventoryOwnership(config: WranglerConfig, environment: WorkerConfig["environment"]): void;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { JsonObject, JsonValue, PrimaryWorkerContributions, PrimaryWorkerEnvironment, WorkerConfig, WorkerDeployEnvironment, WorkerEnvironmentDeclaration, WorkerEnvironmentKind, WorkerEnvironmentVariableConfig, WranglerConfig, coreframeGeneratedWorkerVariables, coreframeLocalWorkerVariables, coreframeManagedWorkerSecrets, derivePrimaryWorkerConfig, normalizeWorkerEnvironment, primaryWorkerConfigPath, primaryWorkerEnvironments, validateWorkerInventoryOwnership, workerBindingNames, wranglerEnvironmentNames };
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`wrangler.jsonc`,t=[`development`,`staging`,`production`],n=[`DEPLOY_ENV`,`POSTHOG_RELEASE`],r=[`COREFRAME_ACCESS_TOKEN_SECRET`,`DASHBOARD_PASSWORD`],i=[`PGDATABASE`,`PGHOST`,`PGPASSWORD`,`PGPORT`,`PGUSER`,`PORTLESS_URL`,`TURSO_AUTH_TOKEN`,`TURSO_DATABASE_URL`],a=/^[A-Z][A-Z0-9_]*$/;function o(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 r=[...new Set(t.requiredIn??[])];if(t.kind===`generated`&&!n.includes(e))throw Error(`${e} is declared as generated, but Coreframe does not generate it. Use kind "variable" or "secret".`);if(n.includes(e)&&t.kind!==`generated`)throw Error(`${e} is generated by Coreframe and must use kind "generated".`);return{...t,name:e,requiredIn:r}}).sort((e,t)=>e.name.localeCompare(t.name))}function s({config:e,environment:t,contributions:n={}}){let r=structuredClone(e),i=m(r.env,`env`),a=m(i[t],`env.${t}`),o=m(a.vars,`env.${t}.vars`),s=m(a.secrets,`env.${t}.secrets`),c=h(s.required,`env.${t}.secrets.required`),l=n.generatedValues??{},u=[...new Set(n.requiredSecrets??[])].sort();f(`variable`,Object.keys(o),Object.keys(l),t),f(`secret`,c,u,t);let g=n.bindings??{},{env:_,...v}=r,y=p(v,a),b=p(g);f(`binding`,[...y],[...b],t);let x=d(a,g,`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 c(e){return p(e)}function l(e){let t=p(e),n=e=>{if(!g(e))return;let n=g(e.vars)?e.vars:{};Object.keys(n).forEach(e=>t.add(e));let r=g(e.secrets)?e.secrets:{};(Array.isArray(r.required)?r.required:[]).forEach(e=>{typeof e==`string`&&t.add(e)})};return n(e),g(e.env)&&Object.values(e.env).forEach(n),t}function u(e,t){let n=o(t),r=new Map(n.map(e=>[e.name,e])),i=[...p(e)].filter(e=>r.has(e)).sort(),a=new Set,s=new Set,c=e=>{g(e)&&(g(e.vars)&&Object.keys(e.vars).forEach(e=>{r.get(e)?.kind===`secret`&&a.add(e)}),g(e.secrets)&&Array.isArray(e.secrets.required)&&e.secrets.required.forEach(e=>{typeof e==`string`&&r.get(e)?.kind!==`secret`&&r.has(e)&&s.add(e)}))};c(e),g(e.env)&&Object.values(e.env).forEach(c);let l=[...i.map(e=>`${e} (native binding)`),...[...a].sort().map(e=>`${e} (plain variable)`),...[...s].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 d(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 f(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 p(...e){let t=new Set,n=e=>{if(Array.isArray(e)){e.forEach(n);return}g(e)&&(typeof e.binding==`string`&&t.add(e.binding),Object.values(e).forEach(n))};return e.forEach(n),t}function m(e,t){if(e===void 0)return{};if(!g(e))throw Error(`${t} in wrangler.jsonc must be an object.`);return e}function h(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 g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{n as coreframeGeneratedWorkerVariables,i as coreframeLocalWorkerVariables,r as coreframeManagedWorkerSecrets,s as derivePrimaryWorkerConfig,o as normalizeWorkerEnvironment,e as primaryWorkerConfigPath,t as primaryWorkerEnvironments,u as validateWorkerInventoryOwnership,c as workerBindingNames,l as wranglerEnvironmentNames};
|
package/package.json
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/airlock-labs/coreframe.git",
|
|
7
|
+
"directory": "node/config"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"development": "./src/index.ts",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"import-meta-resolve": "^4.2.0"
|
|
8
22
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^26.1.0",
|
|
25
|
+
"tsdown": "0.22.3",
|
|
26
|
+
"typescript": "6.0.3",
|
|
27
|
+
"vitest": "^4.1.9"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsdown",
|
|
31
|
+
"test": "vitest run --reporter=minimal",
|
|
32
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
33
|
+
"format": "oxlint --fix && oxfmt",
|
|
34
|
+
"lint": "oxlint"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/readme.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Coming soon...
|