@restforgejs/platform 4.2.8 → 4.3.2
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.
- package/SECURITY.md +83 -4
- package/bin/sdf-tools.exe +0 -0
- package/build-info.json +2 -2
- package/cli/consumer-deploy.js +1 -1
- package/cli/consumer.js +1 -1
- package/generators/cli/dashboard/create.js +4 -1
- package/generators/cli/endpoint/create.js +1 -1
- package/generators/cli/key/generate.js +2 -1
- package/generators/cli/key/revoke.js +2 -1
- package/generators/cli/payload/diff.js +3 -2
- package/generators/cli/payload/generate.js +3 -2
- package/generators/cli/payload/sync.js +3 -2
- package/generators/cli/payload/validate.js +3 -2
- package/generators/cli/processor/create.js +14 -3
- package/generators/cli/project/delete.js +2 -1
- package/generators/cli/query/validate.js +3 -2
- package/generators/cli/schema/apply.js +3 -2
- package/generators/cli/schema/describe.js +3 -2
- package/generators/cli/schema/diff.js +3 -2
- package/generators/cli/schema/introspect.js +3 -2
- package/generators/cli/schema/list.js +3 -2
- package/generators/cli/schema/migrate.js +3 -2
- package/generators/lib/migration/audit-table-runner.js +213 -215
- package/generators/lib/payload/payload-runner.js +1 -1
- package/generators/lib/templates/dashboard-catalog.js +1 -437
- package/generators/lib/templates/db-connection-env.js +1 -212
- package/generators/lib/templates/dbschema-catalog.js +1 -489
- package/generators/lib/templates/field-validation-catalog.js +1 -531
- package/generators/lib/templates/mysql-template.js +1 -3863
- package/generators/lib/templates/oracle-template.js +1 -3915
- package/generators/lib/templates/postgres-template.js +1 -5838
- package/generators/lib/templates/query-declarative-catalog.js +1 -199
- package/generators/lib/templates/sqlite-template.js +1 -3440
- package/generators/lib/utils/env-manager.js +6 -0
- package/generators/lib/utils/path-validator.js +71 -0
- package/generators/lib/validators/payload-validator.js +1 -2
- package/integrity-manifest.json +28 -10
- package/package.json +11 -3
- package/scripts/verify-integrity.js +1 -1
- package/server.js +1 -1
- package/src/components/handlers/adjust_handler.js +1 -1
- package/src/components/handlers/audit_handler.js +1 -1
- package/src/components/handlers/delete_handler.js +1 -1
- package/src/components/handlers/export_handler.js +1 -1
- package/src/components/handlers/import_handler.js +1 -1
- package/src/components/handlers/insert_handler.js +1 -1
- package/src/components/handlers/update_handler.js +1 -1
- package/src/components/handlers/upload_handler.js +1 -1
- package/src/components/handlers/workflow_handler.js +1 -1
- package/src/components/integrations/webhook.js +1 -1
- package/src/consumers/baseConsumer.js +1 -1
- package/src/consumers/declarativeMapper.js +1 -1
- package/src/consumers/handlers/apiHandler.js +1 -1
- package/src/consumers/handlers/consoleHandler.js +1 -1
- package/src/consumers/handlers/databaseHandler.js +1 -1
- package/src/consumers/handlers/index.js +1 -1
- package/src/consumers/handlers/kafkaHandler.js +1 -1
- package/src/consumers/index.js +1 -1
- package/src/consumers/messageTransformer.js +1 -1
- package/src/consumers/validator.js +1 -1
- package/src/core/db/dialect/base-dialect.js +1 -1
- package/src/core/db/dialect/index.js +1 -1
- package/src/core/db/dialect/mysql-dialect.js +1 -1
- package/src/core/db/dialect/oracle-dialect.js +1 -1
- package/src/core/db/dialect/postgres-dialect.js +1 -1
- package/src/core/db/dialect/sqlite-dialect.js +1 -1
- package/src/core/db/flatten-helper.js +1 -1
- package/src/core/db/query-builder-error.js +1 -1
- package/src/core/db/query-builder.js +1 -1
- package/src/core/db/relation-helper.js +1 -1
- package/src/core/handlers/delete_handler.js +1 -1
- package/src/core/handlers/insert_handler.js +1 -1
- package/src/core/handlers/update_handler.js +1 -1
- package/src/core/models/base-model.js +1 -1
- package/src/core/utils/cache-manager.js +1 -1
- package/src/core/utils/component-engine.js +1 -1
- package/src/core/utils/context-builder.js +1 -1
- package/src/core/utils/datetime-formatter.js +1 -1
- package/src/core/utils/datetime-parser.js +1 -1
- package/src/core/utils/db.js +1 -1
- package/src/core/utils/logger.js +1 -1
- package/src/core/utils/payload-loader.js +1 -1
- package/src/core/utils/security-checks.js +1 -1
- package/src/middleware/body-options.js +1 -1
- package/src/middleware/cors.js +1 -1
- package/src/middleware/idempotency.js +1 -1
- package/src/middleware/rate-limiter.js +1 -1
- package/src/middleware/request-logger.js +1 -1
- package/src/middleware/security-headers.js +1 -1
- package/src/models/base-model-mysql.js +1 -1
- package/src/models/base-model-oracle.js +1 -1
- package/src/models/base-model-sqlite.js +1 -1
- package/src/models/base-model.js +1 -1
- package/src/pro/caching/redis-client.js +1 -1
- package/src/pro/caching/redis-helper.js +1 -1
- package/src/pro/consumers/baseConsumer.js +1 -1
- package/src/pro/consumers/declarativeMapper.js +1 -1
- package/src/pro/consumers/handlers/apiHandler.js +1 -1
- package/src/pro/consumers/handlers/consoleHandler.js +1 -1
- package/src/pro/consumers/handlers/databaseHandler.js +1 -1
- package/src/pro/consumers/handlers/index.js +1 -1
- package/src/pro/consumers/handlers/kafkaHandler.js +1 -1
- package/src/pro/consumers/index.js +1 -1
- package/src/pro/consumers/messageTransformer.js +1 -1
- package/src/pro/consumers/validator.js +1 -1
- package/src/pro/database/base-model-mysql.js +1 -1
- package/src/pro/database/base-model-oracle.js +1 -1
- package/src/pro/database/base-model-sqlite.js +1 -1
- package/src/pro/database/db-mysql.js +1 -1
- package/src/pro/database/db-oracle.js +1 -1
- package/src/pro/database/db-sqlite.js +1 -1
- package/src/pro/excel/excel-generator.js +1 -1
- package/src/pro/excel/excel-parser.js +1 -1
- package/src/pro/excel/export-service.js +1 -1
- package/src/pro/excel/export_handler.js +1 -1
- package/src/pro/excel/import-service.js +1 -1
- package/src/pro/excel/import-validator.js +1 -1
- package/src/pro/excel/import_handler.js +1 -1
- package/src/pro/excel/upsert-builder.js +1 -1
- package/src/pro/idgen/idgen-routes.js +1 -1
- package/src/pro/integrations/lookup-resolver.js +1 -1
- package/src/pro/integrations/upload-handler-v2.js +1 -1
- package/src/pro/integrations/upload-handler.js +1 -1
- package/src/pro/integrations/webhook.js +1 -1
- package/src/pro/locking/lock-routes.js +1 -1
- package/src/pro/locking/resource-lock-manager.js +1 -1
- package/src/pro/messaging/kafkaConsumerService.js +1 -1
- package/src/pro/messaging/kafkaService.js +1 -1
- package/src/pro/messaging/messagehubService.js +1 -1
- package/src/pro/messaging/rabbitmqService.js +1 -1
- package/src/pro/scheduler/job-manager.js +1 -1
- package/src/pro/scheduler/job-routes.js +1 -1
- package/src/pro/scheduler/job-validator.js +1 -1
- package/src/pro/storage/base-storage-provider.js +1 -1
- package/src/pro/storage/file-metadata-helper.js +1 -1
- package/src/pro/storage/index.js +1 -1
- package/src/pro/storage/local-storage-provider.js +1 -1
- package/src/pro/storage/s3-storage-provider.js +1 -1
- package/src/pro/storage/upload-cleanup-job.js +1 -1
- package/src/pro/storage/upload-cleanup-scheduler.js +1 -1
- package/src/pro/storage/upload-pending-tracker.js +1 -1
- package/src/pro/websocket/broadcast-helper.js +1 -1
- package/src/pro/websocket/index.js +1 -1
- package/src/pro/websocket/livesync-server.js +1 -1
- package/src/pro/websocket/ws-broadcaster.js +1 -1
- package/src/services/export-service.js +1 -1
- package/src/services/import-service.js +1 -1
- package/src/services/kafkaConsumerService.js +1 -1
- package/src/services/kafkaService.js +1 -1
- package/src/services/messagehubService.js +1 -1
- package/src/services/rabbitmqService.js +1 -1
- package/src/utils/cache-invalidation-registry.js +1 -1
- package/src/utils/cache-manager.js +1 -1
- package/src/utils/component-engine.js +1 -1
- package/src/utils/config-extractor.js +1 -1
- package/src/utils/consumerLogger.js +1 -1
- package/src/utils/context-builder.js +1 -1
- package/src/utils/dashboard-helpers.js +1 -1
- package/src/utils/dateHelper.js +1 -1
- package/src/utils/datetime-formatter.js +1 -1
- package/src/utils/datetime-parser.js +1 -1
- package/src/utils/db-bootstrap.js +1 -1
- package/src/utils/db-mysql.js +1 -1
- package/src/utils/db-oracle.js +1 -1
- package/src/utils/db-sqlite.js +1 -1
- package/src/utils/db.js +1 -1
- package/src/utils/demo-generator.js +1 -1
- package/src/utils/excel-generator.js +1 -1
- package/src/utils/excel-parser.js +1 -1
- package/src/utils/file-watcher.js +1 -1
- package/src/utils/id-generator.js +1 -1
- package/src/utils/idempotency-manager.js +1 -1
- package/src/utils/import-validator.js +1 -1
- package/src/utils/license-client.js +1 -1
- package/src/utils/lock-manager.js +1 -1
- package/src/utils/logger.js +1 -1
- package/src/utils/lookup-resolver.js +1 -1
- package/src/utils/payload-loader.js +1 -1
- package/src/utils/processor-response.js +1 -1
- package/src/utils/rabbitmq.js +1 -1
- package/src/utils/redis-client.js +1 -1
- package/src/utils/redis-helper.js +1 -1
- package/src/utils/request-scope.js +1 -1
- package/src/utils/security-checks.js +1 -1
- package/src/utils/service-resolver.js +1 -1
- package/src/utils/shutdown-coordinator.js +1 -1
- package/src/utils/trusted-keys.js +1 -1
- package/src/utils/upload-handler.js +1 -1
- package/src/utils/upsert-builder.js +1 -1
- package/src/utils/workflow-hook-executor.js +1 -1
- package/generators/metadata/global.json +0 -58
- package/generators/metadata/test-mysql-workbench.json +0 -118
- package/generators/metadata/test-mysql.json +0 -56
- package/generators/metadata/test-oracle-workbench.json +0 -118
- package/generators/metadata/test-oracle.json +0 -56
- package/generators/metadata/test-pg-workbench.json +0 -118
- package/generators/metadata/test-pg.json +0 -56
- package/generators/scripts/obfuscate-source.js +0 -356
- package/generators/scripts/validate-catalog.js +0 -430
- package/generators/scripts/validate-dbschema-catalog.js +0 -708
- package/generators/tests/baseline/mysql/mini_inventory_item/src/models/mini-inventory/item.js +0 -944
- package/generators/tests/baseline/mysql/mini_inventory_item/src/modules/mini-inventory/item.js +0 -740
- package/generators/tests/baseline/mysql/mini_inventory_item/src/modules/mini-inventory.js +0 -336
- package/generators/tests/baseline/oracle/mini_inventory_item/src/models/mini-inventory/item.js +0 -1002
- package/generators/tests/baseline/oracle/mini_inventory_item/src/modules/mini-inventory/item.js +0 -740
- package/generators/tests/baseline/oracle/mini_inventory_item/src/modules/mini-inventory.js +0 -336
- package/generators/tests/baseline/postgres/mini_inventory_item/src/models/mini-inventory/item.js +0 -1333
- package/generators/tests/baseline/postgres/mini_inventory_item/src/modules/mini-inventory/item.js +0 -1173
- package/generators/tests/baseline/postgres/mini_inventory_item/src/modules/mini-inventory.js +0 -496
- package/generators/tests/fixtures/payloads/custom-sensitive.json +0 -27
- package/generators/tests/fixtures/payloads/dynamic-search-optout.json +0 -23
- package/generators/tests/fixtures/payloads/login-with-password.json +0 -22
- package/generators/tests/fixtures/payloads/order-process.json +0 -52
- package/generators/tests/fixtures/payloads/with-inline-sql.json +0 -26
- package/generators/tests/integration-tahap4b/README.md +0 -145
- package/generators/tests/integration-tahap4b/run-concurrent.js +0 -77
- package/generators/tests/integration-tahap4b/seed.sql +0 -53
- package/generators/tests/integration-tahap4b/verify.sql +0 -110
- package/generators/tests/unit/cli/create-dashboard.test.js +0 -505
- package/generators/tests/unit/cli/create-processor.test.js +0 -319
- package/generators/tests/unit/cli/dispatch-dashboard.test.js +0 -149
- package/generators/tests/unit/lib/dashboard-generator.test.js +0 -895
- package/generators/tests/unit/lib/dashboard-validator.test.js +0 -354
- package/generators/tests/unit/lib/dbschema-kit/apply-executor.test.js +0 -437
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-introspect.test.js +0 -393
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-generate-ddl.test.js +0 -104
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-init.test.js +0 -119
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-list.test.js +0 -48
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-migrate.test.js +0 -175
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-kit-validate.test.js +0 -102
- package/generators/tests/unit/lib/dbschema-kit/cli/dbschema-models.test.js +0 -43
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/all-schemas-listing.js +0 -84
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/connection-error.js +0 -13
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/empty.js +0 -12
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/multi-schema.js +0 -124
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/single-schema-inventory.js +0 -64
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/introspect-stubs/two-tables.js +0 -66
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/connection-error.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/partial.js +0 -29
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/rollback.js +0 -26
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/migrate-stubs/success.js +0 -43
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/multi-schema/audit/events.js +0 -18
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/multi-schema/inventory/products.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/cli/fixtures/multi-schema/users.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/connection.test.js +0 -112
- package/generators/tests/unit/lib/dbschema-kit/ddl-generator.test.js +0 -205
- package/generators/tests/unit/lib/dbschema-kit/define-model.test.js +0 -56
- package/generators/tests/unit/lib/dbschema-kit/dialect/index.test.js +0 -46
- package/generators/tests/unit/lib/dbschema-kit/dialect/mysql.test.js +0 -126
- package/generators/tests/unit/lib/dbschema-kit/dialect/oracle.test.js +0 -126
- package/generators/tests/unit/lib/dbschema-kit/dialect/postgres.test.js +0 -131
- package/generators/tests/unit/lib/dbschema-kit/dialect/sqlite.test.js +0 -126
- package/generators/tests/unit/lib/dbschema-kit/driver-loader.test.js +0 -93
- package/generators/tests/unit/lib/dbschema-kit/emitters/create-index.test.js +0 -173
- package/generators/tests/unit/lib/dbschema-kit/emitters/create-table.test.js +0 -376
- package/generators/tests/unit/lib/dbschema-kit/emitters/drop-table.test.js +0 -78
- package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/invalid-dialect.env +0 -6
- package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/missing-dialect.env +0 -5
- package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/missing-host.env +0 -5
- package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/oracle-valid.env +0 -6
- package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/postgres-valid.env +0 -7
- package/generators/tests/unit/lib/dbschema-kit/fixtures/connection/sqlite-valid.env +0 -2
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/category.js +0 -11
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/item_product.js +0 -11
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/stock_inbound.js +0 -24
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/stock_inbound_item.js +0 -28
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/supplier.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory/warehouse.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-invalid/orphan.js +0 -17
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/category.js +0 -11
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/item_product.js +0 -11
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/supplier.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/master/warehouse.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/transactions/stock_inbound.js +0 -24
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/mini-inventory-multifolder/transactions/stock_inbound_item.js +0 -28
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/multi-schema/audit/events.js +0 -18
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/multi-schema/inventory/products.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/integration/multi-schema/public/users.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-subfolder/extra/category.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-subfolder/master/category.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-tablename/bar.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/duplicate-tablename/foo.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/empty-folder/README.md +0 -1
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/invalid-export/plain.js +0 -3
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/invalid-schema/bad.js +0 -6
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/legacy-pattern/legacy.js +0 -12
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-distinct/audit/products.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-distinct/inventory/products.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-duplicate/a/products.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/multi-schema-duplicate/b/products.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/nested-deep/a/b/c/deep_table.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/.hidden/ignored.js +0 -7
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/master/category.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/master/supplier.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/transactions/stock_inbound.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/recursive-multi-folder/transactions/stock_inbound_item.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/valid-multiple/category.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/valid-multiple/item_product.js +0 -9
- package/generators/tests/unit/lib/dbschema-kit/fixtures/loader/valid-single/category.js +0 -8
- package/generators/tests/unit/lib/dbschema-kit/integration.test.js +0 -217
- package/generators/tests/unit/lib/dbschema-kit/introspect-mapper.test.js +0 -403
- package/generators/tests/unit/lib/dbschema-kit/ir-builder.test.js +0 -390
- package/generators/tests/unit/lib/dbschema-kit/loader.test.js +0 -128
- package/generators/tests/unit/lib/dbschema-kit/naming.test.js +0 -170
- package/generators/tests/unit/lib/dbschema-kit/parser/shorthand-parser.test.js +0 -237
- package/generators/tests/unit/lib/dbschema-kit/schema-printer.test.js +0 -251
- package/generators/tests/unit/lib/dbschema-kit/statement-modifier.test.js +0 -105
- package/generators/tests/unit/lib/dbschema-kit/statement-splitter.test.js +0 -165
- package/generators/tests/unit/lib/dbschema-kit/topological-sort.test.js +0 -135
- package/generators/tests/unit/lib/dbschema-kit/validator/check-compatibility-validator.test.js +0 -373
- package/generators/tests/unit/lib/dbschema-kit/validator/circular-relation-validator.test.js +0 -454
- package/generators/tests/unit/lib/dbschema-kit/validator/cross-model-validator.test.js +0 -512
- package/generators/tests/unit/lib/dbschema-kit/validator/enhanced-validate-integration.test.js +0 -390
- package/generators/tests/unit/lib/dbschema-kit/validator/naming-convention-validator.test.js +0 -306
- package/generators/tests/unit/lib/dbschema-kit/validator/schema-validator.test.js +0 -443
- package/generators/tests/unit/lib/dbschema-kit/validator/type-compatibility-validator.test.js +0 -440
- package/generators/tests/unit/lib/dbschema-kit/validator/validator-reporter.test.js +0 -172
- package/generators/tests/unit/lib/metadata-manager-dashboard.test.js +0 -256
- package/generators/tests/unit/lib/payload-validator-fieldpolicy.test.js +0 -240
- package/generators/tests/unit/lib/processor-validation-generator.test.js +0 -300
- package/generators/tests/unit/lib/sensitive-field-masker.test.js +0 -170
- package/generators/tests/unit/lib/sql-table-extractor.test.js +0 -119
- package/scripts/generate-integrity-manifest.js +0 -124
- package/scripts/snapshot-cli-contracts.js +0 -194
- package/scripts/verify-publish.js +0 -56
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const test = require('node:test');
|
|
4
|
-
const assert = require('node:assert');
|
|
5
|
-
|
|
6
|
-
const { buildIR } = require('../../../../../lib/dbschema-kit/ir-builder');
|
|
7
|
-
const { validateSchema } = require('../../../../../lib/dbschema-kit/validator/schema-validator');
|
|
8
|
-
|
|
9
|
-
// =====================================================
|
|
10
|
-
// Group 1: Table Level
|
|
11
|
-
// =====================================================
|
|
12
|
-
|
|
13
|
-
test('validator: tableName snake_case + ada PK tidak throw', () => {
|
|
14
|
-
const ir = buildIR('stock_inbound', { fields: { id: 'uuid pk' } });
|
|
15
|
-
assert.doesNotThrow(() => validateSchema(ir));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('validator: tableName mengandung uppercase harus throw', () => {
|
|
19
|
-
const ir = buildIR('StockInbound', { fields: { id: 'uuid pk' } });
|
|
20
|
-
assert.throws(
|
|
21
|
-
() => validateSchema(ir),
|
|
22
|
-
/^Error: Table name must be snake_case \(lowercase, alphanumeric, underscore, no leading digit\)$/
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('validator: tableName leading digit harus throw', () => {
|
|
27
|
-
const ir = buildIR('1foo', { fields: { id: 'uuid pk' } });
|
|
28
|
-
assert.throws(
|
|
29
|
-
() => validateSchema(ir),
|
|
30
|
-
/^Error: Table name must be snake_case \(lowercase, alphanumeric, underscore, no leading digit\)$/
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("validator: konflik 'pk' shorthand + 'primaryKey' option harus throw", () => {
|
|
35
|
-
const ir = buildIR('foo', {
|
|
36
|
-
fields: { a: 'uuid pk', b: 'uuid' },
|
|
37
|
-
primaryKey: ['a', 'b']
|
|
38
|
-
});
|
|
39
|
-
assert.throws(
|
|
40
|
-
() => validateSchema(ir),
|
|
41
|
-
/^Error: Table 'foo': cannot use 'pk' shorthand together with 'primaryKey' option$/
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// =====================================================
|
|
46
|
-
// Group 2: Field References Existence
|
|
47
|
-
// =====================================================
|
|
48
|
-
|
|
49
|
-
test('validator: primaryKey reference field tidak existing harus throw', () => {
|
|
50
|
-
const ir = buildIR('foo', {
|
|
51
|
-
fields: { a: 'uuid', b: 'uuid' },
|
|
52
|
-
primaryKey: ['a', 'nonexistent']
|
|
53
|
-
});
|
|
54
|
-
assert.throws(
|
|
55
|
-
() => validateSchema(ir),
|
|
56
|
-
/^Error: Table 'foo': primaryKey references unknown field 'nonexistent'$/
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('validator: indexes reference field tidak existing harus throw', () => {
|
|
61
|
-
const ir = buildIR('foo', {
|
|
62
|
-
fields: { id: 'uuid pk', name: 'string:50' },
|
|
63
|
-
indexes: ['nonexistent']
|
|
64
|
-
});
|
|
65
|
-
assert.throws(
|
|
66
|
-
() => validateSchema(ir),
|
|
67
|
-
/^Error: Table 'foo': index references unknown field 'nonexistent'$/
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('validator: uniques reference field tidak existing harus throw', () => {
|
|
72
|
-
const ir = buildIR('foo', {
|
|
73
|
-
fields: { id: 'uuid pk', a: 'string:50' },
|
|
74
|
-
uniques: [['a', 'nonexistent']]
|
|
75
|
-
});
|
|
76
|
-
assert.throws(
|
|
77
|
-
() => validateSchema(ir),
|
|
78
|
-
/^Error: Table 'foo': unique constraint references unknown field 'nonexistent'$/
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('validator: relations.localKey reference field tidak existing harus throw', () => {
|
|
83
|
-
const ir = buildIR('foo', {
|
|
84
|
-
fields: { id: 'uuid pk' },
|
|
85
|
-
relations: {
|
|
86
|
-
bar: { type: 'belongsTo', localKey: 'nonexistent_field', references: 'id' }
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
assert.throws(
|
|
90
|
-
() => validateSchema(ir),
|
|
91
|
-
/^Error: Table 'foo': relation 'bar' references unknown field 'nonexistent_field'$/
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('validator: checks.field reference field tidak existing harus throw', () => {
|
|
96
|
-
const ir = buildIR('foo', {
|
|
97
|
-
fields: { id: 'uuid pk' },
|
|
98
|
-
checks: [{ field: 'nonexistent', gt: 0 }]
|
|
99
|
-
});
|
|
100
|
-
assert.throws(
|
|
101
|
-
() => validateSchema(ir),
|
|
102
|
-
/^Error: Table 'foo': check at index 0 references unknown field 'nonexistent'$/
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// =====================================================
|
|
107
|
-
// Group 3: Relations
|
|
108
|
-
// =====================================================
|
|
109
|
-
|
|
110
|
-
test('validator: relation tanpa type atau type invalid harus throw', () => {
|
|
111
|
-
const ir = buildIR('foo', {
|
|
112
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
113
|
-
relations: {
|
|
114
|
-
bar: { localKey: 'a', references: 'id' }
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
assert.throws(
|
|
118
|
-
() => validateSchema(ir),
|
|
119
|
-
/^Error: Table 'foo': relation 'bar' has invalid or missing type 'undefined'$/
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
const ir2 = buildIR('foo', {
|
|
123
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
124
|
-
relations: {
|
|
125
|
-
bar: { type: 'belongsToMany', localKey: 'a', references: 'id' }
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
assert.throws(
|
|
129
|
-
() => validateSchema(ir2),
|
|
130
|
-
/^Error: Table 'foo': relation 'bar' has invalid or missing type 'belongsToMany'$/
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('validator: relation tanpa localKey harus throw', () => {
|
|
135
|
-
const ir = buildIR('foo', {
|
|
136
|
-
fields: { id: 'uuid pk' },
|
|
137
|
-
relations: {
|
|
138
|
-
bar: { type: 'belongsTo', references: 'id' }
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
assert.throws(
|
|
142
|
-
() => validateSchema(ir),
|
|
143
|
-
/^Error: Table 'foo': relation 'bar' missing 'localKey' property$/
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('validator: relation tanpa references harus throw', () => {
|
|
148
|
-
const ir = buildIR('foo', {
|
|
149
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
150
|
-
relations: {
|
|
151
|
-
bar: { type: 'belongsTo', localKey: 'a' }
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
assert.throws(
|
|
155
|
-
() => validateSchema(ir),
|
|
156
|
-
/^Error: Table 'foo': relation 'bar' missing 'references' property$/
|
|
157
|
-
);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('validator: invalid onDelete value harus throw', () => {
|
|
161
|
-
const ir = buildIR('foo', {
|
|
162
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
163
|
-
relations: {
|
|
164
|
-
bar: { type: 'belongsTo', localKey: 'a', references: 'id', onDelete: 'set null' }
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
assert.throws(
|
|
168
|
-
() => validateSchema(ir),
|
|
169
|
-
/^Error: Table 'foo': relation 'bar' has invalid onDelete 'set null'$/
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const ir2 = buildIR('foo', {
|
|
173
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
174
|
-
relations: {
|
|
175
|
-
bar: { type: 'belongsTo', localKey: 'a', references: 'id', onDelete: 'SET_NULL' }
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
assert.throws(
|
|
179
|
-
() => validateSchema(ir2),
|
|
180
|
-
/^Error: Table 'foo': relation 'bar' has invalid onDelete 'SET_NULL'$/
|
|
181
|
-
);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test('validator: invalid onUpdate value harus throw', () => {
|
|
185
|
-
const ir = buildIR('foo', {
|
|
186
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
187
|
-
relations: {
|
|
188
|
-
bar: { type: 'belongsTo', localKey: 'a', references: 'id', onUpdate: 'cascadex' }
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
assert.throws(
|
|
192
|
-
() => validateSchema(ir),
|
|
193
|
-
/^Error: Table 'foo': relation 'bar' has invalid onUpdate 'cascadex'$/
|
|
194
|
-
);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test("validator: mutual exclusivity 'fk:' shorthand + relations[*].localKey harus throw", () => {
|
|
198
|
-
const ir = buildIR('item_product', {
|
|
199
|
-
fields: {
|
|
200
|
-
id: 'uuid pk',
|
|
201
|
-
category_id: 'string:36 fk:category.category_id'
|
|
202
|
-
},
|
|
203
|
-
relations: {
|
|
204
|
-
category: {
|
|
205
|
-
type: 'belongsTo',
|
|
206
|
-
localKey: 'category_id',
|
|
207
|
-
references: 'category_id',
|
|
208
|
-
onDelete: 'cascade'
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
assert.throws(
|
|
213
|
-
() => validateSchema(ir),
|
|
214
|
-
/^Error: Table 'item_product': field 'category_id' has 'fk:' shorthand and is also referenced by relation 'category'\. Use only one declaration method\.$/
|
|
215
|
-
);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test("validator: auto-generated relation dengan suffix '_auto' harus throw collision", () => {
|
|
219
|
-
const ir = buildIR('foo', {
|
|
220
|
-
fields: {
|
|
221
|
-
id: 'uuid pk',
|
|
222
|
-
b_id: 'string:36 fk:b_table.id',
|
|
223
|
-
other: 'uuid'
|
|
224
|
-
},
|
|
225
|
-
relations: {
|
|
226
|
-
b: { type: 'belongsTo', localKey: 'other', references: 'id' }
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
assert.throws(
|
|
230
|
-
() => validateSchema(ir),
|
|
231
|
-
/^Error: Table 'foo': auto-generated relation name 'b' from field 'b_id' conflicts with explicit relation 'b'\. Rename one of them\.$/
|
|
232
|
-
);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
test('validator: duplikat localKey di dua relations eksplisit harus throw', () => {
|
|
236
|
-
const ir = buildIR('foo', {
|
|
237
|
-
fields: { id: 'uuid pk', a: 'uuid' },
|
|
238
|
-
relations: {
|
|
239
|
-
rel1: { type: 'belongsTo', localKey: 'a', references: 'id' },
|
|
240
|
-
rel2: { type: 'belongsTo', localKey: 'a', references: 'id' }
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
assert.throws(
|
|
244
|
-
() => validateSchema(ir),
|
|
245
|
-
/^Error: Table 'foo': field 'a' is referenced by multiple relations: rel1, rel2$/
|
|
246
|
-
);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// =====================================================
|
|
250
|
-
// Group 4: Checks
|
|
251
|
-
// =====================================================
|
|
252
|
-
|
|
253
|
-
test("validator: check dengan _invalid 'multiple operators' harus throw", () => {
|
|
254
|
-
const ir = buildIR('foo', {
|
|
255
|
-
fields: { id: 'uuid pk', x: 'integer' },
|
|
256
|
-
checks: [{ field: 'x', gt: 0, lt: 100 }]
|
|
257
|
-
});
|
|
258
|
-
assert.throws(
|
|
259
|
-
() => validateSchema(ir),
|
|
260
|
-
/^Error: Table 'foo': check at index 0 has multiple operators \(use one of: in, gt, gte, lt, lte, eq, neq\)$/
|
|
261
|
-
);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
test("validator: check dengan _invalid 'no operator' harus throw", () => {
|
|
265
|
-
const ir = buildIR('foo', {
|
|
266
|
-
fields: { id: 'uuid pk', x: 'integer' },
|
|
267
|
-
checks: [{ field: 'x' }]
|
|
268
|
-
});
|
|
269
|
-
assert.throws(
|
|
270
|
-
() => validateSchema(ir),
|
|
271
|
-
/^Error: Table 'foo': check at index 0 must have exactly one operator \(use one of: in, gt, gte, lt, lte, eq, neq\)$/
|
|
272
|
-
);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
test("validator: operator 'in' value bukan array atau array kosong harus throw", () => {
|
|
276
|
-
const ir = buildIR('foo', {
|
|
277
|
-
fields: { id: 'uuid pk', status: 'string:20' },
|
|
278
|
-
checks: [{ field: 'status', in: 'draft' }]
|
|
279
|
-
});
|
|
280
|
-
assert.throws(
|
|
281
|
-
() => validateSchema(ir),
|
|
282
|
-
/^Error: Table 'foo': check at index 0 operator 'in' requires non-empty array of values$/
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
const ir2 = buildIR('foo', {
|
|
286
|
-
fields: { id: 'uuid pk', status: 'string:20' },
|
|
287
|
-
checks: [{ field: 'status', in: [] }]
|
|
288
|
-
});
|
|
289
|
-
assert.throws(
|
|
290
|
-
() => validateSchema(ir2),
|
|
291
|
-
/^Error: Table 'foo': check at index 0 operator 'in' requires non-empty array of values$/
|
|
292
|
-
);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("validator: operator 'gt' value non-number harus throw", () => {
|
|
296
|
-
const ir = buildIR('foo', {
|
|
297
|
-
fields: { id: 'uuid pk', x: 'integer' },
|
|
298
|
-
checks: [{ field: 'x', gt: '0' }]
|
|
299
|
-
});
|
|
300
|
-
assert.throws(
|
|
301
|
-
() => validateSchema(ir),
|
|
302
|
-
/^Error: Table 'foo': check at index 0 operator 'gt' requires numeric value, got 'string'$/
|
|
303
|
-
);
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// =====================================================
|
|
307
|
-
// Group 5: AutoUpdate
|
|
308
|
-
// =====================================================
|
|
309
|
-
|
|
310
|
-
test("validator: autoUpdate di field type 'string' harus throw", () => {
|
|
311
|
-
const ir = buildIR('foo', {
|
|
312
|
-
fields: {
|
|
313
|
-
id: 'uuid pk',
|
|
314
|
-
name: 'string:50 autoUpdate'
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
assert.throws(
|
|
318
|
-
() => validateSchema(ir),
|
|
319
|
-
/^Error: Table 'foo': field 'name' constraint 'autoUpdate' only valid for type 'timestamp' or 'date', got 'string'$/
|
|
320
|
-
);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
test("validator: autoUpdate di field type 'integer' harus throw", () => {
|
|
324
|
-
const ir = buildIR('foo', {
|
|
325
|
-
fields: {
|
|
326
|
-
id: 'uuid pk',
|
|
327
|
-
counter: 'integer autoUpdate'
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
assert.throws(
|
|
331
|
-
() => validateSchema(ir),
|
|
332
|
-
/^Error: Table 'foo': field 'counter' constraint 'autoUpdate' only valid for type 'timestamp' or 'date', got 'integer'$/
|
|
333
|
-
);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test("validator: autoUpdate + default:now() di field timestamp harus throw", () => {
|
|
337
|
-
const ir = buildIR('foo', {
|
|
338
|
-
fields: {
|
|
339
|
-
id: 'uuid pk',
|
|
340
|
-
updated_at: 'timestamp default:now() autoUpdate'
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
assert.throws(
|
|
344
|
-
() => validateSchema(ir),
|
|
345
|
-
/^Error: Table 'foo': field 'updated_at' constraint 'autoUpdate' cannot be combined with 'default:'$/
|
|
346
|
-
);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// =====================================================
|
|
350
|
-
// Bonus: Complex valid schema
|
|
351
|
-
// =====================================================
|
|
352
|
-
|
|
353
|
-
test('validator: schema valid kompleks (multiple relations, indexes, uniques, checks) tidak throw', () => {
|
|
354
|
-
const ir = buildIR('stock_inbound_item', {
|
|
355
|
-
fields: {
|
|
356
|
-
stock_inbound_item_id: 'uuid pk',
|
|
357
|
-
stock_inbound_id: 'uuid notnull',
|
|
358
|
-
line_number: 'integer notnull',
|
|
359
|
-
item_product_id: 'uuid notnull',
|
|
360
|
-
qty_received: 'decimal:15,0 notnull default:0',
|
|
361
|
-
uom: "string:10 default:'pcs'",
|
|
362
|
-
unit_price: 'decimal:15,2 default:0',
|
|
363
|
-
total_amount: 'decimal:15,2 default:0',
|
|
364
|
-
status: "string:20 default:'draft'",
|
|
365
|
-
notes: 'text',
|
|
366
|
-
created_at: 'timestamp',
|
|
367
|
-
updated_at: 'timestamp autoUpdate'
|
|
368
|
-
},
|
|
369
|
-
uniques: [['stock_inbound_id', 'line_number']],
|
|
370
|
-
indexes: ['stock_inbound_id', 'item_product_id', ['stock_inbound_id', 'item_product_id']],
|
|
371
|
-
relations: {
|
|
372
|
-
header: {
|
|
373
|
-
type: 'belongsTo',
|
|
374
|
-
target: 'stock_inbound',
|
|
375
|
-
localKey: 'stock_inbound_id',
|
|
376
|
-
references: 'stock_inbound_id',
|
|
377
|
-
onDelete: 'cascade'
|
|
378
|
-
},
|
|
379
|
-
product: {
|
|
380
|
-
type: 'belongsTo',
|
|
381
|
-
target: 'item_product',
|
|
382
|
-
localKey: 'item_product_id',
|
|
383
|
-
references: 'item_product_id',
|
|
384
|
-
onDelete: 'restrict'
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
checks: [
|
|
388
|
-
{ field: 'status', in: ['draft', 'confirmed', 'closed', 'cancelled'] },
|
|
389
|
-
{ field: 'line_number', gt: 0 },
|
|
390
|
-
{ field: 'unit_price', gte: 0 }
|
|
391
|
-
]
|
|
392
|
-
});
|
|
393
|
-
let result;
|
|
394
|
-
assert.doesNotThrow(() => {
|
|
395
|
-
result = validateSchema(ir);
|
|
396
|
-
});
|
|
397
|
-
assert.strictEqual(result, undefined, 'validateSchema returns undefined on success');
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// =====================================================
|
|
401
|
-
// Phase 13: schema namespace support
|
|
402
|
-
// =====================================================
|
|
403
|
-
|
|
404
|
-
test('validator: schema valid (snake_case) tidak throw, IR berisi schemaName', () => {
|
|
405
|
-
const ir = buildIR('products', {
|
|
406
|
-
schema: 'inventory',
|
|
407
|
-
fields: { id: 'uuid pk' }
|
|
408
|
-
});
|
|
409
|
-
assert.doesNotThrow(() => validateSchema(ir));
|
|
410
|
-
assert.strictEqual(ir.schemaName, 'inventory');
|
|
411
|
-
assert.strictEqual(ir.qualifiedName, 'inventory.products');
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
test('validator: schema mengandung uppercase atau hyphen harus throw', () => {
|
|
415
|
-
const ir = buildIR('products', {
|
|
416
|
-
schema: 'INVALID-NAME',
|
|
417
|
-
fields: { id: 'uuid pk' }
|
|
418
|
-
});
|
|
419
|
-
assert.throws(
|
|
420
|
-
() => validateSchema(ir),
|
|
421
|
-
/^Error: Table 'INVALID-NAME\.products': invalid schema name 'INVALID-NAME'$/
|
|
422
|
-
);
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
test('validator: schema empty string harus throw', () => {
|
|
426
|
-
// Empty string is treated as null by IR builder (default null), so it does NOT throw.
|
|
427
|
-
// Use explicit invalid string for the negative test.
|
|
428
|
-
const ir = buildIR('products', {
|
|
429
|
-
schema: '_starts_with_underscore',
|
|
430
|
-
fields: { id: 'uuid pk' }
|
|
431
|
-
});
|
|
432
|
-
assert.throws(
|
|
433
|
-
() => validateSchema(ir),
|
|
434
|
-
/^Error: Table '_starts_with_underscore\.products': invalid schema name '_starts_with_underscore'$/
|
|
435
|
-
);
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
test('validator: tanpa schema → IR.schemaName null, qualifiedName == tableName, no error', () => {
|
|
439
|
-
const ir = buildIR('products', { fields: { id: 'uuid pk' } });
|
|
440
|
-
assert.strictEqual(ir.schemaName, null);
|
|
441
|
-
assert.strictEqual(ir.qualifiedName, 'products');
|
|
442
|
-
assert.doesNotThrow(() => validateSchema(ir));
|
|
443
|
-
});
|