@restforgejs/platform 4.2.8 → 4.3.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 (324) hide show
  1. package/SECURITY.md +83 -4
  2. package/bin/sdf-tools.exe +0 -0
  3. package/build-info.json +2 -2
  4. package/cli/consumer-deploy.js +1 -1
  5. package/cli/consumer.js +1 -1
  6. package/generators/cli/dashboard/create.js +4 -1
  7. package/generators/cli/endpoint/create.js +1 -1
  8. package/generators/cli/key/generate.js +2 -1
  9. package/generators/cli/key/revoke.js +2 -1
  10. package/generators/cli/payload/diff.js +3 -2
  11. package/generators/cli/payload/generate.js +3 -2
  12. package/generators/cli/payload/sync.js +3 -2
  13. package/generators/cli/payload/validate.js +3 -2
  14. package/generators/cli/processor/create.js +14 -3
  15. package/generators/cli/project/delete.js +2 -1
  16. package/generators/cli/query/validate.js +3 -2
  17. package/generators/cli/schema/apply.js +3 -2
  18. package/generators/cli/schema/describe.js +3 -2
  19. package/generators/cli/schema/diff.js +3 -2
  20. package/generators/cli/schema/introspect.js +3 -2
  21. package/generators/cli/schema/list.js +3 -2
  22. package/generators/cli/schema/migrate.js +3 -2
  23. package/generators/lib/migration/audit-table-runner.js +213 -215
  24. package/generators/lib/templates/dashboard-catalog.js +1 -437
  25. package/generators/lib/templates/db-connection-env.js +1 -212
  26. package/generators/lib/templates/dbschema-catalog.js +1 -489
  27. package/generators/lib/templates/field-validation-catalog.js +1 -531
  28. package/generators/lib/templates/mysql-template.js +1 -3863
  29. package/generators/lib/templates/oracle-template.js +1 -3915
  30. package/generators/lib/templates/postgres-template.js +1 -5838
  31. package/generators/lib/templates/query-declarative-catalog.js +1 -199
  32. package/generators/lib/templates/sqlite-template.js +1 -3440
  33. package/generators/lib/utils/env-manager.js +6 -0
  34. package/generators/lib/utils/path-validator.js +71 -0
  35. package/generators/lib/validators/payload-validator.js +1 -2
  36. package/integrity-manifest.json +28 -10
  37. package/package.json +11 -3
  38. package/scripts/verify-integrity.js +1 -1
  39. package/server.js +1 -1
  40. package/src/components/handlers/adjust_handler.js +1 -1
  41. package/src/components/handlers/audit_handler.js +1 -1
  42. package/src/components/handlers/delete_handler.js +1 -1
  43. package/src/components/handlers/export_handler.js +1 -1
  44. package/src/components/handlers/import_handler.js +1 -1
  45. package/src/components/handlers/insert_handler.js +1 -1
  46. package/src/components/handlers/update_handler.js +1 -1
  47. package/src/components/handlers/upload_handler.js +1 -1
  48. package/src/components/handlers/workflow_handler.js +1 -1
  49. package/src/components/integrations/webhook.js +1 -1
  50. package/src/consumers/baseConsumer.js +1 -1
  51. package/src/consumers/declarativeMapper.js +1 -1
  52. package/src/consumers/handlers/apiHandler.js +1 -1
  53. package/src/consumers/handlers/consoleHandler.js +1 -1
  54. package/src/consumers/handlers/databaseHandler.js +1 -1
  55. package/src/consumers/handlers/index.js +1 -1
  56. package/src/consumers/handlers/kafkaHandler.js +1 -1
  57. package/src/consumers/index.js +1 -1
  58. package/src/consumers/messageTransformer.js +1 -1
  59. package/src/consumers/validator.js +1 -1
  60. package/src/core/db/dialect/base-dialect.js +1 -1
  61. package/src/core/db/dialect/index.js +1 -1
  62. package/src/core/db/dialect/mysql-dialect.js +1 -1
  63. package/src/core/db/dialect/oracle-dialect.js +1 -1
  64. package/src/core/db/dialect/postgres-dialect.js +1 -1
  65. package/src/core/db/dialect/sqlite-dialect.js +1 -1
  66. package/src/core/db/flatten-helper.js +1 -1
  67. package/src/core/db/query-builder-error.js +1 -1
  68. package/src/core/db/query-builder.js +1 -1
  69. package/src/core/db/relation-helper.js +1 -1
  70. package/src/core/handlers/delete_handler.js +1 -1
  71. package/src/core/handlers/insert_handler.js +1 -1
  72. package/src/core/handlers/update_handler.js +1 -1
  73. package/src/core/models/base-model.js +1 -1
  74. package/src/core/utils/cache-manager.js +1 -1
  75. package/src/core/utils/component-engine.js +1 -1
  76. package/src/core/utils/context-builder.js +1 -1
  77. package/src/core/utils/datetime-formatter.js +1 -1
  78. package/src/core/utils/datetime-parser.js +1 -1
  79. package/src/core/utils/db.js +1 -1
  80. package/src/core/utils/logger.js +1 -1
  81. package/src/core/utils/payload-loader.js +1 -1
  82. package/src/core/utils/security-checks.js +1 -1
  83. package/src/middleware/body-options.js +1 -1
  84. package/src/middleware/cors.js +1 -1
  85. package/src/middleware/idempotency.js +1 -1
  86. package/src/middleware/rate-limiter.js +1 -1
  87. package/src/middleware/request-logger.js +1 -1
  88. package/src/middleware/security-headers.js +1 -1
  89. package/src/models/base-model-mysql.js +1 -1
  90. package/src/models/base-model-oracle.js +1 -1
  91. package/src/models/base-model-sqlite.js +1 -1
  92. package/src/models/base-model.js +1 -1
  93. package/src/pro/caching/redis-client.js +1 -1
  94. package/src/pro/caching/redis-helper.js +1 -1
  95. package/src/pro/consumers/baseConsumer.js +1 -1
  96. package/src/pro/consumers/declarativeMapper.js +1 -1
  97. package/src/pro/consumers/handlers/apiHandler.js +1 -1
  98. package/src/pro/consumers/handlers/consoleHandler.js +1 -1
  99. package/src/pro/consumers/handlers/databaseHandler.js +1 -1
  100. package/src/pro/consumers/handlers/index.js +1 -1
  101. package/src/pro/consumers/handlers/kafkaHandler.js +1 -1
  102. package/src/pro/consumers/index.js +1 -1
  103. package/src/pro/consumers/messageTransformer.js +1 -1
  104. package/src/pro/consumers/validator.js +1 -1
  105. package/src/pro/database/base-model-mysql.js +1 -1
  106. package/src/pro/database/base-model-oracle.js +1 -1
  107. package/src/pro/database/base-model-sqlite.js +1 -1
  108. package/src/pro/database/db-mysql.js +1 -1
  109. package/src/pro/database/db-oracle.js +1 -1
  110. package/src/pro/database/db-sqlite.js +1 -1
  111. package/src/pro/excel/excel-generator.js +1 -1
  112. package/src/pro/excel/excel-parser.js +1 -1
  113. package/src/pro/excel/export-service.js +1 -1
  114. package/src/pro/excel/export_handler.js +1 -1
  115. package/src/pro/excel/import-service.js +1 -1
  116. package/src/pro/excel/import-validator.js +1 -1
  117. package/src/pro/excel/import_handler.js +1 -1
  118. package/src/pro/excel/upsert-builder.js +1 -1
  119. package/src/pro/idgen/idgen-routes.js +1 -1
  120. package/src/pro/integrations/lookup-resolver.js +1 -1
  121. package/src/pro/integrations/upload-handler-v2.js +1 -1
  122. package/src/pro/integrations/upload-handler.js +1 -1
  123. package/src/pro/integrations/webhook.js +1 -1
  124. package/src/pro/locking/lock-routes.js +1 -1
  125. package/src/pro/locking/resource-lock-manager.js +1 -1
  126. package/src/pro/messaging/kafkaConsumerService.js +1 -1
  127. package/src/pro/messaging/kafkaService.js +1 -1
  128. package/src/pro/messaging/messagehubService.js +1 -1
  129. package/src/pro/messaging/rabbitmqService.js +1 -1
  130. package/src/pro/scheduler/job-manager.js +1 -1
  131. package/src/pro/scheduler/job-routes.js +1 -1
  132. package/src/pro/scheduler/job-validator.js +1 -1
  133. package/src/pro/storage/base-storage-provider.js +1 -1
  134. package/src/pro/storage/file-metadata-helper.js +1 -1
  135. package/src/pro/storage/index.js +1 -1
  136. package/src/pro/storage/local-storage-provider.js +1 -1
  137. package/src/pro/storage/s3-storage-provider.js +1 -1
  138. package/src/pro/storage/upload-cleanup-job.js +1 -1
  139. package/src/pro/storage/upload-cleanup-scheduler.js +1 -1
  140. package/src/pro/storage/upload-pending-tracker.js +1 -1
  141. package/src/pro/websocket/broadcast-helper.js +1 -1
  142. package/src/pro/websocket/index.js +1 -1
  143. package/src/pro/websocket/livesync-server.js +1 -1
  144. package/src/pro/websocket/ws-broadcaster.js +1 -1
  145. package/src/services/export-service.js +1 -1
  146. package/src/services/import-service.js +1 -1
  147. package/src/services/kafkaConsumerService.js +1 -1
  148. package/src/services/kafkaService.js +1 -1
  149. package/src/services/messagehubService.js +1 -1
  150. package/src/services/rabbitmqService.js +1 -1
  151. package/src/utils/cache-invalidation-registry.js +1 -1
  152. package/src/utils/cache-manager.js +1 -1
  153. package/src/utils/component-engine.js +1 -1
  154. package/src/utils/config-extractor.js +1 -1
  155. package/src/utils/consumerLogger.js +1 -1
  156. package/src/utils/context-builder.js +1 -1
  157. package/src/utils/dashboard-helpers.js +1 -1
  158. package/src/utils/dateHelper.js +1 -1
  159. package/src/utils/datetime-formatter.js +1 -1
  160. package/src/utils/datetime-parser.js +1 -1
  161. package/src/utils/db-bootstrap.js +1 -1
  162. package/src/utils/db-mysql.js +1 -1
  163. package/src/utils/db-oracle.js +1 -1
  164. package/src/utils/db-sqlite.js +1 -1
  165. package/src/utils/db.js +1 -1
  166. package/src/utils/demo-generator.js +1 -1
  167. package/src/utils/excel-generator.js +1 -1
  168. package/src/utils/excel-parser.js +1 -1
  169. package/src/utils/file-watcher.js +1 -1
  170. package/src/utils/id-generator.js +1 -1
  171. package/src/utils/idempotency-manager.js +1 -1
  172. package/src/utils/import-validator.js +1 -1
  173. package/src/utils/license-client.js +1 -1
  174. package/src/utils/lock-manager.js +1 -1
  175. package/src/utils/logger.js +1 -1
  176. package/src/utils/lookup-resolver.js +1 -1
  177. package/src/utils/payload-loader.js +1 -1
  178. package/src/utils/processor-response.js +1 -1
  179. package/src/utils/rabbitmq.js +1 -1
  180. package/src/utils/redis-client.js +1 -1
  181. package/src/utils/redis-helper.js +1 -1
  182. package/src/utils/request-scope.js +1 -1
  183. package/src/utils/security-checks.js +1 -1
  184. package/src/utils/service-resolver.js +1 -1
  185. package/src/utils/shutdown-coordinator.js +1 -1
  186. package/src/utils/trusted-keys.js +1 -1
  187. package/src/utils/upload-handler.js +1 -1
  188. package/src/utils/upsert-builder.js +1 -1
  189. package/src/utils/workflow-hook-executor.js +1 -1
  190. package/generators/metadata/global.json +0 -58
  191. package/generators/metadata/test-mysql-workbench.json +0 -118
  192. package/generators/metadata/test-mysql.json +0 -56
  193. package/generators/metadata/test-oracle-workbench.json +0 -118
  194. package/generators/metadata/test-oracle.json +0 -56
  195. package/generators/metadata/test-pg-workbench.json +0 -118
  196. package/generators/metadata/test-pg.json +0 -56
  197. package/generators/scripts/obfuscate-source.js +0 -356
  198. package/generators/scripts/validate-catalog.js +0 -430
  199. package/generators/scripts/validate-dbschema-catalog.js +0 -708
  200. package/generators/tests/baseline/mysql/mini_inventory_item/src/models/mini-inventory/item.js +0 -944
  201. package/generators/tests/baseline/mysql/mini_inventory_item/src/modules/mini-inventory/item.js +0 -740
  202. package/generators/tests/baseline/mysql/mini_inventory_item/src/modules/mini-inventory.js +0 -336
  203. package/generators/tests/baseline/oracle/mini_inventory_item/src/models/mini-inventory/item.js +0 -1002
  204. package/generators/tests/baseline/oracle/mini_inventory_item/src/modules/mini-inventory/item.js +0 -740
  205. package/generators/tests/baseline/oracle/mini_inventory_item/src/modules/mini-inventory.js +0 -336
  206. package/generators/tests/baseline/postgres/mini_inventory_item/src/models/mini-inventory/item.js +0 -1333
  207. package/generators/tests/baseline/postgres/mini_inventory_item/src/modules/mini-inventory/item.js +0 -1173
  208. package/generators/tests/baseline/postgres/mini_inventory_item/src/modules/mini-inventory.js +0 -496
  209. package/generators/tests/fixtures/payloads/custom-sensitive.json +0 -27
  210. package/generators/tests/fixtures/payloads/dynamic-search-optout.json +0 -23
  211. package/generators/tests/fixtures/payloads/login-with-password.json +0 -22
  212. package/generators/tests/fixtures/payloads/order-process.json +0 -52
  213. package/generators/tests/fixtures/payloads/with-inline-sql.json +0 -26
  214. package/generators/tests/integration-tahap4b/README.md +0 -145
  215. package/generators/tests/integration-tahap4b/run-concurrent.js +0 -77
  216. package/generators/tests/integration-tahap4b/seed.sql +0 -53
  217. package/generators/tests/integration-tahap4b/verify.sql +0 -110
  218. package/generators/tests/unit/cli/create-dashboard.test.js +0 -505
  219. package/generators/tests/unit/cli/create-processor.test.js +0 -319
  220. package/generators/tests/unit/cli/dispatch-dashboard.test.js +0 -149
  221. package/generators/tests/unit/lib/dashboard-generator.test.js +0 -895
  222. package/generators/tests/unit/lib/dashboard-validator.test.js +0 -354
  223. package/generators/tests/unit/lib/dbschema-kit/apply-executor.test.js +0 -437
  224. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-introspect.test.js +0 -393
  225. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-generate-ddl.test.js +0 -104
  226. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-init.test.js +0 -119
  227. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-list.test.js +0 -48
  228. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-migrate.test.js +0 -175
  229. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-validate.test.js +0 -102
  230. package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-models.test.js +0 -43
  231. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/all-schemas-listing.js +0 -84
  232. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/connection-error.js +0 -13
  233. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/empty.js +0 -12
  234. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/multi-schema.js +0 -124
  235. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/single-schema-inventory.js +0 -64
  236. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/two-tables.js +0 -66
  237. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/connection-error.js +0 -9
  238. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/partial.js +0 -29
  239. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/rollback.js +0 -26
  240. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/success.js +0 -43
  241. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/multi-schema/audit/events.js +0 -18
  242. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/multi-schema/inventory/products.js +0 -9
  243. package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/multi-schema/users.js +0 -8
  244. package/generators/tests/unit/lib/dbschema-kit/connection.test.js +0 -112
  245. package/generators/tests/unit/lib/dbschema-kit/ddl-generator.test.js +0 -205
  246. package/generators/tests/unit/lib/dbschema-kit/define-model.test.js +0 -56
  247. package/generators/tests/unit/lib/dbschema-kit/dialect/index.test.js +0 -46
  248. package/generators/tests/unit/lib/dbschema-kit/dialect/mysql.test.js +0 -126
  249. package/generators/tests/unit/lib/dbschema-kit/dialect/oracle.test.js +0 -126
  250. package/generators/tests/unit/lib/dbschema-kit/dialect/postgres.test.js +0 -131
  251. package/generators/tests/unit/lib/dbschema-kit/dialect/sqlite.test.js +0 -126
  252. package/generators/tests/unit/lib/dbschema-kit/driver-loader.test.js +0 -93
  253. package/generators/tests/unit/lib/dbschema-kit/emitters/create-index.test.js +0 -173
  254. package/generators/tests/unit/lib/dbschema-kit/emitters/create-table.test.js +0 -376
  255. package/generators/tests/unit/lib/dbschema-kit/emitters/drop-table.test.js +0 -78
  256. package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/invalid-dialect.env +0 -6
  257. package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/missing-dialect.env +0 -5
  258. package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/missing-host.env +0 -5
  259. package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/oracle-valid.env +0 -6
  260. package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/postgres-valid.env +0 -7
  261. package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/sqlite-valid.env +0 -2
  262. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/category.js +0 -11
  263. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/item_product.js +0 -11
  264. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/stock_inbound.js +0 -24
  265. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/stock_inbound_item.js +0 -28
  266. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/supplier.js +0 -9
  267. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/warehouse.js +0 -9
  268. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-invalid/orphan.js +0 -17
  269. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/category.js +0 -11
  270. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/item_product.js +0 -11
  271. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/supplier.js +0 -9
  272. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/warehouse.js +0 -9
  273. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/transactions/stock_inbound.js +0 -24
  274. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/transactions/stock_inbound_item.js +0 -28
  275. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/multi-schema/audit/events.js +0 -18
  276. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/multi-schema/inventory/products.js +0 -9
  277. package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/multi-schema/public/users.js +0 -9
  278. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-subfolder/extra/category.js +0 -8
  279. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-subfolder/master/category.js +0 -8
  280. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-tablename/bar.js +0 -8
  281. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-tablename/foo.js +0 -8
  282. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/empty-folder/README.md +0 -1
  283. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/invalid-export/plain.js +0 -3
  284. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/invalid-schema/bad.js +0 -6
  285. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/legacy-pattern/legacy.js +0 -12
  286. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-distinct/audit/products.js +0 -9
  287. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-distinct/inventory/products.js +0 -9
  288. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-duplicate/a/products.js +0 -8
  289. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-duplicate/b/products.js +0 -8
  290. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/nested-deep/a/b/c/deep_table.js +0 -8
  291. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/.hidden/ignored.js +0 -7
  292. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/master/category.js +0 -8
  293. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/master/supplier.js +0 -8
  294. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/transactions/stock_inbound.js +0 -8
  295. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/transactions/stock_inbound_item.js +0 -8
  296. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/valid-multiple/category.js +0 -8
  297. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/valid-multiple/item_product.js +0 -9
  298. package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/valid-single/category.js +0 -8
  299. package/generators/tests/unit/lib/dbschema-kit/integration.test.js +0 -217
  300. package/generators/tests/unit/lib/dbschema-kit/introspect-mapper.test.js +0 -403
  301. package/generators/tests/unit/lib/dbschema-kit/ir-builder.test.js +0 -390
  302. package/generators/tests/unit/lib/dbschema-kit/loader.test.js +0 -128
  303. package/generators/tests/unit/lib/dbschema-kit/naming.test.js +0 -170
  304. package/generators/tests/unit/lib/dbschema-kit/parser/shorthand-parser.test.js +0 -237
  305. package/generators/tests/unit/lib/dbschema-kit/schema-printer.test.js +0 -251
  306. package/generators/tests/unit/lib/dbschema-kit/statement-modifier.test.js +0 -105
  307. package/generators/tests/unit/lib/dbschema-kit/statement-splitter.test.js +0 -165
  308. package/generators/tests/unit/lib/dbschema-kit/topological-sort.test.js +0 -135
  309. package/generators/tests/unit/lib/dbschema-kit/validator/check-compatibility-validator.test.js +0 -373
  310. package/generators/tests/unit/lib/dbschema-kit/validator/circular-relation-validator.test.js +0 -454
  311. package/generators/tests/unit/lib/dbschema-kit/validator/cross-model-validator.test.js +0 -512
  312. package/generators/tests/unit/lib/dbschema-kit/validator/enhanced-validate-integration.test.js +0 -390
  313. package/generators/tests/unit/lib/dbschema-kit/validator/naming-convention-validator.test.js +0 -306
  314. package/generators/tests/unit/lib/dbschema-kit/validator/schema-validator.test.js +0 -443
  315. package/generators/tests/unit/lib/dbschema-kit/validator/type-compatibility-validator.test.js +0 -440
  316. package/generators/tests/unit/lib/dbschema-kit/validator/validator-reporter.test.js +0 -172
  317. package/generators/tests/unit/lib/metadata-manager-dashboard.test.js +0 -256
  318. package/generators/tests/unit/lib/payload-validator-fieldpolicy.test.js +0 -240
  319. package/generators/tests/unit/lib/processor-validation-generator.test.js +0 -300
  320. package/generators/tests/unit/lib/sensitive-field-masker.test.js +0 -170
  321. package/generators/tests/unit/lib/sql-table-extractor.test.js +0 -119
  322. package/scripts/generate-integrity-manifest.js +0 -124
  323. package/scripts/snapshot-cli-contracts.js +0 -194
  324. package/scripts/verify-publish.js +0 -56
