blendsdk 5.33.0
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/README.md +125 -0
- package/dist/cmdline/cmdline.d.ts +144 -0
- package/dist/cmdline/cmdline.d.ts.map +1 -0
- package/dist/cmdline/cmdline.js +683 -0
- package/dist/cmdline/cmdline.js.map +1 -0
- package/dist/cmdline/errors.d.ts +105 -0
- package/dist/cmdline/errors.d.ts.map +1 -0
- package/dist/cmdline/errors.js +153 -0
- package/dist/cmdline/errors.js.map +1 -0
- package/dist/cmdline/index.d.ts +5 -0
- package/dist/cmdline/index.d.ts.map +1 -0
- package/dist/cmdline/index.js +5 -0
- package/dist/cmdline/index.js.map +1 -0
- package/dist/cmdline/types.d.ts +260 -0
- package/dist/cmdline/types.d.ts.map +1 -0
- package/dist/cmdline/types.js +9 -0
- package/dist/cmdline/types.js.map +1 -0
- package/dist/cmdline/validators.d.ts +28 -0
- package/dist/cmdline/validators.d.ts.map +1 -0
- package/dist/cmdline/validators.js +211 -0
- package/dist/cmdline/validators.js.map +1 -0
- package/dist/codegen/database/index.d.ts +3 -0
- package/dist/codegen/database/index.d.ts.map +1 -0
- package/dist/codegen/database/index.js +3 -0
- package/dist/codegen/database/index.js.map +1 -0
- package/dist/codegen/database/introspect/index.d.ts +3 -0
- package/dist/codegen/database/introspect/index.d.ts.map +1 -0
- package/dist/codegen/database/introspect/index.js +3 -0
- package/dist/codegen/database/introspect/index.js.map +1 -0
- package/dist/codegen/database/introspect/introspect-query.d.ts +2 -0
- package/dist/codegen/database/introspect/introspect-query.d.ts.map +1 -0
- package/dist/codegen/database/introspect/introspect-query.js +416 -0
- package/dist/codegen/database/introspect/introspect-query.js.map +1 -0
- package/dist/codegen/database/introspect/introspect-types.d.ts +45 -0
- package/dist/codegen/database/introspect/introspect-types.d.ts.map +1 -0
- package/dist/codegen/database/introspect/introspect-types.js +2 -0
- package/dist/codegen/database/introspect/introspect-types.js.map +1 -0
- package/dist/codegen/database/introspect/introspect.d.ts +21 -0
- package/dist/codegen/database/introspect/introspect.d.ts.map +1 -0
- package/dist/codegen/database/introspect/introspect.js +223 -0
- package/dist/codegen/database/introspect/introspect.js.map +1 -0
- package/dist/codegen/database/schema/check-constraint.d.ts +8 -0
- package/dist/codegen/database/schema/check-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/check-constraint.js +12 -0
- package/dist/codegen/database/schema/check-constraint.js.map +1 -0
- package/dist/codegen/database/schema/column-schema.d.ts +7 -0
- package/dist/codegen/database/schema/column-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/column-schema.js +9 -0
- package/dist/codegen/database/schema/column-schema.js.map +1 -0
- package/dist/codegen/database/schema/constraint-base.d.ts +13 -0
- package/dist/codegen/database/schema/constraint-base.d.ts.map +1 -0
- package/dist/codegen/database/schema/constraint-base.js +32 -0
- package/dist/codegen/database/schema/constraint-base.js.map +1 -0
- package/dist/codegen/database/schema/database-schema.d.ts +19 -0
- package/dist/codegen/database/schema/database-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/database-schema.js +48 -0
- package/dist/codegen/database/schema/database-schema.js.map +1 -0
- package/dist/codegen/database/schema/dataobject-schema.d.ts +9 -0
- package/dist/codegen/database/schema/dataobject-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/dataobject-schema.js +18 -0
- package/dist/codegen/database/schema/dataobject-schema.js.map +1 -0
- package/dist/codegen/database/schema/fkey-constraints.d.ts +21 -0
- package/dist/codegen/database/schema/fkey-constraints.d.ts.map +1 -0
- package/dist/codegen/database/schema/fkey-constraints.js +58 -0
- package/dist/codegen/database/schema/fkey-constraints.js.map +1 -0
- package/dist/codegen/database/schema/index-constraint.d.ts +34 -0
- package/dist/codegen/database/schema/index-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/index-constraint.js +79 -0
- package/dist/codegen/database/schema/index-constraint.js.map +1 -0
- package/dist/codegen/database/schema/index.d.ts +5 -0
- package/dist/codegen/database/schema/index.d.ts.map +1 -0
- package/dist/codegen/database/schema/index.js +5 -0
- package/dist/codegen/database/schema/index.js.map +1 -0
- package/dist/codegen/database/schema/primarykey-constraint.d.ts +4 -0
- package/dist/codegen/database/schema/primarykey-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/primarykey-constraint.js +4 -0
- package/dist/codegen/database/schema/primarykey-constraint.js.map +1 -0
- package/dist/codegen/database/schema/relation-schema.d.ts +16 -0
- package/dist/codegen/database/schema/relation-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/relation-schema.js +32 -0
- package/dist/codegen/database/schema/relation-schema.js.map +1 -0
- package/dist/codegen/database/schema/table-column-schema.d.ts +59 -0
- package/dist/codegen/database/schema/table-column-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/table-column-schema.js +137 -0
- package/dist/codegen/database/schema/table-column-schema.js.map +1 -0
- package/dist/codegen/database/schema/table-schema.d.ts +48 -0
- package/dist/codegen/database/schema/table-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/table-schema.js +219 -0
- package/dist/codegen/database/schema/table-schema.js.map +1 -0
- package/dist/codegen/database/schema/types.d.ts +13 -0
- package/dist/codegen/database/schema/types.d.ts.map +1 -0
- package/dist/codegen/database/schema/types.js +175 -0
- package/dist/codegen/database/schema/types.js.map +1 -0
- package/dist/codegen/database/schema/unique-constraint.d.ts +4 -0
- package/dist/codegen/database/schema/unique-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/unique-constraint.js +4 -0
- package/dist/codegen/database/schema/unique-constraint.js.map +1 -0
- package/dist/codegen/database/schema/view-schema.d.ts +14 -0
- package/dist/codegen/database/schema/view-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/view-schema.js +32 -0
- package/dist/codegen/database/schema/view-schema.js.map +1 -0
- package/dist/codegen/generator/ctype-generator.d.ts +5 -0
- package/dist/codegen/generator/ctype-generator.d.ts.map +1 -0
- package/dist/codegen/generator/ctype-generator.js +26 -0
- package/dist/codegen/generator/ctype-generator.js.map +1 -0
- package/dist/codegen/generator/generator.d.ts +17 -0
- package/dist/codegen/generator/generator.d.ts.map +1 -0
- package/dist/codegen/generator/generator.js +57 -0
- package/dist/codegen/generator/generator.js.map +1 -0
- package/dist/codegen/generator/index.d.ts +8 -0
- package/dist/codegen/generator/index.d.ts.map +1 -0
- package/dist/codegen/generator/index.js +8 -0
- package/dist/codegen/generator/index.js.map +1 -0
- package/dist/codegen/generator/openapi-generator.d.ts +239 -0
- package/dist/codegen/generator/openapi-generator.d.ts.map +1 -0
- package/dist/codegen/generator/openapi-generator.js +434 -0
- package/dist/codegen/generator/openapi-generator.js.map +1 -0
- package/dist/codegen/generator/openapi-types.d.ts +263 -0
- package/dist/codegen/generator/openapi-types.d.ts.map +1 -0
- package/dist/codegen/generator/openapi-types.js +11 -0
- package/dist/codegen/generator/openapi-types.js.map +1 -0
- package/dist/codegen/generator/postgres-schema-generator.d.ts +48 -0
- package/dist/codegen/generator/postgres-schema-generator.d.ts.map +1 -0
- package/dist/codegen/generator/postgres-schema-generator.js +339 -0
- package/dist/codegen/generator/postgres-schema-generator.js.map +1 -0
- package/dist/codegen/generator/type-generator.d.ts +113 -0
- package/dist/codegen/generator/type-generator.d.ts.map +1 -0
- package/dist/codegen/generator/type-generator.js +249 -0
- package/dist/codegen/generator/type-generator.js.map +1 -0
- package/dist/codegen/generator/zod-generator.d.ts +15 -0
- package/dist/codegen/generator/zod-generator.d.ts.map +1 -0
- package/dist/codegen/generator/zod-generator.js +86 -0
- package/dist/codegen/generator/zod-generator.js.map +1 -0
- package/dist/codegen/generator/zod-to-openapi.d.ts +69 -0
- package/dist/codegen/generator/zod-to-openapi.d.ts.map +1 -0
- package/dist/codegen/generator/zod-to-openapi.js +480 -0
- package/dist/codegen/generator/zod-to-openapi.js.map +1 -0
- package/dist/codegen/index.d.ts +4 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +4 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/schema/any-schema.d.ts +6 -0
- package/dist/codegen/schema/any-schema.d.ts.map +1 -0
- package/dist/codegen/schema/any-schema.js +12 -0
- package/dist/codegen/schema/any-schema.js.map +1 -0
- package/dist/codegen/schema/boolean-schema.d.ts +6 -0
- package/dist/codegen/schema/boolean-schema.d.ts.map +1 -0
- package/dist/codegen/schema/boolean-schema.js +12 -0
- package/dist/codegen/schema/boolean-schema.js.map +1 -0
- package/dist/codegen/schema/date-schema.d.ts +6 -0
- package/dist/codegen/schema/date-schema.d.ts.map +1 -0
- package/dist/codegen/schema/date-schema.js +12 -0
- package/dist/codegen/schema/date-schema.js.map +1 -0
- package/dist/codegen/schema/index.d.ts +10 -0
- package/dist/codegen/schema/index.d.ts.map +1 -0
- package/dist/codegen/schema/index.js +10 -0
- package/dist/codegen/schema/index.js.map +1 -0
- package/dist/codegen/schema/object-schema.d.ts +10 -0
- package/dist/codegen/schema/object-schema.d.ts.map +1 -0
- package/dist/codegen/schema/object-schema.js +21 -0
- package/dist/codegen/schema/object-schema.js.map +1 -0
- package/dist/codegen/schema/primitive-schema.d.ts +20 -0
- package/dist/codegen/schema/primitive-schema.d.ts.map +1 -0
- package/dist/codegen/schema/primitive-schema.js +48 -0
- package/dist/codegen/schema/primitive-schema.js.map +1 -0
- package/dist/codegen/schema/ref-schema.d.ts +6 -0
- package/dist/codegen/schema/ref-schema.d.ts.map +1 -0
- package/dist/codegen/schema/ref-schema.js +11 -0
- package/dist/codegen/schema/ref-schema.js.map +1 -0
- package/dist/codegen/schema/schema-container.d.ts +14 -0
- package/dist/codegen/schema/schema-container.d.ts.map +1 -0
- package/dist/codegen/schema/schema-container.js +38 -0
- package/dist/codegen/schema/schema-container.js.map +1 -0
- package/dist/codegen/schema/schema-object.d.ts +42 -0
- package/dist/codegen/schema/schema-object.d.ts.map +1 -0
- package/dist/codegen/schema/schema-object.js +90 -0
- package/dist/codegen/schema/schema-object.js.map +1 -0
- package/dist/codegen/schema/schema-scope.d.ts +23 -0
- package/dist/codegen/schema/schema-scope.d.ts.map +1 -0
- package/dist/codegen/schema/schema-scope.js +67 -0
- package/dist/codegen/schema/schema-scope.js.map +1 -0
- package/dist/codegen/schema/utils.d.ts +17 -0
- package/dist/codegen/schema/utils.d.ts.map +1 -0
- package/dist/codegen/schema/utils.js +47 -0
- package/dist/codegen/schema/utils.js.map +1 -0
- package/dist/dbcore/crud-statement.d.ts +67 -0
- package/dist/dbcore/crud-statement.d.ts.map +1 -0
- package/dist/dbcore/crud-statement.js +75 -0
- package/dist/dbcore/crud-statement.js.map +1 -0
- package/dist/dbcore/database.d.ts +272 -0
- package/dist/dbcore/database.d.ts.map +1 -0
- package/dist/dbcore/database.js +53 -0
- package/dist/dbcore/database.js.map +1 -0
- package/dist/dbcore/dataservice-base.d.ts +18 -0
- package/dist/dbcore/dataservice-base.d.ts.map +1 -0
- package/dist/dbcore/dataservice-base.js +19 -0
- package/dist/dbcore/dataservice-base.js.map +1 -0
- package/dist/dbcore/delete-statement.d.ts +29 -0
- package/dist/dbcore/delete-statement.d.ts.map +1 -0
- package/dist/dbcore/delete-statement.js +30 -0
- package/dist/dbcore/delete-statement.js.map +1 -0
- package/dist/dbcore/filterable-statement.d.ts +126 -0
- package/dist/dbcore/filterable-statement.d.ts.map +1 -0
- package/dist/dbcore/filterable-statement.js +178 -0
- package/dist/dbcore/filterable-statement.js.map +1 -0
- package/dist/dbcore/from-statement.d.ts +120 -0
- package/dist/dbcore/from-statement.d.ts.map +1 -0
- package/dist/dbcore/from-statement.js +150 -0
- package/dist/dbcore/from-statement.js.map +1 -0
- package/dist/dbcore/index.d.ts +21 -0
- package/dist/dbcore/index.d.ts.map +1 -0
- package/dist/dbcore/index.js +21 -0
- package/dist/dbcore/index.js.map +1 -0
- package/dist/dbcore/insert-statement.d.ts +48 -0
- package/dist/dbcore/insert-statement.d.ts.map +1 -0
- package/dist/dbcore/insert-statement.js +52 -0
- package/dist/dbcore/insert-statement.js.map +1 -0
- package/dist/dbcore/query-dataservice.d.ts +144 -0
- package/dist/dbcore/query-dataservice.d.ts.map +1 -0
- package/dist/dbcore/query-dataservice.js +144 -0
- package/dist/dbcore/query-dataservice.js.map +1 -0
- package/dist/dbcore/statement.d.ts +133 -0
- package/dist/dbcore/statement.d.ts.map +1 -0
- package/dist/dbcore/statement.js +138 -0
- package/dist/dbcore/statement.js.map +1 -0
- package/dist/dbcore/update-statement.d.ts +48 -0
- package/dist/dbcore/update-statement.d.ts.map +1 -0
- package/dist/dbcore/update-statement.js +52 -0
- package/dist/dbcore/update-statement.js.map +1 -0
- package/dist/expression/builders/comparison-builder.d.ts +47 -0
- package/dist/expression/builders/comparison-builder.d.ts.map +1 -0
- package/dist/expression/builders/comparison-builder.js +197 -0
- package/dist/expression/builders/comparison-builder.js.map +1 -0
- package/dist/expression/builders/query-builder.d.ts +80 -0
- package/dist/expression/builders/query-builder.d.ts.map +1 -0
- package/dist/expression/builders/query-builder.js +229 -0
- package/dist/expression/builders/query-builder.js.map +1 -0
- package/dist/expression/compiler/postgresql-compiler.d.ts +56 -0
- package/dist/expression/compiler/postgresql-compiler.d.ts.map +1 -0
- package/dist/expression/compiler/postgresql-compiler.js +217 -0
- package/dist/expression/compiler/postgresql-compiler.js.map +1 -0
- package/dist/expression/core/ast-node.d.ts +47 -0
- package/dist/expression/core/ast-node.d.ts.map +1 -0
- package/dist/expression/core/ast-node.js +154 -0
- package/dist/expression/core/ast-node.js.map +1 -0
- package/dist/expression/core/parameter-manager.d.ts +84 -0
- package/dist/expression/core/parameter-manager.d.ts.map +1 -0
- package/dist/expression/core/parameter-manager.js +164 -0
- package/dist/expression/core/parameter-manager.js.map +1 -0
- package/dist/expression/core/query-builder-interfaces.d.ts +188 -0
- package/dist/expression/core/query-builder-interfaces.d.ts.map +1 -0
- package/dist/expression/core/query-builder-interfaces.js +6 -0
- package/dist/expression/core/query-builder-interfaces.js.map +1 -0
- package/dist/expression/core/types.d.ts +239 -0
- package/dist/expression/core/types.d.ts.map +1 -0
- package/dist/expression/core/types.js +121 -0
- package/dist/expression/core/types.js.map +1 -0
- package/dist/expression/index.d.ts +11 -0
- package/dist/expression/index.d.ts.map +1 -0
- package/dist/expression/index.js +11 -0
- package/dist/expression/index.js.map +1 -0
- package/dist/i18n/content-file-source.d.ts +109 -0
- package/dist/i18n/content-file-source.d.ts.map +1 -0
- package/dist/i18n/content-file-source.js +218 -0
- package/dist/i18n/content-file-source.js.map +1 -0
- package/dist/i18n/index.d.ts +19 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +21 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/json-file-source.d.ts +96 -0
- package/dist/i18n/json-file-source.d.ts.map +1 -0
- package/dist/i18n/json-file-source.js +258 -0
- package/dist/i18n/json-file-source.js.map +1 -0
- package/dist/i18n/merge-catalogs.d.ts +20 -0
- package/dist/i18n/merge-catalogs.d.ts.map +1 -0
- package/dist/i18n/merge-catalogs.js +34 -0
- package/dist/i18n/merge-catalogs.js.map +1 -0
- package/dist/i18n/node.d.ts +20 -0
- package/dist/i18n/node.d.ts.map +1 -0
- package/dist/i18n/node.js +19 -0
- package/dist/i18n/node.js.map +1 -0
- package/dist/i18n/translation-source.d.ts +35 -0
- package/dist/i18n/translation-source.d.ts.map +1 -0
- package/dist/i18n/translation-source.js +2 -0
- package/dist/i18n/translation-source.js.map +1 -0
- package/dist/i18n/translator.d.ts +162 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/i18n/translator.js +259 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/i18n/types.d.ts +80 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +2 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/postgresql/database.d.ts +204 -0
- package/dist/postgresql/database.d.ts.map +1 -0
- package/dist/postgresql/database.js +321 -0
- package/dist/postgresql/database.js.map +1 -0
- package/dist/postgresql/delete-statement.d.ts +36 -0
- package/dist/postgresql/delete-statement.d.ts.map +1 -0
- package/dist/postgresql/delete-statement.js +54 -0
- package/dist/postgresql/delete-statement.js.map +1 -0
- package/dist/postgresql/index.d.ts +12 -0
- package/dist/postgresql/index.d.ts.map +1 -0
- package/dist/postgresql/index.js +12 -0
- package/dist/postgresql/index.js.map +1 -0
- package/dist/postgresql/insert-statement.d.ts +34 -0
- package/dist/postgresql/insert-statement.d.ts.map +1 -0
- package/dist/postgresql/insert-statement.js +48 -0
- package/dist/postgresql/insert-statement.js.map +1 -0
- package/dist/postgresql/update-statement.d.ts +38 -0
- package/dist/postgresql/update-statement.d.ts.map +1 -0
- package/dist/postgresql/update-statement.js +75 -0
- package/dist/postgresql/update-statement.js.map +1 -0
- package/dist/stdlib/formatString.d.ts +52 -0
- package/dist/stdlib/formatString.d.ts.map +1 -0
- package/dist/stdlib/formatString.js +118 -0
- package/dist/stdlib/formatString.js.map +1 -0
- package/dist/stdlib/index.d.ts +8 -0
- package/dist/stdlib/index.d.ts.map +1 -0
- package/dist/stdlib/index.js +8 -0
- package/dist/stdlib/index.js.map +1 -0
- package/dist/stdlib/isBoolean.d.ts +15 -0
- package/dist/stdlib/isBoolean.d.ts.map +1 -0
- package/dist/stdlib/isBoolean.js +17 -0
- package/dist/stdlib/isBoolean.js.map +1 -0
- package/dist/stdlib/isNullOrUndef.d.ts +24 -0
- package/dist/stdlib/isNullOrUndef.d.ts.map +1 -0
- package/dist/stdlib/isNullOrUndef.js +28 -0
- package/dist/stdlib/isNullOrUndef.js.map +1 -0
- package/dist/stdlib/isNumeric.d.ts +20 -0
- package/dist/stdlib/isNumeric.d.ts.map +1 -0
- package/dist/stdlib/isNumeric.js +39 -0
- package/dist/stdlib/isNumeric.js.map +1 -0
- package/dist/stdlib/isString.d.ts +15 -0
- package/dist/stdlib/isString.d.ts.map +1 -0
- package/dist/stdlib/isString.js +17 -0
- package/dist/stdlib/isString.js.map +1 -0
- package/dist/stdlib/isTemplateString.d.ts +18 -0
- package/dist/stdlib/isTemplateString.d.ts.map +1 -0
- package/dist/stdlib/isTemplateString.js +38 -0
- package/dist/stdlib/isTemplateString.js.map +1 -0
- package/dist/stdlib/wrapInArray.d.ts +14 -0
- package/dist/stdlib/wrapInArray.d.ts.map +1 -0
- package/dist/stdlib/wrapInArray.js +17 -0
- package/dist/stdlib/wrapInArray.js.map +1 -0
- package/dist/webafx/application/application-settings.d.ts +129 -0
- package/dist/webafx/application/application-settings.d.ts.map +1 -0
- package/dist/webafx/application/application-settings.js +162 -0
- package/dist/webafx/application/application-settings.js.map +1 -0
- package/dist/webafx/application/base-controller.d.ts +128 -0
- package/dist/webafx/application/base-controller.d.ts.map +1 -0
- package/dist/webafx/application/base-controller.js +122 -0
- package/dist/webafx/application/base-controller.js.map +1 -0
- package/dist/webafx/application/console-logger.d.ts +81 -0
- package/dist/webafx/application/console-logger.d.ts.map +1 -0
- package/dist/webafx/application/console-logger.js +111 -0
- package/dist/webafx/application/console-logger.js.map +1 -0
- package/dist/webafx/application/controller-registry.d.ts +34 -0
- package/dist/webafx/application/controller-registry.d.ts.map +1 -0
- package/dist/webafx/application/controller-registry.js +32 -0
- package/dist/webafx/application/controller-registry.js.map +1 -0
- package/dist/webafx/application/error-handler-middleware.d.ts +22 -0
- package/dist/webafx/application/error-handler-middleware.d.ts.map +1 -0
- package/dist/webafx/application/error-handler-middleware.js +70 -0
- package/dist/webafx/application/error-handler-middleware.js.map +1 -0
- package/dist/webafx/application/index.d.ts +13 -0
- package/dist/webafx/application/index.d.ts.map +1 -0
- package/dist/webafx/application/index.js +13 -0
- package/dist/webafx/application/index.js.map +1 -0
- package/dist/webafx/application/logger.d.ts +2 -0
- package/dist/webafx/application/logger.d.ts.map +1 -0
- package/dist/webafx/application/logger.js +2 -0
- package/dist/webafx/application/logger.js.map +1 -0
- package/dist/webafx/application/plugin.d.ts +73 -0
- package/dist/webafx/application/plugin.d.ts.map +1 -0
- package/dist/webafx/application/plugin.js +90 -0
- package/dist/webafx/application/plugin.js.map +1 -0
- package/dist/webafx/application/rate-limiter.d.ts +35 -0
- package/dist/webafx/application/rate-limiter.d.ts.map +1 -0
- package/dist/webafx/application/rate-limiter.js +74 -0
- package/dist/webafx/application/rate-limiter.js.map +1 -0
- package/dist/webafx/application/request-context.d.ts +62 -0
- package/dist/webafx/application/request-context.d.ts.map +1 -0
- package/dist/webafx/application/request-context.js +54 -0
- package/dist/webafx/application/request-context.js.map +1 -0
- package/dist/webafx/application/request-id-middleware.d.ts +30 -0
- package/dist/webafx/application/request-id-middleware.d.ts.map +1 -0
- package/dist/webafx/application/request-id-middleware.js +57 -0
- package/dist/webafx/application/request-id-middleware.js.map +1 -0
- package/dist/webafx/application/route-builder.d.ts +231 -0
- package/dist/webafx/application/route-builder.d.ts.map +1 -0
- package/dist/webafx/application/route-builder.js +182 -0
- package/dist/webafx/application/route-builder.js.map +1 -0
- package/dist/webafx/application/service-container.d.ts +144 -0
- package/dist/webafx/application/service-container.d.ts.map +1 -0
- package/dist/webafx/application/service-container.js +192 -0
- package/dist/webafx/application/service-container.js.map +1 -0
- package/dist/webafx/application/services.d.ts +27 -0
- package/dist/webafx/application/services.d.ts.map +1 -0
- package/dist/webafx/application/services.js +33 -0
- package/dist/webafx/application/services.js.map +1 -0
- package/dist/webafx/application/structured-logger.d.ts +99 -0
- package/dist/webafx/application/structured-logger.d.ts.map +1 -0
- package/dist/webafx/application/structured-logger.js +132 -0
- package/dist/webafx/application/structured-logger.js.map +1 -0
- package/dist/webafx/application/type.d.ts +29 -0
- package/dist/webafx/application/type.d.ts.map +1 -0
- package/dist/webafx/application/type.js +2 -0
- package/dist/webafx/application/type.js.map +1 -0
- package/dist/webafx/application/web-application.d.ts +257 -0
- package/dist/webafx/application/web-application.d.ts.map +1 -0
- package/dist/webafx/application/web-application.js +611 -0
- package/dist/webafx/application/web-application.js.map +1 -0
- package/dist/webafx/errors/api-error.d.ts +21 -0
- package/dist/webafx/errors/api-error.d.ts.map +1 -0
- package/dist/webafx/errors/api-error.js +38 -0
- package/dist/webafx/errors/api-error.js.map +1 -0
- package/dist/webafx/errors/http-errors.d.ts +56 -0
- package/dist/webafx/errors/http-errors.d.ts.map +1 -0
- package/dist/webafx/errors/http-errors.js +74 -0
- package/dist/webafx/errors/http-errors.js.map +1 -0
- package/dist/webafx/errors/index.d.ts +4 -0
- package/dist/webafx/errors/index.d.ts.map +1 -0
- package/dist/webafx/errors/index.js +4 -0
- package/dist/webafx/errors/index.js.map +1 -0
- package/dist/webafx/errors/types.d.ts +42 -0
- package/dist/webafx/errors/types.d.ts.map +1 -0
- package/dist/webafx/errors/types.js +2 -0
- package/dist/webafx/errors/types.js.map +1 -0
- package/dist/webafx/index.d.ts +3 -0
- package/dist/webafx/index.d.ts.map +1 -0
- package/dist/webafx/index.js +3 -0
- package/dist/webafx/index.js.map +1 -0
- package/dist/webafx-auth/abstract-auth-provider.d.ts +178 -0
- package/dist/webafx-auth/abstract-auth-provider.d.ts.map +1 -0
- package/dist/webafx-auth/abstract-auth-provider.js +240 -0
- package/dist/webafx-auth/abstract-auth-provider.js.map +1 -0
- package/dist/webafx-auth/index.d.ts +27 -0
- package/dist/webafx-auth/index.d.ts.map +1 -0
- package/dist/webafx-auth/index.js +32 -0
- package/dist/webafx-auth/index.js.map +1 -0
- package/dist/webafx-auth/jwt-auth-provider.d.ts +100 -0
- package/dist/webafx-auth/jwt-auth-provider.d.ts.map +1 -0
- package/dist/webafx-auth/jwt-auth-provider.js +154 -0
- package/dist/webafx-auth/jwt-auth-provider.js.map +1 -0
- package/dist/webafx-auth/memory-auth-provider.d.ts +100 -0
- package/dist/webafx-auth/memory-auth-provider.d.ts.map +1 -0
- package/dist/webafx-auth/memory-auth-provider.js +122 -0
- package/dist/webafx-auth/memory-auth-provider.js.map +1 -0
- package/dist/webafx-auth/types.d.ts +333 -0
- package/dist/webafx-auth/types.d.ts.map +1 -0
- package/dist/webafx-auth/types.js +24 -0
- package/dist/webafx-auth/types.js.map +1 -0
- package/dist/webafx-cache/abstract-cache-provider.d.ts +185 -0
- package/dist/webafx-cache/abstract-cache-provider.d.ts.map +1 -0
- package/dist/webafx-cache/abstract-cache-provider.js +133 -0
- package/dist/webafx-cache/abstract-cache-provider.js.map +1 -0
- package/dist/webafx-cache/abstract-pubsub-provider.d.ts +170 -0
- package/dist/webafx-cache/abstract-pubsub-provider.d.ts.map +1 -0
- package/dist/webafx-cache/abstract-pubsub-provider.js +132 -0
- package/dist/webafx-cache/abstract-pubsub-provider.js.map +1 -0
- package/dist/webafx-cache/cache-plugin.d.ts +114 -0
- package/dist/webafx-cache/cache-plugin.d.ts.map +1 -0
- package/dist/webafx-cache/cache-plugin.js +176 -0
- package/dist/webafx-cache/cache-plugin.js.map +1 -0
- package/dist/webafx-cache/index.d.ts +33 -0
- package/dist/webafx-cache/index.d.ts.map +1 -0
- package/dist/webafx-cache/index.js +44 -0
- package/dist/webafx-cache/index.js.map +1 -0
- package/dist/webafx-cache/memory-cache-provider.d.ts +99 -0
- package/dist/webafx-cache/memory-cache-provider.d.ts.map +1 -0
- package/dist/webafx-cache/memory-cache-provider.js +251 -0
- package/dist/webafx-cache/memory-cache-provider.js.map +1 -0
- package/dist/webafx-cache/memory-pubsub-provider.d.ts +124 -0
- package/dist/webafx-cache/memory-pubsub-provider.d.ts.map +1 -0
- package/dist/webafx-cache/memory-pubsub-provider.js +195 -0
- package/dist/webafx-cache/memory-pubsub-provider.js.map +1 -0
- package/dist/webafx-cache/pubsub-plugin.d.ts +128 -0
- package/dist/webafx-cache/pubsub-plugin.d.ts.map +1 -0
- package/dist/webafx-cache/pubsub-plugin.js +182 -0
- package/dist/webafx-cache/pubsub-plugin.js.map +1 -0
- package/dist/webafx-cache/redis-cache-provider.d.ts +81 -0
- package/dist/webafx-cache/redis-cache-provider.d.ts.map +1 -0
- package/dist/webafx-cache/redis-cache-provider.js +209 -0
- package/dist/webafx-cache/redis-cache-provider.js.map +1 -0
- package/dist/webafx-cache/redis-pubsub-provider.d.ts +164 -0
- package/dist/webafx-cache/redis-pubsub-provider.d.ts.map +1 -0
- package/dist/webafx-cache/redis-pubsub-provider.js +329 -0
- package/dist/webafx-cache/redis-pubsub-provider.js.map +1 -0
- package/dist/webafx-cache/types.d.ts +206 -0
- package/dist/webafx-cache/types.d.ts.map +1 -0
- package/dist/webafx-cache/types.js +27 -0
- package/dist/webafx-cache/types.js.map +1 -0
- package/dist/webafx-i18n/i18n-plugin.d.ts +29 -0
- package/dist/webafx-i18n/i18n-plugin.d.ts.map +1 -0
- package/dist/webafx-i18n/i18n-plugin.js +145 -0
- package/dist/webafx-i18n/i18n-plugin.js.map +1 -0
- package/dist/webafx-i18n/index.d.ts +12 -0
- package/dist/webafx-i18n/index.d.ts.map +1 -0
- package/dist/webafx-i18n/index.js +12 -0
- package/dist/webafx-i18n/index.js.map +1 -0
- package/dist/webafx-i18n/locale-resolver.d.ts +33 -0
- package/dist/webafx-i18n/locale-resolver.d.ts.map +1 -0
- package/dist/webafx-i18n/locale-resolver.js +67 -0
- package/dist/webafx-i18n/locale-resolver.js.map +1 -0
- package/dist/webafx-i18n/postgresql-source.d.ts +101 -0
- package/dist/webafx-i18n/postgresql-source.d.ts.map +1 -0
- package/dist/webafx-i18n/postgresql-source.js +101 -0
- package/dist/webafx-i18n/postgresql-source.js.map +1 -0
- package/dist/webafx-i18n/types.d.ts +70 -0
- package/dist/webafx-i18n/types.d.ts.map +1 -0
- package/dist/webafx-i18n/types.js +2 -0
- package/dist/webafx-i18n/types.js.map +1 -0
- package/dist/webafx-mailer/abstract-mail-provider.d.ts +55 -0
- package/dist/webafx-mailer/abstract-mail-provider.d.ts.map +1 -0
- package/dist/webafx-mailer/abstract-mail-provider.js +37 -0
- package/dist/webafx-mailer/abstract-mail-provider.js.map +1 -0
- package/dist/webafx-mailer/index.d.ts +24 -0
- package/dist/webafx-mailer/index.d.ts.map +1 -0
- package/dist/webafx-mailer/index.js +34 -0
- package/dist/webafx-mailer/index.js.map +1 -0
- package/dist/webafx-mailer/mail-plugin.d.ts +98 -0
- package/dist/webafx-mailer/mail-plugin.d.ts.map +1 -0
- package/dist/webafx-mailer/mail-plugin.js +155 -0
- package/dist/webafx-mailer/mail-plugin.js.map +1 -0
- package/dist/webafx-mailer/memory-mail-provider.d.ts +85 -0
- package/dist/webafx-mailer/memory-mail-provider.d.ts.map +1 -0
- package/dist/webafx-mailer/memory-mail-provider.js +111 -0
- package/dist/webafx-mailer/memory-mail-provider.js.map +1 -0
- package/dist/webafx-mailer/smtp-mail-provider.d.ts +65 -0
- package/dist/webafx-mailer/smtp-mail-provider.d.ts.map +1 -0
- package/dist/webafx-mailer/smtp-mail-provider.js +113 -0
- package/dist/webafx-mailer/smtp-mail-provider.js.map +1 -0
- package/dist/webafx-mailer/types.d.ts +136 -0
- package/dist/webafx-mailer/types.d.ts.map +1 -0
- package/dist/webafx-mailer/types.js +13 -0
- package/dist/webafx-mailer/types.js.map +1 -0
- package/package.json +159 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* Request context data propagated through async operations.
|
|
4
|
+
* Contains request-scoped information accessible anywhere in the request lifecycle.
|
|
5
|
+
*/
|
|
6
|
+
export interface RequestContext {
|
|
7
|
+
/** Unique request ID for tracing */
|
|
8
|
+
requestId: string;
|
|
9
|
+
/** Request start time (milliseconds since epoch) */
|
|
10
|
+
startTime: number;
|
|
11
|
+
/** Additional context properties can be added dynamically */
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Shared AsyncLocalStorage instance for request context propagation.
|
|
16
|
+
* This enables accessing request-scoped data anywhere in the async call chain
|
|
17
|
+
* without explicitly passing it through function parameters.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* AsyncLocalStorage is a Node.js feature that maintains context across async operations.
|
|
21
|
+
* Each request runs in its own context, preventing cross-request contamination.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // In middleware:
|
|
26
|
+
* requestContextStorage.run(context, () => {
|
|
27
|
+
* next(); // All async operations from here have access to context
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Anywhere in the request lifecycle:
|
|
31
|
+
* const context = getRequestContext();
|
|
32
|
+
* console.log(context?.requestId);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const requestContextStorage: AsyncLocalStorage<RequestContext>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the current request context if inside a request scope.
|
|
38
|
+
*
|
|
39
|
+
* @returns Request context object, or undefined if called outside request scope
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const context = getRequestContext();
|
|
44
|
+
* if (context) {
|
|
45
|
+
* logger.info('Processing request', { requestId: context.requestId });
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function getRequestContext(): RequestContext | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the current request ID if inside a request scope.
|
|
52
|
+
*
|
|
53
|
+
* @returns Request ID string, or undefined if called outside request scope
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const requestId = getRequestId();
|
|
58
|
+
* await database.query('SELECT * FROM users WHERE id = ?', [userId], { requestId });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function getRequestId(): string | undefined;
|
|
62
|
+
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/application/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,qBAAqB,mCAA0C,CAAC;AAE7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAEjD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* Shared AsyncLocalStorage instance for request context propagation.
|
|
4
|
+
* This enables accessing request-scoped data anywhere in the async call chain
|
|
5
|
+
* without explicitly passing it through function parameters.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* AsyncLocalStorage is a Node.js feature that maintains context across async operations.
|
|
9
|
+
* Each request runs in its own context, preventing cross-request contamination.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // In middleware:
|
|
14
|
+
* requestContextStorage.run(context, () => {
|
|
15
|
+
* next(); // All async operations from here have access to context
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Anywhere in the request lifecycle:
|
|
19
|
+
* const context = getRequestContext();
|
|
20
|
+
* console.log(context?.requestId);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const requestContextStorage = new AsyncLocalStorage();
|
|
24
|
+
/**
|
|
25
|
+
* Gets the current request context if inside a request scope.
|
|
26
|
+
*
|
|
27
|
+
* @returns Request context object, or undefined if called outside request scope
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const context = getRequestContext();
|
|
32
|
+
* if (context) {
|
|
33
|
+
* logger.info('Processing request', { requestId: context.requestId });
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function getRequestContext() {
|
|
38
|
+
return requestContextStorage.getStore();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the current request ID if inside a request scope.
|
|
42
|
+
*
|
|
43
|
+
* @returns Request ID string, or undefined if called outside request scope
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const requestId = getRequestId();
|
|
48
|
+
* await database.query('SELECT * FROM users WHERE id = ?', [userId], { requestId });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function getRequestId() {
|
|
52
|
+
return requestContextStorage.getStore()?.requestId;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/application/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAerD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAE7E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,qBAAqB,CAAC,QAAQ,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,qBAAqB,CAAC,QAAQ,EAAE,EAAE,SAAS,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Validates whether a string is a valid UUID v4 format.
|
|
4
|
+
*
|
|
5
|
+
* @param id - The string to validate
|
|
6
|
+
* @returns True if the string matches UUID v4 format
|
|
7
|
+
*/
|
|
8
|
+
export declare function isValidUUID(id: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Request ID middleware.
|
|
11
|
+
* Generates a unique correlation ID for each request and propagates it through
|
|
12
|
+
* AsyncLocalStorage for access anywhere in the request lifecycle.
|
|
13
|
+
* Attaches it to req.id and X-Request-ID response header.
|
|
14
|
+
*
|
|
15
|
+
* If the incoming request has an X-Request-ID header with a valid UUID format,
|
|
16
|
+
* it is reused. Otherwise, a new UUID is generated. This prevents malformed
|
|
17
|
+
* or malicious request IDs from propagating through the system.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The request context is stored in AsyncLocalStorage, making the request ID
|
|
21
|
+
* accessible via `getRequestId()` or `getRequestContext()` anywhere in the
|
|
22
|
+
* async call chain without explicitly passing it through parameters.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* app.use(requestIdMiddleware());
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function requestIdMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
30
|
+
//# sourceMappingURL=request-id-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-id-middleware.d.ts","sourceRoot":"","sources":["../../src/application/request-id-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAS1D;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,KACzB,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,UAuBxD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { requestContextStorage } from './request-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* UUID v4 format regex pattern.
|
|
5
|
+
* Validates standard UUID format: 8-4-4-4-12 hex characters.
|
|
6
|
+
*/
|
|
7
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
|
+
/**
|
|
9
|
+
* Validates whether a string is a valid UUID v4 format.
|
|
10
|
+
*
|
|
11
|
+
* @param id - The string to validate
|
|
12
|
+
* @returns True if the string matches UUID v4 format
|
|
13
|
+
*/
|
|
14
|
+
export function isValidUUID(id) {
|
|
15
|
+
return UUID_REGEX.test(id);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Request ID middleware.
|
|
19
|
+
* Generates a unique correlation ID for each request and propagates it through
|
|
20
|
+
* AsyncLocalStorage for access anywhere in the request lifecycle.
|
|
21
|
+
* Attaches it to req.id and X-Request-ID response header.
|
|
22
|
+
*
|
|
23
|
+
* If the incoming request has an X-Request-ID header with a valid UUID format,
|
|
24
|
+
* it is reused. Otherwise, a new UUID is generated. This prevents malformed
|
|
25
|
+
* or malicious request IDs from propagating through the system.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* The request context is stored in AsyncLocalStorage, making the request ID
|
|
29
|
+
* accessible via `getRequestId()` or `getRequestContext()` anywhere in the
|
|
30
|
+
* async call chain without explicitly passing it through parameters.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* app.use(requestIdMiddleware());
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function requestIdMiddleware() {
|
|
38
|
+
return (req, res, next) => {
|
|
39
|
+
// Check if request already has a valid UUID from upstream proxy
|
|
40
|
+
const existingId = req.headers['x-request-id'];
|
|
41
|
+
// Only reuse existing ID if it's a valid UUID format;
|
|
42
|
+
// reject malformed IDs to prevent injection or log corruption
|
|
43
|
+
const requestId = existingId && isValidUUID(existingId) ? existingId : randomUUID();
|
|
44
|
+
// Attach to request
|
|
45
|
+
req.id = requestId;
|
|
46
|
+
// Add to response headers
|
|
47
|
+
res.setHeader('X-Request-ID', requestId);
|
|
48
|
+
// Create request context and run the rest of the request in AsyncLocalStorage
|
|
49
|
+
const context = {
|
|
50
|
+
requestId,
|
|
51
|
+
startTime: Date.now(),
|
|
52
|
+
};
|
|
53
|
+
// All async operations from this point have access to the context
|
|
54
|
+
requestContextStorage.run(context, () => next());
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=request-id-middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-id-middleware.js","sourceRoot":"","sources":["../../src/application/request-id-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAkB,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7E;;;GAGG;AACH,MAAM,UAAU,GAAG,iEAAiE,CAAC;AAErF;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACzD,gEAAgE;QAChE,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,CAAW,CAAC;QAEzD,sDAAsD;QACtD,8DAA8D;QAC9D,MAAM,SAAS,GAAG,UAAU,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;QAEpF,oBAAoB;QACpB,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;QAEnB,0BAA0B;QAC1B,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAEzC,8EAA8E;QAC9E,MAAM,OAAO,GAAmB;YAC9B,SAAS;YACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QAEF,kEAAkE;QAClE,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { NextFunction, Request, RequestHandler, Response } from 'express';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Supported HTTP methods for routes.
|
|
5
|
+
*/
|
|
6
|
+
export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
7
|
+
/**
|
|
8
|
+
* Response definition for OpenAPI documentation.
|
|
9
|
+
* Describes a possible response from an API endpoint.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This is pure metadata — no generation logic lives in webafx.
|
|
13
|
+
* The actual OpenAPI spec generation happens in `@blendsdk/codegen`.
|
|
14
|
+
*/
|
|
15
|
+
export interface OpenAPIResponseDefinition {
|
|
16
|
+
/** HTTP status code (e.g., 200, 201, 400, 404) */
|
|
17
|
+
statusCode: number;
|
|
18
|
+
/** Human-readable description of this response */
|
|
19
|
+
description: string;
|
|
20
|
+
/** Optional Zod schema describing the response body structure */
|
|
21
|
+
schema?: ZodType;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Optional OpenAPI metadata for route documentation.
|
|
25
|
+
*
|
|
26
|
+
* Only routes with this metadata will be included in generated OpenAPI specs.
|
|
27
|
+
* This serves as the opt-in mechanism: routes without `.openapi()` are excluded
|
|
28
|
+
* from the generated specification, keeping internal routes hidden.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This is pure data — no generation logic lives in webafx.
|
|
32
|
+
* The actual OpenAPI spec generation happens in `@blendsdk/codegen`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* this.route()
|
|
37
|
+
* .get('/')
|
|
38
|
+
* .openapi({
|
|
39
|
+
* summary: 'List products',
|
|
40
|
+
* tags: ['products'],
|
|
41
|
+
* responses: [
|
|
42
|
+
* { statusCode: 200, description: 'Paginated product list' }
|
|
43
|
+
* ]
|
|
44
|
+
* })
|
|
45
|
+
* .validate(productQuerySchema)
|
|
46
|
+
* .handle(this.listProducts);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export interface OpenAPIRouteMetadata {
|
|
50
|
+
/** Short summary of the route (appears in path listing) */
|
|
51
|
+
summary?: string;
|
|
52
|
+
/** Detailed description of the route (supports markdown) */
|
|
53
|
+
description?: string;
|
|
54
|
+
/** Tags for grouping routes in the spec (e.g., 'products', 'auth') */
|
|
55
|
+
tags?: string[];
|
|
56
|
+
/** Unique operation identifier for the route */
|
|
57
|
+
operationId?: string;
|
|
58
|
+
/** Mark route as deprecated in the spec */
|
|
59
|
+
deprecated?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Path parameter schemas for parameters not covered by the validation schema.
|
|
62
|
+
* Each key is the parameter name (matching the Express `:param` in the path).
|
|
63
|
+
*/
|
|
64
|
+
pathParams?: Record<string, {
|
|
65
|
+
schema: ZodType;
|
|
66
|
+
description?: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Response definitions describing possible responses from this endpoint */
|
|
69
|
+
responses?: OpenAPIResponseDefinition[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Route handler function signature.
|
|
73
|
+
* Handles HTTP requests and can be async or sync.
|
|
74
|
+
*/
|
|
75
|
+
export type RouteHandler = (req: Request, res: Response, next: NextFunction) => Promise<void> | void;
|
|
76
|
+
/**
|
|
77
|
+
* Authorization function that determines if a user can access a route.
|
|
78
|
+
*
|
|
79
|
+
* @template T - User type
|
|
80
|
+
* @param req - Express request object
|
|
81
|
+
* @param user - Authenticated user object
|
|
82
|
+
* @returns True if authorized, false otherwise
|
|
83
|
+
*/
|
|
84
|
+
export type AuthorizeFunction<T = any> = (req: Request, user: T) => boolean | Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Complete route definition with all configuration.
|
|
87
|
+
*/
|
|
88
|
+
export interface RouteDefinition {
|
|
89
|
+
method: HttpMethod;
|
|
90
|
+
path: string;
|
|
91
|
+
handler: RouteHandler;
|
|
92
|
+
validation?: ZodType;
|
|
93
|
+
secure?: boolean;
|
|
94
|
+
authorize?: AuthorizeFunction;
|
|
95
|
+
middleware?: RequestHandler[];
|
|
96
|
+
/**
|
|
97
|
+
* Optional OpenAPI metadata for this route.
|
|
98
|
+
* Routes without this field are excluded from generated OpenAPI specs.
|
|
99
|
+
* This is the opt-in mechanism for API documentation.
|
|
100
|
+
*/
|
|
101
|
+
openapi?: OpenAPIRouteMetadata;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Fluent API builder for defining HTTP routes.
|
|
105
|
+
* Provides a chainable interface for configuring route properties.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* Use this class to build route definitions with method chaining:
|
|
109
|
+
* - HTTP method (get, post, put, patch, delete)
|
|
110
|
+
* - Path
|
|
111
|
+
* - Authentication (secure)
|
|
112
|
+
* - Authorization (authorize)
|
|
113
|
+
* - Validation (validate)
|
|
114
|
+
* - Handler function (handle)
|
|
115
|
+
*/
|
|
116
|
+
export declare class RouteBuilder {
|
|
117
|
+
private definition;
|
|
118
|
+
/**
|
|
119
|
+
* Defines a GET route.
|
|
120
|
+
*
|
|
121
|
+
* @param path - URL path for the route
|
|
122
|
+
* @returns This builder instance for method chaining
|
|
123
|
+
*/
|
|
124
|
+
get(path: string): this;
|
|
125
|
+
/**
|
|
126
|
+
* Defines a POST route.
|
|
127
|
+
*
|
|
128
|
+
* @param path - URL path for the route
|
|
129
|
+
* @returns This builder instance for method chaining
|
|
130
|
+
*/
|
|
131
|
+
post(path: string): this;
|
|
132
|
+
/**
|
|
133
|
+
* Defines a PUT route.
|
|
134
|
+
*
|
|
135
|
+
* @param path - URL path for the route
|
|
136
|
+
* @returns This builder instance for method chaining
|
|
137
|
+
*/
|
|
138
|
+
put(path: string): this;
|
|
139
|
+
/**
|
|
140
|
+
* Defines a PATCH route.
|
|
141
|
+
*
|
|
142
|
+
* @param path - URL path for the route
|
|
143
|
+
* @returns This builder instance for method chaining
|
|
144
|
+
*/
|
|
145
|
+
patch(path: string): this;
|
|
146
|
+
/**
|
|
147
|
+
* Defines a DELETE route.
|
|
148
|
+
*
|
|
149
|
+
* @param path - URL path for the route
|
|
150
|
+
* @returns This builder instance for method chaining
|
|
151
|
+
*/
|
|
152
|
+
delete(path: string): this;
|
|
153
|
+
/**
|
|
154
|
+
* Marks the route as requiring authentication.
|
|
155
|
+
* Authenticated user must be present in request.services.
|
|
156
|
+
*
|
|
157
|
+
* @returns This builder instance for method chaining
|
|
158
|
+
*/
|
|
159
|
+
secure(): this;
|
|
160
|
+
/**
|
|
161
|
+
* Adds authorization check to the route.
|
|
162
|
+
* Called after authentication if route is secure.
|
|
163
|
+
*
|
|
164
|
+
* @param authorizeFn - Function that determines if user is authorized
|
|
165
|
+
* @returns This builder instance for method chaining
|
|
166
|
+
*/
|
|
167
|
+
authorize(authorizeFn: AuthorizeFunction): this;
|
|
168
|
+
/**
|
|
169
|
+
* Adds middleware to this route. Can be called multiple times.
|
|
170
|
+
* Middleware runs in order before the route handler.
|
|
171
|
+
*
|
|
172
|
+
* @param fn - Middleware function to add
|
|
173
|
+
* @returns This builder instance for method chaining
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* this.route()
|
|
178
|
+
* .get('/admin')
|
|
179
|
+
* .middleware(authMiddleware)
|
|
180
|
+
* .middleware(rateLimitMiddleware)
|
|
181
|
+
* .handle(fn);
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
middleware(fn: RequestHandler): this;
|
|
185
|
+
/**
|
|
186
|
+
* Attaches OpenAPI metadata to this route.
|
|
187
|
+
*
|
|
188
|
+
* Only routes with this metadata will appear in generated OpenAPI specs.
|
|
189
|
+
* Routes without `.openapi()` are excluded, keeping internal routes hidden.
|
|
190
|
+
*
|
|
191
|
+
* @param meta - OpenAPI metadata for this route
|
|
192
|
+
* @returns This builder instance for method chaining
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* this.route()
|
|
197
|
+
* .get('/:id')
|
|
198
|
+
* .openapi({
|
|
199
|
+
* summary: 'Get product by ID',
|
|
200
|
+
* tags: ['products'],
|
|
201
|
+
* pathParams: { id: { schema: z.coerce.number(), description: 'Product ID' } },
|
|
202
|
+
* responses: [
|
|
203
|
+
* { statusCode: 200, description: 'Product details' },
|
|
204
|
+
* { statusCode: 404, description: 'Product not found' }
|
|
205
|
+
* ]
|
|
206
|
+
* })
|
|
207
|
+
* .handle(this.getProduct);
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
openapi(meta: OpenAPIRouteMetadata): this;
|
|
211
|
+
/**
|
|
212
|
+
* Adds request validation using a Zod schema.
|
|
213
|
+
* Validates merged params, query, and body data.
|
|
214
|
+
*
|
|
215
|
+
* @param schema - Zod validation schema
|
|
216
|
+
* @returns This builder instance for method chaining
|
|
217
|
+
* @template TSchema - Zod schema type
|
|
218
|
+
*/
|
|
219
|
+
validate<TSchema extends ZodType>(schema: TSchema): RouteBuilder;
|
|
220
|
+
/**
|
|
221
|
+
* Sets the route handler function and finalizes the route definition.
|
|
222
|
+
* This must be the last method called in the chain.
|
|
223
|
+
*
|
|
224
|
+
* @param handler - Route handler function
|
|
225
|
+
* @returns Complete route definition
|
|
226
|
+
* @throws {Error} If handler is not a function
|
|
227
|
+
* @throws {Error} If method or path not set
|
|
228
|
+
*/
|
|
229
|
+
handle(handler: RouteHandler): RouteDefinition;
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=route-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-builder.d.ts","sourceRoot":"","sources":["../../src/application/route-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC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ent API builder for defining HTTP routes.
|
|
3
|
+
* Provides a chainable interface for configuring route properties.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Use this class to build route definitions with method chaining:
|
|
7
|
+
* - HTTP method (get, post, put, patch, delete)
|
|
8
|
+
* - Path
|
|
9
|
+
* - Authentication (secure)
|
|
10
|
+
* - Authorization (authorize)
|
|
11
|
+
* - Validation (validate)
|
|
12
|
+
* - Handler function (handle)
|
|
13
|
+
*/
|
|
14
|
+
export class RouteBuilder {
|
|
15
|
+
definition = {};
|
|
16
|
+
/**
|
|
17
|
+
* Defines a GET route.
|
|
18
|
+
*
|
|
19
|
+
* @param path - URL path for the route
|
|
20
|
+
* @returns This builder instance for method chaining
|
|
21
|
+
*/
|
|
22
|
+
get(path) {
|
|
23
|
+
this.definition.method = 'get';
|
|
24
|
+
this.definition.path = path;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Defines a POST route.
|
|
29
|
+
*
|
|
30
|
+
* @param path - URL path for the route
|
|
31
|
+
* @returns This builder instance for method chaining
|
|
32
|
+
*/
|
|
33
|
+
post(path) {
|
|
34
|
+
this.definition.method = 'post';
|
|
35
|
+
this.definition.path = path;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Defines a PUT route.
|
|
40
|
+
*
|
|
41
|
+
* @param path - URL path for the route
|
|
42
|
+
* @returns This builder instance for method chaining
|
|
43
|
+
*/
|
|
44
|
+
put(path) {
|
|
45
|
+
this.definition.method = 'put';
|
|
46
|
+
this.definition.path = path;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Defines a PATCH route.
|
|
51
|
+
*
|
|
52
|
+
* @param path - URL path for the route
|
|
53
|
+
* @returns This builder instance for method chaining
|
|
54
|
+
*/
|
|
55
|
+
patch(path) {
|
|
56
|
+
this.definition.method = 'patch';
|
|
57
|
+
this.definition.path = path;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Defines a DELETE route.
|
|
62
|
+
*
|
|
63
|
+
* @param path - URL path for the route
|
|
64
|
+
* @returns This builder instance for method chaining
|
|
65
|
+
*/
|
|
66
|
+
delete(path) {
|
|
67
|
+
this.definition.method = 'delete';
|
|
68
|
+
this.definition.path = path;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Marks the route as requiring authentication.
|
|
73
|
+
* Authenticated user must be present in request.services.
|
|
74
|
+
*
|
|
75
|
+
* @returns This builder instance for method chaining
|
|
76
|
+
*/
|
|
77
|
+
secure() {
|
|
78
|
+
this.definition.secure = true;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Adds authorization check to the route.
|
|
83
|
+
* Called after authentication if route is secure.
|
|
84
|
+
*
|
|
85
|
+
* @param authorizeFn - Function that determines if user is authorized
|
|
86
|
+
* @returns This builder instance for method chaining
|
|
87
|
+
*/
|
|
88
|
+
authorize(authorizeFn) {
|
|
89
|
+
this.definition.authorize = authorizeFn;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Adds middleware to this route. Can be called multiple times.
|
|
94
|
+
* Middleware runs in order before the route handler.
|
|
95
|
+
*
|
|
96
|
+
* @param fn - Middleware function to add
|
|
97
|
+
* @returns This builder instance for method chaining
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* this.route()
|
|
102
|
+
* .get('/admin')
|
|
103
|
+
* .middleware(authMiddleware)
|
|
104
|
+
* .middleware(rateLimitMiddleware)
|
|
105
|
+
* .handle(fn);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
middleware(fn) {
|
|
109
|
+
if (!this.definition.middleware) {
|
|
110
|
+
this.definition.middleware = [];
|
|
111
|
+
}
|
|
112
|
+
this.definition.middleware.push(fn);
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Attaches OpenAPI metadata to this route.
|
|
117
|
+
*
|
|
118
|
+
* Only routes with this metadata will appear in generated OpenAPI specs.
|
|
119
|
+
* Routes without `.openapi()` are excluded, keeping internal routes hidden.
|
|
120
|
+
*
|
|
121
|
+
* @param meta - OpenAPI metadata for this route
|
|
122
|
+
* @returns This builder instance for method chaining
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* this.route()
|
|
127
|
+
* .get('/:id')
|
|
128
|
+
* .openapi({
|
|
129
|
+
* summary: 'Get product by ID',
|
|
130
|
+
* tags: ['products'],
|
|
131
|
+
* pathParams: { id: { schema: z.coerce.number(), description: 'Product ID' } },
|
|
132
|
+
* responses: [
|
|
133
|
+
* { statusCode: 200, description: 'Product details' },
|
|
134
|
+
* { statusCode: 404, description: 'Product not found' }
|
|
135
|
+
* ]
|
|
136
|
+
* })
|
|
137
|
+
* .handle(this.getProduct);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
openapi(meta) {
|
|
141
|
+
this.definition.openapi = meta;
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Adds request validation using a Zod schema.
|
|
146
|
+
* Validates merged params, query, and body data.
|
|
147
|
+
*
|
|
148
|
+
* @param schema - Zod validation schema
|
|
149
|
+
* @returns This builder instance for method chaining
|
|
150
|
+
* @template TSchema - Zod schema type
|
|
151
|
+
*/
|
|
152
|
+
validate(schema) {
|
|
153
|
+
this.definition.validation = schema;
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Sets the route handler function and finalizes the route definition.
|
|
158
|
+
* This must be the last method called in the chain.
|
|
159
|
+
*
|
|
160
|
+
* @param handler - Route handler function
|
|
161
|
+
* @returns Complete route definition
|
|
162
|
+
* @throws {Error} If handler is not a function
|
|
163
|
+
* @throws {Error} If method or path not set
|
|
164
|
+
*/
|
|
165
|
+
handle(handler) {
|
|
166
|
+
// Validate that handler is a function
|
|
167
|
+
if (typeof handler !== 'function') {
|
|
168
|
+
throw new Error(`Route handler must be a function, received: ${typeof handler}. ` +
|
|
169
|
+
`Path: ${this.definition.path || 'unknown'}, Method: ${this.definition.method || 'unknown'}`);
|
|
170
|
+
}
|
|
171
|
+
// Validate that required route properties are set
|
|
172
|
+
if (!this.definition.method) {
|
|
173
|
+
throw new Error('Route method must be set before calling handle()');
|
|
174
|
+
}
|
|
175
|
+
if (!this.definition.path) {
|
|
176
|
+
throw new Error('Route path must be set before calling handle()');
|
|
177
|
+
}
|
|
178
|
+
this.definition.handler = handler;
|
|
179
|
+
return this.definition;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=route-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-builder.js","sourceRoot":"","sources":["../../src/application/route-builder.ts"],"names":[],"mappings":"AA8GA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,YAAY;IACf,UAAU,GAA6B,EAAE,CAAC;IAElD;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CA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