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,683 @@
|
|
|
1
|
+
import { isBoolean, isNumeric, isString } from '../stdlib/index.js';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { InvalidConfigurationError, MalformedArgumentError } from './errors.js';
|
|
4
|
+
import { getDomainValidationError, getEmailValidationError, isValidDomain, isValidEmail, } from './validators.js';
|
|
5
|
+
/**
|
|
6
|
+
* @export
|
|
7
|
+
* @class CommandLineParser
|
|
8
|
+
*/
|
|
9
|
+
export class CommandLineParser {
|
|
10
|
+
/**
|
|
11
|
+
* @protected
|
|
12
|
+
* @type {ICommandLineParser}
|
|
13
|
+
* @memberof CommandLineParser
|
|
14
|
+
*/
|
|
15
|
+
config;
|
|
16
|
+
/**
|
|
17
|
+
* @protected
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof CommandLineParser
|
|
20
|
+
*/
|
|
21
|
+
interpreter;
|
|
22
|
+
/**
|
|
23
|
+
* @protected
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @memberof CommandLineParser
|
|
26
|
+
*/
|
|
27
|
+
script;
|
|
28
|
+
/**
|
|
29
|
+
* @protected
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @memberof CommandLineParser
|
|
32
|
+
*/
|
|
33
|
+
scriptName;
|
|
34
|
+
/**
|
|
35
|
+
* @protected
|
|
36
|
+
* @type {ICommand[]}
|
|
37
|
+
* @memberof CommandLineParser
|
|
38
|
+
*/
|
|
39
|
+
commands;
|
|
40
|
+
/**
|
|
41
|
+
* @protected
|
|
42
|
+
* @type {IDictionaryOf<IDictionaryOf<any>>}
|
|
43
|
+
* @memberof CommandLineParser
|
|
44
|
+
*/
|
|
45
|
+
optionValues;
|
|
46
|
+
/**
|
|
47
|
+
* References the current running command
|
|
48
|
+
*
|
|
49
|
+
* @protected
|
|
50
|
+
* @memberof CommandLineParser
|
|
51
|
+
*/
|
|
52
|
+
currentCommand;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an instance of CommandLineParser.
|
|
55
|
+
* @param {ICommandLineParser} [config]
|
|
56
|
+
* @memberof CommandLineParser
|
|
57
|
+
*/
|
|
58
|
+
constructor(config) {
|
|
59
|
+
this.config = config ?? { name: 'default' };
|
|
60
|
+
this.config.version = this.config.version ?? '1.0';
|
|
61
|
+
this.commands = [];
|
|
62
|
+
this.optionValues = {};
|
|
63
|
+
this.interpreter = '';
|
|
64
|
+
this.script = '';
|
|
65
|
+
this.scriptName = '';
|
|
66
|
+
this.prepare();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @protected
|
|
70
|
+
* @param {string[][]} table
|
|
71
|
+
* @memberof CommandLineParser
|
|
72
|
+
*/
|
|
73
|
+
print(table) {
|
|
74
|
+
const res = [];
|
|
75
|
+
const colSize = [];
|
|
76
|
+
table.forEach(r => {
|
|
77
|
+
r.forEach((c, ci) => {
|
|
78
|
+
const currentSize = colSize[ci] ?? 0;
|
|
79
|
+
colSize[ci] = c.toString().length > currentSize ? c.toString().length : currentSize;
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
table.forEach((r, ri) => {
|
|
83
|
+
res[ri] = [];
|
|
84
|
+
r.forEach((c, ci) => {
|
|
85
|
+
const size = colSize[ci] ?? 0;
|
|
86
|
+
res[ri][ci] = c.padEnd(size, ' ');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
console.log(res
|
|
90
|
+
.map(r => {
|
|
91
|
+
return r.join('').trimEnd();
|
|
92
|
+
})
|
|
93
|
+
.join('\n')
|
|
94
|
+
.trimEnd());
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Handles quoted arguments and special characters
|
|
98
|
+
* @protected
|
|
99
|
+
* @param {string} arg
|
|
100
|
+
* @return {string}
|
|
101
|
+
* @memberof CommandLineParser
|
|
102
|
+
*/
|
|
103
|
+
processQuotedArgument(arg) {
|
|
104
|
+
// Handle quoted arguments with spaces
|
|
105
|
+
if ((arg.startsWith('"') && arg.endsWith('"')) || (arg.startsWith("'") && arg.endsWith("'"))) {
|
|
106
|
+
return arg.slice(1, -1);
|
|
107
|
+
}
|
|
108
|
+
// Handle escaped characters
|
|
109
|
+
return arg.replace(/\\(.)/g, '$1');
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Validates argument format and handles malformed arguments
|
|
113
|
+
* @protected
|
|
114
|
+
* @param {string} arg
|
|
115
|
+
* @memberof CommandLineParser
|
|
116
|
+
*/
|
|
117
|
+
validateArgument(arg) {
|
|
118
|
+
// Check for empty arguments
|
|
119
|
+
if (arg.length === 0) {
|
|
120
|
+
throw new MalformedArgumentError(arg, 'Empty argument provided');
|
|
121
|
+
}
|
|
122
|
+
// Check for malformed options (starting with - but no content)
|
|
123
|
+
if (arg === '-' || arg === '--') {
|
|
124
|
+
throw new MalformedArgumentError(arg, 'Invalid option format');
|
|
125
|
+
}
|
|
126
|
+
// Check for options with invalid characters
|
|
127
|
+
if (arg.startsWith('-') && !/^-{1,2}[a-zA-Z][a-zA-Z0-9_-]*(?:=.*)?$/.test(arg)) {
|
|
128
|
+
// Allow special case for negative numbers
|
|
129
|
+
if (!/^-\d+(\.\d+)?$/.test(arg)) {
|
|
130
|
+
throw new MalformedArgumentError(arg, 'Invalid option name format');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @protected
|
|
136
|
+
* @return {IToken[]}
|
|
137
|
+
* @memberof CommandLineParser
|
|
138
|
+
*/
|
|
139
|
+
parseTokens() {
|
|
140
|
+
const [, , ...args] = process.argv;
|
|
141
|
+
// Validate and process arguments
|
|
142
|
+
const processedArgs = args.map(arg => {
|
|
143
|
+
try {
|
|
144
|
+
this.validateArgument(arg);
|
|
145
|
+
return this.processQuotedArgument(arg);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (error instanceof MalformedArgumentError) {
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
throw new MalformedArgumentError(arg, `Failed to process argument: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
// Tokenize
|
|
155
|
+
const optionRe = /^-(-?).*$/;
|
|
156
|
+
const commandOption = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
157
|
+
const pass1 = [];
|
|
158
|
+
processedArgs.forEach((arg, index) => {
|
|
159
|
+
const isOption = optionRe.test(arg) && !/^-\d+(\.\d+)?$/.test(arg); // Exclude negative numbers
|
|
160
|
+
const isCommand = commandOption.test(arg) && index === 0 && !isOption;
|
|
161
|
+
const isLongOption = isOption && arg.startsWith('--');
|
|
162
|
+
const isShortOption = isOption && !isLongOption && arg.startsWith('-');
|
|
163
|
+
const isValue = !isOption && !isCommand;
|
|
164
|
+
pass1.push({
|
|
165
|
+
arg,
|
|
166
|
+
index,
|
|
167
|
+
isCommand,
|
|
168
|
+
isOption,
|
|
169
|
+
isShortOption,
|
|
170
|
+
isLongOption,
|
|
171
|
+
isValue,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
const pass2 = [];
|
|
175
|
+
// Find the option values
|
|
176
|
+
pass1.forEach(token => {
|
|
177
|
+
if (token.isShortOption) {
|
|
178
|
+
const argChars = token.arg.split('');
|
|
179
|
+
if (argChars.length < 2)
|
|
180
|
+
return;
|
|
181
|
+
const optionChar = argChars[1] ?? '';
|
|
182
|
+
const parts = argChars.slice(2);
|
|
183
|
+
let value = parts.join('');
|
|
184
|
+
value = (value.startsWith('=') ? value.slice(1) : value).trim();
|
|
185
|
+
value = value.length === 0 ? true : value;
|
|
186
|
+
try {
|
|
187
|
+
value = JSON.parse(value.toString());
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// Keep original value if JSON parsing fails
|
|
191
|
+
}
|
|
192
|
+
// The option
|
|
193
|
+
pass2.push({
|
|
194
|
+
arg: optionChar,
|
|
195
|
+
isCommand: false,
|
|
196
|
+
isOption: true,
|
|
197
|
+
isShortOption: true,
|
|
198
|
+
isLongOption: false,
|
|
199
|
+
isValue: false,
|
|
200
|
+
index: pass2.length,
|
|
201
|
+
value,
|
|
202
|
+
});
|
|
203
|
+
// The value
|
|
204
|
+
pass2.push({
|
|
205
|
+
arg: value.toString(),
|
|
206
|
+
isCommand: false,
|
|
207
|
+
isOption: false,
|
|
208
|
+
isShortOption: false,
|
|
209
|
+
isLongOption: false,
|
|
210
|
+
isValue: true,
|
|
211
|
+
index: pass2.length,
|
|
212
|
+
value,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
else if (token.isLongOption) {
|
|
216
|
+
const parts = token.arg.slice(2).split('=');
|
|
217
|
+
const optionName = parts[0] ?? '';
|
|
218
|
+
let value = parts.length > 1 ? parts.slice(1).join('=') : true;
|
|
219
|
+
if (typeof value === 'string') {
|
|
220
|
+
try {
|
|
221
|
+
value = JSON.parse(value);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// Keep original value if JSON parsing fails
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// The option
|
|
228
|
+
pass2.push({
|
|
229
|
+
arg: optionName,
|
|
230
|
+
isCommand: false,
|
|
231
|
+
isOption: true,
|
|
232
|
+
isShortOption: false,
|
|
233
|
+
isLongOption: true,
|
|
234
|
+
isValue: false,
|
|
235
|
+
index: pass2.length,
|
|
236
|
+
value,
|
|
237
|
+
});
|
|
238
|
+
// The value
|
|
239
|
+
pass2.push({
|
|
240
|
+
arg: value.toString(),
|
|
241
|
+
isCommand: false,
|
|
242
|
+
isOption: false,
|
|
243
|
+
isShortOption: false,
|
|
244
|
+
isLongOption: false,
|
|
245
|
+
isValue: true,
|
|
246
|
+
index: pass2.length,
|
|
247
|
+
value,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
else if (token.isValue) {
|
|
251
|
+
let processedArg = token.arg;
|
|
252
|
+
if (processedArg.startsWith('=')) {
|
|
253
|
+
const parts = processedArg.split('=');
|
|
254
|
+
processedArg = parts.slice(1).join('=');
|
|
255
|
+
}
|
|
256
|
+
let value = processedArg;
|
|
257
|
+
try {
|
|
258
|
+
value = JSON.parse(processedArg);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
// Keep original value if JSON parsing fails
|
|
262
|
+
}
|
|
263
|
+
pass2.push({
|
|
264
|
+
...token,
|
|
265
|
+
arg: processedArg,
|
|
266
|
+
value,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
pass2.push(token);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
const pass3 = [];
|
|
274
|
+
pass2.forEach((token, index) => {
|
|
275
|
+
if (token.isCommand) {
|
|
276
|
+
const lowerCaseArg = token.arg.toLowerCase();
|
|
277
|
+
pass3.push({
|
|
278
|
+
...token,
|
|
279
|
+
arg: lowerCaseArg,
|
|
280
|
+
value: lowerCaseArg,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
else if (token.isOption) {
|
|
284
|
+
const nextToken = pass2[index + 1];
|
|
285
|
+
const nextNextToken = pass2[index + 2];
|
|
286
|
+
const peekIsValue1 = nextToken?.isValue ?? false;
|
|
287
|
+
const peekIsValue2 = nextNextToken?.isValue ?? false;
|
|
288
|
+
const value1 = nextToken?.value;
|
|
289
|
+
if (peekIsValue1 && peekIsValue2 && value1 === true && nextNextToken) {
|
|
290
|
+
pass3.push({
|
|
291
|
+
...token,
|
|
292
|
+
value: nextNextToken.value,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
else if (peekIsValue1 && nextToken) {
|
|
296
|
+
pass3.push({
|
|
297
|
+
...token,
|
|
298
|
+
value: nextToken.value,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
pass3.push(token);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
return pass3;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* @protected
|
|
310
|
+
* @memberof CommandLineParser
|
|
311
|
+
*/
|
|
312
|
+
prepare() {
|
|
313
|
+
this.interpreter = process.argv[0] ?? '';
|
|
314
|
+
this.script = path.resolve(process.argv[1] ?? '');
|
|
315
|
+
const { name } = path.parse(this.script);
|
|
316
|
+
this.scriptName = this.config.name || name;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @protected
|
|
320
|
+
* @param {string} command
|
|
321
|
+
* @param {ICommandOption} option
|
|
322
|
+
* @param {any} value
|
|
323
|
+
* @memberof CommandLineParser
|
|
324
|
+
*/
|
|
325
|
+
setOptionValue(command, option, value) {
|
|
326
|
+
if (!this.optionValues[command]) {
|
|
327
|
+
this.optionValues[command] = {};
|
|
328
|
+
}
|
|
329
|
+
if (option.multiple && value !== undefined) {
|
|
330
|
+
if (!Array.isArray(this.optionValues[command][option.name])) {
|
|
331
|
+
this.optionValues[command][option.name] = [];
|
|
332
|
+
}
|
|
333
|
+
this.optionValues[command][option.name].push(value);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
this.optionValues[command][option.name] = value;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* @protected
|
|
341
|
+
* @param {IToken[]} options
|
|
342
|
+
* @return {object}
|
|
343
|
+
* @memberof CommandLineParser
|
|
344
|
+
*/
|
|
345
|
+
validate(options) {
|
|
346
|
+
const commandToken = options.find(o => o.isCommand);
|
|
347
|
+
const errors = [];
|
|
348
|
+
const command = this.commands.find(c => c.name === commandToken?.arg) || this.commands.find(c => c.default);
|
|
349
|
+
if (!command) {
|
|
350
|
+
errors.push('No command provided!');
|
|
351
|
+
return { errors };
|
|
352
|
+
}
|
|
353
|
+
const tokenOptions = options.filter(o => o.isOption);
|
|
354
|
+
const commandOptions = command.options ?? [];
|
|
355
|
+
for (const option of commandOptions) {
|
|
356
|
+
const foundTokens = tokenOptions.filter(o => o.arg === option.name || o.arg === option.short);
|
|
357
|
+
if (option.required && foundTokens.length === 0 && option.default === undefined) {
|
|
358
|
+
errors.push(`Missing required option [${option.name}]`);
|
|
359
|
+
}
|
|
360
|
+
// Handle default values when no token is found
|
|
361
|
+
if (foundTokens.length === 0 && option.default !== undefined) {
|
|
362
|
+
const defaultValue = option.default;
|
|
363
|
+
// Type validation for default value
|
|
364
|
+
if (option.type === 'string' && !isString(defaultValue)) {
|
|
365
|
+
errors.push(`Invalid default value for option [${option.name}], required ${option.type}, provided [${defaultValue}]`);
|
|
366
|
+
}
|
|
367
|
+
else if (option.type === 'number' && !isNumeric(defaultValue)) {
|
|
368
|
+
errors.push(`Invalid default value for option [${option.name}], required ${option.type}, provided [${defaultValue}]`);
|
|
369
|
+
}
|
|
370
|
+
else if (option.type === 'boolean' && !isBoolean(defaultValue)) {
|
|
371
|
+
errors.push(`Invalid default value for option [${option.name}], required ${option.type}, provided [${defaultValue}]`);
|
|
372
|
+
}
|
|
373
|
+
else if (option.type === 'email') {
|
|
374
|
+
if (!isString(defaultValue)) {
|
|
375
|
+
errors.push(`Invalid default value for option [${option.name}], required email string, provided [${defaultValue}]`);
|
|
376
|
+
}
|
|
377
|
+
else if (!isValidEmail(defaultValue)) {
|
|
378
|
+
errors.push(`Invalid email default value for option [${option.name}]: ${getEmailValidationError(defaultValue)}`);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
else if (option.type === 'domain') {
|
|
382
|
+
if (!isString(defaultValue)) {
|
|
383
|
+
errors.push(`Invalid default value for option [${option.name}], required domain string, provided [${defaultValue}]`);
|
|
384
|
+
}
|
|
385
|
+
else if (!isValidDomain(defaultValue)) {
|
|
386
|
+
errors.push(`Invalid domain default value for option [${option.name}]: ${getDomainValidationError(defaultValue)}`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// Custom validator validation for default value
|
|
390
|
+
if (option.validator && defaultValue !== undefined) {
|
|
391
|
+
const validationResult = option.validator(defaultValue);
|
|
392
|
+
if (validationResult !== true) {
|
|
393
|
+
const errorMsg = typeof validationResult === 'string'
|
|
394
|
+
? validationResult
|
|
395
|
+
: `Invalid default value for option [${option.name}]`;
|
|
396
|
+
errors.push(errorMsg);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
this.setOptionValue(command.name, option, defaultValue);
|
|
400
|
+
}
|
|
401
|
+
for (const foundToken of foundTokens) {
|
|
402
|
+
const tokenValue = foundToken?.value ?? option.default;
|
|
403
|
+
if (tokenValue !== undefined) {
|
|
404
|
+
// Type validation
|
|
405
|
+
if (option.type === 'string' && !isString(tokenValue)) {
|
|
406
|
+
errors.push(`Invalid value provided for option [${option.name}], required ${option.type}, provided [${tokenValue}]`);
|
|
407
|
+
}
|
|
408
|
+
else if (option.type === 'number' && !isNumeric(tokenValue)) {
|
|
409
|
+
errors.push(`Invalid value provided for option [${option.name}], required ${option.type}, provided [${tokenValue}]`);
|
|
410
|
+
}
|
|
411
|
+
else if (option.type === 'boolean' && !isBoolean(tokenValue)) {
|
|
412
|
+
errors.push(`Invalid value provided for option [${option.name}], required ${option.type}, provided [${tokenValue}]`);
|
|
413
|
+
}
|
|
414
|
+
else if (option.type === 'email') {
|
|
415
|
+
if (!isString(tokenValue)) {
|
|
416
|
+
errors.push(`Invalid value provided for option [${option.name}], required email string, provided [${tokenValue}]`);
|
|
417
|
+
}
|
|
418
|
+
else if (!isValidEmail(tokenValue)) {
|
|
419
|
+
errors.push(`Invalid email provided for option [${option.name}]: ${getEmailValidationError(tokenValue)}`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else if (option.type === 'domain') {
|
|
423
|
+
if (!isString(tokenValue)) {
|
|
424
|
+
errors.push(`Invalid value provided for option [${option.name}], required domain string, provided [${tokenValue}]`);
|
|
425
|
+
}
|
|
426
|
+
else if (!isValidDomain(tokenValue)) {
|
|
427
|
+
errors.push(`Invalid domain provided for option [${option.name}]: ${getDomainValidationError(tokenValue)}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// Choices validation
|
|
431
|
+
let choicesValid = true;
|
|
432
|
+
if (option.choices && option.choices.length > 0 && tokenValue !== undefined) {
|
|
433
|
+
if (!option.choices.includes(tokenValue)) {
|
|
434
|
+
const choicesList = option.choices.map(c => `'${c}'`).join(', ');
|
|
435
|
+
errors.push(`Invalid value '${tokenValue}' for option [${option.name}]. Must be one of: ${choicesList}`);
|
|
436
|
+
choicesValid = false;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// Custom validator validation (only if choices validation passed)
|
|
440
|
+
if (choicesValid && option.validator && tokenValue !== undefined) {
|
|
441
|
+
const validationResult = option.validator(tokenValue);
|
|
442
|
+
if (validationResult !== true) {
|
|
443
|
+
const errorMsg = typeof validationResult === 'string'
|
|
444
|
+
? validationResult
|
|
445
|
+
: `Invalid value for option [${option.name}]`;
|
|
446
|
+
errors.push(errorMsg);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
this.setOptionValue(command.name, option, tokenValue);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return { errors, command };
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* @protected
|
|
457
|
+
* @param {ICommand | undefined} command
|
|
458
|
+
* @param {string[]} errors
|
|
459
|
+
* @param {boolean} isHelp
|
|
460
|
+
* @memberof CommandLineParser
|
|
461
|
+
*/
|
|
462
|
+
help(command, errors, isHelp) {
|
|
463
|
+
console.log(`Welcome to ${this.scriptName} ${this.config.version}`);
|
|
464
|
+
if (!isHelp) {
|
|
465
|
+
const errorTable = [];
|
|
466
|
+
if (errors.length !== 0) {
|
|
467
|
+
console.log(command ? `\nErrors: (${command.name} command)\n` : '\nError:\n');
|
|
468
|
+
errors.forEach(l => errorTable.push(['\t', `- ${l}`]));
|
|
469
|
+
}
|
|
470
|
+
this.print(errorTable);
|
|
471
|
+
}
|
|
472
|
+
if (!command) {
|
|
473
|
+
console.log(this.commands.length !== 0 ? '\nCommands:\n' : '');
|
|
474
|
+
const commandTable = [];
|
|
475
|
+
this.commands.forEach(cmd => {
|
|
476
|
+
commandTable.push([
|
|
477
|
+
'\t',
|
|
478
|
+
cmd.name || '(default)',
|
|
479
|
+
'\t\t',
|
|
480
|
+
cmd.description || '',
|
|
481
|
+
cmd.default ? `[default command]` : '',
|
|
482
|
+
]);
|
|
483
|
+
});
|
|
484
|
+
this.print(commandTable);
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
let table = [];
|
|
488
|
+
console.log('\nCommand:\n');
|
|
489
|
+
table.push([
|
|
490
|
+
'\t',
|
|
491
|
+
command.name,
|
|
492
|
+
'\t\t',
|
|
493
|
+
command.description || '',
|
|
494
|
+
'\t',
|
|
495
|
+
command.default ? `[default command]` : '',
|
|
496
|
+
]);
|
|
497
|
+
this.print(table);
|
|
498
|
+
table = [];
|
|
499
|
+
console.log(`\nOptions:\n`);
|
|
500
|
+
const commandOptions = command.options ?? [];
|
|
501
|
+
commandOptions.forEach(option => {
|
|
502
|
+
table.push([
|
|
503
|
+
'\t',
|
|
504
|
+
`--${option.name}`,
|
|
505
|
+
option.short ? ` | -${option.short}` : '',
|
|
506
|
+
'\t\t',
|
|
507
|
+
option.description || 'No description!',
|
|
508
|
+
'\t',
|
|
509
|
+
option.required ? '[required]' : '',
|
|
510
|
+
option.multiple ? '[multiple]' : '',
|
|
511
|
+
option.default !== undefined ? `[default:${option.default}]` : '',
|
|
512
|
+
`[${option.type || 'string'}]`,
|
|
513
|
+
]);
|
|
514
|
+
});
|
|
515
|
+
this.print(table);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Execute the command line parser
|
|
520
|
+
* @param {any} [context]
|
|
521
|
+
* @return {Promise<any>}
|
|
522
|
+
* @memberof CommandLineParser
|
|
523
|
+
*/
|
|
524
|
+
async execute(context) {
|
|
525
|
+
if (this.commands.length > 1) {
|
|
526
|
+
this.commands.forEach(c => {
|
|
527
|
+
c.default = false;
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
try {
|
|
531
|
+
const options = this.parseTokens();
|
|
532
|
+
const { errors, command } = this.validate(options);
|
|
533
|
+
if (!command) {
|
|
534
|
+
this.help(undefined, errors, false);
|
|
535
|
+
return Promise.resolve();
|
|
536
|
+
}
|
|
537
|
+
const commandOptions = this.optionValues[command.name] ?? {};
|
|
538
|
+
const isHelp = commandOptions['help'] !== undefined;
|
|
539
|
+
if (errors.length !== 0 || isHelp) {
|
|
540
|
+
this.help(command, errors, isHelp);
|
|
541
|
+
return Promise.resolve();
|
|
542
|
+
}
|
|
543
|
+
try {
|
|
544
|
+
this.currentCommand = command;
|
|
545
|
+
commandOptions['showHelp'] = () => {
|
|
546
|
+
this.help(this.currentCommand, [], true);
|
|
547
|
+
};
|
|
548
|
+
return await command.handler({ ...commandOptions, context });
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
// Handler errors should be propagated
|
|
552
|
+
throw error;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
// Handle parsing errors gracefully by showing help
|
|
557
|
+
if (error instanceof MalformedArgumentError) {
|
|
558
|
+
this.help(undefined, [error.message], false);
|
|
559
|
+
return Promise.resolve();
|
|
560
|
+
}
|
|
561
|
+
// Re-throw other errors
|
|
562
|
+
throw error;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Validates command configuration for circular dependencies and conflicts
|
|
567
|
+
* @protected
|
|
568
|
+
* @param {ICommand} command
|
|
569
|
+
* @memberof CommandLineParser
|
|
570
|
+
*/
|
|
571
|
+
validateCommandConfiguration(command) {
|
|
572
|
+
// Validate command name
|
|
573
|
+
if (!command.name || typeof command.name !== 'string') {
|
|
574
|
+
throw new InvalidConfigurationError('command.name', 'Command name is required and must be a string');
|
|
575
|
+
}
|
|
576
|
+
// Check for reserved command names
|
|
577
|
+
if (['help', 'version'].includes(command.name.toLowerCase())) {
|
|
578
|
+
throw new InvalidConfigurationError('command.name', `Command name '${command.name}' is reserved`);
|
|
579
|
+
}
|
|
580
|
+
// Validate command name format (no special characters except hyphens and underscores)
|
|
581
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(command.name)) {
|
|
582
|
+
throw new InvalidConfigurationError('command.name', 'Command name must start with a letter and contain only letters, numbers, hyphens, and underscores');
|
|
583
|
+
}
|
|
584
|
+
// Check for duplicate command names
|
|
585
|
+
if (this.commands.some(existingCmd => existingCmd.name === command.name.toLowerCase())) {
|
|
586
|
+
throw new InvalidConfigurationError('command.name', `Command '${command.name}' already exists`);
|
|
587
|
+
}
|
|
588
|
+
// Validate options if present
|
|
589
|
+
if (command.options) {
|
|
590
|
+
this.validateOptionsConfiguration(command.options, command.name);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Validates options configuration for conflicts and format
|
|
595
|
+
* @protected
|
|
596
|
+
* @param {ICommandOption[]} options
|
|
597
|
+
* @param {string} commandName
|
|
598
|
+
* @memberof CommandLineParser
|
|
599
|
+
*/
|
|
600
|
+
validateOptionsConfiguration(options, commandName) {
|
|
601
|
+
const optionNames = new Set();
|
|
602
|
+
const shortNames = new Set();
|
|
603
|
+
for (const option of options) {
|
|
604
|
+
// Validate option name
|
|
605
|
+
if (!option.name || typeof option.name !== 'string') {
|
|
606
|
+
throw new InvalidConfigurationError(`${commandName}.options`, 'Option name is required and must be a string');
|
|
607
|
+
}
|
|
608
|
+
// Check for reserved option names
|
|
609
|
+
if (['help', 'version'].includes(option.name.toLowerCase())) {
|
|
610
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}`, `Option name '${option.name}' is reserved`);
|
|
611
|
+
}
|
|
612
|
+
// Validate option name format
|
|
613
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(option.name)) {
|
|
614
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}`, 'Option name must start with a letter and contain only letters, numbers, hyphens, and underscores');
|
|
615
|
+
}
|
|
616
|
+
// Check for duplicate option names
|
|
617
|
+
if (optionNames.has(option.name)) {
|
|
618
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}`, `Duplicate option name '${option.name}'`);
|
|
619
|
+
}
|
|
620
|
+
optionNames.add(option.name);
|
|
621
|
+
// Validate short name if present
|
|
622
|
+
if (option.short) {
|
|
623
|
+
if (typeof option.short !== 'string' || option.short.length !== 1) {
|
|
624
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}.short`, 'Short option must be a single character');
|
|
625
|
+
}
|
|
626
|
+
if (!/^[a-zA-Z]$/.test(option.short)) {
|
|
627
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}.short`, 'Short option must be a letter');
|
|
628
|
+
}
|
|
629
|
+
if (shortNames.has(option.short)) {
|
|
630
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}.short`, `Duplicate short option '${option.short}'`);
|
|
631
|
+
}
|
|
632
|
+
shortNames.add(option.short);
|
|
633
|
+
}
|
|
634
|
+
// Validate conflicts and dependencies
|
|
635
|
+
if (option.conflicts && option.depends) {
|
|
636
|
+
const conflictSet = new Set(option.conflicts);
|
|
637
|
+
const dependsSet = new Set(option.depends);
|
|
638
|
+
const intersection = [...conflictSet].filter(x => dependsSet.has(x));
|
|
639
|
+
if (intersection.length > 0) {
|
|
640
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}`, `Option cannot both conflict with and depend on: ${intersection.join(', ')}`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
// Validate choices if present
|
|
644
|
+
if (option.choices && (!Array.isArray(option.choices) || option.choices.length === 0)) {
|
|
645
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}.choices`, 'Choices must be a non-empty array');
|
|
646
|
+
}
|
|
647
|
+
// Validate default value against choices
|
|
648
|
+
if (option.choices &&
|
|
649
|
+
option.default !== undefined &&
|
|
650
|
+
!option.choices.includes(option.default)) {
|
|
651
|
+
throw new InvalidConfigurationError(`${commandName}.options.${option.name}.default`, `Default value '${option.default}' is not in choices`);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Add a command to the parser
|
|
657
|
+
* @param {ICommand} config
|
|
658
|
+
* @return {CommandLineParser}
|
|
659
|
+
* @memberof CommandLineParser
|
|
660
|
+
*/
|
|
661
|
+
addCommand(config) {
|
|
662
|
+
const commandConfig = { ...config };
|
|
663
|
+
commandConfig.name = commandConfig.name.toLowerCase();
|
|
664
|
+
commandConfig.options = commandConfig.options ?? [];
|
|
665
|
+
// Validate command configuration
|
|
666
|
+
this.validateCommandConfiguration(commandConfig);
|
|
667
|
+
this.optionValues[commandConfig.name] = {};
|
|
668
|
+
if (this.config.skipHelp !== true) {
|
|
669
|
+
commandConfig.options.push({
|
|
670
|
+
name: 'help',
|
|
671
|
+
short: 'h',
|
|
672
|
+
type: 'boolean',
|
|
673
|
+
description: `Prints help and instructions for the ${commandConfig.name} command.`,
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
commandConfig.options.forEach(option => {
|
|
677
|
+
this.optionValues[commandConfig.name][option.name] = option.multiple ? [] : undefined;
|
|
678
|
+
});
|
|
679
|
+
this.commands.push(commandConfig);
|
|
680
|
+
return this;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
//# sourceMappingURL=cmdline.js.map
|