pinnace 0.0.0 → 0.2.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.
Files changed (83) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +164 -0
  3. package/dist/car/car-build.d.ts +26 -0
  4. package/dist/car/car-build.d.ts.map +1 -0
  5. package/dist/car/car-build.js +113 -0
  6. package/dist/car/car-build.js.map +1 -0
  7. package/dist/ci/ci-emit.d.ts +116 -0
  8. package/dist/ci/ci-emit.d.ts.map +1 -0
  9. package/dist/ci/ci-emit.js +190 -0
  10. package/dist/ci/ci-emit.js.map +1 -0
  11. package/dist/cli/bin.d.ts +3 -0
  12. package/dist/cli/bin.d.ts.map +1 -0
  13. package/dist/cli/bin.js +17 -0
  14. package/dist/cli/bin.js.map +1 -0
  15. package/dist/cli/run.d.ts +94 -0
  16. package/dist/cli/run.d.ts.map +1 -0
  17. package/dist/cli/run.js +731 -0
  18. package/dist/cli/run.js.map +1 -0
  19. package/dist/config/config-resolution.d.ts +186 -0
  20. package/dist/config/config-resolution.d.ts.map +1 -0
  21. package/dist/config/config-resolution.js +137 -0
  22. package/dist/config/config-resolution.js.map +1 -0
  23. package/dist/deploy/deploy.d.ts +121 -0
  24. package/dist/deploy/deploy.d.ts.map +1 -0
  25. package/dist/deploy/deploy.js +150 -0
  26. package/dist/deploy/deploy.js.map +1 -0
  27. package/dist/derive/ipns-key-derivation.d.ts +37 -0
  28. package/dist/derive/ipns-key-derivation.d.ts.map +1 -0
  29. package/dist/derive/ipns-key-derivation.js +130 -0
  30. package/dist/derive/ipns-key-derivation.js.map +1 -0
  31. package/dist/index.d.ts +27 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +29 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/node/node-commands.d.ts +115 -0
  36. package/dist/node/node-commands.d.ts.map +1 -0
  37. package/dist/node/node-commands.js +231 -0
  38. package/dist/node/node-commands.js.map +1 -0
  39. package/dist/provision/cloud-init.d.ts +162 -0
  40. package/dist/provision/cloud-init.d.ts.map +1 -0
  41. package/dist/provision/cloud-init.js +460 -0
  42. package/dist/provision/cloud-init.js.map +1 -0
  43. package/dist/publisher/key-import.d.ts +105 -0
  44. package/dist/publisher/key-import.d.ts.map +1 -0
  45. package/dist/publisher/key-import.js +76 -0
  46. package/dist/publisher/key-import.js.map +1 -0
  47. package/dist/publisher/record-sequence.d.ts +90 -0
  48. package/dist/publisher/record-sequence.d.ts.map +1 -0
  49. package/dist/publisher/record-sequence.js +250 -0
  50. package/dist/publisher/record-sequence.js.map +1 -0
  51. package/dist/rpc/kubo-rpc-client.d.ts +154 -0
  52. package/dist/rpc/kubo-rpc-client.d.ts.map +1 -0
  53. package/dist/rpc/kubo-rpc-client.js +207 -0
  54. package/dist/rpc/kubo-rpc-client.js.map +1 -0
  55. package/dist/rpc/mock-kubo.d.ts +87 -0
  56. package/dist/rpc/mock-kubo.d.ts.map +1 -0
  57. package/dist/rpc/mock-kubo.js +129 -0
  58. package/dist/rpc/mock-kubo.js.map +1 -0
  59. package/dist/site/site-management.d.ts +126 -0
  60. package/dist/site/site-management.d.ts.map +1 -0
  61. package/dist/site/site-management.js +123 -0
  62. package/dist/site/site-management.js.map +1 -0
  63. package/dist/status/status-report.d.ts +145 -0
  64. package/dist/status/status-report.d.ts.map +1 -0
  65. package/dist/status/status-report.js +192 -0
  66. package/dist/status/status-report.js.map +1 -0
  67. package/package.json +45 -2
  68. package/src/car/car-build.ts +135 -0
  69. package/src/ci/ci-emit.ts +284 -0
  70. package/src/cli/bin.ts +20 -0
  71. package/src/cli/run.ts +970 -0
  72. package/src/config/config-resolution.ts +264 -0
  73. package/src/deploy/deploy.ts +250 -0
  74. package/src/derive/ipns-key-derivation.ts +173 -0
  75. package/src/index.ts +146 -0
  76. package/src/node/node-commands.ts +395 -0
  77. package/src/provision/cloud-init.ts +646 -0
  78. package/src/publisher/key-import.ts +141 -0
  79. package/src/publisher/record-sequence.ts +336 -0
  80. package/src/rpc/kubo-rpc-client.ts +281 -0
  81. package/src/rpc/mock-kubo.ts +194 -0
  82. package/src/site/site-management.ts +241 -0
  83. package/src/status/status-report.ts +291 -0
