@powerhousedao/shared 6.0.0-dev.173 → 6.0.0-dev.174

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.
@@ -1,2 +1,40 @@
1
1
  import { B as RegistryPackageStatus, F as PackageInfo, I as RegistryPackage, L as RegistryPackageList, R as RegistryPackageMap, z as RegistryPackageSource } from "../types-DoRrBMid.js";
2
- export { PackageInfo, RegistryPackage, RegistryPackageList, RegistryPackageMap, RegistryPackageSource, RegistryPackageStatus };
2
+
3
+ //#region registry/registry.d.ts
4
+ interface ResolveRegistryUrlOptions {
5
+ /** Explicit registry URL (e.g. from --registry flag). Highest priority. */
6
+ registry?: string;
7
+ /** Project path to read powerhouse.config.json from. */
8
+ projectPath: string;
9
+ /** Environment variables. Defaults to process.env. */
10
+ env?: Record<string, string | undefined>;
11
+ }
12
+ /**
13
+ * Resolve the registry URL with priority: flag > env > config > default.
14
+ */
15
+ declare function resolveRegistryUrl(options: ResolveRegistryUrlOptions): string;
16
+ /**
17
+ * Check if the user is authenticated with the given npm registry.
18
+ * Returns the username on success, throws on failure.
19
+ */
20
+ declare function checkNpmAuth(registryUrl: string): Promise<string>;
21
+ interface NpmPublishOptions {
22
+ /** Registry URL to publish to. */
23
+ registryUrl: string;
24
+ /** Working directory (project root). */
25
+ cwd: string;
26
+ /** Additional arguments forwarded to npm publish. */
27
+ args?: string[];
28
+ }
29
+ interface NpmPublishResult {
30
+ /** stdout from npm publish. */
31
+ stdout: string;
32
+ }
33
+ /**
34
+ * Run `npm publish` against the given registry.
35
+ * Uses spawn with args array to avoid shell injection.
36
+ */
37
+ declare function npmPublish(options: NpmPublishOptions): Promise<NpmPublishResult>;
38
+ //#endregion
39
+ export { NpmPublishOptions, NpmPublishResult, PackageInfo, RegistryPackage, RegistryPackageList, RegistryPackageMap, RegistryPackageSource, RegistryPackageStatus, ResolveRegistryUrlOptions, checkNpmAuth, npmPublish, resolveRegistryUrl };
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../registry/registry.ts"],"mappings":";;;UAQiB,yBAAA;;EAEf,QAAA;;EAEA,WAAA;EAJe;EAMf,GAAA,GAAM,MAAA;AAAA;;;;iBAMQ,kBAAA,CAAmB,OAAA,EAAS,yBAAA;;;;AAA5C;iBAiBsB,YAAA,CAAa,WAAA,WAAsB,OAAA;AAAA,UAIxC,iBAAA;EArB2B;EAuB1C,WAAA;EANoB;EAQpB,GAAA;;EAEA,IAAA;AAAA;AAAA,UAGe,gBAAA;EATiB;EAWhC,MAAA;AAAA;;;;;iBAOoB,UAAA,CACpB,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,gBAAA"}
@@ -0,0 +1,99 @@
1
+ import { join } from "node:path";
2
+ import { homedir } from "node:os";
3
+ import { readFileSync } from "node:fs";
4
+ import { spawn } from "node:child_process";
5
+ const POWERHOUSE_CONFIG_FILE = "powerhouse.config.json";
6
+ join(homedir(), ".ph");
7
+ const DEFAULT_CONFIG = {
8
+ documentModelsDir: "./document-models",
9
+ editorsDir: "./editors",
10
+ processorsDir: "./processors",
11
+ subgraphsDir: "./subgraphs",
12
+ importScriptsDir: "./scripts",
13
+ skipFormat: false,
14
+ logLevel: "info",
15
+ auth: {
16
+ enabled: false,
17
+ admins: []
18
+ }
19
+ };
20
+ //#endregion
21
+ //#region clis/file-system/get-config.ts
22
+ function getConfig(path = "./powerhouse.config.json") {
23
+ let config = { ...DEFAULT_CONFIG };
24
+ try {
25
+ const configStr = readFileSync(path, "utf-8");
26
+ const userConfig = JSON.parse(configStr);
27
+ config = {
28
+ ...config,
29
+ ...userConfig
30
+ };
31
+ } catch {}
32
+ return config;
33
+ }
34
+ //#endregion
35
+ //#region clis/file-system/spawn-async.ts
36
+ function spawnAsync(command, args, options = {}) {
37
+ return new Promise((resolve, reject) => {
38
+ const child = spawn(process.platform === "win32" && command === "npm" ? "npm.cmd" : command, args, {
39
+ cwd: options.cwd,
40
+ env: options.env,
41
+ stdio: [
42
+ "ignore",
43
+ "pipe",
44
+ "pipe"
45
+ ]
46
+ });
47
+ let stdout = "";
48
+ let stderr = "";
49
+ child.stdout.on("data", (d) => {
50
+ stdout += d.toString();
51
+ });
52
+ child.stderr.on("data", (d) => {
53
+ stderr += d.toString();
54
+ });
55
+ child.on("error", reject);
56
+ child.on("close", (code) => {
57
+ if (code === 0) resolve(stdout.trim());
58
+ else reject(new Error(stderr.trim() || `${command} exited with code ${code}`));
59
+ });
60
+ });
61
+ }
62
+ //#endregion
63
+ //#region registry/registry.ts
64
+ /**
65
+ * Resolve the registry URL with priority: flag > env > config > default.
66
+ */
67
+ function resolveRegistryUrl(options) {
68
+ const { registry, projectPath, env = process.env } = options;
69
+ const config = getConfig(join(projectPath, POWERHOUSE_CONFIG_FILE));
70
+ return registry ?? env.PH_REGISTRY_URL ?? config.packageRegistryUrl ?? "https://registry.dev.vetra.io";
71
+ }
72
+ /**
73
+ * Check if the user is authenticated with the given npm registry.
74
+ * Returns the username on success, throws on failure.
75
+ */
76
+ async function checkNpmAuth(registryUrl) {
77
+ return spawnAsync("npm", [
78
+ "whoami",
79
+ "--registry",
80
+ registryUrl
81
+ ]);
82
+ }
83
+ /**
84
+ * Run `npm publish` against the given registry.
85
+ * Uses spawn with args array to avoid shell injection.
86
+ */
87
+ async function npmPublish(options) {
88
+ const { registryUrl, cwd, args = [] } = options;
89
+ return { stdout: await spawnAsync("npm", [
90
+ "publish",
91
+ "--registry",
92
+ registryUrl,
93
+ ...args
94
+ ], { cwd }) };
95
+ }
96
+ //#endregion
97
+ export { checkNpmAuth, npmPublish, resolveRegistryUrl };
98
+
99
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../clis/constants.ts","../../clis/file-system/get-config.ts","../../clis/file-system/spawn-async.ts","../../registry/registry.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { PowerhouseConfig } from \"./types.js\";\n\nexport const SERVICE_ACTIONS = [\n \"start\",\n \"stop\",\n \"status\",\n \"setup\",\n \"restart\",\n] as const;\n\nexport const SECONDS_IN_DAY = 24 * 60 * 60;\nexport const DEFAULT_EXPIRY_DAYS = 7;\nexport const DEFAULT_EXPIRY_SECONDS = DEFAULT_EXPIRY_DAYS * SECONDS_IN_DAY;\n\nexport const DRIVES_PRESERVE_STRATEGIES = [\n \"preserve-all\",\n \"preserve-by-url-and-detach\",\n] as const;\n\nexport const LOG_LEVELS = [\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"verbose\",\n] as const;\n\nexport const DEFAULT_TIMEOUT = 300 as const;\n\nexport const DEFAULT_CONNECT_STUDIO_PORT = 3000 as const;\n\nexport const DEFAULT_VETRA_CONNECT_PORT = 3001 as const;\n\nexport const DEFAULT_CONNECT_PREVIEW_PORT = 4173 as const;\n\nexport const DEFAULT_CONNECT_OUTDIR = \".ph/connect-build/dist/\" as const;\n\nexport const DEFAULT_RENOWN_URL = \"https://www.renown.id\" as const;\n\nexport const DEFAULT_REGISTRY_URL = \"https://registry.dev.vetra.io\" as const;\n\nexport const DEFAULT_SWITCHBOARD_PORT = 4001 as const;\n\nexport const DEFAULT_VETRA_DRIVE_ID = \"vetra\" as const;\n\nexport const MINIMUM_NODE_VERSION = \"24.0.0\" as const;\nexport const PH_BIN = \"ph-cli-legacy\" as const;\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\" as const;\nexport const PH_GLOBAL_DIR_NAME = \".ph\" as const;\n// Keep PH_GLOBAL_PROJECT_NAME for backwards compatibility\nexport const PH_GLOBAL_PROJECT_NAME = PH_GLOBAL_DIR_NAME;\n\nexport const HOME_DIR = homedir();\n\nexport const POWERHOUSE_GLOBAL_DIR = join(HOME_DIR, PH_GLOBAL_DIR_NAME);\n\nexport const VERSIONED_DEPENDENCIES = [\n \"document-model\",\n \"@powerhousedao/design-system\",\n \"@powerhousedao/reactor-api\",\n \"@powerhousedao/reactor-browser\",\n \"@powerhousedao/connect\",\n \"@powerhousedao/analytics-engine-core\",\n];\n\nexport const VERSIONED_DEV_DEPENDENCIES = [\n \"@powerhousedao/ph-cli\",\n \"@powerhousedao/reactor\",\n];\n\nconst DEFAULT_DOCUMENT_MODELS_DIR = \"./document-models\";\nconst DEFAULT_EDITORS_DIR = \"./editors\";\nconst DEFAULT_PROCESSORS_DIR = \"./processors\";\nconst DEFAULT_SUBGRAPHS_DIR = \"./subgraphs\";\nconst DEFAULT_IMPORT_SCRIPTS_DIR = \"./scripts\";\nconst DEFAULT_SKIP_FORMAT = false;\nconst DEFAULT_LOG_LEVEL = \"info\";\n\nexport const DEFAULT_CONFIG: PowerhouseConfig = {\n documentModelsDir: DEFAULT_DOCUMENT_MODELS_DIR,\n editorsDir: DEFAULT_EDITORS_DIR,\n processorsDir: DEFAULT_PROCESSORS_DIR,\n subgraphsDir: DEFAULT_SUBGRAPHS_DIR,\n importScriptsDir: DEFAULT_IMPORT_SCRIPTS_DIR,\n skipFormat: DEFAULT_SKIP_FORMAT,\n logLevel: DEFAULT_LOG_LEVEL,\n auth: {\n enabled: false,\n admins: [],\n },\n};\n","import { readFileSync } from \"node:fs\";\nimport { DEFAULT_CONFIG } from \"../constants.js\";\nimport type { PowerhouseConfig } from \"../types.js\";\n\nexport function getConfig(path = \"./powerhouse.config.json\") {\n let config: PowerhouseConfig = { ...DEFAULT_CONFIG };\n try {\n const configStr = readFileSync(path, \"utf-8\");\n const userConfig = JSON.parse(configStr) as PowerhouseConfig;\n config = { ...config, ...userConfig };\n } catch {\n // console.warn(\"No powerhouse.config.json found, using defaults\");\n }\n\n return config;\n}\n","import { spawn } from \"node:child_process\";\n\nexport function spawnAsync(\n command: string,\n args: string[],\n options: {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n } = {},\n): Promise<string> {\n return new Promise((resolve, reject) => {\n const cmd =\n process.platform === \"win32\" && command === \"npm\" ? \"npm.cmd\" : command;\n\n const child = spawn(cmd, args, {\n cwd: options.cwd,\n env: options.env,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n child.stdout.on(\"data\", (d: Buffer) => {\n stdout += d.toString();\n });\n\n child.stderr.on(\"data\", (d: Buffer) => {\n stderr += d.toString();\n });\n\n child.on(\"error\", reject);\n\n child.on(\"close\", (code) => {\n if (code === 0) {\n resolve(stdout.trim());\n } else {\n reject(\n new Error(stderr.trim() || `${command} exited with code ${code}`),\n );\n }\n });\n });\n}\n","import { join } from \"node:path\";\nimport {\n DEFAULT_REGISTRY_URL,\n POWERHOUSE_CONFIG_FILE,\n} from \"../clis/constants.js\";\nimport { getConfig } from \"../clis/file-system/get-config.js\";\nimport { spawnAsync } from \"../clis/file-system/spawn-async.js\";\n\nexport interface ResolveRegistryUrlOptions {\n /** Explicit registry URL (e.g. from --registry flag). Highest priority. */\n registry?: string;\n /** Project path to read powerhouse.config.json from. */\n projectPath: string;\n /** Environment variables. Defaults to process.env. */\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Resolve the registry URL with priority: flag > env > config > default.\n */\nexport function resolveRegistryUrl(options: ResolveRegistryUrlOptions): string {\n const { registry, projectPath, env = process.env } = options;\n const configPath = join(projectPath, POWERHOUSE_CONFIG_FILE);\n const config = getConfig(configPath);\n\n return (\n registry ??\n env.PH_REGISTRY_URL ??\n config.packageRegistryUrl ??\n DEFAULT_REGISTRY_URL\n );\n}\n\n/**\n * Check if the user is authenticated with the given npm registry.\n * Returns the username on success, throws on failure.\n */\nexport async function checkNpmAuth(registryUrl: string): Promise<string> {\n return spawnAsync(\"npm\", [\"whoami\", \"--registry\", registryUrl]);\n}\n\nexport interface NpmPublishOptions {\n /** Registry URL to publish to. */\n registryUrl: string;\n /** Working directory (project root). */\n cwd: string;\n /** Additional arguments forwarded to npm publish. */\n args?: string[];\n}\n\nexport interface NpmPublishResult {\n /** stdout from npm publish. */\n stdout: string;\n}\n\n/**\n * Run `npm publish` against the given registry.\n * Uses spawn with args array to avoid shell injection.\n */\nexport async function npmPublish(\n options: NpmPublishOptions,\n): Promise<NpmPublishResult> {\n const { registryUrl, cwd, args = [] } = options;\n const npmArgs = [\"publish\", \"--registry\", registryUrl, ...args];\n const stdout = await spawnAsync(\"npm\", npmArgs, { cwd });\n return { stdout };\n}\n"],"mappings":";;;;AAiDA,MAAa,yBAAyB;AAOD,KAFb,SAAS,EAES,MAA6B;AAwBvE,MAAa,iBAAmC;CAC9C,mBATkC;CAUlC,YAT0B;CAU1B,eAT6B;CAU7B,cAT4B;CAU5B,kBATiC;CAUjC,YAT0B;CAU1B,UATwB;CAUxB,MAAM;EACJ,SAAS;EACT,QAAQ,EAAE;EACX;CACF;;;ACxFD,SAAgB,UAAU,OAAO,4BAA4B;CAC3D,IAAI,SAA2B,EAAE,GAAG,gBAAgB;AACpD,KAAI;EACF,MAAM,YAAY,aAAa,MAAM,QAAQ;EAC7C,MAAM,aAAa,KAAK,MAAM,UAAU;AACxC,WAAS;GAAE,GAAG;GAAQ,GAAG;GAAY;SAC/B;AAIR,QAAO;;;;ACZT,SAAgB,WACd,SACA,MACA,UAGI,EAAE,EACW;AACjB,QAAO,IAAI,SAAS,SAAS,WAAW;EAItC,MAAM,QAAQ,MAFZ,QAAQ,aAAa,WAAW,YAAY,QAAQ,YAAY,SAEzC,MAAM;GAC7B,KAAK,QAAQ;GACb,KAAK,QAAQ;GACb,OAAO;IAAC;IAAU;IAAQ;IAAO;GAClC,CAAC;EAEF,IAAI,SAAS;EACb,IAAI,SAAS;AAEb,QAAM,OAAO,GAAG,SAAS,MAAc;AACrC,aAAU,EAAE,UAAU;IACtB;AAEF,QAAM,OAAO,GAAG,SAAS,MAAc;AACrC,aAAU,EAAE,UAAU;IACtB;AAEF,QAAM,GAAG,SAAS,OAAO;AAEzB,QAAM,GAAG,UAAU,SAAS;AAC1B,OAAI,SAAS,EACX,SAAQ,OAAO,MAAM,CAAC;OAEtB,QACE,IAAI,MAAM,OAAO,MAAM,IAAI,GAAG,QAAQ,oBAAoB,OAAO,CAClE;IAEH;GACF;;;;;;;ACtBJ,SAAgB,mBAAmB,SAA4C;CAC7E,MAAM,EAAE,UAAU,aAAa,MAAM,QAAQ,QAAQ;CAErD,MAAM,SAAS,UADI,KAAK,aAAa,uBAAuB,CACxB;AAEpC,QACE,YACA,IAAI,mBACJ,OAAO,sBAAA;;;;;;AASX,eAAsB,aAAa,aAAsC;AACvE,QAAO,WAAW,OAAO;EAAC;EAAU;EAAc;EAAY,CAAC;;;;;;AAqBjE,eAAsB,WACpB,SAC2B;CAC3B,MAAM,EAAE,aAAa,KAAK,OAAO,EAAE,KAAK;AAGxC,QAAO,EAAE,QADM,MAAM,WAAW,OADhB;EAAC;EAAW;EAAc;EAAa,GAAG;EAAK,EACf,EAAE,KAAK,CAAC,EACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/shared",
3
- "version": "6.0.0-dev.173",
3
+ "version": "6.0.0-dev.174",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -81,7 +81,7 @@
81
81
  "change-case": "5.4.4",
82
82
  "cmd-ts": "0.15.0",
83
83
  "jszip": "^3.10.1",
84
- "kysely": "0.28.11",
84
+ "kysely": "0.28.16",
85
85
  "luxon": "3.7.2",
86
86
  "mutative": "1.3.0",
87
87
  "npm-package-arg": "13.0.2",