bkper 4.31.3 → 5.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.
Files changed (148) hide show
  1. package/README.md +12 -5
  2. package/lib/agent/startup-maintenance.d.ts +7 -4
  3. package/lib/agent/startup-maintenance.d.ts.map +1 -1
  4. package/lib/agent/startup-maintenance.js +13 -29
  5. package/lib/agent/startup-maintenance.js.map +1 -1
  6. package/lib/cli.js +8 -4
  7. package/lib/cli.js.map +1 -1
  8. package/lib/commands/accounts/batch-create.d.ts +1 -1
  9. package/lib/commands/accounts/batch-create.d.ts.map +1 -1
  10. package/lib/commands/accounts/batch-create.js +3 -3
  11. package/lib/commands/accounts/batch-create.js.map +1 -1
  12. package/lib/commands/accounts/list.d.ts +2 -3
  13. package/lib/commands/accounts/list.d.ts.map +1 -1
  14. package/lib/commands/accounts/list.js +2 -12
  15. package/lib/commands/accounts/list.js.map +1 -1
  16. package/lib/commands/accounts/register.js +13 -13
  17. package/lib/commands/accounts/register.js.map +1 -1
  18. package/lib/commands/action.d.ts +2 -3
  19. package/lib/commands/action.d.ts.map +1 -1
  20. package/lib/commands/action.js +2 -3
  21. package/lib/commands/action.js.map +1 -1
  22. package/lib/commands/apps/list.d.ts +2 -3
  23. package/lib/commands/apps/list.d.ts.map +1 -1
  24. package/lib/commands/apps/list.js +2 -14
  25. package/lib/commands/apps/list.js.map +1 -1
  26. package/lib/commands/apps/register.js +10 -10
  27. package/lib/commands/apps/register.js.map +1 -1
  28. package/lib/commands/balances/list.d.ts +0 -2
  29. package/lib/commands/balances/list.d.ts.map +1 -1
  30. package/lib/commands/balances/list.js +9 -17
  31. package/lib/commands/balances/list.js.map +1 -1
  32. package/lib/commands/balances/register.d.ts.map +1 -1
  33. package/lib/commands/balances/register.js +3 -4
  34. package/lib/commands/balances/register.js.map +1 -1
  35. package/lib/commands/books/list.d.ts +2 -4
  36. package/lib/commands/books/list.d.ts.map +1 -1
  37. package/lib/commands/books/list.js +2 -30
  38. package/lib/commands/books/list.js.map +1 -1
  39. package/lib/commands/books/register.js +12 -12
  40. package/lib/commands/books/register.js.map +1 -1
  41. package/lib/commands/cli-helpers.d.ts +9 -4
  42. package/lib/commands/cli-helpers.d.ts.map +1 -1
  43. package/lib/commands/cli-helpers.js +18 -12
  44. package/lib/commands/cli-helpers.js.map +1 -1
  45. package/lib/commands/collections/list.d.ts +2 -3
  46. package/lib/commands/collections/list.d.ts.map +1 -1
  47. package/lib/commands/collections/list.js +2 -14
  48. package/lib/commands/collections/list.js.map +1 -1
  49. package/lib/commands/collections/register.d.ts.map +1 -1
  50. package/lib/commands/collections/register.js +15 -25
  51. package/lib/commands/collections/register.js.map +1 -1
  52. package/lib/commands/events/event-json.d.ts +13 -0
  53. package/lib/commands/events/event-json.d.ts.map +1 -0
  54. package/lib/commands/events/event-json.js +33 -0
  55. package/lib/commands/events/event-json.js.map +1 -0
  56. package/lib/commands/events/list.d.ts +4 -3
  57. package/lib/commands/events/list.d.ts.map +1 -1
  58. package/lib/commands/events/list.js +15 -66
  59. package/lib/commands/events/list.js.map +1 -1
  60. package/lib/commands/events/register.d.ts.map +1 -1
  61. package/lib/commands/events/register.js +7 -6
  62. package/lib/commands/events/register.js.map +1 -1
  63. package/lib/commands/files/list.d.ts +3 -2
  64. package/lib/commands/files/list.d.ts.map +1 -1
  65. package/lib/commands/files/list.js +13 -42
  66. package/lib/commands/files/list.js.map +1 -1
  67. package/lib/commands/files/register.d.ts.map +1 -1
  68. package/lib/commands/files/register.js +13 -10
  69. package/lib/commands/files/register.js.map +1 -1
  70. package/lib/commands/groups/list.d.ts +2 -3
  71. package/lib/commands/groups/list.d.ts.map +1 -1
  72. package/lib/commands/groups/list.js +2 -12
  73. package/lib/commands/groups/list.js.map +1 -1
  74. package/lib/commands/groups/register.js +12 -12
  75. package/lib/commands/groups/register.js.map +1 -1
  76. package/lib/commands/transactions/batch-create.d.ts +1 -1
  77. package/lib/commands/transactions/batch-create.d.ts.map +1 -1
  78. package/lib/commands/transactions/batch-create.js +4 -3
  79. package/lib/commands/transactions/batch-create.js.map +1 -1
  80. package/lib/commands/transactions/batch-update.d.ts +1 -1
  81. package/lib/commands/transactions/batch-update.d.ts.map +1 -1
  82. package/lib/commands/transactions/batch-update.js +4 -3
  83. package/lib/commands/transactions/batch-update.js.map +1 -1
  84. package/lib/commands/transactions/list.d.ts +4 -7
  85. package/lib/commands/transactions/list.d.ts.map +1 -1
  86. package/lib/commands/transactions/list.js +15 -32
  87. package/lib/commands/transactions/list.js.map +1 -1
  88. package/lib/commands/transactions/register.d.ts +1 -1
  89. package/lib/commands/transactions/register.d.ts.map +1 -1
  90. package/lib/commands/transactions/register.js +27 -26
  91. package/lib/commands/transactions/register.js.map +1 -1
  92. package/lib/commands/transactions/transaction-json.d.ts +23 -0
  93. package/lib/commands/transactions/transaction-json.d.ts.map +1 -0
  94. package/lib/commands/transactions/transaction-json.js +56 -0
  95. package/lib/commands/transactions/transaction-json.js.map +1 -0
  96. package/lib/commands/upgrade.d.ts.map +1 -1
  97. package/lib/commands/upgrade.js +2 -3
  98. package/lib/commands/upgrade.js.map +1 -1
  99. package/lib/docs/apps/ai.md +2 -2
  100. package/lib/docs/apps/event-handlers.md +12 -0
  101. package/lib/docs/cli/app-management.md +1 -1
  102. package/lib/docs/cli/data-management.md +56 -54
  103. package/lib/docs/index.md +1 -1
  104. package/lib/docs/sdk/bkper-api-types.md +4 -2
  105. package/lib/docs/sdk/bkper-js.md +1 -0
  106. package/lib/docs-compliance/live-readme.d.ts.map +1 -1
  107. package/lib/docs-compliance/live-readme.js +0 -3
  108. package/lib/docs-compliance/live-readme.js.map +1 -1
  109. package/lib/docs-compliance/rules.d.ts.map +1 -1
  110. package/lib/docs-compliance/rules.js +9 -0
  111. package/lib/docs-compliance/rules.js.map +1 -1
  112. package/lib/render/index.d.ts +2 -4
  113. package/lib/render/index.d.ts.map +1 -1
  114. package/lib/render/index.js +1 -3
  115. package/lib/render/index.js.map +1 -1
  116. package/lib/render/output.d.ts +42 -22
  117. package/lib/render/output.d.ts.map +1 -1
  118. package/lib/render/output.js +62 -42
  119. package/lib/render/output.js.map +1 -1
  120. package/lib/upgrade/index.d.ts +5 -4
  121. package/lib/upgrade/index.d.ts.map +1 -1
  122. package/lib/upgrade/index.js +3 -2
  123. package/lib/upgrade/index.js.map +1 -1
  124. package/lib/upgrade/installation.d.ts +54 -20
  125. package/lib/upgrade/installation.d.ts.map +1 -1
  126. package/lib/upgrade/installation.js +222 -122
  127. package/lib/upgrade/installation.js.map +1 -1
  128. package/lib/upgrade/update-check.d.ts +69 -0
  129. package/lib/upgrade/update-check.d.ts.map +1 -0
  130. package/lib/upgrade/update-check.js +253 -0
  131. package/lib/upgrade/update-check.js.map +1 -0
  132. package/lib/upgrade/update-worker.d.ts +2 -0
  133. package/lib/upgrade/update-worker.d.ts.map +1 -0
  134. package/lib/upgrade/update-worker.js +6 -0
  135. package/lib/upgrade/update-worker.js.map +1 -0
  136. package/lib/upgrade/upgrade.d.ts +11 -28
  137. package/lib/upgrade/upgrade.d.ts.map +1 -1
  138. package/lib/upgrade/upgrade.js +49 -96
  139. package/lib/upgrade/upgrade.js.map +1 -1
  140. package/package.json +1 -1
  141. package/lib/render/csv-formatter.d.ts +0 -15
  142. package/lib/render/csv-formatter.d.ts.map +0 -1
  143. package/lib/render/csv-formatter.js +0 -37
  144. package/lib/render/csv-formatter.js.map +0 -1
  145. package/lib/render/table-formatter.d.ts +0 -34
  146. package/lib/render/table-formatter.d.ts.map +0 -1
  147. package/lib/render/table-formatter.js +0 -239
  148. package/lib/render/table-formatter.js.map +0 -1
