@nmakarov/cli-toolkit 0.40.0 → 0.44.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.
- package/dist/cli-runner.cjs +43 -8
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +43 -8
- package/dist/cli-runner.js.map +1 -1
- package/dist/filedatabase.cjs +40 -23
- package/dist/filedatabase.cjs.map +1 -1
- package/dist/filedatabase.js +40 -23
- package/dist/filedatabase.js.map +1 -1
- package/dist/http-client2.cjs +14 -3
- package/dist/http-client2.cjs.map +1 -1
- package/dist/http-client2.js +14 -3
- package/dist/http-client2.js.map +1 -1
- package/dist/index.cjs +83 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +83 -30
- package/dist/index.js.map +1 -1
- package/dist/mock-server.cjs +14 -3
- package/dist/mock-server.cjs.map +1 -1
- package/dist/mock-server.js +14 -3
- package/dist/mock-server.js.map +1 -1
- package/dist/tasks.cjs +57 -10
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +57 -10
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runner.cjs
CHANGED
|
@@ -3790,22 +3790,46 @@ async function ensureTaskTables(context, options = {}) {
|
|
|
3790
3790
|
}
|
|
3791
3791
|
}
|
|
3792
3792
|
const { actions } = await ensureSchema(db, spec, { dryRun, logger: context.logger });
|
|
3793
|
+
const legacyDrops = await dropLegacyTaskNameColumn(db, [tasksTable, historyTable], {
|
|
3794
|
+
dryRun,
|
|
3795
|
+
log,
|
|
3796
|
+
label
|
|
3797
|
+
});
|
|
3798
|
+
const allActions = [...actions, ...legacyDrops];
|
|
3793
3799
|
if (dryRun) {
|
|
3794
|
-
if (
|
|
3800
|
+
if (allActions.length === 0) {
|
|
3795
3801
|
log.info?.(`[tasks-schema] dryRun \u2014 ${label}: queue "${queueName}" already up to date; no DDL`);
|
|
3796
3802
|
} else {
|
|
3797
3803
|
log.info?.(
|
|
3798
|
-
`[tasks-schema] dryRun \u2014 ${label}: would run ${
|
|
3804
|
+
`[tasks-schema] dryRun \u2014 ${label}: would run ${allActions.length} statement(s) for queue "${queueName}":`
|
|
3799
3805
|
);
|
|
3800
|
-
for (const s of
|
|
3806
|
+
for (const s of allActions) log.info?.(` - ${s}`);
|
|
3801
3807
|
}
|
|
3802
|
-
} else if (
|
|
3808
|
+
} else if (allActions.length > 0) {
|
|
3803
3809
|
log.info?.(
|
|
3804
|
-
`[tasks-schema] ${label}: applied ${
|
|
3810
|
+
`[tasks-schema] ${label}: applied ${allActions.length} DDL statement(s) for queue "${queueName}"`
|
|
3805
3811
|
);
|
|
3806
3812
|
}
|
|
3807
3813
|
}
|
|
3808
3814
|
}
|
|
3815
|
+
async function dropLegacyTaskNameColumn(db, tableNames, { dryRun, log, label }) {
|
|
3816
|
+
const actions = [];
|
|
3817
|
+
for (const table of tableNames) {
|
|
3818
|
+
if (!await db.tableExists(table).catch(() => false)) continue;
|
|
3819
|
+
const hasTask = await db.schema.hasColumn(table, "task");
|
|
3820
|
+
const hasName = await db.schema.hasColumn(table, "name");
|
|
3821
|
+
if (!hasTask || !hasName) continue;
|
|
3822
|
+
const sql = `ALTER TABLE "${table}" DROP COLUMN IF EXISTS "task"`;
|
|
3823
|
+
actions.push(sql);
|
|
3824
|
+
if (dryRun) {
|
|
3825
|
+
log?.info?.(`[tasks-schema] dryRun \u2014 ${label}: ${sql}`);
|
|
3826
|
+
} else {
|
|
3827
|
+
await db.raw(sql);
|
|
3828
|
+
log?.info?.(`[tasks-schema] ${label}: dropped legacy column ${table}.task`);
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3831
|
+
return actions;
|
|
3832
|
+
}
|
|
3809
3833
|
async function updateTaskProgress(context, tasksTable, taskId, progress) {
|
|
3810
3834
|
const db = getDb(context);
|
|
3811
3835
|
await db(tasksTable).where({ id: taskId }).update({
|
|
@@ -4082,6 +4106,9 @@ var FileDatabase = class _FileDatabase {
|
|
|
4082
4106
|
currentRecord = 0;
|
|
4083
4107
|
hasReadFirstPage = false;
|
|
4084
4108
|
lastFileData = null;
|
|
4109
|
+
/** Cache of the last JSON file parsed during paginated reads (avoid re-parse per page). */
|
|
4110
|
+
readFileCache = null;
|
|
4111
|
+
// { filePath: string, data: any[] } | null
|
|
4085
4112
|
metadata;
|
|
4086
4113
|
// Synopsis calculation functions
|
|
4087
4114
|
fileSynopsisFunction = null;
|
|
@@ -4848,7 +4875,6 @@ var FileDatabase = class _FileDatabase {
|
|
|
4848
4875
|
let effectivePageSize;
|
|
4849
4876
|
if (nextPage && this.hasReadFirstPage) {
|
|
4850
4877
|
effectivePageSize = pageSize || this.pageSize;
|
|
4851
|
-
this.currentRecord += effectivePageSize;
|
|
4852
4878
|
} else if (!nextPage) {
|
|
4853
4879
|
effectivePageSize = pageSize !== void 0 ? pageSize : this.metadata.totalRecords;
|
|
4854
4880
|
this.currentRecord = 0;
|
|
@@ -4877,8 +4903,14 @@ var FileDatabase = class _FileDatabase {
|
|
|
4877
4903
|
const file = this.metadata.files[i];
|
|
4878
4904
|
const filePath = import_path4.default.join(this.getDestinationPath(this.currentVersion || void 0), file.fileName);
|
|
4879
4905
|
try {
|
|
4880
|
-
|
|
4881
|
-
|
|
4906
|
+
let fileData;
|
|
4907
|
+
if (this.readFileCache?.filePath === filePath && Array.isArray(this.readFileCache.data)) {
|
|
4908
|
+
fileData = this.readFileCache.data;
|
|
4909
|
+
} else {
|
|
4910
|
+
const rawData = await import_fs4.default.promises.readFile(filePath, "utf8");
|
|
4911
|
+
fileData = deserializeData(rawData, this.metadata.dataType);
|
|
4912
|
+
this.readFileCache = { filePath, data: fileData };
|
|
4913
|
+
}
|
|
4882
4914
|
let startIndex = 0;
|
|
4883
4915
|
if (i === currentFileIndex) {
|
|
4884
4916
|
startIndex = this.currentRecord - cumulativeRecords;
|
|
@@ -4892,6 +4924,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
4892
4924
|
throw new FileDatabaseError(`Failed to read file ${file.fileName}: ${error.message}`);
|
|
4893
4925
|
}
|
|
4894
4926
|
}
|
|
4927
|
+
this.currentRecord += recordsRead;
|
|
4895
4928
|
if (result.length > 0) {
|
|
4896
4929
|
if (nextPage || pageSize !== void 0 && pageSize < this.metadata.totalRecords) {
|
|
4897
4930
|
this.hasReadFirstPage = true;
|
|
@@ -4905,6 +4938,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
4905
4938
|
setStartRecord(startRecord) {
|
|
4906
4939
|
this.currentRecord = startRecord - 1;
|
|
4907
4940
|
this.hasReadFirstPage = false;
|
|
4941
|
+
this.readFileCache = null;
|
|
4908
4942
|
}
|
|
4909
4943
|
/**
|
|
4910
4944
|
* Reset read pagination state
|
|
@@ -4912,6 +4946,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
4912
4946
|
resetPagination() {
|
|
4913
4947
|
this.currentRecord = 0;
|
|
4914
4948
|
this.hasReadFirstPage = false;
|
|
4949
|
+
this.readFileCache = null;
|
|
4915
4950
|
}
|
|
4916
4951
|
/**
|
|
4917
4952
|
* List filenames in the table directory.
|