@powerhousedao/shared 6.1.0-dev.6 → 6.1.0-dev.7

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,4 +1,4 @@
1
- import { Ai as ModuleSpecification, An as ActionSignatureContext, Br as DocumentModelOperationErrorOperations, Dr as DocumentModelDocument, Ha as Reducer, Hr as DocumentModelOperationExampleOperations, Ia as PruneActionInput, Kr as DocumentModelStateOperations, Lr as DocumentModelModuleOperations, Pr as DocumentModelLocalState, Ss as StateReducer, Ua as ReducerOptions, Ur as DocumentModelOperationOperations, Wr as DocumentModelPHState, Xn as Author, Yr as DocumentModelVersioningOperations, Zr as DocumentSpecification, an as Operation, ao as ReplayDocumentOptions, bs as SkipHeaderOperations, bt as PHDocumentHeader, co as SaveToFileHandle, fi as ISigner, hn as PHBaseState, in as DocumentOperations, jr as DocumentModelHeaderOperations, ka as OperationSpecification, ki as MinimalBackupData, kr as DocumentModelGlobalState, on as OperationContext, ps as SignalDispatch, ri as FileInput, t as Action, vi as LoadFromInput, vs as SigningParameters, yt as PHDocument, zs as ValidationError } from "./actions-UH5nIJcP.js";
1
+ import { Ai as ModuleSpecification, An as ActionSignatureContext, Br as DocumentModelOperationErrorOperations, Da as OperationErrorSpecification, Dr as DocumentModelDocument, Ha as Reducer, Hr as DocumentModelOperationExampleOperations, Ia as PruneActionInput, Kr as DocumentModelStateOperations, Lr as DocumentModelModuleOperations, Pr as DocumentModelLocalState, Ss as StateReducer, Ua as ReducerOptions, Ur as DocumentModelOperationOperations, Wr as DocumentModelPHState, Xn as Author, Yr as DocumentModelVersioningOperations, Zn as CodeExample, Zr as DocumentSpecification, an as Operation, ao as ReplayDocumentOptions, bs as SkipHeaderOperations, bt as PHDocumentHeader, co as SaveToFileHandle, fi as ISigner, hn as PHBaseState, in as DocumentOperations, jr as DocumentModelHeaderOperations, ka as OperationSpecification, ki as MinimalBackupData, kr as DocumentModelGlobalState, on as OperationContext, ps as SignalDispatch, ri as FileInput, t as Action, vi as LoadFromInput, vs as SigningParameters, yt as PHDocument, zs as ValidationError } from "./actions-UH5nIJcP.js";
2
2
  import { ZodIssue, z } from "zod";
3
3
 
4
4
  //#region document-model/constants.d.ts
