@venizia/ignis 0.4.8-8 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +6 -3
- package/dist/esm/components/api-reference/common/types.js.map +1 -1
- package/dist/esm/components/api-reference/component.js +8 -3
- package/dist/esm/components/api-reference/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.js +3 -2
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +3 -3
- package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +5 -3
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +18 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +1 -2
- package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/mail/common/constants.d.ts +24 -14
- package/dist/esm/components/mail/common/constants.js +19 -32
- package/dist/esm/components/mail/common/constants.js.map +1 -1
- package/dist/esm/components/mail/common/errors.d.ts +10 -1
- package/dist/esm/components/mail/common/errors.js +7 -1
- package/dist/esm/components/mail/common/errors.js.map +1 -1
- package/dist/esm/components/mail/common/types/message.d.ts +4 -4
- package/dist/esm/components/mail/common/types/message.js.map +1 -1
- package/dist/esm/components/mail/common/types/options.d.ts +54 -10
- package/dist/esm/components/mail/common/types/options.js.map +1 -1
- package/dist/esm/components/mail/common/types/queue.d.ts +23 -12
- package/dist/esm/components/mail/common/types/queue.js.map +1 -1
- package/dist/esm/components/mail/common/types/template.d.ts +5 -4
- package/dist/esm/components/mail/common/types/template.js.map +1 -1
- package/dist/esm/components/mail/common/types/verification.d.ts +1 -0
- package/dist/esm/components/mail/common/types/verification.js.map +1 -1
- package/dist/esm/components/mail/component.js +11 -2
- package/dist/esm/components/mail/component.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +15 -28
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +2 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +17 -10
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +11 -6
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +2 -3
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +15 -6
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +2 -3
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +2 -2
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -2
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +7 -9
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-transporter.provider.js +7 -7
- package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
- package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -6
- package/dist/esm/components/mail/services/generators/numeric-code.js +3 -31
- package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
- package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -1
- package/dist/esm/components/mail/services/generators/random-token.js +9 -6
- package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.d.ts +1 -2
- package/dist/esm/components/mail/services/mail.service.js +21 -19
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +7 -5
- package/dist/esm/components/mail/services/template.service.js +24 -16
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/attachment.utility.js +8 -6
- package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/header.utility.d.ts +14 -0
- package/dist/esm/components/mail/utilities/header.utility.js +44 -0
- package/dist/esm/components/mail/utilities/header.utility.js.map +1 -0
- package/dist/esm/components/mail/utilities/index.d.ts +1 -0
- package/dist/esm/components/mail/utilities/index.js +1 -0
- package/dist/esm/components/mail/utilities/index.js.map +1 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts +5 -1
- package/dist/esm/components/mail/utilities/mime.utility.js +12 -58
- package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/type.utility.d.ts +2 -3
- package/dist/esm/components/mail/utilities/type.utility.js +6 -7
- package/dist/esm/components/mail/utilities/type.utility.js.map +1 -1
- package/dist/esm/components/server-info/common/constants.d.ts +6 -0
- package/dist/esm/components/server-info/common/constants.js +6 -0
- package/dist/esm/components/server-info/common/constants.js.map +1 -0
- package/dist/esm/components/server-info/common/index.d.ts +5 -0
- package/dist/esm/components/server-info/common/index.js +5 -0
- package/dist/esm/components/server-info/common/index.js.map +1 -0
- package/dist/esm/components/server-info/common/keys.d.ts +5 -0
- package/dist/esm/components/server-info/common/keys.js +5 -0
- package/dist/esm/components/server-info/common/keys.js.map +1 -0
- package/dist/esm/components/server-info/common/rest-paths.d.ts +5 -0
- package/dist/esm/components/server-info/common/rest-paths.js +5 -0
- package/dist/esm/components/server-info/common/rest-paths.js.map +1 -0
- package/dist/esm/components/server-info/common/types.d.ts +68 -0
- package/dist/esm/components/server-info/common/types.js +2 -0
- package/dist/esm/components/server-info/common/types.js.map +1 -0
- package/dist/esm/components/server-info/component.d.ts +31 -0
- package/dist/esm/components/server-info/component.js +87 -0
- package/dist/esm/components/server-info/component.js.map +1 -0
- package/dist/esm/components/server-info/controller.d.ts +14 -0
- package/dist/esm/components/server-info/controller.js +68 -0
- package/dist/esm/components/server-info/controller.js.map +1 -0
- package/dist/esm/components/server-info/index.d.ts +5 -0
- package/dist/esm/components/server-info/index.js +5 -0
- package/dist/esm/components/server-info/index.js.map +1 -0
- package/dist/esm/components/server-info/reporter.d.ts +25 -0
- package/dist/esm/components/server-info/reporter.js +68 -0
- package/dist/esm/components/server-info/reporter.js.map +1 -0
- package/dist/esm/components/socket-io/handlers/bun.handler.d.ts +13 -3
- package/dist/esm/components/socket-io/handlers/bun.handler.js.map +1 -1
- package/dist/esm/components/static-asset/common/constants.d.ts +51 -24
- package/dist/esm/components/static-asset/common/constants.js +75 -47
- package/dist/esm/components/static-asset/common/constants.js.map +1 -1
- package/dist/esm/components/static-asset/common/errors.d.ts +30 -35
- package/dist/esm/components/static-asset/common/errors.js +31 -33
- package/dist/esm/components/static-asset/common/errors.js.map +1 -1
- package/dist/esm/components/static-asset/common/index.d.ts +1 -1
- package/dist/esm/components/static-asset/common/index.js +1 -1
- package/dist/esm/components/static-asset/common/index.js.map +1 -1
- package/dist/esm/components/static-asset/common/keys.d.ts +10 -2
- package/dist/esm/components/static-asset/common/keys.js +10 -2
- package/dist/esm/components/static-asset/common/keys.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +267 -147
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/common/validation.d.ts +10 -0
- package/dist/esm/components/static-asset/common/validation.js +8 -0
- package/dist/esm/components/static-asset/common/validation.js.map +1 -0
- package/dist/esm/components/static-asset/component.d.ts +4 -2
- package/dist/esm/components/static-asset/component.js +26 -31
- package/dist/esm/components/static-asset/component.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +37 -79
- package/dist/esm/components/static-asset/controller/factory.js +26 -917
- package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
- package/dist/esm/components/static-asset/controller/index.d.ts +1 -0
- package/dist/esm/components/static-asset/controller/index.js +1 -0
- package/dist/esm/components/static-asset/controller/index.js.map +1 -1
- package/dist/esm/components/static-asset/controller/routes/context.d.ts +62 -0
- package/dist/esm/components/static-asset/controller/routes/context.js +45 -0
- package/dist/esm/components/static-asset/controller/routes/context.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/definition.d.ts +40 -0
- package/dist/esm/components/static-asset/controller/routes/definition.js +83 -0
- package/dist/esm/components/static-asset/controller/routes/definition.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/direct-upload.d.ts +3 -0
- package/dist/esm/components/static-asset/controller/routes/direct-upload.js +153 -0
- package/dist/esm/components/static-asset/controller/routes/direct-upload.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/labels.d.ts +16 -0
- package/dist/esm/components/static-asset/controller/routes/labels.js +19 -0
- package/dist/esm/components/static-asset/controller/routes/labels.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/objects.d.ts +7 -0
- package/dist/esm/components/static-asset/controller/routes/objects.js +193 -0
- package/dist/esm/components/static-asset/controller/routes/objects.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/serve.d.ts +29 -0
- package/dist/esm/components/static-asset/controller/routes/serve.js +152 -0
- package/dist/esm/components/static-asset/controller/routes/serve.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/table.d.ts +12 -0
- package/dist/esm/components/static-asset/controller/routes/table.js +52 -0
- package/dist/esm/components/static-asset/controller/routes/table.js.map +1 -0
- package/dist/esm/components/static-asset/controller/routes/upload.d.ts +10 -0
- package/dist/esm/components/static-asset/controller/routes/upload.js +175 -0
- package/dist/esm/components/static-asset/controller/routes/upload.js.map +1 -0
- package/dist/esm/components/static-asset/index.d.ts +2 -1
- package/dist/esm/components/static-asset/index.js +2 -1
- package/dist/esm/components/static-asset/index.js.map +1 -1
- package/dist/esm/components/static-asset/models/base.model.d.ts +4 -4
- package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
- package/dist/esm/components/static-asset/services/commitment.service.d.ts +103 -0
- package/dist/esm/components/static-asset/services/commitment.service.js +252 -0
- package/dist/esm/components/static-asset/services/commitment.service.js.map +1 -0
- package/dist/esm/components/static-asset/services/index.d.ts +3 -0
- package/dist/esm/components/static-asset/services/index.js +3 -0
- package/dist/esm/components/static-asset/services/index.js.map +1 -0
- package/dist/esm/components/static-asset/services/policy.service.d.ts +45 -0
- package/dist/esm/components/static-asset/services/policy.service.js +104 -0
- package/dist/esm/components/static-asset/services/policy.service.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/commit-token.utility.d.ts +28 -0
- package/dist/esm/components/static-asset/utilities/commit-token.utility.js +112 -0
- package/dist/esm/components/static-asset/utilities/commit-token.utility.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/entry.utility.d.ts +69 -0
- package/dist/esm/components/static-asset/utilities/entry.utility.js +160 -0
- package/dist/esm/components/static-asset/utilities/entry.utility.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/index.d.ts +6 -0
- package/dist/esm/components/static-asset/utilities/index.js +6 -0
- package/dist/esm/components/static-asset/utilities/index.js.map +1 -0
- package/dist/esm/components/static-asset/{ingest.d.ts → utilities/ingest.utility.d.ts} +5 -5
- package/dist/esm/components/static-asset/{ingest.js → utilities/ingest.utility.js} +12 -10
- package/dist/esm/components/static-asset/utilities/ingest.utility.js.map +1 -0
- package/dist/esm/components/static-asset/{controller/key-scope.d.ts → utilities/key-scope.utility.d.ts} +21 -2
- package/dist/esm/components/static-asset/utilities/key-scope.utility.js +74 -0
- package/dist/esm/components/static-asset/utilities/key-scope.utility.js.map +1 -0
- package/dist/esm/components/static-asset/{controller/meta-link.d.ts → utilities/meta-link.utility.d.ts} +9 -9
- package/dist/esm/components/static-asset/{controller/meta-link.js → utilities/meta-link.utility.js} +10 -10
- package/dist/esm/components/static-asset/utilities/meta-link.utility.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/object-link.utility.d.ts +16 -0
- package/dist/esm/components/static-asset/utilities/object-link.utility.js +20 -0
- package/dist/esm/components/static-asset/utilities/object-link.utility.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/pinned-file.utility.d.ts +39 -0
- package/dist/esm/components/static-asset/utilities/pinned-file.utility.js +53 -0
- package/dist/esm/components/static-asset/utilities/pinned-file.utility.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/route-options.utility.d.ts +43 -0
- package/dist/esm/components/static-asset/utilities/route-options.utility.js +71 -0
- package/dist/esm/components/static-asset/utilities/route-options.utility.js.map +1 -0
- package/dist/esm/components/static-asset/utilities/toggle.utility.d.ts +5 -0
- package/dist/esm/components/static-asset/utilities/toggle.utility.js +5 -0
- package/dist/esm/components/static-asset/utilities/toggle.utility.js.map +1 -0
- package/dist/esm/testing/assert-application-boots.d.ts +2 -2
- package/dist/esm/testing/assert-application-boots.js +6 -2
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +8 -8
- package/dist/esm/components/static-asset/common/commit-token.d.ts +0 -28
- package/dist/esm/components/static-asset/common/commit-token.js +0 -48
- package/dist/esm/components/static-asset/common/commit-token.js.map +0 -1
- package/dist/esm/components/static-asset/controller/base.definition.d.ts +0 -30
- package/dist/esm/components/static-asset/controller/base.definition.js +0 -307
- package/dist/esm/components/static-asset/controller/base.definition.js.map +0 -1
- package/dist/esm/components/static-asset/controller/key-scope.js +0 -41
- package/dist/esm/components/static-asset/controller/key-scope.js.map +0 -1
- package/dist/esm/components/static-asset/controller/meta-link.js.map +0 -1
- package/dist/esm/components/static-asset/controller/route-options.d.ts +0 -29
- package/dist/esm/components/static-asset/controller/route-options.js +0 -47
- package/dist/esm/components/static-asset/controller/route-options.js.map +0 -1
- package/dist/esm/components/static-asset/ingest.js.map +0 -1
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/rest-paths.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,OAAO,mBAAmB;aACd,SAAI,GAAG,OAAO,CAAC","sourcesContent":["/** Routes of the server info controller, relative to the configured base path. */\nexport class ServerInfoRestPaths {\n static readonly TIME = '/time';\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';
|
|
7
|
+
*
|
|
8
|
+
* export const bindServerInfo = (application: BaseApplication) => {
|
|
9
|
+
* application
|
|
10
|
+
* .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
|
|
11
|
+
* .toValue({ restOptions: { path: '/clock' } });
|
|
12
|
+
* };
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface IServerInfoOptions {
|
|
16
|
+
/** Partially-filled bindings are accepted; every missing field falls back to its default. */
|
|
17
|
+
restOptions?: {
|
|
18
|
+
/**
|
|
19
|
+
* Base path the server info routes mount under. The routes are public by design.
|
|
20
|
+
*
|
|
21
|
+
* @default '/server/info'
|
|
22
|
+
*/
|
|
23
|
+
path?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```json
|
|
31
|
+
* {
|
|
32
|
+
* "server": {
|
|
33
|
+
* "date": "2026-11-10",
|
|
34
|
+
* "time": "15:00:00.123",
|
|
35
|
+
* "epoch": 1794297600123,
|
|
36
|
+
* "iso": "2026-11-10T15:00:00.123+07:00"
|
|
37
|
+
* },
|
|
38
|
+
* "tz": "Asia/Ho_Chi_Minh",
|
|
39
|
+
* "utc": { "offset": "+07:00", "minutes": 420, "iso": "2026-11-10T08:00:00.123Z" }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export interface IServerTime {
|
|
44
|
+
server: {
|
|
45
|
+
/** Calendar date in the server time zone, `YYYY-MM-DD`. */
|
|
46
|
+
date: string;
|
|
47
|
+
/** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */
|
|
48
|
+
time: string;
|
|
49
|
+
/** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */
|
|
50
|
+
epoch: number;
|
|
51
|
+
/** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */
|
|
52
|
+
iso: string;
|
|
53
|
+
};
|
|
54
|
+
/** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */
|
|
55
|
+
tz: string;
|
|
56
|
+
utc: {
|
|
57
|
+
/** Offset of `tz` from UTC at response time, `+07:00` style. */
|
|
58
|
+
offset: string;
|
|
59
|
+
/**
|
|
60
|
+
* The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite
|
|
61
|
+
* sign of JavaScript's `Date.prototype.getTimezoneOffset()`.
|
|
62
|
+
*/
|
|
63
|
+
minutes: number;
|
|
64
|
+
/** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */
|
|
65
|
+
iso: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BaseApplication } from '../../base/applications/index.js';
|
|
2
|
+
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
3
|
+
import { type IServerInfoOptions } from './common/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mounts the server info controller: `GET <path>/time`, public, no authentication.
|
|
6
|
+
*
|
|
7
|
+
* The rule of this component: it carries only data that is safe to publish and does not help an
|
|
8
|
+
* attacker. No version, runtime, pid, memory or environment - those stay in the gated
|
|
9
|
+
* `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock
|
|
10
|
+
* `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';
|
|
15
|
+
*
|
|
16
|
+
* abstract class App extends BaseApplication {
|
|
17
|
+
* preConfigure(): void {
|
|
18
|
+
* const options: IServerInfoOptions = { restOptions: { path: '/clock' } };
|
|
19
|
+
* this.component(ServerInfoComponent, { options });
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class ServerInfoComponent extends BaseComponent<IServerInfoOptions> {
|
|
25
|
+
private application;
|
|
26
|
+
constructor(application: BaseApplication);
|
|
27
|
+
/** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */
|
|
28
|
+
configure(opts?: IServerInfoOptions): Promise<void>;
|
|
29
|
+
binding(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var ServerInfoComponent_1;
|
|
14
|
+
import { controller, inject } from '../../base/metadata/index.js';
|
|
15
|
+
import { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';
|
|
16
|
+
import { ServerInfoBindingKeys } from './common/index.js';
|
|
17
|
+
import { ServerInfoController } from './controller.js';
|
|
18
|
+
const DEFAULT_REST_PATH = '/server/info';
|
|
19
|
+
const DEFAULT_OPTIONS = {
|
|
20
|
+
restOptions: { path: DEFAULT_REST_PATH },
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Mounts the server info controller: `GET <path>/time`, public, no authentication.
|
|
24
|
+
*
|
|
25
|
+
* The rule of this component: it carries only data that is safe to publish and does not help an
|
|
26
|
+
* attacker. No version, runtime, pid, memory or environment - those stay in the gated
|
|
27
|
+
* `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock
|
|
28
|
+
* `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';
|
|
33
|
+
*
|
|
34
|
+
* abstract class App extends BaseApplication {
|
|
35
|
+
* preConfigure(): void {
|
|
36
|
+
* const options: IServerInfoOptions = { restOptions: { path: '/clock' } };
|
|
37
|
+
* this.component(ServerInfoComponent, { options });
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
let ServerInfoComponent = ServerInfoComponent_1 = class ServerInfoComponent extends BaseComponent {
|
|
43
|
+
constructor(application) {
|
|
44
|
+
super({
|
|
45
|
+
scope: ServerInfoComponent_1.name,
|
|
46
|
+
initDefault: { enable: true, container: application },
|
|
47
|
+
bindings: {
|
|
48
|
+
[ServerInfoBindingKeys.SERVER_INFO_OPTIONS]: Binding.bind({
|
|
49
|
+
key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,
|
|
50
|
+
}).toValue(DEFAULT_OPTIONS),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
this.application = application;
|
|
54
|
+
}
|
|
55
|
+
/** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */
|
|
56
|
+
async configure(opts) {
|
|
57
|
+
// The base short-circuits a second call; binding before that check would swap the options
|
|
58
|
+
// under routes that were already mounted from the first ones.
|
|
59
|
+
if (this.isConfigured) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (opts !== undefined) {
|
|
63
|
+
this.application
|
|
64
|
+
.bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
|
|
65
|
+
.toValue(opts);
|
|
66
|
+
}
|
|
67
|
+
await super.configure(opts);
|
|
68
|
+
}
|
|
69
|
+
binding() {
|
|
70
|
+
const options = this.application.get({
|
|
71
|
+
key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,
|
|
72
|
+
isOptional: true,
|
|
73
|
+
});
|
|
74
|
+
// A partially filled options binding (env/config driven) must not take the app down at boot.
|
|
75
|
+
const path = options?.restOptions?.path ?? DEFAULT_REST_PATH;
|
|
76
|
+
// `@controller` writes the PATH onto this shared class in the process-wide MetadataRegistry;
|
|
77
|
+
// two applications booted concurrently with different paths would race, as in health-check.
|
|
78
|
+
Reflect.decorate([controller({ path })], ServerInfoController);
|
|
79
|
+
this.application.controller(ServerInfoController);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
ServerInfoComponent = ServerInfoComponent_1 = __decorate([
|
|
83
|
+
__param(0, inject({ key: CoreBindings.APPLICATION_INSTANCE })),
|
|
84
|
+
__metadata("design:paramtypes", [Function])
|
|
85
|
+
], ServerInfoComponent);
|
|
86
|
+
export { ServerInfoComponent };
|
|
87
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +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,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,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,IAAa,mBAAmB,2BAAhC,MA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C,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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseRestController } from '../../base/controllers/index.js';
|
|
2
|
+
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
3
|
+
/**
|
|
4
|
+
* Serves `GET <path>/time`, a PUBLIC route with no authentication.
|
|
5
|
+
*
|
|
6
|
+
* Everything this controller answers must be safe to publish and must not help an attacker: a
|
|
7
|
+
* clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those
|
|
8
|
+
* belong to the gated `/health/stats`. A new route here needs that same test.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ServerInfoController extends BaseRestController {
|
|
11
|
+
constructor();
|
|
12
|
+
binding(): ValueOrPromise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BaseRestController } from '../../base/controllers/index.js';
|
|
2
|
+
import { OpenApiResponses } from '@venizia/ignis-kernel';
|
|
3
|
+
import { z } from '@hono/zod-openapi';
|
|
4
|
+
import { HTTP } from '@venizia/ignis-helpers/common';
|
|
5
|
+
import { ServerInfoCacheControls, ServerInfoRestPaths } from './common/index.js';
|
|
6
|
+
import { ServerInfoReporter } from './reporter.js';
|
|
7
|
+
const RouteConfigs = {
|
|
8
|
+
TIME: {
|
|
9
|
+
method: HTTP.Methods.GET,
|
|
10
|
+
path: ServerInfoRestPaths.TIME,
|
|
11
|
+
responses: OpenApiResponses.jsonResponse({
|
|
12
|
+
schema: z
|
|
13
|
+
.object({
|
|
14
|
+
server: z.object({
|
|
15
|
+
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
16
|
+
time: z.string().regex(/^\d{2}:\d{2}:\d{2}\.\d{3}$/),
|
|
17
|
+
epoch: z.number().int(),
|
|
18
|
+
iso: z.iso.datetime({ offset: true }),
|
|
19
|
+
}),
|
|
20
|
+
tz: z.string(),
|
|
21
|
+
utc: z.object({
|
|
22
|
+
offset: z.string().regex(/^[+-]\d{2}:\d{2}$/),
|
|
23
|
+
minutes: z.number().int(),
|
|
24
|
+
iso: z.iso.datetime(),
|
|
25
|
+
}),
|
|
26
|
+
})
|
|
27
|
+
.openapi({
|
|
28
|
+
description: 'Server time',
|
|
29
|
+
examples: [
|
|
30
|
+
{
|
|
31
|
+
server: {
|
|
32
|
+
date: '2026-11-10',
|
|
33
|
+
time: '15:00:00.123',
|
|
34
|
+
epoch: 1794297600123,
|
|
35
|
+
iso: '2026-11-10T15:00:00.123+07:00',
|
|
36
|
+
},
|
|
37
|
+
tz: 'Asia/Ho_Chi_Minh',
|
|
38
|
+
utc: { offset: '+07:00', minutes: 420, iso: '2026-11-10T08:00:00.123Z' },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
description: 'The server clock: local date and time, epoch milliseconds, time zone, UTC offset and the UTC instant',
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Serves `GET <path>/time`, a PUBLIC route with no authentication.
|
|
48
|
+
*
|
|
49
|
+
* Everything this controller answers must be safe to publish and must not help an attacker: a
|
|
50
|
+
* clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those
|
|
51
|
+
* belong to the gated `/health/stats`. A new route here needs that same test.
|
|
52
|
+
*/
|
|
53
|
+
export class ServerInfoController extends BaseRestController {
|
|
54
|
+
constructor() {
|
|
55
|
+
super({ scope: ServerInfoController.name });
|
|
56
|
+
this.definitions = RouteConfigs;
|
|
57
|
+
}
|
|
58
|
+
binding() {
|
|
59
|
+
this.bindRoute({ configs: RouteConfigs.TIME }).to({
|
|
60
|
+
handler: (context) => {
|
|
61
|
+
// A cached time is a wrong time; without this a cache or a service worker may serve it stale.
|
|
62
|
+
context.header(HTTP.Headers.CACHE_CONTROL, ServerInfoCacheControls.NO_STORE);
|
|
63
|
+
return context.json(ServerInfoReporter.buildTime(), HTTP.ResultCodes.RS_2.Ok);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/components/server-info/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE;QACJ,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;QACxB,IAAI,EAAE,mBAAmB,CAAC,IAAI;QAC9B,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC;YACvC,MAAM,EAAE,CAAC;iBACN,MAAM,CAAC;gBACN,MAAM,EAAE,CAAC,C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AC;IAEQ,OAAO;QACd,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;gBACnB,8FAA8F;gBAC9F,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CAAC;gBAE7E,OAAO,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { BaseRestController } from '@/base/controllers';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { ServerInfoCacheControls, ServerInfoRestPaths } from './common';\nimport { ServerInfoReporter } from './reporter';\n\nconst RouteConfigs = {\n TIME: {\n method: HTTP.Methods.GET,\n path: ServerInfoRestPaths.TIME,\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n server: z.object({\n date: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/),\n time: z.string().regex(/^\\d{2}:\\d{2}:\\d{2}\\.\\d{3}$/),\n epoch: z.number().int(),\n iso: z.iso.datetime({ offset: true }),\n }),\n tz: z.string(),\n utc: z.object({\n offset: z.string().regex(/^[+-]\\d{2}:\\d{2}$/),\n minutes: z.number().int(),\n iso: z.iso.datetime(),\n }),\n })\n .openapi({\n description: 'Server time',\n examples: [\n {\n server: {\n date: '2026-11-10',\n time: '15:00:00.123',\n epoch: 1794297600123,\n iso: '2026-11-10T15:00:00.123+07:00',\n },\n tz: 'Asia/Ho_Chi_Minh',\n utc: { offset: '+07:00', minutes: 420, iso: '2026-11-10T08:00:00.123Z' },\n },\n ],\n }),\n description:\n 'The server clock: local date and time, epoch milliseconds, time zone, UTC offset and the UTC instant',\n }),\n },\n} as const;\n\n/**\n * Serves `GET <path>/time`, a PUBLIC route with no authentication.\n *\n * Everything this controller answers must be safe to publish and must not help an attacker: a\n * clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those\n * belong to the gated `/health/stats`. A new route here needs that same test.\n */\nexport class ServerInfoController extends BaseRestController {\n constructor() {\n super({ scope: ServerInfoController.name });\n\n this.definitions = RouteConfigs;\n }\n\n override binding(): ValueOrPromise<void> {\n this.bindRoute({ configs: RouteConfigs.TIME }).to({\n handler: (context) => {\n // A cached time is a wrong time; without this a cache or a service worker may serve it stale.\n context.header(HTTP.Headers.CACHE_CONTROL, ServerInfoCacheControls.NO_STORE);\n\n return context.json(ServerInfoReporter.buildTime(), HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/server-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC","sourcesContent":["export * from './common';\nexport * from './component';\nexport * from './controller';\nexport * from './reporter';\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IServerTime } from './common/index.js';
|
|
2
|
+
/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */
|
|
3
|
+
export declare class ServerInfoReporter {
|
|
4
|
+
private static readonly MINUTES_PER_HOUR;
|
|
5
|
+
private static readonly MS_PER_SECOND;
|
|
6
|
+
private static readonly MS_PER_MINUTE;
|
|
7
|
+
private static readonly formatters;
|
|
8
|
+
private static getFormatter;
|
|
9
|
+
/** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */
|
|
10
|
+
static formatUtcOffset(opts: {
|
|
11
|
+
minutes: number;
|
|
12
|
+
}): string;
|
|
13
|
+
/** The process time zone as the runtime resolved it (`TZ`, or the host setting). */
|
|
14
|
+
static resolveTimeZone(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the
|
|
17
|
+
* same instant. The offset is read from the zone AT that instant (a DST change moves it), not
|
|
18
|
+
* from the zone's standard offset.
|
|
19
|
+
*/
|
|
20
|
+
static buildTime(opts?: {
|
|
21
|
+
now?: Date;
|
|
22
|
+
timeZone?: string;
|
|
23
|
+
}): IServerTime;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */
|
|
2
|
+
export class ServerInfoReporter {
|
|
3
|
+
static { this.MINUTES_PER_HOUR = 60; }
|
|
4
|
+
static { this.MS_PER_SECOND = 1000; }
|
|
5
|
+
static { this.MS_PER_MINUTE = 60_000; }
|
|
6
|
+
static { this.formatters = new Map(); }
|
|
7
|
+
static getFormatter(opts) {
|
|
8
|
+
const cached = ServerInfoReporter.formatters.get(opts.timeZone);
|
|
9
|
+
if (cached) {
|
|
10
|
+
return cached;
|
|
11
|
+
}
|
|
12
|
+
// `h23` keeps midnight as `00`; the default `h24` of some locales prints `24`.
|
|
13
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
14
|
+
timeZone: opts.timeZone,
|
|
15
|
+
hourCycle: 'h23',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
month: '2-digit',
|
|
18
|
+
day: '2-digit',
|
|
19
|
+
hour: '2-digit',
|
|
20
|
+
minute: '2-digit',
|
|
21
|
+
second: '2-digit',
|
|
22
|
+
});
|
|
23
|
+
ServerInfoReporter.formatters.set(opts.timeZone, formatter);
|
|
24
|
+
return formatter;
|
|
25
|
+
}
|
|
26
|
+
/** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */
|
|
27
|
+
static formatUtcOffset(opts) {
|
|
28
|
+
const sign = opts.minutes < 0 ? '-' : '+';
|
|
29
|
+
const absolute = Math.abs(opts.minutes);
|
|
30
|
+
const hh = String(Math.trunc(absolute / ServerInfoReporter.MINUTES_PER_HOUR)).padStart(2, '0');
|
|
31
|
+
const mm = String(absolute % ServerInfoReporter.MINUTES_PER_HOUR).padStart(2, '0');
|
|
32
|
+
return `${sign}${hh}:${mm}`;
|
|
33
|
+
}
|
|
34
|
+
/** The process time zone as the runtime resolved it (`TZ`, or the host setting). */
|
|
35
|
+
static resolveTimeZone() {
|
|
36
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the
|
|
40
|
+
* same instant. The offset is read from the zone AT that instant (a DST change moves it), not
|
|
41
|
+
* from the zone's standard offset.
|
|
42
|
+
*/
|
|
43
|
+
static buildTime(opts) {
|
|
44
|
+
const now = opts?.now ?? new Date();
|
|
45
|
+
const tz = opts?.timeZone ?? ServerInfoReporter.resolveTimeZone();
|
|
46
|
+
const epoch = now.getTime();
|
|
47
|
+
const parts = {};
|
|
48
|
+
for (const part of ServerInfoReporter.getFormatter({ timeZone: tz }).formatToParts(now)) {
|
|
49
|
+
parts[part.type] = part.value;
|
|
50
|
+
}
|
|
51
|
+
const date = `${parts.year}-${parts.month}-${parts.day}`;
|
|
52
|
+
const ms = String(((epoch % ServerInfoReporter.MS_PER_SECOND) + ServerInfoReporter.MS_PER_SECOND) %
|
|
53
|
+
ServerInfoReporter.MS_PER_SECOND).padStart(3, '0');
|
|
54
|
+
const time = `${parts.hour}:${parts.minute}:${parts.second}.${ms}`;
|
|
55
|
+
// The wall clock, read back as if it were UTC, minus the true instant (both cut to the
|
|
56
|
+
// second) is the zone's offset. Intl has no offset field that is portable across runtimes.
|
|
57
|
+
const wallAsUtc = Date.UTC(Number(parts.year), Number(parts.month) - 1, Number(parts.day), Number(parts.hour), Number(parts.minute), Number(parts.second));
|
|
58
|
+
const epochSecond = Math.floor(epoch / ServerInfoReporter.MS_PER_SECOND) * ServerInfoReporter.MS_PER_SECOND;
|
|
59
|
+
const minutes = (wallAsUtc - epochSecond) / ServerInfoReporter.MS_PER_MINUTE;
|
|
60
|
+
const offset = ServerInfoReporter.formatUtcOffset({ minutes });
|
|
61
|
+
return {
|
|
62
|
+
server: { date, time, epoch, iso: `${date}T${time}${offset}` },
|
|
63
|
+
tz,
|
|
64
|
+
utc: { offset, minutes, iso: now.toISOString() },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/server-info/reporter.ts"],"names":[],"mappings":"AAEA,yGAAyG;AACzG,MAAM,OAAO,kBAAkB;aACL,qBAAgB,GAAG,EAAE,CAAC;aACtB,kBAAa,GAAG,IAAI,CAAC;aACrB,kBAAa,GAAG,MAAM,CAAC;aAEvB,eAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEpE,MAAM,CAAC,YAAY,CAAC,IAA0B;QACpD,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhE,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,+EAA+E;QAC/E,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YACjD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,KAAK;YAChB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;QACH,kBAAkB,CAAC,UA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,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,IAAI,GAAG,MAAM,EAAE,EAAE;YAC9D,EAAE;YACF,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE;SACjD,CAAC;IACJ,CAAC","sourcesContent":["import type { IServerTime } from './common';\n\n/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */\nexport class ServerInfoReporter {\n private static readonly MINUTES_PER_HOUR = 60;\n private static readonly MS_PER_SECOND = 1000;\n private static readonly MS_PER_MINUTE = 60_000;\n\n private static readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private static getFormatter(opts: { timeZone: string }): Intl.DateTimeFormat {\n const cached = ServerInfoReporter.formatters.get(opts.timeZone);\n\n if (cached) {\n return cached;\n }\n\n // `h23` keeps midnight as `00`; the default `h24` of some locales prints `24`.\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: opts.timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n ServerInfoReporter.formatters.set(opts.timeZone, formatter);\n\n return formatter;\n }\n\n /** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */\n static formatUtcOffset(opts: { minutes: number }): string {\n const sign = opts.minutes < 0 ? '-' : '+';\n const absolute = Math.abs(opts.minutes);\n const hh = String(Math.trunc(absolute / ServerInfoReporter.MINUTES_PER_HOUR)).padStart(2, '0');\n const mm = String(absolute % ServerInfoReporter.MINUTES_PER_HOUR).padStart(2, '0');\n\n return `${sign}${hh}:${mm}`;\n }\n\n /** The process time zone as the runtime resolved it (`TZ`, or the host setting). */\n static resolveTimeZone(): string {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /**\n * Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the\n * same instant. The offset is read from the zone AT that instant (a DST change moves it), not\n * from the zone's standard offset.\n */\n static buildTime(opts?: { now?: Date; timeZone?: string }): IServerTime {\n const now = opts?.now ?? new Date();\n const tz = opts?.timeZone ?? ServerInfoReporter.resolveTimeZone();\n const epoch = now.getTime();\n\n const parts: Record<string, string> = {};\n\n for (const part of ServerInfoReporter.getFormatter({ timeZone: tz }).formatToParts(now)) {\n parts[part.type] = part.value;\n }\n\n const date = `${parts.year}-${parts.month}-${parts.day}`;\n const ms = String(\n ((epoch % ServerInfoReporter.MS_PER_SECOND) + ServerInfoReporter.MS_PER_SECOND) %\n ServerInfoReporter.MS_PER_SECOND,\n ).padStart(3, '0');\n const time = `${parts.hour}:${parts.minute}:${parts.second}.${ms}`;\n\n // The wall clock, read back as if it were UTC, minus the true instant (both cut to the\n // second) is the zone's offset. Intl has no offset field that is portable across runtimes.\n const wallAsUtc = Date.UTC(\n Number(parts.year),\n Number(parts.month) - 1,\n Number(parts.day),\n Number(parts.hour),\n Number(parts.minute),\n Number(parts.second),\n );\n const epochSecond =\n Math.floor(epoch / ServerInfoReporter.MS_PER_SECOND) * ServerInfoReporter.MS_PER_SECOND;\n const minutes = (wallAsUtc - epochSecond) / ServerInfoReporter.MS_PER_MINUTE;\n const offset = ServerInfoReporter.formatUtcOffset({ minutes });\n\n return {\n server: { date, time, epoch, iso: `${date}T${time}${offset}` },\n tz,\n utc: { offset, minutes, iso: now.toISOString() },\n };\n }\n}\n"]}
|
|
@@ -5,11 +5,21 @@ export declare class SocketIOBunHandler {
|
|
|
5
5
|
static createEngine(opts: {
|
|
6
6
|
serverOptions: Partial<ServerOptions>;
|
|
7
7
|
}): Promise<{
|
|
8
|
-
engine:
|
|
9
|
-
engineHandler:
|
|
8
|
+
engine: import("@socket.io/bun-engine").Server;
|
|
9
|
+
engineHandler: {
|
|
10
|
+
fetch: (req: Request, server: Bun.Server<import("@socket.io/bun-engine").WebSocketData>) => Response | Promise<Response>;
|
|
11
|
+
websocket: {
|
|
12
|
+
open: (ws: import("@socket.io/bun-engine").BunWebSocket) => void;
|
|
13
|
+
message: (ws: import("@socket.io/bun-engine").BunWebSocket, message: import("@socket.io/bun-engine").RawData) => void;
|
|
14
|
+
close: (ws: import("@socket.io/bun-engine").BunWebSocket, code: number, message: string) => void;
|
|
15
|
+
maxPayloadLength: number;
|
|
16
|
+
};
|
|
17
|
+
idleTimeout: number;
|
|
18
|
+
maxRequestBodySize: number;
|
|
19
|
+
};
|
|
10
20
|
}>;
|
|
11
21
|
static createFetchHandler(opts: {
|
|
12
|
-
engine:
|
|
22
|
+
engine: Awaited<ReturnType<typeof SocketIOBunHandler.createEngine>>['engine'];
|
|
13
23
|
enginePath: string;
|
|
14
24
|
honoServer: OpenAPIHono;
|
|
15
25
|
}): (req: Request, server: TBunServerInstance) => Response | Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.handler.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/handlers/bun.handler.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,kBAAkB;IAC7B,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"bun.handler.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/handlers/bun.handler.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,kBAAkB;IAC7B,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,IAA+C;QACvE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QAC/B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;QAEpE,iFAAiF;QACjF,MAAM,UAAU,GAAG,OAAO,aAAa,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3F,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;YAC3B,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,aAAa;YACzC,GAAG,CAAC,UAAU,IAAI;gBAChB,IAAI,EAAE;oBACJ,MAAM,EAAE,UAAU,CAAC,MAA2D;oBAC9E,OAAO,EAAE,UAAU,CAAC,OAAO;oBAC3B,WAAW,EAAE,UAAU,CAAC,WAAW;oBACnC,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC1B;aACF,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAEvC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,IAIzB;QACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEhD,OAAO,CAAC,GAAY,EAAE,MAA0B,EAAgC,EAAE;YAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAE7B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACvC,CAAC;YAED,OAAO,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAClF,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { OpenAPIHono } from '@hono/zod-openapi';\nimport type { TBunServerInstance } from '@/base/applications';\nimport type { ServerOptions } from 'socket.io';\n\nexport class SocketIOBunHandler {\n static async createEngine(opts: { serverOptions: Partial<ServerOptions> }) {\n const { serverOptions } = opts;\n const { Server: BunEngine } = await import('@socket.io/bun-engine');\n\n // Extract cors fields explicitly to bridge socket.io/bun-engine type differences\n const corsConfig = typeof serverOptions.cors === 'object' ? serverOptions.cors : undefined;\n const engine = new BunEngine({\n path: serverOptions.path ?? '/socket.io/',\n ...(corsConfig && {\n cors: {\n origin: corsConfig.origin as string | RegExp | (string | RegExp)[] | undefined,\n methods: corsConfig.methods,\n credentials: corsConfig.credentials,\n allowedHeaders: corsConfig.allowedHeaders,\n exposedHeaders: corsConfig.exposedHeaders,\n maxAge: corsConfig.maxAge,\n },\n }),\n });\n\n const engineHandler = engine.handler();\n\n return { engine, engineHandler };\n }\n\n static createFetchHandler(opts: {\n engine: Awaited<ReturnType<typeof SocketIOBunHandler.createEngine>>['engine'];\n enginePath: string;\n honoServer: OpenAPIHono;\n }): (req: Request, server: TBunServerInstance) => Response | Promise<Response> {\n const { engine, enginePath, honoServer } = opts;\n\n return (req: Request, server: TBunServerInstance): Response | Promise<Response> => {\n const url = new URL(req.url);\n\n if (!url.pathname.startsWith(enginePath)) {\n return honoServer.fetch(req, server);\n }\n\n return engine.handleRequest(req, server) ?? new Response(null, { status: 404 });\n };\n }\n}\n"]}
|
|
@@ -1,34 +1,61 @@
|
|
|
1
1
|
import type { TConstValue } from '@venizia/ignis-helpers/common';
|
|
2
|
-
/**
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export declare
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
static
|
|
2
|
+
/** What a controller sends with every object. */
|
|
3
|
+
export declare class StaticAssetHeaders {
|
|
4
|
+
static readonly NOSNIFF = "nosniff";
|
|
5
|
+
static readonly CSP_SANDBOX = "sandbox";
|
|
6
|
+
static readonly RANGE_UNIT: "bytes";
|
|
7
|
+
}
|
|
8
|
+
/** Content types the controller serves. */
|
|
9
|
+
export declare class StaticAssetContentTypes {
|
|
10
|
+
/**
|
|
11
|
+
* Types the controller will let a browser render, keyed off the object name. Anything absent here is
|
|
12
|
+
* served as an attachment, because a renderable upload on the API origin is stored XSS - and `nosniff`
|
|
13
|
+
* cannot stop a type we declared ourselves. `image/svg+xml` is deliberately excluded: SVG carries script.
|
|
14
|
+
*/
|
|
15
|
+
static readonly RENDERABLE: Set<string>;
|
|
16
|
+
}
|
|
17
|
+
/** The built-in routes of a generated controller, the keys of `routes`. */
|
|
18
|
+
export declare class StaticAssetRouteKeys {
|
|
19
|
+
static readonly UPLOAD = "upload";
|
|
20
|
+
static readonly LIST_OBJECTS = "listObjects";
|
|
21
|
+
static readonly DELETE_OBJECT = "deleteObject";
|
|
22
|
+
static readonly GET_OBJECT_BY_NAME = "getObjectByName";
|
|
23
|
+
static readonly DOWNLOAD_OBJECT_BY_NAME = "downloadObjectByName";
|
|
24
|
+
static readonly UPLOAD_POLICY = "uploadPolicy";
|
|
25
|
+
static readonly UPLOAD_COMMIT = "uploadCommit";
|
|
26
|
+
static readonly UPLOAD_VALIDATE = "uploadValidate";
|
|
27
|
+
static readonly RECREATE_META_LINK = "recreateMetaLink";
|
|
28
|
+
/** Every key, in registration order. */
|
|
29
|
+
static readonly ALL: readonly ["getObjectByName", "downloadObjectByName", "upload", "deleteObject", "listObjects", "uploadPolicy", "uploadCommit", "uploadValidate", "recreateMetaLink"];
|
|
16
30
|
}
|
|
17
|
-
/** One of the `StaticAssetStorageTypes` values. */
|
|
18
|
-
export type TStaticAssetStorageType = TConstValue<typeof StaticAssetStorageTypes>;
|
|
19
31
|
/** What `recreate-metalink` did: refreshed the rows of an object, or created its first one. */
|
|
20
32
|
export declare class MetaLinkRecreateActions {
|
|
21
33
|
static readonly CREATED = "created";
|
|
22
34
|
static readonly REFRESHED = "refreshed";
|
|
23
|
-
static readonly SCHEME_SET: Set<string>;
|
|
24
|
-
static isValid(value: string): boolean;
|
|
25
35
|
}
|
|
26
36
|
/** One of the `MetaLinkRecreateActions` values. */
|
|
27
37
|
export type TMetaLinkRecreateAction = TConstValue<typeof MetaLinkRecreateActions>;
|
|
28
|
-
/** Where a
|
|
29
|
-
export declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
/** Where a commit token is in its life: issued with the policy, then validated against the content it pins. */
|
|
39
|
+
export declare class StaticAssetTokenStages {
|
|
40
|
+
static readonly ISSUED = "issued";
|
|
41
|
+
static readonly VALIDATED = "validated";
|
|
42
|
+
}
|
|
43
|
+
/** One of the `StaticAssetTokenStages` values. */
|
|
44
|
+
export type TStaticAssetTokenStage = TConstValue<typeof StaticAssetTokenStages>;
|
|
45
|
+
/** Defaults of the static asset component. */
|
|
46
|
+
export declare class StaticAssetDefaults {
|
|
47
|
+
/** Where a signed policy may write. The final key is never inside it, so content cannot be replaced after the commit. */
|
|
48
|
+
static readonly PENDING_PREFIX = "pending/";
|
|
49
|
+
/** The most file parts one upload request may carry unless `serverUpload.maxFiles` says otherwise. */
|
|
50
|
+
static readonly MAX_UPLOAD_FILES = 20;
|
|
51
|
+
/** The most bytes of JSON one file's signed `metadata` may take: the token travels in every request. */
|
|
52
|
+
static readonly MAX_TOKEN_METADATA_BYTES = 1024;
|
|
53
|
+
/** The key of the application's token metadata inside a MetaLink row's `metadata` column. */
|
|
54
|
+
static readonly META_LINK_METADATA_KEY = "app";
|
|
55
|
+
}
|
|
56
|
+
/** Codes the component reports in a body instead of throwing. */
|
|
57
|
+
export declare class StaticAssetMetaLinkCodes {
|
|
58
|
+
/** Reported in the body, never thrown: the bytes are stored, only the row is not. A CODE, because a 200 bypasses the middleware that strips the driver's `detail`/`table`/`constraint`. */
|
|
59
|
+
static readonly CREATE_FAILED = "META_LINK_CREATE_FAILED";
|
|
60
|
+
}
|
|
34
61
|
//# sourceMappingURL=constants.d.ts.map
|