@proteinjs/db-driver-knex 1.14.1 → 1.15.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +5 -3
  3. package/dist/generated/index.js +1 -1
  4. package/dist/generated/index.js.map +1 -1
  5. package/dist/generated/test/index.js +1 -1
  6. package/dist/generated/test/index.js.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/src/KnexConfig.d.ts +8 -0
  12. package/dist/src/KnexConfig.d.ts.map +1 -1
  13. package/dist/src/KnexDriver.d.ts +8 -7
  14. package/dist/src/KnexDriver.d.ts.map +1 -1
  15. package/dist/src/KnexDriver.js +52 -36
  16. package/dist/src/KnexDriver.js.map +1 -1
  17. package/dist/src/KnexFailureLine.d.ts +58 -0
  18. package/dist/src/KnexFailureLine.d.ts.map +1 -0
  19. package/dist/src/KnexFailureLine.js +124 -0
  20. package/dist/src/KnexFailureLine.js.map +1 -0
  21. package/dist/test/LogValuesSwitch.test.js +13 -7
  22. package/dist/test/LogValuesSwitch.test.js.map +1 -1
  23. package/dist/test/OperationDeadline.test.d.ts +2 -0
  24. package/dist/test/OperationDeadline.test.d.ts.map +1 -0
  25. package/dist/test/OperationDeadline.test.js +166 -0
  26. package/dist/test/OperationDeadline.test.js.map +1 -0
  27. package/dist/test/StatementLogNeverThrows.test.js +23 -29
  28. package/dist/test/StatementLogNeverThrows.test.js.map +1 -1
  29. package/dist/test/StatementParamLogging.test.js +16 -41
  30. package/dist/test/StatementParamLogging.test.js.map +1 -1
  31. package/dist/test/VendorTextNeverOnALine.test.d.ts +2 -0
  32. package/dist/test/VendorTextNeverOnALine.test.d.ts.map +1 -0
  33. package/dist/test/VendorTextNeverOnALine.test.js +330 -0
  34. package/dist/test/VendorTextNeverOnALine.test.js.map +1 -0
  35. package/generated/index.ts +1 -1
  36. package/generated/test/index.ts +1 -1
  37. package/index.ts +1 -0
  38. package/package.json +5 -5
  39. package/src/KnexConfig.ts +8 -0
  40. package/src/KnexDriver.ts +36 -37
  41. package/src/KnexFailureLine.ts +127 -0
  42. package/test/LogValuesSwitch.test.ts +3 -1
  43. package/test/OperationDeadline.test.ts +118 -0
  44. package/test/StatementLogNeverThrows.test.ts +24 -20
  45. package/test/StatementParamLogging.test.ts +12 -17
  46. package/test/VendorTextNeverOnALine.test.ts +257 -0
@@ -8,7 +8,7 @@ import '@proteinjs/logger';
8
8
  /** Generate Source Graph */
9
9
 
10
10
  const sourceGraph =
