json-rest-api 1.0.22 → 1.0.24

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 (290) hide show
  1. package/CLAUDE.md +1 -2
  2. package/JSKIT_BACKEND_MIGRATION_TRACKER.txt +180 -0
  3. package/README.md +22 -1
  4. package/SINGLE_VALIDATION_CONTRACT_TODO.txt +172 -0
  5. package/docs/API.md +196 -38
  6. package/docs/COMPARISON.md +2 -2
  7. package/docs/GUIDE/GUIDE_1_Initial_Setup.md +111 -5
  8. package/docs/GUIDE/GUIDE_2_2_Manipulating_And_Searching_Tables.md +5 -1
  9. package/docs/GUIDE/GUIDE_2_7_Pagination_And_Ordering.md +3 -1
  10. package/docs/GUIDE/GUIDE_2_8_Effects_of_PUT_and_PATCH.md +12 -60
  11. package/docs/GUIDE/GUIDE_2_Data_And_Relations.md +2 -2
  12. package/docs/GUIDE/GUIDE_3_Field_Transformations.md +5 -1
  13. package/docs/GUIDE/GUIDE_7_Hooks_Data_Management_And_Plugins.md +2 -0
  14. package/docs/GUIDE/GUIDE_X_Autofiltering.md +355 -0
  15. package/docs/GUIDE/GUIDE_X_Fastify.md +78 -0
  16. package/docs/GUIDE/GUIDE_X_Knex_Schema_And_Migrations.md +370 -0
  17. package/docs/GUIDE/GUIDE_X_Query_Projections.md +159 -0
  18. package/docs/GUIDE/GUIDE_X_Writing_Plugins.md +199 -0
  19. package/docs/GUIDE/index.md +18 -9
  20. package/docs/QUICKSTART.md +5 -1
  21. package/docs/index.md +1 -1
  22. package/index.js +3 -2
  23. package/lib/enhanced-logger.js +1 -1
  24. package/package.json +6 -2
  25. package/plugins/core/bulk-operations-plugin.js +26 -34
  26. package/plugins/core/connectors/express-plugin.js +97 -190
  27. package/plugins/core/connectors/fastify-plugin.js +206 -0
  28. package/plugins/core/connectors/lib/busboy-detector.js +4 -4
  29. package/plugins/core/connectors/lib/connector-core.js +195 -0
  30. package/plugins/core/connectors/lib/transport-http-helpers.js +122 -0
  31. package/plugins/core/connectors/lib/transport-route-schemas.js +92 -0
  32. package/plugins/core/lib/anyapi/schema-utils.js +43 -4
  33. package/plugins/core/lib/anyapi/utils/descriptor-helpers.js +4 -1
  34. package/plugins/core/lib/dbIntrospection.js +1078 -0
  35. package/plugins/core/lib/dbTablesOperations.js +1111 -160
  36. package/plugins/core/lib/querying/knex-cross-table-search.js +0 -7
  37. package/plugins/core/lib/querying/knex-json-api-transformers-querying.js +5 -3
  38. package/plugins/core/lib/querying/knex-process-includes.js +3 -4
  39. package/plugins/core/lib/querying/knex-query-helpers.js +21 -76
  40. package/plugins/core/lib/querying/knex-relationship-includes.js +468 -215
  41. package/plugins/core/lib/querying/query-builder-utils.js +19 -0
  42. package/plugins/core/lib/querying/query-field-sort-helpers.js +135 -0
  43. package/plugins/core/lib/querying/sort-helpers.js +33 -0
  44. package/plugins/core/lib/querying/storage-adapter-utils.js +51 -0
  45. package/plugins/core/lib/querying/url-helpers.js +8 -2
  46. package/plugins/core/lib/querying-writing/compile-schemas.js +20 -5
  47. package/plugins/core/lib/querying-writing/knex-field-helpers.js +83 -14
  48. package/plugins/core/lib/querying-writing/knex-json-api-transformers.js +13 -12
  49. package/plugins/core/lib/querying-writing/query-field-helpers.js +88 -0
  50. package/plugins/core/lib/querying-writing/request-contracts.js +590 -0
  51. package/plugins/core/lib/querying-writing/resource-id-normalization.js +131 -0
  52. package/plugins/core/lib/querying-writing/schema-helpers.js +0 -2
  53. package/plugins/core/lib/querying-writing/simplified-helpers.js +4 -11
  54. package/plugins/core/lib/storage/canonical-storage-mapping.js +133 -0
  55. package/plugins/core/lib/storage/storage-adapter.js +82 -4
  56. package/plugins/core/lib/storage/storage-mapping.js +274 -0
  57. package/plugins/core/lib/writing/many-to-many-manipulations.js +4 -2
  58. package/plugins/core/rest-api-anyapi-knex-plugin.js +531 -312
  59. package/plugins/core/rest-api-autofilter-plugin.js +414 -0
  60. package/plugins/core/rest-api-knex-plugin.js +271 -226
  61. package/plugins/core/rest-api-plugin-hooks/register-relationship-routes.js +10 -5
  62. package/plugins/core/rest-api-plugin-hooks/register-scope-routes.js +12 -6
  63. package/plugins/core/rest-api-plugin-hooks/turn-scope-init-into-vars.js +1 -0
  64. package/plugins/core/rest-api-plugin-methods/apply-query-filters.js +41 -0
  65. package/plugins/core/rest-api-plugin-methods/common.js +148 -92
  66. package/plugins/core/rest-api-plugin-methods/delete-relationship.js +11 -2
  67. package/plugins/core/rest-api-plugin-methods/delete.js +6 -1
  68. package/plugins/core/rest-api-plugin-methods/enrich-attributes.js +6 -1
  69. package/plugins/core/rest-api-plugin-methods/get-related.js +7 -2
  70. package/plugins/core/rest-api-plugin-methods/get-relationship.js +7 -2
  71. package/plugins/core/rest-api-plugin-methods/get.js +29 -14
  72. package/plugins/core/rest-api-plugin-methods/patch-relationship.js +10 -3
  73. package/plugins/core/rest-api-plugin-methods/patch.js +56 -12
  74. package/plugins/core/rest-api-plugin-methods/post-relationship.js +11 -2
  75. package/plugins/core/rest-api-plugin-methods/post.js +21 -8
  76. package/plugins/core/rest-api-plugin-methods/put.js +73 -21
  77. package/plugins/core/rest-api-plugin-methods/query.js +15 -53
  78. package/plugins/core/rest-api-plugin-methods/release.js +0 -2
  79. package/plugins/core/rest-api-plugin.js +6 -0
  80. package/plugins/core/rest-api-positioning-plugin.js +2 -5
  81. package/plugins/core/rest-api-query-projections-plugin.js +130 -0
  82. package/plugins/core/socketio-plugin.js +1 -4
  83. package/plugins/storage/local-storage.js +1 -1
  84. package/plugins/storage/s3-storage.js +5 -2
  85. package/quickTest.js +1 -0
  86. package/scripts/run-docs.js +80 -84
  87. package/test-debug.js +1 -1
  88. package/tests/README.md +7 -0
  89. package/tests/anyapi-basic.test.js +3 -0
  90. package/tests/autofilter.test.js +463 -0
  91. package/tests/custom-id-mysql-returning-fallback.test.js +128 -0
  92. package/tests/custom-id-simplified-post.test.js +75 -0
  93. package/tests/custom-idproperty-relationships.test.js +33 -0
  94. package/tests/db-introspection.test.js +521 -0
  95. package/tests/db-table-operations.test.js +786 -0
  96. package/tests/fastify-plugin.test.js +156 -0
  97. package/tests/field-getters.test.js +1 -2
  98. package/tests/field-setters.test.js +0 -4
  99. package/tests/fixtures/api-configs.js +278 -176
  100. package/tests/helpers/fake-fastify.js +99 -0
  101. package/tests/http-connectors-parity.test.js +235 -0
  102. package/tests/id-normalization.test.js +444 -0
  103. package/tests/logical-id-write-validation.test.js +151 -0
  104. package/tests/pagination-cursor-multifield.test.js +11 -11
  105. package/tests/projected-fields.test.js +319 -0
  106. package/tests/relationships.test.js +3 -3
  107. package/tests/searchschema-knex-behavior.test.js +187 -0
  108. package/tests/searchschema-merge.test.js +21 -69
  109. package/tests/storage-mapping.test.js +259 -0
  110. package/audit/00-charter.md +0 -103
  111. package/audit/01-scope-map.md +0 -84
  112. package/audit/02-coverage-matrix.csv +0 -174
  113. package/audit/03-invariants.md +0 -123
  114. package/audit/04-standards-rubric.md +0 -56
  115. package/audit/05-competitor-rubric.md +0 -77
  116. package/audit/06-findings.md +0 -160
  117. package/audit/07-risk-register.csv +0 -10
  118. package/audit/08-remediation-roadmap.md +0 -177
  119. package/audit/09-signoff-check.md +0 -23
  120. package/audit/10-final-synthesis.md +0 -29
  121. package/audit/evidence/code/all-files-json-rest-api.txt +0 -168
  122. package/audit/evidence/code/all-files-json-rest-schema.txt +0 -12
  123. package/audit/evidence/code/boundary-leak-checks.txt +0 -72
  124. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__bulk-operations-plugin.js.txt +0 -480
  125. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__express-plugin.js.txt +0 -532
  126. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__busboy-detector.js.txt +0 -175
  127. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__formidable-detector.js.txt +0 -138
  128. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__connectors__lib__request-helpers.js.txt +0 -222
  129. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__file-handling-plugin.js.txt +0 -342
  130. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__dbTablesOperations.js.txt +0 -304
  131. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__fractional-positioning.js.txt +0 -188
  132. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__compile-schemas.js.txt +0 -336
  133. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__connectors-query-parser.js.txt +0 -165
  134. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__database-capabilities.js.txt +0 -265
  135. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__database-value-normalizers.js.txt +0 -369
  136. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__default-data-helpers.js.txt +0 -72
  137. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__field-utils.js.txt +0 -139
  138. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-constants.js.txt +0 -45
  139. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-field-helpers.js.txt +0 -396
  140. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__knex-json-api-transformers.js.txt +0 -162
  141. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__payload-validators.js.txt +0 -1314
  142. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__schema-helpers.js.txt +0 -488
  143. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__scope-validations.js.txt +0 -484
  144. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying-writing__simplified-helpers.js.txt +0 -857
  145. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-cross-table-search.js.txt +0 -565
  146. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-json-api-transformers-querying.js.txt +0 -485
  147. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-pagination-helpers.js.txt +0 -560
  148. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-process-includes.js.txt +0 -167
  149. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-query-helpers-base.js.txt +0 -109
  150. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-query-helpers.js.txt +0 -1064
  151. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-relationship-includes.js.txt +0 -1983
  152. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__knex-window-queries.js.txt +0 -328
  153. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__querying__url-helpers.js.txt +0 -119
  154. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__storage__storage-adapter.js.txt +0 -160
  155. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__writing__many-to-many-manipulations.js.txt +0 -300
  156. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__lib__writing__relationship-processor.js.txt +0 -245
  157. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-access.js.txt +0 -459
  158. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-cors-plugin.js.txt +0 -237
  159. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-knex-plugin.js.txt +0 -1135
  160. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-multihome-plugin.js.txt +0 -314
  161. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__compile-resource-schemas.js.txt +0 -7
  162. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__register-relationship-routes.js.txt +0 -71
  163. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__register-scope-routes.js.txt +0 -102
  164. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__turn-scope-init-into-vars.js.txt +0 -49
  165. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-hooks__validate-include-configurations.js.txt +0 -39
  166. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__add-route.js.txt +0 -23
  167. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__check-permissions.js.txt +0 -13
  168. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__common.js.txt +0 -639
  169. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__delete-relationship.js.txt +0 -117
  170. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__delete.js.txt +0 -104
  171. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__enrich-attributes.js.txt +0 -199
  172. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get-related.js.txt +0 -353
  173. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get-relationship.js.txt +0 -61
  174. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__get.js.txt +0 -184
  175. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__patch-relationship.js.txt +0 -55
  176. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__patch.js.txt +0 -191
  177. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__post-relationship.js.txt +0 -110
  178. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__post.js.txt +0 -168
  179. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__put.js.txt +0 -253
  180. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__query.js.txt +0 -207
  181. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin-methods__release.js.txt +0 -12
  182. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-plugin.js.txt +0 -165
  183. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__rest-api-positioning-plugin.js.txt +0 -668
  184. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__core__socketio-plugin.js.txt +0 -621
  185. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__storage__local-storage.js.txt +0 -218
  186. package/audit/evidence/code/critical-pass1/json-rest-api__plugins__storage__s3-storage.js.txt +0 -124
  187. package/audit/evidence/code/critical-pass1/json-rest-schema__src__CorePlugin.js.txt +0 -269
  188. package/audit/evidence/code/critical-pass1/json-rest-schema__src__Schema.js.txt +0 -242
  189. package/audit/evidence/code/critical-pass1/json-rest-schema__src__index.js.txt +0 -77
  190. package/audit/evidence/code/critical-pass1-risk-keywords.txt +0 -238
  191. package/audit/evidence/code/critical-pass1-summary.csv +0 -67
  192. package/audit/evidence/code/critical-pass2-summary.csv +0 -67
  193. package/audit/evidence/code/early-silent-zones-no-test-token.txt +0 -57
  194. package/audit/evidence/code/error-model-signals.txt +0 -98
  195. package/audit/evidence/code/git-files-json-rest-api.txt +0 -171
  196. package/audit/evidence/code/git-files-json-rest-schema.txt +0 -27
  197. package/audit/evidence/code/hook-flow-signals.txt +0 -282
  198. package/audit/evidence/code/idproperty-signals.txt +0 -157
  199. package/audit/evidence/code/import-cycles-non-anyapi.txt +0 -3
  200. package/audit/evidence/code/import-hotspots-non-anyapi.txt +0 -96
  201. package/audit/evidence/code/imports-json-rest-api.txt +0 -354
  202. package/audit/evidence/code/imports-json-rest-schema.txt +0 -15
  203. package/audit/evidence/code/in-scope-files-json-rest-api.txt +0 -160
  204. package/audit/evidence/code/in-scope-files-json-rest-schema.txt +0 -13
  205. package/audit/evidence/code/non-anyapi-core-files.txt +0 -101
  206. package/audit/evidence/code/permission-signals.txt +0 -193
  207. package/audit/evidence/code/query-include-signals.txt +0 -687
  208. package/audit/evidence/code/transaction-signals.txt +0 -28
  209. package/audit/evidence/code/validation-signals.txt +0 -650
  210. package/audit/evidence/code/write-path-signals.txt +0 -61
  211. package/audit/evidence/docs/docs-claims-signals.txt +0 -1075
  212. package/audit/evidence/docs/schema-docs-claims-signals.txt +0 -179
  213. package/audit/evidence/external/corpus-freeze.md +0 -21
  214. package/audit/evidence/external/npm-competitor-metadata.txt +0 -70
  215. package/audit/evidence/external/npm-download-signals.txt +0 -23
  216. package/audit/evidence/external/npm-jsonapi-server.txt +0 -8
  217. package/audit/evidence/external/npm-modern-jsonapi-metadata.txt +0 -38
  218. package/audit/evidence/external/readme-fortune-signals.txt +0 -26
  219. package/audit/evidence/external/readme-fortune.md +0 -165
  220. package/audit/evidence/external/readme-json-api-serializer-signals.txt +0 -80
  221. package/audit/evidence/external/readme-json-api-serializer.md +0 -690
  222. package/audit/evidence/external/readme-jsonapi-serde-server-signals.txt +0 -0
  223. package/audit/evidence/external/readme-jsonapi-serde-server.md +0 -22
  224. package/audit/evidence/external/readme-jsonapi-serializer-signals.txt +0 -63
  225. package/audit/evidence/external/readme-jsonapi-serializer.md +0 -315
  226. package/audit/evidence/external/readme-jsonapi-server-signals.txt +0 -19
  227. package/audit/evidence/external/readme-jsonapi-server.md +0 -104
  228. package/audit/evidence/external/readme-nestjs-json-api-signals.txt +0 -4
  229. package/audit/evidence/external/readme-nestjs-json-api.md +0 -94
  230. package/audit/evidence/external/readme-yaser-json-api-nestjs-signals.txt +0 -47
  231. package/audit/evidence/external/readme-yaser-json-api-nestjs.md +0 -447
  232. package/audit/evidence/external/standard-jsonapi-snippets.txt +0 -84
  233. package/audit/evidence/external/standard-rfc-snippets.txt +0 -168
  234. package/audit/evidence/external/standards-sources.txt +0 -6
  235. package/audit/evidence/runtime/baseline-commits.txt +0 -2
  236. package/audit/evidence/runtime/db-adapter-assumptions.txt +0 -3
  237. package/audit/evidence/runtime/environment.txt +0 -4
  238. package/audit/evidence/runtime/invariant-runtime-mapping.md +0 -38
  239. package/audit/evidence/runtime/probe-patch-relationship-error.exitcode +0 -1
  240. package/audit/evidence/runtime/probe-patch-relationship-error.log +0 -76
  241. package/audit/evidence/runtime/probe-patch-relationship-error.mjs +0 -67
  242. package/audit/evidence/runtime/probe-patch-relationship-referenceerror.exitcode +0 -1
  243. package/audit/evidence/runtime/probe-patch-relationship-referenceerror.log +0 -62
  244. package/audit/evidence/runtime/probe-patch-relationship-referenceerror.mjs +0 -47
  245. package/audit/evidence/runtime/test-exitcodes.txt +0 -4
  246. package/audit/evidence/runtime/test-summary.md +0 -107
  247. package/audit/evidence/runtime/trace-anchors.txt +0 -61
  248. package/audit/evidence/tests/access-multitenancy-test-signals.txt +0 -125
  249. package/audit/evidence/tests/failing-tests-summary.txt +0 -25
  250. package/audit/evidence/tests/npm-test-json-rest-api.exitcode +0 -1
  251. package/audit/evidence/tests/npm-test-json-rest-api.log +0 -5885
  252. package/audit/evidence/tests/npm-test-json-rest-schema.exitcode +0 -1
  253. package/audit/evidence/tests/npm-test-json-rest-schema.log +0 -356
  254. package/audit/evidence/tests/query-include-test-signals.txt +0 -948
  255. package/audit/evidence/tests/relationship-test-signals.txt +0 -223
  256. package/audit/evidence/tests/skipped-tests.txt +0 -10
  257. package/audit/evidence/tests/test-suite-list-non-anyapi.txt +0 -30
  258. package/audit/evidence/tests/test-suite-list.txt +0 -32
  259. package/audit/subsystems/docs-drift.md +0 -49
  260. package/audit/subsystems/pass2-cross-review.md +0 -131
  261. package/audit/subsystems/plugins-access.md +0 -51
  262. package/audit/subsystems/plugins-bulk.md +0 -50
  263. package/audit/subsystems/plugins-cors.md +0 -48
  264. package/audit/subsystems/plugins-file.md +0 -53
  265. package/audit/subsystems/plugins-multihome.md +0 -50
  266. package/audit/subsystems/plugins-positioning.md +0 -54
  267. package/audit/subsystems/plugins-socketio.md +0 -50
  268. package/audit/subsystems/query-engine.md +0 -61
  269. package/audit/subsystems/relationships.md +0 -55
  270. package/audit/subsystems/rest-orchestration.md +0 -66
  271. package/audit/subsystems/schema-core.md +0 -64
  272. package/audit/subsystems/storage-knex.md +0 -57
  273. package/audit/subsystems/tests.md +0 -48
  274. package/audit/subsystems/transport-express.md +0 -55
  275. package/audit/traces/trace-read-get.md +0 -22
  276. package/audit/traces/trace-read-query.md +0 -25
  277. package/audit/traces/trace-relationship-endpoints.md +0 -31
  278. package/audit/traces/trace-write-delete.md +0 -17
  279. package/audit/traces/trace-write-patch.md +0 -26
  280. package/audit/traces/trace-write-post.md +0 -22
  281. package/audit/traces/trace-write-put.md +0 -23
  282. package/docs/GUIDE/GUIDE_4_Authentication_And_Permissions.md +0 -707
  283. package/docs/GUIDE/GUIDE_X_Multihome.md +0 -666
  284. package/plugins/core/lib/querying-writing/payload-validators.js +0 -1314
  285. package/plugins/core/rest-api-access.js +0 -459
  286. package/plugins/core/rest-api-multihome-plugin.js +0 -314
  287. package/tests/multihome.test.js +0 -553
  288. package/tests/multihome.test.js.bak +0 -550
  289. package/tests/ownership-optout.test.js +0 -76
  290. package/tests/rest-api-access.test.js +0 -206
