@cascade-flow/backend-factory 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +10 -0
- package/package.json +51 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Backend } from "@cascade-flow/backend-interface";
|
|
2
|
+
/**
|
|
3
|
+
* Create a backend instance based on environment variables
|
|
4
|
+
*
|
|
5
|
+
* Backend selection logic:
|
|
6
|
+
* - If POSTGRES_URL is set → PostgresBackend
|
|
7
|
+
* - Otherwise → FileSystemBackend
|
|
8
|
+
*
|
|
9
|
+
* Environment variables:
|
|
10
|
+
* - POSTGRES_URL: PostgreSQL connection string (e.g., postgres://user:pass@host:5432/db)
|
|
11
|
+
* - BACKEND_PATH: Filesystem backend storage path (default: ./.runs)
|
|
12
|
+
*
|
|
13
|
+
* @param options - Optional configuration
|
|
14
|
+
* @param options.baseDir - Override filesystem backend path (takes precedence over BACKEND_PATH env var)
|
|
15
|
+
* @returns Configured backend instance
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Use default backend (filesystem at ./.runs)
|
|
20
|
+
* const backend = createBackend();
|
|
21
|
+
*
|
|
22
|
+
* // Use filesystem with custom path
|
|
23
|
+
* const backend = createBackend({ baseDir: '/custom/path' });
|
|
24
|
+
*
|
|
25
|
+
* // Use Postgres (via POSTGRES_URL env var)
|
|
26
|
+
* // POSTGRES_URL="postgres://user:pass@localhost:5432/db"
|
|
27
|
+
* const backend = createBackend();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function createBackend(options?: {
|
|
31
|
+
baseDir?: string;
|
|
32
|
+
}): Backend;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAWrE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { FileSystemBackend } from "@cascade-flow/backend-filesystem";
|
|
3
|
+
import { PostgresBackend } from "@cascade-flow/backend-postgres";
|
|
4
|
+
function createBackend(options) {
|
|
5
|
+
const postgresUrl = process.env.POSTGRES_URL;
|
|
6
|
+
if (postgresUrl) {
|
|
7
|
+
return new PostgresBackend(postgresUrl);
|
|
8
|
+
}
|
|
9
|
+
const baseDir = options?.baseDir || process.env.BACKEND_PATH || "./.runs";
|
|
10
|
+
return new FileSystemBackend(baseDir);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
createBackend
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# debugId=E3551D172E44DAE164756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { Backend } from \"@cascade-flow/backend-interface\";\nimport { FileSystemBackend } from \"@cascade-flow/backend-filesystem\";\nimport { PostgresBackend } from \"@cascade-flow/backend-postgres\";\n\n/**\n * Create a backend instance based on environment variables\n *\n * Backend selection logic:\n * - If POSTGRES_URL is set → PostgresBackend\n * - Otherwise → FileSystemBackend\n *\n * Environment variables:\n * - POSTGRES_URL: PostgreSQL connection string (e.g., postgres://user:pass@host:5432/db)\n * - BACKEND_PATH: Filesystem backend storage path (default: ./.runs)\n *\n * @param options - Optional configuration\n * @param options.baseDir - Override filesystem backend path (takes precedence over BACKEND_PATH env var)\n * @returns Configured backend instance\n *\n * @example\n * ```typescript\n * // Use default backend (filesystem at ./.runs)\n * const backend = createBackend();\n *\n * // Use filesystem with custom path\n * const backend = createBackend({ baseDir: '/custom/path' });\n *\n * // Use Postgres (via POSTGRES_URL env var)\n * // POSTGRES_URL=\"postgres://user:pass@localhost:5432/db\"\n * const backend = createBackend();\n * ```\n */\nexport function createBackend(options?: { baseDir?: string }): Backend {\n const postgresUrl = process.env.POSTGRES_URL;\n\n if (postgresUrl) {\n // Use Postgres backend\n return new PostgresBackend(postgresUrl);\n }\n\n // Use Filesystem backend\n const baseDir = options?.baseDir || process.env.BACKEND_PATH || \"./.runs\";\n return new FileSystemBackend(baseDir);\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AACA;AACA;AA8BO,SAAS,aAAa,CAAC,SAAyC;AAAA,EACrE,MAAM,cAAc,QAAQ,IAAI;AAAA,EAEhC,IAAI,aAAa;AAAA,IAEf,OAAO,IAAI,gBAAgB,WAAW;AAAA,EACxC;AAAA,EAGA,MAAM,UAAU,SAAS,WAAW,QAAQ,IAAI,gBAAgB;AAAA,EAChE,OAAO,IAAI,kBAAkB,OAAO;AAAA;",
|
|
8
|
+
"debugId": "E3551D172E44DAE164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cascade-flow/backend-factory",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "rm -rf dist && bun build src/index.ts --outdir dist --target node --sourcemap=external --external=@cascade-flow/* && tsc -p tsconfig.build.json",
|
|
17
|
+
"prepublishOnly": "bun run build",
|
|
18
|
+
"test": "bun test"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@cascade-flow/backend-interface": "0.1.0",
|
|
22
|
+
"@cascade-flow/backend-filesystem": "0.1.0",
|
|
23
|
+
"@cascade-flow/backend-postgres": "0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/bun": "latest",
|
|
27
|
+
"typescript": "^5"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"typescript": "^5"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/cascadeflow/cascadeflow.git",
|
|
41
|
+
"directory": "packages/backend-factory"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"description": "Backend factory for CascadeFlow - creates configured backend instances",
|
|
45
|
+
"keywords": [
|
|
46
|
+
"workflow",
|
|
47
|
+
"orchestrator",
|
|
48
|
+
"backend",
|
|
49
|
+
"factory"
|
|
50
|
+
]
|
|
51
|
+
}
|