11
- '{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-driver-knex/KnexDriver","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":"src/KnexDriver.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"KNEX","type":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"config","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexConfig","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexConfig","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexConfig","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"getTable","type":{"packageName":"","name":"((name: string) => Table<any>) | undefined","filePath":null,"qualifiedName":"/((name: string) => Table<any>) | undefined","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getKnex","returnType":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"getDbName","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDbIfNotExists","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"options","type":{"packageName":"@proteinjs/db-driver-knex","name":"{ ddl?: string[] }","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/{ ddl?: string[] }","typeParameters":null,"directParents":null}}]},{"name":"dropDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"dbExists","returnType":{"packageName":"","name":"Promise<boolean>","filePath":null,"qualifiedName":"/Promise<boolean>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"databaseName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"start","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"stop","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"setMaxAllowedPacketSize","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]},{"name":"getTableManager","returnType":{"packageName":"@proteinjs/db","name":"TableManager","filePath":null,"qualifiedName":"@proteinjs/db/TableManager","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"handleCaseSensitivity","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tableName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"columnName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"caseSensitive","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}}]},{"name":"runQuery","returnType":{"packageName":"","name":"Promise<SerializedRecord[]>","filePath":null,"qualifiedName":"/Promise<SerializedRecord[]>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverQueryStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverQueryStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runDml","returnType":{"packageName":"","name":"Promise<number>","filePath":null,"qualifiedName":"/Promise<number>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverDmlStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverDmlStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runTransaction","returnType":{"packageName":"","name":"Promise<T>","filePath":null,"qualifiedName":"/Promise<T>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"fn","type":{"packageName":"","name":"(transaction: Transaction) => Promise<T>","filePath":null,"qualifiedName":"/(transaction: Transaction) => Promise<T>","typeParameters":null,"directParents":null}}]},{"name":"logFailure","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"sql","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}},{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"writeStatementLine","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"write","type":{"packageName":"","name":"() => void","filePath":null,"qualifiedName":"/() => void","typeParameters":null,"directParents":null}}]},{"name":"causeSummary","returnType":{"packageName":"@proteinjs/db-driver-knex","name":"FailureCauseSummary","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/FailureCauseSummary","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"describeParams","returnType":{"packageName":"","name":"ParamsDescription | undefined","filePath":null,"qualifiedName":"/ParamsDescription | undefined","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"describeParam","returnType":{"packageName":"@proteinjs/db-driver-knex","name":"ParamDescription","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/ParamDescription","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"read","type":{"packageName":"","name":"() => unknown","filePath":null,"qualifiedName":"/() => unknown","typeParameters":null,"directParents":null}}]},{"name":"paramKind","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"value","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"isDictionary","returnType":{"packageName":"","name":"params is { [name: string]: unknown }","filePath":null,"qualifiedName":"/params is { [name: string]: unknown }","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"vendorFact","returnType":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}},{"name":"fact","type":{"packageName":"","name":"keyof FailureCauseSummary","filePath":null,"qualifiedName":"/keyof FailureCauseSummary","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"DbDriver","filePath":null,"qualifiedName":"@proteinjs/db/DbDriver","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/DbDriver"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexSchemaOperations","filePath":"src/KnexSchemaOperations.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexSchemaOperations","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexDriver","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"createTables","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tables","type":{"packageName":"","name":"Table<any>[]","filePath":null,"qualifiedName":"/Table<any>[]","typeParameters":null,"directParents":null}}]},{"name":"createTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}}]},{"name":"alterTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]},{"name":"createColumn","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"column","type":{"packageName":"","name":"Column<any, any>","filePath":null,"qualifiedName":"/Column<any, any>","typeParameters":null,"directParents":null}},{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableBuilder","type":{"packageName":"","name":"knex.TableBuilder","filePath":null,"qualifiedName":"/knex.TableBuilder","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"SchemaOperations","filePath":null,"qualifiedName":"@proteinjs/db/SchemaOperations","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/SchemaOperations"}],"edges":[{"v":"@proteinjs/db-driver-knex/KnexDriver","w":"@proteinjs/db/DbDriver","value":"implements interface"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","w":"@proteinjs/db/SchemaOperations","value":"implements interface"}]}';
11
+ '{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-driver-knex/KnexDriver","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":"src/KnexDriver.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"KNEX","type":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"DEFAULT_OPERATION_DEADLINE_MS","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"config","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexConfig","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexConfig","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexConfig","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"getTable","type":{"packageName":"","name":"((name: string) => Table<any>) | undefined","filePath":null,"qualifiedName":"/((name: string) => Table<any>) | undefined","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getKnex","returnType":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"getDbName","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDbIfNotExists","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"options","type":{"packageName":"@proteinjs/db-driver-knex","name":"{ ddl?: string[] }","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/{ ddl?: string[] }","typeParameters":null,"directParents":null}}]},{"name":"dropDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"dbExists","returnType":{"packageName":"","name":"Promise<boolean>","filePath":null,"qualifiedName":"/Promise<boolean>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"databaseName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"start","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"stop","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"setMaxAllowedPacketSize","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]},{"name":"getTableManager","returnType":{"packageName":"@proteinjs/db","name":"TableManager","filePath":null,"qualifiedName":"@proteinjs/db/TableManager","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"handleCaseSensitivity","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tableName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"columnName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"caseSensitive","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}}]},{"name":"runQuery","returnType":{"packageName":"","name":"Promise<SerializedRecord[]>","filePath":null,"qualifiedName":"/Promise<SerializedRecord[]>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverQueryStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverQueryStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runDml","returnType":{"packageName":"","name":"Promise<number>","filePath":null,"qualifiedName":"/Promise<number>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverDmlStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverDmlStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runTransaction","returnType":{"packageName":"","name":"Promise<T>","filePath":null,"qualifiedName":"/Promise<T>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"fn","type":{"packageName":"","name":"(transaction: Transaction) => Promise<T>","filePath":null,"qualifiedName":"/(transaction: Transaction) => Promise<T>","typeParameters":null,"directParents":null}}]},{"name":"getOperationDeadlineMs","returnType":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"logFailure","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"sql","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}},{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"writeStatementLine","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"write","type":{"packageName":"","name":"() => void","filePath":null,"qualifiedName":"/() => void","typeParameters":null,"directParents":null}}]},{"name":"describeParams","returnType":{"packageName":"","name":"ParamsDescription | undefined","filePath":null,"qualifiedName":"/ParamsDescription | undefined","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"describeParam","returnType":{"packageName":"@proteinjs/db-driver-knex","name":"ParamDescription","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/ParamDescription","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"read","type":{"packageName":"","name":"() => unknown","filePath":null,"qualifiedName":"/() => unknown","typeParameters":null,"directParents":null}}]},{"name":"paramKind","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"value","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"isDictionary","returnType":{"packageName":"","name":"params is { [name: string]: unknown }","filePath":null,"qualifiedName":"/params is { [name: string]: unknown }","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"DbDriver","filePath":null,"qualifiedName":"@proteinjs/db/DbDriver","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/DbDriver"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexSchemaOperations","filePath":"src/KnexSchemaOperations.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexSchemaOperations","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexDriver","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"createTables","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tables","type":{"packageName":"","name":"Table<any>[]","filePath":null,"qualifiedName":"/Table<any>[]","typeParameters":null,"directParents":null}}]},{"name":"createTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}}]},{"name":"alterTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]},{"name":"createColumn","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"column","type":{"packageName":"","name":"Column<any, any>","filePath":null,"qualifiedName":"/Column<any, any>","typeParameters":null,"directParents":null}},{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableBuilder","type":{"packageName":"","name":"knex.TableBuilder","filePath":null,"qualifiedName":"/knex.TableBuilder","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"SchemaOperations","filePath":null,"qualifiedName":"@proteinjs/db/SchemaOperations","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/SchemaOperations"}],"edges":[{"v":"@proteinjs/db-driver-knex/KnexDriver","w":"@proteinjs/db/DbDriver","value":"implements interface"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","w":"@proteinjs/db/SchemaOperations","value":"implements interface"}]}';
12
12
 
