@venizia/ignis 0.4.8-0 → 0.4.8-10
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 +7 -14
- package/dist/esm/base/applications/base.d.ts +19 -0
- package/dist/esm/base/applications/base.js +19 -0
- package/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/base/applications/boot-steps.d.ts +1 -0
- package/dist/esm/base/applications/boot-steps.js.map +1 -1
- package/dist/esm/base/applications/common/types.d.ts +21 -4
- package/dist/esm/base/applications/common/types.js.map +1 -1
- package/dist/esm/base/applications/server.d.ts +12 -0
- package/dist/esm/base/applications/server.js +11 -0
- package/dist/esm/base/applications/server.js.map +1 -1
- package/dist/esm/base/metadata/request-context.d.ts +1 -0
- package/dist/esm/base/metadata/request-context.js +1 -0
- package/dist/esm/base/metadata/request-context.js.map +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts +1 -0
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +9 -2
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
- package/dist/esm/components/api-reference/common/constants.d.ts +1 -0
- package/dist/esm/components/api-reference/common/constants.js +1 -0
- package/dist/esm/components/api-reference/common/constants.js.map +1 -1
- package/dist/esm/components/api-reference/common/keys.d.ts +1 -0
- package/dist/esm/components/api-reference/common/keys.js +1 -0
- package/dist/esm/components/api-reference/common/keys.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +18 -1
- package/dist/esm/components/api-reference/common/types.js.map +1 -1
- package/dist/esm/components/api-reference/component.d.ts +14 -0
- package/dist/esm/components/api-reference/component.js +14 -0
- package/dist/esm/components/api-reference/component.js.map +1 -1
- package/dist/esm/components/api-reference/ui/factory.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/factory.js +1 -0
- package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
- package/dist/esm/components/api-reference/ui/scalar.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/scalar.js +1 -0
- package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
- package/dist/esm/components/api-reference/ui/swagger.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/swagger.js +1 -0
- package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/component.js +38 -1
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +2 -0
- package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -0
- package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js +1 -0
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +56 -5
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +115 -11
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +3 -2
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +11 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +11 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +25 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/index.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/index.js +1 -0
- package/dist/esm/components/auth/authenticate/services/index.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +42 -0
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +162 -0
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -0
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +7 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js +2 -4
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts +1 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.js +3 -2
- package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +2 -0
- package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/connector.d.ts +2 -2
- package/dist/esm/components/auth/authorize/adapters/connector.js +3 -2
- package/dist/esm/components/auth/authorize/adapters/connector.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js +1 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts +2 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts +1 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js +1 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js.map +1 -1
- package/dist/esm/components/auth/authorize/component.d.ts +1 -0
- package/dist/esm/components/auth/authorize/component.js +1 -0
- package/dist/esm/components/auth/authorize/component.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts +1 -0
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js +1 -0
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
- package/dist/esm/components/auth/models/entities/columns.d.ts +1 -0
- package/dist/esm/components/auth/models/entities/columns.js.map +1 -1
- package/dist/esm/components/auth/models/entities/permission.model.d.ts +2 -0
- package/dist/esm/components/auth/models/entities/permission.model.js.map +1 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts +1 -0
- package/dist/esm/components/auth/models/entities/policy-definition.model.js.map +1 -1
- package/dist/esm/components/controller/grpc/common/types.d.ts +2 -0
- package/dist/esm/components/controller/grpc/common/types.js +1 -0
- package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
- package/dist/esm/components/controller/grpc/grpc.component.d.ts +1 -0
- package/dist/esm/components/controller/grpc/grpc.component.js +1 -0
- package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
- package/dist/esm/components/health-check/common/constants.d.ts +1 -0
- package/dist/esm/components/health-check/common/constants.js +1 -0
- package/dist/esm/components/health-check/common/constants.js.map +1 -1
- package/dist/esm/components/health-check/common/keys.d.ts +1 -0
- package/dist/esm/components/health-check/common/keys.js +1 -0
- package/dist/esm/components/health-check/common/keys.js.map +1 -1
- package/dist/esm/components/health-check/common/rest-paths.d.ts +1 -0
- package/dist/esm/components/health-check/common/rest-paths.js +1 -0
- package/dist/esm/components/health-check/common/rest-paths.js.map +1 -1
- package/dist/esm/components/health-check/common/types.d.ts +24 -3
- package/dist/esm/components/health-check/common/types.js.map +1 -1
- package/dist/esm/components/health-check/component.d.ts +15 -0
- package/dist/esm/components/health-check/component.js +15 -0
- package/dist/esm/components/health-check/component.js.map +1 -1
- package/dist/esm/components/health-check/controller.d.ts +1 -0
- package/dist/esm/components/health-check/controller.js +1 -0
- package/dist/esm/components/health-check/controller.js.map +1 -1
- package/dist/esm/components/health-check/reporter.js +2 -2
- package/dist/esm/components/health-check/reporter.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/mail/common/constants.d.ts +6 -0
- package/dist/esm/components/mail/common/constants.js +5 -0
- package/dist/esm/components/mail/common/constants.js.map +1 -1
- package/dist/esm/components/mail/common/keys.d.ts +1 -0
- package/dist/esm/components/mail/common/keys.js +1 -0
- package/dist/esm/components/mail/common/keys.js.map +1 -1
- package/dist/esm/components/mail/common/types/message.d.ts +10 -0
- package/dist/esm/components/mail/common/types/message.js.map +1 -1
- package/dist/esm/components/mail/common/types/options.d.ts +22 -1
- package/dist/esm/components/mail/common/types/options.js.map +1 -1
- package/dist/esm/components/mail/common/types/queue.d.ts +7 -0
- package/dist/esm/components/mail/common/types/queue.js.map +1 -1
- package/dist/esm/components/mail/common/types/template.d.ts +2 -0
- package/dist/esm/components/mail/common/types/template.js.map +1 -1
- package/dist/esm/components/mail/common/types/verification.d.ts +6 -0
- package/dist/esm/components/mail/common/types/verification.js.map +1 -1
- package/dist/esm/components/mail/component.d.ts +1 -0
- package/dist/esm/components/mail/component.js +1 -0
- package/dist/esm/components/mail/component.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -0
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +1 -0
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts +2 -0
- package/dist/esm/components/mail/providers/mail-transporter.provider.js +1 -0
- package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
- package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -5
- package/dist/esm/components/mail/services/generators/numeric-code.js +3 -30
- package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
- package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -0
- package/dist/esm/components/mail/services/generators/random-token.js +9 -5
- package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
- package/dist/esm/components/mail/services/generators/verification-data.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/verification-data.js +1 -0
- package/dist/esm/components/mail/services/generators/verification-data.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.d.ts +1 -0
- package/dist/esm/components/mail/services/mail.service.js +1 -0
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +1 -0
- package/dist/esm/components/mail/services/template.service.js +1 -0
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/address.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/address.utility.js +1 -0
- package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/mime.utility.js +5 -4
- package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/verification.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/verification.utility.js +1 -0
- package/dist/esm/components/mail/utilities/verification.utility.js.map +1 -1
- package/dist/esm/components/request-tracker/component.d.ts +1 -0
- package/dist/esm/components/request-tracker/component.js +1 -0
- package/dist/esm/components/request-tracker/component.js.map +1 -1
- package/dist/esm/components/server-info/common/constants.d.ts +6 -0
- package/dist/esm/components/server-info/common/constants.js +6 -0
- package/dist/esm/components/server-info/common/constants.js.map +1 -0
- package/dist/esm/components/server-info/common/index.d.ts +5 -0
- package/dist/esm/components/server-info/common/index.js +5 -0
- package/dist/esm/components/server-info/common/index.js.map +1 -0
- package/dist/esm/components/server-info/common/keys.d.ts +5 -0
- package/dist/esm/components/server-info/common/keys.js +5 -0
- package/dist/esm/components/server-info/common/keys.js.map +1 -0
- package/dist/esm/components/server-info/common/rest-paths.d.ts +5 -0
- package/dist/esm/components/server-info/common/rest-paths.js +5 -0
- package/dist/esm/components/server-info/common/rest-paths.js.map +1 -0
- package/dist/esm/components/server-info/common/types.d.ts +68 -0
- package/dist/esm/components/server-info/common/types.js +2 -0
- package/dist/esm/components/server-info/common/types.js.map +1 -0
- package/dist/esm/components/server-info/component.d.ts +31 -0
- package/dist/esm/components/server-info/component.js +87 -0
- package/dist/esm/components/server-info/component.js.map +1 -0
- package/dist/esm/components/server-info/controller.d.ts +14 -0
- package/dist/esm/components/server-info/controller.js +68 -0
- package/dist/esm/components/server-info/controller.js.map +1 -0
- package/dist/esm/components/server-info/index.d.ts +5 -0
- package/dist/esm/components/server-info/index.js +5 -0
- package/dist/esm/components/server-info/index.js.map +1 -0
- package/dist/esm/components/server-info/reporter.d.ts +25 -0
- package/dist/esm/components/server-info/reporter.js +68 -0
- package/dist/esm/components/server-info/reporter.js.map +1 -0
- package/dist/esm/components/socket-io/common/keys.d.ts +1 -0
- package/dist/esm/components/socket-io/common/keys.js +1 -0
- package/dist/esm/components/socket-io/common/keys.js.map +1 -1
- package/dist/esm/components/socket-io/component.d.ts +1 -0
- package/dist/esm/components/socket-io/component.js +1 -0
- package/dist/esm/components/socket-io/component.js.map +1 -1
- package/dist/esm/components/static-asset/common/constants.d.ts +5 -0
- package/dist/esm/components/static-asset/common/constants.js +3 -0
- package/dist/esm/components/static-asset/common/constants.js.map +1 -1
- package/dist/esm/components/static-asset/common/keys.d.ts +1 -0
- package/dist/esm/components/static-asset/common/keys.js +1 -0
- package/dist/esm/components/static-asset/common/keys.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +48 -6
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/controller/base.definition.d.ts +2 -0
- package/dist/esm/components/static-asset/controller/base.definition.js +6 -4
- package/dist/esm/components/static-asset/controller/base.definition.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +3 -0
- package/dist/esm/components/static-asset/controller/factory.js +18 -9
- package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
- package/dist/esm/components/static-asset/controller/meta-link.js +1 -1
- package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
- package/dist/esm/components/static-asset/controller/route-options.d.ts +9 -0
- package/dist/esm/components/static-asset/controller/route-options.js +16 -3
- package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
- package/dist/esm/components/static-asset/ingest.d.ts +7 -3
- package/dist/esm/components/static-asset/ingest.js +2 -2
- package/dist/esm/components/static-asset/ingest.js.map +1 -1
- package/dist/esm/components/static-asset/models/base.model.d.ts +2 -0
- package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
- package/dist/esm/components/websocket/common/keys.d.ts +1 -0
- package/dist/esm/components/websocket/common/keys.js +1 -0
- package/dist/esm/components/websocket/common/keys.js.map +1 -1
- package/dist/esm/components/websocket/component.d.ts +1 -0
- package/dist/esm/components/websocket/component.js +1 -0
- package/dist/esm/components/websocket/component.js.map +1 -1
- package/dist/esm/testing/assert-application-boots.d.ts +48 -8
- package/dist/esm/testing/assert-application-boots.js +25 -1
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/esm/utilities/drizzle-result.utility.d.ts +1 -0
- package/dist/esm/utilities/drizzle-result.utility.js +1 -0
- package/dist/esm/utilities/drizzle-result.utility.js.map +1 -1
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/components/server-info/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;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AAG,EAAE,0BAA0B,EAAE;qBACzE;iBACF;aACF,CAAC;YACJ,WAAW,EACT,sGAAsG;SACzG,CAAC;KACH;CACO,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;QAE5C,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC;IAClC,CAAC;IAEQ,OAAO;QACd,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;gBACnB,8FAA8F;gBAC9F,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CAAC;gBAE7E,OAAO,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { BaseRestController } from '@/base/controllers';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { ServerInfoCacheControls, ServerInfoRestPaths } from './common';\nimport { ServerInfoReporter } from './reporter';\n\nconst RouteConfigs = {\n TIME: {\n method: HTTP.Methods.GET,\n path: ServerInfoRestPaths.TIME,\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n server: z.object({\n date: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/),\n time: z.string().regex(/^\\d{2}:\\d{2}:\\d{2}\\.\\d{3}$/),\n epoch: z.number().int(),\n iso: z.iso.datetime({ offset: true }),\n }),\n tz: z.string(),\n utc: z.object({\n offset: z.string().regex(/^[+-]\\d{2}:\\d{2}$/),\n minutes: z.number().int(),\n iso: z.iso.datetime(),\n }),\n })\n .openapi({\n description: 'Server time',\n examples: [\n {\n server: {\n date: '2026-11-10',\n time: '15:00:00.123',\n epoch: 1794297600123,\n iso: '2026-11-10T15:00:00.123+07:00',\n },\n tz: 'Asia/Ho_Chi_Minh',\n utc: { offset: '+07:00', minutes: 420, iso: '2026-11-10T08:00:00.123Z' },\n },\n ],\n }),\n description:\n 'The server clock: local date and time, epoch milliseconds, time zone, UTC offset and the UTC instant',\n }),\n },\n} as const;\n\n/**\n * Serves `GET <path>/time`, a PUBLIC route with no authentication.\n *\n * Everything this controller answers must be safe to publish and must not help an attacker: a\n * clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those\n * belong to the gated `/health/stats`. A new route here needs that same test.\n */\nexport class ServerInfoController extends BaseRestController {\n constructor() {\n super({ scope: ServerInfoController.name });\n\n this.definitions = RouteConfigs;\n }\n\n override binding(): ValueOrPromise<void> {\n this.bindRoute({ configs: RouteConfigs.TIME }).to({\n handler: (context) => {\n // A cached time is a wrong time; without this a cache or a service worker may serve it stale.\n context.header(HTTP.Headers.CACHE_CONTROL, ServerInfoCacheControls.NO_STORE);\n\n return context.json(ServerInfoReporter.buildTime(), HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/server-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC","sourcesContent":["export * from './common';\nexport * from './component';\nexport * from './controller';\nexport * from './reporter';\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IServerTime } from './common/index.js';
|
|
2
|
+
/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */
|
|
3
|
+
export declare class ServerInfoReporter {
|
|
4
|
+
private static readonly MINUTES_PER_HOUR;
|
|
5
|
+
private static readonly MS_PER_SECOND;
|
|
6
|
+
private static readonly MS_PER_MINUTE;
|
|
7
|
+
private static readonly formatters;
|
|
8
|
+
private static getFormatter;
|
|
9
|
+
/** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */
|
|
10
|
+
static formatUtcOffset(opts: {
|
|
11
|
+
minutes: number;
|
|
12
|
+
}): string;
|
|
13
|
+
/** The process time zone as the runtime resolved it (`TZ`, or the host setting). */
|
|
14
|
+
static resolveTimeZone(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the
|
|
17
|
+
* same instant. The offset is read from the zone AT that instant (a DST change moves it), not
|
|
18
|
+
* from the zone's standard offset.
|
|
19
|
+
*/
|
|
20
|
+
static buildTime(opts?: {
|
|
21
|
+
now?: Date;
|
|
22
|
+
timeZone?: string;
|
|
23
|
+
}): IServerTime;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */
|
|
2
|
+
export class ServerInfoReporter {
|
|
3
|
+
static { this.MINUTES_PER_HOUR = 60; }
|
|
4
|
+
static { this.MS_PER_SECOND = 1000; }
|
|
5
|
+
static { this.MS_PER_MINUTE = 60_000; }
|
|
6
|
+
static { this.formatters = new Map(); }
|
|
7
|
+
static getFormatter(opts) {
|
|
8
|
+
const cached = ServerInfoReporter.formatters.get(opts.timeZone);
|
|
9
|
+
if (cached) {
|
|
10
|
+
return cached;
|
|
11
|
+
}
|
|
12
|
+
// `h23` keeps midnight as `00`; the default `h24` of some locales prints `24`.
|
|
13
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
14
|
+
timeZone: opts.timeZone,
|
|
15
|
+
hourCycle: 'h23',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
month: '2-digit',
|
|
18
|
+
day: '2-digit',
|
|
19
|
+
hour: '2-digit',
|
|
20
|
+
minute: '2-digit',
|
|
21
|
+
second: '2-digit',
|
|
22
|
+
});
|
|
23
|
+
ServerInfoReporter.formatters.set(opts.timeZone, formatter);
|
|
24
|
+
return formatter;
|
|
25
|
+
}
|
|
26
|
+
/** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */
|
|
27
|
+
static formatUtcOffset(opts) {
|
|
28
|
+
const sign = opts.minutes < 0 ? '-' : '+';
|
|
29
|
+
const absolute = Math.abs(opts.minutes);
|
|
30
|
+
const hh = String(Math.trunc(absolute / ServerInfoReporter.MINUTES_PER_HOUR)).padStart(2, '0');
|
|
31
|
+
const mm = String(absolute % ServerInfoReporter.MINUTES_PER_HOUR).padStart(2, '0');
|
|
32
|
+
return `${sign}${hh}:${mm}`;
|
|
33
|
+
}
|
|
34
|
+
/** The process time zone as the runtime resolved it (`TZ`, or the host setting). */
|
|
35
|
+
static resolveTimeZone() {
|
|
36
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the
|
|
40
|
+
* same instant. The offset is read from the zone AT that instant (a DST change moves it), not
|
|
41
|
+
* from the zone's standard offset.
|
|
42
|
+
*/
|
|
43
|
+
static buildTime(opts) {
|
|
44
|
+
const now = opts?.now ?? new Date();
|
|
45
|
+
const tz = opts?.timeZone ?? ServerInfoReporter.resolveTimeZone();
|
|
46
|
+
const epoch = now.getTime();
|
|
47
|
+
const parts = {};
|
|
48
|
+
for (const part of ServerInfoReporter.getFormatter({ timeZone: tz }).formatToParts(now)) {
|
|
49
|
+
parts[part.type] = part.value;
|
|
50
|
+
}
|
|
51
|
+
const date = `${parts.year}-${parts.month}-${parts.day}`;
|
|
52
|
+
const ms = String(((epoch % ServerInfoReporter.MS_PER_SECOND) + ServerInfoReporter.MS_PER_SECOND) %
|
|
53
|
+
ServerInfoReporter.MS_PER_SECOND).padStart(3, '0');
|
|
54
|
+
const time = `${parts.hour}:${parts.minute}:${parts.second}.${ms}`;
|
|
55
|
+
// The wall clock, read back as if it were UTC, minus the true instant (both cut to the
|
|
56
|
+
// second) is the zone's offset. Intl has no offset field that is portable across runtimes.
|
|
57
|
+
const wallAsUtc = Date.UTC(Number(parts.year), Number(parts.month) - 1, Number(parts.day), Number(parts.hour), Number(parts.minute), Number(parts.second));
|
|
58
|
+
const epochSecond = Math.floor(epoch / ServerInfoReporter.MS_PER_SECOND) * ServerInfoReporter.MS_PER_SECOND;
|
|
59
|
+
const minutes = (wallAsUtc - epochSecond) / ServerInfoReporter.MS_PER_MINUTE;
|
|
60
|
+
const offset = ServerInfoReporter.formatUtcOffset({ minutes });
|
|
61
|
+
return {
|
|
62
|
+
server: { date, time, epoch, iso: `${date}T${time}${offset}` },
|
|
63
|
+
tz,
|
|
64
|
+
utc: { offset, minutes, iso: now.toISOString() },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/server-info/reporter.ts"],"names":[],"mappings":"AAEA,yGAAyG;AACzG,MAAM,OAAO,kBAAkB;aACL,qBAAgB,GAAG,EAAE,CAAC;aACtB,kBAAa,GAAG,IAAI,CAAC;aACrB,kBAAa,GAAG,MAAM,CAAC;aAEvB,eAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEpE,MAAM,CAAC,YAAY,CAAC,IAA0B;QACpD,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhE,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,+EAA+E;QAC/E,MAAM,SAA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KAAK,GAAG,kBAAkB,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAC,aAAa,CAAC;QAC1F,MAAM,OAAO,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,kBAAkB,CAAC,aAAa,CAAC;QAC7E,MAAM,MAAM,GAAG,kBAAkB,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAE/D,OAAO;YACL,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,IAAI,GAAG,MAAM,EAAE,EAAE;YAC9D,EAAE;YACF,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE;SACjD,CAAC;IACJ,CAAC","sourcesContent":["import type { IServerTime } from './common';\n\n/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */\nexport class ServerInfoReporter {\n private static readonly MINUTES_PER_HOUR = 60;\n private static readonly MS_PER_SECOND = 1000;\n private static readonly MS_PER_MINUTE = 60_000;\n\n private static readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private static getFormatter(opts: { timeZone: string }): Intl.DateTimeFormat {\n const cached = ServerInfoReporter.formatters.get(opts.timeZone);\n\n if (cached) {\n return cached;\n }\n\n // `h23` keeps midnight as `00`; the default `h24` of some locales prints `24`.\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: opts.timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n ServerInfoReporter.formatters.set(opts.timeZone, formatter);\n\n return formatter;\n }\n\n /** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */\n static formatUtcOffset(opts: { minutes: number }): string {\n const sign = opts.minutes < 0 ? '-' : '+';\n const absolute = Math.abs(opts.minutes);\n const hh = String(Math.trunc(absolute / ServerInfoReporter.MINUTES_PER_HOUR)).padStart(2, '0');\n const mm = String(absolute % ServerInfoReporter.MINUTES_PER_HOUR).padStart(2, '0');\n\n return `${sign}${hh}:${mm}`;\n }\n\n /** The process time zone as the runtime resolved it (`TZ`, or the host setting). */\n static resolveTimeZone(): string {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /**\n * Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the\n * same instant. The offset is read from the zone AT that instant (a DST change moves it), not\n * from the zone's standard offset.\n */\n static buildTime(opts?: { now?: Date; timeZone?: string }): IServerTime {\n const now = opts?.now ?? new Date();\n const tz = opts?.timeZone ?? ServerInfoReporter.resolveTimeZone();\n const epoch = now.getTime();\n\n const parts: Record<string, string> = {};\n\n for (const part of ServerInfoReporter.getFormatter({ timeZone: tz }).formatToParts(now)) {\n parts[part.type] = part.value;\n }\n\n const date = `${parts.year}-${parts.month}-${parts.day}`;\n const ms = String(\n ((epoch % ServerInfoReporter.MS_PER_SECOND) + ServerInfoReporter.MS_PER_SECOND) %\n ServerInfoReporter.MS_PER_SECOND,\n ).padStart(3, '0');\n const time = `${parts.hour}:${parts.minute}:${parts.second}.${ms}`;\n\n // The wall clock, read back as if it were UTC, minus the true instant (both cut to the\n // second) is the zone's offset. Intl has no offset field that is portable across runtimes.\n const wallAsUtc = Date.UTC(\n Number(parts.year),\n Number(parts.month) - 1,\n Number(parts.day),\n Number(parts.hour),\n Number(parts.minute),\n Number(parts.second),\n );\n const epochSecond =\n Math.floor(epoch / ServerInfoReporter.MS_PER_SECOND) * ServerInfoReporter.MS_PER_SECOND;\n const minutes = (wallAsUtc - epochSecond) / ServerInfoReporter.MS_PER_MINUTE;\n const offset = ServerInfoReporter.formatUtcOffset({ minutes });\n\n return {\n server: { date, time, epoch, iso: `${date}T${time}${offset}` },\n tz,\n utc: { offset, minutes, iso: now.toISOString() },\n };\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */
|
|
1
2
|
export declare class SocketIOBindingKeys {
|
|
2
3
|
static readonly SOCKET_IO_INSTANCE = "@app/socket-io/instance";
|
|
3
4
|
static readonly SERVER_OPTIONS = "@app/socket-io/server-options";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */
|
|
1
2
|
export class SocketIOBindingKeys {
|
|
2
3
|
static { this.SOCKET_IO_INSTANCE = '@app/socket-io/instance'; }
|
|
3
4
|
static { this.SERVER_OPTIONS = '@app/socket-io/server-options'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAmB;aACd,uBAAkB,GAAG,yBAAyB,CAAC;aAE/C,mBAAc,GAAG,+BAA+B,CAAC;aACjD,qBAAgB,GAAG,iCAAiC,CAAC;aAErD,yBAAoB,GAAG,qCAAqC,CAAC;aAC7D,0BAAqB,GAAG,sCAAsC,CAAC;aAC/D,6BAAwB,GAAG,yCAAyC,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/common/keys.ts"],"names":[],"mappings":"AAAA,+IAA+I;AAC/I,MAAM,OAAO,mBAAmB;aACd,uBAAkB,GAAG,yBAAyB,CAAC;aAE/C,mBAAc,GAAG,+BAA+B,CAAC;aACjD,qBAAgB,GAAG,iCAAiC,CAAC;aAErD,yBAAoB,GAAG,qCAAqC,CAAC;aAC7D,0BAAqB,GAAG,sCAAsC,CAAC;aAC/D,6BAAwB,GAAG,yCAAyC,CAAC","sourcesContent":["/** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */\nexport class SocketIOBindingKeys {\n static readonly SOCKET_IO_INSTANCE = '@app/socket-io/instance';\n\n static readonly SERVER_OPTIONS = '@app/socket-io/server-options';\n static readonly REDIS_CONNECTION = '@app/socket-io/redis-connection';\n\n static readonly AUTHENTICATE_HANDLER = '@app/socket-io/authenticate-handler';\n static readonly VALIDATE_ROOM_HANDLER = '@app/socket-io/validate-room-handler';\n static readonly CLIENT_CONNECTED_HANDLER = '@app/socket-io/client-connected-handler';\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { type BaseApplication } from '../../base/applications/index.js';
|
|
|
2
2
|
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
3
3
|
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
4
4
|
import { type IServerOptions } from './common/index.js';
|
|
5
|
+
/** Starts a Socket.IO server on Bun after the application starts. Requires a Redis helper at `SocketIOBindingKeys.REDIS_CONNECTION` and an authenticate handler at `AUTHENTICATE_HANDLER`; binding throws without them. */
|
|
5
6
|
export declare class SocketIOComponent extends BaseComponent {
|
|
6
7
|
private application;
|
|
7
8
|
protected serverOptions: Partial<IServerOptions>;
|
|
@@ -21,6 +21,7 @@ import { isRedisHelper } from '@venizia/ignis-helpers';
|
|
|
21
21
|
import { SocketIOServerHelper, } from '@venizia/ignis-helpers/socket-io';
|
|
22
22
|
import { SocketIOBindingKeys, DEFAULT_SERVER_OPTIONS, } from './common/index.js';
|
|
23
23
|
import { SocketIOBunHandler } from './handlers/index.js';
|
|
24
|
+
/** Starts a Socket.IO server on Bun after the application starts. Requires a Redis helper at `SocketIOBindingKeys.REDIS_CONNECTION` and an authenticate handler at `AUTHENTICATE_HANDLER`; binding throws without them. */
|
|
24
25
|
let SocketIOComponent = SocketIOComponent_1 = class SocketIOComponent extends BaseComponent {
|
|
25
26
|
constructor(application) {
|
|
26
27
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/socket-io/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAA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S,EAAE,CAAC;gBAChD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC;gBAEvD,cAAe,CAAC,MAAM,CAAC;oBACrB,KAAK,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;oBAChF,SAAS,EAAE,aAAa,CAAC,SAAS;iBACnC,CAAC,CAAC;gBAEH,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAEQ,OAAO;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EAAE,yDAAyD;aACnE,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAEnD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AArIY,iBAAiB;IAIzB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,iBAAiB,CAqI7B","sourcesContent":["import { type BaseApplication, type TBunServerInstance } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, RuntimeModules, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type AbstractRedisHelper, isRedisHelper } from '@venizia/ignis-helpers';\nimport {\n SocketIOServerHelper,\n type TSocketIOAuthenticateFn,\n type TSocketIOClientConnectedFn,\n type TSocketIOValidateRoomFn,\n} from '@venizia/ignis-helpers/socket-io';\nimport type { ServerOptions } from 'socket.io';\nimport {\n SocketIOBindingKeys,\n DEFAULT_SERVER_OPTIONS,\n type IResolvedBindings,\n type IServerOptions,\n} from './common';\nimport { SocketIOBunHandler } from './handlers';\n\nexport class SocketIOComponent extends BaseComponent {\n protected serverOptions: Partial<IServerOptions>;\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: SocketIOComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [SocketIOBindingKeys.SERVER_OPTIONS]: Binding.bind<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n }).toValue(DEFAULT_SERVER_OPTIONS),\n\n [SocketIOBindingKeys.REDIS_CONNECTION]: Binding.bind<AbstractRedisHelper | null>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n }).toValue(null),\n\n [SocketIOBindingKeys.AUTHENTICATE_HANDLER]: Binding.bind<TSocketIOAuthenticateFn | null>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.VALIDATE_ROOM_HANDLER]: Binding.bind<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER]:\n Binding.bind<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }).toValue(null),\n },\n });\n }\n\n private resolveBindings(): IResolvedBindings {\n const extraServerOptions =\n this.application.get<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n isOptional: true,\n }) ?? {};\n this.serverOptions = Object.assign({}, DEFAULT_SERVER_OPTIONS, extraServerOptions);\n\n const redisConnection = this.application.get<AbstractRedisHelper>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n });\n\n if (!isRedisHelper(redisConnection)) {\n throw getError({\n message:\n '[SocketIOComponent][resolveBindings] Invalid instance of redisConnection | Please init connection with RedisSingleHelper (single), RedisClusterHelper (cluster), or RedisSentinelHelper (sentinel)!',\n });\n }\n\n const authenticateFn = this.application.get<TSocketIOAuthenticateFn>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n });\n\n if (!authenticateFn) {\n throw getError({\n message: '[DANGER][SocketIOComponent] Invalid authenticateFn to setup io socket server!',\n });\n }\n\n const validateRoomFn =\n this.application.get<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }) ?? undefined;\n\n const clientConnectedFn =\n this.application.get<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }) ?? undefined;\n\n return { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn };\n }\n\n private registerBunHook(opts: IResolvedBindings) {\n const { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn } = opts;\n const serverOptions = this.serverOptions;\n const logger = this.logger.for(this.registerBunHook.name);\n\n this.application.registerPostStartHook({\n identifier: 'socket-io-initialize',\n hook: async () => {\n const { engine, engineHandler } = await SocketIOBunHandler.createEngine({ serverOptions });\n\n const socketIOHelper = new SocketIOServerHelper({\n runtime: RuntimeModules.BUN,\n identifier: serverOptions.identifier!,\n engine,\n serverOptions,\n redisConnection,\n authenticateFn,\n validateRoomFn,\n clientConnectedFn,\n });\n await socketIOHelper.configure();\n\n this.application\n .bind({ key: SocketIOBindingKeys.SOCKET_IO_INSTANCE })\n .toValue(socketIOHelper);\n\n const serverInstance = this.application.getServerInstance<TBunServerInstance>();\n const honoServer = this.application.getServer();\n const enginePath = serverOptions.path ?? '/socket.io/';\n\n serverInstance!.reload({\n fetch: SocketIOBunHandler.createFetchHandler({ engine, enginePath, honoServer }),\n websocket: engineHandler.websocket,\n });\n\n logger.info('SocketIO initialized for Bun runtime');\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const logger = this.logger.for(this.binding.name);\n\n if (!this.application) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[binding] Invalid application to bind SocketIOComponent',\n });\n }\n\n logger.info('Binding SocketIO for application...');\n\n const resolved = this.resolveBindings();\n logger.debug('Socket.IO Server Options: %j', this.serverOptions);\n\n this.registerBunHook(resolved);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/socket-io/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAuB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAA4B,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EACL,oBAAoB,GAIrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,2NAA2N;AAC3N,IAAa,iBAAiB,yBAA9B,MAAa,iBAAkB,SAAQ,aAAa;IAGlD,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,mBAAiB,CAAC,IAAI;YAC7B,WAAW,EAAE,EAAE,MAA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AC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAEnD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AArIY,iBAAiB;IAIzB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,iBAAiB,CAqI7B","sourcesContent":["import { type BaseApplication, type TBunServerInstance } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, RuntimeModules, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type AbstractRedisHelper, isRedisHelper } from '@venizia/ignis-helpers';\nimport {\n SocketIOServerHelper,\n type TSocketIOAuthenticateFn,\n type TSocketIOClientConnectedFn,\n type TSocketIOValidateRoomFn,\n} from '@venizia/ignis-helpers/socket-io';\nimport type { ServerOptions } from 'socket.io';\nimport {\n SocketIOBindingKeys,\n DEFAULT_SERVER_OPTIONS,\n type IResolvedBindings,\n type IServerOptions,\n} from './common';\nimport { SocketIOBunHandler } from './handlers';\n\n/** Starts a Socket.IO server on Bun after the application starts. Requires a Redis helper at `SocketIOBindingKeys.REDIS_CONNECTION` and an authenticate handler at `AUTHENTICATE_HANDLER`; binding throws without them. */\nexport class SocketIOComponent extends BaseComponent {\n protected serverOptions: Partial<IServerOptions>;\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: SocketIOComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [SocketIOBindingKeys.SERVER_OPTIONS]: Binding.bind<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n }).toValue(DEFAULT_SERVER_OPTIONS),\n\n [SocketIOBindingKeys.REDIS_CONNECTION]: Binding.bind<AbstractRedisHelper | null>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n }).toValue(null),\n\n [SocketIOBindingKeys.AUTHENTICATE_HANDLER]: Binding.bind<TSocketIOAuthenticateFn | null>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.VALIDATE_ROOM_HANDLER]: Binding.bind<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER]:\n Binding.bind<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }).toValue(null),\n },\n });\n }\n\n private resolveBindings(): IResolvedBindings {\n const extraServerOptions =\n this.application.get<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n isOptional: true,\n }) ?? {};\n this.serverOptions = Object.assign({}, DEFAULT_SERVER_OPTIONS, extraServerOptions);\n\n const redisConnection = this.application.get<AbstractRedisHelper>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n });\n\n if (!isRedisHelper(redisConnection)) {\n throw getError({\n message:\n '[SocketIOComponent][resolveBindings] Invalid instance of redisConnection | Please init connection with RedisSingleHelper (single), RedisClusterHelper (cluster), or RedisSentinelHelper (sentinel)!',\n });\n }\n\n const authenticateFn = this.application.get<TSocketIOAuthenticateFn>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n });\n\n if (!authenticateFn) {\n throw getError({\n message: '[DANGER][SocketIOComponent] Invalid authenticateFn to setup io socket server!',\n });\n }\n\n const validateRoomFn =\n this.application.get<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }) ?? undefined;\n\n const clientConnectedFn =\n this.application.get<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }) ?? undefined;\n\n return { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn };\n }\n\n private registerBunHook(opts: IResolvedBindings) {\n const { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn } = opts;\n const serverOptions = this.serverOptions;\n const logger = this.logger.for(this.registerBunHook.name);\n\n this.application.registerPostStartHook({\n identifier: 'socket-io-initialize',\n hook: async () => {\n const { engine, engineHandler } = await SocketIOBunHandler.createEngine({ serverOptions });\n\n const socketIOHelper = new SocketIOServerHelper({\n runtime: RuntimeModules.BUN,\n identifier: serverOptions.identifier!,\n engine,\n serverOptions,\n redisConnection,\n authenticateFn,\n validateRoomFn,\n clientConnectedFn,\n });\n await socketIOHelper.configure();\n\n this.application\n .bind({ key: SocketIOBindingKeys.SOCKET_IO_INSTANCE })\n .toValue(socketIOHelper);\n\n const serverInstance = this.application.getServerInstance<TBunServerInstance>();\n const honoServer = this.application.getServer();\n const enginePath = serverOptions.path ?? '/socket.io/';\n\n serverInstance!.reload({\n fetch: SocketIOBunHandler.createFetchHandler({ engine, enginePath, honoServer }),\n websocket: engineHandler.websocket,\n });\n\n logger.info('SocketIO initialized for Bun runtime');\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const logger = this.logger.for(this.binding.name);\n\n if (!this.application) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[binding] Invalid application to bind SocketIOComponent',\n });\n }\n\n logger.info('Binding SocketIO for application...');\n\n const resolved = this.resolveBindings();\n logger.debug('Socket.IO Server Options: %j', this.serverOptions);\n\n this.registerBunHook(resolved);\n }\n}\n"]}
|
|
@@ -7,12 +7,14 @@ export declare const WHITELIST_HEADERS: readonly ["content-encoding", "cache-con
|
|
|
7
7
|
* cannot stop a type we declared ourselves. `image/svg+xml` is deliberately excluded: SVG carries script.
|
|
8
8
|
*/
|
|
9
9
|
export declare const RENDERABLE_CONTENT_TYPES: Set<string>;
|
|
10
|
+
/** Storage backends a static asset controller can serve from. `isValid` checks a string against them. */
|
|
10
11
|
export declare class StaticAssetStorageTypes {
|
|
11
12
|
static readonly DISK = "disk";
|
|
12
13
|
static readonly BUN_S3 = "bun-s3";
|
|
13
14
|
static readonly SCHEME_SET: Set<string>;
|
|
14
15
|
static isValid(orgType: string): boolean;
|
|
15
16
|
}
|
|
17
|
+
/** One of the `StaticAssetStorageTypes` values. */
|
|
16
18
|
export type TStaticAssetStorageType = TConstValue<typeof StaticAssetStorageTypes>;
|
|
17
19
|
/** What `recreate-metalink` did: refreshed the rows of an object, or created its first one. */
|
|
18
20
|
export declare class MetaLinkRecreateActions {
|
|
@@ -21,9 +23,12 @@ export declare class MetaLinkRecreateActions {
|
|
|
21
23
|
static readonly SCHEME_SET: Set<string>;
|
|
22
24
|
static isValid(value: string): boolean;
|
|
23
25
|
}
|
|
26
|
+
/** One of the `MetaLinkRecreateActions` values. */
|
|
24
27
|
export type TMetaLinkRecreateAction = TConstValue<typeof MetaLinkRecreateActions>;
|
|
25
28
|
/** Where a signed policy may write. The final key is never inside it, so content cannot be replaced after the commit. */
|
|
26
29
|
export declare const DEFAULT_PENDING_PREFIX = "pending/";
|
|
30
|
+
/** The most file parts one upload request may carry unless `parseMultipartBody.maxFiles` says otherwise. */
|
|
31
|
+
export declare const DEFAULT_MAX_UPLOAD_FILES = 20;
|
|
27
32
|
/** Reported in the body, never thrown: the bytes are stored, only the row is not. A CODE, because a 200 bypasses the middleware that strips the driver's `detail`/`table`/`constraint`. */
|
|
28
33
|
export declare const META_LINK_CREATE_FAILED = "META_LINK_CREATE_FAILED";
|
|
29
34
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -28,6 +28,7 @@ export const RENDERABLE_CONTENT_TYPES = new Set([
|
|
|
28
28
|
'text/plain',
|
|
29
29
|
'text/csv',
|
|
30
30
|
]);
|
|
31
|
+
/** Storage backends a static asset controller can serve from. `isValid` checks a string against them. */
|
|
31
32
|
export class StaticAssetStorageTypes {
|
|
32
33
|
static { this.DISK = 'disk'; }
|
|
33
34
|
static { this.BUN_S3 = 'bun-s3'; }
|
|
@@ -47,6 +48,8 @@ export class MetaLinkRecreateActions {
|
|
|
47
48
|
}
|
|
48
49
|
/** Where a signed policy may write. The final key is never inside it, so content cannot be replaced after the commit. */
|
|
49
50
|
export const DEFAULT_PENDING_PREFIX = 'pending/';
|
|
51
|
+
/** The most file parts one upload request may carry unless `parseMultipartBody.maxFiles` says otherwise. */
|
|
52
|
+
export const DEFAULT_MAX_UPLOAD_FILES = 20;
|
|
50
53
|
/** Reported in the body, never thrown: the bytes are stored, only the row is not. A CODE, because a 200 bypasses the middleware that strips the driver's `detail`/`table`/`constraint`. */
|
|
51
54
|
export const META_LINK_CREATE_FAILED = 'META_LINK_CREATE_FAILED';
|
|
52
55
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,uGAAuG;AACvG,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,CAAC,OAAO,CAAC,gBAAgB;IAC7B,IAAI,CAAC,OAAO,CAAC,aAAa;IAC1B,IAAI,CAAC,OAAO,CAAC,IAAI;IACjB,IAAI,CAAC,OAAO,CAAC,aAAa;CAClB,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAS;IACtD,WAAW;IACX,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,cAAc;IACd,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,WAAW;IACX,iBAAiB;IACjB,YAAY;IACZ,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,OAAO,uBAAuB;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,uGAAuG;AACvG,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,CAAC,OAAO,CAAC,gBAAgB;IAC7B,IAAI,CAAC,OAAO,CAAC,aAAa;IAC1B,IAAI,CAAC,OAAO,CAAC,IAAI;IACjB,IAAI,CAAC,OAAO,CAAC,aAAa;CAClB,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAS;IACtD,WAAW;IACX,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,cAAc;IACd,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,WAAW;IACX,iBAAiB;IACjB,YAAY;IACZ,UAAU;CACX,CAAC,CAAC;AAEH,yGAAyG;AACzG,MAAM,OAAO,uBAAuB;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;;AAMH,+FAA+F;AAC/F,MAAM,OAAO,uBAAuB;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,cAAS,GAAG,WAAW,CAAC;aAExB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAErE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,yHAAyH;AACzH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAEjD,4GAA4G;AAC5G,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,2LAA2L;AAC3L,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\n\n/** `content-type` is absent on purpose: it is decided from the object name, never from the backend. */\nexport const WHITELIST_HEADERS = [\n HTTP.Headers.CONTENT_ENCODING,\n HTTP.Headers.CACHE_CONTROL,\n HTTP.Headers.ETAG,\n HTTP.Headers.LAST_MODIFIED,\n] as const;\n\n/**\n * Types the controller will let a browser render, keyed off the object name. Anything absent here is\n * served as an attachment, because a renderable upload on the API origin is stored XSS - and `nosniff`\n * cannot stop a type we declared ourselves. `image/svg+xml` is deliberately excluded: SVG carries script.\n */\nexport const RENDERABLE_CONTENT_TYPES = new Set<string>([\n 'image/png',\n 'image/jpeg',\n 'image/gif',\n 'image/webp',\n 'image/avif',\n 'image/bmp',\n 'image/x-icon',\n 'video/mp4',\n 'video/webm',\n 'audio/mpeg',\n 'audio/wav',\n 'audio/ogg',\n 'application/pdf',\n 'text/plain',\n 'text/csv',\n]);\n\n/** Storage backends a static asset controller can serve from. `isValid` checks a string against them. */\nexport class StaticAssetStorageTypes {\n static readonly DISK = 'disk';\n static readonly BUN_S3 = 'bun-s3';\n\n static readonly SCHEME_SET = new Set([this.DISK, this.BUN_S3]);\n\n static isValid(orgType: string): boolean {\n return this.SCHEME_SET.has(orgType);\n }\n}\n\n/** One of the `StaticAssetStorageTypes` values. */\nexport type TStaticAssetStorageType = TConstValue<typeof StaticAssetStorageTypes>;\n\n/** What `recreate-metalink` did: refreshed the rows of an object, or created its first one. */\nexport class MetaLinkRecreateActions {\n static readonly CREATED = 'created';\n static readonly REFRESHED = 'refreshed';\n\n static readonly SCHEME_SET = new Set([this.CREATED, this.REFRESHED]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** One of the `MetaLinkRecreateActions` values. */\nexport type TMetaLinkRecreateAction = TConstValue<typeof MetaLinkRecreateActions>;\n\n/** Where a signed policy may write. The final key is never inside it, so content cannot be replaced after the commit. */\nexport const DEFAULT_PENDING_PREFIX = 'pending/';\n\n/** The most file parts one upload request may carry unless `parseMultipartBody.maxFiles` says otherwise. */\nexport const DEFAULT_MAX_UPLOAD_FILES = 20;\n\n/** Reported in the body, never thrown: the bytes are stored, only the row is not. A CODE, because a 200 bypasses the middleware that strips the driver's `detail`/`table`/`constraint`. */\nexport const META_LINK_CREATE_FAILED = 'META_LINK_CREATE_FAILED';\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container keys of the static asset component. */
|
|
1
2
|
export declare class StaticAssetComponentBindingKeys {
|
|
2
3
|
/** The options an application registers through `configs.artifacts` land here, because an artifact index carries classes and no options. `application.component(StaticAssetComponent, { options })` passes them directly and wins over this key. */
|
|
3
4
|
static readonly STATIC_ASSET_COMPONENT_OPTIONS = "@app/static-asset-component/options";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container keys of the static asset component. */
|
|
1
2
|
export class StaticAssetComponentBindingKeys {
|
|
2
3
|
/** The options an application registers through `configs.artifacts` land here, because an artifact index carries classes and no options. `application.component(StaticAssetComponent, { options })` passes them directly and wins over this key. */
|
|
3
4
|
static { this.STATIC_ASSET_COMPONENT_OPTIONS = '@app/static-asset-component/options'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,+BAA+B;IAC1C,oPAAoP;aACpO,mCAA8B,GAAG,qCAAqC,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/keys.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,OAAO,+BAA+B;IAC1C,oPAAoP;aACpO,mCAA8B,GAAG,qCAAqC,CAAC","sourcesContent":["/** Container keys of the static asset component. */\nexport class StaticAssetComponentBindingKeys {\n /** The options an application registers through `configs.artifacts` land here, because an artifact index carries classes and no options. `application.component(StaticAssetComponent, { options })` passes them directly and wins over this key. */\n static readonly STATIC_ASSET_COMPONENT_OPTIONS = '@app/static-asset-component/options';\n}\n"]}
|
|
@@ -7,17 +7,28 @@ import type { AnyType, TValueOrAsyncResolver, ValueOrPromise } from '@venizia/ig
|
|
|
7
7
|
import type { TMultipartStorage } from '@venizia/ignis-helpers';
|
|
8
8
|
import type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models/index.js';
|
|
9
9
|
import type { StaticAssetStorageTypes } from './constants.js';
|
|
10
|
+
/** Per-controller upload tuning: multipart parsing, name and link normalization, folder depth and size ceiling. */
|
|
10
11
|
export type TStaticAssetExtraOptions = {
|
|
11
12
|
parseMultipartBody?: {
|
|
12
13
|
storage?: TMultipartStorage;
|
|
13
14
|
uploadDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The most file parts one upload request may carry; more is refused with 413 before anything is written. The upload-policy request is bounded by the same number (more is a 422).
|
|
17
|
+
*
|
|
18
|
+
* @default DEFAULT_MAX_UPLOAD_FILES (20)
|
|
19
|
+
*/
|
|
20
|
+
maxFiles?: number;
|
|
14
21
|
};
|
|
15
22
|
/** `folderPath` carries the upload query's target folder - dropping it flattens nested uploads. */
|
|
16
23
|
normalizeNameFn?: (opts: {
|
|
17
24
|
file: TUploadNaming;
|
|
18
25
|
}) => string;
|
|
19
26
|
normalizeLinkFn?: (opts: IObjectLocation) => string;
|
|
20
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Maximum folder nesting depth allowed in object paths.
|
|
29
|
+
*
|
|
30
|
+
* @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH
|
|
31
|
+
*/
|
|
21
32
|
maxFolderDepth?: number;
|
|
22
33
|
/** Largest file the UPLOAD route accepts. Absent means no ceiling. Checked against `content-length` before spooling, then per file after parsing. */
|
|
23
34
|
maxBytes?: number;
|
|
@@ -36,13 +47,16 @@ export type TDefineExtraRoutes = (opts: {
|
|
|
36
47
|
helper: IStorageHelper;
|
|
37
48
|
basePath: string;
|
|
38
49
|
}) => void;
|
|
50
|
+
/** Path parameters of the bucket routes. */
|
|
39
51
|
export type TBucketParams = {
|
|
40
52
|
bucketName: string;
|
|
41
53
|
};
|
|
54
|
+
/** Path parameters of the object routes. */
|
|
42
55
|
export type TObjectParams = {
|
|
43
56
|
bucketName: string;
|
|
44
57
|
objectName: string;
|
|
45
58
|
};
|
|
59
|
+
/** Labels recorded on the MetaLink row of an uploaded object. */
|
|
46
60
|
export type TUploadQuery = {
|
|
47
61
|
principalType?: string;
|
|
48
62
|
principalId?: string;
|
|
@@ -51,11 +65,13 @@ export type TUploadQuery = {
|
|
|
51
65
|
sequence?: number;
|
|
52
66
|
folderPath?: string;
|
|
53
67
|
};
|
|
68
|
+
/** Query of the list objects route. Every value arrives as a string. */
|
|
54
69
|
export type TListQuery = {
|
|
55
70
|
prefix?: string;
|
|
56
71
|
recursive?: string;
|
|
57
72
|
maxKeys?: string;
|
|
58
73
|
};
|
|
74
|
+
/** Enables the signed-policy upload flow, where the client posts bytes straight to the storage and IGNIS only signs the permission and verifies the commit. */
|
|
59
75
|
export type TDirectUploadOptions = {
|
|
60
76
|
/** Who may ask for a policy. REQUIRED, not defaulted: this route hands out a write credential, and there is no safe default for that. */
|
|
61
77
|
authorize: (opts: {
|
|
@@ -65,9 +81,17 @@ export type TDirectUploadOptions = {
|
|
|
65
81
|
secretKey: string;
|
|
66
82
|
/** The ceiling the policy carries as `content-length-range`. A signed PUT cannot express this at all, which is why this is a POST policy. */
|
|
67
83
|
maxBytes: number;
|
|
68
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Where a policy may write. The final key is NEVER in a policy, so content cannot be replaced after the commit.
|
|
86
|
+
*
|
|
87
|
+
* @default 'pending/'
|
|
88
|
+
*/
|
|
69
89
|
pendingPrefix?: string;
|
|
70
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* How long a policy and its commit token stay good.
|
|
92
|
+
*
|
|
93
|
+
* @default StoragePresignDefaults.POST_EXPIRES_IN
|
|
94
|
+
*/
|
|
71
95
|
expiresIn?: IDuration;
|
|
72
96
|
/** Runs BEFORE the copy to the final key, so a hook that throws leaves the object under the pending prefix for a lifecycle rule to collect, rather than stranding it at the final key. */
|
|
73
97
|
onCommit?: (opts: {
|
|
@@ -76,6 +100,7 @@ export type TDirectUploadOptions = {
|
|
|
76
100
|
object: IObjectRef;
|
|
77
101
|
}) => ValueOrPromise<void>;
|
|
78
102
|
};
|
|
103
|
+
/** Body of the upload policy route: the files the client intends to upload. */
|
|
79
104
|
export type TUploadPolicyRequest = {
|
|
80
105
|
files: Array<{
|
|
81
106
|
fileName: string;
|
|
@@ -99,9 +124,14 @@ export type TMetaLinkConfig<Schema extends TMetaLinkCompatibleSchema = TMetaLink
|
|
|
99
124
|
};
|
|
100
125
|
/** The part of a built-in route an application may change. */
|
|
101
126
|
export type TStaticAssetRouteConfig = Partial<Omit<IAuthRouteConfig, 'method' | 'request' | 'responses'>> & {
|
|
102
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Whether this route is registered.
|
|
129
|
+
*
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
103
132
|
enabled?: boolean;
|
|
104
133
|
};
|
|
134
|
+
/** Per-route overrides for the built-in routes of a generated asset controller. A key left out keeps that route as built. */
|
|
105
135
|
export type TStaticAssetRoutes = {
|
|
106
136
|
getBuckets?: TStaticAssetRouteConfig;
|
|
107
137
|
getBucketByName?: TStaticAssetRouteConfig;
|
|
@@ -116,13 +146,23 @@ export type TStaticAssetRoutes = {
|
|
|
116
146
|
uploadCommit?: TStaticAssetRouteConfig;
|
|
117
147
|
recreateMetaLink?: TStaticAssetRouteConfig;
|
|
118
148
|
};
|
|
149
|
+
/** Static asset controllers keyed by an application-chosen name. Each entry pairs a storage type with its matching helper, and `useMetaLink: true` requires a `metaLink` config. */
|
|
119
150
|
export type TStaticAssetsComponentOptions<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {
|
|
120
151
|
[key: string]: {
|
|
121
152
|
controller: {
|
|
122
153
|
name: string;
|
|
123
154
|
basePath: string;
|
|
155
|
+
/**
|
|
156
|
+
* Whether `/path` and `/path/` are different routes on this controller.
|
|
157
|
+
*
|
|
158
|
+
* @default true
|
|
159
|
+
*/
|
|
124
160
|
isStrict?: boolean;
|
|
125
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* `true` serves a raw nested object path (`/objects/photos/2024/f.jpg`) - a URL shape change; a percent-encoded path keeps working either way.
|
|
163
|
+
*
|
|
164
|
+
* @default false
|
|
165
|
+
*/
|
|
126
166
|
rawObjectPath?: boolean;
|
|
127
167
|
/** The single bucket every object route uses. It leaves the URL (`/objects/{objectName}`) and the four bucket-management routes are not registered. The function form is read per request, so an environment variable can be read lazily. */
|
|
128
168
|
bucket?: TValueOrAsyncResolver<string>;
|
|
@@ -131,7 +171,9 @@ export type TStaticAssetsComponentOptions<Schema extends TMetaLinkCompatibleSche
|
|
|
131
171
|
* as a 404 without calling the storage, `listObjects` lists only inside it, and an upload key
|
|
132
172
|
* must land inside it: the default name is placed there, a `resolveObjectName` or
|
|
133
173
|
* `extra.normalizeNameFn` key outside it is refused. `maxFolderDepth` counts the folders below
|
|
134
|
-
* it.
|
|
174
|
+
* it.
|
|
175
|
+
*
|
|
176
|
+
* @default every key in the bucket
|
|
135
177
|
*/
|
|
136
178
|
keyPrefix?: string;
|
|
137
179
|
routes?: TStaticAssetRoutes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BaseRestController, IAuthRouteConfig, TRouteContext } from '@/base';\nimport type { IDuration } from '@venizia/ignis-helpers/common';\nimport type {\n BaseRelationalEntity,\n DefaultCRUDRepository,\n TTableObject,\n} from '@venizia/ignis-connectors/postgres';\nimport type {\n DiskHelper,\n IBucketRef,\n IFileStat,\n IObjectLocation,\n IObjectRef,\n IStorageHelper,\n IUploadResult,\n TUploadNaming,\n} from '@venizia/ignis-helpers';\nimport type { BunS3Helper } from '@venizia/ignis-helpers/bun-s3';\nimport type { AnyType, TValueOrAsyncResolver, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { TMultipartStorage } from '@venizia/ignis-helpers';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models';\nimport type { StaticAssetStorageTypes } from './constants';\n\nexport type TStaticAssetExtraOptions = {\n parseMultipartBody?: {\n storage?: TMultipartStorage;\n uploadDir?: string;\n };\n\n /** `folderPath` carries the upload query's target folder - dropping it flattens nested uploads. */\n normalizeNameFn?: (opts: { file: TUploadNaming }) => string;\n normalizeLinkFn?: (opts: IObjectLocation) => string;\n\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BaseRestController, IAuthRouteConfig, TRouteContext } from '@/base';\nimport type { IDuration } from '@venizia/ignis-helpers/common';\nimport type {\n BaseRelationalEntity,\n DefaultCRUDRepository,\n TTableObject,\n} from '@venizia/ignis-connectors/postgres';\nimport type {\n DiskHelper,\n IBucketRef,\n IFileStat,\n IObjectLocation,\n IObjectRef,\n IStorageHelper,\n IUploadResult,\n TUploadNaming,\n} from '@venizia/ignis-helpers';\nimport type { BunS3Helper } from '@venizia/ignis-helpers/bun-s3';\nimport type { AnyType, TValueOrAsyncResolver, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { TMultipartStorage } from '@venizia/ignis-helpers';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models';\nimport type { StaticAssetStorageTypes } from './constants';\n\n/** Per-controller upload tuning: multipart parsing, name and link normalization, folder depth and size ceiling. */\nexport type TStaticAssetExtraOptions = {\n parseMultipartBody?: {\n storage?: TMultipartStorage;\n uploadDir?: string;\n /**\n * The most file parts one upload request may carry; more is refused with 413 before anything is written. The upload-policy request is bounded by the same number (more is a 422).\n *\n * @default DEFAULT_MAX_UPLOAD_FILES (20)\n */\n maxFiles?: number;\n };\n\n /** `folderPath` carries the upload query's target folder - dropping it flattens nested uploads. */\n normalizeNameFn?: (opts: { file: TUploadNaming }) => string;\n normalizeLinkFn?: (opts: IObjectLocation) => string;\n\n /**\n * Maximum folder nesting depth allowed in object paths.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /** Largest file the UPLOAD route accepts. Absent means no ceiling. Checked against `content-length` before spooling, then per file after parsing. */\n maxBytes?: number;\n [key: string]: AnyType;\n};\n\n/** Decides the key one uploaded file is stored under. `defaultKey` is what IGNIS would have written. */\nexport type TObjectNameResolver = (opts: {\n bucket: IBucketRef;\n file: TUploadNaming;\n defaultKey: string;\n}) => string;\n\n/** Adds routes of the application's own to a generated asset controller. Runs after every built-in route, so a built-in route always wins a path collision. `basePath` is the mount path with exactly one leading slash. */\n/** Adds routes of the application's own. Registration order decides a path collision, so the same shape serves both the before and the after hook. */\nexport type TDefineExtraRoutes = (opts: {\n controller: BaseRestController;\n helper: IStorageHelper;\n basePath: string;\n}) => void;\n\n// Declared by hand rather than inferred: RouteHandler inference here is heavy.\n/** Path parameters of the bucket routes. */\nexport type TBucketParams = { bucketName: string };\n/** Path parameters of the object routes. */\nexport type TObjectParams = { bucketName: string; objectName: string };\n/** Labels recorded on the MetaLink row of an uploaded object. */\nexport type TUploadQuery = {\n principalType?: string;\n principalId?: string;\n variant?: string;\n /** Display order within the principal. Caller-supplied: deriving it would be a non-atomic read of `max(sequence)` then a write of `max + 1`. */\n sequence?: number;\n folderPath?: string;\n};\n/** Query of the list objects route. Every value arrives as a string. */\nexport type TListQuery = { prefix?: string; recursive?: string; maxKeys?: string };\n\n/** Enables the signed-policy upload flow, where the client posts bytes straight to the storage and IGNIS only signs the permission and verifies the commit. */\nexport type TDirectUploadOptions = {\n /** Who may ask for a policy. REQUIRED, not defaulted: this route hands out a write credential, and there is no safe default for that. */\n authorize: (opts: { context: TRouteContext }) => ValueOrPromise<boolean>;\n\n /** Signs the commit token. Keep it out of the repository and out of the client. */\n secretKey: string;\n\n /** The ceiling the policy carries as `content-length-range`. A signed PUT cannot express this at all, which is why this is a POST policy. */\n maxBytes: number;\n\n /**\n * Where a policy may write. The final key is NEVER in a policy, so content cannot be replaced after the commit.\n *\n * @default 'pending/'\n */\n pendingPrefix?: string;\n\n /**\n * How long a policy and its commit token stay good.\n *\n * @default StoragePresignDefaults.POST_EXPIRES_IN\n */\n expiresIn?: IDuration;\n\n /** Runs BEFORE the copy to the final key, so a hook that throws leaves the object under the pending prefix for a lifecycle rule to collect, rather than stranding it at the final key. */\n onCommit?: (opts: {\n bucket: IBucketRef;\n pendingObject: IObjectRef;\n object: IObjectRef;\n }) => ValueOrPromise<void>;\n};\n\n/** Body of the upload policy route: the files the client intends to upload. */\nexport type TUploadPolicyRequest = {\n files: Array<{ fileName: string; contentType?: string; size?: number }>;\n};\n\n/** The MetaLink table belongs to the application. `Schema` defaults to the table IGNIS ships, and widens to any table whose row carries the same fields. */\nexport type TMetaLinkConfig<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {\n model: TValueOrAsyncResolver<typeof BaseRelationalEntity<Schema>>;\n repository: TValueOrAsyncResolver<DefaultCRUDRepository<Schema>>;\n createMetaLink?: (opts: {\n uploadResult: IUploadResult;\n fileStat: IFileStat;\n /** The caller's labels. Named for where they used to travel - they arrive in the request BODY now, as form fields on an upload and beside the commit token on a direct one. */\n query: TUploadQuery;\n }) => ValueOrPromise<{ count: number; data: TTableObject<Schema> }>;\n};\n\n/** The part of a built-in route an application may change. */\nexport type TStaticAssetRouteConfig = Partial<\n Omit<IAuthRouteConfig, 'method' | 'request' | 'responses'>\n> & {\n /**\n * Whether this route is registered.\n *\n * @default true\n */\n enabled?: boolean;\n};\n\n/** Per-route overrides for the built-in routes of a generated asset controller. A key left out keeps that route as built. */\nexport type TStaticAssetRoutes = {\n getBuckets?: TStaticAssetRouteConfig;\n getBucketByName?: TStaticAssetRouteConfig;\n createBucket?: TStaticAssetRouteConfig;\n deleteBucket?: TStaticAssetRouteConfig;\n\n upload?: TStaticAssetRouteConfig;\n listObjects?: TStaticAssetRouteConfig;\n deleteObject?: TStaticAssetRouteConfig;\n getObjectByName?: TStaticAssetRouteConfig;\n downloadObjectByName?: TStaticAssetRouteConfig;\n\n uploadPolicy?: TStaticAssetRouteConfig;\n uploadCommit?: TStaticAssetRouteConfig;\n\n recreateMetaLink?: TStaticAssetRouteConfig;\n};\n\n/** Static asset controllers keyed by an application-chosen name. Each entry pairs a storage type with its matching helper, and `useMetaLink: true` requires a `metaLink` config. */\nexport type TStaticAssetsComponentOptions<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> = {\n [key: string]: {\n controller: {\n name: string;\n basePath: string;\n\n /**\n * Whether `/path` and `/path/` are different routes on this controller.\n *\n * @default true\n */\n isStrict?: boolean;\n\n /**\n * `true` serves a raw nested object path (`/objects/photos/2024/f.jpg`) - a URL shape change; a percent-encoded path keeps working either way.\n *\n * @default false\n */\n rawObjectPath?: boolean;\n\n /** The single bucket every object route uses. It leaves the URL (`/objects/{objectName}`) and the four bucket-management routes are not registered. The function form is read per request, so an environment variable can be read lazily. */\n bucket?: TValueOrAsyncResolver<string>;\n\n /**\n * The key scope this controller owns, e.g. `inventory/`. Every route refuses a key outside it\n * as a 404 without calling the storage, `listObjects` lists only inside it, and an upload key\n * must land inside it: the default name is placed there, a `resolveObjectName` or\n * `extra.normalizeNameFn` key outside it is refused. `maxFolderDepth` counts the folders below\n * it.\n *\n * @default every key in the bucket\n */\n keyPrefix?: string;\n\n routes?: TStaticAssetRoutes;\n\n /** Direct upload: the browser posts the bytes to the storage and IGNIS only signs the permission. Absent leaves both routes unregistered. Requires `bucket` - a policy names one bucket, and a bucket in the URL is a bucket the caller chooses. */\n directUpload?: TDirectUploadOptions;\n };\n extra?: TStaticAssetExtraOptions;\n\n /** Decides the stored object name of each uploaded file; absent keeps the storage helper's own naming. */\n resolveObjectName?: TObjectNameResolver;\n\n /** Registers the application's own routes BEFORE every built-in one, so a literal path wins over the catch-all `rawObjectPath` produces. Hono matches in registration order. */\n defineRoutesBefore?: TDefineExtraRoutes;\n\n /** Registers the application's own routes on the generated controller, after every built-in one. */\n defineExtraRoutes?: TDefineExtraRoutes;\n } & (\n | { storage: typeof StaticAssetStorageTypes.BUN_S3; helper: BunS3Helper }\n | { storage: typeof StaticAssetStorageTypes.DISK; helper: DiskHelper }\n ) &\n (\n | { useMetaLink?: false | undefined }\n | { useMetaLink: true; metaLink: TMetaLinkConfig<Schema> }\n );\n};\n"]}
|
|
@@ -23,6 +23,8 @@ export declare class AssetDefinitionBuilder {
|
|
|
23
23
|
static build(opts: {
|
|
24
24
|
hasConfiguredBucket?: boolean;
|
|
25
25
|
rawObjectPath?: boolean;
|
|
26
|
+
/** The most files one upload-policy request may name. */
|
|
27
|
+
maxPolicyFiles?: number;
|
|
26
28
|
}): IAssetDefinitions;
|
|
27
29
|
}
|
|
28
30
|
//# sourceMappingURL=base.definition.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenApiResponses } from '@venizia/ignis-kernel';
|
|
2
2
|
import { z } from '@hono/zod-openapi';
|
|
3
3
|
import { HTTP } from '@venizia/ignis-helpers/common';
|
|
4
|
-
import { MetaLinkRecreateActions } from '../common/constants.js';
|
|
4
|
+
import { DEFAULT_MAX_UPLOAD_FILES, MetaLinkRecreateActions } from '../common/constants.js';
|
|
5
5
|
/** The labels both upload paths take. They ride the BODY, not the URL - an identifier in a query string lands in every access log between the client and here. */
|
|
6
6
|
const uploadLabels = () => ({
|
|
7
7
|
principalType: z.string().optional(),
|
|
@@ -59,7 +59,7 @@ const fileStreamResponses = () => ({
|
|
|
59
59
|
*/
|
|
60
60
|
export class AssetDefinitionBuilder {
|
|
61
61
|
static build(opts) {
|
|
62
|
-
const { hasConfiguredBucket = false, rawObjectPath = false } = opts;
|
|
62
|
+
const { hasConfiguredBucket = false, rawObjectPath = false, maxPolicyFiles = DEFAULT_MAX_UPLOAD_FILES, } = opts;
|
|
63
63
|
const bucketPrefix = hasConfiguredBucket ? '' : '/buckets/{bucketName}';
|
|
64
64
|
// `{objectName}` is ONE segment: a folder path travels percent-encoded (`photos%2F2024%2Ff.jpg`).
|
|
65
65
|
// The catch-all also matches a RAW nested path; the encoded form keeps working either way.
|
|
@@ -144,11 +144,13 @@ export class AssetDefinitionBuilder {
|
|
|
144
144
|
content: {
|
|
145
145
|
'application/json': {
|
|
146
146
|
schema: z.object({
|
|
147
|
-
files: z
|
|
147
|
+
files: z
|
|
148
|
+
.array(z.object({
|
|
148
149
|
fileName: z.string().min(1),
|
|
149
150
|
contentType: z.string().optional(),
|
|
150
151
|
size: z.number().int().nonnegative().optional(),
|
|
151
|
-
}))
|
|
152
|
+
}))
|
|
153
|
+
.max(maxPolicyFiles),
|
|
152
154
|
}),
|
|
153
155
|
},
|
|
154
156
|
},
|