@@ -1,54 +1,74 @@
1
- import { formatTable, formatItem } from './table-formatter.js';
2
- import { formatCsv } from './csv-formatter.js';
3
1
  /**
4
- * Renders a ListResult to stdout based on the active output format.
2
+ * JSON-only output rendering.
3
+ *
4
+ * Contract:
5
+ * - stdout carries only the JSON result, so it is always parseable (e.g. by jq).
6
+ * - Lists use a stable `{"items":[...]}` envelope, adding `"cursor"` only when a
7
+ * next page exists. Each record is compact on its own line.
8
+ * - Matrices (balance reports) are bare 2D arrays with one row per line.
9
+ * - Single items are pretty-printed only on an interactive terminal.
10
+ * - Hints, notices, and warnings go to stderr.
5
11
  */
6
- export function renderListResult(result, format) {
7
- if (result.kind === 'json') {
8
- const payload = result.cursor ? { items: result.items, cursor: result.cursor } : result.items;
9
- console.log(JSON.stringify(payload, null, 2));
10
- return;
11
- }
12
- renderTable(result.matrix, format);
13
- if (result.footer && format === 'table') {
14
- console.log(result.footer);
15
- }
12
+ /**
13
+ * Serializes lines as a JSON array body with one entry per line.
14
+ */
15
+ function formatLines(lines) {
16
+ return lines.length > 0 ? `[\n${lines.join(',\n')}\n]` : '[]';
16
17
  }
17
18
  /**
18
- * Renders a 2D matrix as a formatted table, JSON, or CSV.
19
- *
20
- * @param matrix - 2D array where row 0 is headers and rows 1+ are data
21
- * @param format - Output format: 'table' (default), 'json', or 'csv'
22
- */
23
- export function renderTable(matrix, format) {
24
- switch (format) {
25
- case 'json':
26
- console.log(JSON.stringify(matrix, null, 2));
27
- return;
28
- case 'csv': {
29
- const csv = formatCsv(matrix);
30
- console.log(csv || 'No results found.');
31
- return;
32
- }
33
- default: {
34
- const formatted = formatTable(matrix);
35
- console.log(formatted || 'No results found.');
36
- }
19
+ * Formats list items in the `{"items":[...]}` envelope, one record per line.
20
+ */
21
+ export function formatList(items, cursor) {
22
+ const body = formatLines(items.map(item => JSON.stringify(item)));
23
+ const cursorPart = cursor !== undefined ? `,"cursor":${JSON.stringify(cursor)}` : '';
24
+ return `{"items":${body}${cursorPart}}`;
25
+ }
26
+ /**
27
+ * Formats a 2D matrix as JSON, one row per line.
28
+ */
29
+ export function formatMatrix(matrix) {
30
+ return formatLines(matrix.map(row => JSON.stringify(row)));
31
+ }
32
+ /**
33
+ * Formats a single item as pretty (2-space) or compact JSON.
34
+ */
35
+ export function formatItem(item, pretty) {
36
+ return pretty ? JSON.stringify(item, null, 2) : JSON.stringify(item);
37
+ }
38
+ /**
39
+ * Whether stdout is an interactive terminal (a human is reading).
40
+ */
41
+ export function isInteractiveOutput() {
42
+ return process.stdout.isTTY === true;
43
+ }
44
+ /**
45
+ * Renders a list result: JSON to stdout, hint to stderr.
46
+ */
47
+ export function renderList(result) {
48
+ console.log(formatList(result.items, result.cursor));
49
+ if (result.hint) {
50
+ console.error(result.hint);
37
51
  }
38
52
  }
39
53
  /**
40
- * Renders a single item as key-value pairs, JSON, or JSON (for CSV, since
41
- * single items are not tabular, CSV falls back to JSON).
54
+ * Renders a 2D matrix as JSON to stdout.
55
+ */
56
+ export function renderMatrix(matrix) {
57
+ console.log(formatMatrix(matrix));
58
+ }
59
+ /**
60
+ * Renders a single item as JSON to stdout.
42
61
  *
43
62
  * @param item - Record to render
44
- * @param format - Output format: 'table' (default), 'json', or 'csv'
63
+ * @param pretty - Pretty-print; defaults to true only on an interactive terminal
45
64
  */
46
- export function renderItem(item, format) {
47
- if (format === 'json' || format === 'csv') {
48
- console.log(JSON.stringify(item, null, 2));
49
- return;
50
- }
51
- const formatted = formatItem(item);
52
- console.log(formatted || 'No results found.');
65
+ export function renderItem(item, pretty = isInteractiveOutput()) {
66
+ console.log(formatItem(item, pretty));
67
+ }
68
+ /**
69
+ * Renders a human-readable notice (e.g. success without a result) to stderr.
70
+ */
71
+ export function renderNotice(message) {
72
+ console.error(message);
53
73
  }
54
74
  //# sourceMappingURL=output.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/render/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAkB,EAAE,MAAoB;IACrE,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,C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C,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAC/B,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAkB;IACzC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAmB;IAC5C,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,MAAM,GAAG,mBAAmB,EAAE;IACnE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC"}
@@ -1,5 +1,6 @@
1
- export { VERSION, detectMethod, detectMethodAsync, fetchLatestVersion, getUpgradeCommand, isVersionInstalledAsync, startDetachedUpgrade, } from './installation.js';
2
- export { autoUpgrade, foregroundUpgrade, getAvailableUpgrade, isNewerVersion, } from './upgrade.js';
3
- export type { InstallMethod } from './installation.js';
4
- export type { AvailableUpgrade } from './upgrade.js';
1
+ export { PACKAGE_DIR, VERSION, detectInstallMethod, fetchLatestVersion, getInstallCommand, getSelfUpdatePlan, } from './installation.js';
2
+ export { foregroundUpgrade, isNewerVersion, runUpgrade } from './upgrade.js';
3
+ export { formatUpdateNotice, getUpdateNotice, isUpdateCheckDisabled, maybeStartUpdateCheck, readUpdateState, runCommandUpdateCheck, } from './update-check.js';
4
+ export type { InstallMethod, SelfUpdatePlan } from './installation.js';
5
+ export type { UpdateNotice } from './update-check.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACH,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,3 +1,4 @@
1
- export { VERSION, detectMethod, detectMethodAsync, fetchLatestVersion, getUpgradeCommand, isVersionInstalledAsync, startDetachedUpgrade, } from './installation.js';
2
- export { autoUpgrade, foregroundUpgrade, getAvailableUpgrade, isNewerVersion, } from './upgrade.js';
1
+ export { PACKAGE_DIR, VERSION, detectInstallMethod, fetchLatestVersion, getInstallCommand, getSelfUpdatePlan, } from './installation.js';
2
+ export { foregroundUpgrade, isNewerVersion, runUpgrade } from './upgrade.js';
3
+ export { formatUpdateNotice, getUpdateNotice, isUpdateCheckDisabled, maybeStartUpdateCheck, readUpdateState, runCommandUpdateCheck, } from './update-check.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,GACjB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACH,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,GACxB,MAAM,mBAAmB,CAAC"}
@@ -1,38 +1,72 @@
1
1
  /** Current installed version of the CLI. */
2
2
  export declare const VERSION: string;
3
+ /** Directory of the running bkper package (the folder holding its package.json). */
4
+ export declare const PACKAGE_DIR: string;
3
5
  /** Supported installation methods. */
4
- export type InstallMethod = 'npm' | 'bun' | 'yarn' | 'unknown';
5
- export type CommandRunner = (command: string, timeoutMs: number) => Promise<string>;
6
- export type DetachedCommandStarter = (command: string) => void;
6
+ export type InstallMethod = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'unknown';
7
+ /** Where the running CLI lives and how it was started. */
8
+ export interface RuntimeLocation {
9
+ packageDir: string;
10
+ /** process.argv[1], not symlink-resolved. */
11
+ entrypoint?: string;
12
+ execPath: string;
13
+ isBunRuntime: boolean;
14
+ platform: NodeJS.Platform;
15
+ }
16
+ /** Side effects needed to decide whether the running copy can upgrade itself. */
17
+ export interface SelfUpdateEnvironment {
18
+ homedir: string;
19
+ readCommandOutput: (command: string) => string | undefined;
20
+ isWritable: (dir: string) => boolean;
21
+ }
22
+ export interface InstallPlan {
23
+ kind: 'install';
24
+ method: InstallMethod;
25
+ packageDir: string;
26
+ command: string;
27
+ /** package.json to read after installing, reached through the global root. */
28
+ packageJsonPath: string;
29
+ }
30
+ export interface ManualPlan {
31
+ kind: 'manual';
32
+ method: InstallMethod;
33
+ packageDir: string;
34
+ instruction: string;
35
+ }
36
+ export type SelfUpdatePlan = InstallPlan | ManualPlan;
37
+ export declare function getRuntimeLocation(): RuntimeLocation;
7
38
  /**
8
- * Detects how the CLI was installed by checking global package lists
9
- * for each supported package manager.
39
+ * Detects the package manager from the location of the running code
40
+ * (same rules as Pi's detectInstallMethod).
10
41
  */
11
- export declare function detectMethod(): InstallMethod;
42
+ export declare function detectInstallMethod(location?: RuntimeLocation): InstallMethod;
12
43
  /**
13
- * Async version of installation method detection to avoid blocking the event loop.
44
+ * Infers the npm prefix from a `<prefix>/lib/node_modules/bkper` layout.
45
+ * Windows prefixes look like project installs, so they are never inferred.
14
46
  */
15
- export declare function detectMethodAsync(commandRunner?: CommandRunner): Promise<InstallMethod>;
47
+ export declare function inferNpmPrefix(packageDir: string, platform: NodeJS.Platform): string | undefined;
16
48
  /**
17
- * Checks whether a specific Bkper version is already installed globally.
49
+ * Returns the shell command that installs a version with a package manager.
18
50
  */
19
- export declare function isVersionInstalledAsync(method: InstallMethod, version: string, commandRunner?: CommandRunner): Promise<boolean>;
51
+ export declare function getInstallCommand(method: InstallMethod, version: string, npmPrefix?: string): string | null;
20
52
  /**
21
- * Fetches the latest published version from the npm registry.
22
- * Returns null if the fetch fails.
53
+ * Decides whether the running copy can safely upgrade itself: it must be
54
+ * inside its package manager's global root and writable. Otherwise returns
55
+ * the manual instruction to show. Never suggests sudo.
23
56
  */
24
- export declare function fetchLatestVersion(): Promise<string | null>;
57
+ export declare function getSelfUpdatePlan(version: string, location?: RuntimeLocation, environment?: SelfUpdateEnvironment): SelfUpdatePlan;
25
58
  /**
26
- * Returns the shell command to upgrade the CLI for a given install method and version.
59
+ * Reads a package version from disk, bypassing the module cache.
27
60
  */
28
- export declare function getUpgradeCommand(method: InstallMethod, version: string): string | null;
61
+ export declare function readInstalledVersion(packageJsonPath: string): string | undefined;
29
62
  /**
30
- * Executes the upgrade to the specified version using the given install method.
31
- * Throws if the upgrade command fails.
63
+ * Runs an install command synchronously. BKPER_AUTOUPDATE_COMMAND replaces
64
+ * the command (for tests) but never the safety checks that lead here.
32
65
  */
33
- export declare function executeUpgrade(method: InstallMethod, version: string): void;
66
+ export declare function runInstallCommand(command: string): void;
34
67
  /**
35
- * Starts the upgrade in a detached background process.
68
+ * Fetches the latest published version from the npm registry.
69
+ * Returns null if the fetch fails.
36
70
  */
37
- export declare function startDetachedUpgrade(method: InstallMethod, version: string, commandStarter?: DetachedCommandStarter): void;
71
+ export declare function fetchLatestVersion(timeoutMs?: number): Promise<string | null>;
38
72
  //# sourceMappingURL=installation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"installation.d.ts","sourceRoot":"","sources":["../../src/upgrade/installation.ts"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAK3C,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE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