13
13
  /** Generate Source Links */
14
14
 
@@ -8,7 +8,7 @@ import '@proteinjs/logger';
8
8
  /** Generate Source Graph */
9
9
 
10
10
  const sourceGraph =
11
- '{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-driver-knex/TestDbDriverFactory","value":{"packageName":"@proteinjs/db-driver-knex","name":"TestDbDriverFactory","filePath":"test/config/TestDbDriverFactory.ts","qualifiedName":"@proteinjs/db-driver-knex/TestDbDriverFactory","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[{"name":"getDbDriver","returnType":{"packageName":"@proteinjs/db","name":"DbDriver","filePath":null,"qualifiedName":"@proteinjs/db/DbDriver","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"DefaultDbDriverFactory","filePath":null,"qualifiedName":"@proteinjs/db/DefaultDbDriverFactory","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/DefaultDbDriverFactory"},{"v":"@proteinjs/db-driver-knex/KnexDriver","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":"src/KnexDriver.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"KNEX","type":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"config","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexConfig","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexConfig","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexConfig","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"getTable","type":{"packageName":"","name":"((name: string) => Table<any>) | undefined","filePath":null,"qualifiedName":"/((name: string) => Table<any>) | undefined","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getKnex","returnType":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"getDbName","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDbIfNotExists","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"options","type":{"packageName":"@proteinjs/db-driver-knex","name":"{ ddl?: string[] }","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/{ ddl?: string[] }","typeParameters":null,"directParents":null}}]},{"name":"dropDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"dbExists","returnType":{"packageName":"","name":"Promise<boolean>","filePath":null,"qualifiedName":"/Promise<boolean>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"databaseName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"start","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"stop","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"setMaxAllowedPacketSize","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]},{"name":"getTableManager","returnType":{"packageName":"@proteinjs/db","name":"TableManager","filePath":null,"qualifiedName":"@proteinjs/db/TableManager","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"handleCaseSensitivity","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tableName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"columnName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"caseSensitive","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}}]},{"name":"runQuery","returnType":{"packageName":"","name":"Promise<SerializedRecord[]>","filePath":null,"qualifiedName":"/Promise<SerializedRecord[]>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverQueryStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverQueryStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runDml","returnType":{"packageName":"","name":"Promise<number>","filePath":null,"qualifiedName":"/Promise<number>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverDmlStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverDmlStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runTransaction","returnType":{"packageName":"","name":"Promise<T>","filePath":null,"qualifiedName":"/Promise<T>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"fn","type":{"packageName":"","name":"(transaction: Transaction) => Promise<T>","filePath":null,"qualifiedName":"/(transaction: Transaction) => Promise<T>","typeParameters":null,"directParents":null}}]},{"name":"logFailure","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"sql","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}},{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"writeStatementLine","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"write","type":{"packageName":"","name":"() => void","filePath":null,"qualifiedName":"/() => void","typeParameters":null,"directParents":null}}]},{"name":"causeSummary","returnType":{"packageName":"@proteinjs/db-driver-knex","name":"FailureCauseSummary","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/FailureCauseSummary","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"describeParams","returnType":{"packageName":"","name":"ParamsDescription | undefined","filePath":null,"qualifiedName":"/ParamsDescription | undefined","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"describeParam","returnType":{"packageName":"@proteinjs/db-driver-knex","name":"ParamDescription","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/ParamDescription","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"read","type":{"packageName":"","name":"() => unknown","filePath":null,"qualifiedName":"/() => unknown","typeParameters":null,"directParents":null}}]},{"name":"paramKind","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"value","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"isDictionary","returnType":{"packageName":"","name":"params is { [name: string]: unknown }","filePath":null,"qualifiedName":"/params is { [name: string]: unknown }","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"vendorFact","returnType":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}},{"name":"fact","type":{"packageName":"","name":"keyof FailureCauseSummary","filePath":null,"qualifiedName":"/keyof FailureCauseSummary","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"DbDriver","filePath":null,"qualifiedName":"@proteinjs/db/DbDriver","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/DbDriver"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexSchemaOperations","filePath":"src/KnexSchemaOperations.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexSchemaOperations","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexDriver","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"createTables","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tables","type":{"packageName":"","name":"Table<any>[]","filePath":null,"qualifiedName":"/Table<any>[]","typeParameters":null,"directParents":null}}]},{"name":"createTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}}]},{"name":"alterTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]},{"name":"createColumn","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"column","type":{"packageName":"","name":"Column<any, any>","filePath":null,"qualifiedName":"/Column<any, any>","typeParameters":null,"directParents":null}},{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableBuilder","type":{"packageName":"","name":"knex.TableBuilder","filePath":null,"qualifiedName":"/knex.TableBuilder","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"SchemaOperations","filePath":null,"qualifiedName":"@proteinjs/db/SchemaOperations","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/SchemaOperations"}],"edges":[{"v":"@proteinjs/db-driver-knex/TestDbDriverFactory","w":"@proteinjs/db/DefaultDbDriverFactory","value":"implements interface"},{"v":"@proteinjs/db-driver-knex/KnexDriver","w":"@proteinjs/db/DbDriver","value":"implements interface"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","w":"@proteinjs/db/SchemaOperations","value":"implements interface"}]}';
11
+ '{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-driver-knex/TestDbDriverFactory","value":{"packageName":"@proteinjs/db-driver-knex","name":"TestDbDriverFactory","filePath":"test/config/TestDbDriverFactory.ts","qualifiedName":"@proteinjs/db-driver-knex/TestDbDriverFactory","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[{"name":"getDbDriver","returnType":{"packageName":"@proteinjs/db","name":"DbDriver","filePath":null,"qualifiedName":"@proteinjs/db/DbDriver","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"DefaultDbDriverFactory","filePath":null,"qualifiedName":"@proteinjs/db/DefaultDbDriverFactory","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/DefaultDbDriverFactory"},{"v":"@proteinjs/db-driver-knex/KnexDriver","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":"src/KnexDriver.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"KNEX","type":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"DEFAULT_OPERATION_DEADLINE_MS","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"config","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexConfig","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexConfig","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexConfig","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"getTable","type":{"packageName":"","name":"((name: string) => Table<any>) | undefined","filePath":null,"qualifiedName":"/((name: string) => Table<any>) | undefined","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getKnex","returnType":{"packageName":"","name":"knex","filePath":null,"qualifiedName":"/knex","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"getDbName","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDbIfNotExists","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"createDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"options","type":{"packageName":"@proteinjs/db-driver-knex","name":"{ ddl?: string[] }","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/{ ddl?: string[] }","typeParameters":null,"directParents":null}}]},{"name":"dropDb","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"name","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"dbExists","returnType":{"packageName":"","name":"Promise<boolean>","filePath":null,"qualifiedName":"/Promise<boolean>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"databaseName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"start","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"stop","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"setMaxAllowedPacketSize","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]},{"name":"getTableManager","returnType":{"packageName":"@proteinjs/db","name":"TableManager","filePath":null,"qualifiedName":"@proteinjs/db/TableManager","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"handleCaseSensitivity","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tableName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"columnName","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"caseSensitive","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}}]},{"name":"runQuery","returnType":{"packageName":"","name":"Promise<SerializedRecord[]>","filePath":null,"qualifiedName":"/Promise<SerializedRecord[]>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverQueryStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverQueryStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runDml","returnType":{"packageName":"","name":"Promise<number>","filePath":null,"qualifiedName":"/Promise<number>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"generateStatement","type":{"packageName":"","name":"(config: DbDriverDmlStatementConfig) => Statement","filePath":null,"qualifiedName":"/(config: DbDriverDmlStatementConfig) => Statement","typeParameters":null,"directParents":null}},{"name":"transaction","type":{"packageName":"knex","name":"Transaction","filePath":null,"qualifiedName":"knex/Transaction","typeParameters":null,"directParents":null}}]},{"name":"runTransaction","returnType":{"packageName":"","name":"Promise<T>","filePath":null,"qualifiedName":"/Promise<T>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"fn","type":{"packageName":"","name":"(transaction: Transaction) => Promise<T>","filePath":null,"qualifiedName":"/(transaction: Transaction) => Promise<T>","typeParameters":null,"directParents":null}}]},{"name":"getOperationDeadlineMs","returnType":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"logFailure","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"sql","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}},{"name":"error","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"writeStatementLine","returnType":{"packageName":"","name":"void","filePath":null,"qualifiedName":"/void","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"write","type":{"packageName":"","name":"() => void","filePath":null,"qualifiedName":"/() => void","typeParameters":null,"directParents":null}}]},{"name":"describeParams","returnType":{"packageName":"","name":"ParamsDescription | undefined","filePath":null,"qualifiedName":"/ParamsDescription | undefined","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"describeParam","returnType":{"packageName":"@proteinjs/db-driver-knex","name":"ParamDescription","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/ParamDescription","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"read","type":{"packageName":"","name":"() => unknown","filePath":null,"qualifiedName":"/() => unknown","typeParameters":null,"directParents":null}}]},{"name":"paramKind","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"value","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]},{"name":"isDictionary","returnType":{"packageName":"","name":"params is { [name: string]: unknown }","filePath":null,"qualifiedName":"/params is { [name: string]: unknown }","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"params","type":{"packageName":"","name":"unknown","filePath":null,"qualifiedName":"/unknown","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"DbDriver","filePath":null,"qualifiedName":"@proteinjs/db/DbDriver","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/DbDriver"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","value":{"packageName":"@proteinjs/db-driver-knex","name":"KnexSchemaOperations","filePath":"src/KnexSchemaOperations.ts","qualifiedName":"@proteinjs/db-driver-knex/KnexSchemaOperations","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"logger","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"knexDriver","type":{"packageName":"@proteinjs/db-driver-knex","name":"KnexDriver","filePath":null,"qualifiedName":"@proteinjs/db-driver-knex/KnexDriver","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"createTables","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"tables","type":{"packageName":"","name":"Table<any>[]","filePath":null,"qualifiedName":"/Table<any>[]","typeParameters":null,"directParents":null}}]},{"name":"createTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}}]},{"name":"alterTable","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]},{"name":"createColumn","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"column","type":{"packageName":"","name":"Column<any, any>","filePath":null,"qualifiedName":"/Column<any, any>","typeParameters":null,"directParents":null}},{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null}},{"name":"tableBuilder","type":{"packageName":"","name":"knex.TableBuilder","filePath":null,"qualifiedName":"/knex.TableBuilder","typeParameters":null,"directParents":null}},{"name":"tableChanges","type":{"packageName":"@proteinjs/db","name":"TableChanges","filePath":null,"qualifiedName":"@proteinjs/db/TableChanges","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"SchemaOperations","filePath":null,"qualifiedName":"@proteinjs/db/SchemaOperations","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/SchemaOperations"}],"edges":[{"v":"@proteinjs/db-driver-knex/TestDbDriverFactory","w":"@proteinjs/db/DefaultDbDriverFactory","value":"implements interface"},{"v":"@proteinjs/db-driver-knex/KnexDriver","w":"@proteinjs/db/DbDriver","value":"implements interface"},{"v":"@proteinjs/db-driver-knex/KnexSchemaOperations","w":"@proteinjs/db/SchemaOperations","value":"implements interface"}]}';
12
12
 
