refactor(server): finish services layer — subscription/spreadsheet/oidc/userDbImport → .cts
Completes the services/ TypeScript migration (0 .js remain). These four are the largest, most dynamic modules (subscription-catalog matcher, xlsx/spreadsheet parser, OIDC protocol client, SQLite user-DB importer); converted to .cts with a top-of-file @ts-nocheck so they run via Node type-stripping now, with rich typing deferred as an incremental follow-up. The other ~46 services are fully typed. Behavior-preserving. Verified: typecheck:server 0, check:server 0, suite 226/226. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
99e4927640
commit
409b8a5618
|
|
@ -1213,7 +1213,7 @@ module.exports = function buildVersionedMigrations(deps) {
|
|||
description: 're-normalize merchant rules after & fix; ensure rejection expiry column',
|
||||
dependsOn: ['v0.89'],
|
||||
run: function() {
|
||||
const { normalizeMerchant } = require('../../services/subscriptionService');
|
||||
const { normalizeMerchant } = require('../../services/subscriptionService.cts');
|
||||
|
||||
// Re-normalize bill_merchant_rules stored under old normalization ("at t" → "att")
|
||||
let billFixed = 0;
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ const {
|
|||
buildAuthModeStatus,
|
||||
buildSubmittedOidcConfig,
|
||||
testOidcConfiguration,
|
||||
} = require('../services/oidcService');
|
||||
} = require('../services/oidcService.cts');
|
||||
|
||||
// GET /api/admin/auth-mode
|
||||
router.get('/auth-mode', (req, res) => {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const { login, logout, hashPassword, cookieOpts, COOKIE_NAME, SINGLE_COOKIE_NAME
|
|||
const { decryptSecret } = require('../services/encryptionService.cts');
|
||||
const { getCsrfToken } = require('../middleware/csrf');
|
||||
const { requireAuth, requireAdmin } = require('../middleware/requireAuth');
|
||||
const { getPublicOidcInfo } = require('../services/oidcService');
|
||||
const { getPublicOidcInfo } = require('../services/oidcService.cts');
|
||||
const { ValidationError, formatError } = require('../utils/apiError.cts');
|
||||
const { standardizeError } = require('../middleware/errorFormatter');
|
||||
const { passwordLimiter } = require('../middleware/rateLimiter');
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const {
|
|||
buildAuthorizationUrl,
|
||||
exchangeAndVerifyTokens,
|
||||
findOrProvisionUser,
|
||||
} = require('../services/oidcService');
|
||||
} = require('../services/oidcService.cts');
|
||||
|
||||
const NOT_ACTIVE = { error: 'OIDC authentication is not configured or not enabled on this server' };
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const { amortizationSchedule, debtAprSnapshot } = require('../services/aprServic
|
|||
const { standardizeError } = require('../middleware/errorFormatter');
|
||||
const { validatePaymentInput, serializePayment } = require('../services/paymentValidation.cts');
|
||||
const { addMerchantRule, syncBillPaymentsFromSimplefin, merchantMatches } = require('../services/billMerchantRuleService.cts');
|
||||
const { normalizeMerchant } = require('../services/subscriptionService');
|
||||
const { normalizeMerchant } = require('../services/subscriptionService.cts');
|
||||
const { decorateTransaction } = require('../services/transactionService.cts');
|
||||
const {
|
||||
accountingActiveSql,
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ const {
|
|||
previewSpreadsheet,
|
||||
applyImportDecisions,
|
||||
getImportHistory,
|
||||
} = require('../services/spreadsheetImportService');
|
||||
} = require('../services/spreadsheetImportService.cts');
|
||||
const {
|
||||
previewUserDbImport,
|
||||
applyUserDbImport,
|
||||
} = require('../services/userDbImportService');
|
||||
} = require('../services/userDbImportService.cts');
|
||||
const {
|
||||
previewCsvTransactions,
|
||||
commitCsvTransactions,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const { passwordLimiter } = require('../middleware/rateLimiter');
|
|||
|
||||
const { getDb, getSetting } = require('../db/database');
|
||||
const { hashPassword, invalidateOtherSessions, rotateSessionId, COOKIE_NAME, cookieOpts } = require('../services/authService.cts');
|
||||
const { getImportHistory } = require('../services/spreadsheetImportService');
|
||||
const { getImportHistory } = require('../services/spreadsheetImportService.cts');
|
||||
const { logAudit } = require('../services/auditService.cts');
|
||||
const { standardizeError } = require('../middleware/errorFormatter');
|
||||
const { encryptSecret, decryptSecret } = require('../services/encryptionService.cts');
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const {
|
|||
monthlyEquivalent,
|
||||
recordSubscriptionFeedback,
|
||||
searchSubscriptionTransactions,
|
||||
} = require('../services/subscriptionService');
|
||||
} = require('../services/subscriptionService.cts');
|
||||
const { addMerchantRule, applyMerchantRules } = require('../services/billMerchantRuleService.cts');
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import type { Db } from '../types/db';
|
||||
|
||||
const { normalizeMerchant } = require('./subscriptionService');
|
||||
const { normalizeMerchant } = require('./subscriptionService.cts');
|
||||
const { getUserSettings } = require('./userSettings.cts');
|
||||
const { applyBankPaymentAsSourceOfTruth } = require('./paymentAccountingService.cts');
|
||||
const { localDateString } = require('../utils/dates.mts') as typeof import('../utils/dates.mts');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @ts-nocheck — converted to .cts (runs via Node type-stripping); rich typing deferred (large dynamic OIDC protocol client). TODO: type incrementally.
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import type { Db } from '../types/db';
|
||||
|
||||
const { normalizeMerchant } = require('./subscriptionService');
|
||||
const { normalizeMerchant } = require('./subscriptionService.cts');
|
||||
const { localDateString } = require('../utils/dates.mts') as typeof import('../utils/dates.mts');
|
||||
const { toCents, fromCents } = require('../utils/money.mts') as typeof import('../utils/money.mts');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @ts-nocheck — converted to .cts (runs via Node type-stripping); rich typing deferred (1800-line dynamic spreadsheet/xlsx parser). TODO: type incrementally.
|
||||
'use strict';
|
||||
|
||||
// Security note: xlsx (SheetJS Community Edition) has known prototype-pollution
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @ts-nocheck — converted to .cts (runs via Node type-stripping); rich typing deferred (large, dynamic subscription-catalog matcher). TODO: type incrementally.
|
||||
'use strict';
|
||||
|
||||
const { billingCycleForCycleType, insertBill, validateBillData } = require('./billsService.cts');
|
||||
|
|
@ -8,7 +8,7 @@ const { getUserSettings } = require('./userSettings.cts');
|
|||
const { computeBalanceDelta, applyBalanceDelta } = require('./billsService.cts');
|
||||
const { computeAmountSuggestionsBatch } = require('./amountSuggestionService.cts');
|
||||
const { accountingActiveSql } = require('./paymentAccountingService.cts');
|
||||
const { normalizeMerchant } = require('./subscriptionService');
|
||||
const { normalizeMerchant } = require('./subscriptionService.cts');
|
||||
const { localDateString } = require('../utils/dates.mts');
|
||||
// Aggregation-heavy: money results flow through many .filter/.sort/arith, so a
|
||||
// plain require (→ any) avoids Dollars|null friction (cf. analyticsService).
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @ts-nocheck — converted to .cts (runs via Node type-stripping); rich typing deferred (large dynamic SQLite user-DB importer). TODO: type incrementally.
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
|
|
@ -15,7 +15,7 @@ process.env.DB_PATH = dbPath;
|
|||
|
||||
const { getDb, closeDb } = require('../db/database');
|
||||
const { buildUserDbExportFile } = require('../routes/export');
|
||||
const { previewUserDbImport, applyUserDbImport } = require('../services/userDbImportService');
|
||||
const { previewUserDbImport, applyUserDbImport } = require('../services/userDbImportService.cts');
|
||||
|
||||
const mkUser = (db, name) =>
|
||||
db.prepare("INSERT INTO users (username, password_hash, role, active) VALUES (?, 'x', 'user', 1)").run(name).lastInsertRowid;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const {
|
|||
getSubscriptionRecommendations,
|
||||
recordSubscriptionFeedback,
|
||||
searchSubscriptionTransactions,
|
||||
} = require('../services/subscriptionService');
|
||||
} = require('../services/subscriptionService.cts');
|
||||
|
||||
function createUser(db, suffix) {
|
||||
return db.prepare(`
|
||||
|
|
|
|||
Loading…
Reference in New Issue