114 lines
7.8 KiB
JavaScript
114 lines
7.8 KiB
JavaScript
// Generated, do not edit. sha256:958c567a3f8a5513bb292a105e1d9e3838bf252c71b7a83188de3f33183e7f66
|
|||
|
|
import { DatabaseSync } from 'node:sqlite';
|
||
|
|
|
||
|
|
import { SCHEMA as BASELINE_SCHEMA } from '../../server/db/schema.js';
|
||
|
|
import { CONFIG } from '../../shared/config.js';
|
||
|
|
|
||
|
|
const NU = '2026-08-12T10:00:00.000Z';
|
||
|
|
|
||
|
|
export function openBaselineDb() {
|
||
|
|
const db = new DatabaseSync(':memory:', { enableForeignKeyConstraints: true });
|
||
|
|
db.exec(`PRAGMA foreign_keys = ON`);
|
||
|
|
db.exec(BASELINE_SCHEMA);
|
||
|
|
return db;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function foreignKeysAan(db) {
|
||
|
|
return db.prepare(`PRAGMA foreign_keys`).get().foreign_keys === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
const FIXTURE = [
|
||
|
|
[`Asset`, `(symbol, name, searchName, description, unit, subunit, displayUnit, decimals, kind)
|
||
|
|
VALUES ('BTC','Bitcoin','bitcoin',NULL,'BTC','sat','subunit',8,'crypto')`],
|
||
|
|
[`Account`, `(name, searchName, description, kind, isOwnCustody, scanEnabled, isActive, closedAt)
|
||
|
|
VALUES ('Kluis','kluis',NULL,'wallet',1,0,1,NULL)`],
|
||
|
|
[`Label`, `(name, searchName, description) VALUES ('Werk','werk',NULL)`],
|
||
|
|
[`MetalProduct`, `(assetId, name, searchName, description, fineGrams, form)
|
||
|
|
VALUES (1,'Baar 1 kg','baar 1 kg',NULL,10000000000,'bar')`],
|
||
|
|
[`Provider`, `(key, name, searchName, description, baseUrl, authenticationHeaderName, authenticationParameterName,
|
||
|
|
authenticationKind, authenticationRequired, isActive, isSeed, isSystem, createdAt)
|
||
|
|
VALUES ('mempool','mempool','mempool',NULL,'https://voorbeeld.test',NULL,NULL,'none',0,1,1,0,'${NU}')`],
|
||
|
|
[`ProviderAuthenticationHmac`, `(providerId, messageParts, keyHeader, signatureHeader, timestampHeader,
|
||
|
|
windowHeader, windowMs, hashAlgorithm, encoding)
|
||
|
|
VALUES (1,'timestamp,method','K','S','T',NULL,NULL,'SHA-256','hex')`],
|
||
|
|
[`ProviderEndpoint`, `(providerId, pathTemplate, queryTemplate, capability, method)
|
||
|
|
VALUES (1,'/api/prijs',NULL,'spot','GET')`],
|
||
|
|
[`ProviderFixedRate`, `(providerId, fiatPrice) VALUES (1,1.0)`],
|
||
|
|
[`ProviderCallLimit`, `(providerId, callsPerMonth, createdAt) VALUES (1,100,'${NU}')`],
|
||
|
|
[`ProviderInputMap`, `(providerId, symbol, externalId, isCatchAll) VALUES (1,'XAU','gold',0)`],
|
||
|
|
[`ProviderOutputMap`, `(providerId, jsonPath, capability, internalField, transform)
|
||
|
|
VALUES (1,'EUR','spot','price','none')`],
|
||
|
|
[`ProviderCoverage`, `(providerId, symbol) VALUES (1,'BTC')`],
|
||
|
|
[`ApiCallMetric`, `(providerId, capability, bucketMinute, okCount, failCount, sumLatencyMs, maxLatencyMs)
|
||
|
|
VALUES (1,'spot','2026-08-12T10:00',1,0,120,120)`],
|
||
|
|
[`Connection`, `(name, searchName, description, url, kind, isActive, isSystem, lastStatus,
|
||
|
|
lastCheckedAt, createdAt, updatedAt)
|
||
|
|
VALUES ('Self-hosted','self-hosted',NULL,'https://knoop.test','btc_explorer',1,0,NULL,NULL,'${NU}','${NU}')`],
|
||
|
|
[`WalletSource`, `(accountId, connectionId, value, name, kind, scriptType, createdAt)
|
||
|
|
VALUES (1,NULL,'xpub6voorbeeld','Hoofdbron','xpub','p2tr','${NU}')`],
|
||
|
|
[`WalletAddress`, `(accountId, sourceId, address, automaticLabel, chainIndex, derivationIndex,
|
||
|
|
balanceSats, transactionCount, lastScannedAt)
|
||
|
|
VALUES (1,1,'bc1qvoorbeeld',NULL,0,0,1000,2,'${NU}')`],
|
||
|
|
[`WalletTransaction`, `(accountId, sourceId, labelId, layer, txid, address, valueSats, feeSats, blockHeight,
|
||
|
|
blockTime, direction, createdAt)
|
||
|
|
VALUES (1,1,1,'onchain','aabbcc','bc1qvoorbeeld',1000,10,900000,'${NU}','in','${NU}')`],
|
||
|
|
[`Event`, `(assetId, fromAccountId, toAccountId, productId, productCount, importReference, externalAddress,
|
||
|
|
note, amount, fiatPrice, fiatFee, unitFee, type, source, occurredAt, createdAt)
|
||
|
|
VALUES (1,1,1,1,1,NULL,NULL,NULL,10000000000,50000.0,NULL,NULL,'buy','manual','${NU}','${NU}')`],
|
||
|
|
[`Valuation`, `(assetId, accountId, balance, fiatRate, source, valuedOn, rateAt)
|
||
|
|
VALUES (1,1,1000,50000.0,'manual','2026-08-12','${NU}')`],
|
||
|
|
[`ScanLog`, `(accountId, addressesFound, balanceFound, proposalsCreated, rawData, status, scannedAt)
|
||
|
|
VALUES (1,2,1000,0,NULL,'success','${NU}')`],
|
||
|
|
[`ReconcileProposal`, `(accountId, assetId, walletTransactionId, resolvedEventId, transactionHash, amount,
|
||
|
|
direction, suggestedType, status, detectedAt)
|
||
|
|
VALUES (1,1,1,1,'aabbcc',1000,'in','transfer','pending','${NU}')`],
|
||
|
|
[`WalletTransactionEventLink`, `(walletTransactionId, eventId, method, createdAt) VALUES (1,1,'exact','${NU}')`],
|
||
|
|
[`ImportBatch`, `(accountId, filename, rowCount, rawData, origin, importedAt)
|
||
|
|
VALUES (1,'export.csv',3,NULL,'Bitvavo','${NU}')`],
|
||
|
|
[`PriceHistory`, `(assetId, providerId, fiatPrice, resolution, observedAt, updatedAt)
|
||
|
|
VALUES (1,1,50000.0,'day','${NU}','${NU}')`],
|
||
|
|
[`InterestSchedule`, `(accountId, principalAssetId, payoutAssetId, note, principalAmount, annualRate,
|
||
|
|
rateKind, creditCadence, creditWeekday, creditDayOfMonth, startsOn, endsOn, compounding, createdAt)
|
||
|
|
VALUES (1,1,1,NULL,100000,0.05,'fixed','weekly',1,NULL,'2026-01-01',NULL,0,'${NU}')`],
|
||
|
|
[`InterestPeriod`, `(scheduleId, startsOn, annualRate)
|
||
|
|
VALUES (1,'2026-04-01',0.037)`],
|
||
|
|
[`InterestCredit`, `(scheduleId, eventId, status, periodStart, periodEnd, createdAt)
|
||
|
|
VALUES (1,1,'booked','2026-08-01','2026-08-08','${NU}')`],
|
||
|
|
[`Notification`, `(count, highWater, kind, dismissedAt, createdAt)
|
||
|
|
VALUES (1,3,'reconcile',NULL,'${NU}')`],
|
||
|
|
[`PriceSource`, `(assetId, providerId, capability, rank, status)
|
||
|
|
VALUES (1,1,'spot',1,'confirmed')`],
|
||
|
|
[`DashboardProfile`, `(name, searchName, description, sortOrder, isActive, isSystem, createdAt, updatedAt)
|
||
|
|
VALUES ('Standaard','standaard',NULL,0,1,1,'${NU}','${NU}')`],
|
||
|
|
[`DashboardWidget`, `(profileId, assetId, instanceKey, gridX, gridY, spanWidth, spanHeight, type, settings)
|
||
|
|
VALUES (1,1,'spot:1',0,0,2,2,'spot',NULL)`],
|
||
|
|
[`Preference`, `(scope, key, value) VALUES ('ui','theme','"dark"')`],
|
||
|
|
[`AiToolCall`, `(sessionId, client, tool, arguments, fieldsShared, charactersOut, outcome, detail, occurredAt)
|
||
|
|
VALUES ('11111111-2222-3333-4444-555555555555','voorbeeld-client','connection_test','{}','[]',42,'ok',NULL,'${NU}')`],
|
||
|
|
[`AiToolCallMessage`, `(callId, kind, text, occurredAt)
|
||
|
|
VALUES (1,'request','{"note":"hallo"}','${NU}')`],
|
||
|
|
[`BusSignal`, `(name, occurredAt) VALUES ('providers-changed','${NU}')`],
|
||
|
|
[`Command`, `(kind, payload, state, expiresAt, createdAt)
|
||
|
|
VALUES ('navigate','{"route":"system","tab":"ai"}','open','${NU}','${NU}')`],
|
||
|
|
[`ChangeLog`, `(tableName, rowId, operation, origin, originId, changes, occurredAt)
|
||
|
|
VALUES ('Account',1,'update','manual',NULL,'{"name":["Oude naam","Nieuwe naam"]}','${NU}')`],
|
||
|
|
[`AiProposal`, `(kind, assetId, fiatPrice, observedAt, note, status, createdAt)
|
||
|
|
VALUES ('price_point',1,50000.0,'${NU}','premie volgens de muntwinkel','pending','${NU}')`],
|
||
|
|
[`HygieneAcceptance`, `(kind, fingerprint, summary, note, createdAt)
|
||
|
|
VALUES ('transfer_without_counterpart','abc123','Verplaatsing zonder tegenkant (1)',NULL,'${NU}')`],
|
||
|
|
[`IgnoredPriceGap`, `(assetId, fromDay, untilDay, createdAt) VALUES (1,'1994-01-01','1994-01-31','${NU}')`],
|
||
|
|
[`PriceAbsence`, `(assetId, providerId, day, createdAt) VALUES (1,1,'2025-12-26','${NU}')`],
|
||
|
|
[`IntegrationCall`, `(target, providerKey, operation, subject, outcome, httpStatus, errorKey, detail, latencyMs, requestId, occurredAt)
|
||
|
|
VALUES ('service',NULL,'/v1/series','crypto:BTC','fail',404,'marketService.rejected api.noSeries','No series',42,'a1b2c3d4-0000-4000-8000-000000000000','${NU}')`],
|
||
|
|
[`AssetNote`, `(assetId, body, createdAt) VALUES (1,'2026-09-26 14:32 geërfd van oma','${NU}')`],
|
||
|
|
[`Schema`, `(id, version) VALUES (1,${CONFIG.SCHEMA_VERSION})`],
|
||
|
|
[`Portfolio`, `(id, baseCurrency, createdAt) VALUES (1,'EUR','${NU}')`],
|
||
|
|
];
|
||
|
|
|
||
|
|
export function vulFixture(db) {
|
||
|
|
for (const [tabel, rest] of FIXTURE) db.exec(`INSERT INTO ${tabel} ${rest}`);
|
||
|
|
return FIXTURE.map(([tabel]) => tabel);
|
||
|
|
}
|
||
|
|
|
||
|
|
export const FIXTURE_TABELLEN = FIXTURE.map(([tabel]) => tabel);
|
||
|
|
export const FIXTURE_TIJD = NU;
|