@@ -1,53 +0,0 @@
1
- # Subsystem: plugins-file (Pass 1)
2
-
3
- ## Scope
4
- - File handling plugin + storage backends (`local-storage`, `s3-storage`) + transport detector integration.
5
-
6
- ## Purpose
7
- - Detect multipart/file uploads, validate schema-declared file constraints, upload via configured storage backend, and merge resulting URLs into write payloads.
8
-
9
- ## Key entry points
10
- - `plugins/core/file-handling-plugin.js`
11
- - `plugins/storage/local-storage.js`
12
- - `plugins/storage/s3-storage.js`
13
- - `plugins/core/connectors/lib/{busboy-detector,formidable-detector}.js`
14
-
15
- ## Core data flow
16
- - Walkthrough (POST with file):
17
- - [Verified][C5] `beforeProcessing` hook detects file-capable scope, runs detector registry, validates mime/size, uploads, then mutates `params.inputRecord.data.attributes` with stored value(s). Evidence: `file-handling-plugin.js:112-275`, `280-292`.
18
-
19
- ## Hook/control flow
20
- - [Verified][C4] Detectors are transport-registered and protocol-agnostic via `api.rest.registerFileDetector`.
21
-
22
- ## Failure modes
23
- - [Verified][C4] Upload failure throws validation error and attempts temp-file cleanup; cleanup failures only logged. Evidence: `file-handling-plugin.js:224-248`, `266-273`.
24
- - [Inferred][C3] No built-in transactional compensation for already-uploaded files if DB write later fails; rollback of storage side effects depends on custom hooks/backends.
25
-
26
- ## Strengths
27
- - [Verified][C4] Schema-driven file field detection avoids hardcoded upload logic.
28
- - [Verified][C4] Required file checks handled both no-detector and missing-field cases.
29
-
30
- ## Risks
31
- - R-FILE-001:
32
- - [Inferred][C3] Potential orphaned files on downstream write rollback.
33
- - R-FILE-002:
34
- - [Unknown][C2] Large concurrent upload pressure not benchmarked.
35
-
36
- ## Missing tests
37
- - [Inferred][C3] Add test that simulates upload success + DB failure to verify cleanup/compensation strategy.
38
-
39
- ## Explicit unknowns
40
- - [Unknown][C2] Backend-specific consistency guarantees for S3/local under partial failures.
41
-
42
- ## Pass-1 confidence
43
- - Overall: **C3-C4**.
44
-
45
- ## Evidence links
46
- - `plugins/core/file-handling-plugin.js`
47
- - `plugins/storage/local-storage.js`
48
- - `plugins/storage/s3-storage.js`
49
- - `docs/mini-guides/file-uploads-complete.md`
50
-
51
- ## Pass-2 cross-review status
52
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
53
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,50 +0,0 @@
1
- # Subsystem: plugins-multihome (Pass 1)
2
-
3
- ## Scope
4
- - Multi-tenant extraction/filter/enforcement plugin.
5
-
6
- ## Purpose
7
- - Enforce tenant isolation by attaching tenant context, filtering queries, setting tenant field on writes, and checking ownership on single-resource operations.
8
-
9
- ## Key entry points
10
- - `plugins/core/rest-api-multihome-plugin.js`
11
-
12
- ## Core data flow
13
- - Walkthrough (tenant-scoped query + write):
14
- - [Verified][C5] `transport:request` extracts tenant ID into `context.auth.multihome_id`. Evidence: `rest-api-multihome-plugin.js:65-84`.
15
- - [Verified][C5] `knexQueryFiltering` adds tenant where clause for eligible scopes. Evidence: `rest-api-multihome-plugin.js:112-179`.
16
- - [Verified][C4] `beforeSchemaValidate` enforces/sets tenant field on writes. Evidence: `rest-api-multihome-plugin.js:182-228`.
17
-
18
- ## Hook/control flow
19
- - [Verified][C4] `checkPermissions` hook validates tenant ownership of `minimalRecord` for existing-resource operations. Evidence: `rest-api-multihome-plugin.js:232-287`.
20
-
21
- ## Failure modes
22
- - [Verified][C4] For tenant mismatch, plugin throws generic errors with custom codes (`REST_API_RESOURCE` / `REST_API_FORBIDDEN`) instead of typed `RestApiResourceError`; transport mapping may produce non-uniform envelope semantics. Evidence: `rest-api-multihome-plugin.js:274-284`, `express-plugin.js:236-266`.
23
-
24
- ## Strengths
25
- - [Verified][C5] Defense-in-depth: both query-time filtering and single-record permission checks.
26
- - [Verified][C4] Explicit handling for excluded resources and missing-tenant policy toggles.
27
-
28
- ## Risks
29
- - R-MULTI-001:
30
- - [Inferred][C3] Error typing inconsistency can alter client-observed semantics across connectors.
31
- - R-MULTI-002:
32
- - [Unknown][C2] Dependence on extractor correctness (subdomain/header) may cause tenant mis-assignment if upstream proxy headers are untrusted.
33
-
34
- ## Missing tests
35
- - [Inferred][C3] Add negative tests for malformed forwarded host/header extraction and spoofing scenarios.
36
-
37
- ## Explicit unknowns
38
- - [Unknown][C2] Full trust-boundary hardening at edge proxy layer is not inspectable from this repo alone.
39
-
40
- ## Pass-1 confidence
41
- - Overall: **C4**.
42
-
43
- ## Evidence links
44
- - `plugins/core/rest-api-multihome-plugin.js`
45
- - `tests/multihome.test.js`
46
- - `audit/evidence/tests/access-multitenancy-test-signals.txt`
47
-
48
- ## Pass-2 cross-review status
49
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
50
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,54 +0,0 @@
1
- # Subsystem: plugins-positioning (Pass 1)
2
-
3
- ## Scope
4
- - Fractional positioning plugin and helper math.
5
-
6
- ## Purpose
7
- - Compute and persist sortable position values with optional group filters and `beforeId` insertion semantics.
8
-
9
- ## Key entry points
10
- - `plugins/core/rest-api-positioning-plugin.js`
11
- - `plugins/core/lib/fractional-positioning.js`
12
-
13
- ## Core data flow
14
- - Walkthrough (PATCH with `beforeId`):
15
- - [Verified][C4] `beforeSchemaValidate` strips `beforeId` and managed `position` from client payload, storing intent in context. Evidence: `rest-api-positioning-plugin.js:257-323`.
16
- - [Verified][C4] `beforeDataCallPatch` computes target position using grouped query and writes computed position into `context.inputRecord.data.attributes` before storage update. Evidence: `rest-api-positioning-plugin.js:339-345`, `347-545`.
17
-
18
- ## Hook/control flow
19
- - [Verified][C4] Uses method-specific `beforeDataCall*` hooks, plus optional query-sort default hook (`beforeQuery`). Evidence: `rest-api-positioning-plugin.js:326-345`, `574-589`.
20
-
21
- ## Failure modes
22
- - [Inferred][C3] Concurrent reordering operations can still race without explicit row locking; final ordering correctness depends on DB isolation and retry strategy.
23
- - [Verified][C3] Index creation best-effort errors are downgraded to warnings, which can hide performance regressions. Evidence: `rest-api-positioning-plugin.js:251-253`.
24
-
25
- ## Strengths
26
- - [Verified][C4] Adapter-aware filter-to-column translation and scoped grouping logic.
27
- - [Verified][C4] Prevents direct client overwrite of managed position field.
28
-
29
- ## Risks
30
- - R-POS-001:
31
- - [Inferred][C3] Concurrency ordering race risk under heavy writes.
32
- - R-POS-002:
33
- - [Inferred][C3] Silent index-create failure can degrade query/update performance.
34
-
35
- ## Missing tests
36
- - [Inferred][C3] Add concurrent reorder tests (same group, multiple writers).
37
- - [Unknown][C2] No observed tests for index-creation fallback path.
38
-
39
- ## Explicit unknowns
40
- - [Unknown][C2] Long-term rebalance behavior once `rebalanceThreshold` is exceeded.
41
-
42
- ## Pass-1 confidence
43
- - Overall: **C3-C4**.
44
-
45
- ## Evidence links
46
- - `plugins/core/rest-api-positioning-plugin.js`
47
- - `plugins/core/lib/fractional-positioning.js`
48
- - `tests/positioning.test.js`
49
- - `tests/positioning-advanced.test.js`
50
- - `tests/positioning-extended.test.js`
51
-
52
- ## Pass-2 cross-review status
53
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
54
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,50 +0,0 @@
1
- # Subsystem: plugins-socketio (Pass 1)
2
-
3
- ## Scope
4
- - Socket.IO realtime subscription and broadcast plugin.
5
-
6
- ## Purpose
7
- - Allow clients to subscribe to resource updates with filter validation and emit events after successful write lifecycles.
8
-
9
- ## Key entry points
10
- - `plugins/core/socketio-plugin.js`
11
-
12
- ## Core data flow
13
- - Walkthrough (write -> broadcast):
14
- - [Verified][C4] `finish` hook queues broadcasts when a transaction exists; `afterCommit` flushes; `afterRollback` drops pending messages. Evidence: `socketio-plugin.js:576-619`.
15
- - [Verified][C4] Subscription registration validates resource existence, query permission, filter schema, include/fields shape, then joins room. Evidence: `socketio-plugin.js:161-288`.
16
-
17
- ## Hook/control flow
18
- - [Verified][C4] Broadcast filtering uses `searchSchemaStructure` and `matchesFilters` against minimal record context.
19
-
20
- ## Failure modes
21
- - [Inferred][C3] If `minimalRecord` lacks attributes needed for subscription filters, updates may be under/over-delivered depending on filter type.
22
- - [Unknown][C2] Backpressure and memory behavior under very high subscription fanout not verified.
23
-
24
- ## Strengths
25
- - [Verified][C4] Commit-aware broadcast deferral avoids notifying on rolled-back mutations.
26
- - [Verified][C4] Optional Redis adapter support for horizontal scaling.
27
-
28
- ## Risks
29
- - R-SOCKET-001:
30
- - [Inferred][C3] Filter evaluation fidelity depends on minimal record shape.
31
- - R-SOCKET-002:
32
- - [Unknown][C2] Throughput limits and queue growth under load.
33
-
34
- ## Missing tests
35
- - [Inferred][C3] Add explicit tests for afterRollback suppression and post-commit-only delivery with failing writes.
36
- - [Unknown][C2] Load/fanout tests absent.
37
-
38
- ## Explicit unknowns
39
- - [Unknown][C2] Ordering guarantees across clustered deployments with Redis adapter under network partitions.
40
-
41
- ## Pass-1 confidence
42
- - Overall: **C3-C4**.
43
-
44
- ## Evidence links
45
- - `plugins/core/socketio-plugin.js`
46
- - `tests/socketio.test.js`
47
-
48
- ## Pass-2 cross-review status
49
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
50
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,61 +0,0 @@
1
- # Subsystem: query-engine (Pass 1)
2
-
3
- ## Scope
4
- - Query parsing, filtering, sorting, pagination, include loading, and response shaping.
5
- - Exclusion: anyapi-only query branches.
6
-
7
- ## Purpose
8
- - Implement JSON:API-style collection/single retrieval with filters, sparse fieldsets, includes, and pagination.
9
-
10
- ## Key entry points
11
- - `plugins/core/rest-api-plugin-methods/query.js`
12
- - `plugins/core/lib/querying-writing/payload-validators.js`
13
- - `plugins/core/lib/querying/knex-query-helpers.js`
14
- - `plugins/core/lib/querying/knex-relationship-includes.js`
15
- - `plugins/core/lib/querying-writing/knex-field-helpers.js`
16
- - `plugins/core/lib/querying-writing/connectors-query-parser.js`
17
-
18
- ## Core data flow
19
- - Walkthrough (query + include):
20
- - [Verified][C5] Query payload parsed/validated, then permission gate runs before `helpers.dataQuery`. Evidence: `query.js:75-137`.
21
- - [Verified][C5] `dataQuery` builds field selection, runs filter hooks, applies sort/pagination, then relationship identifiers/includes and JSON:API transformation. Evidence: `rest-api-knex-plugin.js:448-880`.
22
- - [Verified][C4] Include engine batches by relationship type and parent IDs (not per-record) for standard hasMany/manyToMany identifier loading. Evidence: `knex-relationship-includes.js:595-625`, `1876-1903`, `1925-1927`.
23
-
24
- ## Hook/control flow
25
- - [Verified][C4] Filtering hook chain order is explicit: polymorphic -> cross-table -> basic. Evidence: `rest-api-knex-plugin.js:152-163` and hook helper docs in `knex-query-helpers.js`.
26
-
27
- ## Failure modes
28
- - [Verified][C4] Unknown sparse fields throw hard errors; hidden fields are suppressed even if requested. Evidence: `knex-field-helpers.js:203`, `209-214`.
29
- - [Inferred][C3] Include recursion still risks high query volume at deep nesting despite per-layer batching; worst-case behavior depends on relationship fanout. Evidence: `knex-relationship-includes.js:1598-1727`.
30
- - [Inferred][C3] Query string generation may produce duplicated delimiters (`&&`) in some link paths (doc examples show this pattern), creating cosmetic interoperability risk.
31
-
32
- ## Strengths
33
- - [Verified][C5] Strong validation on include depth, sort whitelist, page param types.
34
- - [Verified][C4] `idProperty` handling is deeply integrated in selection, includes, and pagination cursor construction.
35
-
36
- ## Risks
37
- - R-QUERY-001:
38
- - [Inferred][C3] Potential performance cliff on deep includes with high cardinality.
39
- - R-QUERY-002:
40
- - [Unknown][C2] Window-strategy fallback behavior across all supported SQL dialects not yet runtime-confirmed.
41
-
42
- ## Missing tests
43
- - [Inferred][C3] Expand high-cardinality include tests with explicit query-count assertions.
44
- - [Verified][C4] Some multi-field cursor cases are skipped in suite (`pagination-cursor-multifield.test.js` has skipped tests).
45
-
46
- ## Explicit unknowns
47
- - [Unknown][C2] Practical N+1 envelope under production dataset shape.
48
-
49
- ## Pass-1 confidence
50
- - Overall: **C4** on correctness path; **C2-C3** on large-scale performance bounds.
51
-
52
- ## Evidence links
53
- - `plugins/core/rest-api-plugin-methods/query.js`
54
- - `plugins/core/lib/querying/knex-relationship-includes.js`
55
- - `plugins/core/lib/querying-writing/knex-field-helpers.js`
56
- - `audit/evidence/code/query-include-signals.txt`
57
- - `audit/evidence/tests/query-include-test-signals.txt`
58
-
59
- ## Pass-2 cross-review status
60
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
61
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,55 +0,0 @@
1
- # Subsystem: relationships (Pass 1)
2
-
3
- ## Scope
4
- - Relationship read/write methods and relationship processing helpers.
5
- - Exclusion: anyapi-specific link backends.
6
-
7
- ## Purpose
8
- - Keep relationship semantics consistent across `POST/PUT/PATCH` resource writes and explicit relationship endpoints.
9
-
10
- ## Key entry points
11
- - `plugins/core/rest-api-plugin-methods/{get-related,get-relationship,post-relationship,patch-relationship,delete-relationship}.js`
12
- - `plugins/core/lib/writing/{relationship-processor,many-to-many-manipulations}.js`
13
-
14
- ## Core data flow
15
- - Walkthrough (PATCH relationship endpoint):
16
- - [Verified][C4] `patchRelationship` proxies to scope `patch` with synthesized `inputRecord.data.relationships`. Evidence: `patch-relationship.js:27-42`.
17
- - [Verified][C5] Resource-level `patch` then executes standard validation, permission checks, storage update, and relationship synchronization. Evidence: `patch.js:58-165`.
18
-
19
- ## Hook/control flow
20
- - [Verified][C4] Relationship endpoint methods run `checkPermissions` and endpoint-specific hook suffixes before mutation. Evidence: `post-relationship.js:49-52`, `delete-relationship.js:47-49`, `patch-relationship.js:24-25`.
21
-
22
- ## Failure modes
23
- - [Verified][C5] `patch-relationship` error handling defect (undefined symbol path) can break rollback hook execution on failures. Evidence: `patch-relationship.js:52-54`, `common.js:210-215`.
24
- - [Inferred][C3] `getRelated` many-to-many fallback may degrade to multiple GET calls when included resources are absent, increasing latency with many IDs. Evidence: `get-related.js:306-341`.
25
-
26
- ## Strengths
27
- - [Verified][C5] Relationship processor cleanly separates belongsTo updates, polymorphic writes, and many-to-many pivot sync list generation.
28
- - [Verified][C4] Many-to-many sync logic preserves existing pivot records where possible (`updateManyToManyRelationship`).
29
-
30
- ## Risks
31
- - R-REL-001:
32
- - [Verified][C5] Relationship PATCH error-path reliability defect.
33
- - R-REL-002:
34
- - [Inferred][C3] High cardinality many-to-many read paths can incur extra per-id lookups in fallback branch.
35
-
36
- ## Missing tests
37
- - [Inferred][C4] Add explicit failure-path tests for relationship endpoint transaction rollback + hook behavior.
38
- - [Unknown][C2] Add stress test for many-to-many fallback retrieval volume.
39
-
40
- ## Explicit unknowns
41
- - [Unknown][C2] Exact behavior parity between relationship endpoints and base methods under all plugin combinations is not fully runtime-proven yet.
42
-
43
- ## Pass-1 confidence
44
- - Overall: **C4**.
45
-
46
- ## Evidence links
47
- - `plugins/core/rest-api-plugin-methods/patch-relationship.js`
48
- - `plugins/core/rest-api-plugin-methods/get-related.js`
49
- - `plugins/core/lib/writing/relationship-processor.js`
50
- - `plugins/core/lib/writing/many-to-many-manipulations.js`
51
- - `audit/evidence/tests/relationship-test-signals.txt`
52
-
53
- ## Pass-2 cross-review status
54
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
55
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,66 +0,0 @@
1
- # Subsystem: rest-orchestration (Pass 1)
2
-
3
- ## Scope
4
- - Core REST method orchestration and shared method helpers.
5
- - Exclusion: anyapi-specific branches are not evaluated.
6
-
7
- ## Purpose
8
- - Normalize request context, enforce payload/permission contract ordering, route to storage helpers, and apply hook lifecycle around CRUD and relationship operations.
9
-
10
- ## Key entry points
11
- - `plugins/core/rest-api-plugin.js`
12
- - `plugins/core/rest-api-plugin-methods/{query,get,post,put,patch,delete}.js`
13
- - `plugins/core/rest-api-plugin-methods/{post-relationship,patch-relationship,delete-relationship,get-related,get-relationship}.js`
14
- - `plugins/core/rest-api-plugin-methods/common.js`
15
- - `plugins/core/rest-api-plugin-hooks/{register-scope-routes,register-relationship-routes}.js`
16
-
17
- ## Core data flow
18
- - Walkthrough (write path: POST/PUT/PATCH):
19
- - [Verified][C5] `setupCommonRequest` establishes `context.inputRecord`, schema shortcuts, transaction, type/ID consistency checks. Evidence: `common.js:54-197`.
20
- - [Verified][C5] Write methods call validation and relationship access checks before `helpers.dataPost/dataPut/dataPatch`. Evidence: `post.js:53-121`, `put.js:57-194`, `patch.js:58-134`.
21
- - [Verified][C5] Permission gate executes before irreversible storage operation (`scope.checkPermissions` before `beforeDataCall` + data helper). Evidence: `post.js:97-121`, `put.js:170-194`, `patch.js:102-134`, `delete.js:67-84`.
22
-
23
- ## Hook/control flow
24
- - [Verified][C5] Standardized lifecycle hooks exist for pre-processing, schema validation, data call, finish, commit/rollback handling. Evidence: `common.js:285-410`, methods throughout.
25
- - [Verified][C4] Relationship routes map explicitly to dedicated methods and reuse shared checks. Evidence: `register-relationship-routes.js:33-68`.
26
-
27
- ## Failure modes
28
- - [Verified][C5] **Concrete defect**: `patch-relationship` catch block calls `handleWriteMethodError` and `log` without import/parameter wiring, likely causing `ReferenceError` and masking original failures.
29
- - Evidence: `patch-relationship.js:52-54`; compare correct pattern in `post-relationship.js:1-3,15,107-109` and `delete-relationship.js:1-3,14,114-116`.
30
- - [Inferred][C4] Error-path rollback semantics in `patch-relationship` are unreliable because missing `runHooks` argument to `handleWriteMethodError` would break `afterRollback` hook even if symbol existed. Evidence: `common.js:210-215`, `patch-relationship.js:53`.
31
-
32
- ## Strengths
33
- - [Verified][C5] Clear centralization of cross-cutting behavior in `common.js`.
34
- - [Verified][C4] Consistent permission placement before storage write calls.
35
- - [Verified][C4] Route registration is explicit and auditable.
36
-
37
- ## Risks
38
- - R-REST-001:
39
- - [Verified][C5] Relationship PATCH error-path defect (undefined symbol path).
40
- - Impact: high (error handling reliability, rollback hooks).
41
- - R-REST-002:
42
- - [Inferred][C3] Route handler/context shaping differences between scope routes and relationship routes can create subtle transport-level behavior drift.
43
- - Evidence: `register-scope-routes.js:10-53` vs `register-relationship-routes.js:10-30`.
44
-
45
- ## Missing tests
46
- - [Inferred][C4] Add targeted failure-path tests for `PATCH /relationships/*` with forced storage errors to verify rollback + error envelope.
47
- - [Unknown][C2] No direct test evidence yet for all hook lifecycle transitions under nested transaction reuse.
48
-
49
- ## Explicit unknowns
50
- - [Unknown][C2] Whether plugin hooks depend on currently missing rollback hook in relationship PATCH path.
51
-
52
- ## Pass-1 confidence
53
- - Overall: **C4**.
54
-
55
- ## Evidence links
56
- - `plugins/core/rest-api-plugin.js`
57
- - `plugins/core/rest-api-plugin-methods/common.js`
58
- - `plugins/core/rest-api-plugin-methods/patch-relationship.js`
59
- - `plugins/core/rest-api-plugin-methods/post-relationship.js`
60
- - `plugins/core/rest-api-plugin-methods/delete-relationship.js`
61
- - `plugins/core/rest-api-plugin-hooks/register-scope-routes.js`
62
- - `plugins/core/rest-api-plugin-hooks/register-relationship-routes.js`
63
-
64
- ## Pass-2 cross-review status
65
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
66
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,64 +0,0 @@
1
- # Subsystem: schema-core (Pass 1)
2
-
3
- ## Scope
4
- - Repositories: `json-rest-schema` + schema compilation path in `json-rest-api`.
5
- - Exclusion: anyapi internals are out of scope.
6
-
7
- ## Purpose
8
- - Compile and enforce schema contracts (types, validators, relationships, getter/setter/computed metadata) before runtime read/write paths.
9
-
10
- ## Key entry points
11
- - `json-rest-schema/src/index.js`
12
- - `json-rest-schema/src/Schema.js`
13
- - `json-rest-schema/src/CorePlugin.js`
14
- - `plugins/core/lib/querying-writing/compile-schemas.js`
15
- - `plugins/core/rest-api-plugin-hooks/compile-resource-schemas.js`
16
-
17
- ## Core data flow
18
- - Walkthrough (resource registration path):
19
- - [Verified][C5] `scope:added -> compileResourceSchemas -> compileSchemas` builds `scope.vars.schemaInfo` once per scope. Evidence: `plugins/core/rest-api-plugin.js:117-120`, `plugins/core/rest-api-plugin-hooks/compile-resource-schemas.js:3-6`, `plugins/core/lib/querying-writing/compile-schemas.js:124-335`.
20
- - [Verified][C5] `compileSchemas` separates computed fields, enriches belongsTo types, builds validation schema and search schema, then caches `schemaInfo` with `schemaStructure`, `searchSchemaStructure`, `schemaRelationships`, `idProperty`, getters/setters metadata. Evidence: `compile-schemas.js:132-335`.
21
- - [Verified][C5] `Schema.validate()` in `json-rest-schema` enforces unknown-field errors, per-field cast/validator pipeline, and default/null completion behavior for full validation. Evidence: `/home/merc/Development/current/json-rest-schema/src/Schema.js:177-225`.
22
-
23
- ## Hook/control flow
24
- - [Verified][C4] Schema enrichment hooks are first-class (`schema:enrich`, `searchSchema:enrich`), allowing plugin extensions before schema instances are finalized. Evidence: `compile-schemas.js:183-190`, `217-224`.
25
- - [Verified][C4] Relationship definitions for runtime include both explicit `scopeOptions.relationships` and schema-derived belongsTo metadata checks. Evidence: `compile-schemas.js:231-244`.
26
-
27
- ## Failure modes
28
- - [Verified][C5] Invalid schema config fails fast at scope-add time (missing `as` on belongsTo, invalid getter/setter dependencies, invalid computed definition). Evidence: `compile-schemas.js:142-148`, `237-242`, `260-315`.
29
- - [Inferred][C3] Global mutable registries in `json-rest-schema` (`globalTypes`, `globalValidators`) can create cross-test/plugin coupling if mutated dynamically after schema creation order changes. Evidence: `/home/merc/Development/current/json-rest-schema/src/index.js:13-43`, `64-74`.
30
-
31
- ## Strengths
32
- - [Verified][C5] Clear separation between schema compile phase and request execution phase.
33
- - [Verified][C4] Search schema auto-generation and index intent (`ensureSearchFieldsAreIndexed`) are centralized.
34
- - [Verified][C4] Getter/setter dependency ordering provides deterministic execution semantics.
35
-
36
- ## Risks
37
- - R-SCHEMA-001:
38
- - [Inferred][C3] Global registry mutation risk in long-lived process/plugin hot-load scenarios.
39
- - Impact: medium; can create non-local behavior shifts.
40
- - Evidence: `/home/merc/Development/current/json-rest-schema/src/index.js:13-43`.
41
- - R-SCHEMA-002:
42
- - [Unknown][C2] No direct benchmark evidence yet for schema validation overhead under high-field payloads.
43
-
44
- ## Missing tests
45
- - [Unknown][C2] No explicit concurrency/ordering tests found for dynamic plugin registration in `json-rest-schema`.
46
- - [Inferred][C3] Add tests for `schema:enrich` + `searchSchema:enrich` conflict resolution ordering.
47
-
48
- ## Explicit unknowns
49
- - [Unknown][C2] Runtime memory growth profile with many scopes and large computed dependency graphs.
50
- - [Unknown][C2] Backward-compatibility expectations for runtime mutation of global validators/types.
51
-
52
- ## Pass-1 confidence
53
- - Overall: **C4 (high)** for correctness of structural claims, **C2-C3** for performance/operational unknowns.
54
-
55
- ## Evidence links
56
- - `audit/evidence/code/import-hotspots-non-anyapi.txt`
57
- - `plugins/core/lib/querying-writing/compile-schemas.js`
58
- - `/home/merc/Development/current/json-rest-schema/src/Schema.js`
59
- - `/home/merc/Development/current/json-rest-schema/src/index.js`
60
- - `/home/merc/Development/current/json-rest-schema/src/CorePlugin.js`
61
-
62
- ## Pass-2 cross-review status
63
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
64
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,57 +0,0 @@
1
- # Subsystem: storage-knex (Pass 1)
2
-
3
- ## Scope
4
- - Knex-backed storage helpers and storage adapter abstraction.
5
- - Exclusion: anyapi-specific storage paths.
6
-
7
- ## Purpose
8
- - Provide database CRUD primitives used by REST methods, including adapter translation hooks and query construction support.
9
-
10
- ## Key entry points
11
- - `plugins/core/rest-api-knex-plugin.js`
12
- - `plugins/core/lib/storage/storage-adapter.js`
13
- - `plugins/core/lib/querying-writing/{database-value-normalizers,compile-schemas,knex-json-api-transformers}.js`
14
- - `plugins/core/lib/querying-writing/{field-utils,schema-helpers,database-capabilities,knex-field-helpers}.js`
15
-
16
- ## Core data flow
17
- - Walkthrough (PATCH):
18
- - [Verified][C5] Method layer provides transaction in `context.db`; storage helper checks existence then applies merged attributes/relationship FK updates and strips non-db fields. Evidence: `patch.js:116-134`, `rest-api-knex-plugin.js:1030-1078`.
19
- - [Verified][C5] Adapter abstraction translates columns/values and applies base resource scope when canonical adapter is used. Evidence: `storage-adapter.js:25-49`, `68-147`.
20
-
21
- ## Hook/control flow
22
- - [Verified][C4] Query filtering hooks are invoked by dataQuery/countQuery via `context.knexQuery` handoff to hook chain. Evidence: `rest-api-knex-plugin.js:491-507`, `787-804`.
23
- - [Verified][C4] `helpers.newTransaction` is exposed and used by method layer for managed transactions. Evidence: `rest-api-knex-plugin.js:213-215`, `common.js:126-130`.
24
-
25
- ## Failure modes
26
- - [Verified][C4] `dataPut` performs create/update branching and duplicate existence checks; race between existence check and write is possible without higher isolation/constraints. Evidence: `rest-api-knex-plugin.js:974-1007`.
27
- - [Inferred][C3] Error semantics depend heavily on upstream method orchestration; storage helpers do not independently enforce permission ordering.
28
-
29
- ## Strengths
30
- - [Verified][C5] Clear separation between orchestration and storage implementation.
31
- - [Verified][C4] `idProperty` handling is consistently aliased/selectable across get/query/write helpers.
32
-
33
- ## Risks
34
- - R-STORAGE-001:
35
- - [Inferred][C3] Possible TOCTOU edge on update/delete existence checks under concurrent writers.
36
- - R-STORAGE-002:
37
- - [Unknown][C2] No explicit retry/backoff strategy for transient DB faults.
38
-
39
- ## Missing tests
40
- - [Inferred][C3] Add concurrency tests for PUT/PATCH/DELETE conflict windows.
41
- - [Unknown][C2] Add tests for adapter translation edge cases across all relationship filter forms.
42
-
43
- ## Explicit unknowns
44
- - [Unknown][C2] Real DB behavior variance (SQLite vs Postgres vs MySQL) for returning/locking paths is not yet runtime-verified.
45
-
46
- ## Pass-1 confidence
47
- - Overall: **C4** for structure/call order; **C2-C3** for concurrency behavior.
48
-
49
- ## Evidence links
50
- - `plugins/core/rest-api-knex-plugin.js`
51
- - `plugins/core/lib/storage/storage-adapter.js`
52
- - `audit/evidence/code/transaction-signals.txt`
53
- - `audit/evidence/code/idproperty-signals.txt`
54
-
55
- ## Pass-2 cross-review status
56
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
57
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,48 +0,0 @@
1
- # Subsystem: tests (Pass 1)
2
-
3
- ## Scope
4
- - Test suite structure and invariant coverage signal (excluding anyapi tests).
5
-
6
- ## Purpose
7
- - Provide confidence on correctness/regression resistance for critical behaviors.
8
-
9
- ## Inventory signal
10
- - [Verified][C5] Non-anyapi test files: 30 (`tests/*.test.js` excluding anyapi). Evidence: `audit/evidence/tests/test-suite-list-non-anyapi.txt`.
11
- - [Verified][C5] Skipped tests: 10, all in multi-field cursor pagination suite. Evidence: `audit/evidence/tests/skipped-tests.txt`.
12
-
13
- ## Coverage strengths
14
- - [Verified][C4] Relationship semantics have dedicated suites (`relationships`, `relationship-endpoints`, custom idProperty relationship tests).
15
- - [Verified][C4] Plugin-focused suites exist for access, CORS, multihome, positioning, socketio, bulk.
16
- - [Verified][C4] Include depth and sparse-field interactions are tested.
17
-
18
- ## Coverage gaps
19
- - [Inferred][C4] Critical cursor edge cases are deferred via skipped tests, lowering confidence for pagination invariants under complex sort tuples.
20
- - [Inferred][C3] Limited explicit failure-path assertions for rollback hooks (especially relationship PATCH defect path) found in static scan.
21
- - [Unknown][C2] Query-count/N+1 guard tests are not evident from static test names/signals.
22
-
23
- ## Risks
24
- - R-TEST-001:
25
- - [Verified][C4] Skipped pagination tests leave known edge space unverified.
26
- - R-TEST-002:
27
- - [Inferred][C3] Runtime invariants may be indirectly covered but not explicitly mapped per invariant ID.
28
-
29
- ## Missing tests
30
- - [Inferred][C4] Add targeted regression for `patch-relationship` error path (undefined handler/log).
31
- - [Inferred][C3] Add explicit N+1/query-count budget tests for representative include graphs.
32
- - [Inferred][C3] Add rollback + afterRollback hook assertions across all relationship endpoint mutations.
33
-
34
- ## Explicit unknowns
35
- - [Unknown][C2] Current CI timing/flakiness profile (not observed yet; runtime run pending).
36
-
37
- ## Pass-1 confidence
38
- - Overall: **C3-C4** (good breadth, specific deep-edge gaps).
39
-
40
- ## Evidence links
41
- - `audit/evidence/tests/test-suite-list-non-anyapi.txt`
42
- - `audit/evidence/tests/skipped-tests.txt`
43
- - `audit/evidence/tests/relationship-test-signals.txt`
44
- - `audit/evidence/tests/query-include-test-signals.txt`
45
-
46
- ## Pass-2 cross-review status
47
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
48
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,55 +0,0 @@
1
- # Subsystem: transport-express (Pass 1)
2
-
3
- ## Scope
4
- - Express connector and request helpers.
5
- - Exclusion: anyapi paths.
6
-
7
- ## Purpose
8
- - Convert HTTP traffic to scope method calls, enforce transport-level media rules, and map internal errors to JSON:API-style HTTP responses.
9
-
10
- ## Key entry points
11
- - `plugins/core/connectors/express-plugin.js`
12
- - `plugins/core/connectors/lib/request-helpers.js`
13
- - `plugins/core/connectors/lib/{busboy-detector,formidable-detector}.js`
14
-
15
- ## Core data flow
16
- - Walkthrough (GET request):
17
- - [Verified][C5] Middleware builds request context (`createContext`), runs `transport:request`, then route handler dispatches to scope method handler with parsed query. Evidence: `express-plugin.js:116-177`, `295-308`, `register-scope-routes.js:31-53`.
18
- - [Verified][C5] Response status rules are method-sensitive (POST 201/204, DELETE 204, PUT/PATCH 204 on empty body). Evidence: `express-plugin.js:310-326`.
19
-
20
- ## Hook/control flow
21
- - [Verified][C5] Transport hooks are run on both success and error paths (`transport:request`, `transport:response`). Evidence: `express-plugin.js:151`, `268-279`, `333-341`.
22
- - [Verified][C4] Wildcard route path uses `router.use` with method gate for match-all behavior (used by CORS OPTIONS). Evidence: `express-plugin.js:393-414`.
23
-
24
- ## Failure modes
25
- - [Verified][C4] Non-library errors default to 500 with direct `error.message` in response; may expose internal messages in production unless upstream sanitizes. Evidence: `express-plugin.js:210-217`.
26
- - [Inferred][C3] Inconsistent error coding from plugins (e.g., custom `error.code`) can degrade status mapping determinism because only known codes map to specific status branches. Evidence: `express-plugin.js:219-266`.
27
-
28
- ## Strengths
29
- - [Verified][C5] Clear error mapping for `REST_API_VALIDATION`, `REST_API_RESOURCE`, `REST_API_PAYLOAD`.
30
- - [Verified][C4] Content-type gate for write methods and structured 404 handling under mount path.
31
-
32
- ## Risks
33
- - R-TRANSPORT-001:
34
- - [Inferred][C3] Potential information leakage via raw `error.message` on unexpected errors.
35
- - R-TRANSPORT-002:
36
- - [Unknown][C2] Behavior under malformed large payloads near `requestSizeLimit` not yet runtime-validated.
37
-
38
- ## Missing tests
39
- - [Inferred][C3] Add tests for unknown exception mapping to verify production-safe envelope strategy.
40
- - [Unknown][C2] Add tests for transport hook failure isolation (`transport:response` throwing).
41
-
42
- ## Explicit unknowns
43
- - [Unknown][C2] Reverse proxy edge-case behavior for URL prefix calculation under mixed forwarded headers.
44
-
45
- ## Pass-1 confidence
46
- - Overall: **C4**.
47
-
48
- ## Evidence links
49
- - `plugins/core/connectors/express-plugin.js`
50
- - `plugins/core/connectors/lib/request-helpers.js`
51
- - `audit/evidence/code/error-model-signals.txt`
52
-
53
- ## Pass-2 cross-review status
54
- - Reconciled in [pass2-cross-review.md](/home/merc/Development/current/json-rest-api/audit/subsystems/pass2-cross-review.md).
55
- - Final assertion/confidence values in this report are considered pass-2 normalized.
@@ -1,22 +0,0 @@
1
- # Trace: Read Get
2
-
3
- ## Scope
4
- - Non-anyapi path only.
5
-
6
- ## Scenario
7
- - Retrieve single resource by ID (`books.get`).
8
-
9
- ## Input shape
10
- - Method call: `api.resources.books.get({ id, simplified: false })`
11
-
12
- ## Call path
13
- 1. Route dispatch to `scope.get` from `register-scope-routes` ([register-scope-routes.js](/home/merc/Development/current/json-rest-api/plugins/core/rest-api-plugin-hooks/register-scope-routes.js)).
14
- 2. `get.js` performs `dataGetMinimal` + `scope.checkPermissions` then `helpers.dataGet` ([get.js](/home/merc/Development/current/json-rest-api/plugins/core/rest-api-plugin-methods/get.js)).
15
- 3. Storage helper resolves idProperty-aware query and transforms output ([rest-api-knex-plugin.js](/home/merc/Development/current/json-rest-api/plugins/core/rest-api-knex-plugin.js)).
16
-
17
- ## Runtime evidence
18
- - `npm test` confirms single get path:
19
- - `ok 1 - should retrieve a single resource` at `audit/evidence/tests/npm-test-json-rest-api.log:5480`
20
-
21
- ## Result
22
- - [Verified][C4] Non-anyapi get flow is operational under test.