@@ -319,7 +319,43 @@ declare function findModuleOrThrow(state: DocumentModelGlobalState, moduleId: st
319
319
  * fail loudly when the operation doesn't exist.
320
320
  */
321
321
  declare function findOperationOrThrow(state: DocumentModelGlobalState, operationId: string): OperationSpecification;
322
+ /**
323
+ * Find an operation error by id across all operations in the latest
324
+ * specification, or throw. Throws on a duplicate id too: setters act on a
325
+ * single error, so an ambiguous id must fail loudly rather than mutate an
326
+ * arbitrary match.
327
+ */
328
+ declare function findOperationErrorOrThrow(state: DocumentModelGlobalState, errorId: string): OperationErrorSpecification;
329
+ /**
330
+ * Find an operation example (code example) by id across all operations in the
331
+ * latest specification, or throw. Throws on a duplicate id for the same reason
332
+ * as findOperationErrorOrThrow.
333
+ */
334
+ declare function findOperationExampleOrThrow(state: DocumentModelGlobalState, exampleId: string): CodeExample;
335
+ /**
336
+ * Assert no module in the latest specification already uses `id`. Modules are
337
+ * targeted by id by the setter/delete/reorder reducers, so a duplicate id makes
338
+ * those operations ambiguous.
339
+ */
340
+ declare function assertModuleIdUnique(state: DocumentModelGlobalState, id: string): void;
341
+ /**
342
+ * Assert no operation in the latest specification already uses `id`. Operations
343
+ * are targeted by id across all modules, so the id must be unique document-wide.
344
+ */
345
+ declare function assertOperationIdUnique(state: DocumentModelGlobalState, id: string): void;
346
+ /**
347
+ * Assert no operation error in the latest specification already uses `id`.
348
+ * Error ids are targeted document-wide by the setter/delete reducers, so the id
349
+ * must be unique to keep those operations unambiguous.
350
+ */
351
+ declare function assertOperationErrorIdUnique(state: DocumentModelGlobalState, id: string): void;
352
+ /**
353
+ * Assert no operation example in the latest specification already uses `id`.
354
+ * Example ids are targeted document-wide by the update/delete reducers, so the
355
+ * id must be unique to keep those operations unambiguous.
356
+ */
357
+ declare function assertOperationExampleIdUnique(state: DocumentModelGlobalState, id: string): void;
322
358
  declare function validateOperations(operations: DocumentOperations): ValidationError[];
323
359
  //#endregion
324
- export { BaseDocumentHeaderSchema as $, updateDocument as A, createMinimalZip as B, documentModelStateSchemaReducer as C, processUndoRedo as D, createReducer as E, sign as F, getFileBrowser as G, documentModelLoadFromInput as H, validateHeader as I, FileSystemError as J, readFileBrowser as K, verify as L, createSignedHeader as M, createSignedHeaderForSigner as N, pruneOperation as O, createVerificationSigner as P, documentModelDocumentType as Q, baseLoadFromInput as R, documentModelStateReducer as S, documentModelInitialLocalState as St, baseReducer as T, documentModelSaveToFileHandle as U, createZip as V, fetchFileBrowser as W, InvalidActionInputError as X, HashMismatchError as Y, InvalidActionInputZodError as Z, documentModelModuleReducer as _, HASH_ENCODING_BASE64 as _t, findOperationOrThrow as a, assertIsDocumentModelState as at, documentModelOperationReducer as b, documentModelGlobalState as bt, isValidOperationNameFormat as c, ab2hex as ct, validateModuleOperation as d, getUnixTimestamp as dt, BaseDocumentStateSchema as et, validateModules as f, hashBrowser as ft, documentModelHeaderReducer as g, HASH_ALGORITHM_SHA512 as gt, validateStateSchemaName as h, HASH_ALGORITHM_SHA256 as ht, findModuleOrThrow as i, assertIsDocumentModelDocument as it, createPresignedHeader as j, replayOperations as k, validateInitialState as l, buildOperationSignatureMessage as lt, validateOperations as m, HASH_ALGORITHM_SHA1 as mt, RESERVED_OPERATION_NAMES as n, DocumentModelPHStateSchema as nt, getAllOperationNames as o, isDocumentModelDocument as ot, validateOperationName as p, hex2ab as pt, writeFileBrowser as q, ReservedOperationName as r, DocumentModelSchema as rt, isReservedOperationName as s, isDocumentModelState as st, OPERATION_NAME_PATTERN as t, DocumentModelHeaderSchema as tt, validateModule as u, buildOperationSignatureParams as ut, documentModelOperationErrorReducer as v, HASH_ENCODING_HEX as vt, documentModelVersioningReducer as w, documentModelReducer as x, documentModelInitialGlobalState as xt, documentModelOperationExampleReducer as y, documentModelFileExtension as yt, baseSaveToFileHandle as z };
325
- //# sourceMappingURL=index-Ci29hVA5.d.ts.map
360
+ export { writeFileBrowser as $, documentModelVersioningReducer as A, createVerificationSigner as B, documentModelModuleReducer as C, HASH_ENCODING_BASE64 as Ct, documentModelReducer as D, documentModelInitialGlobalState as Dt, documentModelOperationReducer as E, documentModelGlobalState as Et, replayOperations as F, baseSaveToFileHandle as G, validateHeader as H, updateDocument as I, documentModelLoadFromInput as J, createMinimalZip as K, createPresignedHeader as L, createReducer as M, processUndoRedo as N, documentModelStateReducer as O, documentModelInitialLocalState as Ot, pruneOperation as P, readFileBrowser as Q, createSignedHeader as R, documentModelHeaderReducer as S, HASH_ALGORITHM_SHA512 as St, documentModelOperationExampleReducer as T, documentModelFileExtension as Tt, verify as U, sign as V, baseLoadFromInput as W, fetchFileBrowser as X, documentModelSaveToFileHandle as Y, getFileBrowser as Z, validateModuleOperation as _, getUnixTimestamp as _t, assertOperationErrorIdUnique as a, BaseDocumentHeaderSchema as at, validateOperations as b, HASH_ALGORITHM_SHA1 as bt, findModuleOrThrow as c, DocumentModelPHStateSchema as ct, findOperationOrThrow as d, assertIsDocumentModelState as dt, FileSystemError as et, getAllOperationNames as f, isDocumentModelDocument as ft, validateModule as g, buildOperationSignatureParams as gt, validateInitialState as h, buildOperationSignatureMessage as ht, assertModuleIdUnique as i, documentModelDocumentType as it, baseReducer as j, documentModelStateSchemaReducer as k, findOperationErrorOrThrow as l, DocumentModelSchema as lt, isValidOperationNameFormat as m, ab2hex as mt, RESERVED_OPERATION_NAMES as n, InvalidActionInputError as nt, assertOperationExampleIdUnique as o, BaseDocumentStateSchema as ot, isReservedOperationName as p, isDocumentModelState as pt, createZip as q, ReservedOperationName as r, InvalidActionInputZodError as rt, assertOperationIdUnique as s, DocumentModelHeaderSchema as st, OPERATION_NAME_PATTERN as t, HashMismatchError as tt, findOperationExampleOrThrow as u, assertIsDocumentModelDocument as ut, validateModules as v, hashBrowser as vt, documentModelOperationErrorReducer as w, HASH_ENCODING_HEX as wt, validateStateSchemaName as x, HASH_ALGORITHM_SHA256 as xt, validateOperationName as y, hex2ab as yt, createSignedHeaderForSigner as z };
361
+ //# sourceMappingURL=index-ytANG577.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-Ci29hVA5.d.ts","names":[],"sources":["../document-model/constants.ts","../document-model/crypto.ts","../document-model/document-schema.ts","../document-model/document-type.ts","../document-model/errors.ts","../document-model/files.ts","../document-model/header.ts","../document-model/reducer.ts","../document-model/reducers.ts","../document-model/validation.ts"],"mappings":";;;;cAKa,0BAAA;AAAA,cAEA,8BAAA,EAAgC,uBAAA;AAAA,cAChC,+BAAA,EAAiC,wBAAA;AAAA,cA6BjC,wBAAA,EAA0B,wBAAA;AAAA,cAylB1B,mBAAA;AAAA,cACA,qBAAA;AAAA,cACA,qBAAA;AAAA,cAGA,oBAAA;AAAA,cACA,iBAAA;;;cChoBA,WAAA,GACX,IAAA,WAAe,UAAA,GAAa,eAAA,GAAkB,QAAA,EAC9C,SAAA,WACA,QAAA,WACA,OAAA,GAAU,MAAA;AAAA,iBAqDI,gBAAA,CAAiB,IAAA,EAAM,IAAA;AAAA,iBAIvB,6BAAA,CAAA;EACd,UAAA;EACA,MAAA;EACA,MAAA;EACA;AAAA,GACC,sBAAA;AAAA,iBAca,8BAAA,CACd,MAAA,qCACC,UAAA;AAAA,iBAMa,MAAA,CAAO,EAAA,EAAI,WAAA,GAAc,eAAA;AAAA,iBAOzB,MAAA,CAAO,GAAA,WAAW,UAAA,CAAA,WAAA;;;cC9FrB,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;cAQxB,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;cAKvB,yBAAA,EAAyB,CAAA,CAAA,SAAA;;;;;;;;cAKzB,0BAAA,EAA0B,CAAA,CAAA,SAAA;;sBAErC,MAAA;;;;;;;;cAEW,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOhB,oBAAA,CACd,KAAA,YACC,KAA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;AThB5C;;;;cSuBa,sBAAA,EAAsB,MAAA;AAAA,iBAEnB,0BAAA,CAA2B,IAAA;;;;iBAO3B,uBAAA,CAAwB,IAAA;ATFxC;;;;AAAA,iBSYgB,oBAAA,CACd,KAAA,EAAO,wBAAA,EACP,kBAAA;AT2kBF;;;;;AACA;;;AADA,iBSpjBgB,qBAAA,CACd,IAAA,UACA,KAAA,EAAO,wBAAA,EACP,kBAAA;AAAA,iBAiCc,oBAAA,CACd,YAAA,UACA,eAAA,aACC,eAAA;AAAA,iBA4Ba,uBAAA,CACd,MAAA,UACA,YAAA,UACA,KAAA,WACA,gBAAA,aACC,eAAA;AAAA,iBAqCa,eAAA,CACd,OAAA,EAAS,mBAAA,KACR,eAAA;AAAA,iBAmBa,cAAA,CAAe,GAAA,EAAK,mBAAA,GAAsB,eAAA;AAAA,iBA6B1C,uBAAA,CACd,SAAA,EAAW,sBAAA,GACV,eAAA;;ATwZH;;;;iBS3XgB,iBAAA,CACd,KAAA,EAAO,wBAAA,EACP,QAAA,WACC,mBAAA;ATyXH;;;;;AAAA,iBSzWgB,oBAAA,CACd,KAAA,EAAO,wBAAA,EACP,WAAA,WACC,sBAAA;AAAA,iBAaa,kBAAA,CAAmB,UAAA,EAAY,kBAAA,GAAkB,eAAA"}
1
+ {"version":3,"file":"index-ytANG577.d.ts","names":[],"sources":["../document-model/constants.ts","../document-model/crypto.ts","../document-model/document-schema.ts","../document-model/document-type.ts","../document-model/errors.ts","../document-model/files.ts","../document-model/header.ts","../document-model/reducer.ts","../document-model/reducers.ts","../document-model/validation.ts"],"mappings":";;;;cAKa,0BAAA;AAAA,cAEA,8BAAA,EAAgC,uBAAA;AAAA,cAChC,+BAAA,EAAiC,wBAAA;AAAA,cA6BjC,wBAAA,EAA0B,wBAAA;AAAA,cAylB1B,mBAAA;AAAA,cACA,qBAAA;AAAA,cACA,qBAAA;AAAA,cAGA,oBAAA;AAAA,cACA,iBAAA;;;cChoBA,WAAA,GACX,IAAA,WAAe,UAAA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eAAA;;ATsZH;;;;iBSzXgB,iBAAA,CACd,KAAA,EAAO,wBAAA,EACP,QAAA,WACC,mBAAA;ATuXH;;;;;AAAA,iBSvWgB,oBAAA,CACd,KAAA,EAAO,wBAAA,EACP,WAAA,WACC,sBAAA;;;AR5RH;;;;iBQ+SgB,yBAAA,CACd,KAAA,EAAO,wBAAA,EACP,OAAA,WACC,2BAAA;;;;;;iBAwBa,2BAAA,CACd,KAAA,EAAO,wBAAA,EACP,SAAA,WACC,WAAA;;;;;;iBA0Ba,oBAAA,CACd,KAAA,EAAO,wBAAA,EACP,EAAA;;;ARhTF;;iBQ8TgB,uBAAA,CACd,KAAA,EAAO,wBAAA,EACP,EAAA;;;AR5TF;;;iBQ8UgB,4BAAA,CACd,KAAA,EAAO,wBAAA,EACP,EAAA;;;;;;iBAkBc,8BAAA,CACd,KAAA,EAAO,wBAAA,EACP,EAAA;AAAA,iBAac,kBAAA,CAAmB,UAAA,EAAY,kBAAA,GAAkB,eAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fs"],"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 { Manifest } from \"../document-model/types.js\";\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\n// Workspace packages that go in peerDependencies of every generated project.\nexport const VERSIONED_PEER_DEPENDENCIES = [\n \"document-model\",\n \"@powerhousedao/reactor-browser\",\n];\n\ntype PeerSpec = { peer: string; dev: string };\n\nexport const REACTOR_API_PACKAGE = \"@powerhousedao/reactor-api\";\nexport const ANALYTICS_ENGINE_CORE_PACKAGE =\n \"@powerhousedao/analytics-engine-core\";\nexport const GRAPHQL_PACKAGE = \"graphql\";\nexport const GRAPHQL_TAG_PACKAGE = \"graphql-tag\";\n\n// External peerDependencies of every generated project.\n// `peer` is the consumer-facing range; `dev` is the exact build-tested pin.\n// graphql / graphql-tag are always-on because the workspace packages pulled\n// in by every `ph init` project (codegen, reactor-api, reactor-browser,\n// vetra-packages) declare them as peers — even projects without subgraphs\n// need them in scope so pnpm hoists a single graphql instance.\nexport const PEER_EXTERNAL_DEPENDENCIES = {\n [GRAPHQL_PACKAGE]: { peer: \"^16\", dev: \"16.12.0\" },\n [GRAPHQL_TAG_PACKAGE]: { peer: \"^2\", dev: \"2.12.6\" },\n react: { peer: \"^19\", dev: \"19.2.3\" },\n \"react-dom\": { peer: \"^19\", dev: \"19.2.3\" },\n zod: { peer: \"^4\", dev: \"4.3.6\" },\n} as const satisfies Record<string, PeerSpec>;\n\n// Per-feature deps added dynamically by codegen when required.\nexport const FEATURE_DEPENDENCIES = {\n analyticsProcessor: {\n peerVersioned: [ANALYTICS_ENGINE_CORE_PACKAGE],\n peerExternal: {},\n },\n} as const satisfies Record<\n string,\n { peerVersioned: readonly string[]; peerExternal: Record<string, PeerSpec> }\n>;\n\nexport const VERSIONED_DEPENDENCIES = [\n ...VERSIONED_PEER_DEPENDENCIES,\n ...FEATURE_DEPENDENCIES.analyticsProcessor.peerVersioned,\n];\n\n// Transitive dependencies whose postinstall scripts the generated project\n// trusts. Mirrors the `allowBuilds` map in the boilerplate's\n// pnpm-workspace.yaml and is also passed as `--allow-build` flags to\n// `pnpm dlx @powerhousedao/ph-cli init` so pnpm 11's strict-dep-builds\n// default doesn't prompt during the outer dlx download.\nexport const BOILERPLATE_ALLOWED_BUILDS = [\n \"@apollo/protobufjs\",\n \"@datadog/pprof\",\n \"@parcel/watcher\",\n \"esbuild\",\n \"protobufjs\",\n] as const;\n\nexport const VERSIONED_DEV_DEPENDENCIES = [\n \"@powerhousedao/ph-cli\",\n \"@powerhousedao/reactor\",\n \"@powerhousedao/shared\",\n \"@powerhousedao/connect\",\n \"@powerhousedao/design-system\",\n];\n\nexport const packageJsonExports = {\n \".\": {\n types: \"./dist/types/index.d.ts\",\n browser: \"./dist/browser/index.js\",\n node: \"./dist/node/index.mjs\",\n },\n \"./document-models\": {\n types: \"./dist/types/document-models/index.d.ts\",\n browser: \"./dist/browser/document-models/index.js\",\n node: \"./dist/node/document-models/index.mjs\",\n },\n \"./document-models/*\": {\n types: \"./dist/types/document-models/*/index.d.ts\",\n browser: \"./dist/browser/document-models/*/index.js\",\n node: \"./dist/node/document-models/*/index.mjs\",\n },\n \"./editors\": {\n types: \"./dist/types/editors/index.d.ts\",\n browser: \"./dist/browser/editors/index.js\",\n node: \"./dist/node/editors/index.mjs\",\n },\n \"./editors/*\": {\n types: \"./dist/types/editors/*/editor.d.ts\",\n browser: \"./dist/browser/editors/*/editor.js\",\n node: \"./dist/node/editors/*/editor.mjs\",\n },\n \"./subgraphs\": {\n types: \"./dist/types/subgraphs/index.d.ts\",\n browser: \"./dist/browser/subgraphs/index.js\",\n node: \"./dist/node/subgraphs/index.mjs\",\n },\n \"./processors\": {\n types: \"./dist/types/processors/index.d.ts\",\n browser: \"./dist/browser/processors/index.js\",\n node: \"./dist/node/processors/index.mjs\",\n },\n \"./manifest\": \"./dist/powerhouse.manifest.json\",\n \"./style.css\": \"./dist/style.css\",\n} as const;\n\nexport const packageScripts = {\n \"test:watch\": \"vitest\",\n lint: \"eslint --config eslint.config.js --cache\",\n \"lint:fix\": \"npm run lint -- --fix\",\n tsc: \"tsc\",\n \"tsc:watch\": \"tsc --watch\",\n generate: \"ph-cli generate\",\n connect: \"ph-cli connect\",\n build: \"ph-cli build\",\n reactor: \"ph-cli reactor\",\n service: \"ph-cli service\",\n vetra: \"ph-cli vetra\",\n \"service-startup\":\n \"bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-startup.sh\",\n \"service-unstartup\":\n \"bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-unstartup.sh\",\n} as const;\n\nexport const externalDependencies = {} as const;\n\nexport const externalDevDependencies = {\n \"@electric-sql/pglite\": \"0.3.15\",\n \"@electric-sql/pglite-tools\": \"0.2.20\",\n \"@eslint/js\": \"^9.38.0\",\n \"@powerhousedao/document-engineering\": \"1.40.5\",\n \"@tailwindcss/cli\": \"^4.1.18\",\n \"@tailwindcss/vite\": \"^4.1.18\",\n \"@types/node\": \"^24.9.2\",\n \"@types/react\": \"^19.2.3\",\n \"@types/react-dom\": \"^19.2.3\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"@vitest/coverage-v8\": \"4.1.1\",\n eslint: \"^9.38.0\",\n \"eslint-config-prettier\": \"^10.1.8\",\n \"eslint-plugin-prettier\": \"^5.5.4\",\n \"eslint-plugin-react\": \"^7.37.5\",\n \"eslint-plugin-react-hooks\": \"^7.0.1\",\n globals: \"^16.4.0\",\n tailwindcss: \"^4.1.16\",\n typescript: \"^5.9.3\",\n \"typescript-eslint\": \"^8.46.2\",\n vite: \"^8.0.8\",\n \"vite-tsconfig-paths\": \"6.1.1\",\n vitest: \"4.1.1\",\n} as const;\n\nexport const defaultManifest: Manifest = {\n name: \"\",\n description: \"\",\n category: \"\",\n publisher: {\n name: \"\",\n url: \"\",\n },\n documentModels: [],\n editors: [],\n apps: [],\n subgraphs: [],\n processors: [],\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 { promises as fs } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { 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 { DEFAULT_REGISTRY_URL } from \"../clis/constants.js\";\n\n/**\n * Extract the host portion of a registry URL — what npm uses as the key in\n * `~/.npmrc` for per-registry tokens (e.g. `//registry.dev.vetra.io/`).\n */\nexport function registryAuthKey(registryUrl: string): string {\n const url = new URL(registryUrl);\n // Always trailing slash; npm's lookup is exact-match against the leading\n // path of the registry URL, with `//` prefix and trailing `/`.\n const path = url.pathname.endsWith(\"/\") ? url.pathname : `${url.pathname}/`;\n return `//${url.host}${path}:_authToken`;\n}\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 /** Bearer token for the registry. When set, passed via a registry-scoped\n * `_authToken` config flag rather than read from the user's `.npmrc`. */\n authToken?: 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 *\n * When `authToken` is provided, the token is passed via a registry-scoped\n * `--//host/:_authToken=<token>` flag (npm's standard form for per-registry\n * tokens) so we never have to write to `~/.npmrc`.\n */\nexport async function npmPublish(\n options: NpmPublishOptions,\n): Promise<NpmPublishResult> {\n const { registryUrl, cwd, args = [], authToken } = options;\n const tokenArg = authToken\n ? [`--${registryAuthKey(registryUrl)}=${authToken}`]\n : [];\n const npmArgs = [\"publish\", \"--registry\", registryUrl, ...tokenArg, ...args];\n const stdout = await spawnAsync(\"npm\", npmArgs, { cwd });\n return { stdout };\n}\n\n/**\n * Write `_authToken=<token>` for the given registry host into `~/.npmrc`,\n * preserving any other lines. Replaces the existing entry for the same key\n * if present. Returns the absolute path to the npmrc that was written.\n */\nexport async function writeRegistryAuthToken(\n registryUrl: string,\n token: string,\n): Promise<string> {\n const npmrcPath = join(homedir(), \".npmrc\");\n const key = registryAuthKey(registryUrl);\n let existing = \"\";\n try {\n existing = await fs.readFile(npmrcPath, \"utf8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n const lines = existing.split(\"\\n\");\n const filtered = lines.filter((line) => !line.startsWith(`${key}=`));\n // Also drop any trailing empties to avoid stacking blank lines on rewrite.\n while (filtered.length && filtered[filtered.length - 1] === \"\")\n filtered.pop();\n filtered.push(`${key}=${token}`);\n await fs.writeFile(npmrcPath, `${filtered.join(\"\\n\")}\\n`, \"utf8\");\n return npmrcPath;\n}\n\nexport interface NpmUnpublishOptions {\n /** Registry URL to unpublish from. */\n registryUrl: string;\n /** Working directory (project root). */\n cwd: string;\n /** Package spec: `<name>` (whole package) or `<name>@<version>` (single version). */\n spec: string;\n /** Additional arguments forwarded to npm unpublish. */\n args?: string[];\n /** Bearer token for the registry (same semantics as `NpmPublishOptions.authToken`). */\n authToken?: string;\n}\n\nexport interface NpmUnpublishResult {\n /** stdout from npm unpublish. */\n stdout: string;\n}\n\n/**\n * Run `npm unpublish` against the given registry.\n * Always passes `--force` because npm otherwise refuses to unpublish packages\n * older than 72h (a public-npmjs safeguard that doesn't apply to private registries).\n */\nexport async function npmUnpublish(\n options: NpmUnpublishOptions,\n): Promise<NpmUnpublishResult> {\n const { registryUrl, cwd, spec, args = [], authToken } = options;\n const tokenArg = authToken\n ? [`--${registryAuthKey(registryUrl)}=${authToken}`]\n : [];\n const npmArgs = [\n \"unpublish\",\n spec,\n \"--registry\",\n registryUrl,\n \"--force\",\n ...tokenArg,\n ...args,\n ];\n const stdout = await spawnAsync(\"npm\", npmArgs, { cwd });\n return { stdout };\n}\n"],"mappings":";;;;AA0CA,MA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SAAG,UAAU,WAAW,GAAG,SAAS,KAAK,KAAK,CAAC,KAAK,OAAO;AACjE,QAAO;;;;;;;AA0BT,eAAsB,aACpB,SAC6B;CAC7B,MAAM,EAAE,aAAa,KAAK,MAAM,OAAO,EAAE,EAAE,cAAc;AAczD,QAAO,EAAE,QADM,MAAM,WAAW,OAThB;EACd;EACA;EACA;EACA;EACA;EACA,GATe,YACb,CAAC,KAAK,gBAAgB,YAAY,CAAC,GAAG,YAAY,GAClD,EAAE;EAQJ,GAAG;EACJ,EAC+C,EAAE,KAAK,CAAC,EACvC"}
1
+ {"version":3,"file":"index.js","names":["fs"],"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 { Manifest } from \"../document-model/types.js\";\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\n// Workspace packages that go in peerDependencies of every generated project.\nexport const VERSIONED_PEER_DEPENDENCIES = [\n \"document-model\",\n \"@powerhousedao/reactor-browser\",\n];\n\ntype PeerSpec = { peer: string; dev: string };\n\nexport const REACTOR_API_PACKAGE = \"@powerhousedao/reactor-api\";\nexport const ANALYTICS_ENGINE_CORE_PACKAGE =\n \"@powerhousedao/analytics-engine-core\";\nexport const GRAPHQL_PACKAGE = \"graphql\";\nexport const GRAPHQL_TAG_PACKAGE = \"graphql-tag\";\n\n// External peerDependencies of every generated project.\n// `peer` is the consumer-facing range; `dev` is the exact build-tested pin.\n// graphql / graphql-tag are always-on because the workspace packages pulled\n// in by every `ph init` project (codegen, reactor-api, reactor-browser,\n// vetra-packages) declare them as peers — even projects without subgraphs\n// need them in scope so pnpm hoists a single graphql instance.\nexport const PEER_EXTERNAL_DEPENDENCIES = {\n [GRAPHQL_PACKAGE]: { peer: \"^16\", dev: \"16.12.0\" },\n [GRAPHQL_TAG_PACKAGE]: { peer: \"^2\", dev: \"2.12.6\" },\n react: { peer: \"^19\", dev: \"19.2.6\" },\n \"react-dom\": { peer: \"^19\", dev: \"19.2.6\" },\n zod: { peer: \"^4\", dev: \"4.3.6\" },\n} as const satisfies Record<string, PeerSpec>;\n\n// Per-feature deps added dynamically by codegen when required.\nexport const FEATURE_DEPENDENCIES = {\n analyticsProcessor: {\n peerVersioned: [ANALYTICS_ENGINE_CORE_PACKAGE],\n peerExternal: {},\n },\n} as const satisfies Record<\n string,\n { peerVersioned: readonly string[]; peerExternal: Record<string, PeerSpec> }\n>;\n\nexport const VERSIONED_DEPENDENCIES = [\n ...VERSIONED_PEER_DEPENDENCIES,\n ...FEATURE_DEPENDENCIES.analyticsProcessor.peerVersioned,\n];\n\n// Transitive dependencies whose postinstall scripts the generated project\n// trusts. Mirrors the `allowBuilds` map in the boilerplate's\n// pnpm-workspace.yaml and is also passed as `--allow-build` flags to\n// `pnpm dlx @powerhousedao/ph-cli init` so pnpm 11's strict-dep-builds\n// default doesn't prompt during the outer dlx download.\nexport const BOILERPLATE_ALLOWED_BUILDS = [\n \"@apollo/protobufjs\",\n \"@datadog/pprof\",\n \"@parcel/watcher\",\n \"esbuild\",\n \"protobufjs\",\n] as const;\n\n// pnpm `overrides` written into the generated project's pnpm-workspace.yaml to\n// force a single chosen version of each, avoiding duplicates from coexisting\n// version ranges. Generated-project only — never change the monorepo catalog\n// for this (a re-resolution there pulls a tsc-crashing TS6 beta).\nexport const BOILERPLATE_PNPM_OVERRIDES = {\n \"date-fns\": \"4.3.0\",\n vite: \"8.0.14\",\n rolldown: \"1.0.2\",\n} as const satisfies Record<string, string>;\n\nexport const VERSIONED_DEV_DEPENDENCIES = [\n \"@powerhousedao/ph-cli\",\n \"@powerhousedao/reactor\",\n \"@powerhousedao/shared\",\n \"@powerhousedao/connect\",\n \"@powerhousedao/design-system\",\n];\n\nexport const packageJsonExports = {\n \".\": {\n types: \"./dist/types/index.d.ts\",\n browser: \"./dist/browser/index.js\",\n node: \"./dist/node/index.mjs\",\n },\n \"./document-models\": {\n types: \"./dist/types/document-models/index.d.ts\",\n browser: \"./dist/browser/document-models/index.js\",\n node: \"./dist/node/document-models/index.mjs\",\n },\n \"./document-models/*\": {\n types: \"./dist/types/document-models/*/index.d.ts\",\n browser: \"./dist/browser/document-models/*/index.js\",\n node: \"./dist/node/document-models/*/index.mjs\",\n },\n \"./editors\": {\n types: \"./dist/types/editors/index.d.ts\",\n browser: \"./dist/browser/editors/index.js\",\n node: \"./dist/node/editors/index.mjs\",\n },\n \"./editors/*\": {\n types: \"./dist/types/editors/*/editor.d.ts\",\n browser: \"./dist/browser/editors/*/editor.js\",\n node: \"./dist/node/editors/*/editor.mjs\",\n },\n \"./subgraphs\": {\n types: \"./dist/types/subgraphs/index.d.ts\",\n browser: \"./dist/browser/subgraphs/index.js\",\n node: \"./dist/node/subgraphs/index.mjs\",\n },\n \"./processors\": {\n types: \"./dist/types/processors/index.d.ts\",\n browser: \"./dist/browser/processors/index.js\",\n node: \"./dist/node/processors/index.mjs\",\n },\n \"./manifest\": \"./dist/powerhouse.manifest.json\",\n \"./style.css\": \"./dist/style.css\",\n} as const;\n\nexport const packageScripts = {\n \"test:watch\": \"vitest\",\n lint: \"eslint --config eslint.config.js --cache\",\n \"lint:fix\": \"npm run lint -- --fix\",\n tsc: \"tsc\",\n \"tsc:watch\": \"tsc --watch\",\n generate: \"ph-cli generate\",\n connect: \"ph-cli connect\",\n build: \"ph-cli build\",\n reactor: \"ph-cli reactor\",\n service: \"ph-cli service\",\n vetra: \"ph-cli vetra\",\n \"service-startup\":\n \"bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-startup.sh\",\n \"service-unstartup\":\n \"bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-unstartup.sh\",\n} as const;\n\nexport const externalDependencies = {} as const;\n\nexport const externalDevDependencies = {\n \"@electric-sql/pglite\": \"0.3.15\",\n \"@electric-sql/pglite-tools\": \"0.2.20\",\n \"@eslint/js\": \"^9.38.0\",\n \"@powerhousedao/document-engineering\": \"1.40.5\",\n \"@tailwindcss/cli\": \"^4.1.18\",\n \"@tailwindcss/vite\": \"^4.1.18\",\n \"@types/node\": \"^24.9.2\",\n \"@types/react\": \"^19.2.3\",\n \"@types/react-dom\": \"^19.2.3\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"@vitest/coverage-v8\": \"4.1.1\",\n eslint: \"^9.38.0\",\n \"eslint-config-prettier\": \"^10.1.8\",\n \"eslint-plugin-prettier\": \"^5.5.4\",\n \"eslint-plugin-react\": \"^7.37.5\",\n \"eslint-plugin-react-hooks\": \"^7.0.1\",\n globals: \"^16.4.0\",\n tailwindcss: \"^4.1.16\",\n typescript: \"^5.9.3\",\n \"typescript-eslint\": \"^8.46.2\",\n vite: \"^8.0.8\",\n \"vite-tsconfig-paths\": \"6.1.1\",\n vitest: \"4.1.1\",\n} as const;\n\nexport const defaultManifest: Manifest = {\n name: \"\",\n description: \"\",\n category: \"\",\n publisher: {\n name: \"\",\n url: \"\",\n },\n documentModels: [],\n editors: [],\n apps: [],\n subgraphs: [],\n processors: [],\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 { promises as fs } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { 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 { DEFAULT_REGISTRY_URL } from \"../clis/constants.js\";\n\n/**\n * Extract the host portion of a registry URL — what npm uses as the key in\n * `~/.npmrc` for per-registry tokens (e.g. `//registry.dev.vetra.io/`).\n */\nexport function registryAuthKey(registryUrl: string): string {\n const url = new URL(registryUrl);\n // Always trailing slash; npm's lookup is exact-match against the leading\n // path of the registry URL, with `//` prefix and trailing `/`.\n const path = url.pathname.endsWith(\"/\") ? url.pathname : `${url.pathname}/`;\n return `//${url.host}${path}:_authToken`;\n}\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 /** Bearer token for the registry. When set, passed via a registry-scoped\n * `_authToken` config flag rather than read from the user's `.npmrc`. */\n authToken?: 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 *\n * When `authToken` is provided, the token is passed via a registry-scoped\n * `--//host/:_authToken=<token>` flag (npm's standard form for per-registry\n * tokens) so we never have to write to `~/.npmrc`.\n */\nexport async function npmPublish(\n options: NpmPublishOptions,\n): Promise<NpmPublishResult> {\n const { registryUrl, cwd, args = [], authToken } = options;\n const tokenArg = authToken\n ? [`--${registryAuthKey(registryUrl)}=${authToken}`]\n : [];\n const npmArgs = [\"publish\", \"--registry\", registryUrl, ...tokenArg, ...args];\n const stdout = await spawnAsync(\"npm\", npmArgs, { cwd });\n return { stdout };\n}\n\n/**\n * Write `_authToken=<token>` for the given registry host into `~/.npmrc`,\n * preserving any other lines. Replaces the existing entry for the same key\n * if present. Returns the absolute path to the npmrc that was written.\n */\nexport async function writeRegistryAuthToken(\n registryUrl: string,\n token: string,\n): Promise<string> {\n const npmrcPath = join(homedir(), \".npmrc\");\n const key = registryAuthKey(registryUrl);\n let existing = \"\";\n try {\n existing = await fs.readFile(npmrcPath, \"utf8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n const lines = existing.split(\"\\n\");\n const filtered = lines.filter((line) => !line.startsWith(`${key}=`));\n // Also drop any trailing empties to avoid stacking blank lines on rewrite.\n while (filtered.length && filtered[filtered.length - 1] === \"\")\n filtered.pop();\n filtered.push(`${key}=${token}`);\n await fs.writeFile(npmrcPath, `${filtered.join(\"\\n\")}\\n`, \"utf8\");\n return npmrcPath;\n}\n\nexport interface NpmUnpublishOptions {\n /** Registry URL to unpublish from. */\n registryUrl: string;\n /** Working directory (project root). */\n cwd: string;\n /** Package spec: `<name>` (whole package) or `<name>@<version>` (single version). */\n spec: string;\n /** Additional arguments forwarded to npm unpublish. */\n args?: string[];\n /** Bearer token for the registry (same semantics as `NpmPublishOptions.authToken`). */\n authToken?: string;\n}\n\nexport interface NpmUnpublishResult {\n /** stdout from npm unpublish. */\n stdout: string;\n}\n\n/**\n * Run `npm unpublish` against the given registry.\n * Always passes `--force` because npm otherwise refuses to unpublish packages\n * older than 72h (a public-npmjs safeguard that doesn't apply to private registries).\n */\nexport async function npmUnpublish(\n options: NpmUnpublishOptions,\n): Promise<NpmUnpublishResult> {\n const { registryUrl, cwd, spec, args = [], authToken } = options;\n const tokenArg = authToken\n ? [`--${registryAuthKey(registryUrl)}=${authToken}`]\n : [];\n const npmArgs = [\n \"unpublish\",\n spec,\n \"--registry\",\n registryUrl,\n \"--force\",\n ...tokenArg,\n ...args,\n ];\n const stdout = await spawnAsync(\"npm\", npmArgs, { cwd });\n return { stdout };\n}\n"],"mappings":";;;;AA0CA,MAAa,uBAAuB;AAQp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W,GAAG,SAAS,KAAK,KAAK,CAAC,KAAK,OAAO;AACjE,QAAO;;;;;;;AA0BT,eAAsB,aACpB,SAC6B;CAC7B,MAAM,EAAE,aAAa,KAAK,MAAM,OAAO,EAAE,EAAE,cAAc;AAczD,QAAO,EAAE,QADM,MAAM,WAAW,OAThB;EACd;EACA;EACA;EACA;EACA;EACA,GATe,YACb,CAAC,KAAK,gBAAgB,YAAY,CAAC,GAAG,YAAY,GAClD,EAAE;EAQJ,GAAG;EACJ,EAC+C,EAAE,KAAK,CAAC,EACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/shared",
3
- "version": "6.1.0-dev.6",
3
+ "version": "6.1.0-dev.7",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -126,6 +126,7 @@
126
126
  "@sentry/node-core": "^10.52.0",
127
127
  "@types/bun": "1.3.8",
128
128
  "@types/luxon": "3.7.1",
129
+ "@types/node": "25.2.3",
129
130
  "@types/npm-package-arg": "6.1.4",
130
131
  "@types/react": "19.2.14",
131
132
  "kysely": "0.28.16",