@memberjunction/cli 6.2.2 → 6.3.0-edge.1
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/commands/app/check-updates.d.ts +2 -2
- package/dist/commands/app/check-updates.d.ts.map +1 -1
- package/dist/commands/app/check-updates.js +8 -5
- package/dist/commands/app/check-updates.js.map +1 -1
- package/dist/commands/app/disable.d.ts.map +1 -1
- package/dist/commands/app/disable.js +7 -1
- package/dist/commands/app/disable.js.map +1 -1
- package/dist/commands/app/enable.d.ts.map +1 -1
- package/dist/commands/app/enable.js +7 -1
- package/dist/commands/app/enable.js.map +1 -1
- package/dist/commands/app/install.d.ts +2 -2
- package/dist/commands/app/install.d.ts.map +1 -1
- package/dist/commands/app/install.js +29 -18
- package/dist/commands/app/install.js.map +1 -1
- package/dist/commands/app/remove.d.ts.map +1 -1
- package/dist/commands/app/remove.js +10 -2
- package/dist/commands/app/remove.js.map +1 -1
- package/dist/commands/app/upgrade.d.ts +1 -0
- package/dist/commands/app/upgrade.d.ts.map +1 -1
- package/dist/commands/app/upgrade.js +6 -0
- package/dist/commands/app/upgrade.js.map +1 -1
- package/dist/commands/codegen/index.d.ts +1 -0
- package/dist/commands/codegen/index.d.ts.map +1 -1
- package/dist/commands/dev/workspace/clean.d.ts +4 -1
- package/dist/commands/dev/workspace/clean.d.ts.map +1 -1
- package/dist/commands/dev/workspace/clean.js +21 -4
- package/dist/commands/dev/workspace/clean.js.map +1 -1
- package/dist/commands/dev/workspace/doctor.js +1 -1
- package/dist/commands/dev/workspace/doctor.js.map +1 -1
- package/dist/commands/dev/workspace/index.d.ts +5 -0
- package/dist/commands/dev/workspace/index.d.ts.map +1 -1
- package/dist/commands/dev/workspace/index.js +26 -3
- package/dist/commands/dev/workspace/index.js.map +1 -1
- package/dist/commands/doctor/value-lists.d.ts +18 -0
- package/dist/commands/doctor/value-lists.d.ts.map +1 -0
- package/dist/commands/doctor/value-lists.js +83 -0
- package/dist/commands/doctor/value-lists.js.map +1 -0
- package/dist/commands/migrate/convert.d.ts +23 -1
- package/dist/commands/migrate/convert.d.ts.map +1 -1
- package/dist/commands/migrate/convert.js +47 -11
- package/dist/commands/migrate/convert.js.map +1 -1
- package/dist/commands/migrate/index.d.ts +6 -0
- package/dist/commands/migrate/index.d.ts.map +1 -1
- package/dist/commands/migrate/index.js +30 -4
- package/dist/commands/migrate/index.js.map +1 -1
- package/dist/commands/migrate/rebake.d.ts.map +1 -1
- package/dist/commands/migrate/rebake.js +3 -8
- package/dist/commands/migrate/rebake.js.map +1 -1
- package/dist/commands/queue/index.d.ts.map +1 -1
- package/dist/commands/queue/index.js +1 -0
- package/dist/commands/queue/index.js.map +1 -1
- package/dist/commands/queue/sweep.d.ts +13 -0
- package/dist/commands/queue/sweep.d.ts.map +1 -0
- package/dist/commands/queue/sweep.js +44 -0
- package/dist/commands/queue/sweep.js.map +1 -0
- package/dist/commands/queue/work.d.ts +21 -0
- package/dist/commands/queue/work.d.ts.map +1 -1
- package/dist/commands/queue/work.js +23 -3
- package/dist/commands/queue/work.js.map +1 -1
- package/dist/init-templates/citizen-builder/.env.example +6 -0
- package/dist/init-templates/citizen-builder/README.md +5 -5
- package/dist/init-templates/citizen-builder/docker-compose.yml +10 -0
- package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +53 -32
- package/dist/init-templates/citizen-builder/scripts/query-run-history.sh +4 -4
- package/dist/init-templates/citizen-builder/scripts/sync-metadata.sh +1 -1
- package/dist/lib/app-manifest-schema.d.ts +17 -0
- package/dist/lib/app-manifest-schema.d.ts.map +1 -0
- package/dist/lib/app-manifest-schema.js +59 -0
- package/dist/lib/app-manifest-schema.js.map +1 -0
- package/dist/lib/dev-workspace/build.d.ts +4 -3
- package/dist/lib/dev-workspace/build.d.ts.map +1 -1
- package/dist/lib/dev-workspace/build.js +7 -2
- package/dist/lib/dev-workspace/build.js.map +1 -1
- package/dist/lib/dev-workspace/clean.d.ts.map +1 -1
- package/dist/lib/dev-workspace/clean.js +19 -3
- package/dist/lib/dev-workspace/clean.js.map +1 -1
- package/dist/lib/dev-workspace/doctor.d.ts.map +1 -1
- package/dist/lib/dev-workspace/doctor.js +24 -0
- package/dist/lib/dev-workspace/doctor.js.map +1 -1
- package/dist/lib/dev-workspace/prebundle.d.ts +88 -0
- package/dist/lib/dev-workspace/prebundle.d.ts.map +1 -0
- package/dist/lib/dev-workspace/prebundle.js +347 -0
- package/dist/lib/dev-workspace/prebundle.js.map +1 -0
- package/dist/lib/dev-workspace/status.d.ts.map +1 -1
- package/dist/lib/dev-workspace/status.js +4 -0
- package/dist/lib/dev-workspace/status.js.map +1 -1
- package/dist/lib/dev-workspace/types.d.ts +17 -0
- package/dist/lib/dev-workspace/types.d.ts.map +1 -1
- package/dist/lib/value-list-scan.d.ts +125 -0
- package/dist/lib/value-list-scan.d.ts.map +1 -0
- package/dist/lib/value-list-scan.js +260 -0
- package/dist/lib/value-list-scan.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/app-source-lookups.d.ts +19 -0
- package/dist/utils/app-source-lookups.d.ts.map +1 -0
- package/dist/utils/app-source-lookups.js +19 -0
- package/dist/utils/app-source-lookups.js.map +1 -0
- package/dist/utils/open-app-context.d.ts +3 -8
- package/dist/utils/open-app-context.d.ts.map +1 -1
- package/dist/utils/open-app-context.js +13 -16
- package/dist/utils/open-app-context.js.map +1 -1
- package/dist/utils/update-check.d.ts +8 -1
- package/dist/utils/update-check.d.ts.map +1 -1
- package/dist/utils/update-check.js +6 -4
- package/dist/utils/update-check.js.map +1 -1
- package/oclif.manifest.json +971 -842
- package/package.json +28 -28
- package/regression-compose/docker-compose.bacpac-standalone.yml +4 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scan behind `mj doctor value-lists`: rows whose `List` field holds a value outside the
|
|
3
|
+
* field's value list.
|
|
4
|
+
*
|
|
5
|
+
* Since 6.1, `BaseEntity.Validate()` refuses a save when a field whose `ValueListType` is `List`
|
|
6
|
+
* holds a value that is not one of its `EntityFieldValue` rows. On 5.x only the database decided,
|
|
7
|
+
* and not every such field has a CHECK constraint, so a database upgraded from 5.x can hold rows
|
|
8
|
+
* that saved fine before and are refused on their next save. This scan finds them in advance.
|
|
9
|
+
*
|
|
10
|
+
* Membership is decided by `EntityFieldInfo.ValueIsPermittedByValueList`, the same rule the save
|
|
11
|
+
* path applies, and only fields the save path validates are read (see {@link ValueListFields}), so
|
|
12
|
+
* the scan reports what a save would refuse.
|
|
13
|
+
*/
|
|
14
|
+
import { type DatabaseProviderBase, type EntityFieldInfo, type EntityInfo, type UserInfo } from '@memberjunction/core';
|
|
15
|
+
/** The provider surface the scan reads through: dialect quoting and raw SQL. */
|
|
16
|
+
export type ValueListScanProvider = Pick<DatabaseProviderBase, 'ExecuteSQL' | 'QuoteIdentifier' | 'QuoteSchemaAndView'>;
|
|
17
|
+
/** The provider surface `--fix` writes through. */
|
|
18
|
+
export type ValueListFixProvider = Pick<DatabaseProviderBase, 'GetEntityObject'>;
|
|
19
|
+
/** How many distinct offending values a report lists per field. */
|
|
20
|
+
export declare const MAX_LISTED_VALUES = 20;
|
|
21
|
+
/** One field's result. Only fields with offending rows, or that could not be read, are reported. */
|
|
22
|
+
export interface ValueListFieldReport {
|
|
23
|
+
Entity: string;
|
|
24
|
+
Field: string;
|
|
25
|
+
/** Rows whose value is outside the list. */
|
|
26
|
+
RowsOutsideList: number;
|
|
27
|
+
/** How many distinct values are outside the list. */
|
|
28
|
+
DistinctValuesOutsideList: number;
|
|
29
|
+
/** Up to {@link MAX_LISTED_VALUES} of those values, most frequent first. */
|
|
30
|
+
Values: Array<{
|
|
31
|
+
Value: string;
|
|
32
|
+
Rows: number;
|
|
33
|
+
}>;
|
|
34
|
+
/** Whether the column carries a CHECK constraint; null when the catalog could not be read. */
|
|
35
|
+
HasCheckConstraint: boolean | null;
|
|
36
|
+
/** Set when the field's table could not be read. */
|
|
37
|
+
Error?: string;
|
|
38
|
+
}
|
|
39
|
+
/** The whole scan. */
|
|
40
|
+
export interface ValueListScanReport {
|
|
41
|
+
FieldsScanned: number;
|
|
42
|
+
/** `List` fields skipped because they have no values (a separate, already-reported metadata fault). */
|
|
43
|
+
FieldsWithoutValues: number;
|
|
44
|
+
Findings: ValueListFieldReport[];
|
|
45
|
+
}
|
|
46
|
+
/** One `Entity.Field` named for `--fix`. */
|
|
47
|
+
export interface ValueListFixTarget {
|
|
48
|
+
Entity: string;
|
|
49
|
+
Field: string;
|
|
50
|
+
}
|
|
51
|
+
/** The result of one `--fix` target. */
|
|
52
|
+
export interface ValueListFixResult extends ValueListFixTarget {
|
|
53
|
+
Fixed: boolean;
|
|
54
|
+
Message: string;
|
|
55
|
+
}
|
|
56
|
+
/** A distinct value and how many rows hold it. */
|
|
57
|
+
interface DistinctValueRow {
|
|
58
|
+
Value: string | number | Date | null;
|
|
59
|
+
ValueCount: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The `List` fields the scan reads: columns of entities that have a base table, that the save path
|
|
63
|
+
* validates. `EntityField.Validate()` skips a field that is read-only (`AllowUpdateAPI` off, the
|
|
64
|
+
* primary key, a special date field), virtual, or auto-increment (`SkipValidation`), so a value
|
|
65
|
+
* outside the list there never fails a save and is not reported.
|
|
66
|
+
*/
|
|
67
|
+
export declare function ValueListFields(entities: readonly EntityInfo[], entityNames?: readonly string[]): Array<{
|
|
68
|
+
Entity: EntityInfo;
|
|
69
|
+
Field: EntityFieldInfo;
|
|
70
|
+
}>;
|
|
71
|
+
/** The names in `entityNames` that match no entity (case-insensitive), as given. */
|
|
72
|
+
export declare function UnknownEntityNames(entities: readonly EntityInfo[], entityNames?: readonly string[]): string[];
|
|
73
|
+
/** One `SELECT <col>, COUNT(*) … GROUP BY <col>` over the field's base table, in the provider's dialect. */
|
|
74
|
+
export declare function DistinctValuesSQL(provider: ValueListScanProvider, entity: EntityInfo, field: EntityFieldInfo): string;
|
|
75
|
+
/**
|
|
76
|
+
* The columns that carry a CHECK constraint, read from INFORMATION_SCHEMA (the same views on SQL
|
|
77
|
+
* Server and PostgreSQL). Null when the catalog cannot be read, so the report says "unknown"
|
|
78
|
+
* rather than "no".
|
|
79
|
+
*
|
|
80
|
+
* An empty result is also treated as unreadable. PostgreSQL's `constraint_column_usage` lists only
|
|
81
|
+
* tables the connected role owns, so a role with only `SELECT` gets no rows rather than an error,
|
|
82
|
+
* and every MJ database has CHECK constraints on its own core tables, so "none at all" means the
|
|
83
|
+
* catalog was not visible.
|
|
84
|
+
*/
|
|
85
|
+
export declare function CheckConstrainedColumns(provider: ValueListScanProvider, user?: UserInfo): Promise<Set<string> | null>;
|
|
86
|
+
/** Classify one field's distinct values with the product's own rule; null when nothing is outside the list. */
|
|
87
|
+
export declare function ClassifyDistinctValues(entity: EntityInfo, field: EntityFieldInfo, rows: readonly DistinctValueRow[], hasCheck: boolean | null): ValueListFieldReport | null;
|
|
88
|
+
/** Scan every `List` field (or those of the named entities) for rows outside the field's list. */
|
|
89
|
+
export declare function ScanValueLists(provider: ValueListScanProvider, entities: readonly EntityInfo[], options?: {
|
|
90
|
+
EntityNames?: readonly string[];
|
|
91
|
+
User?: UserInfo;
|
|
92
|
+
}): Promise<ValueListScanReport>;
|
|
93
|
+
/**
|
|
94
|
+
* Parse `--fix` values: each is one or more comma-separated `Entity.Field` names. The field is the
|
|
95
|
+
* part after the LAST dot, since entity names hold spaces and colons (`MJ: AI Agents.Status`).
|
|
96
|
+
*/
|
|
97
|
+
export declare function ParseFixTargets(values: readonly string[]): ValueListFixTarget[];
|
|
98
|
+
/**
|
|
99
|
+
* Set each named field's `ValueListType` to `ListOrUserEntry` through the `MJ: Entity Fields`
|
|
100
|
+
* entity, so Record Changes logs who changed it. The list stays as suggestions in the UI and the
|
|
101
|
+
* save-time rule stops applying. Only the named fields change.
|
|
102
|
+
*
|
|
103
|
+
* A field whose column carries a CHECK constraint is skipped: CodeGen sets such a field back to
|
|
104
|
+
* `List` on its next run, and the database refuses the values anyway, so the change would not
|
|
105
|
+
* last. Fix the data or the constraint instead. When the CHECK constraints could not be read
|
|
106
|
+
* (`checkColumns` is null), nothing is changed, since that guard cannot be applied.
|
|
107
|
+
*/
|
|
108
|
+
export declare function ApplyValueListFixes(provider: ValueListFixProvider, entities: readonly EntityInfo[], targets: readonly ValueListFixTarget[], checkColumns: Set<string> | null, user?: UserInfo): Promise<ValueListFixResult[]>;
|
|
109
|
+
/** Plain-text report lines. */
|
|
110
|
+
export declare function FormatValueListScan(report: ValueListScanReport): string[];
|
|
111
|
+
/**
|
|
112
|
+
* Run `work` with `console.log`, `console.info` and `console.debug` written to stderr, then restore
|
|
113
|
+
* them. Provider startup logs status lines through the console, so without this `--format json`
|
|
114
|
+
* would print them ahead of the JSON on stdout and the output would not parse.
|
|
115
|
+
*/
|
|
116
|
+
export declare function WithConsoleOnStderr<T>(work: () => Promise<T>): Promise<T>;
|
|
117
|
+
/**
|
|
118
|
+
* How `mj doctor value-lists` ends the process. The database provider can leave handles open after
|
|
119
|
+
* its pool is released, so the command exits explicitly, like the other database commands.
|
|
120
|
+
*/
|
|
121
|
+
export declare const ValueListScanExit: {
|
|
122
|
+
Exit(code: number): never;
|
|
123
|
+
};
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=value-list-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-list-scan.d.ts","sourceRoot":"","sources":["../../src/lib/value-list-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAA4B,KAAK,oBAAoB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGjJ,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,oBAAoB,EAAE,YAAY,GAAG,iBAAiB,GAAG,oBAAoB,CAAC,CAAC;AAExH,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,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C,IAAI,CAAC,EAAE,QAAQ,GAChB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA0C/B;AAED,+BAA+B;AAC/B,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAuBzE;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAe/E;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB;eACf,MAAM,GAAG,KAAK;CAG5B,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scan behind `mj doctor value-lists`: rows whose `List` field holds a value outside the
|
|
3
|
+
* field's value list.
|
|
4
|
+
*
|
|
5
|
+
* Since 6.1, `BaseEntity.Validate()` refuses a save when a field whose `ValueListType` is `List`
|
|
6
|
+
* holds a value that is not one of its `EntityFieldValue` rows. On 5.x only the database decided,
|
|
7
|
+
* and not every such field has a CHECK constraint, so a database upgraded from 5.x can hold rows
|
|
8
|
+
* that saved fine before and are refused on their next save. This scan finds them in advance.
|
|
9
|
+
*
|
|
10
|
+
* Membership is decided by `EntityFieldInfo.ValueIsPermittedByValueList`, the same rule the save
|
|
11
|
+
* path applies, and only fields the save path validates are read (see {@link ValueListFields}), so
|
|
12
|
+
* the scan reports what a save would refuse.
|
|
13
|
+
*/
|
|
14
|
+
import { EntityFieldValueListType } from '@memberjunction/core';
|
|
15
|
+
/** How many distinct offending values a report lists per field. */
|
|
16
|
+
export const MAX_LISTED_VALUES = 20;
|
|
17
|
+
const columnKey = (schema, table, column) => `${schema}.${table}.${column}`.toLowerCase();
|
|
18
|
+
/**
|
|
19
|
+
* The `List` fields the scan reads: columns of entities that have a base table, that the save path
|
|
20
|
+
* validates. `EntityField.Validate()` skips a field that is read-only (`AllowUpdateAPI` off, the
|
|
21
|
+
* primary key, a special date field), virtual, or auto-increment (`SkipValidation`), so a value
|
|
22
|
+
* outside the list there never fails a save and is not reported.
|
|
23
|
+
*/
|
|
24
|
+
export function ValueListFields(entities, entityNames) {
|
|
25
|
+
const wanted = entityNames?.length ? new Set(entityNames.map((n) => n.trim().toLowerCase())) : null;
|
|
26
|
+
const fields = [];
|
|
27
|
+
for (const entity of entities) {
|
|
28
|
+
if (wanted && !wanted.has(entity.Name.toLowerCase()))
|
|
29
|
+
continue;
|
|
30
|
+
if (!entity.BaseTable || !entity.SchemaName)
|
|
31
|
+
continue;
|
|
32
|
+
for (const field of entity.Fields) {
|
|
33
|
+
if (field.ValueListTypeEnum !== EntityFieldValueListType.List)
|
|
34
|
+
continue;
|
|
35
|
+
if (field.ReadOnly || field.SkipValidation)
|
|
36
|
+
continue;
|
|
37
|
+
fields.push({ Entity: entity, Field: field });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return fields;
|
|
41
|
+
}
|
|
42
|
+
/** The names in `entityNames` that match no entity (case-insensitive), as given. */
|
|
43
|
+
export function UnknownEntityNames(entities, entityNames) {
|
|
44
|
+
if (!entityNames?.length)
|
|
45
|
+
return [];
|
|
46
|
+
const known = new Set(entities.map((e) => e.Name.toLowerCase()));
|
|
47
|
+
return entityNames.filter((n) => !known.has(n.trim().toLowerCase()));
|
|
48
|
+
}
|
|
49
|
+
/** One `SELECT <col>, COUNT(*) … GROUP BY <col>` over the field's base table, in the provider's dialect. */
|
|
50
|
+
export function DistinctValuesSQL(provider, entity, field) {
|
|
51
|
+
const column = provider.QuoteIdentifier(field.Name);
|
|
52
|
+
return (`SELECT ${column} AS ${provider.QuoteIdentifier('Value')}, COUNT(*) AS ${provider.QuoteIdentifier('ValueCount')} ` +
|
|
53
|
+
`FROM ${provider.QuoteSchemaAndView(entity.SchemaName, entity.BaseTable)} ` +
|
|
54
|
+
`WHERE ${column} IS NOT NULL GROUP BY ${column}`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The columns that carry a CHECK constraint, read from INFORMATION_SCHEMA (the same views on SQL
|
|
58
|
+
* Server and PostgreSQL). Null when the catalog cannot be read, so the report says "unknown"
|
|
59
|
+
* rather than "no".
|
|
60
|
+
*
|
|
61
|
+
* An empty result is also treated as unreadable. PostgreSQL's `constraint_column_usage` lists only
|
|
62
|
+
* tables the connected role owns, so a role with only `SELECT` gets no rows rather than an error,
|
|
63
|
+
* and every MJ database has CHECK constraints on its own core tables, so "none at all" means the
|
|
64
|
+
* catalog was not visible.
|
|
65
|
+
*/
|
|
66
|
+
export async function CheckConstrainedColumns(provider, user) {
|
|
67
|
+
const q = (name) => provider.QuoteIdentifier(name);
|
|
68
|
+
const sql = `SELECT ccu.TABLE_SCHEMA AS ${q('SchemaName')}, ccu.TABLE_NAME AS ${q('TableName')}, ccu.COLUMN_NAME AS ${q('ColumnName')} ` +
|
|
69
|
+
`FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ` +
|
|
70
|
+
`INNER JOIN INFORMATION_SCHEMA.CHECK_CONSTRAINTS cc ` +
|
|
71
|
+
`ON cc.CONSTRAINT_SCHEMA = ccu.CONSTRAINT_SCHEMA AND cc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME`;
|
|
72
|
+
try {
|
|
73
|
+
const rows = await provider.ExecuteSQL(sql, undefined, { description: 'Value-list scan: CHECK-constrained columns', ignoreLogging: true }, user);
|
|
74
|
+
if (rows.length === 0)
|
|
75
|
+
return null;
|
|
76
|
+
return new Set(rows.map((r) => columnKey(r.SchemaName, r.TableName, r.ColumnName)));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Classify one field's distinct values with the product's own rule; null when nothing is outside the list. */
|
|
83
|
+
export function ClassifyDistinctValues(entity, field, rows, hasCheck) {
|
|
84
|
+
const outside = rows
|
|
85
|
+
.filter((r) => r.Value !== null && r.Value !== undefined && !field.ValueIsPermittedByValueList(r.Value))
|
|
86
|
+
.map((r) => ({ Value: r.Value instanceof Date ? r.Value.toISOString() : String(r.Value), Rows: Number(r.ValueCount) }))
|
|
87
|
+
.sort((a, b) => b.Rows - a.Rows || a.Value.localeCompare(b.Value));
|
|
88
|
+
if (outside.length === 0)
|
|
89
|
+
return null;
|
|
90
|
+
return {
|
|
91
|
+
Entity: entity.Name,
|
|
92
|
+
Field: field.Name,
|
|
93
|
+
RowsOutsideList: outside.reduce((sum, v) => sum + v.Rows, 0),
|
|
94
|
+
DistinctValuesOutsideList: outside.length,
|
|
95
|
+
Values: outside.slice(0, MAX_LISTED_VALUES),
|
|
96
|
+
HasCheckConstraint: hasCheck,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Scan every `List` field (or those of the named entities) for rows outside the field's list. */
|
|
100
|
+
export async function ScanValueLists(provider, entities, options = {}) {
|
|
101
|
+
const checkColumns = await CheckConstrainedColumns(provider, options.User);
|
|
102
|
+
const report = { FieldsScanned: 0, FieldsWithoutValues: 0, Findings: [] };
|
|
103
|
+
for (const { Entity: entity, Field: field } of ValueListFields(entities, options.EntityNames)) {
|
|
104
|
+
if (!field.EntityFieldValues?.length) {
|
|
105
|
+
report.FieldsWithoutValues++;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
report.FieldsScanned++;
|
|
109
|
+
const hasCheck = checkColumns ? checkColumns.has(columnKey(entity.SchemaName, entity.BaseTable, field.Name)) : null;
|
|
110
|
+
try {
|
|
111
|
+
const rows = await provider.ExecuteSQL(DistinctValuesSQL(provider, entity, field), undefined, { description: `Value-list scan: ${entity.Name}.${field.Name}`, ignoreLogging: true }, options.User);
|
|
112
|
+
const finding = ClassifyDistinctValues(entity, field, rows, hasCheck);
|
|
113
|
+
if (finding)
|
|
114
|
+
report.Findings.push(finding);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
report.Findings.push({
|
|
118
|
+
Entity: entity.Name,
|
|
119
|
+
Field: field.Name,
|
|
120
|
+
RowsOutsideList: 0,
|
|
121
|
+
DistinctValuesOutsideList: 0,
|
|
122
|
+
Values: [],
|
|
123
|
+
HasCheckConstraint: hasCheck,
|
|
124
|
+
Error: error instanceof Error ? error.message : String(error),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return report;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parse `--fix` values: each is one or more comma-separated `Entity.Field` names. The field is the
|
|
132
|
+
* part after the LAST dot, since entity names hold spaces and colons (`MJ: AI Agents.Status`).
|
|
133
|
+
*/
|
|
134
|
+
export function ParseFixTargets(values) {
|
|
135
|
+
const targets = [];
|
|
136
|
+
for (const value of values) {
|
|
137
|
+
for (const part of value.split(',')) {
|
|
138
|
+
const trimmed = part.trim();
|
|
139
|
+
if (!trimmed)
|
|
140
|
+
continue;
|
|
141
|
+
const dot = trimmed.lastIndexOf('.');
|
|
142
|
+
if (dot <= 0 || dot === trimmed.length - 1) {
|
|
143
|
+
throw new Error(`"${trimmed}" is not Entity.Field (for example "MJ: AI Agents.Status").`);
|
|
144
|
+
}
|
|
145
|
+
targets.push({ Entity: trimmed.slice(0, dot).trim(), Field: trimmed.slice(dot + 1).trim() });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return targets;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Set each named field's `ValueListType` to `ListOrUserEntry` through the `MJ: Entity Fields`
|
|
152
|
+
* entity, so Record Changes logs who changed it. The list stays as suggestions in the UI and the
|
|
153
|
+
* save-time rule stops applying. Only the named fields change.
|
|
154
|
+
*
|
|
155
|
+
* A field whose column carries a CHECK constraint is skipped: CodeGen sets such a field back to
|
|
156
|
+
* `List` on its next run, and the database refuses the values anyway, so the change would not
|
|
157
|
+
* last. Fix the data or the constraint instead. When the CHECK constraints could not be read
|
|
158
|
+
* (`checkColumns` is null), nothing is changed, since that guard cannot be applied.
|
|
159
|
+
*/
|
|
160
|
+
export async function ApplyValueListFixes(provider, entities, targets, checkColumns, user) {
|
|
161
|
+
const results = [];
|
|
162
|
+
for (const target of targets) {
|
|
163
|
+
const entity = entities.find((e) => e.Name.toLowerCase() === target.Entity.toLowerCase());
|
|
164
|
+
const field = entity?.Fields.find((f) => f.Name.toLowerCase() === target.Field.toLowerCase());
|
|
165
|
+
if (!entity || !field) {
|
|
166
|
+
results.push({ ...target, Fixed: false, Message: 'no such entity field' });
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (field.ValueListTypeEnum !== EntityFieldValueListType.List) {
|
|
170
|
+
results.push({ ...target, Fixed: false, Message: `ValueListType is already ${field.ValueListType}` });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (checkColumns === null) {
|
|
174
|
+
results.push({
|
|
175
|
+
...target,
|
|
176
|
+
Fixed: false,
|
|
177
|
+
Message: 'the CHECK constraints could not be read (does this login own the tables?), so whether CodeGen would set the field back to List is unknown',
|
|
178
|
+
});
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (checkColumns.has(columnKey(entity.SchemaName, entity.BaseTable, field.Name))) {
|
|
182
|
+
results.push({
|
|
183
|
+
...target,
|
|
184
|
+
Fixed: false,
|
|
185
|
+
Message: 'the column has a CHECK constraint, and CodeGen sets such a field back to List; fix the rows or the constraint instead',
|
|
186
|
+
});
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const record = await provider.GetEntityObject('MJ: Entity Fields', user);
|
|
190
|
+
if (!(await record.Load(field.ID))) {
|
|
191
|
+
results.push({ ...target, Fixed: false, Message: 'could not load the entity field record' });
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
record.ValueListType = 'ListOrUserEntry';
|
|
195
|
+
if (await record.Save()) {
|
|
196
|
+
results.push({ ...target, Fixed: true, Message: 'ValueListType set to ListOrUserEntry' });
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
results.push({ ...target, Fixed: false, Message: record.LatestResult?.CompleteMessage ?? 'save failed' });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return results;
|
|
203
|
+
}
|
|
204
|
+
/** Plain-text report lines. */
|
|
205
|
+
export function FormatValueListScan(report) {
|
|
206
|
+
const lines = [];
|
|
207
|
+
for (const f of report.Findings) {
|
|
208
|
+
const check = f.HasCheckConstraint === null ? 'CHECK unknown' : f.HasCheckConstraint ? 'has CHECK' : 'no CHECK';
|
|
209
|
+
if (f.Error) {
|
|
210
|
+
lines.push(`${f.Entity}.${f.Field}: could not be read (${f.Error})`);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
lines.push(`${f.Entity}.${f.Field}: ${f.RowsOutsideList} row(s), ${f.DistinctValuesOutsideList} distinct value(s) outside the list (${check})`);
|
|
214
|
+
for (const v of f.Values)
|
|
215
|
+
lines.push(` ${JSON.stringify(v.Value)} ${v.Rows} row(s)`);
|
|
216
|
+
if (f.DistinctValuesOutsideList > f.Values.length)
|
|
217
|
+
lines.push(` … ${f.DistinctValuesOutsideList - f.Values.length} more`);
|
|
218
|
+
}
|
|
219
|
+
const withRows = report.Findings.filter((f) => !f.Error).length;
|
|
220
|
+
lines.push(`${report.FieldsScanned} List field(s) scanned; ${withRows} hold values outside their list` +
|
|
221
|
+
(report.FieldsWithoutValues ? `; ${report.FieldsWithoutValues} skipped with no values` : '') +
|
|
222
|
+
'.');
|
|
223
|
+
if (withRows > 0) {
|
|
224
|
+
lines.push('Saving any of these rows fails validation. Correct the rows, or let the field accept other values with');
|
|
225
|
+
lines.push(' mj doctor value-lists --fix "<Entity>.<Field>" (sets ValueListType to ListOrUserEntry)');
|
|
226
|
+
}
|
|
227
|
+
return lines;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Run `work` with `console.log`, `console.info` and `console.debug` written to stderr, then restore
|
|
231
|
+
* them. Provider startup logs status lines through the console, so without this `--format json`
|
|
232
|
+
* would print them ahead of the JSON on stdout and the output would not parse.
|
|
233
|
+
*/
|
|
234
|
+
export async function WithConsoleOnStderr(work) {
|
|
235
|
+
const saved = { log: console.log, info: console.info, debug: console.debug };
|
|
236
|
+
const toStderr = (...args) => {
|
|
237
|
+
console.error(...args);
|
|
238
|
+
};
|
|
239
|
+
console.log = toStderr;
|
|
240
|
+
console.info = toStderr;
|
|
241
|
+
console.debug = toStderr;
|
|
242
|
+
try {
|
|
243
|
+
return await work();
|
|
244
|
+
}
|
|
245
|
+
finally {
|
|
246
|
+
console.log = saved.log;
|
|
247
|
+
console.info = saved.info;
|
|
248
|
+
console.debug = saved.debug;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* How `mj doctor value-lists` ends the process. The database provider can leave handles open after
|
|
253
|
+
* its pool is released, so the command exits explicitly, like the other database commands.
|
|
254
|
+
*/
|
|
255
|
+
export const ValueListScanExit = {
|
|
256
|
+
Exit(code) {
|
|
257
|
+
process.exit(code);
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=value-list-scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-list-scan.js","sourceRoot":"","sources":["../../src/lib/value-list-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,wBAAwB,EAAmF,MAAM,sBAAsB,CAAC;AASjJ,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAmDpC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,KAAa,EAAE,MAAc,EAAU,EAAE,CAAC,GAAG,MAAM,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;AAE1H;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAA+B,EAAE,WAA+B;IAC5F,MAAM,MAAM,GAAG,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAA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