13
13
  /** Generate Source Links */
14
14
 
package/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './src/KnexDriver';
2
2
  export * from './src/KnexConfig';
3
3
  export * from './src/KnexLogValues';
4
+ export * from './src/KnexFailureLine';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteinjs/db-driver-knex",
3
- "version": "1.14.1",
3
+ "version": "1.15.1",
4
4
  "main": "./dist/generated/index.js",
5
5
  "types": "./dist/generated/index.d.ts",
6
6
  "exports": {
@@ -41,10 +41,10 @@
41
41
  "test": "jest --runInBand --passWithNoTests"
42
42
  },
43
43
  "dependencies": {
44
- "@proteinjs/db": "^1.47.3",
44
+ "@proteinjs/db": "^1.49.0",
45
45
  "@proteinjs/db-query": "^1.10.1",
46
- "@proteinjs/db-transaction-context": "^0.5.35",
47
- "@proteinjs/logger": "^1.0.21",
46
+ "@proteinjs/db-transaction-context": "^0.5.37",
47
+ "@proteinjs/logger": "^1.2.0",
48
48
  "@proteinjs/reflection": "^1.2.0",
49
49
  "@proteinjs/util": "^1.6.1",
50
50
  "knex": "0.21.5",
@@ -67,5 +67,5 @@
67
67
  "ts-jest": "29.1.1",
68
68
  "typescript": "5.2.2"
69
69
  },
