@aerokit/sdk 12.44.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/LICENSE +277 -0
- package/README.md +170 -0
- package/dist/cjs/bpm/deployer.js +57 -0
- package/dist/cjs/bpm/index.js +35 -0
- package/dist/cjs/bpm/process.js +636 -0
- package/dist/cjs/bpm/tasks.js +973 -0
- package/dist/cjs/bpm/values.js +82 -0
- package/dist/cjs/cache/cache.js +64 -0
- package/dist/cjs/cache/index.js +26 -0
- package/dist/cjs/cms/cmis.js +689 -0
- package/dist/cjs/cms/index.js +26 -0
- package/dist/cjs/component/decorators.js +126 -0
- package/dist/cjs/component/index.js +36 -0
- package/dist/cjs/core/configurations.js +110 -0
- package/dist/cjs/core/context.js +47 -0
- package/dist/cjs/core/env.js +45 -0
- package/dist/cjs/core/globals.js +54 -0
- package/dist/cjs/core/index.js +35 -0
- package/dist/cjs/db/dao.js +795 -0
- package/dist/cjs/db/database.js +904 -0
- package/dist/cjs/db/decorators.js +167 -0
- package/dist/cjs/db/index.js +72 -0
- package/dist/cjs/db/insert.js +51 -0
- package/dist/cjs/db/orm.js +245 -0
- package/dist/cjs/db/ormstatements.js +243 -0
- package/dist/cjs/db/procedure.js +112 -0
- package/dist/cjs/db/query.js +57 -0
- package/dist/cjs/db/repository.js +148 -0
- package/dist/cjs/db/sequence.js +59 -0
- package/dist/cjs/db/sql.js +516 -0
- package/dist/cjs/db/store.js +172 -0
- package/dist/cjs/db/translator.js +100 -0
- package/dist/cjs/db/update.js +43 -0
- package/dist/cjs/etcd/client.js +174 -0
- package/dist/cjs/etcd/index.js +26 -0
- package/dist/cjs/extensions/decorators.js +40 -0
- package/dist/cjs/extensions/extensions.js +108 -0
- package/dist/cjs/extensions/index.js +39 -0
- package/dist/cjs/git/client.js +277 -0
- package/dist/cjs/git/index.js +26 -0
- package/dist/cjs/http/client-async.js +224 -0
- package/dist/cjs/http/client.js +145 -0
- package/dist/cjs/http/decorators.js +76 -0
- package/dist/cjs/http/errors/ForbiddenError.js +41 -0
- package/dist/cjs/http/errors/ValidationError.js +41 -0
- package/dist/cjs/http/errors.js +26 -0
- package/dist/cjs/http/index.js +59 -0
- package/dist/cjs/http/request.js +281 -0
- package/dist/cjs/http/response.js +452 -0
- package/dist/cjs/http/rs/resource-common.js +32 -0
- package/dist/cjs/http/rs/resource-http-controller.js +306 -0
- package/dist/cjs/http/rs/resource-mappings.js +130 -0
- package/dist/cjs/http/rs/resource-method.js +218 -0
- package/dist/cjs/http/rs/resource.js +232 -0
- package/dist/cjs/http/rs.js +31 -0
- package/dist/cjs/http/session.js +124 -0
- package/dist/cjs/http/upload.js +144 -0
- package/dist/cjs/http/utils.js +106 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/indexing/index.js +29 -0
- package/dist/cjs/indexing/searcher.js +70 -0
- package/dist/cjs/indexing/writer.js +45 -0
- package/dist/cjs/integrations/index.js +26 -0
- package/dist/cjs/integrations/integrations.js +55 -0
- package/dist/cjs/io/bytes.js +101 -0
- package/dist/cjs/io/files.js +344 -0
- package/dist/cjs/io/image.js +43 -0
- package/dist/cjs/io/index.js +38 -0
- package/dist/cjs/io/streams.js +243 -0
- package/dist/cjs/io/zip.js +251 -0
- package/dist/cjs/job/decorators.js +40 -0
- package/dist/cjs/job/index.js +39 -0
- package/dist/cjs/job/scheduler.js +347 -0
- package/dist/cjs/junit/index.js +18 -0
- package/dist/cjs/junit/junit.js +67 -0
- package/dist/cjs/kafka/consumer.js +70 -0
- package/dist/cjs/kafka/index.js +29 -0
- package/dist/cjs/kafka/producer.js +70 -0
- package/dist/cjs/log/index.js +26 -0
- package/dist/cjs/log/logging.js +174 -0
- package/dist/cjs/mail/client.js +153 -0
- package/dist/cjs/mail/index.js +26 -0
- package/dist/cjs/messaging/consumer.js +83 -0
- package/dist/cjs/messaging/decorators.js +40 -0
- package/dist/cjs/messaging/index.js +42 -0
- package/dist/cjs/messaging/producer.js +81 -0
- package/dist/cjs/mongodb/client.js +627 -0
- package/dist/cjs/mongodb/dao.js +390 -0
- package/dist/cjs/mongodb/index.js +36 -0
- package/dist/cjs/net/decorators.js +40 -0
- package/dist/cjs/net/index.js +42 -0
- package/dist/cjs/net/soap.js +228 -0
- package/dist/cjs/net/websockets.js +151 -0
- package/dist/cjs/net/wrappers/onClose.js +2 -0
- package/dist/cjs/net/wrappers/onError.js +2 -0
- package/dist/cjs/net/wrappers/onMessage.js +2 -0
- package/dist/cjs/net/wrappers/onOpen.js +2 -0
- package/dist/cjs/pdf/index.js +26 -0
- package/dist/cjs/pdf/pdf.js +160 -0
- package/dist/cjs/platform/command.js +47 -0
- package/dist/cjs/platform/engines.js +70 -0
- package/dist/cjs/platform/index.js +47 -0
- package/dist/cjs/platform/lifecycle.js +49 -0
- package/dist/cjs/platform/os.js +51 -0
- package/dist/cjs/platform/problems.js +127 -0
- package/dist/cjs/platform/registry.js +319 -0
- package/dist/cjs/platform/repository.js +498 -0
- package/dist/cjs/platform/workspace.js +574 -0
- package/dist/cjs/qldb/index.js +26 -0
- package/dist/cjs/qldb/qldb.js +24 -0
- package/dist/cjs/rabbitmq/consumer.js +50 -0
- package/dist/cjs/rabbitmq/index.js +29 -0
- package/dist/cjs/rabbitmq/producer.js +38 -0
- package/dist/cjs/redis/client.js +190 -0
- package/dist/cjs/redis/index.js +26 -0
- package/dist/cjs/security/decorators.js +48 -0
- package/dist/cjs/security/index.js +40 -0
- package/dist/cjs/security/oauth.js +75 -0
- package/dist/cjs/security/user.js +88 -0
- package/dist/cjs/template/engines.js +139 -0
- package/dist/cjs/template/index.js +26 -0
- package/dist/cjs/utils/alphanumeric.js +107 -0
- package/dist/cjs/utils/base64.js +104 -0
- package/dist/cjs/utils/converter.js +78 -0
- package/dist/cjs/utils/digest.js +167 -0
- package/dist/cjs/utils/escape.js +160 -0
- package/dist/cjs/utils/hex.js +104 -0
- package/dist/cjs/utils/index.js +68 -0
- package/dist/cjs/utils/jsonpath.js +489 -0
- package/dist/cjs/utils/qrcode.js +41 -0
- package/dist/cjs/utils/url.js +82 -0
- package/dist/cjs/utils/utf8.js +61 -0
- package/dist/cjs/utils/uuid.js +48 -0
- package/dist/cjs/utils/xml.js +57 -0
- package/dist/dts/bpm/deployer.d.ts +29 -0
- package/dist/dts/bpm/index.d.ts +8 -0
- package/dist/dts/bpm/process.d.ts +433 -0
- package/dist/dts/bpm/tasks.d.ts +2022 -0
- package/dist/dts/bpm/values.d.ts +38 -0
- package/dist/dts/cache/cache.d.ts +30 -0
- package/dist/dts/cache/index.d.ts +2 -0
- package/dist/dts/cms/cmis.d.ts +413 -0
- package/dist/dts/cms/index.d.ts +2 -0
- package/dist/dts/component/decorators.d.ts +52 -0
- package/dist/dts/component/index.d.ts +2 -0
- package/dist/dts/core/configurations.d.ts +65 -0
- package/dist/dts/core/context.d.ts +19 -0
- package/dist/dts/core/env.d.ts +23 -0
- package/dist/dts/core/globals.d.ts +30 -0
- package/dist/dts/core/index.d.ts +8 -0
- package/dist/dts/db/dao.d.ts +8 -0
- package/dist/dts/db/database.d.ts +507 -0
- package/dist/dts/db/decorators.d.ts +89 -0
- package/dist/dts/db/index.d.ts +25 -0
- package/dist/dts/db/insert.d.ts +32 -0
- package/dist/dts/db/orm.d.ts +44 -0
- package/dist/dts/db/ormstatements.d.ts +4 -0
- package/dist/dts/db/procedure.d.ts +25 -0
- package/dist/dts/db/query.d.ts +48 -0
- package/dist/dts/db/repository.d.ts +64 -0
- package/dist/dts/db/sequence.d.ts +34 -0
- package/dist/dts/db/sql.d.ts +267 -0
- package/dist/dts/db/store.d.ts +138 -0
- package/dist/dts/db/translator.d.ts +26 -0
- package/dist/dts/db/update.d.ts +21 -0
- package/dist/dts/etcd/client.d.ts +92 -0
- package/dist/dts/etcd/index.d.ts +2 -0
- package/dist/dts/extensions/decorators.d.ts +11 -0
- package/dist/dts/extensions/extensions.d.ts +41 -0
- package/dist/dts/extensions/index.d.ts +4 -0
- package/dist/dts/git/client.d.ts +478 -0
- package/dist/dts/git/index.d.ts +2 -0
- package/dist/dts/http/client-async.d.ts +158 -0
- package/dist/dts/http/client.d.ts +180 -0
- package/dist/dts/http/decorators.d.ts +11 -0
- package/dist/dts/http/errors/ForbiddenError.d.ts +20 -0
- package/dist/dts/http/errors/ValidationError.d.ts +20 -0
- package/dist/dts/http/errors.d.ts +2 -0
- package/dist/dts/http/index.d.ts +16 -0
- package/dist/dts/http/request.d.ts +158 -0
- package/dist/dts/http/response.d.ts +281 -0
- package/dist/dts/http/rs/resource-common.d.ts +11 -0
- package/dist/dts/http/rs/resource-http-controller.d.ts +43 -0
- package/dist/dts/http/rs/resource-mappings.d.ts +70 -0
- package/dist/dts/http/rs/resource-method.d.ts +206 -0
- package/dist/dts/http/rs/resource.d.ts +126 -0
- package/dist/dts/http/rs.d.ts +4 -0
- package/dist/dts/http/session.d.ts +81 -0
- package/dist/dts/http/upload.d.ts +100 -0
- package/dist/dts/http/utils.d.ts +54 -0
- package/dist/dts/index.d.ts +0 -0
- package/dist/dts/indexing/index.d.ts +4 -0
- package/dist/dts/indexing/searcher.d.ts +47 -0
- package/dist/dts/indexing/writer.d.ts +22 -0
- package/dist/dts/integrations/index.d.ts +2 -0
- package/dist/dts/integrations/integrations.d.ts +118 -0
- package/dist/dts/io/bytes.d.ts +56 -0
- package/dist/dts/io/files.d.ts +261 -0
- package/dist/dts/io/image.d.ts +22 -0
- package/dist/dts/io/index.d.ts +10 -0
- package/dist/dts/io/streams.d.ts +172 -0
- package/dist/dts/io/zip.d.ts +178 -0
- package/dist/dts/job/decorators.d.ts +11 -0
- package/dist/dts/job/index.d.ts +4 -0
- package/dist/dts/job/scheduler.d.ts +250 -0
- package/dist/dts/junit/index.d.ts +1 -0
- package/dist/dts/junit/junit.d.ts +50 -0
- package/dist/dts/kafka/consumer.d.ts +48 -0
- package/dist/dts/kafka/index.d.ts +4 -0
- package/dist/dts/kafka/producer.d.ts +50 -0
- package/dist/dts/log/index.d.ts +2 -0
- package/dist/dts/log/logging.d.ts +102 -0
- package/dist/dts/mail/client.d.ts +90 -0
- package/dist/dts/mail/index.d.ts +2 -0
- package/dist/dts/messaging/consumer.d.ts +61 -0
- package/dist/dts/messaging/decorators.d.ts +11 -0
- package/dist/dts/messaging/index.d.ts +6 -0
- package/dist/dts/messaging/producer.d.ts +59 -0
- package/dist/dts/mongodb/client.d.ts +367 -0
- package/dist/dts/mongodb/dao.d.ts +24 -0
- package/dist/dts/mongodb/index.d.ts +2 -0
- package/dist/dts/net/decorators.d.ts +11 -0
- package/dist/dts/net/index.d.ts +6 -0
- package/dist/dts/net/soap.d.ts +115 -0
- package/dist/dts/net/websockets.d.ts +100 -0
- package/dist/dts/net/wrappers/onClose.d.ts +0 -0
- package/dist/dts/net/wrappers/onError.d.ts +0 -0
- package/dist/dts/net/wrappers/onMessage.d.ts +0 -0
- package/dist/dts/net/wrappers/onOpen.d.ts +0 -0
- package/dist/dts/pdf/index.d.ts +2 -0
- package/dist/dts/pdf/pdf.d.ts +72 -0
- package/dist/dts/platform/command.d.ts +41 -0
- package/dist/dts/platform/engines.d.ts +35 -0
- package/dist/dts/platform/index.d.ts +16 -0
- package/dist/dts/platform/lifecycle.d.ts +22 -0
- package/dist/dts/platform/os.d.ts +23 -0
- package/dist/dts/platform/problems.d.ts +114 -0
- package/dist/dts/platform/registry.d.ts +227 -0
- package/dist/dts/platform/repository.d.ts +354 -0
- package/dist/dts/platform/workspace.d.ts +421 -0
- package/dist/dts/qldb/index.d.ts +2 -0
- package/dist/dts/qldb/qldb.d.ts +1 -0
- package/dist/dts/rabbitmq/consumer.d.ts +25 -0
- package/dist/dts/rabbitmq/index.d.ts +4 -0
- package/dist/dts/rabbitmq/producer.d.ts +15 -0
- package/dist/dts/redis/client.d.ts +134 -0
- package/dist/dts/redis/index.d.ts +2 -0
- package/dist/dts/security/decorators.d.ts +4 -0
- package/dist/dts/security/index.d.ts +5 -0
- package/dist/dts/security/oauth.d.ts +39 -0
- package/dist/dts/security/user.d.ts +51 -0
- package/dist/dts/template/engines.d.ts +98 -0
- package/dist/dts/template/index.d.ts +2 -0
- package/dist/dts/utils/alphanumeric.d.ts +39 -0
- package/dist/dts/utils/base64.d.ts +48 -0
- package/dist/dts/utils/converter.d.ts +44 -0
- package/dist/dts/utils/digest.d.ts +50 -0
- package/dist/dts/utils/escape.d.ts +110 -0
- package/dist/dts/utils/hex.d.ts +48 -0
- package/dist/dts/utils/index.d.ts +23 -0
- package/dist/dts/utils/jsonpath.d.ts +22 -0
- package/dist/dts/utils/qrcode.d.ts +16 -0
- package/dist/dts/utils/url.d.ts +50 -0
- package/dist/dts/utils/utf8.d.ts +33 -0
- package/dist/dts/utils/uuid.d.ts +21 -0
- package/dist/dts/utils/xml.d.ts +22 -0
- package/dist/esm/bpm/deployer.mjs +38 -0
- package/dist/esm/bpm/index.mjs +15 -0
- package/dist/esm/bpm/process.mjs +617 -0
- package/dist/esm/bpm/tasks.mjs +954 -0
- package/dist/esm/bpm/values.mjs +63 -0
- package/dist/esm/cache/cache.mjs +45 -0
- package/dist/esm/cache/index.mjs +6 -0
- package/dist/esm/cms/cmis.mjs +660 -0
- package/dist/esm/cms/index.mjs +6 -0
- package/dist/esm/component/decorators.mjs +107 -0
- package/dist/esm/component/index.mjs +6 -0
- package/dist/esm/core/configurations.mjs +91 -0
- package/dist/esm/core/context.mjs +28 -0
- package/dist/esm/core/env.mjs +26 -0
- package/dist/esm/core/globals.mjs +35 -0
- package/dist/esm/core/index.mjs +15 -0
- package/dist/esm/db/dao.mjs +775 -0
- package/dist/esm/db/database.mjs +885 -0
- package/dist/esm/db/decorators.mjs +148 -0
- package/dist/esm/db/index.mjs +42 -0
- package/dist/esm/db/insert.mjs +32 -0
- package/dist/esm/db/orm.mjs +225 -0
- package/dist/esm/db/ormstatements.mjs +223 -0
- package/dist/esm/db/procedure.mjs +93 -0
- package/dist/esm/db/query.mjs +38 -0
- package/dist/esm/db/repository.mjs +129 -0
- package/dist/esm/db/sequence.mjs +40 -0
- package/dist/esm/db/sql.mjs +497 -0
- package/dist/esm/db/store.mjs +153 -0
- package/dist/esm/db/translator.mjs +81 -0
- package/dist/esm/db/update.mjs +24 -0
- package/dist/esm/etcd/client.mjs +155 -0
- package/dist/esm/etcd/index.mjs +6 -0
- package/dist/esm/extensions/decorators.mjs +21 -0
- package/dist/esm/extensions/extensions.mjs +89 -0
- package/dist/esm/extensions/index.mjs +9 -0
- package/dist/esm/git/client.mjs +258 -0
- package/dist/esm/git/index.mjs +6 -0
- package/dist/esm/http/client-async.mjs +205 -0
- package/dist/esm/http/client.mjs +126 -0
- package/dist/esm/http/decorators.mjs +47 -0
- package/dist/esm/http/errors/ForbiddenError.mjs +22 -0
- package/dist/esm/http/errors/ValidationError.mjs +22 -0
- package/dist/esm/http/errors.mjs +7 -0
- package/dist/esm/http/index.mjs +29 -0
- package/dist/esm/http/request.mjs +262 -0
- package/dist/esm/http/response.mjs +433 -0
- package/dist/esm/http/rs/resource-common.mjs +13 -0
- package/dist/esm/http/rs/resource-http-controller.mjs +287 -0
- package/dist/esm/http/rs/resource-mappings.mjs +111 -0
- package/dist/esm/http/rs/resource-method.mjs +199 -0
- package/dist/esm/http/rs/resource.mjs +213 -0
- package/dist/esm/http/rs.mjs +12 -0
- package/dist/esm/http/session.mjs +105 -0
- package/dist/esm/http/upload.mjs +125 -0
- package/dist/esm/http/utils.mjs +87 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/indexing/index.mjs +9 -0
- package/dist/esm/indexing/searcher.mjs +51 -0
- package/dist/esm/indexing/writer.mjs +26 -0
- package/dist/esm/integrations/index.mjs +6 -0
- package/dist/esm/integrations/integrations.mjs +36 -0
- package/dist/esm/io/bytes.mjs +82 -0
- package/dist/esm/io/files.mjs +325 -0
- package/dist/esm/io/image.mjs +24 -0
- package/dist/esm/io/index.mjs +18 -0
- package/dist/esm/io/streams.mjs +224 -0
- package/dist/esm/io/zip.mjs +232 -0
- package/dist/esm/job/decorators.mjs +21 -0
- package/dist/esm/job/index.mjs +9 -0
- package/dist/esm/job/scheduler.mjs +328 -0
- package/dist/esm/junit/index.mjs +2 -0
- package/dist/esm/junit/junit.mjs +48 -0
- package/dist/esm/kafka/consumer.mjs +51 -0
- package/dist/esm/kafka/index.mjs +9 -0
- package/dist/esm/kafka/producer.mjs +51 -0
- package/dist/esm/log/index.mjs +6 -0
- package/dist/esm/log/logging.mjs +155 -0
- package/dist/esm/mail/client.mjs +134 -0
- package/dist/esm/mail/index.mjs +6 -0
- package/dist/esm/messaging/consumer.mjs +64 -0
- package/dist/esm/messaging/decorators.mjs +21 -0
- package/dist/esm/messaging/index.mjs +12 -0
- package/dist/esm/messaging/producer.mjs +62 -0
- package/dist/esm/mongodb/client.mjs +608 -0
- package/dist/esm/mongodb/dao.mjs +360 -0
- package/dist/esm/mongodb/index.mjs +7 -0
- package/dist/esm/net/decorators.mjs +21 -0
- package/dist/esm/net/index.mjs +12 -0
- package/dist/esm/net/soap.mjs +209 -0
- package/dist/esm/net/websockets.mjs +132 -0
- package/dist/esm/net/wrappers/onClose.mjs +2 -0
- package/dist/esm/net/wrappers/onError.mjs +2 -0
- package/dist/esm/net/wrappers/onMessage.mjs +2 -0
- package/dist/esm/net/wrappers/onOpen.mjs +2 -0
- package/dist/esm/pdf/index.mjs +6 -0
- package/dist/esm/pdf/pdf.mjs +141 -0
- package/dist/esm/platform/command.mjs +28 -0
- package/dist/esm/platform/engines.mjs +51 -0
- package/dist/esm/platform/index.mjs +27 -0
- package/dist/esm/platform/lifecycle.mjs +30 -0
- package/dist/esm/platform/os.mjs +32 -0
- package/dist/esm/platform/problems.mjs +108 -0
- package/dist/esm/platform/registry.mjs +300 -0
- package/dist/esm/platform/repository.mjs +479 -0
- package/dist/esm/platform/workspace.mjs +555 -0
- package/dist/esm/qldb/index.mjs +6 -0
- package/dist/esm/qldb/qldb.mjs +5 -0
- package/dist/esm/rabbitmq/consumer.mjs +31 -0
- package/dist/esm/rabbitmq/index.mjs +9 -0
- package/dist/esm/rabbitmq/producer.mjs +19 -0
- package/dist/esm/redis/client.mjs +171 -0
- package/dist/esm/redis/index.mjs +6 -0
- package/dist/esm/security/decorators.mjs +29 -0
- package/dist/esm/security/index.mjs +10 -0
- package/dist/esm/security/oauth.mjs +56 -0
- package/dist/esm/security/user.mjs +69 -0
- package/dist/esm/template/engines.mjs +120 -0
- package/dist/esm/template/index.mjs +6 -0
- package/dist/esm/utils/alphanumeric.mjs +88 -0
- package/dist/esm/utils/base64.mjs +85 -0
- package/dist/esm/utils/converter.mjs +59 -0
- package/dist/esm/utils/digest.mjs +148 -0
- package/dist/esm/utils/escape.mjs +141 -0
- package/dist/esm/utils/hex.mjs +85 -0
- package/dist/esm/utils/index.mjs +38 -0
- package/dist/esm/utils/jsonpath.mjs +470 -0
- package/dist/esm/utils/qrcode.mjs +22 -0
- package/dist/esm/utils/url.mjs +63 -0
- package/dist/esm/utils/utf8.mjs +42 -0
- package/dist/esm/utils/uuid.mjs +29 -0
- package/dist/esm/utils/xml.mjs +38 -0
- package/package.json +58 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides a static façade (`Response` class) for managing the HTTP response.
|
|
3
|
+
* This class wraps a native Java HTTP response object, offering methods for setting
|
|
4
|
+
* status codes, headers, cookies, and writing content (text, JSON, or binary).
|
|
5
|
+
*/
|
|
6
|
+
import { OutputStream } from "@aerokit/sdk/io/streams";
|
|
7
|
+
/**
|
|
8
|
+
* Defines the structure for an HTTP cookie, including its name, value, and optional attributes.
|
|
9
|
+
*/
|
|
10
|
+
export interface Cookie {
|
|
11
|
+
/** The name of the cookie. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** The value of the cookie. */
|
|
14
|
+
value: string;
|
|
15
|
+
/** Key-value map of cookie attributes (e.g., 'maxAge', 'path', 'domain', 'secure', 'httpOnly'). */
|
|
16
|
+
attributes: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The static Response class providing standardized HTTP status codes and methods
|
|
22
|
+
* for constructing the server's response.
|
|
23
|
+
*/
|
|
24
|
+
export declare class Response {
|
|
25
|
+
static readonly ACCEPTED = 202;
|
|
26
|
+
static readonly BAD_GATEWAY = 502;
|
|
27
|
+
static readonly BAD_REQUEST = 400;
|
|
28
|
+
static readonly CONFLICT = 409;
|
|
29
|
+
static readonly CONTINUE = 100;
|
|
30
|
+
static readonly CREATED = 201;
|
|
31
|
+
static readonly EXPECTATION_FAILED = 417;
|
|
32
|
+
static readonly FORBIDDEN = 403;
|
|
33
|
+
static readonly FOUND = 302;
|
|
34
|
+
static readonly GATEWAY_TIMEOUT = 504;
|
|
35
|
+
static readonly GONE = 410;
|
|
36
|
+
static readonly HTTP_VERSION_NOT_SUPPORTED = 505;
|
|
37
|
+
static readonly INTERNAL_SERVER_ERROR = 500;
|
|
38
|
+
static readonly LENGTH_REQUIRED = 411;
|
|
39
|
+
static readonly METHOD_NOT_ALLOWED = 405;
|
|
40
|
+
static readonly MOVED_PERMANENTLY = 301;
|
|
41
|
+
static readonly MOVED_TEMPORARILY = 302;
|
|
42
|
+
static readonly MULTIPLE_CHOICES = 300;
|
|
43
|
+
static readonly NO_CONTENT = 204;
|
|
44
|
+
static readonly NON_AUTHORITATIVE_INFORMATION = 203;
|
|
45
|
+
static readonly NOT_ACCEPTABLE = 406;
|
|
46
|
+
static readonly NOT_FOUND = 404;
|
|
47
|
+
static readonly NOT_IMPLEMENTED = 501;
|
|
48
|
+
static readonly NOT_MODIFIED = 304;
|
|
49
|
+
static readonly OK = 200;
|
|
50
|
+
static readonly PARTIAL_CONTENT = 206;
|
|
51
|
+
static readonly PAYMENT_REQUIRED = 402;
|
|
52
|
+
static readonly PRECONDITION_FAILED = 412;
|
|
53
|
+
static readonly PROXY_AUTHENTICATION_REQUIRED = 407;
|
|
54
|
+
static readonly REQUEST_ENTITY_TOO_LARGE = 413;
|
|
55
|
+
static readonly REQUEST_TIMEOUT = 408;
|
|
56
|
+
static readonly REQUEST_URI_TOO_LONG = 414;
|
|
57
|
+
static readonly REQUESTED_RANGE_NOT_SATISFIABLE = 416;
|
|
58
|
+
static readonly RESET_CONTENT = 205;
|
|
59
|
+
static readonly SEE_OTHER = 303;
|
|
60
|
+
static readonly SERVICE_UNAVAILABLE = 503;
|
|
61
|
+
static readonly SWITCHING_PROTOCOLS = 101;
|
|
62
|
+
static readonly TEMPORARY_REDIRECT = 307;
|
|
63
|
+
static readonly UNAUTHORIZED = 401;
|
|
64
|
+
static readonly UNSUPPORTED_MEDIA_TYPE = 415;
|
|
65
|
+
static readonly USE_PROXY = 305;
|
|
66
|
+
static readonly UNPROCESSABLE_CONTENT = 422;
|
|
67
|
+
/**
|
|
68
|
+
* Mapping between HTTP response codes (string) and their corresponding reason-phrases
|
|
69
|
+
* as defined in RFC 7231, section 6.1.
|
|
70
|
+
*/
|
|
71
|
+
static readonly HttpCodesReasons: {
|
|
72
|
+
"100": string;
|
|
73
|
+
"101": string;
|
|
74
|
+
"200": string;
|
|
75
|
+
"201": string;
|
|
76
|
+
"202": string;
|
|
77
|
+
"203": string;
|
|
78
|
+
"204": string;
|
|
79
|
+
"205": string;
|
|
80
|
+
"206": string;
|
|
81
|
+
"300": string;
|
|
82
|
+
"301": string;
|
|
83
|
+
"302": string;
|
|
84
|
+
"303": string;
|
|
85
|
+
"304": string;
|
|
86
|
+
"305": string;
|
|
87
|
+
"307": string;
|
|
88
|
+
"400": string;
|
|
89
|
+
"401": string;
|
|
90
|
+
"402": string;
|
|
91
|
+
"403": string;
|
|
92
|
+
"404": string;
|
|
93
|
+
"405": string;
|
|
94
|
+
"406": string;
|
|
95
|
+
"407": string;
|
|
96
|
+
"408": string;
|
|
97
|
+
"409": string;
|
|
98
|
+
"410": string;
|
|
99
|
+
"411": string;
|
|
100
|
+
"412": string;
|
|
101
|
+
"413": string;
|
|
102
|
+
"414": string;
|
|
103
|
+
"415": string;
|
|
104
|
+
"416": string;
|
|
105
|
+
"417": string;
|
|
106
|
+
"422": string;
|
|
107
|
+
"426": string;
|
|
108
|
+
"500": string;
|
|
109
|
+
"501": string;
|
|
110
|
+
"502": string;
|
|
111
|
+
"503": string;
|
|
112
|
+
"504": string;
|
|
113
|
+
"505": string;
|
|
114
|
+
/**
|
|
115
|
+
* Utility method that accepts an HTTP code and returns its corresponding reason-phrase.
|
|
116
|
+
* @param code The HTTP status code (number).
|
|
117
|
+
* @returns The reason phrase string.
|
|
118
|
+
* @throws Error if the code is not a valid integer in the range [100-505].
|
|
119
|
+
*/
|
|
120
|
+
getReason: (code: number) => string;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Checks if the response façade is currently valid or connected to an active request context.
|
|
124
|
+
* @returns True if valid, false otherwise.
|
|
125
|
+
*/
|
|
126
|
+
static isValid(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Serializes a JavaScript object to JSON, sets the `Content-Type: application/json` header,
|
|
129
|
+
* and writes the JSON string to the response output stream.
|
|
130
|
+
* @param obj The JavaScript object to be serialized and sent.
|
|
131
|
+
*/
|
|
132
|
+
static json(obj: any): void;
|
|
133
|
+
/**
|
|
134
|
+
* Writes a string of text to the response body using **UTF-8** encoding.
|
|
135
|
+
* Note: This method automatically handles flushing the output stream.
|
|
136
|
+
* @param text The string content to write.
|
|
137
|
+
*/
|
|
138
|
+
static print(text: string): void;
|
|
139
|
+
/**
|
|
140
|
+
* Writes a string of text followed by a newline character (`\n`) to the response body
|
|
141
|
+
* using **UTF-8** encoding.
|
|
142
|
+
* @param text The string content to write.
|
|
143
|
+
*/
|
|
144
|
+
static println(text: string): void;
|
|
145
|
+
/**
|
|
146
|
+
* Writes an array of bytes directly to the response output stream, typically used for binary data.
|
|
147
|
+
* @param bytes The array of bytes to write.
|
|
148
|
+
*/
|
|
149
|
+
static write(bytes: any[]): void;
|
|
150
|
+
/**
|
|
151
|
+
* Checks if the response headers and status have already been sent to the client.
|
|
152
|
+
* @returns True if the response is committed, false otherwise.
|
|
153
|
+
*/
|
|
154
|
+
static isCommitted(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Sets the value of the `Content-Type` header.
|
|
157
|
+
* @param contentType The MIME type string (e.g., 'text/html', 'application/pdf').
|
|
158
|
+
*/
|
|
159
|
+
static setContentType(contentType: string): void;
|
|
160
|
+
/**
|
|
161
|
+
* Forces any buffered output to be written to the client.
|
|
162
|
+
*/
|
|
163
|
+
static flush(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Closes the response output stream.
|
|
166
|
+
*/
|
|
167
|
+
static close(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Adds a cookie to the response. The cookie object is serialized to JSON before being passed
|
|
170
|
+
* to the underlying Java facade.
|
|
171
|
+
* @param cookie The cookie definition object.
|
|
172
|
+
*/
|
|
173
|
+
static addCookie(cookie: Cookie): void;
|
|
174
|
+
/**
|
|
175
|
+
* Checks if a response header with the specified name has already been set.
|
|
176
|
+
* @param name The name of the header.
|
|
177
|
+
* @returns True if the header exists, false otherwise.
|
|
178
|
+
*/
|
|
179
|
+
static containsHeader(name: string): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Encodes a URL for use in redirects or forms, including session information if necessary.
|
|
182
|
+
* @param url The URL to encode.
|
|
183
|
+
* @returns The encoded URL string.
|
|
184
|
+
*/
|
|
185
|
+
static encodeURL(url: string): string;
|
|
186
|
+
/**
|
|
187
|
+
* Gets the character encoding used for the response body.
|
|
188
|
+
* @returns The character encoding string.
|
|
189
|
+
*/
|
|
190
|
+
static getCharacterEncoding(): string;
|
|
191
|
+
/**
|
|
192
|
+
* Encodes a URL for use in the `Location` header of a redirect response.
|
|
193
|
+
* @param url The redirect URL to encode.
|
|
194
|
+
* @returns The encoded redirect URL string.
|
|
195
|
+
*/
|
|
196
|
+
static encodeRedirectURL(url: string): string;
|
|
197
|
+
/**
|
|
198
|
+
* Gets the current `Content-Type` header value.
|
|
199
|
+
* @returns The content type string.
|
|
200
|
+
*/
|
|
201
|
+
static getContentType(): string;
|
|
202
|
+
/**
|
|
203
|
+
* Sends an HTTP error response to the client with the specified status code and optional message.
|
|
204
|
+
* This bypasses the normal response body writing process.
|
|
205
|
+
* @param status The HTTP status code (e.g., 404, 500).
|
|
206
|
+
* @param message An optional message to include in the error response.
|
|
207
|
+
*/
|
|
208
|
+
static sendError(status: number, message?: string): void;
|
|
209
|
+
/**
|
|
210
|
+
* Sets the character encoding to be used for the response body (e.g., 'UTF-8').
|
|
211
|
+
* @param charset The character set string.
|
|
212
|
+
*/
|
|
213
|
+
static setCharacterEncoding(charset: string): void;
|
|
214
|
+
/**
|
|
215
|
+
* Sends a redirect response (status code 302 by default) to the client.
|
|
216
|
+
* @param location The new URL to redirect the client to.
|
|
217
|
+
*/
|
|
218
|
+
static sendRedirect(location: string): void;
|
|
219
|
+
/**
|
|
220
|
+
* Sets the `Content-Length` header for the response.
|
|
221
|
+
* @param length The size of the response body in bytes.
|
|
222
|
+
*/
|
|
223
|
+
static setContentLength(length: number): void;
|
|
224
|
+
/**
|
|
225
|
+
* Sets a response header with the given name and value. If the header already exists, its value is overwritten.
|
|
226
|
+
* @param name The name of the header.
|
|
227
|
+
* @param value The value of the header.
|
|
228
|
+
*/
|
|
229
|
+
static setHeader(name: string, value: string): void;
|
|
230
|
+
/**
|
|
231
|
+
* Adds a response header with the given name and value. If the header already exists, a second header with the same name is added.
|
|
232
|
+
* @param name The name of the header.
|
|
233
|
+
* @param value The value of the header.
|
|
234
|
+
*/
|
|
235
|
+
static addHeader(name: string, value: string): void;
|
|
236
|
+
/**
|
|
237
|
+
* Sets the HTTP status code for the response.
|
|
238
|
+
* @param status The integer status code (e.g., 200, 404).
|
|
239
|
+
*/
|
|
240
|
+
static setStatus(status: number): void;
|
|
241
|
+
/**
|
|
242
|
+
* Clears all buffers, status code, and headers from the response, allowing a new response to be generated.
|
|
243
|
+
* This is only possible if the response has not yet been committed.
|
|
244
|
+
*/
|
|
245
|
+
static reset(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Gets the value of a specific header. If multiple headers with the same name exist, it returns the first one.
|
|
248
|
+
* @param name The name of the header.
|
|
249
|
+
* @returns The header value string.
|
|
250
|
+
*/
|
|
251
|
+
static getHeader(name: string): string;
|
|
252
|
+
/**
|
|
253
|
+
* Sets the locale for the response, which may affect language and date/time formatting.
|
|
254
|
+
* @param language The language code (e.g., 'en', 'fr').
|
|
255
|
+
* @param country The optional country code (e.g., 'US', 'GB').
|
|
256
|
+
* @param variant The optional variant code.
|
|
257
|
+
*/
|
|
258
|
+
static setLocale(language: string, country?: string, variant?: string): void;
|
|
259
|
+
/**
|
|
260
|
+
* Gets all header values for a specific header name as an array of strings.
|
|
261
|
+
* @param name The name of the header.
|
|
262
|
+
* @returns An array of header values.
|
|
263
|
+
*/
|
|
264
|
+
static getHeaders(name: string): string[];
|
|
265
|
+
/**
|
|
266
|
+
* Gets the names of all headers that have been set on the response.
|
|
267
|
+
* @returns An array of header names.
|
|
268
|
+
*/
|
|
269
|
+
static getHeaderNames(): string[];
|
|
270
|
+
/**
|
|
271
|
+
* Gets the currently set locale string for the response.
|
|
272
|
+
* @returns The locale string.
|
|
273
|
+
*/
|
|
274
|
+
static getLocale(): string;
|
|
275
|
+
/**
|
|
276
|
+
* Gets the underlying output stream object, wrapped in the SDK's `OutputStream` class.
|
|
277
|
+
* This is useful for writing raw or large amounts of data.
|
|
278
|
+
* @returns The output stream object.
|
|
279
|
+
*/
|
|
280
|
+
static getOutputStream(): OutputStream;
|
|
281
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commmon function for initializng the callback functions in the ResourceMethod instances.
|
|
3
|
+
*
|
|
4
|
+
* @param thiz The ResourceMethod instance to which the function is bound (or Resource instance in the case of redirect).
|
|
5
|
+
* @param configuration The configuration object where the handler will be attached.
|
|
6
|
+
* @param sHandlerFuncName The name of the function that will be attached to the resource mappings configuration (e.g., 'serve', 'redirect').
|
|
7
|
+
* @param fHandler The handler function or value that will be attached to the resource mappings configuration.
|
|
8
|
+
* @returns The instance passed in as 'thiz' for method chaining.
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export declare function handlerFunction(thiz: any, configuration: any, sHandlerFuncName: string, fHandler: Function | string): any;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ResourceMappings } from "./resource-mappings";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a service (HttpController) instance, optionally initialized with oMappings.
|
|
4
|
+
*
|
|
5
|
+
* @param oConfig Configuration object or configuration builder with configuration() getter function.
|
|
6
|
+
* @returns A new HttpController instance.
|
|
7
|
+
*/
|
|
8
|
+
export declare function service(oConfig?: any): HttpController;
|
|
9
|
+
/**
|
|
10
|
+
* The main class for handling HTTP requests and routing them to the correct resource handlers.
|
|
11
|
+
*/
|
|
12
|
+
export declare class HttpController {
|
|
13
|
+
resource: Function;
|
|
14
|
+
resourcePath: Function;
|
|
15
|
+
resourceMappings: ResourceMappings;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
/**
|
|
18
|
+
* Constructor function for HttpController instances.
|
|
19
|
+
*
|
|
20
|
+
* @param oMappings The mappings configuration for this controller.
|
|
21
|
+
*/
|
|
22
|
+
constructor(oMappings?: ResourceMappings | any);
|
|
23
|
+
/**
|
|
24
|
+
* Alias for execute.
|
|
25
|
+
*/
|
|
26
|
+
listen(request: any, response: any): void;
|
|
27
|
+
/**
|
|
28
|
+
* Executes the request handling logic, finding the best matching resource and handler.
|
|
29
|
+
*/
|
|
30
|
+
execute(request?: any, response?: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the ResourceMappings instance of this controller.
|
|
33
|
+
*/
|
|
34
|
+
mappings(): ResourceMappings;
|
|
35
|
+
/**
|
|
36
|
+
* Sends an error response to the client, formatted based on the accepted media type.
|
|
37
|
+
*/
|
|
38
|
+
sendError(httpErrorCode: number, applicationErrorCode: any, errorName: string, errorDetails: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Flushes and closes the HTTP response stream.
|
|
41
|
+
*/
|
|
42
|
+
closeResponse(): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Resource } from "./resource";
|
|
2
|
+
/**
|
|
3
|
+
* The ResourceMappings class abstracts the mappings between resource URL path templates
|
|
4
|
+
* and their corresponding resource handler specifications. It acts as the configuration
|
|
5
|
+
* store for the HttpController.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ResourceMappings {
|
|
8
|
+
resources: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
controller: any;
|
|
12
|
+
execute: any;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor function for ResourceMappings instances.
|
|
15
|
+
*
|
|
16
|
+
* @param oConfiguration Configuration object defining initial resource paths and their handlers.
|
|
17
|
+
* @param controller The HttpController instance, for which this ResourceMappings handles configuration.
|
|
18
|
+
*/
|
|
19
|
+
constructor(oConfiguration: any, controller: any);
|
|
20
|
+
/**
|
|
21
|
+
* Creates or retrieves a Resource object corresponding to the given path.
|
|
22
|
+
* The second, optional argument can be used to initialize the resource.
|
|
23
|
+
*
|
|
24
|
+
* @param sPath The URL path template for the resource (e.g., "users/{id}").
|
|
25
|
+
* @param oConfiguration Optional configuration object for initial resource setup.
|
|
26
|
+
* @returns The created or existing Resource instance.
|
|
27
|
+
*/
|
|
28
|
+
path(sPath: string, oConfiguration?: any): Resource;
|
|
29
|
+
/**
|
|
30
|
+
* Alias for path().
|
|
31
|
+
*/
|
|
32
|
+
resourcePath(sPath: string, oConfiguration?: any): Resource;
|
|
33
|
+
/**
|
|
34
|
+
* Alias for path().
|
|
35
|
+
*/
|
|
36
|
+
resource(sPath: string, oConfiguration?: any): Resource;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the compiled configuration object for all resources managed by this ResourceMappings.
|
|
39
|
+
* The configuration is structured to be consumed by the HttpController's routing logic.
|
|
40
|
+
*/
|
|
41
|
+
configuration(): {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Removes all but GET resource handlers from all managed resources, making them read-only.
|
|
46
|
+
*
|
|
47
|
+
* @returns The ResourceMappings instance for method chaining.
|
|
48
|
+
*/
|
|
49
|
+
readonly(): this;
|
|
50
|
+
/**
|
|
51
|
+
* Disables resource handling specifications matching the arguments, effectively removing them from this API.
|
|
52
|
+
*
|
|
53
|
+
* @param sPath The path of the resource.
|
|
54
|
+
* @param sVerb The HTTP verb (e.g., 'get', 'post').
|
|
55
|
+
* @param arrConsumes Array of consumed media types.
|
|
56
|
+
* @param arrProduces Array of produced media types.
|
|
57
|
+
* @returns The ResourceMappings instance for method chaining.
|
|
58
|
+
*/
|
|
59
|
+
disable(sPath: string, sVerb: string, arrConsumes: string[], arrProduces: string[]): this;
|
|
60
|
+
/**
|
|
61
|
+
* Provides a reference to a handler specification matching the supplied arguments.
|
|
62
|
+
*
|
|
63
|
+
* @param sPath The path of the resource.
|
|
64
|
+
* @param sVerb The HTTP verb (e.g., 'get', 'post').
|
|
65
|
+
* @param arrConsumes Array of consumed media types.
|
|
66
|
+
* @param arrProduces Array of produced media types.
|
|
67
|
+
* @returns The matching Resource handler specification or undefined.
|
|
68
|
+
*/
|
|
69
|
+
find(sPath: string, sVerb: string, arrConsumes: string[], arrProduces: string[]): any | undefined;
|
|
70
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for the internal configuration object of a ResourceMethod.
|
|
3
|
+
*/
|
|
4
|
+
interface ResourceMethodConfig {
|
|
5
|
+
consumes?: string[];
|
|
6
|
+
produces?: string[];
|
|
7
|
+
before?: Function;
|
|
8
|
+
serve?: Function;
|
|
9
|
+
catch?: Function;
|
|
10
|
+
finally?: Function;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Constructor function for ResourceMethod instances.
|
|
15
|
+
* This class handles the fluent configuration for a single HTTP method handler (e.g., GET)
|
|
16
|
+
* attached to a Resource.
|
|
17
|
+
*
|
|
18
|
+
* /**
|
|
19
|
+
* Constructor function for ResourceMethod instances.
|
|
20
|
+
* All parameters of the function are optional.
|
|
21
|
+
*
|
|
22
|
+
* Providing oConfiguration will initialize this instance with some initial configuration instead of starting
|
|
23
|
+
* entirely from scratch. Note that the configuration object schema must be compliant with the one produced by
|
|
24
|
+
* the ResourceMethod itself. If this parameter is omited, setup will start from scratch.
|
|
25
|
+
*
|
|
26
|
+
* Provisioning controller, will inject a reference to the execute method of the controller so that it can be
|
|
27
|
+
* fluently invoked in the scope of this ResourceMehtod instance as part of the method chaining flow. The execute
|
|
28
|
+
* function scope is bound to the controller instance for this ResourceMethod.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```js
|
|
32
|
+
* rs.service()
|
|
33
|
+
* .resource('')
|
|
34
|
+
* .get()
|
|
35
|
+
* .execute();
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Provisioning resource, will inject a reference ot the HTTP method functions of the Resource class (get, post,
|
|
39
|
+
* put, delete, remove, method) so that they can be fluently invoked in the scope of this ResourceMethod instance
|
|
40
|
+
* as part of the method chaining flow. The functions are bound to the resource instance for this ResourceMethod.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```js
|
|
44
|
+
* rs.service()
|
|
45
|
+
* .resource('')
|
|
46
|
+
* .get(function(){})
|
|
47
|
+
* .post(function(){})
|
|
48
|
+
* .put(function(){})
|
|
49
|
+
* .remove(function(){})
|
|
50
|
+
* .execute();
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* Provisioning mappings, will inject a reference ot the resource method of the ResourceMappings class so that
|
|
54
|
+
* it can be fluently invoked in the scope of this ResourceMethod instance as part of the method chaining flow.
|
|
55
|
+
* The function is bound to the mappings instance for this ResourceMethod.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```js
|
|
59
|
+
* rs.service()
|
|
60
|
+
* .resource('')
|
|
61
|
+
* .get(function(){})
|
|
62
|
+
* .resource('{id}')
|
|
63
|
+
* .get(function(){})
|
|
64
|
+
* .execute();
|
|
65
|
+
* ``
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
export declare class ResourceMethod {
|
|
69
|
+
cfg: ResourceMethodConfig;
|
|
70
|
+
_resource: any;
|
|
71
|
+
controller: any;
|
|
72
|
+
resource: Function;
|
|
73
|
+
resourcePath: Function;
|
|
74
|
+
path: Function;
|
|
75
|
+
/**
|
|
76
|
+
* @param oConfiguration Initial configuration object.
|
|
77
|
+
* @param controller The HttpController instance.
|
|
78
|
+
* @param resource The parent Resource instance.
|
|
79
|
+
* @param mappings The parent ResourceMappings instance.
|
|
80
|
+
* @returns {ResourceMethod}
|
|
81
|
+
*/
|
|
82
|
+
constructor(oConfiguration: any, controller: any, resource: any, mappings: any);
|
|
83
|
+
/**
|
|
84
|
+
* Delegates to the HttpController's execute function to process the request.
|
|
85
|
+
*/
|
|
86
|
+
execute(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Delegates to the parent Resource's 'get' method.
|
|
89
|
+
*/
|
|
90
|
+
get(): any;
|
|
91
|
+
/**
|
|
92
|
+
* Delegates to the parent Resource's 'post' method.
|
|
93
|
+
*/
|
|
94
|
+
post(): any;
|
|
95
|
+
/**
|
|
96
|
+
* Delegates to the parent Resource's 'put' method.
|
|
97
|
+
*/
|
|
98
|
+
put(): any;
|
|
99
|
+
/**
|
|
100
|
+
* Delegates to the parent Resource's 'delete' method.
|
|
101
|
+
*/
|
|
102
|
+
delete(): any;
|
|
103
|
+
/**
|
|
104
|
+
* Delegates to the parent Resource's 'remove' method.
|
|
105
|
+
*/
|
|
106
|
+
remove(): any;
|
|
107
|
+
/**
|
|
108
|
+
* Delegates to the parent Resource's 'method' method.
|
|
109
|
+
*/
|
|
110
|
+
method(): any;
|
|
111
|
+
/**
|
|
112
|
+
* Returns the configuration object for this ResourceMethod instance.
|
|
113
|
+
*
|
|
114
|
+
* @returns The configuration object.
|
|
115
|
+
*/
|
|
116
|
+
configuration(): ResourceMethodConfig;
|
|
117
|
+
/**
|
|
118
|
+
* Applies a callback function for the **before** phase of processing a matched resource request.
|
|
119
|
+
*
|
|
120
|
+
* @param fHandler Callback function for the before phase.
|
|
121
|
+
* @returns The ResourceMethod instance for method chaining.
|
|
122
|
+
*/
|
|
123
|
+
before(fHandler: Function): ResourceMethod;
|
|
124
|
+
/**
|
|
125
|
+
* Applies a callback function for processing a matched resource request (**serve** phase).
|
|
126
|
+
*
|
|
127
|
+
* @param fHandler Callback function for the serve phase.
|
|
128
|
+
* @returns The ResourceMethod instance for method chaining.
|
|
129
|
+
*/
|
|
130
|
+
serve(fHandler: Function): ResourceMethod;
|
|
131
|
+
/**
|
|
132
|
+
* Applies a callback function for the **catch** errors phase of processing a matched resource request.
|
|
133
|
+
*
|
|
134
|
+
* @param fHandler Callback function for the catch phase.
|
|
135
|
+
* @returns The ResourceMethod instance for method chaining.
|
|
136
|
+
*/
|
|
137
|
+
catch(fHandler: Function): ResourceMethod;
|
|
138
|
+
/**
|
|
139
|
+
* Applies a callback function for the **finally** phase of processing a matched resource request.
|
|
140
|
+
*
|
|
141
|
+
* @param fHandler Callback function for the finally phase.
|
|
142
|
+
* @returns The ResourceMethod instance for method chaining.
|
|
143
|
+
*/
|
|
144
|
+
finally(fHandler: Function): ResourceMethod;
|
|
145
|
+
/**
|
|
146
|
+
* Defines the content MIME type(s), which this ResourceMethod expects as input (**consumes**).
|
|
147
|
+
*
|
|
148
|
+
* @param mimeTypes Sets the mime types that this ResourceMethod is capable to consume.
|
|
149
|
+
* @returns The ResourceMethod instance for method chaining.
|
|
150
|
+
*/
|
|
151
|
+
consumes(mimeTypes: string | string[]): ResourceMethod;
|
|
152
|
+
/**
|
|
153
|
+
* Defines the HTTP response payload MIME type(s), which this ResourceMethod request processing function outputs, i.e.
|
|
154
|
+
* those that it 'produces'. At runtime, the Accept request header will be matched for compatibility with this setting
|
|
155
|
+
* to elicit request processing functions.
|
|
156
|
+
* Note that the matching is performed by compatibility, not strict equality, i.e. the MIME type format wildcards are
|
|
157
|
+
* considered too. For example, a request Accept header "*\/json" will match a produces setting "application\/json".
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```js
|
|
161
|
+
* rs.service()
|
|
162
|
+
* .resource("")
|
|
163
|
+
* .get(function(){})
|
|
164
|
+
* .produces(["application\/json"])
|
|
165
|
+
* .execute();
|
|
166
|
+
* .
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* Take care to make sure that the produces constraint correctly describes the response contenty MIME types that the request
|
|
170
|
+
* processing function can produce so that only client request that can accept them land there.
|
|
171
|
+
*
|
|
172
|
+
* A note about method argument multiplicity (string vs array of strings).
|
|
173
|
+
* One of the arguments of the produce method will translate to the response Content-Type property, which is known to be a
|
|
174
|
+
* single value header by [specification](https://tools.ietf.org/html/rfc7231#section-3.1.1.5). There are two reasons why
|
|
175
|
+
* the method accepts array and not a single value only:
|
|
176
|
+
*
|
|
177
|
+
* 1. Normally, when matched, content types are evaluated for semantic compatibility and not strict equality on both sides
|
|
178
|
+
* - client and server. Providing a range of compatible MIME types instead of single value, increases the range of acceptable
|
|
179
|
+
* requests for procesing, while reducing the stricness of the requirements on the client making the request. For example,
|
|
180
|
+
* declaring ["text/json,"application/json"] as produced types makes requests with any of these accept headers (or a combination
|
|
181
|
+
* of them) acceptable for processing: "*\/json", "text/json", "application/json", "*\/*".
|
|
182
|
+
*
|
|
183
|
+
* 2. Although in most cases a handler function will produce payload in single format (media type), it is quite possible to
|
|
184
|
+
* desgin it also as a controller that produces alternative payload in different formats. In these cases you need produces
|
|
185
|
+
* that declares all supported media types so that the request with a relaxed Accept header matching any of them can land
|
|
186
|
+
* in this function. That makes the routing a bit less transparent and dependent on the client, but may prove valuable for
|
|
187
|
+
* certian cases.
|
|
188
|
+
*
|
|
189
|
+
* In any case it is responsibility of the request processing function to set the correct Content-Type header.
|
|
190
|
+
*
|
|
191
|
+
* @param mimeTypes Sets the mime type(s) that this ResourceMethod may produce.
|
|
192
|
+
* @returns The ResourceMethod instance for method chaining.
|
|
193
|
+
*/
|
|
194
|
+
produces(mimeTypes: string | string[]): ResourceMethod;
|
|
195
|
+
/**
|
|
196
|
+
* Commmon function for initializng the 'consumes' and 'produces' arrays in the ResourceMethod instances.
|
|
197
|
+
* Before finalizing the configuration setup the function will remove duplicates with exact match filtering.
|
|
198
|
+
*
|
|
199
|
+
* @param mimeSettingName must be either 'consumes' or 'produces'.
|
|
200
|
+
* @param mimeTypes An array of strings formatted as mime types (type/subtype) or a single string.
|
|
201
|
+
* @returns The ResourceMethod instance to which the function is bound.
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
private mimeSetting;
|
|
205
|
+
}
|
|
206
|
+
export {};
|