@tomflow/proflow-platform-cli 0.1.9 → 0.1.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tomflow/proflow-platform-cli
2
2
 
3
+ ## 0.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Fail closed on malformed persisted module config instead of treating it as missing configuration.
8
+
3
9
  ## 0.1.9
4
10
 
5
11
  ### Patch Changes
@@ -5,7 +5,7 @@ export declare const behaviorAdapter: {
5
5
  ok: boolean;
6
6
  status: "SUCCEEDED";
7
7
  moduleRef: "platform-cli";
8
- moduleVersion: "0.1.9";
8
+ moduleVersion: "0.1.10";
9
9
  data?: {} | null;
10
10
  };
11
11
  observedEffects: never[];
@@ -16,7 +16,7 @@ export declare const behaviorAdapter: {
16
16
  ok: boolean;
17
17
  status: "SUCCEEDED";
18
18
  moduleRef: "platform-cli";
19
- moduleVersion: "0.1.9";
19
+ moduleVersion: "0.1.10";
20
20
  data?: {} | null;
21
21
  };
22
22
  observedEffects: never[];
@@ -27,7 +27,7 @@ export declare const behaviorAdapter: {
27
27
  ok: boolean;
28
28
  status: "SUCCEEDED";
29
29
  moduleRef: "platform-cli";
30
- moduleVersion: "0.1.9";
30
+ moduleVersion: "0.1.10";
31
31
  data?: {} | null;
32
32
  };
33
33
  observedEffects: never[];
@@ -38,7 +38,7 @@ export declare const behaviorAdapter: {
38
38
  ok: boolean;
39
39
  status: "SUCCEEDED";
40
40
  moduleRef: "platform-cli";
41
- moduleVersion: "0.1.9";
41
+ moduleVersion: "0.1.10";
42
42
  data?: {} | null;
43
43
  };
44
44
  observedEffects: never[];
@@ -49,7 +49,7 @@ export declare const behaviorAdapter: {
49
49
  ok: boolean;
50
50
  status: "SUCCEEDED";
51
51
  moduleRef: "platform-cli";
52
- moduleVersion: "0.1.9";
52
+ moduleVersion: "0.1.10";
53
53
  data?: {} | null;
54
54
  };
55
55
  observedEffects: never[];
@@ -3,7 +3,7 @@ export declare const descriptor: {
3
3
  readonly contractVersion: "1.0.0";
4
4
  readonly moduleRef: "platform-cli";
5
5
  readonly packageName: "@tomflow/proflow-platform-cli";
6
- readonly moduleVersion: "0.1.9";
6
+ readonly moduleVersion: "0.1.10";
7
7
  readonly kind: "cli";
8
8
  readonly templateVersion: "1.0.0";
9
9
  readonly platformCompatibility: ">=1.0.0 <2.0.0";
@@ -3,7 +3,7 @@ export const descriptor = {
3
3
  contractVersion: "1.0.0",
4
4
  moduleRef: "platform-cli",
5
5
  packageName: "@tomflow/proflow-platform-cli",
6
- moduleVersion: "0.1.9",
6
+ moduleVersion: "0.1.10",
7
7
  kind: "cli",
8
8
  templateVersion: "1.0.0",
9
9
  platformCompatibility: ">=1.0.0 <2.0.0",
@@ -1,4 +1,4 @@
1
- import { type WorkspacePaths } from "../paths.ts";
1
+ import type { WorkspacePaths } from "../paths.ts";
2
2
  export interface MaterializedConfig {
3
3
  publicValues: Record<string, string>;
4
4
  secretValues: Record<string, string>;
@@ -1,5 +1,6 @@
1
+ import { readFile } from "node:fs/promises";
1
2
  import { join } from "node:path";
2
- import { readJson } from "../paths.js";
3
+ import { PlatformError } from "../errors.js";
3
4
  import { writeJsonAtomic } from "./atomic.js";
4
5
  import { assertSafeFileName } from "./guards.js";
5
6
  function configFilePath(paths, moduleRef) {
@@ -16,6 +17,32 @@ function isStringMap(value) {
16
17
  }
17
18
  return Object.values(value).every((item) => typeof item === "string");
18
19
  }
20
+ function isMissingFile(error) {
21
+ return (typeof error === "object" &&
22
+ error !== null &&
23
+ "code" in error &&
24
+ error.code === "ENOENT");
25
+ }
26
+ async function readConfigValues(file, moduleRef, kind) {
27
+ let raw;
28
+ try {
29
+ raw = await readFile(file, "utf8");
30
+ }
31
+ catch (error) {
32
+ if (isMissingFile(error))
33
+ return undefined;
34
+ throw new PlatformError("CONFIG_INVALID", `cannot read ${kind} config for ${moduleRef}: ${error instanceof Error ? error.message : String(error)}`);
35
+ }
36
+ try {
37
+ const parsed = JSON.parse(raw);
38
+ if (!isStringMap(parsed))
39
+ throw new TypeError("expected a JSON object whose values are strings");
40
+ return parsed;
41
+ }
42
+ catch (error) {
43
+ throw new PlatformError("CONFIG_INVALID", `${kind} config for ${moduleRef} is invalid JSON/config: ${error instanceof Error ? error.message : String(error)}`);
44
+ }
45
+ }
19
46
  // secretRef config values are opaque reference identities (e.g.
20
47
  // `secret://model-provider/default`), not raw secrets, so they materialize to
21
48
  // the public config file verbatim. A raw secret would go to the separate 0o600
@@ -30,10 +57,8 @@ export async function materializeConfig(paths, config) {
30
57
  await writeJsonAtomic(secretsFilePath(paths, config.moduleRef), {}, 0o600);
31
58
  }
32
59
  export async function loadConfig(paths, moduleRef) {
33
- const publicRaw = await readJson(configFilePath(paths, moduleRef));
34
- const secretRaw = await readJson(secretsFilePath(paths, moduleRef));
35
- const publicValues = isStringMap(publicRaw) ? publicRaw : undefined;
36
- const secretValues = isStringMap(secretRaw) ? secretRaw : undefined;
60
+ const publicValues = await readConfigValues(configFilePath(paths, moduleRef), moduleRef, "public");
61
+ const secretValues = await readConfigValues(secretsFilePath(paths, moduleRef), moduleRef, "secret");
37
62
  if (publicValues === undefined && secretValues === undefined)
38
63
  return undefined;
39
64
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/proflow-platform-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -3,7 +3,7 @@
3
3
  "contractVersion": "1.0.0",
4
4
  "moduleRef": "platform-cli",
5
5
  "packageName": "@tomflow/proflow-platform-cli",
6
- "moduleVersion": "0.1.9",
6
+ "moduleVersion": "0.1.10",
7
7
  "kind": "cli",
8
8
  "templateVersion": "1.0.0",
9
9
  "platformCompatibility": ">=1.0.0 <2.0.0",