@dinoxx/dinox-cli 1.1.1 → 2.0.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 (104) hide show
  1. package/README.md +44 -3
  2. package/dist/cli.js +4 -0
  3. package/dist/commands/auth/index.js +1 -2
  4. package/dist/commands/boxes/index.js +37 -13
  5. package/dist/commands/boxes/operations.d.ts +3 -3
  6. package/dist/commands/boxes/operations.js +51 -28
  7. package/dist/commands/info/index.js +30 -5
  8. package/dist/commands/meta/repo.js +2 -1
  9. package/dist/commands/notes/actions.js +20 -37
  10. package/dist/commands/notes/bulk.d.ts +2 -2
  11. package/dist/commands/notes/bulk.js +3 -18
  12. package/dist/commands/notes/contentPatch.d.ts +5 -1
  13. package/dist/commands/notes/contentPatch.js +12 -1
  14. package/dist/commands/notes/contentPatchCommand.d.ts +3 -0
  15. package/dist/commands/notes/contentPatchCommand.js +29 -8
  16. package/dist/commands/notes/descriptors.js +19 -16
  17. package/dist/commands/notes/export.js +3 -0
  18. package/dist/commands/notes/repo.d.ts +9 -0
  19. package/dist/commands/notes/repo.js +65 -15
  20. package/dist/commands/notes/searchOutput.d.ts +2 -1
  21. package/dist/commands/notes/searchOutput.js +2 -1
  22. package/dist/commands/notes/searchSql.js +9 -3
  23. package/dist/commands/prompt/index.d.ts +1 -0
  24. package/dist/commands/prompt/index.js +26 -11
  25. package/dist/commands/savedViews/index.d.ts +7 -0
  26. package/dist/commands/savedViews/index.js +458 -0
  27. package/dist/commands/savedViews/model.d.ts +87 -0
  28. package/dist/commands/savedViews/model.js +306 -0
  29. package/dist/commands/savedViews/repo.d.ts +123 -0
  30. package/dist/commands/savedViews/repo.js +512 -0
  31. package/dist/commands/savedViews/semantics.d.ts +46 -0
  32. package/dist/commands/savedViews/semantics.js +738 -0
  33. package/dist/commands/schema/renderSkills.d.ts +2 -0
  34. package/dist/commands/schema/renderSkills.js +69 -10
  35. package/dist/commands/schema/spec.js +4 -0
  36. package/dist/commands/skills/index.d.ts +54 -0
  37. package/dist/commands/skills/index.js +468 -0
  38. package/dist/commands/storage/index.js +2 -2
  39. package/dist/commands/sync.js +2 -1
  40. package/dist/commands/tags/index.js +30 -11
  41. package/dist/commands/tags/operations.d.ts +3 -3
  42. package/dist/commands/tags/operations.js +45 -20
  43. package/dist/commands/templates/model.d.ts +50 -0
  44. package/dist/commands/templates/model.js +239 -0
  45. package/dist/commands/todo/index.js +3 -3
  46. package/dist/commands/update.d.ts +1 -0
  47. package/dist/commands/update.js +46 -9
  48. package/dist/commands/writeConfirmation.d.ts +13 -0
  49. package/dist/commands/writeConfirmation.js +54 -0
  50. package/dist/config/resolve.js +5 -10
  51. package/dist/config/types.d.ts +3 -6
  52. package/dist/constants/links.d.ts +18 -1
  53. package/dist/constants/links.js +26 -1
  54. package/dist/daemon/client.d.ts +2 -2
  55. package/dist/daemon/client.js +106 -52
  56. package/dist/daemon/index.d.ts +5 -3
  57. package/dist/daemon/index.js +28 -5
  58. package/dist/daemon/lifecycle.d.ts +7 -2
  59. package/dist/daemon/lifecycle.js +53 -13
  60. package/dist/daemon/pid.d.ts +1 -1
  61. package/dist/daemon/pid.js +6 -3
  62. package/dist/dinox.js +9 -1
  63. package/dist/powersync/exclusiveRuntime.d.ts +1 -0
  64. package/dist/powersync/exclusiveRuntime.js +26 -8
  65. package/dist/powersync/runtime.d.ts +3 -2
  66. package/dist/powersync/runtime.js +19 -3
  67. package/dist/powersync/schema/content.d.ts +1 -78
  68. package/dist/powersync/schema/content.js +1 -78
  69. package/dist/powersync/schema/electronCanonical.d.ts +1561 -0
  70. package/dist/powersync/schema/electronCanonical.js +1154 -0
  71. package/dist/powersync/schema/index.d.ts +573 -129
  72. package/dist/powersync/schema/index.js +3 -32
  73. package/dist/powersync/schema/local.d.ts +1 -56
  74. package/dist/powersync/schema/local.js +1 -60
  75. package/dist/powersync/schema/note.d.ts +1 -35
  76. package/dist/powersync/schema/note.js +1 -35
  77. package/dist/powersync/schema/notesExtras.d.ts +1 -62
  78. package/dist/powersync/schema/notesExtras.js +1 -71
  79. package/dist/powersync/schema/projects.d.ts +1 -104
  80. package/dist/powersync/schema/projects.js +1 -104
  81. package/dist/powersync/schema/savedViews.d.ts +1 -0
  82. package/dist/powersync/schema/savedViews.js +1 -0
  83. package/dist/powersync/schema/storage.d.ts +1 -24
  84. package/dist/powersync/schema/storage.js +1 -24
  85. package/dist/powersync/schema/tags.d.ts +1 -37
  86. package/dist/powersync/schema/tags.js +1 -37
  87. package/dist/powersync/syncGate.d.ts +20 -2
  88. package/dist/powersync/uploader.d.ts +16 -2
  89. package/dist/powersync/uploader.js +152 -158
  90. package/dist/skills/check.d.ts +1 -0
  91. package/dist/skills/check.js +538 -70
  92. package/dist/skills/retired.d.ts +60 -0
  93. package/dist/skills/retired.js +58 -0
  94. package/dist/utils/deadline.d.ts +8 -0
  95. package/dist/utils/deadline.js +31 -0
  96. package/dist/utils/dryRun.d.ts +20 -1
  97. package/dist/utils/dryRun.js +22 -3
  98. package/dist/utils/errors.d.ts +2 -0
  99. package/dist/utils/errors.js +2 -0
  100. package/dist/utils/processExit.d.ts +1 -0
  101. package/dist/utils/processExit.js +33 -0
  102. package/dist/utils/updateNotice.d.ts +1 -0
  103. package/dist/utils/updateNotice.js +1 -1
  104. package/package.json +8 -5
