@venizia/ignis 0.4.8 → 0.5.0-1

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.
Files changed (114) hide show
  1. package/dist/esm/base/applications/base.js +5 -2
  2. package/dist/esm/base/applications/base.js.map +1 -1
  3. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +1 -1
  4. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
  5. package/dist/esm/components/api-reference/common/keys.d.ts +2 -1
  6. package/dist/esm/components/api-reference/common/keys.js +4 -1
  7. package/dist/esm/components/api-reference/common/keys.js.map +1 -1
  8. package/dist/esm/components/api-reference/common/types.d.ts +1 -1
  9. package/dist/esm/components/api-reference/common/types.js.map +1 -1
  10. package/dist/esm/components/api-reference/component.js.map +1 -1
  11. package/dist/esm/components/auth/authenticate/component.js +10 -16
  12. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  13. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
  14. package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts +2 -2
  15. package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
  16. package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts +2 -2
  17. package/dist/esm/components/auth/authenticate/services/basic/service.js +1 -1
  18. package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
  19. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +1 -1
  20. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  21. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +3 -3
  22. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +1 -1
  23. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  24. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +3 -3
  25. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +2 -2
  26. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  27. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +3 -3
  28. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +1 -1
  29. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
  30. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +10 -22
  31. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +16 -112
  32. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -1
  33. package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts +11 -0
  34. package/dist/esm/components/auth/authenticate/services/service/signer.service.js +18 -0
  35. package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
  36. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +1 -1
  37. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  38. package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
  39. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
  40. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
  41. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
  42. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
  43. package/dist/esm/components/auth/authorize/component.js.map +1 -1
  44. package/dist/esm/components/controller/grpc/common/types.d.ts +1 -1
  45. package/dist/esm/components/controller/grpc/common/types.js +4 -1
  46. package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
  47. package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
  48. package/dist/esm/components/health-check/common/keys.d.ts +4 -2
  49. package/dist/esm/components/health-check/common/keys.js +7 -2
  50. package/dist/esm/components/health-check/common/keys.js.map +1 -1
  51. package/dist/esm/components/health-check/common/types.d.ts +1 -1
  52. package/dist/esm/components/health-check/common/types.js.map +1 -1
  53. package/dist/esm/components/health-check/component.js +1 -3
  54. package/dist/esm/components/health-check/component.js.map +1 -1
  55. package/dist/esm/components/mail/common/constants.d.ts +8 -0
  56. package/dist/esm/components/mail/common/constants.js +6 -0
  57. package/dist/esm/components/mail/common/constants.js.map +1 -1
  58. package/dist/esm/components/mail/common/errors.d.ts +9 -0
  59. package/dist/esm/components/mail/common/errors.js +6 -0
  60. package/dist/esm/components/mail/common/errors.js.map +1 -1
  61. package/dist/esm/components/mail/common/keys.d.ts +14 -11
  62. package/dist/esm/components/mail/common/keys.js +34 -11
  63. package/dist/esm/components/mail/common/keys.js.map +1 -1
  64. package/dist/esm/components/mail/common/types/message.d.ts +3 -0
  65. package/dist/esm/components/mail/common/types/message.js.map +1 -1
  66. package/dist/esm/components/mail/common/types/queue.d.ts +2 -0
  67. package/dist/esm/components/mail/common/types/queue.js.map +1 -1
  68. package/dist/esm/components/mail/common/types/template.d.ts +4 -1
  69. package/dist/esm/components/mail/common/types/template.js.map +1 -1
  70. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +2 -0
  71. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +17 -10
  72. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  73. package/dist/esm/components/mail/services/mail.service.js +3 -2
  74. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  75. package/dist/esm/components/mail/services/template.service.d.ts +3 -3
  76. package/dist/esm/components/mail/services/template.service.js +29 -36
  77. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  78. package/dist/esm/components/mail/utilities/index.d.ts +1 -0
  79. package/dist/esm/components/mail/utilities/index.js +1 -0
  80. package/dist/esm/components/mail/utilities/index.js.map +1 -1
  81. package/dist/esm/components/mail/utilities/template-renderer.utility.d.ts +31 -0
  82. package/dist/esm/components/mail/utilities/template-renderer.utility.js +184 -0
  83. package/dist/esm/components/mail/utilities/template-renderer.utility.js.map +1 -0
  84. package/dist/esm/components/request-tracker/component.d.ts +2 -1
  85. package/dist/esm/components/request-tracker/component.js +5 -5
  86. package/dist/esm/components/request-tracker/component.js.map +1 -1
  87. package/dist/esm/components/server-info/common/keys.d.ts +2 -1
  88. package/dist/esm/components/server-info/common/keys.js +4 -1
  89. package/dist/esm/components/server-info/common/keys.js.map +1 -1
  90. package/dist/esm/components/server-info/common/types.d.ts +1 -1
  91. package/dist/esm/components/server-info/common/types.js.map +1 -1
  92. package/dist/esm/components/server-info/component.js +1 -3
  93. package/dist/esm/components/server-info/component.js.map +1 -1
  94. package/dist/esm/components/socket-io/common/keys.d.ts +9 -6
  95. package/dist/esm/components/socket-io/common/keys.js +19 -6
  96. package/dist/esm/components/socket-io/common/keys.js.map +1 -1
  97. package/dist/esm/components/socket-io/component.js +1 -1
  98. package/dist/esm/components/socket-io/component.js.map +1 -1
  99. package/dist/esm/components/static-asset/common/keys.d.ts +8 -4
  100. package/dist/esm/components/static-asset/common/keys.js +10 -3
  101. package/dist/esm/components/static-asset/common/keys.js.map +1 -1
  102. package/dist/esm/components/static-asset/component.js +1 -0
  103. package/dist/esm/components/static-asset/component.js.map +1 -1
  104. package/dist/esm/components/static-asset/utilities/ingest.utility.d.ts +3 -3
  105. package/dist/esm/components/static-asset/utilities/ingest.utility.js +14 -18
  106. package/dist/esm/components/static-asset/utilities/ingest.utility.js.map +1 -1
  107. package/dist/esm/components/websocket/common/keys.d.ts +12 -10
  108. package/dist/esm/components/websocket/common/keys.js +31 -10
  109. package/dist/esm/components/websocket/common/keys.js.map +1 -1
  110. package/dist/esm/components/websocket/component.js.map +1 -1
  111. package/dist/presets/app/preset.json +4 -4
  112. package/dist/presets/lib/preset.json +3 -3
  113. package/dist/presets/shared/preset.json +1 -1
  114. package/package.json +8 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-renderer.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/template-renderer.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAA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AAK,QAAQ,EAAE,CAAC;gBAC9B,MAAM,oBAAoB,CAAC,OAAO,CAAC;oBACjC,OAAO,EAAE,oDAAoD,IAAI,CAAC,GAAG,mDAAmD;iBACzH,CAAC,CAAC;YACL,CAAC;YAED,+DAA+D;YAC/D,GAAG,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport { MailErrors, MailTemplateFormats, MailTemplateMissingModes } from '../common';\nimport type { TMailTemplateFormat, TMailTemplateMissing } from '../common';\n\n/**\n * One tag: `{{{key}}}` (group 1), or a placeholder or a section tag (group 2 the sigil `#`, `^` or `/`, group 3 the key; a lone `.` is the current\n * item). The last form only finds the start of a Mustache partial, comment, delimiter change or `&` tag: those are refused. Any other `{{` stays as written.\n */\nconst TAG = /\\{\\{\\{\\s*([\\w.]+)\\s*\\}\\}\\}|\\{\\{\\s*(?:([#^/])\\s*)?([\\w.]+)\\s*\\}\\}|\\{\\{\\s*[>=!&<]/g;\n\n/** How many sections may be open at once: deeper than any real template, and a bound on the scope stack. */\nconst MAX_DEPTH = 64;\n\ntype TNode =\n | { type: 'text'; text: string }\n | { type: 'value'; key: string; isRaw: boolean; source: string }\n | { type: 'section'; key: string; isInverted: boolean; children: TNode[] };\n\n/** Renders placeholders (escaped, raw and dotted) and sections (a list, a flag, its inverse): no partial, no lambda, no delimiter change, no code. */\nexport class MailTemplateRenderer {\n private static invalid(opts: { message: string }) {\n return getError({ error: MailErrors.TEMPLATE_INVALID, message: opts.message });\n }\n\n /** Splits a template into text, values and sections; a closing tag that does not match, a section left open and a tag this renderer does not have throw. */\n private static parse(opts: { template: string }): TNode[] {\n const { template } = opts;\n const root: TNode[] = [];\n const open: Array<{ key: string; parent: TNode[] }> = [];\n let current = root;\n let cursor = 0;\n\n for (const match of template.matchAll(TAG)) {\n const [source, rawKey, sigil, key] = match;\n\n current.push({ type: 'text', text: template.slice(cursor, match.index) });\n cursor = match.index + source.length;\n\n if (rawKey === undefined && key === undefined) {\n throw MailTemplateRenderer.invalid({ message: `Unsupported template tag: ${source}` });\n }\n\n if (sigil === '#' || sigil === '^') {\n if (open.length >= MAX_DEPTH) {\n throw MailTemplateRenderer.invalid({\n message: `Template nests sections deeper than ${MAX_DEPTH}`,\n });\n }\n\n const children: TNode[] = [];\n\n current.push({ type: 'section', key, isInverted: sigil === '^', children });\n open.push({ key, parent: current });\n current = children;\n } else if (sigil === '/') {\n const closing = open.pop();\n\n if (closing?.key !== key) {\n throw MailTemplateRenderer.invalid({\n message: `Template closes {{/${key}}} but ${closing ? `{{#${closing.key}}} is open` : 'no section is open'}`,\n });\n }\n\n current = closing.parent;\n } else {\n current.push({ type: 'value', key: rawKey ?? key, isRaw: rawKey !== undefined, source });\n }\n }\n\n if (open.length > 0) {\n throw MailTemplateRenderer.invalid({\n message: `Template leaves {{#${open[open.length - 1].key}}} open`,\n });\n }\n\n current.push({ type: 'text', text: template.slice(cursor) });\n\n return root;\n }\n\n /** The keys a template reads outside any section, and the keys of its sections (a section body reads the item first, so its keys are not the data's to check). */\n static readKeys(opts: { template: string }): { valueKeys: string[]; sectionKeys: string[] } {\n const valueKeys: string[] = [];\n const sectionKeys: string[] = [];\n\n const visit = (nodes: TNode[], isTopLevel: boolean) => {\n for (const node of nodes) {\n if (\n node.type === 'value' &&\n isTopLevel &&\n node.key !== '.' &&\n !valueKeys.includes(node.key)\n ) {\n valueKeys.push(node.key);\n }\n\n if (node.type === 'section') {\n if (!sectionKeys.includes(node.key)) {\n sectionKeys.push(node.key);\n }\n\n visit(node.children, false);\n }\n }\n };\n\n visit(MailTemplateRenderer.parse(opts), true);\n\n return { valueKeys, sectionKeys };\n }\n\n /** Own properties only, so a key such as `constructor` or `__proto__.x` never reaches the prototype chain. The first segment picks the innermost scope that has it. */\n private static lookup(opts: { scopes: unknown[]; key: string }): unknown {\n const { scopes, key } = opts;\n\n if (key === '.') {\n return scopes[scopes.length - 1];\n }\n\n const [head, ...rest] = key.split('.');\n let start: unknown;\n\n for (let index = scopes.length - 1; index >= 0; index -= 1) {\n const scope = scopes[index];\n\n if (scope !== null && typeof scope === 'object' && Object.hasOwn(scope, head)) {\n start = Reflect.get(scope, head);\n break;\n }\n }\n\n return rest.reduce<unknown>(\n (current, segment) =>\n current !== null && typeof current === 'object' && Object.hasOwn(current, segment)\n ? Reflect.get(current, segment)\n : undefined,\n start,\n );\n }\n\n /** The value of `key` in `data` (own properties only), or `undefined`. */\n static read(opts: { data: Record<string, unknown>; key: string }): unknown {\n return MailTemplateRenderer.lookup({ scopes: [opts.data], key: opts.key });\n }\n\n static render(opts: {\n template: string;\n data: Record<string, unknown>;\n format?: TMailTemplateFormat;\n missing?: TMailTemplateMissing;\n /** Called with the key of every placeholder that rendered empty because the data had no value (never the value). */\n onEmpty?: (key: string) => void;\n }): string {\n const {\n template,\n data,\n format = MailTemplateFormats.HTML,\n missing = MailTemplateMissingModes.EMPTY,\n onEmpty,\n } = opts;\n\n return MailTemplateRenderer.renderNodes({\n nodes: MailTemplateRenderer.parse({ template }),\n scopes: [data],\n isHtml: format === MailTemplateFormats.HTML,\n missing,\n onEmpty,\n });\n }\n\n private static renderNodes(opts: {\n nodes: TNode[];\n scopes: unknown[];\n isHtml: boolean;\n missing: TMailTemplateMissing;\n onEmpty?: (key: string) => void;\n }): string {\n const { nodes, scopes, isHtml, missing, onEmpty } = opts;\n let out = '';\n\n for (const node of nodes) {\n if (node.type === 'text') {\n out += node.text;\n continue;\n }\n\n const value = MailTemplateRenderer.lookup({ scopes, key: node.key });\n\n if (typeof value === 'function') {\n throw MailTemplateRenderer.invalid({\n message: `Template value is a function: ${node.key}`,\n });\n }\n\n if (node.type === 'section') {\n const isEmpty = !value || (Array.isArray(value) && value.length === 0);\n\n if (node.isInverted) {\n out += isEmpty\n ? MailTemplateRenderer.renderNodes({\n nodes: node.children,\n scopes,\n isHtml,\n missing,\n onEmpty,\n })\n : '';\n } else if (!isEmpty) {\n // A list repeats per item, anything else truthy renders once; `{{.}}` is the item, and its keys come before the outer ones.\n for (const item of Array.isArray(value) ? value : [value]) {\n out += MailTemplateRenderer.renderNodes({\n nodes: node.children,\n scopes: [...scopes, item],\n isHtml,\n missing,\n onEmpty,\n });\n }\n }\n\n continue;\n }\n\n if (value === undefined || value === null) {\n if (missing === MailTemplateMissingModes.THROW) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: `Missing template data for keys: ${node.key}`,\n });\n }\n\n if (missing === MailTemplateMissingModes.KEEP) {\n out += node.source;\n } else {\n onEmpty?.(node.key);\n }\n\n continue;\n }\n\n if (typeof value === 'object') {\n throw MailTemplateRenderer.invalid({\n message: `Template value is an object or a list, not text: ${node.key} | resolve it (a locale, a date) before rendering`,\n });\n }\n\n // `{{{key}}}` inserts as it is; `{{key}}` is escaped for HTML.\n out += isHtml && !node.isRaw ? Bun.escapeHTML(String(value)) : String(value);\n }\n\n return out;\n }\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  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
+ import { type MiddlewareHandler } from 'hono/types';
4
5
  /** Installs the request spy middleware on the application server, which tracks each request. */
5
6
  export declare class RequestTrackerComponent extends BaseComponent {
6
7
  private application;
7
- static readonly REQUEST_TRACKER_MW_BINDING_KEY: string;
8
+ static readonly REQUEST_TRACKER_MW_BINDING_KEY: import("@venizia/ignis-inversion").TBindingKey<MiddlewareHandler>;
8
9
  constructor(application: BaseApplication);
9
10
  /** No `requestId()` here: the id is installed by `RestApplication.registerDefaultMiddlewares()`, which runs first and uses `RequestIdGenerator`. Same UUID v4 shape hono's own default produces, but hono calls `crypto.randomUUID` unguarded, and a browser leaves that one `undefined` outside a secure context. */
10
11
  binding(): ValueOrPromise<void>;
@@ -14,16 +14,16 @@ var RequestTrackerComponent_1;
14
14
  import { BaseComponent } from '@venizia/ignis-kernel';
15
15
  import { inject } from '../../base/metadata/index.js';
16
16
  import { RequestSpyMiddleware } from '../../base/middlewares/index.js';
17
- import { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';
17
+ import { BindingKeys, BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';
18
18
  import { Binding, BindingScopes } from '@venizia/ignis-kernel';
19
19
  import { getError } from '@venizia/ignis-helpers/core';
20
20
  /** Installs the request spy middleware on the application server, which tracks each request. */
21
21
  let RequestTrackerComponent = class RequestTrackerComponent extends BaseComponent {
22
22
  static { RequestTrackerComponent_1 = this; }
23
- static { this.REQUEST_TRACKER_MW_BINDING_KEY = [
24
- BindingNamespaces.MIDDLEWARE,
25
- RequestSpyMiddleware.name,
26
- ].join('.'); }
23
+ static { this.REQUEST_TRACKER_MW_BINDING_KEY = BindingKeys.build({
24
+ namespace: BindingNamespaces.MIDDLEWARE,
25
+ key: RequestSpyMiddleware.name,
26
+ }); }
27
27
  constructor(application) {
28
28
  super({
29
29
  scope: RequestTrackerComponent_1.name,
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/request-tracker/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIvD,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ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { RequestSpyMiddleware } from '@/base/middlewares';\nimport { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding, BindingScopes } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type MiddlewareHandler } from 'hono/types';\n\n/** Installs the request spy middleware on the application server, which tracks each request. */\nexport class RequestTrackerComponent extends BaseComponent {\n static readonly REQUEST_TRACKER_MW_BINDING_KEY = [\n BindingNamespaces.MIDDLEWARE,\n RequestSpyMiddleware.name,\n ].join('.');\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: RequestTrackerComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY]: Binding.bind({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n })\n .toProvider(RequestSpyMiddleware)\n .setScope(BindingScopes.SINGLETON),\n },\n });\n }\n\n /** No `requestId()` here: the id is installed by `RestApplication.registerDefaultMiddlewares()`, which runs first and uses `RequestIdGenerator`. Same UUID v4 shape hono's own default produces, but hono calls `crypto.randomUUID` unguarded, and a browser leaves that one `undefined` outside a secure context. */\n override binding(): ValueOrPromise<void> {\n const server = this.application.getServer();\n\n const mw = this.application.get<MiddlewareHandler>({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n });\n\n if (!mw) {\n throw getError({\n message: `[RequestTrackerComponent][binding] Invalid middleware to init request tracker | Please check again binding value | key: ${RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY}`,\n });\n }\n\n server.use(mw);\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/request-tracker/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,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AAM,QAAQ,CAAC;gBACb,OAAO,EAAE,2HAA2H,yBAAuB,CAAC,8BAA8B,EAAE;aAC7L,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;;AArCU,uBAAuB;IAO/B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAP1C,uBAAuB,CAsCnC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { RequestSpyMiddleware } from '@/base/middlewares';\nimport { BindingKeys, BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding, BindingScopes } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type MiddlewareHandler } from 'hono/types';\n\n/** Installs the request spy middleware on the application server, which tracks each request. */\nexport class RequestTrackerComponent extends BaseComponent {\n static readonly REQUEST_TRACKER_MW_BINDING_KEY = BindingKeys.build<MiddlewareHandler>({\n namespace: BindingNamespaces.MIDDLEWARE,\n key: RequestSpyMiddleware.name,\n });\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: RequestTrackerComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY]: Binding.bind({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n })\n .toProvider(RequestSpyMiddleware)\n .setScope(BindingScopes.SINGLETON),\n },\n });\n }\n\n /** No `requestId()` here: the id is installed by `RestApplication.registerDefaultMiddlewares()`, which runs first and uses `RequestIdGenerator`. Same UUID v4 shape hono's own default produces, but hono calls `crypto.randomUUID` unguarded, and a browser leaves that one `undefined` outside a secure context. */\n override binding(): ValueOrPromise<void> {\n const server = this.application.getServer();\n\n const mw = this.application.get<MiddlewareHandler>({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n });\n\n if (!mw) {\n throw getError({\n message: `[RequestTrackerComponent][binding] Invalid middleware to init request tracker | Please check again binding value | key: ${RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY}`,\n });\n }\n\n server.use(mw);\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
+ import type { IServerInfoOptions } from './types.js';
1
2
  /** Container keys of the server info component. */
2
3
  export declare class ServerInfoBindingKeys {
3
- static readonly SERVER_INFO_OPTIONS = "@app/server-info/options";
4
+ static readonly SERVER_INFO_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<IServerInfoOptions>;
4
5
  }
5
6
  //# sourceMappingURL=keys.d.ts.map
@@ -1,5 +1,8 @@
1
+ import { BindingKeys } from '@venizia/ignis-inversion';
1
2
  /** Container keys of the server info component. */
2
3
  export class ServerInfoBindingKeys {
3
- static { this.SERVER_INFO_OPTIONS = '@app/server-info/options'; }
4
+ static { this.SERVER_INFO_OPTIONS = BindingKeys.build({
5
+ key: '@app/server-info/options',
6
+ }); }
4
7
  }
5
8
  //# sourceMappingURL=keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/keys.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,OAAO,qBAAqB;aAChB,wBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/** Container keys of the server info component. */\nexport class ServerInfoBindingKeys {\n static readonly SERVER_INFO_OPTIONS = '@app/server-info/options';\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,mDAAmD;AACnD,MAAM,OAAO,qBAAqB;aAChB,wBAAmB,GAAG,WAAW,CAAC,KAAK,CAAqB;QAC1E,GAAG,EAAE,0BAA0B;KAChC,CAAC,CAAC","sourcesContent":["import { BindingKeys } from '@venizia/ignis-inversion';\nimport type { IServerInfoOptions } from './types';\n\n/** Container keys of the server info component. */\nexport class ServerInfoBindingKeys {\n static readonly SERVER_INFO_OPTIONS = BindingKeys.build<IServerInfoOptions>({\n key: '@app/server-info/options',\n });\n}\n"]}
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * export const bindServerInfo = (application: BaseApplication) => {
9
9
  * application
10
- * .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
10
+ * .bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
11
11
  * .toValue({ restOptions: { path: '/clock' } });
12
12
  * };
13
13
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';\n *\n * export const bindServerInfo = (application: BaseApplication) => {\n * application\n * .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })\n * .toValue({ restOptions: { path: '/clock' } });\n * };\n * ```\n */\nexport interface IServerInfoOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the server info routes mount under. The routes are public by design.\n *\n * @default '/server/info'\n */\n path?: string;\n };\n}\n\n/**\n * Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.\n *\n * @example\n * ```json\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 */\nexport interface IServerTime {\n server: {\n /** Calendar date in the server time zone, `YYYY-MM-DD`. */\n date: string;\n /** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */\n time: string;\n /** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */\n epoch: number;\n /** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */\n iso: string;\n };\n /** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */\n tz: string;\n utc: {\n /** Offset of `tz` from UTC at response time, `+07:00` style. */\n offset: string;\n /**\n * The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite\n * sign of JavaScript's `Date.prototype.getTimezoneOffset()`.\n */\n minutes: number;\n /** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */\n iso: string;\n };\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';\n *\n * export const bindServerInfo = (application: BaseApplication) => {\n * application\n * .bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })\n * .toValue({ restOptions: { path: '/clock' } });\n * };\n * ```\n */\nexport interface IServerInfoOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the server info routes mount under. The routes are public by design.\n *\n * @default '/server/info'\n */\n path?: string;\n };\n}\n\n/**\n * Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.\n *\n * @example\n * ```json\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 */\nexport interface IServerTime {\n server: {\n /** Calendar date in the server time zone, `YYYY-MM-DD`. */\n date: string;\n /** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */\n time: string;\n /** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */\n epoch: number;\n /** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */\n iso: string;\n };\n /** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */\n tz: string;\n utc: {\n /** Offset of `tz` from UTC at response time, `+07:00` style. */\n offset: string;\n /**\n * The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite\n * sign of JavaScript's `Date.prototype.getTimezoneOffset()`.\n */\n minutes: number;\n /** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */\n iso: string;\n };\n}\n"]}
@@ -60,9 +60,7 @@ let ServerInfoComponent = ServerInfoComponent_1 = class ServerInfoComponent exte
60
60
  return;
61
61
  }