@@ -0,0 +1,94 @@
1
+ import { type NodeVerb, type NodeCommandContext, type NodeCommandResult } from '../node/node-commands.js';
2
+ import { type ListSitesInput, type SiteListing, type RemoveSiteInput, type RemoveSiteResult, type AddSiteInput, type AddSiteResult } from '../site/site-management.js';
3
+ import { type PromoteReplicaInput, type PromoteReplicaResult } from '../publisher/record-sequence.js';
4
+ import { type DeriveIpnsInput as DeriveIpnsKeyInput, type DerivedIpnsKey } from '../derive/ipns-key-derivation.js';
5
+ import { type ProvisionInput, type ProvisionResult } from '../provision/cloud-init.js';
6
+ import { type DeployInput, type DeployResult } from '../deploy/deploy.js';
7
+ import { type EmitCiInput, type EmittedCi } from '../ci/ci-emit.js';
8
+ import { type StatusReportInput, type StatusReport } from '../status/status-report.js';
9
+ import { type DeriveIpnsInput } from '../derive/ipns-key-derivation.js';
10
+ import { type PinnaceConfigFile, type EnvRecord } from '../config/config-resolution.js';
11
+ /**
12
+ * The core functions the client verbs dispatch to. This seam is what makes the
13
+ * CLI a THIN wrapper AND independently testable: production wires the real core
14
+ * ({@link DEFAULT_DEPS}); tests inject recording stubs and assert each verb
15
+ * calls the RIGHT function with the correctly-resolved arguments (rather than
16
+ * re-testing the core through the CLI).
17
+ */
18
+ export interface ClientDeps {
19
+ /** `provision` -> the cloud-init generator. */
20
+ provision(input: ProvisionInput): ProvisionResult;
21
+ /** `deploy` -> the multi-target CAR deploy. */
22
+ deploy(input: DeployInput): Promise<DeployResult>;
23
+ /** `install-ci` -> the CI workflow emitter. */
24
+ emitCi(input: EmitCiInput): EmittedCi;
25
+ /** `status` -> the per-site status report. */
26
+ statusReport(input: StatusReportInput): Promise<StatusReport>;
27
+ /** `derive` -> the master + site `id` -> IPNS id derivation (no deploy). */
28
+ deriveIpnsId(input: DeriveIpnsInput): string;
29
+ /** `node <verb>` -> the on-box command runner (context assembled by the CLI). */
30
+ runNodeCommand(verb: NodeVerb, ctx: NodeCommandContext): Promise<NodeCommandResult>;
31
+ /** `site list` -> enumerate the node's MFS sites. */
32
+ listSites(input: ListSitesInput): Promise<SiteListing[]>;
33
+ /** `site remove` -> drop an MFS site + unpin its content. */
34
+ removeSite(input: RemoveSiteInput): Promise<RemoveSiteResult>;
35
+ /** `site add` -> place an already-imported CID into MFS as a site. */
36
+ addSite(input: AddSiteInput): Promise<AddSiteResult>;
37
+ /** `promote` -> derive the per-site key material from the master + `id`. */
38
+ deriveIpnsKey(input: DeriveIpnsKeyInput): DerivedIpnsKey;
39
+ /** `promote` -> import the key + flip the node's role to publisher (story 14). */
40
+ promoteReplicaToPublisher(input: PromoteReplicaInput): Promise<PromoteReplicaResult>;
41
+ }
42
+ /**
43
+ * The CLI run context: the injectable env/config/output/core seams. Everything
44
+ * is optional; omitted fields default to the real process environment, a real
45
+ * `pinnace.json` read, `console` sinks, and the real core. Tests pass explicit
46
+ * in-memory values to stay hermetic.
47
+ */
48
+ export interface RunContext {
49
+ /** The env layer (defaults to `process.env`). Tests pass an in-memory record. */
50
+ env?: EnvRecord;
51
+ /**
52
+ * Load the parsed config file (defaults to reading `./pinnace.json`, or an
53
+ * empty config if absent). Tests pass an in-memory object.
54
+ *
55
+ * `path` is the operator's explicit `--config <path>` when given, else
56
+ * `undefined` (the `./pinnace.json` default). The default loader treats an
57
+ * ABSENT default file as a benign empty config, but an explicitly-named path
58
+ * that is missing / unreadable / invalid JSON must THROW so `run()` can fail
59
+ * loud naming that path (an operator-named file is a claim it exists).
60
+ */
61
+ loadConfigFile?: (path?: string) => PinnaceConfigFile;
62
+ /** The core functions to dispatch to (defaults to the real core). */
63
+ deps?: ClientDeps;
64
+ /** stdout sink (defaults to `console.log`). */
65
+ out?: (line: string) => void;
66
+ /** stderr sink (defaults to `console.error`). */
67
+ err?: (line: string) => void;
68
+ }
69
+ /**
70
+ * An explicitly-named `--config <path>` could not be read or parsed. Names the
71
+ * path so `run()` can emit a loud, operator-actionable error (exit 1) instead
72
+ * of silently resolving to an empty config.
73
+ */
74
+ export declare class ConfigLoadError extends Error {
75
+ readonly path: string;
76
+ readonly kind: 'read' | 'parse';
77
+ constructor(path: string, kind: 'read' | 'parse', cause?: unknown);
78
+ }
79
+ /**
80
+ * Dispatch a pinnace CLI invocation. Returns the process exit code.
81
+ *
82
+ * Routes the client verbs (provision/deploy/install-ci/status/derive), the
83
+ * on-box `node` namespace, and the `site` namespace. A missing command is a
84
+ * benign no-op (exit 0); an UNKNOWN command is loud (exit 1) so the surface is
85
+ * an explicit allow-list, not a silent catch-all.
86
+ *
87
+ * A GLOBAL `--config <path>` flag may appear BEFORE the command; it is consumed
88
+ * here (stripped from the per-verb argv) and threaded into config loading via
89
+ * the {@link RunContext.loadConfigFile} seam. With no `--config`, the default
90
+ * `./pinnace.json` is read and its absence is benign; an explicitly-named path
91
+ * that is missing/unreadable/invalid JSON fails loud (names the path, exit 1).
92
+ */
93
+ export declare function run(argv: readonly string[], context?: RunContext): Promise<number>;
94
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AA4BA,OAAO,EAGN,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAMN,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEN,KAAK,eAAe,IAAI,kBAAkB,EAC1C,KAAK,cAAc,EACnB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAEN,KAAK,cAAc,EACnB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