70
- "gitHead": "08154afae17a9a19c9e48520a3dd67ead7b997c6"
70
+ "gitHead": "5ef7c5a2f3eb6ef3b774aa93cc74cc1754cfa011"
71
71
  }
package/src/KnexConfig.ts CHANGED
@@ -3,4 +3,12 @@ export type KnexConfig = {
3
3
  user: string;
4
4
  password: string;
5
5
  dbName: string;
6
+ /**
7
+ * Deadline applied to every query and DML statement the driver runs, inside a transaction or
8
+ * not (default 60_000ms). A statement that has not settled by the deadline is cancelled on the
9
+ * server (`KILL QUERY`) and FAILS with an error naming the deadline, instead of holding its
10
+ * connection for as long as the server lets it run. Schema operations (DDL) are exempt. The
11
+ * driver reports this value as its per-operation deadline (`DbDriver.getOperationDeadlineMs`).
12
+ */
13
+ operationDeadlineMs?: number;
6
14
  };
package/src/KnexDriver.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  } from '@proteinjs/db';
11
11
  import { KnexConfig } from './KnexConfig';
12
12
  import { KnexLogValues } from './KnexLogValues';
13
+ import { KnexFailureLine } from './KnexFailureLine';
13
14
  import { Logger } from '@proteinjs/logger';