62
62
  if (opts !== undefined) {
63
- this.application
64
- .bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
65
- .toValue(opts);
63
+ this.application.bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS }).toValue(opts);
66
64
  }
67
65
  await super.configure(opts);
68
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/server-info/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO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C9C,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,6FAA6F;QAC7F,MAAM,IAAI,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,iBAAiB,CAAC;QAE7D,6FAA6F;QAC7F,4FAA4F;QAC5F,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC/D,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AA9CY,mBAAmB;IAE3B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,mBAAmB,CA8C/B","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { controller, inject } from '@/base/metadata';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport { ServerInfoBindingKeys, type IServerInfoOptions } from './common';\nimport { ServerInfoController } from './controller';\n\nconst DEFAULT_REST_PATH = '/server/info';\nconst DEFAULT_OPTIONS: IServerInfoOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\n/**\n * Mounts the server info controller: `GET <path>/time`, public, no authentication.\n *\n * The rule of this component: it carries only data that is safe to publish and does not help an\n * attacker. No version, runtime, pid, memory or environment - those stay in the gated\n * `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock\n * `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.\n *\n * @example\n * ```typescript\n * import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * const options: IServerInfoOptions = { restOptions: { path: '/clock' } };\n * this.component(ServerInfoComponent, { options });\n * }\n * }\n * ```\n */\nexport class ServerInfoComponent extends BaseComponent<IServerInfoOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ServerInfoComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ServerInfoBindingKeys.SERVER_INFO_OPTIONS]: Binding.bind<IServerInfoOptions>({\n key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */\n override async configure(opts?: IServerInfoOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application\n .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })\n .toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override binding(): void {\n const options = this.application.get<IServerInfoOptions>({\n key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = options?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // `@controller` writes the PATH onto this shared class in the process-wide MetadataRegistry;\n // two applications booted concurrently with different paths would race, as in health-check.\n Reflect.decorate([controller({ path })], ServerInfoController);\n this.application.controller(ServerInfoController);\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/server-info/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAA2B,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,MAAM,eAAe,GAAuB;IAC1C,WAAW,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;CACzC,C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I,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC/D,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AA5CY,mBAAmB;IAE3B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,mBAAmB,CA4C/B","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { controller, inject } from '@/base/metadata';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport { ServerInfoBindingKeys, type IServerInfoOptions } from './common';\nimport { ServerInfoController } from './controller';\n\nconst DEFAULT_REST_PATH = '/server/info';\nconst DEFAULT_OPTIONS: IServerInfoOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\n/**\n * Mounts the server info controller: `GET <path>/time`, public, no authentication.\n *\n * The rule of this component: it carries only data that is safe to publish and does not help an\n * attacker. No version, runtime, pid, memory or environment - those stay in the gated\n * `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock\n * `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.\n *\n * @example\n * ```typescript\n * import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * const options: IServerInfoOptions = { restOptions: { path: '/clock' } };\n * this.component(ServerInfoComponent, { options });\n * }\n * }\n * ```\n */\nexport class ServerInfoComponent extends BaseComponent<IServerInfoOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ServerInfoComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ServerInfoBindingKeys.SERVER_INFO_OPTIONS]: Binding.bind({\n key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */\n override async configure(opts?: IServerInfoOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application.bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS }).toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override binding(): void {\n const options = this.application.get({\n key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = options?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // `@controller` writes the PATH onto this shared class in the process-wide MetadataRegistry;\n // two applications booted concurrently with different paths would race, as in health-check.\n Reflect.decorate([controller({ path })], ServerInfoController);\n this.application.controller(ServerInfoController);\n }\n}\n"]}
@@ -1,10 +1,13 @@
1
+ import type { AbstractRedisHelper } from '@venizia/ignis-helpers';
2
+ import type { SocketIOServerHelper, TSocketIOAuthenticateFn, TSocketIOClientConnectedFn, TSocketIOValidateRoomFn } from '@venizia/ignis-helpers/socket-io';
3
+ import type { ServerOptions } from 'socket.io';
1
4
  /** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */
2
5
  export declare class SocketIOBindingKeys {
3
- static readonly SOCKET_IO_INSTANCE = "@app/socket-io/instance";
4
- static readonly SERVER_OPTIONS = "@app/socket-io/server-options";
5
- static readonly REDIS_CONNECTION = "@app/socket-io/redis-connection";
6
- static readonly AUTHENTICATE_HANDLER = "@app/socket-io/authenticate-handler";
7
- static readonly VALIDATE_ROOM_HANDLER = "@app/socket-io/validate-room-handler";
8
- static readonly CLIENT_CONNECTED_HANDLER = "@app/socket-io/client-connected-handler";
6
+ static readonly SOCKET_IO_INSTANCE: import("@venizia/ignis-inversion").TBindingKey<SocketIOServerHelper>;
7
+ static readonly SERVER_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<Partial<ServerOptions>>;
8
+ static readonly REDIS_CONNECTION: import("@venizia/ignis-inversion").TBindingKey<AbstractRedisHelper<import("@venizia/ignis-helpers").TRedisClient> | null>;
9
+ static readonly AUTHENTICATE_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TSocketIOAuthenticateFn | null>;
10
+ static readonly VALIDATE_ROOM_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TSocketIOValidateRoomFn | null>;
11
+ static readonly CLIENT_CONNECTED_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TSocketIOClientConnectedFn | null>;
9
12
  }
10
13
  //# sourceMappingURL=keys.d.ts.map
@@ -1,10 +1,23 @@
1
+ import { BindingKeys } from '@venizia/ignis-inversion';
1
2
  /** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */
2
3
  export class SocketIOBindingKeys {
3
- static { this.SOCKET_IO_INSTANCE = '@app/socket-io/instance'; }
4
- static { this.SERVER_OPTIONS = '@app/socket-io/server-options'; }
5
- static { this.REDIS_CONNECTION = '@app/socket-io/redis-connection'; }
6
- static { this.AUTHENTICATE_HANDLER = '@app/socket-io/authenticate-handler'; }
7
- static { this.VALIDATE_ROOM_HANDLER = '@app/socket-io/validate-room-handler'; }
8
- static { this.CLIENT_CONNECTED_HANDLER = '@app/socket-io/client-connected-handler'; }
4
+ static { this.SOCKET_IO_INSTANCE = BindingKeys.build({
5
+ key: '@app/socket-io/instance',
6
+ }); }
7
+ static { this.SERVER_OPTIONS = BindingKeys.build({
8
+ key: '@app/socket-io/server-options',
9
+ }); }
10
+ static { this.REDIS_CONNECTION = BindingKeys.build({
11
+ key: '@app/socket-io/redis-connection',
12
+ }); }
13
+ static { this.AUTHENTICATE_HANDLER = BindingKeys.build({
14
+ key: '@app/socket-io/authenticate-handler',
15
+ }); }
16
+ static { this.VALIDATE_ROOM_HANDLER = BindingKeys.build({
17
+ key: '@app/socket-io/validate-room-handler',
18
+ }); }
19
+ static { this.CLIENT_CONNECTED_HANDLER = BindingKeys.build({
20
+ key: '@app/socket-io/client-connected-handler',
21
+ }); }
9
22
  }
10
23
  //# sourceMappingURL=keys.js.map
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAUvD,+IAA+I;AAC/I,MAAM,OAAO,mBAAmB;aACd,uBAAkB,GAAG,WAAW,CAAC,KAAK,CAAuB;QAC3E,GAAG,EAAE,yBAAyB;KAC/B,CAAC,CAAC;aAEa,mBAAc,GAAG,WAAW,CAAC,KAAK,CAAyB;QACzE,GAAG,EAAE,+BAA+B;KACrC,CAAC,CAAC;aAEa,qBAAgB,GAAG,WAAW,CAAC,KAAK,CAA6B;QAC/E,GAAG,EAAE,iCAAiC;KACvC,CAAC,CAAC;aAEa,yBAAoB,GAAG,WAAW,CAAC,KAAK,CAAiC;QACvF,GAAG,EAAE,qCAAqC;KAC3C,CAAC,CAAC;aAEa,0BAAqB,GAAG,WAAW,CAAC,KAAK,CAAiC;QACxF,GAAG,EAAE,sCAAsC;KAC5C,CAAC,CAAC;aAEa,6BAAwB,GAAG,WAAW,CAAC,KAAK,CAAoC;QAC9F,GAAG,EAAE,yCAAyC;KAC/C,CAAC,CAAC","sourcesContent":["import { BindingKeys } from '@venizia/ignis-inversion';\nimport type { AbstractRedisHelper } from '@venizia/ignis-helpers';\nimport type {\n SocketIOServerHelper,\n TSocketIOAuthenticateFn,\n TSocketIOClientConnectedFn,\n TSocketIOValidateRoomFn,\n} from '@venizia/ignis-helpers/socket-io';\nimport type { ServerOptions } from 'socket.io';\n\n/** 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 = BindingKeys.build<SocketIOServerHelper>({\n key: '@app/socket-io/instance',\n });\n\n static readonly SERVER_OPTIONS = BindingKeys.build<Partial<ServerOptions>>({\n key: '@app/socket-io/server-options',\n });\n\n static readonly REDIS_CONNECTION = BindingKeys.build<AbstractRedisHelper | null>({\n key: '@app/socket-io/redis-connection',\n });\n\n static readonly AUTHENTICATE_HANDLER = BindingKeys.build<TSocketIOAuthenticateFn | null>({\n key: '@app/socket-io/authenticate-handler',\n });\n\n static readonly VALIDATE_ROOM_HANDLER = BindingKeys.build<TSocketIOValidateRoomFn | null>({\n key: '@app/socket-io/validate-room-handler',\n });\n\n static readonly CLIENT_CONNECTED_HANDLER = BindingKeys.build<TSocketIOClientConnectedFn | null>({\n key: '@app/socket-io/client-connected-handler',\n });\n}\n"]}
@@ -18,7 +18,7 @@ import { Binding } from '@venizia/ignis-kernel';
18
18
  import { getError } from '@venizia/ignis-helpers/core';
19
19
  import { HTTP, RuntimeModules } from '@venizia/ignis-helpers/common';
20
20
  import { isRedisHelper } from '@venizia/ignis-helpers';
21
- import { SocketIOServerHelper, } from '@venizia/ignis-helpers/socket-io';
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
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. */
@@ -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,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,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,mBAAmB,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAyB;oBACzE,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AC,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"]}
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,OAA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,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;AApIY,iBAAiB;IAIzB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,iBAAiB,CAoI7B","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 { isRedisHelper } from '@venizia/ignis-helpers';\nimport { SocketIOServerHelper } from '@venizia/ignis-helpers/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({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n }).toValue(DEFAULT_SERVER_OPTIONS),\n\n [SocketIOBindingKeys.REDIS_CONNECTION]: Binding.bind({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n }).toValue(null),\n\n [SocketIOBindingKeys.AUTHENTICATE_HANDLER]: Binding.bind({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.VALIDATE_ROOM_HANDLER]: Binding.bind({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER]: Binding.bind({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }).toValue(null),\n },\n });\n }\n\n private resolveBindings(): IResolvedBindings {\n const extraServerOptions =\n this.application.get({\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({\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({\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({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }) ?? undefined;\n\n const clientConnectedFn =\n this.application.get({\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,14 +1,18 @@
1
+ import type { TBindingKey } from '@venizia/ignis-inversion';
2
+ import type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models/index.js';
3
+ import type { StaticAssetUploadCommitService, StaticAssetUploadPolicyService } from '../services/index.js';
4
+ import type { TStaticAssetComponentOptions } from './types.js';
1
5
  /** Container keys of the static asset component. */
2
6
  export declare class StaticAssetBindingKeys {
3
7
  /** 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. */
4
- static readonly STATIC_ASSET_OPTIONS = "@app/static-asset/options";
8
+ static readonly STATIC_ASSET_OPTIONS: TBindingKey<TStaticAssetComponentOptions<TMetaLinkCompatibleSchema>>;
5
9
  /** The `StaticAssetUploadPolicyService` of one options entry, bound only for an entry that turns `directUpload` on. `name` is the entry's KEY in the options object, not the controller name. */
6
10
  static policyService(opts: {
7
11
  name: string;
8
- }): string;
12
+ }): TBindingKey<StaticAssetUploadPolicyService>;
9
13
  /** The `StaticAssetUploadCommitService` of one options entry, bound with its policy service. */
10
- static commitService(opts: {
14
+ static commitService<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema>(opts: {
11
15
  name: string;
12
- }): string;
16
+ }): TBindingKey<StaticAssetUploadCommitService<Schema>>;
13
17
  }
14
18
  //# sourceMappingURL=keys.d.ts.map
@@ -1,14 +1,21 @@
1
+ import { BindingKeys } from '@venizia/ignis-inversion';
1
2
  /** Container keys of the static asset component. */
2
3
  export class StaticAssetBindingKeys {
3
4
  /** 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. */
4
- static { this.STATIC_ASSET_OPTIONS = '@app/static-asset/options'; }
5
+ static { this.STATIC_ASSET_OPTIONS = BindingKeys.build({
6
+ key: '@app/static-asset/options',
7
+ }); }
5
8
  /** The `StaticAssetUploadPolicyService` of one options entry, bound only for an entry that turns `directUpload` on. `name` is the entry's KEY in the options object, not the controller name. */
6
9
  static policyService(opts) {
7
- return `@app/static-asset/policy-service/${opts.name}`;
10
+ return BindingKeys.build({
11
+ key: `@app/static-asset/policy-service/${opts.name}`,
12
+ });
8
13
  }
9
14
  /** The `StaticAssetUploadCommitService` of one options entry, bound with its policy service. */
10
15
  static commitService(opts) {
11
- return `@app/static-asset/commit-service/${opts.name}`;
16
+ return BindingKeys.build({
17
+ key: `@app/static-asset/commit-service/${opts.name}`,
18
+ });
12
19
  }
13
20
  }
14
21
  //# sourceMappingURL=keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/keys.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,OAAO,sBAAsB;IACjC,oPAAoP;aACpO,yBAAoB,GAAG,2BAA2B,CAAC;IAEnE,iMAAiM;IACjM,MAAM,CAAC,aAAa,CAAC,IAAsB;QACzC,OAAO,oCAAoC,IAAI,CAAC,IAAI,EAAE,CAAC;IACzD,CAAC;IAED,gGAAgG;IAChG,MAAM,CAAC,aAAa,CAAC,IAAsB;QACzC,OAAO,oCAAoC,IAAI,CAAC,IAAI,EAAE,CAAC;IACzD,CAAC","sourcesContent":["/** Container keys of the static asset component. */\nexport class StaticAssetBindingKeys {\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_OPTIONS = '@app/static-asset/options';\n\n /** The `StaticAssetUploadPolicyService` of one options entry, bound only for an entry that turns `directUpload` on. `name` is the entry's KEY in the options object, not the controller name. */\n static policyService(opts: { name: string }): string {\n return `@app/static-asset/policy-service/${opts.name}`;\n }\n\n /** The `StaticAssetUploadCommitService` of one options entry, bound with its policy service. */\n static commitService(opts: { name: string }): string {\n return `@app/static-asset/commit-service/${opts.name}`;\n }\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvD,oDAAoD;AACpD,MAAM,OAAO,sBAAsB;IACjC,oPAAoP;aACpO,yBAAoB,GAAG,WAAW,CAAC,KAAK,CAEtD;QACA,GAAG,EAAE,2BAA2B;KACjC,CAAC,CAAC;IAEH,iMAAiM;IACjM,MAAM,CAAC,aAAa,CAAC,IAAsB;QACzC,OAAO,WAAW,CAAC,KAAK,CAAiC;YACvD,GAAG,EAAE,oCAAoC,IAAI,CAAC,IAAI,EAAE;SACrD,CAAC,CAAC;IACL,CAAC;IAED,gGAAgG;IAChG,MAAM,CAAC,aAAa,CAA6D,IAEhF;QACC,OAAO,WAAW,CAAC,KAAK,CAAyC;YAC/D,GAAG,EAAE,oCAAoC,IAAI,CAAC,IAAI,EAAE;SACrD,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { BindingKeys } from '@venizia/ignis-inversion';\nimport type { TBindingKey } from '@venizia/ignis-inversion';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models';\nimport type { StaticAssetUploadCommitService, StaticAssetUploadPolicyService } from '../services';\nimport type { TStaticAssetComponentOptions } from './types';\n\n/** Container keys of the static asset component. */\nexport class StaticAssetBindingKeys {\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_OPTIONS = BindingKeys.build<\n TStaticAssetComponentOptions<TMetaLinkCompatibleSchema>\n >({\n key: '@app/static-asset/options',\n });\n\n /** The `StaticAssetUploadPolicyService` of one options entry, bound only for an entry that turns `directUpload` on. `name` is the entry's KEY in the options object, not the controller name. */\n static policyService(opts: { name: string }): TBindingKey<StaticAssetUploadPolicyService> {\n return BindingKeys.build<StaticAssetUploadPolicyService>({\n key: `@app/static-asset/policy-service/${opts.name}`,\n });\n }\n\n /** The `StaticAssetUploadCommitService` of one options entry, bound with its policy service. */\n static commitService<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema>(opts: {\n name: string;\n }): TBindingKey<StaticAssetUploadCommitService<Schema>> {\n return BindingKeys.build<StaticAssetUploadCommitService<Schema>>({\n key: `@app/static-asset/commit-service/${opts.name}`,\n });\n }\n}\n"]}
@@ -36,6 +36,7 @@ let StaticAssetComponent = StaticAssetComponent_1 = class StaticAssetComponent e
36
36
  // Direct options win. The key is the path for an application that registers this component
37
37
  // through `configs.artifacts`, where an index carries classes and no options.
38
38
  const componentOptions = this.options ??
39
+ // The key is typed with the widest schema; this component is generic over its own, so it names it.
39
40
  this.application.get({
40
41
  key: StaticAssetBindingKeys.STATIC_ASSET_OPTIONS,
41
42
  });
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/static-asset/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;AAEhD,OAAO,EAAE,sBAAsB,EAAqC,MAAM,UAAU,CAAC;AAErF,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAkC,MAAM,2BAA2B,CAAC;AAEpG,kQAAkQ;AAClQ,IAAa,oBAAoB,4BAAjC,MAAa,oBAEX,SAAQ,aAAmD;IAC3D,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,sBAAoB,CAAC,IAAI;YAChC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE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AM,QAAQ,GAAG,uBAAuB,CAAC,yBAAyB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEjF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,WAAW;aACb,IAAI,CAAC,EAAE,GAAG,EAAE,sBAAsB,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;aAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QACnC,IAAI,CAAC,WAAW;aACb,IAAI,CAAC,EAAE,GAAG,EAAE,sBAAsB,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;aAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAEnC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAlEY,oBAAoB;IAI5B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,oBAAoB,CAkEhC","sourcesContent":["import { type BaseApplication } 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 { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { StaticAssetBindingKeys, type TStaticAssetComponentOptions } from './common';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from './models';\nimport { StaticAssetControllerFactory } from './controller';\nimport { StaticAssetEntryUtility, type IStaticAssetResolvedEntry } from './utilities/entry.utility';\n\n/** `Schema` is the MetaLink table the application binds. It has to live on the CLASS, not only on the options: `component(Ctor, { options })` infers the options from the class, so a class pinned to the shipped table can only carry options for that table. */\nexport class StaticAssetComponent<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> extends BaseComponent<TStaticAssetComponentOptions<Schema>> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: StaticAssetComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [StaticAssetBindingKeys.STATIC_ASSET_OPTIONS]: Binding.bind<TStaticAssetComponentOptions>({\n key: StaticAssetBindingKeys.STATIC_ASSET_OPTIONS,\n }).toValue({}),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n // Direct options win. The key is the path for an application that registers this component\n // through `configs.artifacts`, where an index carries classes and no options.\n const componentOptions =\n this.options ??\n this.application.get<TStaticAssetComponentOptions<Schema>>({\n key: StaticAssetBindingKeys.STATIC_ASSET_OPTIONS,\n });\n\n for (const [key, entry] of Object.entries(componentOptions)) {\n const resolved = StaticAssetEntryUtility.resolve({ key, entry });\n const services = this.bindDirectUploadServices({ key, resolved });\n\n this.application.controller(\n StaticAssetControllerFactory.build<Schema>({ key, entry, ...services }),\n );\n\n this.application.logger.info(\n `[binding] Asset storage is bound | Key: %s | Mount: %s | Storage type: %s | Direct upload: %s | MetaLink: %s`,\n key,\n resolved.basePath,\n resolved.storage,\n resolved.directUpload !== undefined,\n resolved.metaLink !== undefined,\n );\n }\n }\n\n /** One pair of services per entry that turns direct upload on. The routes run the very objects an application's service resolves from the keys. */\n private bindDirectUploadServices(opts: {\n key: string;\n resolved: IStaticAssetResolvedEntry<Schema>;\n }) {\n const { key, resolved } = opts;\n const services = StaticAssetEntryUtility.buildDirectUploadServices({ resolved });\n\n if (!services) {\n return undefined;\n }\n\n this.application\n .bind({ key: StaticAssetBindingKeys.policyService({ name: key }) })\n .toValue(services.policyService);\n this.application\n .bind({ key: StaticAssetBindingKeys.commitService({ name: key }) })\n .toValue(services.commitService);\n\n return services;\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/static-asset/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAA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hC","sourcesContent":["import { type BaseApplication } 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 { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { StaticAssetBindingKeys, type TStaticAssetComponentOptions } from './common';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from './models';\nimport { StaticAssetControllerFactory } from './controller';\nimport { StaticAssetEntryUtility, type IStaticAssetResolvedEntry } from './utilities/entry.utility';\n\n/** `Schema` is the MetaLink table the application binds. It has to live on the CLASS, not only on the options: `component(Ctor, { options })` infers the options from the class, so a class pinned to the shipped table can only carry options for that table. */\nexport class StaticAssetComponent<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> extends BaseComponent<TStaticAssetComponentOptions<Schema>> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: StaticAssetComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [StaticAssetBindingKeys.STATIC_ASSET_OPTIONS]: Binding.bind({\n key: StaticAssetBindingKeys.STATIC_ASSET_OPTIONS,\n }).toValue({}),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n // Direct options win. The key is the path for an application that registers this component\n // through `configs.artifacts`, where an index carries classes and no options.\n const componentOptions =\n this.options ??\n // The key is typed with the widest schema; this component is generic over its own, so it names it.\n this.application.get<TStaticAssetComponentOptions<Schema>>({\n key: StaticAssetBindingKeys.STATIC_ASSET_OPTIONS,\n });\n\n for (const [key, entry] of Object.entries(componentOptions)) {\n const resolved = StaticAssetEntryUtility.resolve({ key, entry });\n const services = this.bindDirectUploadServices({ key, resolved });\n\n this.application.controller(\n StaticAssetControllerFactory.build<Schema>({ key, entry, ...services }),\n );\n\n this.application.logger.info(\n `[binding] Asset storage is bound | Key: %s | Mount: %s | Storage type: %s | Direct upload: %s | MetaLink: %s`,\n key,\n resolved.basePath,\n resolved.storage,\n resolved.directUpload !== undefined,\n resolved.metaLink !== undefined,\n );\n }\n }\n\n /** One pair of services per entry that turns direct upload on. The routes run the very objects an application's service resolves from the keys. */\n private bindDirectUploadServices(opts: {\n key: string;\n resolved: IStaticAssetResolvedEntry<Schema>;\n }) {\n const { key, resolved } = opts;\n const services = StaticAssetEntryUtility.buildDirectUploadServices({ resolved });\n\n if (!services) {\n return undefined;\n }\n\n this.application\n .bind({ key: StaticAssetBindingKeys.policyService({ name: key }) })\n .toValue(services.policyService);\n this.application\n .bind({ key: StaticAssetBindingKeys.commitService<Schema>({ name: key }) })\n .toValue(services.commitService);\n\n return services;\n }\n}\n"]}
@@ -50,9 +50,9 @@ export declare class StaticAssetIngestUtility {
50
50
  * Fetches an untrusted url and stores what comes back, without the bytes passing through this
51
51
  * process: the guarded body is capped and handed to `writeStream` as a stream.
52
52
  *
53
- * The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address
54
- * checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the
55
- * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.
53
+ * The url is fetched by a `NativeFetcher` with a `guard` - scheme allow-list, every resolved address
54
+ * checked, redirects walked by hand with a per-hop re-check, a timeout and a size cap. The connection goes to the
55
+ * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlGuard`.
56
56
  *
57
57
  * The served content type is decided from the stored KEY, never from what the remote host
58
58
  * claimed - the same rule the asset routes apply, and for the same reason.
@@ -1,5 +1,6 @@
1
+ import { HTTP } from '@venizia/ignis-helpers/common';
1
2
  import { getError } from '@venizia/ignis-helpers/core';
2
- import { UrlIngest, UrlSafetyDefaults, UrlSafetyErrors, } from '@venizia/ignis-helpers';
3
+ import { NativeFetcher, UrlGuard, UrlSafetyDefaults, } from '@venizia/ignis-helpers';
3
4
  const readKeyFromUrl = (opts) => {
4
5
  const { url, folderPath } = opts;
5
6
  const lastSegment = url.pathname.split('/').filter(Boolean).pop() ?? 'object';
@@ -12,17 +13,23 @@ export class StaticAssetIngestUtility {
12
13
  * Fetches an untrusted url and stores what comes back, without the bytes passing through this
13
14
  * process: the guarded body is capped and handed to `writeStream` as a stream.
14
15
  *
15
- * The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address
16
- * checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the
17
- * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.
16
+ * The url is fetched by a `NativeFetcher` with a `guard` - scheme allow-list, every resolved address
17
+ * checked, redirects walked by hand with a per-hop re-check, a timeout and a size cap. The connection goes to the
18
+ * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlGuard`.
18
19
  *
19
20
  * The served content type is decided from the stored KEY, never from what the remote host
20
21
  * claimed - the same rule the asset routes apply, and for the same reason.
21
22
  */
22
23
  static async fromUrl(opts) {
23
24
  const { helper, url, bucket, folderPath, policy, resolveKey, normalizeLinkFn } = opts;
24
- const response = await UrlIngest.fetchGuarded({ url, policy });
25
- const remoteType = response.headers.get('content-type')?.split(';')[0]?.trim() ?? '';
25
+ const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;
26
+ const fetcher = new NativeFetcher({
27
+ name: StaticAssetIngestUtility.name,
28
+ guardEngine: UrlGuard,
29
+ });
30
+ // The fetcher refuses a declared size over the cap before anything is read, and hands back a body that fails the moment the bytes cross it.
31
+ const response = await fetcher.get({ url, guard: policy ?? {}, maxBytes });
32
+ const remoteType = response.headers.get(HTTP.Headers.CONTENT_TYPE)?.split(';')[0]?.trim() ?? '';
26
33
  const parsed = new URL(url);
27
34
  const key = resolveKey
28
35
  ? resolveKey({ url: parsed, contentType: remoteType })
@@ -35,17 +42,6 @@ export class StaticAssetIngestUtility {
35
42
  message: `[StaticAssetIngestUtility.fromUrl] Invalid object key | key: ${key}`,
36
43
  });
37
44
  }
38
- // Refused before the write starts, so a declared size never opens a multipart upload. A body
39
- // that lies or omits it is caught by `capStream`; Bun's client aborts the upload, leaving no parts.
40
- const declaredLength = Number(response.headers.get('content-length') ?? 0);
41
- const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;
42
- if (declaredLength > maxBytes) {
43
- await response.body?.cancel();
44
- throw getError({
45
- error: UrlSafetyErrors.URL_REFUSED,
46
- message: `[StaticAssetIngestUtility.fromUrl] Body exceeds the cap | declared: ${declaredLength} | max: ${maxBytes}`,
47
- });
48
- }
49
45
  if (!response.body) {
50
46
  throw getError({
51
47
  message: `[StaticAssetIngestUtility.fromUrl] Response carried no body | url: ${url}`,
@@ -56,7 +52,7 @@ export class StaticAssetIngestUtility {
56
52
  await helper.writeStream({
57
53
  bucket,
58
54
  object,
59
- source: UrlIngest.capStream({ source: response.body, policy }),
55
+ source: response.body,
60
56
  contentType,
61
57
  maxFolderDepth: opts.maxFolderDepth,
62
58
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ingest.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/ingest.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,GAOhB,MAAM,wBAAwB,CAAC;AA+ChC,MAAM,cAAc,GAAG,CAAC,IAAuC,EAAU,EAAE;IACzE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;IAC9E,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEhE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC,CA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,CAAC,IAAI,EAAE;gBAC7B,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBAC7C,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport {\n UrlIngest,\n UrlSafetyDefaults,\n UrlSafetyErrors,\n type IBucketRef,\n type IObjectRef,\n type IFileStat,\n type IStorageHelper,\n type IUploadResult,\n type IUrlSafetyPolicy,\n} from '@venizia/ignis-helpers';\n\n/**\n * What was stored, and what the backend reports about it. The stat is returned because `getStat`\n * already ran to size the result - a caller writing its own row would otherwise pay for it twice.\n *\n * This does NOT write a meta link. The columns an application attaches to an object - a principal,\n * a variant - come from its own domain, not from the object, so the row stays the caller's.\n */\nexport interface IStaticAssetIngestFromUrlResult {\n upload: IUploadResult;\n stat: IFileStat;\n}\n\n/** Where a fetched object lands, and what it is attached to. */\nexport interface IStaticAssetIngestFromUrlOptions {\n helper: IStorageHelper;\n url: string;\n bucket: IBucketRef;\n\n /**\n * Decides the stored key.\n *\n * **Absent, the key comes from the remote url's last path segment - which on an untrusted url is\n * named by whoever supplied it.** Pass `resolveKey` whenever the url is not your own; the\n * validation below bounds what it can do, but it does not make the remote name yours.\n */\n resolveKey?: (opts: { url: URL; contentType: string }) => string;\n folderPath?: string;\n\n /** Absent leaves IGNIS's own default: https only, no private address, 3 hops, 10s, 10 MB. */\n policy?: IUrlSafetyPolicy;\n\n /**\n * Folder nesting the key may carry.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * Where the object is served from. **Required**: an absent hook used to yield an empty link, which\n * is exactly the value that satisfies a NOT NULL column and points nowhere.\n */\n normalizeLinkFn: (opts: { bucket: IBucketRef; object: IObjectRef }) => string;\n}\n\nconst readKeyFromUrl = (opts: { url: URL; folderPath?: string }): string => {\n const { url, folderPath } = opts;\n const lastSegment = url.pathname.split('/').filter(Boolean).pop() ?? 'object';\n const normalized = lastSegment.toLowerCase().replace(/ /g, '_');\n\n return folderPath ? `${folderPath}/${normalized}` : normalized;\n};\n\n/** Storing an object that came from somewhere else. */\nexport class StaticAssetIngestUtility {\n /**\n * Fetches an untrusted url and stores what comes back, without the bytes passing through this\n * process: the guarded body is capped and handed to `writeStream` as a stream.\n *\n * The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address\n * checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the\n * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.\n *\n * The served content type is decided from the stored KEY, never from what the remote host\n * claimed - the same rule the asset routes apply, and for the same reason.\n */\n static async fromUrl(\n opts: IStaticAssetIngestFromUrlOptions,\n ): Promise<IStaticAssetIngestFromUrlResult> {\n const { helper, url, bucket, folderPath, policy, resolveKey, normalizeLinkFn } = opts;\n\n const response = await UrlIngest.fetchGuarded({ url, policy });\n const remoteType = response.headers.get('content-type')?.split(';')[0]?.trim() ?? '';\n const parsed = new URL(url);\n\n const key = resolveKey\n ? resolveKey({ url: parsed, contentType: remoteType })\n : readKeyFromUrl({ url: parsed, folderPath });\n\n // The helper's own default, not an unbounded one: an object arriving through ingest must obey\n // the same depth rule as one arriving through the upload route.\n if (!helper.isValidObjectKey({ object: { key }, maxDepth: opts.maxFolderDepth })) {\n await response.body?.cancel();\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] Invalid object key | key: ${key}`,\n });\n }\n\n // Refused before the write starts, so a declared size never opens a multipart upload. A body\n // that lies or omits it is caught by `capStream`; Bun's client aborts the upload, leaving no parts.\n const declaredLength = Number(response.headers.get('content-length') ?? 0);\n const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;\n\n if (declaredLength > maxBytes) {\n await response.body?.cancel();\n throw getError({\n error: UrlSafetyErrors.URL_REFUSED,\n message: `[StaticAssetIngestUtility.fromUrl] Body exceeds the cap | declared: ${declaredLength} | max: ${maxBytes}`,\n });\n }\n\n if (!response.body) {\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] Response carried no body | url: ${url}`,\n });\n }\n\n const object: IObjectRef = { key };\n const contentType = helper.getMimeType({ filename: key });\n\n await helper.writeStream({\n bucket,\n object,\n source: UrlIngest.capStream({ source: response.body, policy }),\n contentType,\n maxFolderDepth: opts.maxFolderDepth,\n });\n\n const stat = await helper.getStat({ bucket, object });\n const link = normalizeLinkFn({ bucket, object });\n\n if (!link) {\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] normalizeLinkFn returned an empty link | key: ${key}`,\n });\n }\n\n return {\n upload: {\n bucket: { name: bucket.name },\n object: { key, size: stat.size, contentType },\n link,\n },\n stat,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"ingest.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/ingest.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,iBAAiB,GAOlB,MAAM,wBAAwB,CAAC;AA+ChC,MAAM,cAAc,GAAG,CAAC,IAAuC,EAAU,EAAE;IACzE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;IAC9E,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEhE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AACjE,CAAC,CAAC;AAEF,uDAAuD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AAM,EAAE,CAAC;YAC9B,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,gEAAgE,GAAG,EAAE;aAC/E,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,sEAAsE,GAAG,EAAE;aACrF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAe,EAAE,GAAG,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;QAE1D,MAAM,MAAM,CAAC,WAAW,CAAC;YACvB,MAAM;YACN,MAAM;YACN,MAAM,EAAE,QAAQ,CAAC,IAAI;YACrB,WAAW;YACX,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oFAAoF,GAAG,EAAE;aACnG,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;gBAC7B,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBAC7C,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n NativeFetcher,\n UrlGuard,\n UrlSafetyDefaults,\n type IBucketRef,\n type IObjectRef,\n type IFileStat,\n type IStorageHelper,\n type IUploadResult,\n type IUrlSafetyPolicy,\n} from '@venizia/ignis-helpers';\n\n/**\n * What was stored, and what the backend reports about it. The stat is returned because `getStat`\n * already ran to size the result - a caller writing its own row would otherwise pay for it twice.\n *\n * This does NOT write a meta link. The columns an application attaches to an object - a principal,\n * a variant - come from its own domain, not from the object, so the row stays the caller's.\n */\nexport interface IStaticAssetIngestFromUrlResult {\n upload: IUploadResult;\n stat: IFileStat;\n}\n\n/** Where a fetched object lands, and what it is attached to. */\nexport interface IStaticAssetIngestFromUrlOptions {\n helper: IStorageHelper;\n url: string;\n bucket: IBucketRef;\n\n /**\n * Decides the stored key.\n *\n * **Absent, the key comes from the remote url's last path segment - which on an untrusted url is\n * named by whoever supplied it.** Pass `resolveKey` whenever the url is not your own; the\n * validation below bounds what it can do, but it does not make the remote name yours.\n */\n resolveKey?: (opts: { url: URL; contentType: string }) => string;\n folderPath?: string;\n\n /** Absent leaves IGNIS's own default: https only, no private address, 3 hops, 10s, 10 MB. */\n policy?: IUrlSafetyPolicy;\n\n /**\n * Folder nesting the key may carry.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * Where the object is served from. **Required**: an absent hook used to yield an empty link, which\n * is exactly the value that satisfies a NOT NULL column and points nowhere.\n */\n normalizeLinkFn: (opts: { bucket: IBucketRef; object: IObjectRef }) => string;\n}\n\nconst readKeyFromUrl = (opts: { url: URL; folderPath?: string }): string => {\n const { url, folderPath } = opts;\n const lastSegment = url.pathname.split('/').filter(Boolean).pop() ?? 'object';\n const normalized = lastSegment.toLowerCase().replace(/ /g, '_');\n\n return folderPath ? `${folderPath}/${normalized}` : normalized;\n};\n\n/** Storing an object that came from somewhere else. */\nexport class StaticAssetIngestUtility {\n /**\n * Fetches an untrusted url and stores what comes back, without the bytes passing through this\n * process: the guarded body is capped and handed to `writeStream` as a stream.\n *\n * The url is fetched by a `NativeFetcher` with a `guard` - scheme allow-list, every resolved address\n * checked, redirects walked by hand with a per-hop re-check, a timeout and a size cap. The connection goes to the\n * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlGuard`.\n *\n * The served content type is decided from the stored KEY, never from what the remote host\n * claimed - the same rule the asset routes apply, and for the same reason.\n */\n static async fromUrl(\n opts: IStaticAssetIngestFromUrlOptions,\n ): Promise<IStaticAssetIngestFromUrlResult> {\n const { helper, url, bucket, folderPath, policy, resolveKey, normalizeLinkFn } = opts;\n\n const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;\n const fetcher = new NativeFetcher({\n name: StaticAssetIngestUtility.name,\n guardEngine: UrlGuard,\n });\n // The fetcher refuses a declared size over the cap before anything is read, and hands back a body that fails the moment the bytes cross it.\n const response = await fetcher.get({ url, guard: policy ?? {}, maxBytes });\n const remoteType = response.headers.get(HTTP.Headers.CONTENT_TYPE)?.split(';')[0]?.trim() ?? '';\n const parsed = new URL(url);\n\n const key = resolveKey\n ? resolveKey({ url: parsed, contentType: remoteType })\n : readKeyFromUrl({ url: parsed, folderPath });\n\n // The helper's own default, not an unbounded one: an object arriving through ingest must obey\n // the same depth rule as one arriving through the upload route.\n if (!helper.isValidObjectKey({ object: { key }, maxDepth: opts.maxFolderDepth })) {\n await response.body?.cancel();\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] Invalid object key | key: ${key}`,\n });\n }\n\n if (!response.body) {\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] Response carried no body | url: ${url}`,\n });\n }\n\n const object: IObjectRef = { key };\n const contentType = helper.getMimeType({ filename: key });\n\n await helper.writeStream({\n bucket,\n object,\n source: response.body,\n contentType,\n maxFolderDepth: opts.maxFolderDepth,\n });\n\n const stat = await helper.getStat({ bucket, object });\n const link = normalizeLinkFn({ bucket, object });\n\n if (!link) {\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] normalizeLinkFn returned an empty link | key: ${key}`,\n });\n }\n\n return {\n upload: {\n bucket: { name: bucket.name },\n object: { key, size: stat.size, contentType },\n link,\n },\n stat,\n };\n }\n}\n"]}
@@ -1,14 +1,16 @@
1
+ import type { AbstractRedisHelper, TWebSocketAuthenticateFn, TWebSocketClientConnectedFn, TWebSocketClientDisconnectedFn, TWebSocketHandshakeFn, TWebSocketMessageHandler, TWebSocketOutboundTransformer, TWebSocketValidateRoomFn, WebSocketServerHelper } from '@venizia/ignis-helpers';
2
+ import type { IServerOptions } from './types.js';
1
3
  /** Container keys of the WebSocket component: the server instance, its options, the Redis connection and the handlers an application binds. */
2
4
  export declare class WebSocketBindingKeys {
3
- static readonly WEBSOCKET_INSTANCE = "@app/websocket/instance";
4
- static readonly SERVER_OPTIONS = "@app/websocket/server-options";
5
- static readonly REDIS_CONNECTION = "@app/websocket/redis-connection";
6
- static readonly AUTHENTICATE_HANDLER = "@app/websocket/authenticate-handler";
7
- static readonly VALIDATE_ROOM_HANDLER = "@app/websocket/validate-room-handler";
8
- static readonly CLIENT_CONNECTED_HANDLER = "@app/websocket/client-connected-handler";
9
- static readonly CLIENT_DISCONNECTED_HANDLER = "@app/websocket/client-disconnected-handler";
10
- static readonly MESSAGE_HANDLER = "@app/websocket/message-handler";
11
- static readonly OUTBOUND_TRANSFORMER = "@app/websocket/outbound-transformer";
12
- static readonly HANDSHAKE_HANDLER = "@app/websocket/handshake-handler";
5
+ static readonly WEBSOCKET_INSTANCE: import("@venizia/ignis-inversion").TBindingKey<WebSocketServerHelper<Record<string, unknown>, Record<string, unknown>>>;
6
+ static readonly SERVER_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<Partial<IServerOptions>>;
7
+ static readonly REDIS_CONNECTION: import("@venizia/ignis-inversion").TBindingKey<AbstractRedisHelper<import("@venizia/ignis-helpers").TRedisClient> | null>;
8
+ static readonly AUTHENTICATE_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketAuthenticateFn | null>;
9
+ static readonly VALIDATE_ROOM_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketValidateRoomFn | null>;
10
+ static readonly CLIENT_CONNECTED_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketClientConnectedFn | null>;
11
+ static readonly CLIENT_DISCONNECTED_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketClientDisconnectedFn | null>;
12
+ static readonly MESSAGE_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketMessageHandler | null>;
13
+ static readonly OUTBOUND_TRANSFORMER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketOutboundTransformer | null>;
14
+ static readonly HANDSHAKE_HANDLER: import("@venizia/ignis-inversion").TBindingKey<TWebSocketHandshakeFn | null>;
13
15
  }
14
16
  //# sourceMappingURL=keys.d.ts.map