@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.js
CHANGED
|
@@ -3774,22 +3774,46 @@ async function ensureTaskTables(context, options = {}) {
|
|
|
3774
3774
|
}
|
|
3775
3775
|
}
|
|
3776
3776
|
const { actions } = await ensureSchema(db, spec, { dryRun, logger: context.logger });
|
|
3777
|
+
const legacyDrops = await dropLegacyTaskNameColumn(db, [tasksTable, historyTable], {
|
|
3778
|
+
dryRun,
|
|
3779
|
+
log,
|
|
3780
|
+
label
|
|
3781
|
+
});
|
|
3782
|
+
const allActions = [...actions, ...legacyDrops];
|
|
3777
3783
|
if (dryRun) {
|
|
3778
|
-
if (
|
|
3784
|
+
if (allActions.length === 0) {
|
|
3779
3785
|
log.info?.(`[tasks-schema] dryRun \u2014 ${label}: queue "${queueName}" already up to date; no DDL`);
|
|
3780
3786
|
} else {
|
|
3781
3787
|
log.info?.(
|
|
3782
|
-
`[tasks-schema] dryRun \u2014 ${label}: would run ${
|
|
3788
|
+
`[tasks-schema] dryRun \u2014 ${label}: would run ${allActions.length} statement(s) for queue "${queueName}":`
|
|
3783
3789
|
);
|
|
3784
|
-
for (const s of
|
|
3790
|
+
for (const s of allActions) log.info?.(` - ${s}`);
|
|
3785
3791
|
}
|
|
3786
|
-
} else if (
|
|
3792
|
+
} else if (allActions.length > 0) {
|
|
3787
3793
|
log.info?.(
|
|
3788
|
-
`[tasks-schema] ${label}: applied ${
|
|
3794
|
+
`[tasks-schema] ${label}: applied ${allActions.length} DDL statement(s) for queue "${queueName}"`
|
|
3789
3795
|
);
|
|
3790
3796
|
}
|
|
3791
3797
|
}
|
|
3792
3798
|
}
|
|
3799
|
+
async function dropLegacyTaskNameColumn(db, tableNames, { dryRun, log, label }) {
|
|
3800
|
+
const actions = [];
|
|
3801
|
+
for (const table of tableNames) {
|
|
3802
|
+
if (!await db.tableExists(table).catch(() => false)) continue;
|
|
3803
|
+
const hasTask = await db.schema.hasColumn(table, "task");
|
|
3804
|
+
const hasName = await db.schema.hasColumn(table, "name");
|
|
3805
|
+
if (!hasTask || !hasName) continue;
|
|
3806
|
+
const sql = `ALTER TABLE "${table}" DROP COLUMN IF EXISTS "task"`;
|
|
3807
|
+
actions.push(sql);
|
|
3808
|
+
if (dryRun) {
|
|
3809
|
+
log?.info?.(`[tasks-schema] dryRun \u2014 ${label}: ${sql}`);
|
|
3810
|
+
} else {
|
|
3811
|
+
await db.raw(sql);
|
|
3812
|
+
log?.info?.(`[tasks-schema] ${label}: dropped legacy column ${table}.task`);
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
return actions;
|
|
3816
|
+
}
|
|
3793
3817
|
async function updateTaskProgress(context, tasksTable, taskId, progress) {
|
|
3794
3818
|
const db = getDb(context);
|
|
3795
3819
|
await db(tasksTable).where({ id: taskId }).update({
|
|
@@ -4066,6 +4090,9 @@ var FileDatabase = class _FileDatabase {
|
|
|
4066
4090
|
currentRecord = 0;
|
|
4067
4091
|
hasReadFirstPage = false;
|
|
4068
4092
|
lastFileData = null;
|
|
4093
|
+
/** Cache of the last JSON file parsed during paginated reads (avoid re-parse per page). */
|
|
4094
|
+
readFileCache = null;
|
|
4095
|
+
// { filePath: string, data: any[] } | null
|
|
4069
4096
|
metadata;
|
|
4070
4097
|
// Synopsis calculation functions
|
|
4071
4098
|
fileSynopsisFunction = null;
|
|
@@ -4832,7 +4859,6 @@ var FileDatabase = class _FileDatabase {
|
|
|
4832
4859
|
let effectivePageSize;
|
|
4833
4860
|
if (nextPage && this.hasReadFirstPage) {
|
|
4834
4861
|
effectivePageSize = pageSize || this.pageSize;
|
|
4835
|
-
this.currentRecord += effectivePageSize;
|
|
4836
4862
|
} else if (!nextPage) {
|
|
4837
4863
|
effectivePageSize = pageSize !== void 0 ? pageSize : this.metadata.totalRecords;
|
|
4838
4864
|
this.currentRecord = 0;
|
|
@@ -4861,8 +4887,14 @@ var FileDatabase = class _FileDatabase {
|
|
|
4861
4887
|
const file = this.metadata.files[i];
|
|
4862
4888
|
const filePath = path3.join(this.getDestinationPath(this.currentVersion || void 0), file.fileName);
|
|
4863
4889
|
try {
|
|
4864
|
-
|
|
4865
|
-
|
|
4890
|
+
let fileData;
|
|
4891
|
+
if (this.readFileCache?.filePath === filePath && Array.isArray(this.readFileCache.data)) {
|
|
4892
|
+
fileData = this.readFileCache.data;
|
|
4893
|
+
} else {
|
|
4894
|
+
const rawData = await fs3.promises.readFile(filePath, "utf8");
|
|
4895
|
+
fileData = deserializeData(rawData, this.metadata.dataType);
|
|
4896
|
+
this.readFileCache = { filePath, data: fileData };
|
|
4897
|
+
}
|
|
4866
4898
|
let startIndex = 0;
|
|
4867
4899
|
if (i === currentFileIndex) {
|
|
4868
4900
|
startIndex = this.currentRecord - cumulativeRecords;
|
|
@@ -4876,6 +4908,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
4876
4908
|
throw new FileDatabaseError(`Failed to read file ${file.fileName}: ${error.message}`);
|
|
4877
4909
|
}
|
|
4878
4910
|
}
|
|
4911
|
+
this.currentRecord += recordsRead;
|
|
4879
4912
|
if (result.length > 0) {
|
|
4880
4913
|
if (nextPage || pageSize !== void 0 && pageSize < this.metadata.totalRecords) {
|
|
4881
4914
|
this.hasReadFirstPage = true;
|
|
@@ -4889,6 +4922,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
4889
4922
|
setStartRecord(startRecord) {
|
|
4890
4923
|
this.currentRecord = startRecord - 1;
|
|
4891
4924
|
this.hasReadFirstPage = false;
|
|
4925
|
+
this.readFileCache = null;
|
|
4892
4926
|
}
|
|
4893
4927
|
/**
|
|
4894
4928
|
* Reset read pagination state
|
|
@@ -4896,6 +4930,7 @@ var FileDatabase = class _FileDatabase {
|
|
|
4896
4930
|
resetPagination() {
|
|
4897
4931
|
this.currentRecord = 0;
|
|
4898
4932
|
this.hasReadFirstPage = false;
|
|
4933
|
+
this.readFileCache = null;
|
|
4899
4934
|
}
|
|
4900
4935
|
/**
|
|
4901
4936
|
* List filenames in the table directory.
|