package/dist/dinox.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { createCli } from './cli.js';
3
3
  import { buildStructuredErrorPayload, isDinoxError } from './utils/errors.js';
4
4
  import { clearRequestedStructuredOutputFormat, parseStructuredOutputFormatFromArgv, printError, printHumanReadableError, setRequestedStructuredOutputFormat, } from './utils/output.js';
5
+ import { exitProcessAfterFlushing } from './utils/processExit.js';
5
6
  function normalizeArgv(argv) {
6
7
  // pnpm/npm script forwarding can prepend a standalone "--".
7
8
  if (argv[0] === '--') {
@@ -25,7 +26,12 @@ function isCommanderError(error) {
25
26
  && error.code.startsWith('commander.')
26
27
  && typeof error.exitCode === 'number';
27
28
  }
28
- main().catch((error) => {
29
+ async function exitAfterFatalCleanup(error, exitCode) {
30
+ if (isDinoxError(error) && error.requiresProcessExit) {
31
+ await exitProcessAfterFlushing(exitCode);
32
+ }
33
+ }
34
+ main().catch(async (error) => {
29
35
  if (isCommanderError(error)) {
30
36
  process.exitCode = error.exitCode === 0 ? 0 : 2;
31
37
  return;
@@ -46,6 +52,7 @@ main().catch((error) => {
46
52
  setRequestedStructuredOutputFormat(format);
47
53
  printError(payload, format);
48
54
  clearRequestedStructuredOutputFormat();
55
+ await exitAfterFatalCleanup(error, exitCode);
49
56
  return;
50
57
  }
51
58
  printHumanReadableError(payload.message);
@@ -59,4 +66,5 @@ main().catch((error) => {
59
66
  if (verbose && payload.stack) {
60
67
  printHumanReadableError(payload.stack);
61
68
  }
69
+ await exitAfterFatalCleanup(error, exitCode);
62
70
  });
@@ -13,6 +13,7 @@ export declare function withExclusivePowerSync<T>(args: {
13
13
  offline: boolean;
14
14
  timeoutMs: number;
15
15
  deadlineAtMs?: number;
16
+ operationDeadlineAtMs?: number;
16
17
  waitForInitialSync?: boolean;
17
18
  expectedTokenFingerprint?: string | null;
18
19
  cleanupFailureMode?: 'warn' | 'throw';
@@ -1,4 +1,6 @@
1
1
  import { withDaemonExclusiveAccess } from '../daemon/lifecycle.js';
2
+ import { runWithinDeadline, remainingDeadlineMs } from '../utils/deadline.js';
3
+ import { DinoxError } from '../utils/errors.js';
2
4
  import { printHumanReadableWarning } from '../utils/output.js';
3
5
  import { closePowerSyncAndReleaseOwner, connectPowerSync, } from './runtime.js';
4
6
  const exclusivePowerSyncDependencies = {
@@ -10,16 +12,24 @@ const exclusivePowerSyncDependencies = {
10
12
  function errorMessage(error) {
11
13
  return error instanceof Error ? error.message : String(error);
12
14
  }
15
+ function createRuntimeCleanupDeadlineError() {
16
+ return new DinoxError('Sync deadline exceeded while closing the local PowerSync runtime.', {
17
+ code: 'SYNC_TIMEOUT',
18
+ details: { phase: 'powersync-cleanup' },
19
+ suggestion: 'Run `dino doctor --format json` to verify the local runtime before retrying sync.',
20
+ recoverable: true,
21
+ requiresProcessExit: true,
22
+ });
23
+ }
13
24
  export async function withExclusivePowerSync(args, run, overrides = {}) {
14
25
  const dependencies = { ...exclusivePowerSyncDependencies, ...overrides };
15
- const { cleanupFailureMode, deadlineAtMs, ...connectArgs } = args;
16
- const remainingTimeoutMs = () => deadlineAtMs === undefined
17
- ? args.timeoutMs
18
- : Math.max(1, Math.min(args.timeoutMs, deadlineAtMs - Date.now()));
19
- return dependencies.withDaemonExclusiveAccess(args.config, remainingTimeoutMs(), async (daemonLifecycle) => {
26
+ const { cleanupFailureMode, deadlineAtMs, operationDeadlineAtMs = deadlineAtMs, ...connectArgs } = args;
27
+ const remainingOperationTimeoutMs = () => Math.max(1, remainingDeadlineMs(operationDeadlineAtMs, args.timeoutMs));
28
+ const remainingTotalTimeoutMs = () => Math.max(1, remainingDeadlineMs(deadlineAtMs, args.timeoutMs));
29
+ return dependencies.withDaemonExclusiveAccess(args.config, remainingTotalTimeoutMs(), async (daemonLifecycle) => {
20
30
  const connected = await dependencies.connectPowerSync({
21
31
  ...connectArgs,
22
- timeoutMs: remainingTimeoutMs(),
32
+ timeoutMs: remainingOperationTimeoutMs(),
23
33
  });
24
34
  let outcome;
25
35
  try {
@@ -30,7 +40,11 @@ export async function withExclusivePowerSync(args, run, overrides = {}) {
30
40
  }
31
41
  let cleanupError;
32
42
  try {
33
- await dependencies.closePowerSyncAndReleaseOwner(connected.db, connected.releaseOwner);
43
+ await runWithinDeadline(() => dependencies.closePowerSyncAndReleaseOwner(connected.db, connected.releaseOwner), {
44
+ deadlineAtMs,
45
+ maximumTimeoutMs: args.timeoutMs,
46
+ createTimeoutError: createRuntimeCleanupDeadlineError,
47
+ });
34
48
  }
35
49
  catch (error) {
36
50
  cleanupError = error;
@@ -44,5 +58,9 @@ export async function withExclusivePowerSync(args, run, overrides = {}) {
44
58
  throw cleanupError;
45
59
  }
46
60
  return outcome.value;
47
- }, {}, { deadlineAtMs });
61
+ }, {}, {
62
+ deadlineAtMs,
63
+ operationDeadlineAtMs,
64
+ cleanupFailureMode,
65
+ });
48
66
  }
@@ -1,6 +1,7 @@
1
1
  import { PowerSyncDatabase } from '@powersync/node';
2
- import type { AbstractPowerSyncDatabase, SyncStatusOptions } from '@powersync/common';
2
+ import type { AbstractPowerSyncDatabase } from '@powersync/common';
3
3
  import type { ResolvedDinoxConfig } from '../config/types.js';
4
+ import type { SyncStatusRaw } from './syncGate.js';
4
5
  export type ConnectResult = {
5
6
  db: PowerSyncDatabase;
6
7
  dbPath: string;
@@ -29,7 +30,7 @@ export declare function getStatusSnapshot(db: AbstractPowerSyncDatabase): {
29
30
  message: string;
30
31
  };
31
32
  };
32
- raw: SyncStatusOptions;
33
+ raw: SyncStatusRaw;
33
34
  };
34
35
  export declare function connectPowerSync(args: {
35
36
  config: ResolvedDinoxConfig;
@@ -88,8 +88,25 @@ async function ensureDataDir() {
88
88
  await fs.mkdir(dir, { recursive: true, mode: 0o700 });
89
89
  return dir;
90
90
  }
91
+ function readSyncStatus(status) {
92
+ if (!status)
93
+ return {};
94
+ return {
95
+ connected: status.connected,
96
+ connecting: status.connecting,
97
+ hasSynced: status.hasSynced,
98
+ lastSyncedAt: status.lastSyncedAt,
99
+ dataFlow: {
100
+ downloading: status.downloading,
101
+ uploading: status.uploading,
102
+ downloadError: status.downloadError,
103
+ uploadError: status.uploadError,
104
+ },
105
+ priorityStatusEntries: status.priorityStatusEntries,
106
+ };
107
+ }
91
108
  export function getStatusSnapshot(db) {
92
- const raw = db.currentStatus?.toJSON?.() ?? {};
109
+ const raw = readSyncStatus(db.currentStatus);
93
110
  const lastSyncedAt = raw.lastSyncedAt instanceof Date ? raw.lastSyncedAt.toISOString() : raw.lastSyncedAt ?? null;
94
111
  const dataFlow = raw.dataFlow ?? {};
95
112
  return {
@@ -185,8 +202,7 @@ export async function connectPowerSync(args) {
185
202
  ? createPowerSyncUploadHandler({
186
203
  authorization: args.config.auth.authorization,
187
204
  uploadBaseUrl: args.config.powersync.uploadBaseUrl,
188
- uploadV4Path: args.config.powersync.uploadV4Path,
189
- uploadV2Path: args.config.powersync.uploadV2Path,
205
+ uploadPath: args.config.powersync.uploadPath,
190
206
  timeoutMs: args.timeoutMs,
191
207
  })
192
208
  : undefined;
@@ -1,78 +1 @@
1
- import { Table } from '@powersync/common';
2
- export declare const c_card_box: Table<{
3
- id: import("@powersync/common").BaseColumnType<string | null>;
4
- name: import("@powersync/common").BaseColumnType<string | null>;
5
- type: import("@powersync/common").BaseColumnType<string | null>;
6
- cover_url: import("@powersync/common").BaseColumnType<string | null>;
7
- prompt: import("@powersync/common").BaseColumnType<string | null>;
8
- headers: import("@powersync/common").BaseColumnType<string | null>;
9
- priority: import("@powersync/common").BaseColumnType<number | null>;
10
- created_at: import("@powersync/common").BaseColumnType<string | null>;
11
- updated_at: import("@powersync/common").BaseColumnType<string | null>;
12
- extra_data: import("@powersync/common").BaseColumnType<string | null>;
13
- user_no: import("@powersync/common").BaseColumnType<string | null>;
14
- is_del: import("@powersync/common").BaseColumnType<number | null>;
15
- template_id: import("@powersync/common").BaseColumnType<string | null>;
16
- }>;
17
- export declare const c_card_note: Table<{
18
- id: import("@powersync/common").BaseColumnType<string | null>;
19
- box_id: import("@powersync/common").BaseColumnType<string | null>;
20
- content: import("@powersync/common").BaseColumnType<string | null>;
21
- created_at: import("@powersync/common").BaseColumnType<string | null>;
22
- updated_at: import("@powersync/common").BaseColumnType<string | null>;
23
- extra_data: import("@powersync/common").BaseColumnType<string | null>;
24
- user_no: import("@powersync/common").BaseColumnType<string | null>;
25
- is_del: import("@powersync/common").BaseColumnType<number | null>;
26
- origin_note_id: import("@powersync/common").BaseColumnType<string | null>;
27
- origin_type: import("@powersync/common").BaseColumnType<string | null>;
28
- output_type: import("@powersync/common").BaseColumnType<string | null>;
29
- is_array: import("@powersync/common").BaseColumnType<number | null>;
30
- }>;
31
- export declare const c_cmd: Table<{
32
- id: import("@powersync/common").BaseColumnType<string | null>;
33
- zone: import("@powersync/common").BaseColumnType<string | null>;
34
- type: import("@powersync/common").BaseColumnType<string | null>;
35
- cmd: import("@powersync/common").BaseColumnType<string | null>;
36
- name: import("@powersync/common").BaseColumnType<string | null>;
37
- priority: import("@powersync/common").BaseColumnType<number | null>;
38
- is_show: import("@powersync/common").BaseColumnType<number | null>;
39
- description: import("@powersync/common").BaseColumnType<string | null>;
40
- extra_data: import("@powersync/common").BaseColumnType<string | null>;
41
- user_id: import("@powersync/common").BaseColumnType<string | null>;
42
- insert_at: import("@powersync/common").BaseColumnType<string | null>;
43
- update_at: import("@powersync/common").BaseColumnType<string | null>;
44
- is_del: import("@powersync/common").BaseColumnType<number | null>;
45
- template_id: import("@powersync/common").BaseColumnType<string | null>;
46
- meta_data: import("@powersync/common").BaseColumnType<string | null>;
47
- output: import("@powersync/common").BaseColumnType<string | null>;
48
- output_param: import("@powersync/common").BaseColumnType<string | null>;
49
- category: import("@powersync/common").BaseColumnType<string | null>;
50
- }>;
51
- export declare const c_note_template: Table<{
52
- id: import("@powersync/common").BaseColumnType<string | null>;
53
- content: import("@powersync/common").BaseColumnType<string | null>;
54
- name: import("@powersync/common").BaseColumnType<string | null>;
55
- priority: import("@powersync/common").BaseColumnType<number | null>;
56
- is_show: import("@powersync/common").BaseColumnType<number | null>;
57
- extra_data: import("@powersync/common").BaseColumnType<string | null>;
58
- user_id: import("@powersync/common").BaseColumnType<string | null>;
59
- insert_at: import("@powersync/common").BaseColumnType<string | null>;
60
- update_at: import("@powersync/common").BaseColumnType<string | null>;
61
- is_del: import("@powersync/common").BaseColumnType<number | null>;
62
- }>;
63
- export declare const c_zettel_box: Table<{
64
- id: import("@powersync/common").BaseColumnType<string | null>;
65
- name: import("@powersync/common").BaseColumnType<string | null>;
66
- path: import("@powersync/common").BaseColumnType<string | null>;
67
- parent_id: import("@powersync/common").BaseColumnType<string | null>;
68
- description: import("@powersync/common").BaseColumnType<string | null>;
69
- color: import("@powersync/common").BaseColumnType<string | null>;
70
- priority: import("@powersync/common").BaseColumnType<number | null>;
71
- is_show: import("@powersync/common").BaseColumnType<number | null>;
72
- cover_url: import("@powersync/common").BaseColumnType<string | null>;
73
- created_at: import("@powersync/common").BaseColumnType<string | null>;
74
- updated_at: import("@powersync/common").BaseColumnType<string | null>;
75
- extra_data: import("@powersync/common").BaseColumnType<string | null>;
76
- user_no: import("@powersync/common").BaseColumnType<string | null>;
77
- is_del: import("@powersync/common").BaseColumnType<number | null>;
78
- }>;
1
+ export { c_card_box, c_card_note, c_cmd, c_note_template, c_zettel_box, } from './electronCanonical.js';
@@ -1,78 +1 @@
1
- import { column, Table } from '@powersync/common';
2
- export const c_card_box = new Table({
3
- id: column.text,
4
- name: column.text,
5
- type: column.text,
6
- cover_url: column.text,
7
- prompt: column.text,
8
- headers: column.text,
9
- priority: column.integer,
10
- created_at: column.text,
11
- updated_at: column.text,
12
- extra_data: column.text,
13
- user_no: column.text,
14
- is_del: column.integer,
15
- template_id: column.text,
16
- });
17
- export const c_card_note = new Table({
18
- id: column.text,
19
- box_id: column.text,
20
- content: column.text,
21
- created_at: column.text,
22
- updated_at: column.text,
23
- extra_data: column.text,
24
- user_no: column.text,
25
- is_del: column.integer,
26
- origin_note_id: column.text,
27
- origin_type: column.text,
28
- output_type: column.text,
29
- is_array: column.integer,
30
- });
31
- export const c_cmd = new Table({
32
- id: column.text,
33
- zone: column.text,
34
- type: column.text,
35
- cmd: column.text,
36
- name: column.text,
37
- priority: column.integer,
38
- is_show: column.integer,
39
- description: column.text,
40
- extra_data: column.text,
41
- user_id: column.text,
42
- insert_at: column.text,
43
- update_at: column.text,
44
- is_del: column.integer,
45
- template_id: column.text,
46
- meta_data: column.text,
47
- output: column.text,
48
- output_param: column.text,
49
- category: column.text,
50
- });
51
- export const c_note_template = new Table({
52
- id: column.text,
53
- content: column.text,
54
- name: column.text,
55
- priority: column.integer,
56
- is_show: column.integer,
57
- extra_data: column.text,
58
- user_id: column.text,
59
- insert_at: column.text,
60
- update_at: column.text,
61
- is_del: column.integer,
62
- });
63
- export const c_zettel_box = new Table({
64
- id: column.text,
65
- name: column.text,
66
- path: column.text,
67
- parent_id: column.text,
68
- description: column.text,
69
- color: column.text,
70
- priority: column.integer,
71
- is_show: column.integer,
72
- cover_url: column.text,
73
- created_at: column.text,
74
- updated_at: column.text,
75
- extra_data: column.text,
76
- user_no: column.text,
77
- is_del: column.integer,
78
- });
1
+ export { c_card_box, c_card_note, c_cmd, c_note_template, c_zettel_box, } from './electronCanonical.js';