14
15
  import { Statement } from '@proteinjs/db-query';
15
16
  import { KnexSchemaOperations } from './KnexSchemaOperations';
@@ -24,14 +25,13 @@ type ParamDescription = { type: string; length?: number; null?: true };
24
25
  */
25
26
  type ParamsDescription = ParamDescription[] | { [name: string]: ParamDescription } | 'unreadable';
26
27
 
27
- /** A failure as the log line carries it: the error's name, the vendor's codes and the server's own message. */
28
- type FailureCauseSummary = { name?: string; code?: string; errno?: number; sqlState?: string; sqlMessage?: string };
29
-
30
28
  /**
31
29
  * Knex driver (configured for MariaDb) for ProteinJs Db
32
30
  */
33
31
  export class KnexDriver implements DbDriver {
34
32
  private static KNEX: knex;
33
+ /** The per-operation deadline when `KnexConfig.operationDeadlineMs` is unset (see getOperationDeadlineMs). */
34
+ private static readonly DEFAULT_OPERATION_DEADLINE_MS = 60_000;
35
35
  private logger = new Logger({ name: this.constructor.name });
36
36
  private config: KnexConfig;
37
37
  private knexConfig: any;
@@ -172,8 +172,11 @@ export class KnexDriver implements DbDriver {
172
172
 
173
173
  try {
174
174
  const runner = transaction || this.getKnex();
175
- return (await runner.raw(sql, params as any))[0]; // returns 2 arrays, first is records, second is metadata per record
175
+ // returns 2 arrays, first is records, second is metadata per record
176
+ return (await runner.raw(sql, params as any).timeout(this.getOperationDeadlineMs(), { cancel: true }))[0];
176
177
  } catch (error: unknown) {
178
+ // Rethrown as it is; marked, so no line about it — this driver's or a caller's — prints its text.
179
+ KnexFailureLine.mark(error, 'Failed when executing sql');
177
180
  this.logFailure(sql, params, error);
178
181
  throw error;
179
182
  }
@@ -193,10 +196,34 @@ export class KnexDriver implements DbDriver {
193
196
  * @returns the return value of the `fn`
194
197
  */
195
198
  async runTransaction<T>(fn: (transaction: Transaction) => Promise<T>): Promise<T> {
196
- return await this.getKnex().transaction(async (trx) => {
197
- const result = await fn(trx);
198
- return result;
199
- });
199
+ const bodyErrors = new Set<unknown>();
200
+ try {
201
+ return await this.getKnex().transaction(async (trx) => {
202
+ try {
203
+ return await fn(trx);
204
+ } catch (error: unknown) {
205
+ bodyErrors.add(error);
206
+ throw error;
207
+ }
208
+ });
209
+ } catch (error: unknown) {
210
+ // What the BODY threw is the caller's own error, or a failure already marked at the
211
+ // statement's door. Anything else was raised around the body — beginning, committing —
212
+ // and words itself as the vendor did. Rethrown as it is, either way.
213
+ if (!bodyErrors.has(error)) {
214
+ KnexFailureLine.mark(error, 'Transaction failed');
215
+ }
216
+ throw error;
217
+ }
218
+ }
219
+
220
+ /**
221
+ * The deadline every statement runs under — `KnexConfig.operationDeadlineMs`, 60 s when unset —
222
+ * and the one place the driver reads it: the deadline this reports is the deadline runQuery
223
+ * enforces (the query layer's timeout, cancelling the statement on the server when it fires).
224
+ */
225
+ getOperationDeadlineMs(): number {
226
+ return this.config.operationDeadlineMs ?? KnexDriver.DEFAULT_OPERATION_DEADLINE_MS;
200
227
  }
201
228
 
202
229
  /**
@@ -226,7 +253,7 @@ export class KnexDriver implements DbDriver {
226
253
  sql,
227
254
  params: this.describeParams(params),
228
255
  ...KnexLogValues.ofStatement(params),
229
- cause: this.causeSummary(error),
256
+ cause: KnexFailureLine.causeOf(error),
230
257
  },
231
258
  ...KnexLogValues.ofFailure(error),
232
259
  })
@@ -255,25 +282,6 @@ export class KnexDriver implements DbDriver {
255
282
  }
256
283
  }
257
284
 
258
- /**
259
- * The name, codes and server message of any thrown value — never the query layer's rewritten
260
- * `message` or `sql`. Total: a fact that cannot be read (vendorFact) is left out.
261
- */
262
- private causeSummary(error: unknown): FailureCauseSummary {
263
- const name = this.vendorFact(error, 'name');
264
- const code = this.vendorFact(error, 'code');
265
- const errno = this.vendorFact(error, 'errno');
266
- const sqlState = this.vendorFact(error, 'sqlState');
267
- const sqlMessage = this.vendorFact(error, 'sqlMessage');
268
- return {
269
- ...(typeof name === 'string' ? { name } : {}),
270
- ...(typeof code === 'string' ? { code } : {}),
271
- ...(typeof errno === 'number' ? { errno } : {}),
272
- ...(typeof sqlState === 'string' ? { sqlState } : {}),
273
- ...(typeof sqlMessage === 'string' ? { sqlMessage } : {}),
274
- };
275
- }
276
-
277
285
  /**
278
286
  * A statement's bound parameters as a LOG LINE carries them — the one owner of that form: by
279
287
  * position, the KIND of each value and, for strings, arrays and bytes, its LENGTH. Never a
@@ -365,13 +373,4 @@ export class KnexDriver implements DbDriver {
365
373
  const prototype = Object.getPrototypeOf(params);
366
374
  return prototype === null || Object.getPrototypeOf(prototype) === null;
367
375
  }
368
-
369
- /** One fact of a thrown value, or nothing when it cannot be read (nothing thrown, a scalar, a throwing accessor). */
370
- private vendorFact(error: unknown, fact: keyof FailureCauseSummary): unknown {
371
- try {
372
- return (error as { [fact: string]: unknown } | null | undefined)?.[fact];
373
- } catch {
374
- return undefined;
375
- }
376
- }
377
376
  }
@@ -0,0 +1,127 @@
1
+ import { ErrorLine, LogLineErrors } from '@proteinjs/logger';
2
+ import { KnexLogValues } from './KnexLogValues';
3
+
4
+ /**
5
+ * A failure as the driver's own line carries it under `cause`: the error's name, the vendor's
6
+ * codes and, as `message`, the driver's sentence — the field a reader of any driver's line parses.
7
+ */
8
+ export type FailureCause = {
9
+ name?: string;
10
+ code?: string;
11
+ errno?: number;
12
+ sqlState?: string;
13
+ message: string;
14
+ /** The server's own message — behind the dev-only values switch, never otherwise. */
15
+ sqlMessage?: string;
16
+ };
17
+
18
+ /**
19
+ * The ONE owner of how a failure of the database reads on a LOG LINE: the vendor's codes and a
20
+ * sentence of the driver's own — never the vendor's text.
21
+ *
22
+ * What the driver THROWS is the vendor's error itself, untouched, and it is not safe to print:
23
+ * the query layer rewrites its `message` to the SQL with every binding INTERPOLATED, the client
24
+ * library carries the same text as `sql`, and the server's own message (`sqlMessage`) quotes the
25
+ * value it refused (`Duplicate entry '<key>' for key 'PRIMARY'`). The driver's own line never
26
+ * carried the first two; a CALLER's line about the error it caught carried all three. So every
27
+ * failure that leaves the driver is marked with the logger (`mark`), which never touches the
28
+ * error; from then on any line about it, the driver's or a caller's, carries the codes and the
29
+ * sentence in place of the error's own text.
30
+ *
31
+ * The vendor's text rides a line only behind the dev-only values switch (KnexLogValues): with
32
+ * both gates open a marked error prints as it is, and `causeOf` adds the server's message.
33
+ * Asked at each line, like the switch itself.
34
+ */
35
+ export class KnexFailureLine {
36
+ private static readonly UNNAMED = 'the database refused the statement';
37
+ private static readonly UNREACHABLE = 'the database could not be reached';
38
+ private static readonly SENTENCES: { [code: string]: string } = {
39
+ ER_DUP_ENTRY: 'a row with that key already exists',
40
+ ER_NO_SUCH_TABLE: 'a table the statement names does not exist',
41
+ ER_BAD_FIELD_ERROR: 'a column the statement names does not exist',
42
+ ER_PARSE_ERROR: 'the statement does not parse',
43
+ ER_LOCK_DEADLOCK: 'the transaction was chosen as a deadlock victim',
44
+ ER_LOCK_WAIT_TIMEOUT: 'a lock wait timed out',
45
+ ER_DATA_TOO_LONG: 'a value is longer than its column',
46
+ ER_TRUNCATED_WRONG_VALUE: 'a value does not convert to the type of its column',
47
+ ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: 'a value does not convert to the type of its column',
48
+ ER_WARN_DATA_OUT_OF_RANGE: 'a value is out of range for its column',
49
+ ER_BAD_NULL_ERROR: 'a column that cannot be null was given null',
50
+ ER_NO_REFERENCED_ROW_2: 'a foreign key refused the statement',
51
+ ER_ROW_IS_REFERENCED_2: 'a foreign key refused the statement',
52
+ ER_ACCESS_DENIED_ERROR: 'the credentials of the caller were not accepted',
53
+ ER_NET_PACKET_TOO_LARGE: 'the statement is larger than the server accepts',
54
+ ECONNREFUSED: KnexFailureLine.UNREACHABLE,
55
+ ECONNRESET: KnexFailureLine.UNREACHABLE,
56
+ ETIMEDOUT: KnexFailureLine.UNREACHABLE,
57
+ PROTOCOL_CONNECTION_LOST: KnexFailureLine.UNREACHABLE,
58
+ };
59
+ /**
60
+ * The failures the query layer raises itself, which carry no vendor code — by the error's name.
61
+ * Its timeout is one error for the statement's operation deadline and for the wait for a free
62
+ * connection; either way it carries the statement's bindings, so it is marked like any other.
63
+ */
64
+ private static readonly SENTENCES_BY_NAME: { [name: string]: string } = {
65
+ KnexTimeoutError: 'the statement or its wait for a connection timed out',
66
+ };
67
+
68
+ /**
69
+ * Marks `error` — whatever the client library or the query layer rejected with — as never
70
+ * printing its own text, and answers the same error. `what` is the driver's words for what
71
+ * failed. An error already marked keeps its line.
72
+ */
73
+ static mark<T>(error: T, what: string): T {
74
+ if (!LogLineErrors.isMarked(error)) {
75
+ LogLineErrors.mark(error, () => (KnexLogValues.enabled() ? undefined : KnexFailureLine.lineOf(error, what)));
76
+ }
77
+ return error;
78
+ }
79
+
80
+ /**
81
+ * The failure as the driver's own line carries it under `cause` — never the query layer's
82
+ * rewritten `message` or `sql`, and the server's own message only behind the values switch.
83
+ * Total: a fact that cannot be read is left out.
84
+ */
85
+ static causeOf(error: unknown): FailureCause {
86
+ const name = KnexFailureLine.vendorFact(error, 'name');
87
+ const code = KnexFailureLine.vendorFact(error, 'code');
88
+ const errno = KnexFailureLine.vendorFact(error, 'errno');
89
+ const sqlState = KnexFailureLine.vendorFact(error, 'sqlState');
90
+ const sqlMessage = KnexLogValues.enabled() ? KnexFailureLine.vendorFact(error, 'sqlMessage') : undefined;
91
+ return {
92
+ ...(typeof name === 'string' ? { name } : {}),
93
+ ...(typeof code === 'string' ? { code } : {}),
94
+ ...(typeof errno === 'number' ? { errno } : {}),
95
+ ...(typeof sqlState === 'string' ? { sqlState } : {}),
96
+ message: KnexFailureLine.sentenceOf(code, name),
97
+ ...(typeof sqlMessage === 'string' ? { sqlMessage } : {}),
98
+ };
99
+ }
100
+
101
+ private static lineOf(error: unknown, what: string): ErrorLine {
102
+ const { name: _name, message, sqlMessage: _sqlMessage, ...codes } = KnexFailureLine.causeOf(error);
103
+ const named = [codes.code, codes.errno !== undefined ? `errno ${codes.errno}` : undefined].filter(Boolean);
104
+ return {
105
+ ...(codes.code !== undefined ? { code: codes.code } : {}),
106
+ sentence: `${what}${named.length ? ` (${named.join(', ')})` : ''}: ${message}`,
107
+ facts: codes,
108
+ };
109
+ }
110
+
111
+ private static sentenceOf(code: unknown, name: unknown): string {
112
+ return (
113
+ (typeof code === 'string' ? KnexFailureLine.SENTENCES[code] : undefined) ??
114
+ (typeof name === 'string' ? KnexFailureLine.SENTENCES_BY_NAME[name] : undefined) ??
115
+ KnexFailureLine.UNNAMED
116
+ );
117
+ }
118
+
119
+ /** One fact of a thrown value, or nothing when it cannot be read (nothing thrown, a scalar, a throwing accessor). */
120
+ private static vendorFact(error: unknown, fact: string): unknown {
121
+ try {
122
+ return (error as { [fact: string]: unknown } | null | undefined)?.[fact];
123
+ } catch {
124
+ return undefined;
125
+ }
126
+ }
127
+ }
@@ -141,12 +141,14 @@ describe('the dev-only values switch: real values ride the driver`s failure line
141
141
  expect(facts(caught)).toEqual(baseline);
142
142
  // The description and the summary ride the line at every gate.
143
143
  expect(failure.obj.params).toEqual([{ type: 'string', length: VALUE.length }, { type: 'number' }]);
144
+ // The server's own message rides the summary only behind the switch.
144
145
  expect(failure.obj.cause).toEqual({
145
146
  name: 'Error',
146
147
  code: 'ER_NO_SUCH_TABLE',
147
148
  errno: 1146,
148
149
  sqlState: '42S02',
149
- sqlMessage: `Table 'test.credential' doesn't exist`,
150
+ message: 'a table the statement names does not exist',
151
+ ...(on ? { sqlMessage: `Table 'test.credential' doesn't exist` } : {}),
150
152
  });
151
153
  if (!on) {
152
154
  for (const log of captured) {