@@ -1,430 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * RESTForge - Field Validation Catalog Sync Validator
5
- *
6
- * Cross-check catalog metadata vs spec doc and template implementation
7
- * to detect drift between three artifacts:
8
- *
9
- * 1. Catalog data : generators/lib/templates/field-validation-catalog.js
10
- * 2. Spec doc : <repo-root>/docs/schema-reference/feat-field-validation.md
11
- * (belum tersedia di v3 baseline — siapkan placeholder
12
- * bila Level 4 cross-check ingin diaktifkan)
13
- * 3. Template engine : generators/lib/templates/postgres-template.js (PG = primary)
14
- * generators/lib/templates/{mysql,oracle,sqlite}-template.js (best-effort)
15
- *
16
- * Usage (jalankan dari folder packages/platform):
17
- * node generators/scripts/validate-catalog.js [--strict] [--quiet]
18
- *
19
- * Exit codes:
20
- * 0 = no issues, or only warnings (default)
21
- * 1 = errors found, or warnings found in --strict mode
22
- *
23
- * @module scripts/validate-catalog
24
- */
25
-
26
- const fs = require('fs');
27
- const path = require('path');
28
-
29
- // ============================================================================
30
- // CONFIG
31
- // ============================================================================
32
-
33
- const CATALOG_PATH = path.join(__dirname, '..', 'lib', 'templates', 'field-validation-catalog.js');
34
- const PG_TEMPLATE_PATH = path.join(__dirname, '..', 'lib', 'templates', 'postgres-template.js');
35
- // Spec doc lives at <repo-root>/docs/schema-reference/feat-field-validation.md (v3 layout).
36
- // __dirname = packages/platform/generators/scripts → naik 4 level untuk reach repo root.
37
- // CATATAN v3: file ini belum tersedia di baseline; Level 4 cross-check akan report
38
- // "Spec doc file not found" sampai placeholder/spec disiapkan di lokasi ini.
39
- const SPEC_DOC_PATH = path.join(__dirname, '..', '..', '..', '..', 'docs', 'schema-reference', 'feat-field-validation.md');
40
-
41
- const SECONDARY_TEMPLATES = [
42
- { name: 'MySQL', path: path.join(__dirname, '..', 'lib', 'templates', 'mysql-template.js') },
43
- { name: 'Oracle', path: path.join(__dirname, '..', 'lib', 'templates', 'oracle-template.js') },
44
- { name: 'SQLite', path: path.join(__dirname, '..', 'lib', 'templates', 'sqlite-template.js') }
45
- ];
46
-
47
- // ============================================================================
48
- // REPORTING
49
- // ============================================================================
50
-
51
- const report = {
52
- errors: [],
53
- warnings: [],
54
- info: []
55
- };
56
-
57
- function err(msg) { report.errors.push(msg); }
58
- function warn(msg) { report.warnings.push(msg); }
59
- function info(msg) { report.info.push(msg); }
60
-
61
- // ============================================================================
62
- // PARSE ARGUMENTS
63
- // ============================================================================
64
-
65
- function parseArgs() {
66
- const args = process.argv.slice(2);
67
- return {
68
- strict: args.includes('--strict'),
69
- quiet: args.includes('--quiet')
70
- };
71
- }
72
-
73
- // ============================================================================
74
- // LEVEL 1: CATALOG SCHEMA INTEGRITY
75
- // ============================================================================
76
-
77
- function checkCatalogStructure(catalog) {
78
- const requiredKeys = ['schemaVersion', 'source', 'types', 'constraints', 'formatPresets', 'auditColumns', 'messageOverridePattern'];
79
- for (const key of requiredKeys) {
80
- if (!(key in catalog)) {
81
- err(`Catalog missing required top-level key: '${key}'`);
82
- }
83
- }
84
- if (!Array.isArray(catalog.types)) err('catalog.types must be an array');
85
- if (!Array.isArray(catalog.constraints)) err('catalog.constraints must be an array');
86
- if (!Array.isArray(catalog.formatPresets)) err('catalog.formatPresets must be an array');
87
- if (typeof catalog.auditColumns !== 'object' || catalog.auditColumns === null) err('catalog.auditColumns must be an object');
88
- if (typeof catalog.messageOverridePattern !== 'object' || catalog.messageOverridePattern === null) err('catalog.messageOverridePattern must be an object');
89
- }
90
-
91
- function checkTypesIntegrity(types) {
92
- const requiredFields = ['name', 'description', 'databaseTypes', 'exampleValue', 'applicableConstraints'];
93
- const seen = new Set();
94
-
95
- for (const t of types) {
96
- for (const f of requiredFields) {
97
- if (!(f in t)) err(`Type '${t.name || '<unknown>'}' missing field: '${f}'`);
98
- }
99
- if (seen.has(t.name)) err(`Duplicate type name: '${t.name}'`);
100
- seen.add(t.name);
101
-
102
- if (!Array.isArray(t.databaseTypes)) err(`Type '${t.name}': databaseTypes must be array`);
103
- if (!Array.isArray(t.applicableConstraints)) err(`Type '${t.name}': applicableConstraints must be array`);
104
- }
105
- }
106
-
107
- function checkConstraintsIntegrity(constraints) {
108
- const requiredFields = ['name', 'valueType', 'description', 'scope', 'applicableTypes', 'messageOverrideKey', 'example'];
109
- const validScopes = ['general', 'string', 'number', 'date', 'boolean', 'array', 'json', 'uuid'];
110
- const validValueTypes = ['boolean', 'integer', 'number', 'string', 'array', 'object', 'any'];
111
-
112
- const nameScopeKeys = new Set();
113
-
114
- for (const c of constraints) {
115
- for (const f of requiredFields) {
116
- if (!(f in c)) err(`Constraint '${c.name || '<unknown>'}' missing field: '${f}'`);
117
- }
118
- if (!validScopes.includes(c.scope)) {
119
- err(`Constraint '${c.name}': invalid scope '${c.scope}' (must be one of: ${validScopes.join(', ')})`);
120
- }
121
- if (!validValueTypes.includes(c.valueType)) {
122
- err(`Constraint '${c.name}': invalid valueType '${c.valueType}' (must be one of: ${validValueTypes.join(', ')})`);
123
- }
124
- if (!Array.isArray(c.applicableTypes)) {
125
- err(`Constraint '${c.name}': applicableTypes must be array`);
126
- }
127
-
128
- // Composite key (name + scope) — same name can appear with different scopes (e.g. 'format' for string and date)
129
- const key = `${c.name}@${c.scope}`;
130
- if (nameScopeKeys.has(key)) {
131
- err(`Duplicate constraint: '${c.name}' with scope '${c.scope}'`);
132
- }
133
- nameScopeKeys.add(key);
134
- }
135
- }
136
-
137
- function checkFormatPresetsIntegrity(formatPresets) {
138
- const seen = new Set();
139
- for (const p of formatPresets) {
140
- if (!p.name) err('Format preset missing name');
141
- if (!p.description) err(`Format preset '${p.name}' missing description`);
142
- if (seen.has(p.name)) err(`Duplicate format preset: '${p.name}'`);
143
- seen.add(p.name);
144
- }
145
- }
146
-
147
- function checkAuditColumnsIntegrity(auditColumns) {
148
- const required = ['managedColumns', 'validValues', 'rejectedValues', 'errorMessage'];
149
- for (const f of required) {
150
- if (!(f in auditColumns)) err(`auditColumns missing field: '${f}'`);
151
- }
152
- if (!Array.isArray(auditColumns.managedColumns)) err('auditColumns.managedColumns must be array');
153
- if (!Array.isArray(auditColumns.validValues)) err('auditColumns.validValues must be array');
154
- if (!Array.isArray(auditColumns.rejectedValues)) err('auditColumns.rejectedValues must be array');
155
- }
156
-
157
- // ============================================================================
158
- // LEVEL 2: INTERNAL CROSS-REFERENCE
159
- // ============================================================================
160
-
161
- function checkCrossReferences(catalog) {
162
- const typeNames = new Set(catalog.types.map(t => t.name));
163
- const constraintNames = new Set(catalog.constraints.map(c => c.name));
164
-
165
- // 1. Each type's applicableConstraints must reference real constraints
166
- for (const t of catalog.types) {
167
- for (const cName of t.applicableConstraints) {
168
- if (!constraintNames.has(cName)) {
169
- err(`Type '${t.name}': references non-existent constraint '${cName}' in applicableConstraints`);
170
- }
171
- }
172
- }
173
-
174
- // 2. Each constraint's applicableTypes must reference real types (or "all")
175
- for (const c of catalog.constraints) {
176
- for (const tName of c.applicableTypes) {
177
- if (tName === 'all') continue;
178
- if (!typeNames.has(tName)) {
179
- err(`Constraint '${c.name}@${c.scope}': references non-existent type '${tName}' in applicableTypes`);
180
- }
181
- }
182
- }
183
-
184
- // 3. Bidirectional consistency: if constraint X applies to type Y, then type Y should list X in applicableConstraints
185
- for (const c of catalog.constraints) {
186
- const targets = c.applicableTypes.includes('all')
187
- ? Array.from(typeNames)
188
- : c.applicableTypes;
189
- for (const tName of targets) {
190
- const t = catalog.types.find(x => x.name === tName);
191
- if (!t) continue;
192
- if (!t.applicableConstraints.includes(c.name)) {
193
- warn(`Bidirectional drift: constraint '${c.name}@${c.scope}' applicable to '${tName}', but type '${tName}' does not list it in applicableConstraints`);
194
- }
195
- }
196
- }
197
-
198
- // 4. messageOverrideKey naming convention
199
- for (const c of catalog.constraints) {
200
- if (c.messageOverrideKey === null) continue;
201
- const expected = c.name + 'Message';
202
- if (c.messageOverrideKey !== expected) {
203
- warn(`Constraint '${c.name}@${c.scope}': messageOverrideKey '${c.messageOverrideKey}' does not match convention '${expected}'`);
204
- }
205
- }
206
- }
207
-
208
- // ============================================================================
209
- // LEVEL 3: TEMPLATE IMPLEMENTATION (PostgreSQL = primary)
210
- // ============================================================================
211
-
212
- function checkPgTemplateImplementation(catalog) {
213
- if (!fs.existsSync(PG_TEMPLATE_PATH)) {
214
- err(`PostgreSQL template not found: ${PG_TEMPLATE_PATH}`);
215
- return;
216
- }
217
-
218
- const tpl = fs.readFileSync(PG_TEMPLATE_PATH, 'utf8');
219
-
220
- // Constraints that are sanitization or marker only — not validated as runtime check
221
- // (still listed in catalog for completeness)
222
- const NON_VALIDATABLE = new Set([
223
- 'unique', // database-level
224
- 'default', // pre-validation injection
225
- 'primaryKey', // structural
226
- 'autoGenerate', // pre-validation injection
227
- 'nullable', // structural
228
- 'patternMessage', // override key, not validatable itself
229
- 'scale', // schema-level (DDL)
230
- 'precision', // schema-level (DDL)
231
- 'schema', // not yet enforced at runtime
232
- 'strict' // not yet enforced at runtime
233
- ]);
234
-
235
- // Constraint names that PG template should reference (e.g. constraints.required, constraints.minLength)
236
- const constraintNames = new Set(catalog.constraints.map(c => c.name));
237
-
238
- for (const cName of constraintNames) {
239
- if (NON_VALIDATABLE.has(cName)) continue;
240
- // Look for constraints.<name> or constraints['<name>']
241
- const pattern = new RegExp(`constraints\\.${cName}\\b|constraints\\[['"]${cName}['"]\\]`);
242
- if (!pattern.test(tpl)) {
243
- warn(`PG template: constraint '${cName}' declared in catalog but not referenced in postgres-template.js`);
244
- }
245
- }
246
-
247
- // Verify type-specific dispatcher methods exist
248
- const typeMethods = {
249
- string: '_validateStringConstraints',
250
- integer: '_validateNumberConstraints',
251
- decimal: '_validateNumberConstraints',
252
- number: '_validateNumberConstraints',
253
- boolean: '_validateBooleanConstraints',
254
- date: '_validateDateConstraints',
255
- datetime: '_validateDateConstraints',
256
- timestamp: '_validateDateConstraints',
257
- uuid: '_validateUuidConstraints',
258
- array: '_validateArrayConstraints',
259
- json: '_validateJsonConstraints'
260
- };
261
-
262
- for (const [typeName, methodName] of Object.entries(typeMethods)) {
263
- const typeInCatalog = catalog.types.find(t => t.name === typeName);
264
- if (!typeInCatalog) continue;
265
- if (!tpl.includes(methodName)) {
266
- warn(`PG template: type '${typeName}' declared in catalog but dispatcher method '${methodName}' not found`);
267
- }
268
- }
269
-
270
- // Verify format presets are referenced
271
- // Match: 'email', "email", or email: (object key)
272
- for (const preset of catalog.formatPresets) {
273
- const pattern = new RegExp(`['"]${preset.name}['"]|\\b${preset.name}\\s*:`);
274
- if (!pattern.test(tpl)) {
275
- warn(`PG template: format preset '${preset.name}' declared in catalog but not referenced`);
276
- }
277
- }
278
- }
279
-
280
- function checkSecondaryTemplates(catalog) {
281
- for (const tplDef of SECONDARY_TEMPLATES) {
282
- if (!fs.existsSync(tplDef.path)) {
283
- info(`${tplDef.name} template not found, skipping: ${tplDef.path}`);
284
- continue;
285
- }
286
- const tpl = fs.readFileSync(tplDef.path, 'utf8');
287
- const hasValidationMethod = tpl.includes('validateFieldConstraints');
288
- if (!hasValidationMethod) {
289
- info(`${tplDef.name} template: no full validation engine (this is by design — only PG has full implementation currently)`);
290
- } else {
291
- info(`${tplDef.name} template: has validateFieldConstraints — consider running similar checks`);
292
- }
293
- }
294
- }
295
-
296
- // ============================================================================
297
- // LEVEL 4: SPEC DOCUMENT (best-effort textual check)
298
- // ============================================================================
299
-
300
- function checkSpecDocReferences(catalog) {
301
- if (!fs.existsSync(SPEC_DOC_PATH)) {
302
- warn(`Spec doc not found: ${SPEC_DOC_PATH}`);
303
- return;
304
- }
305
-
306
- const doc = fs.readFileSync(SPEC_DOC_PATH, 'utf8');
307
-
308
- // Check that each constraint name appears in the spec doc
309
- for (const c of catalog.constraints) {
310
- const pattern = new RegExp(`\\b${c.name}\\b`);
311
- if (!pattern.test(doc)) {
312
- warn(`Spec doc: constraint '${c.name}@${c.scope}' not referenced in feat-field-validation.md`);
313
- }
314
- }
315
-
316
- // Check that each type name appears in the spec doc
317
- for (const t of catalog.types) {
318
- const pattern = new RegExp(`\\b${t.name}\\b`);
319
- if (!pattern.test(doc)) {
320
- warn(`Spec doc: type '${t.name}' not referenced in feat-field-validation.md`);
321
- }
322
- }
323
-
324
- // Check that each format preset appears
325
- for (const p of catalog.formatPresets) {
326
- const pattern = new RegExp(`format:\\s*${p.name}|format\\s*=\\s*["']${p.name}["']|\\b${p.name}\\b`);
327
- if (!pattern.test(doc)) {
328
- warn(`Spec doc: format preset '${p.name}' not referenced in feat-field-validation.md`);
329
- }
330
- }
331
- }
332
-
333
- // ============================================================================
334
- // MAIN
335
- // ============================================================================
336
-
337
- function printReport(quiet) {
338
- const lines = [];
339
-
340
- lines.push('');
341
- lines.push('================================================================');
342
- lines.push(' Field Validation Catalog Sync Validator');
343
- lines.push('================================================================');
344
- lines.push('');
345
-
346
- if (report.errors.length > 0) {
347
- lines.push(`ERRORS (${report.errors.length}):`);
348
- for (const e of report.errors) lines.push(` [X] ${e}`);
349
- lines.push('');
350
- }
351
-
352
- if (report.warnings.length > 0) {
353
- lines.push(`WARNINGS (${report.warnings.length}):`);
354
- for (const w of report.warnings) lines.push(` [!] ${w}`);
355
- lines.push('');
356
- }
357
-
358
- if (!quiet && report.info.length > 0) {
359
- lines.push(`INFO (${report.info.length}):`);
360
- for (const i of report.info) lines.push(` [i] ${i}`);
361
- lines.push('');
362
- }
363
-
364
- lines.push('----------------------------------------------------------------');
365
- lines.push(' Summary');
366
- lines.push('----------------------------------------------------------------');
367
- lines.push(` Errors : ${report.errors.length}`);
368
- lines.push(` Warnings: ${report.warnings.length}`);
369
- lines.push(` Info : ${report.info.length}`);
370
- lines.push('');
371
-
372
- if (report.errors.length === 0 && report.warnings.length === 0) {
373
- lines.push(' Status: PASS — catalog, spec doc, and PG template are in sync.');
374
- } else if (report.errors.length === 0) {
375
- lines.push(' Status: PASS WITH WARNINGS — review warnings above.');
376
- } else {
377
- lines.push(' Status: FAIL — fix errors before commit.');
378
- }
379
- lines.push('');
380
-
381
- console.log(lines.join('\n'));
382
- }
383
-
384
- function main() {
385
- const opts = parseArgs();
386
-
387
- let catalog;
388
- try {
389
- ({ FIELD_VALIDATION_CATALOG: catalog } = require(CATALOG_PATH));
390
- } catch (e) {
391
- console.error(`Failed to load catalog from ${CATALOG_PATH}`);
392
- console.error(e.message);
393
- process.exit(1);
394
- }
395
-
396
- info(`Catalog loaded from: ${path.relative(process.cwd(), CATALOG_PATH)}`);
397
- info(`Schema version: ${catalog.schemaVersion}`);
398
- info(`Types: ${catalog.types.length}, Constraints: ${catalog.constraints.length}, Format presets: ${catalog.formatPresets.length}`);
399
-
400
- // Level 1: structure
401
- checkCatalogStructure(catalog);
402
- checkTypesIntegrity(catalog.types);
403
- checkConstraintsIntegrity(catalog.constraints);
404
- checkFormatPresetsIntegrity(catalog.formatPresets);
405
- checkAuditColumnsIntegrity(catalog.auditColumns);
406
-
407
- // Stop early if structural errors — cross-ref checks will be misleading
408
- if (report.errors.length > 0) {
409
- printReport(opts.quiet);
410
- process.exit(1);
411
- }
412
-
413
- // Level 2: cross-reference
414
- checkCrossReferences(catalog);
415
-
416
- // Level 3: template implementation
417
- checkPgTemplateImplementation(catalog);
418
- checkSecondaryTemplates(catalog);
419
-
420
- // Level 4: spec doc
421
- checkSpecDocReferences(catalog);
422
-
423
- printReport(opts.quiet);
424
-
425
- if (report.errors.length > 0) process.exit(1);
426
- if (opts.strict && report.warnings.length > 0) process.exit(1);
427
- process.exit(0);
428
- }
429
-
430
- main();