Some checks failed
Main Confidence / confidence (push) Failing after 45s
## Summary - introduce surface-aware compressed governance outcomes and reuse the shared truth/explanation seams for operator-first summaries - apply the compressed outcome hierarchy across baseline, evidence, review, review-pack, canonical review/evidence, and artifact-oriented operation-run surfaces - expand spec 214 fixtures and Pest coverage, and fix tenant-panel route assertions by generating explicit tenant-panel URLs in the affected Filament tests ## Validation - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - focused governance compression suite from `specs/214-governance-outcome-compression/quickstart.md` passed (`68` tests, `445` assertions) - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/InventoryItemResourceTest.php tests/Feature/Filament/BackupSetUiEnforcementTest.php tests/Feature/Filament/RestoreRunUiEnforcementTest.php` passed (`18` tests, `81` assertions) Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #253
125 lines
3.3 KiB
Plaintext
125 lines
3.3 KiB
Plaintext
import { entityKind } from "../../entity.js";
|
|
import { sql } from "../../sql/sql.js";
|
|
import { getColumnNameAndConfig } from "../../utils.js";
|
|
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
|
|
class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
|
|
static [entityKind] = "SQLiteBaseIntegerBuilder";
|
|
constructor(name, dataType, columnType) {
|
|
super(name, dataType, columnType);
|
|
this.config.autoIncrement = false;
|
|
}
|
|
primaryKey(config) {
|
|
if (config?.autoIncrement) {
|
|
this.config.autoIncrement = true;
|
|
}
|
|
this.config.hasDefault = true;
|
|
return super.primaryKey();
|
|
}
|
|
}
|
|
class SQLiteBaseInteger extends SQLiteColumn {
|
|
static [entityKind] = "SQLiteBaseInteger";
|
|
autoIncrement = this.config.autoIncrement;
|
|
getSQLType() {
|
|
return "integer";
|
|
}
|
|
}
|
|
class SQLiteIntegerBuilder extends SQLiteBaseIntegerBuilder {
|
|
static [entityKind] = "SQLiteIntegerBuilder";
|
|
constructor(name) {
|
|
super(name, "number", "SQLiteInteger");
|
|
}
|
|
build(table) {
|
|
return new SQLiteInteger(
|
|
table,
|
|
this.config
|
|
);
|
|
}
|
|
}
|
|
class SQLiteInteger extends SQLiteBaseInteger {
|
|
static [entityKind] = "SQLiteInteger";
|
|
}
|
|
class SQLiteTimestampBuilder extends SQLiteBaseIntegerBuilder {
|
|
static [entityKind] = "SQLiteTimestampBuilder";
|
|
constructor(name, mode) {
|
|
super(name, "date", "SQLiteTimestamp");
|
|
this.config.mode = mode;
|
|
}
|
|
/**
|
|
* @deprecated Use `default()` with your own expression instead.
|
|
*
|
|
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
|
|
*/
|
|
defaultNow() {
|
|
return this.default(sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
|
|
}
|
|
build(table) {
|
|
return new SQLiteTimestamp(
|
|
table,
|
|
this.config
|
|
);
|
|
}
|
|
}
|
|
class SQLiteTimestamp extends SQLiteBaseInteger {
|
|
static [entityKind] = "SQLiteTimestamp";
|
|
mode = this.config.mode;
|
|
mapFromDriverValue(value) {
|
|
if (this.config.mode === "timestamp") {
|
|
return new Date(value * 1e3);
|
|
}
|
|
return new Date(value);
|
|
}
|
|
mapToDriverValue(value) {
|
|
const unix = value.getTime();
|
|
if (this.config.mode === "timestamp") {
|
|
return Math.floor(unix / 1e3);
|
|
}
|
|
return unix;
|
|
}
|
|
}
|
|
class SQLiteBooleanBuilder extends SQLiteBaseIntegerBuilder {
|
|
static [entityKind] = "SQLiteBooleanBuilder";
|
|
constructor(name, mode) {
|
|
super(name, "boolean", "SQLiteBoolean");
|
|
this.config.mode = mode;
|
|
}
|
|
build(table) {
|
|
return new SQLiteBoolean(
|
|
table,
|
|
this.config
|
|
);
|
|
}
|
|
}
|
|
class SQLiteBoolean extends SQLiteBaseInteger {
|
|
static [entityKind] = "SQLiteBoolean";
|
|
mode = this.config.mode;
|
|
mapFromDriverValue(value) {
|
|
return Number(value) === 1;
|
|
}
|
|
mapToDriverValue(value) {
|
|
return value ? 1 : 0;
|
|
}
|
|
}
|
|
function integer(a, b) {
|
|
const { name, config } = getColumnNameAndConfig(a, b);
|
|
if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") {
|
|
return new SQLiteTimestampBuilder(name, config.mode);
|
|
}
|
|
if (config?.mode === "boolean") {
|
|
return new SQLiteBooleanBuilder(name, config.mode);
|
|
}
|
|
return new SQLiteIntegerBuilder(name);
|
|
}
|
|
const int = integer;
|
|
export {
|
|
SQLiteBaseInteger,
|
|
SQLiteBaseIntegerBuilder,
|
|
SQLiteBoolean,
|
|
SQLiteBooleanBuilder,
|
|
SQLiteInteger,
|
|
SQLiteIntegerBuilder,
|
|
SQLiteTimestamp,
|
|
SQLiteTimestampBuilder,
|
|
int,
|
|
integer
|
|
};
|
|
//# sourceMappingURL=integer.js.map |