@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
package/dist/esm/components/static-asset/{controller/meta-link.js → utilities/meta-link.utility.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResolverUtility } from '@venizia/ignis-helpers/common';
|
|
2
|
-
export class
|
|
2
|
+
export class StaticAssetMetaLinkUtility {
|
|
3
3
|
/** What a stat says about one stored object: the columns a refresh rewrites and a new row starts from. */
|
|
4
4
|
static buildStoredObjectFacts(opts) {
|
|
5
5
|
const { helper, object, link, fileStat } = opts;
|
|
@@ -28,9 +28,9 @@ export class AssetMetaLink {
|
|
|
28
28
|
}
|
|
29
29
|
/** The MetaLink row for one stored object. Every path that creates a row goes through here, so each lands exactly the row an ordinary upload does. */
|
|
30
30
|
static async createRow(opts) {
|
|
31
|
-
const { metaLink, helper, storage, uploadResult, fileStat,
|
|
31
|
+
const { metaLink, helper, storage, uploadResult, fileStat, labels } = opts;
|
|
32
32
|
if (metaLink.createMetaLink) {
|
|
33
|
-
const created = await metaLink.createMetaLink({ uploadResult, fileStat,
|
|
33
|
+
const created = await metaLink.createMetaLink({ uploadResult, fileStat, labels });
|
|
34
34
|
return created.data;
|
|
35
35
|
}
|
|
36
36
|
// Resolved per call so an application that swaps the repository is not pinned to the first one.
|
|
@@ -39,19 +39,19 @@ export class AssetMetaLink {
|
|
|
39
39
|
data: {
|
|
40
40
|
bucketName: uploadResult.bucket.name,
|
|
41
41
|
objectName: uploadResult.object.key,
|
|
42
|
-
...
|
|
42
|
+
...StaticAssetMetaLinkUtility.buildStoredObjectFacts({
|
|
43
43
|
helper,
|
|
44
44
|
object: uploadResult.object,
|
|
45
45
|
link: uploadResult.link,
|
|
46
46
|
fileStat,
|
|
47
47
|
}),
|
|
48
48
|
storageType: storage,
|
|
49
|
-
principalId:
|
|
50
|
-
principalType:
|
|
51
|
-
variant:
|
|
49
|
+
principalId: labels.principalId,
|
|
50
|
+
principalType: labels.principalType,
|
|
51
|
+
variant: labels.variant,
|
|
52
52
|
// Absent leaves the column default rather than writing 0, so a row the caller never
|
|
53
53
|
// ordered is indistinguishable from a legacy one.
|
|
54
|
-
sequence:
|
|
54
|
+
sequence: labels.sequence,
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
return created.data;
|
|
@@ -64,7 +64,7 @@ export class AssetMetaLink {
|
|
|
64
64
|
static async refreshRows(opts) {
|
|
65
65
|
const { metaLink, helper, bucket, object, link, fileStat } = opts;
|
|
66
66
|
const repository = await ResolverUtility.resolveValueAsync({ value: metaLink.repository });
|
|
67
|
-
const { mimetype, size, etag, isSynced } =
|
|
67
|
+
const { mimetype, size, etag, isSynced } = StaticAssetMetaLinkUtility.buildStoredObjectFacts({
|
|
68
68
|
helper,
|
|
69
69
|
object,
|
|
70
70
|
link,
|
|
@@ -88,4 +88,4 @@ export class AssetMetaLink {
|
|
|
88
88
|
return { count: updated.count, data: merged.map((result) => result.data) };
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
//# sourceMappingURL=meta-link.js.map
|
|
91
|
+
//# sourceMappingURL=meta-link.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-link.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/meta-link.utility.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIhE,MAAM,OAAO,0BAA0B;IACrC,0GAA0G;IAClG,MAAM,CAAC,sBAAsB,CAAC,IAKrC;QACC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAEhD,OAAO;YACL,IAAI;YACJ,2DAA2D;YAC3D,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,IAAI,MAAM,CAAC,WAAW,CAAC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AI,EAAE;YACtE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,EAAE;SAC3D,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;QAEhC,IAAI,QAAQ,CAAC,cAAc,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAClD,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC9C,CAAC;QAED,4FAA4F;QAC5F,6FAA6F;QAC7F,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACf,UAAU,CAAC,UAAU,CAAC;YACpB,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE;SAC9D,CAAC,CACH,CACF,CAAC;QAEF,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import type {\n IBucketRef,\n IFileStat,\n IObjectRef,\n IStorageHelper,\n IUploadResult,\n} from '@venizia/ignis-helpers';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport type { TMetaLink, TMetaLinkCompatibleSchema } from '../models';\nimport type { TMetaLinkConfig, TStaticAssetStorageType, TStaticAssetUploadLabels } from '../common';\n\nexport class StaticAssetMetaLinkUtility {\n /** What a stat says about one stored object: the columns a refresh rewrites and a new row starts from. */\n private static buildStoredObjectFacts(opts: {\n helper: IStorageHelper;\n object: IObjectRef;\n link: string;\n fileStat: IFileStat;\n }) {\n const { helper, object, link, fileStat } = opts;\n\n return {\n link,\n // The column is NOT NULL and a backend may report nothing.\n mimetype: fileStat.metadata?.mimetype ?? helper.getMimeType({ filename: object.key }),\n size: fileStat.size,\n etag: fileStat.etag,\n metadata: fileStat.metadata,\n isSynced: true,\n };\n }\n\n /** The upload result of an object already in storage, so a commit or a recreate writes its row the way an upload does. */\n static buildStoredUploadResult(opts: {\n helper: IStorageHelper;\n bucket: IBucketRef;\n object: IObjectRef;\n link: string;\n fileStat: IFileStat;\n }): IUploadResult {\n const { helper, bucket, object, link, fileStat } = opts;\n\n return {\n bucket,\n object: {\n key: object.key,\n size: fileStat.size,\n contentType: fileStat.metadata?.mimetype ?? helper.getMimeType({ filename: object.key }),\n },\n link,\n };\n }\n\n /** The MetaLink row for one stored object. Every path that creates a row goes through here, so each lands exactly the row an ordinary upload does. */\n static async createRow(opts: {\n metaLink: TMetaLinkConfig<TMetaLinkCompatibleSchema>;\n helper: IStorageHelper;\n storage: TStaticAssetStorageType;\n uploadResult: IUploadResult;\n fileStat: IFileStat;\n labels: TStaticAssetUploadLabels;\n }): Promise<TMetaLink> {\n const { metaLink, helper, storage, uploadResult, fileStat, labels } = opts;\n\n if (metaLink.createMetaLink) {\n const created = await metaLink.createMetaLink({ uploadResult, fileStat, labels });\n\n return created.data;\n }\n\n // Resolved per call so an application that swaps the repository is not pinned to the first one.\n const repository = await ResolverUtility.resolveValueAsync({ value: metaLink.repository });\n const created = await repository.create({\n data: {\n bucketName: uploadResult.bucket.name,\n objectName: uploadResult.object.key,\n ...StaticAssetMetaLinkUtility.buildStoredObjectFacts({\n helper,\n object: uploadResult.object,\n link: uploadResult.link,\n fileStat,\n }),\n storageType: storage,\n principalId: labels.principalId,\n principalType: labels.principalType,\n variant: labels.variant,\n // Absent leaves the column default rather than writing 0, so a row the caller never\n // ordered is indistinguishable from a legacy one.\n sequence: labels.sequence,\n },\n });\n\n return created.data;\n }\n\n /**\n * Rewrites the stored-object facts on every row of the pair. Rows per pair are deliberately not\n * unique, and each keeps its own labels and storage type. A `createMetaLink` hook owns `link` and\n * `metadata`, so with one only the stat columns change; without one, `metadata` is merged per row.\n */\n static async refreshRows(opts: {\n metaLink: TMetaLinkConfig<TMetaLinkCompatibleSchema>;\n helper: IStorageHelper;\n bucket: IBucketRef;\n object: IObjectRef;\n link: string;\n fileStat: IFileStat;\n }): Promise<{ count: number; data: TMetaLink[] }> {\n const { metaLink, helper, bucket, object, link, fileStat } = opts;\n\n const repository = await ResolverUtility.resolveValueAsync({ value: metaLink.repository });\n const { mimetype, size, etag, isSynced } = StaticAssetMetaLinkUtility.buildStoredObjectFacts({\n helper,\n object,\n link,\n fileStat,\n });\n const statColumns = { mimetype, size, etag, isSynced };\n\n const updated = await repository.updateBy({\n data: metaLink.createMetaLink ? statColumns : { ...statColumns, link },\n where: { bucketName: bucket.name, objectName: object.key },\n });\n const rows = updated.data ?? [];\n\n if (metaLink.createMetaLink || !fileStat.metadata) {\n return { count: updated.count, data: rows };\n }\n\n // One UPDATE per row: each merge starts from that row's own keys, which the statement above\n // returned untouched and which no single engine-neutral statement over the pair can express.\n const merged = await Promise.all(\n rows.map((row) =>\n repository.updateById({\n id: row.id,\n data: { metadata: { ...row.metadata, ...fileStat.metadata } },\n }),\n ),\n );\n\n return { count: updated.count, data: merged.map((result) => result.data) };\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IObjectLocation } from '@venizia/ignis-helpers';
|
|
2
|
+
/** Builds the URL of an object in the shape its controller serves. */
|
|
3
|
+
export declare class StaticAssetObjectLinkUtility {
|
|
4
|
+
/** The mount path may be declared with or without a leading slash; a link must carry exactly one. */
|
|
5
|
+
static normalizeBasePath(opts: {
|
|
6
|
+
basePath: string;
|
|
7
|
+
}): string;
|
|
8
|
+
/** Encodes an object path into a SINGLE url segment: `{objectName}` matches one segment only, so `/` must be percent-encoded too (Hono decodes it back before the handler reads the param). */
|
|
9
|
+
private static encodeObjectPath;
|
|
10
|
+
/** The URL of one object, in the shape its controller serves: a raw path with `rawObjectPath`, a percent-encoded one without. */
|
|
11
|
+
static build(opts: IObjectLocation & {
|
|
12
|
+
basePath: string;
|
|
13
|
+
rawObjectPath?: boolean;
|
|
14
|
+
}): string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=object-link.utility.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Builds the URL of an object in the shape its controller serves. */
|
|
2
|
+
export class StaticAssetObjectLinkUtility {
|
|
3
|
+
/** The mount path may be declared with or without a leading slash; a link must carry exactly one. */
|
|
4
|
+
static normalizeBasePath(opts) {
|
|
5
|
+
return opts.basePath.startsWith('/') ? opts.basePath : `/${opts.basePath}`;
|
|
6
|
+
}
|
|
7
|
+
/** Encodes an object path into a SINGLE url segment: `{objectName}` matches one segment only, so `/` must be percent-encoded too (Hono decodes it back before the handler reads the param). */
|
|
8
|
+
static encodeObjectPath(opts) {
|
|
9
|
+
return encodeURIComponent(opts.objectPath);
|
|
10
|
+
}
|
|
11
|
+
/** The URL of one object, in the shape its controller serves: a raw path with `rawObjectPath`, a percent-encoded one without. */
|
|
12
|
+
static build(opts) {
|
|
13
|
+
const { basePath, object, rawObjectPath = false } = opts;
|
|
14
|
+
const objectSegment = rawObjectPath
|
|
15
|
+
? object.key
|
|
16
|
+
: StaticAssetObjectLinkUtility.encodeObjectPath({ objectPath: object.key });
|
|
17
|
+
return `${basePath}/objects/${objectSegment}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=object-link.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-link.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/object-link.utility.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,MAAM,OAAO,4BAA4B;IACvC,qGAAqG;IACrG,MAAM,CAAC,iBAAiB,CAAC,IAA0B;QACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC7E,CAAC;IAED,+LAA+L;IACvL,MAAM,CAAC,gBAAgB,CAAC,IAA4B;QAC1D,OAAO,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,iIAAiI;IACjI,MAAM,CAAC,KAAK,CAAC,IAAqE;QAChF,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;QACzD,MAAM,aAAa,GAAG,aAAa;YACjC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAE9E,OAAO,GAAG,QAAQ,YAAY,aAAa,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["import type { IObjectLocation } from '@venizia/ignis-helpers';\n\n/** Builds the URL of an object in the shape its controller serves. */\nexport class StaticAssetObjectLinkUtility {\n /** The mount path may be declared with or without a leading slash; a link must carry exactly one. */\n static normalizeBasePath(opts: { basePath: string }): string {\n return opts.basePath.startsWith('/') ? opts.basePath : `/${opts.basePath}`;\n }\n\n /** Encodes an object path into a SINGLE url segment: `{objectName}` matches one segment only, so `/` must be percent-encoded too (Hono decodes it back before the handler reads the param). */\n private static encodeObjectPath(opts: { objectPath: string }): string {\n return encodeURIComponent(opts.objectPath);\n }\n\n /** The URL of one object, in the shape its controller serves: a raw path with `rawObjectPath`, a percent-encoded one without. */\n static build(opts: IObjectLocation & { basePath: string; rawObjectPath?: boolean }): string {\n const { basePath, object, rawObjectPath = false } = opts;\n const objectSegment = rawObjectPath\n ? object.key\n : StaticAssetObjectLinkUtility.encodeObjectPath({ objectPath: object.key });\n\n return `${basePath}/objects/${objectSegment}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type IFileStat, type IObjectLocation, type IStorageHelper } from '@venizia/ignis-helpers';
|
|
2
|
+
import { type IStaticAssetPin } from '../common/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The pending file as `validation.handler` sees it. Every read asks the storage for exactly the
|
|
5
|
+
* content that was pinned, so a handler cannot parse bytes that are not the ones `commit` will copy:
|
|
6
|
+
* a read that finds other content or no object throws `UPLOAD_CHANGED`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StaticAssetPinnedFile {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly size: number;
|
|
11
|
+
private readonly helper;
|
|
12
|
+
private readonly location;
|
|
13
|
+
private readonly pin;
|
|
14
|
+
constructor(opts: {
|
|
15
|
+
helper: IStorageHelper;
|
|
16
|
+
location: IObjectLocation;
|
|
17
|
+
pin: IStaticAssetPin;
|
|
18
|
+
size: number;
|
|
19
|
+
});
|
|
20
|
+
/** What a read or a copy requires of the object: the exact version when the pin has one, else the ETag. */
|
|
21
|
+
static conditionOf(opts: {
|
|
22
|
+
pin: IStaticAssetPin;
|
|
23
|
+
}): {
|
|
24
|
+
ifMatch?: string;
|
|
25
|
+
versionId?: string;
|
|
26
|
+
};
|
|
27
|
+
/** The pin of what the storage holds now. An object with no ETag cannot be pinned. */
|
|
28
|
+
static pinOf(opts: {
|
|
29
|
+
stat: IFileStat;
|
|
30
|
+
scope: string;
|
|
31
|
+
}): IStaticAssetPin;
|
|
32
|
+
stream(opts?: {
|
|
33
|
+
range?: {
|
|
34
|
+
start: number;
|
|
35
|
+
end?: number;
|
|
36
|
+
};
|
|
37
|
+
}): Promise<ReadableStream<Uint8Array>>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=pinned-file.utility.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { StorageUtility, } from '@venizia/ignis-helpers';
|
|
2
|
+
import { getError } from '@venizia/ignis-helpers/core';
|
|
3
|
+
import { StaticAssetErrors } from '../common/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* The pending file as `validation.handler` sees it. Every read asks the storage for exactly the
|
|
6
|
+
* content that was pinned, so a handler cannot parse bytes that are not the ones `commit` will copy:
|
|
7
|
+
* a read that finds other content or no object throws `UPLOAD_CHANGED`.
|
|
8
|
+
*/
|
|
9
|
+
export class StaticAssetPinnedFile {
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
this.helper = opts.helper;
|
|
12
|
+
this.location = opts.location;
|
|
13
|
+
this.pin = opts.pin;
|
|
14
|
+
this.key = opts.location.object.key;
|
|
15
|
+
this.size = opts.size;
|
|
16
|
+
}
|
|
17
|
+
/** What a read or a copy requires of the object: the exact version when the pin has one, else the ETag. */
|
|
18
|
+
static conditionOf(opts) {
|
|
19
|
+
const { pin } = opts;
|
|
20
|
+
return pin.versionId === undefined ? { ifMatch: pin.etag } : { versionId: pin.versionId };
|
|
21
|
+
}
|
|
22
|
+
/** The pin of what the storage holds now. An object with no ETag cannot be pinned. */
|
|
23
|
+
static pinOf(opts) {
|
|
24
|
+
const { stat, scope } = opts;
|
|
25
|
+
if (!stat.etag) {
|
|
26
|
+
throw getError({
|
|
27
|
+
message: `[${scope}] The storage reported no ETag for the pending object | a pinned validation needs one`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
etag: stat.etag,
|
|
32
|
+
versionId: StorageUtility.realVersionId({ value: stat.versionId }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async stream(opts) {
|
|
36
|
+
try {
|
|
37
|
+
const stream = await this.helper.getObjectStream({
|
|
38
|
+
...this.location,
|
|
39
|
+
range: opts?.range,
|
|
40
|
+
...StaticAssetPinnedFile.conditionOf({ pin: this.pin }),
|
|
41
|
+
});
|
|
42
|
+
return stream;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (StorageUtility.isPreconditionFailedError({ error }) ||
|
|
46
|
+
StorageUtility.isNotFoundError({ error })) {
|
|
47
|
+
throw getError({ error: StaticAssetErrors.UPLOAD_CHANGED, cause: error });
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=pinned-file.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinned-file.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/pinned-file.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,WAAW,CAAC;AAEpE;;;;GAIG;AACH,MAAM,OAAO,qBAAqB;IAQhC,YAAY,IAKX;QACC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,2GAA2G;IAC3G,MAAM,CAAC,WAAW,CAAC,IAA8B;QAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,OAAO,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;IAC5F,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAC,IAAwC;QACnD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,IAAI,KAAK,uFAAuF;aAC1G,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,cAAc,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAEZ;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;gBAC/C,GAAG,IAAI,CAAC,QAAQ;gBAChB,KAAK,EAAE,IAAI,EAAE,KAAK;gBAClB,GAAG,qBAAqB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;aACxD,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IACE,cAAc,CAAC,yBAAyB,CAAC,EAAE,KAAK,EAAE,CAAC;gBACnD,cAAc,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,EACzC,CAAC;gBACD,MAAM,QAAQ,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAC5E,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n StorageUtility,\n type IFileStat,\n type IObjectLocation,\n type IStorageHelper,\n} from '@venizia/ignis-helpers';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { StaticAssetErrors, type IStaticAssetPin } from '../common';\n\n/**\n * The pending file as `validation.handler` sees it. Every read asks the storage for exactly the\n * content that was pinned, so a handler cannot parse bytes that are not the ones `commit` will copy:\n * a read that finds other content or no object throws `UPLOAD_CHANGED`.\n */\nexport class StaticAssetPinnedFile {\n readonly key: string;\n readonly size: number;\n\n private readonly helper: IStorageHelper;\n private readonly location: IObjectLocation;\n private readonly pin: IStaticAssetPin;\n\n constructor(opts: {\n helper: IStorageHelper;\n location: IObjectLocation;\n pin: IStaticAssetPin;\n size: number;\n }) {\n this.helper = opts.helper;\n this.location = opts.location;\n this.pin = opts.pin;\n this.key = opts.location.object.key;\n this.size = opts.size;\n }\n\n /** What a read or a copy requires of the object: the exact version when the pin has one, else the ETag. */\n static conditionOf(opts: { pin: IStaticAssetPin }): { ifMatch?: string; versionId?: string } {\n const { pin } = opts;\n\n return pin.versionId === undefined ? { ifMatch: pin.etag } : { versionId: pin.versionId };\n }\n\n /** The pin of what the storage holds now. An object with no ETag cannot be pinned. */\n static pinOf(opts: { stat: IFileStat; scope: string }): IStaticAssetPin {\n const { stat, scope } = opts;\n\n if (!stat.etag) {\n throw getError({\n message: `[${scope}] The storage reported no ETag for the pending object | a pinned validation needs one`,\n });\n }\n\n return {\n etag: stat.etag,\n versionId: StorageUtility.realVersionId({ value: stat.versionId }),\n };\n }\n\n async stream(opts?: {\n range?: { start: number; end?: number };\n }): Promise<ReadableStream<Uint8Array>> {\n try {\n const stream = await this.helper.getObjectStream({\n ...this.location,\n range: opts?.range,\n ...StaticAssetPinnedFile.conditionOf({ pin: this.pin }),\n });\n\n return stream;\n } catch (error) {\n if (\n StorageUtility.isPreconditionFailedError({ error }) ||\n StorageUtility.isNotFoundError({ error })\n ) {\n throw getError({ error: StaticAssetErrors.UPLOAD_CHANGED, cause: error });\n }\n\n throw error;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IAuthRouteConfig } from '../../../base/index.js';
|
|
2
|
+
import { type TStaticAssetRouteConfig, type TStaticAssetRouteKey } from '../common/index.js';
|
|
3
|
+
import type { IStaticAssetResolvedEntry, IStaticAssetResolvedRoute } from './entry.utility.js';
|
|
4
|
+
/** What a route is registered with: the application's overrides, and the auth it ends up with. */
|
|
5
|
+
export type TStaticAssetRouteOverride = Omit<TStaticAssetRouteConfig, 'authenticate' | 'authorize'> & Pick<IAuthRouteConfig, 'authenticate' | 'authorize'>;
|
|
6
|
+
export declare class StaticAssetRouteOptionsUtility {
|
|
7
|
+
/** Multipart framing of one file (boundary, `Content-Disposition` with a file name, `Content-Type`), allowed on top of its `maxBytes` in the route's body limit. */
|
|
8
|
+
static readonly ENVELOPE_BYTES_PER_FILE: number;
|
|
9
|
+
/** The non-file parts of an upload (policy fields, the closing boundary), allowed once in the route's body limit. */
|
|
10
|
+
static readonly ENVELOPE_BYTES_BASE: number;
|
|
11
|
+
/** The routes `auth.publicRead` leaves open: reading ONE object. Listing is not reading an object. */
|
|
12
|
+
private static readonly PUBLIC_READ_ROUTES;
|
|
13
|
+
/**
|
|
14
|
+
* Reads one built-in route's configuration: whether it is registered, the Hono overrides, and the
|
|
15
|
+
* authentication and authorization it ends up with.
|
|
16
|
+
*
|
|
17
|
+
* Auth is resolved by the same resolver the CRUD factory uses: a route's own config beats the
|
|
18
|
+
* entry's `auth`, and `{ skip: true }` opens the route. `publicRead` is the entry's default for
|
|
19
|
+
* the two read routes and loses to any auth the route sets itself.
|
|
20
|
+
*/
|
|
21
|
+
static readRoute(opts: {
|
|
22
|
+
key: TStaticAssetRouteKey;
|
|
23
|
+
route?: IStaticAssetResolvedRoute;
|
|
24
|
+
auth?: IStaticAssetResolvedEntry<never>['auth'];
|
|
25
|
+
}): {
|
|
26
|
+
isEnabled: boolean;
|
|
27
|
+
override: TStaticAssetRouteOverride;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The route's body validator reads the whole multipart body, so a limit checked in the handler arrives
|
|
31
|
+
* too late to save any memory. Appended after the application's own middleware, so a check of its own
|
|
32
|
+
* still answers first.
|
|
33
|
+
*
|
|
34
|
+
* The limit is `maxFiles` files of `maxBytes` each, plus their multipart framing. A chunked body, which
|
|
35
|
+
* has no declared length, is counted too. The per-file check in the handler still decides each file.
|
|
36
|
+
*/
|
|
37
|
+
static appendBodyLimit(opts: {
|
|
38
|
+
middleware: TStaticAssetRouteConfig['middleware'];
|
|
39
|
+
maxBytes: number;
|
|
40
|
+
maxFiles: number;
|
|
41
|
+
}): NonNullable<TStaticAssetRouteConfig['middleware']>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=route-options.utility.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BodyLimits, RouteConfigResolver } from '@venizia/ignis-kernel';
|
|
2
|
+
import { StaticAssetRouteKeys, } from '../common/index.js';
|
|
3
|
+
export class StaticAssetRouteOptionsUtility {
|
|
4
|
+
/** Multipart framing of one file (boundary, `Content-Disposition` with a file name, `Content-Type`), allowed on top of its `maxBytes` in the route's body limit. */
|
|
5
|
+
static { this.ENVELOPE_BYTES_PER_FILE = 4 * 1024; }
|
|
6
|
+
/** The non-file parts of an upload (policy fields, the closing boundary), allowed once in the route's body limit. */
|
|
7
|
+
static { this.ENVELOPE_BYTES_BASE = 64 * 1024; }
|
|
8
|
+
/** The routes `auth.publicRead` leaves open: reading ONE object. Listing is not reading an object. */
|
|
9
|
+
static { this.PUBLIC_READ_ROUTES = new Set([
|
|
10
|
+
StaticAssetRouteKeys.GET_OBJECT_BY_NAME,
|
|
11
|
+
StaticAssetRouteKeys.DOWNLOAD_OBJECT_BY_NAME,
|
|
12
|
+
]); }
|
|
13
|
+
/**
|
|
14
|
+
* Reads one built-in route's configuration: whether it is registered, the Hono overrides, and the
|
|
15
|
+
* authentication and authorization it ends up with.
|
|
16
|
+
*
|
|
17
|
+
* Auth is resolved by the same resolver the CRUD factory uses: a route's own config beats the
|
|
18
|
+
* entry's `auth`, and `{ skip: true }` opens the route. `publicRead` is the entry's default for
|
|
19
|
+
* the two read routes and loses to any auth the route sets itself.
|
|
20
|
+
*/
|
|
21
|
+
static readRoute(opts) {
|
|
22
|
+
const { key, route, auth } = opts;
|
|
23
|
+
const { authenticate, authorize, ...override } = route?.override ?? {};
|
|
24
|
+
const isPublicRead = auth?.isPublicRead === true &&
|
|
25
|
+
StaticAssetRouteOptionsUtility.PUBLIC_READ_ROUTES.has(key) &&
|
|
26
|
+
authenticate == null &&
|
|
27
|
+
authorize == null;
|
|
28
|
+
const endpoint = isPublicRead
|
|
29
|
+
? { authenticate: { skip: true } }
|
|
30
|
+
: { authenticate, authorize };
|
|
31
|
+
// An entry-level `skip` is no default at all: nothing to inherit.
|
|
32
|
+
const entryAuthenticate = auth?.authenticate == null || auth.authenticate.skip === true ? undefined : auth.authenticate;
|
|
33
|
+
const entryAuthorize = auth?.authorize == null || (!Array.isArray(auth.authorize) && 'skip' in auth.authorize)
|
|
34
|
+
? undefined
|
|
35
|
+
: auth.authorize;
|
|
36
|
+
return {
|
|
37
|
+
isEnabled: route?.isEnabled ?? true,
|
|
38
|
+
override: {
|
|
39
|
+
...override,
|
|
40
|
+
authenticate: RouteConfigResolver.resolveAuthenticate({
|
|
41
|
+
controller: entryAuthenticate,
|
|
42
|
+
endpoint: endpoint.authenticate,
|
|
43
|
+
}),
|
|
44
|
+
authorize: RouteConfigResolver.resolveAuthorize({
|
|
45
|
+
controller: entryAuthorize,
|
|
46
|
+
endpoint,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The route's body validator reads the whole multipart body, so a limit checked in the handler arrives
|
|
53
|
+
* too late to save any memory. Appended after the application's own middleware, so a check of its own
|
|
54
|
+
* still answers first.
|
|
55
|
+
*
|
|
56
|
+
* The limit is `maxFiles` files of `maxBytes` each, plus their multipart framing. A chunked body, which
|
|
57
|
+
* has no declared length, is counted too. The per-file check in the handler still decides each file.
|
|
58
|
+
*/
|
|
59
|
+
static appendBodyLimit(opts) {
|
|
60
|
+
const { middleware, maxBytes, maxFiles } = opts;
|
|
61
|
+
const limit = BodyLimits.route({
|
|
62
|
+
maxSize: maxFiles * (maxBytes + StaticAssetRouteOptionsUtility.ENVELOPE_BYTES_PER_FILE) +
|
|
63
|
+
StaticAssetRouteOptionsUtility.ENVELOPE_BYTES_BASE,
|
|
64
|
+
});
|
|
65
|
+
if (!middleware) {
|
|
66
|
+
return [limit];
|
|
67
|
+
}
|
|
68
|
+
return Array.isArray(middleware) ? [...middleware, limit] : [middleware, limit];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=route-options.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-options.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/route-options.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EACL,oBAAoB,GAGrB,MAAM,WAAW,CAAC;AAUnB,MAAM,OAAO,8BAA8B;IACzC,oKAAoK;aACpJ,4BAAuB,GAAG,CAAC,GAAG,IAAI,CAAC;IAEnD,qHAAqH;aACrG,wBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC;IAEhD,sGAAsG;aAC9E,uBAAkB,GAAsC,IAAI,GAAG,CAAC;QACtF,oBAAoB,CAAC,kBAAkB;QACvC,oBAAoB,CAAC,uBAAuB;KAC7C,CAAC,CAAC;IAEH;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,CAAC,IAIhB;QACC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAClC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,QAAQ,IAAI,EAAE,CAAC;QAEvE,MAAM,YAAY,GAChB,IAAI,EAAE,YAAY,KAAK,IAAI;YAC3B,8BAA8B,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC;YAC1D,YAAY,IAAI,IAAI;YACpB,SAAS,IAAI,IAAI,CAAC;QACpB,MAAM,QAAQ,GAAqB,YAAY;YAC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;YAChB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC","sourcesContent":["import { BodyLimits, RouteConfigResolver } from '@venizia/ignis-kernel';\nimport type { IAuthRouteConfig, TRouteAuthConfig } from '@/base';\nimport {\n StaticAssetRouteKeys,\n type TStaticAssetRouteConfig,\n type TStaticAssetRouteKey,\n} from '../common';\nimport type { IStaticAssetResolvedEntry, IStaticAssetResolvedRoute } from './entry.utility';\n\n/** What a route is registered with: the application's overrides, and the auth it ends up with. */\nexport type TStaticAssetRouteOverride = Omit<\n TStaticAssetRouteConfig,\n 'authenticate' | 'authorize'\n> &\n Pick<IAuthRouteConfig, 'authenticate' | 'authorize'>;\n\nexport class StaticAssetRouteOptionsUtility {\n /** Multipart framing of one file (boundary, `Content-Disposition` with a file name, `Content-Type`), allowed on top of its `maxBytes` in the route's body limit. */\n static readonly ENVELOPE_BYTES_PER_FILE = 4 * 1024;\n\n /** The non-file parts of an upload (policy fields, the closing boundary), allowed once in the route's body limit. */\n static readonly ENVELOPE_BYTES_BASE = 64 * 1024;\n\n /** The routes `auth.publicRead` leaves open: reading ONE object. Listing is not reading an object. */\n private static readonly PUBLIC_READ_ROUTES: ReadonlySet<TStaticAssetRouteKey> = new Set([\n StaticAssetRouteKeys.GET_OBJECT_BY_NAME,\n StaticAssetRouteKeys.DOWNLOAD_OBJECT_BY_NAME,\n ]);\n\n /**\n * Reads one built-in route's configuration: whether it is registered, the Hono overrides, and the\n * authentication and authorization it ends up with.\n *\n * Auth is resolved by the same resolver the CRUD factory uses: a route's own config beats the\n * entry's `auth`, and `{ skip: true }` opens the route. `publicRead` is the entry's default for\n * the two read routes and loses to any auth the route sets itself.\n */\n static readRoute(opts: {\n key: TStaticAssetRouteKey;\n route?: IStaticAssetResolvedRoute;\n auth?: IStaticAssetResolvedEntry<never>['auth'];\n }): { isEnabled: boolean; override: TStaticAssetRouteOverride } {\n const { key, route, auth } = opts;\n const { authenticate, authorize, ...override } = route?.override ?? {};\n\n const isPublicRead =\n auth?.isPublicRead === true &&\n StaticAssetRouteOptionsUtility.PUBLIC_READ_ROUTES.has(key) &&\n authenticate == null &&\n authorize == null;\n const endpoint: TRouteAuthConfig = isPublicRead\n ? { authenticate: { skip: true } }\n : { authenticate, authorize };\n\n // An entry-level `skip` is no default at all: nothing to inherit.\n const entryAuthenticate =\n auth?.authenticate == null || auth.authenticate.skip === true ? undefined : auth.authenticate;\n const entryAuthorize =\n auth?.authorize == null || (!Array.isArray(auth.authorize) && 'skip' in auth.authorize)\n ? undefined\n : auth.authorize;\n\n return {\n isEnabled: route?.isEnabled ?? true,\n override: {\n ...override,\n authenticate: RouteConfigResolver.resolveAuthenticate({\n controller: entryAuthenticate,\n endpoint: endpoint.authenticate,\n }),\n authorize: RouteConfigResolver.resolveAuthorize({\n controller: entryAuthorize,\n endpoint,\n }),\n },\n };\n }\n\n /**\n * The route's body validator reads the whole multipart body, so a limit checked in the handler arrives\n * too late to save any memory. Appended after the application's own middleware, so a check of its own\n * still answers first.\n *\n * The limit is `maxFiles` files of `maxBytes` each, plus their multipart framing. A chunked body, which\n * has no declared length, is counted too. The per-file check in the handler still decides each file.\n */\n static appendBodyLimit(opts: {\n middleware: TStaticAssetRouteConfig['middleware'];\n maxBytes: number;\n maxFiles: number;\n }): NonNullable<TStaticAssetRouteConfig['middleware']> {\n const { middleware, maxBytes, maxFiles } = opts;\n\n const limit = BodyLimits.route({\n maxSize:\n maxFiles * (maxBytes + StaticAssetRouteOptionsUtility.ENVELOPE_BYTES_PER_FILE) +\n StaticAssetRouteOptionsUtility.ENVELOPE_BYTES_BASE,\n });\n\n if (!middleware) {\n return [limit];\n }\n\n return Array.isArray(middleware) ? [...middleware, limit] : [middleware, limit];\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ToggleUtility } from '@venizia/ignis-kernel';
|
|
2
|
+
/** Reads the `{ use }` switches an entry is written with. The logic lives in the kernel's `ToggleUtility`, shared with controllers. */
|
|
3
|
+
export declare class StaticAssetToggleUtility extends ToggleUtility {
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=toggle.utility.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ToggleUtility } from '@venizia/ignis-kernel';
|
|
2
|
+
/** Reads the `{ use }` switches an entry is written with. The logic lives in the kernel's `ToggleUtility`, shared with controllers. */
|
|
3
|
+
export class StaticAssetToggleUtility extends ToggleUtility {
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=toggle.utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/toggle.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,uIAAuI;AACvI,MAAM,OAAO,wBAAyB,SAAQ,aAAa;CAAG","sourcesContent":["import { ToggleUtility } from '@venizia/ignis-kernel';\n\n/** Reads the `{ use }` switches an entry is written with. The logic lives in the kernel's `ToggleUtility`, shared with controllers. */\nexport class StaticAssetToggleUtility extends ToggleUtility {}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseApplication } from '../base/applications/index.js';
|
|
2
2
|
import { type TServerBootStep } from '../base/applications/index.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TClass } from '@venizia/ignis-helpers/common';
|
|
4
4
|
/** A class (matched against the instance's constructor) or a string (matched against the binding key or the class name). */
|
|
5
|
-
export type TBootProbeTarget = TClass<
|
|
5
|
+
export type TBootProbeTarget = TClass<unknown> | string;
|
|
6
6
|
/** Options of `ApplicationBootAssertion.assert`; each field narrows or relaxes what the boot probe runs and verifies. */
|
|
7
7
|
export interface IAssertApplicationBootsOptions {
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServerBootSteps } from '../base/applications/index.js';
|
|
2
2
|
import { getError } from '@venizia/ignis-helpers/core';
|
|
3
|
-
import { BindingVerifier } from '@venizia/ignis-inversion';
|
|
3
|
+
import { BindingVerifier, isClass } from '@venizia/ignis-inversion';
|
|
4
4
|
import { AuthorizationEnforcerRegistry, BindingNamespaces, BindingValueTypes, ControllerTransports, CoreBindings, MetadataRegistry, } from '@venizia/ignis-kernel';
|
|
5
5
|
/** The boot sequence is the contract; these two are what the helper wraps on one instance. */
|
|
6
6
|
const WRAPPED_METHODS = ['registerDynamicBindings', 'getBootSequence'];
|
|
@@ -32,7 +32,7 @@ const patchProperty = (opts) => {
|
|
|
32
32
|
Object.defineProperty(object, name, descriptor);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
Reflect.deleteProperty(object, name);
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
};
|
|
@@ -60,6 +60,10 @@ const assertNoDuplicateRoutes = (opts) => {
|
|
|
60
60
|
if (!metadata?.path || metadata.transport === ControllerTransports.GRPC) {
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
|
+
// A bound controller is a class; this narrows it for the `prototype` read below.
|
|
64
|
+
if (!isClass(target)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
63
67
|
const instance = application.get({
|
|
64
68
|
key: binding.key,
|
|
65
69
|
isOptional: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-application-boots.js","sourceRoot":"","sources":["../../../src/testing/assert-application-boots.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAEL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AC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAE7C,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,CAAC,MAAM;qBACV,GAAG,CAAC,iCAAiC,CAAC;qBACtC,IAAI,CACH,oCAAoC,OAAO,oDAAoD,OAAO,oEAAoE,CAC3K,CAAC;YACN,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;gBACtC,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,CAAC;YAED,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;gBACrC,OAAO,OAAO,CAAC,UAAU,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,UAAU,GAAG,kBAAkB,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { ServerBootSteps, type TServerBootStep } from '@/base/applications';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BindingVerifier } from '@venizia/ignis-inversion';\nimport {\n type AbstractRestController,\n AuthorizationEnforcerRegistry,\n type Binding,\n BindingNamespaces,\n BindingValueTypes,\n ControllerTransports,\n CoreBindings,\n MetadataRegistry,\n} from '@venizia/ignis-kernel';\n\n/** A class (matched against the instance's constructor) or a string (matched against the binding key or the class name). */\nexport type TBootProbeTarget = TClass<AnyType> | string;\n\n/** Options of `ApplicationBootAssertion.assert`; each field narrows or relaxes what the boot probe runs and verifies. */\nexport interface IAssertApplicationBootsOptions {\n /**\n * Datasources whose real `configure()` runs. Every other datasource is bound and resolved but not\n * configured, so no connection is made. Close a kept one with `await application.stop()`.\n *\n * @default []\n */\n keepDataSources?: TBootProbeTarget[];\n\n /**\n * Components whose `configure()` (and so their `binding()`) is skipped, for the few that need\n * infrastructure. What a skipped component would have registered is not registered.\n *\n * @default []\n */\n skipComponents?: TBootProbeTarget[];\n\n /**\n * Boot steps that do not run, so a remote secrets provider is never contacted. A value REPLACES\n * the default; an unknown name rejects before anything boots.\n *\n * @default [ServerBootSteps.HYDRATE_SECRETS, ServerBootSteps.WIRE_SECRET_ROTATABLES]\n */\n skipSteps?: TServerBootStep[];\n\n /**\n * After boot, resolves every service and repository with the shared core of\n * `@venizia/ignis-inversion`, so an injection nobody references at boot still fails. An explicit value\n * wins over the application's own `bootChecks`, whose boot step is off for the run.\n *\n * @default true\n */\n verifyBindings?: boolean;\n\n /**\n * Services or repositories the verification leaves unresolved, for one whose constructor needs\n * infrastructure. A class (exact), a class name or a binding key. A name that matches nothing rejects.\n *\n * @default []\n */\n skipBindings?: TBootProbeTarget[];\n\n /**\n * Whether an application that registered no controller passes. Off, it fails: it proves nothing, for example when the artifact index was empty.\n *\n * @default false\n */\n allowNoControllers?: boolean;\n\n /**\n * This helper's own check that no method and path is mounted twice. IGNIS boot does not detect that.\n *\n * @default true\n */\n routes?: boolean;\n}\n\n/** The boot sequence is the contract; these two are what the helper wraps on one instance. */\nconst WRAPPED_METHODS = ['registerDynamicBindings', 'getBootSequence'] as const;\n\nconst DEFAULT_SKIPPED_STEPS: TServerBootStep[] = [\n ServerBootSteps.HYDRATE_SECRETS,\n ServerBootSteps.WIRE_SECRET_ROTATABLES,\n];\n\n/** Methods a route entry may carry that are middleware, not a mounted handler. */\nconst NON_ROUTE_METHOD = 'ALL';\n\nconst bootedApplications = new WeakSet<object>();\n\ninterface IProbeBinding {\n key: string;\n}\n\ninterface IDynamicBindingsOptions {\n namespace: string;\n onBeforeConfigure?: (opts: { binding: Binding<AnyType> }) => Promise<void>;\n onAfterConfigure?: (opts: { binding: Binding<AnyType>; instance: AnyType }) => Promise<void>;\n}\n\n/** What the helper replaced, so every path puts it back. */\ninterface IPatch {\n restore: () => void;\n}\n\nconst matchesTarget = (opts: {\n targets: TBootProbeTarget[];\n binding: IProbeBinding;\n instance: AnyType;\n}): boolean => {\n const { targets, binding, instance } = opts;\n const className: string | undefined = instance?.constructor?.name;\n\n return targets.some((target) =>\n typeof target === 'string'\n ? target === binding.key || target === className\n : instance?.constructor === target,\n );\n};\n\nconst fail = (message: string): never => {\n throw getError({ message: `[ApplicationBootAssertion.assert] ${message}` });\n};\n\n/** Replaces `object[name]` and returns the way back, even when `name` was inherited. */\nconst patchProperty = (opts: { object: AnyType; name: string; value: unknown }): IPatch => {\n const { object, name, value } = opts;\n const descriptor = Object.getOwnPropertyDescriptor(object, name);\n\n Object.defineProperty(object, name, { value, configurable: true, writable: true });\n\n return {\n restore: () => {\n if (descriptor) {\n Object.defineProperty(object, name, descriptor);\n\n return;\n }\n\n delete object[name];\n },\n };\n};\n\nconst normalizePath = (path: string): string => {\n const withParams = path.replace(/:[A-Za-z0-9_]+/g, ':param').replace(/\\/{2,}/g, '/');\n\n return withParams.length > 1 ? withParams.replace(/\\/$/, '') : withParams;\n};\n\n/** The helper's own check: IGNIS mounts a method and path twice without complaint, and the first one wins. */\nconst assertNoDuplicateRoutes = (opts: { application: BaseApplication }): void => {\n const { application } = opts;\n // signature -> controller key -> how many times that controller declares it\n const mounted = new Map<string, Map<string, number>>();\n\n const record = (signature: string, key: string, declarations: number): void => {\n const owners = mounted.get(signature) ?? new Map<string, number>();\n owners.set(key, Math.max(owners.get(key) ?? 0, declarations));\n mounted.set(signature, owners);\n };\n\n for (const binding of application.findByTag<AbstractRestController>({\n tag: BindingNamespaces.CONTROLLER,\n })) {\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n const metadata = target\n ? MetadataRegistry.getInstance().getControllerMetadata({ target })\n : undefined;\n\n if (!metadata?.path || metadata.transport === ControllerTransports.GRPC) {\n continue;\n }\n\n const instance = application.get<AbstractRestController>({\n key: binding.key,\n isOptional: true,\n });\n\n // Hono's `routes` has one entry PER HANDLER (a validator, an authenticate and the handler of one route are three\n // entries with the same method and path), so an entry is not a declaration: a controller counts once per signature.\n for (const route of instance?.getRouter().routes ?? []) {\n if (route.method === NON_ROUTE_METHOD) {\n continue;\n }\n\n record(`${route.method} ${normalizePath(`${metadata.path}/${route.path}`)}`, binding.key, 1);\n }\n\n // What the router cannot show: one controller declaring a method and path twice. Decorated routes are one\n // metadata entry per declaration, so those are counted there.\n const declared = new Map<string, number>();\n\n for (const route of MetadataRegistry.getInstance()\n .getRoutes({ target: (target as TClass<AnyType>).prototype })\n ?.values() ?? []) {\n const signature = `${String(route.method).toUpperCase()} ${normalizePath(`${metadata.path}/${route.path}`)}`;\n declared.set(signature, (declared.get(signature) ?? 0) + 1);\n }\n\n for (const [signature, declarations] of declared) {\n record(signature, binding.key, declarations);\n }\n }\n\n const duplicates = [...mounted.entries()].filter(\n ([, owners]) =>\n owners.size > 1 || [...owners.values()].some((declarations) => declarations > 1),\n );\n\n if (duplicates.length === 0) {\n return;\n }\n\n const lines = duplicates.map(\n ([signature, owners]) =>\n `${signature} | controllers: ${[...owners]\n .map(([key, declarations]) =>\n declarations > 1 ? `${key} (declared ${declarations} times)` : key,\n )\n .join(', ')}`,\n );\n fail(\n `${duplicates.length} route(s) are mounted more than once, and only the first one answers | ${lines.join(' ; ')} | This is the helper's own check (IGNIS boot does not detect it); pass { routes: false } to turn it off`,\n );\n};\n\n/**\n * Proves an IGNIS application boots, without a datasource connection, a socket or a secrets provider:\n * it runs the application's own boot sequence (`init()` then `initialize()`) and never calls `start()`,\n * so no socket is opened and no post-start hook runs.\n *\n * Datasources are bound and resolved but not configured, unless named in `keepDataSources`; the\n * secrets steps are skipped; every other step and every component runs as in a real boot. A component\n * that opens Redis, Kafka or S3 in `binding()` therefore runs for real: name it in `skipComponents`.\n * `setupMiddlewares()` is not run: it is the application's own start-time step, user code that may open\n * connections, and the probe cannot know it is free of side effects. The framework's default stack (CORS, body\n * limit, request id) is a boot step of `initialize()`, so an invalid `configs.middlewares` value still fails here.\n * When the boot fails inside a component, one warning names it; the rejection is still the original error. When the\n * boot fails, the rejection is the original error. The application stays booted and is returned;\n * a failed boot leaves a half-booted instance, so build a new one rather than reuse it.\n *\n * It wraps `registerDynamicBindings` and `getBootSequence` on THIS instance only (an application's\n * own override of either still runs) and restores them whatever happens.\n *\n * It owns the process-wide `AuthorizationEnforcerRegistry` for the duration of the check: it resets it before it\n * boots, so a second boot in the same process (another probe, or a test boot after this one) does not fail with\n * `Enforcer already registered`. An application still running in the same process loses its enforcer registrations\n * and its authorize options, so its requests are then decided by the no-enforcer default (deny unless configured\n * otherwise): do not run the probe in a process that serves an application.\n *\n * @example\n * ```typescript\n * import { ApplicationBootAssertion } from '@venizia/ignis/testing';\n * import { test } from 'bun:test';\n * import { Application } from './application';\n *\n * test('the application boots offline', async () => {\n * await ApplicationBootAssertion.assert({\n * application: () => new Application({ scope: 'Application', config: { host: '127.0.0.1', port: 0, path: { base: '/', isStrict: true } } }),\n * options: { skipComponents: ['MailComponent'], allowNoControllers: true },\n * });\n * });\n * ```\n */\nexport class ApplicationBootAssertion {\n static async assert<Application extends BaseApplication>(opts: {\n application: Application | (() => Application | Promise<Application>);\n options?: IAssertApplicationBootsOptions;\n }): Promise<Application> {\n const { application, options = {} } = opts;\n const {\n keepDataSources = [],\n skipComponents = [],\n skipSteps = DEFAULT_SKIPPED_STEPS,\n verifyBindings = true,\n skipBindings = [],\n allowNoControllers = false,\n routes = true,\n } = options;\n\n for (const step of skipSteps) {\n if (!ServerBootSteps.isValid(step)) {\n fail(\n `Unknown boot step in skipSteps: '${String(step)}' | Expected one of: ${[...ServerBootSteps.SCHEME_SET].join(', ')}`,\n );\n }\n }\n\n let target: Application;\n\n if (typeof application === 'function') {\n const built = await application();\n target = built;\n } else {\n target = application;\n }\n\n if (\n bootedApplications.has(target) ||\n Object.keys(target['registeredBindings'] ?? {}).length > 0\n ) {\n fail(\n `This application instance was already booted | A failed or finished boot leaves registrations behind, so build a new instance (pass a factory) for each call`,\n );\n }\n\n bootedApplications.add(target);\n\n for (const name of WRAPPED_METHODS) {\n if (typeof target[name] !== 'function') {\n fail(\n `The kernel method '${name}' is missing on this application | The helper cannot keep a boot offline without it, so it refuses to boot`,\n );\n }\n }\n\n const skippedSteps = new Set<string>(skipSteps);\n const patches: IPatch[] = [];\n let sweepsSeen = 0;\n // The components whose `configure()` is running, innermost last: when the boot rejects, the last one is where it failed.\n const configuringComponents: string[] = [];\n\n const neutralise = async (entry: {\n namespace: string;\n binding: Binding<AnyType>;\n }): Promise<void> => {\n const { namespace, binding } = entry;\n const isDataSource = namespace === BindingNamespaces.DATASOURCE;\n const isComponent = namespace === BindingNamespaces.COMPONENT;\n\n if (!isDataSource && !isComponent) {\n return;\n }\n\n const instance = target.get<AnyType>({ key: binding.key, isOptional: false });\n\n if (typeof instance?.configure !== 'function') {\n return;\n }\n\n const shouldRun = isDataSource\n ? matchesTarget({ targets: keepDataSources, binding, instance })\n : !matchesTarget({ targets: skipComponents, binding, instance });\n\n if (shouldRun) {\n return;\n }\n\n patches.push(patchProperty({ object: instance, name: 'configure', value: async () => {} }));\n };\n\n const originalRegisterDynamicBindings = target['registerDynamicBindings'] as unknown as (\n opts: IDynamicBindingsOptions,\n ) => Promise<void>;\n const originalGetBootSequence = target['getBootSequence'] as unknown as () => Array<{\n name: string;\n }>;\n\n const wrappedRegister = async (sweepOptions: IDynamicBindingsOptions): Promise<void> => {\n sweepsSeen += 1;\n const userBefore = sweepOptions.onBeforeConfigure;\n const userAfter = sweepOptions.onAfterConfigure;\n\n return originalRegisterDynamicBindings.call(target, {\n ...sweepOptions,\n onBeforeConfigure: async ({ binding }) => {\n await neutralise({ namespace: sweepOptions.namespace, binding });\n\n if (sweepOptions.namespace === BindingNamespaces.COMPONENT) {\n const instance = target.get<AnyType>({ key: binding.key, isOptional: true });\n configuringComponents.push(String(instance?.constructor?.name ?? binding.key));\n }\n\n await userBefore?.({ binding });\n },\n onAfterConfigure: async ({ binding, instance }) => {\n if (sweepOptions.namespace === BindingNamespaces.COMPONENT) {\n configuringComponents.pop();\n }\n\n await userAfter?.({ binding, instance });\n },\n });\n };\n\n patches.push(\n patchProperty({ object: target, name: 'registerDynamicBindings', value: wrappedRegister }),\n );\n patches.push(\n patchProperty({\n object: target,\n name: 'getBootSequence',\n value: () =>\n originalGetBootSequence.call(target).filter((step) => !skippedSteps.has(step.name)),\n }),\n );\n\n if ((target['registerDynamicBindings'] as unknown) !== wrappedRegister) {\n patches.forEach((patch) => patch.restore());\n fail(\n `The wrap of 'registerDynamicBindings' did not take effect | Refusing to boot against real infrastructure`,\n );\n }\n\n const configs = target['configs'];\n const originalBootChecks = configs.bootChecks;\n const originalBinding = originalBootChecks?.binding;\n configs.bootChecks = {\n ...originalBootChecks,\n binding: {\n allowManual: originalBinding?.allowManual ?? true,\n allowOverride: originalBinding?.allowOverride ?? true,\n doVerify: false,\n },\n };\n\n AuthorizationEnforcerRegistry.getInstance().reset();\n\n try {\n if (!target.isBound({ key: CoreBindings.APPLICATION_INSTANCE })) {\n target.init();\n }\n\n await target.initialize();\n\n const sweepsExpected = [\n ServerBootSteps.REGISTER_DATA_SOURCES,\n ServerBootSteps.REGISTER_COMPONENTS,\n ServerBootSteps.REGISTER_CONTRIBUTED_DATA_SOURCES,\n ].some((step) => !skippedSteps.has(step));\n\n if (sweepsExpected && sweepsSeen === 0) {\n fail(\n `The boot never went through 'registerDynamicBindings' | The wrap did not take effect, so datasources may have been configured`,\n );\n }\n\n if (verifyBindings) {\n BindingVerifier.assertResolve({\n container: target,\n namespaces: [BindingNamespaces.SERVICE, BindingNamespaces.REPOSITORY],\n skip: skipBindings,\n scope: 'verifyBindings',\n });\n }\n\n if (\n !allowNoControllers &&\n target.findByTag({ tag: BindingNamespaces.CONTROLLER }).length === 0\n ) {\n fail(\n `The application registered no controller | A boot that registers nothing proves nothing: check the artifact index (for example the AutoArtifacts plugin under 'bun test'), or pass { allowNoControllers: true }`,\n );\n }\n\n if (routes) {\n assertNoDuplicateRoutes({ application: target });\n }\n\n return target;\n } catch (error) {\n const failing = configuringComponents.at(-1);\n\n if (failing) {\n target.logger\n .for('ApplicationBootAssertion.assert')\n .warn(\n `The boot failed inside component ${failing} | If it needs infrastructure, skipComponents: ['${failing}'] skips it, and skipBindings lists the services that depend on it`,\n );\n }\n\n throw error;\n } finally {\n for (const patch of patches.reverse()) {\n patch.restore();\n }\n\n if (originalBootChecks === undefined) {\n delete configs.bootChecks;\n } else {\n configs.bootChecks = originalBootChecks;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"assert-application-boots.js","sourceRoot":"","sources":["../../../src/testing/assert-application-boots.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAEL,6BAA6B,EAE7B,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AA+D/B,8FAA8F;AAC9F,MAAM,eAAe,GAAG,CAAC,yBAAyB,EAAE,iBAAiB,CAAU,CAAC;AAEhF,MAAM,qBAAqB,GAAsB;IAC/C,eAAe,CAAC,eAAe;IAC/B,eAAe,CAAC,sBAAsB;CACvC,CAAC;AAEF,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAU,CAAC;AAoBjD,MAAM,aAAa,GAAG,CAAC,IAItB,EAAW,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,SAAS,GAAuB,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC;IAElE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAC7B,OAAO,MAAM,KAAK,Q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,UAAU,GAAG,kBAAkB,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { ServerBootSteps, type TServerBootStep } from '@/base/applications';\nimport type { IConfigurable, TClass } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BindingVerifier, isClass } from '@venizia/ignis-inversion';\nimport {\n type AbstractRestController,\n AuthorizationEnforcerRegistry,\n type Binding,\n BindingNamespaces,\n BindingValueTypes,\n ControllerTransports,\n CoreBindings,\n MetadataRegistry,\n} from '@venizia/ignis-kernel';\n\n/** A class (matched against the instance's constructor) or a string (matched against the binding key or the class name). */\nexport type TBootProbeTarget = TClass<unknown> | string;\n\n/** Options of `ApplicationBootAssertion.assert`; each field narrows or relaxes what the boot probe runs and verifies. */\nexport interface IAssertApplicationBootsOptions {\n /**\n * Datasources whose real `configure()` runs. Every other datasource is bound and resolved but not\n * configured, so no connection is made. Close a kept one with `await application.stop()`.\n *\n * @default []\n */\n keepDataSources?: TBootProbeTarget[];\n\n /**\n * Components whose `configure()` (and so their `binding()`) is skipped, for the few that need\n * infrastructure. What a skipped component would have registered is not registered.\n *\n * @default []\n */\n skipComponents?: TBootProbeTarget[];\n\n /**\n * Boot steps that do not run, so a remote secrets provider is never contacted. A value REPLACES\n * the default; an unknown name rejects before anything boots.\n *\n * @default [ServerBootSteps.HYDRATE_SECRETS, ServerBootSteps.WIRE_SECRET_ROTATABLES]\n */\n skipSteps?: TServerBootStep[];\n\n /**\n * After boot, resolves every service and repository with the shared core of\n * `@venizia/ignis-inversion`, so an injection nobody references at boot still fails. An explicit value\n * wins over the application's own `bootChecks`, whose boot step is off for the run.\n *\n * @default true\n */\n verifyBindings?: boolean;\n\n /**\n * Services or repositories the verification leaves unresolved, for one whose constructor needs\n * infrastructure. A class (exact), a class name or a binding key. A name that matches nothing rejects.\n *\n * @default []\n */\n skipBindings?: TBootProbeTarget[];\n\n /**\n * Whether an application that registered no controller passes. Off, it fails: it proves nothing, for example when the artifact index was empty.\n *\n * @default false\n */\n allowNoControllers?: boolean;\n\n /**\n * This helper's own check that no method and path is mounted twice. IGNIS boot does not detect that.\n *\n * @default true\n */\n routes?: boolean;\n}\n\n/** The boot sequence is the contract; these two are what the helper wraps on one instance. */\nconst WRAPPED_METHODS = ['registerDynamicBindings', 'getBootSequence'] as const;\n\nconst DEFAULT_SKIPPED_STEPS: TServerBootStep[] = [\n ServerBootSteps.HYDRATE_SECRETS,\n ServerBootSteps.WIRE_SECRET_ROTATABLES,\n];\n\n/** Methods a route entry may carry that are middleware, not a mounted handler. */\nconst NON_ROUTE_METHOD = 'ALL';\n\nconst bootedApplications = new WeakSet<object>();\n\ninterface IProbeBinding {\n key: string;\n}\n\ninterface IDynamicBindingsOptions {\n namespace: string;\n onBeforeConfigure?: (opts: { binding: Binding<IConfigurable> }) => Promise<void>;\n onAfterConfigure?: (opts: {\n binding: Binding<IConfigurable>;\n instance: IConfigurable;\n }) => Promise<void>;\n}\n\n/** What the helper replaced, so every path puts it back. */\ninterface IPatch {\n restore: () => void;\n}\n\nconst matchesTarget = (opts: {\n targets: TBootProbeTarget[];\n binding: IProbeBinding;\n instance: IConfigurable;\n}): boolean => {\n const { targets, binding, instance } = opts;\n const className: string | undefined = instance?.constructor?.name;\n\n return targets.some((target) =>\n typeof target === 'string'\n ? target === binding.key || target === className\n : instance?.constructor === target,\n );\n};\n\nconst fail = (message: string): never => {\n throw getError({ message: `[ApplicationBootAssertion.assert] ${message}` });\n};\n\n/** Replaces `object[name]` and returns the way back, even when `name` was inherited. */\nconst patchProperty = (opts: { object: object; name: string; value: unknown }): IPatch => {\n const { object, name, value } = opts;\n const descriptor = Object.getOwnPropertyDescriptor(object, name);\n\n Object.defineProperty(object, name, { value, configurable: true, writable: true });\n\n return {\n restore: () => {\n if (descriptor) {\n Object.defineProperty(object, name, descriptor);\n\n return;\n }\n\n Reflect.deleteProperty(object, name);\n },\n };\n};\n\nconst normalizePath = (path: string): string => {\n const withParams = path.replace(/:[A-Za-z0-9_]+/g, ':param').replace(/\\/{2,}/g, '/');\n\n return withParams.length > 1 ? withParams.replace(/\\/$/, '') : withParams;\n};\n\n/** The helper's own check: IGNIS mounts a method and path twice without complaint, and the first one wins. */\nconst assertNoDuplicateRoutes = (opts: { application: BaseApplication }): void => {\n const { application } = opts;\n // signature -> controller key -> how many times that controller declares it\n const mounted = new Map<string, Map<string, number>>();\n\n const record = (signature: string, key: string, declarations: number): void => {\n const owners = mounted.get(signature) ?? new Map<string, number>();\n owners.set(key, Math.max(owners.get(key) ?? 0, declarations));\n mounted.set(signature, owners);\n };\n\n for (const binding of application.findByTag<AbstractRestController>({\n tag: BindingNamespaces.CONTROLLER,\n })) {\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n const metadata = target\n ? MetadataRegistry.getInstance().getControllerMetadata({ target })\n : undefined;\n\n if (!metadata?.path || metadata.transport === ControllerTransports.GRPC) {\n continue;\n }\n\n // A bound controller is a class; this narrows it for the `prototype` read below.\n if (!isClass(target)) {\n continue;\n }\n\n const instance = application.get<AbstractRestController>({\n key: binding.key,\n isOptional: true,\n });\n\n // Hono's `routes` has one entry PER HANDLER (a validator, an authenticate and the handler of one route are three\n // entries with the same method and path), so an entry is not a declaration: a controller counts once per signature.\n for (const route of instance?.getRouter().routes ?? []) {\n if (route.method === NON_ROUTE_METHOD) {\n continue;\n }\n\n record(`${route.method} ${normalizePath(`${metadata.path}/${route.path}`)}`, binding.key, 1);\n }\n\n // What the router cannot show: one controller declaring a method and path twice. Decorated routes are one\n // metadata entry per declaration, so those are counted there.\n const declared = new Map<string, number>();\n\n for (const route of MetadataRegistry.getInstance()\n .getRoutes({ target: target.prototype })\n ?.values() ?? []) {\n const signature = `${String(route.method).toUpperCase()} ${normalizePath(`${metadata.path}/${route.path}`)}`;\n declared.set(signature, (declared.get(signature) ?? 0) + 1);\n }\n\n for (const [signature, declarations] of declared) {\n record(signature, binding.key, declarations);\n }\n }\n\n const duplicates = [...mounted.entries()].filter(\n ([, owners]) =>\n owners.size > 1 || [...owners.values()].some((declarations) => declarations > 1),\n );\n\n if (duplicates.length === 0) {\n return;\n }\n\n const lines = duplicates.map(\n ([signature, owners]) =>\n `${signature} | controllers: ${[...owners]\n .map(([key, declarations]) =>\n declarations > 1 ? `${key} (declared ${declarations} times)` : key,\n )\n .join(', ')}`,\n );\n fail(\n `${duplicates.length} route(s) are mounted more than once, and only the first one answers | ${lines.join(' ; ')} | This is the helper's own check (IGNIS boot does not detect it); pass { routes: false } to turn it off`,\n );\n};\n\n/**\n * Proves an IGNIS application boots, without a datasource connection, a socket or a secrets provider:\n * it runs the application's own boot sequence (`init()` then `initialize()`) and never calls `start()`,\n * so no socket is opened and no post-start hook runs.\n *\n * Datasources are bound and resolved but not configured, unless named in `keepDataSources`; the\n * secrets steps are skipped; every other step and every component runs as in a real boot. A component\n * that opens Redis, Kafka or S3 in `binding()` therefore runs for real: name it in `skipComponents`.\n * `setupMiddlewares()` is not run: it is the application's own start-time step, user code that may open\n * connections, and the probe cannot know it is free of side effects. The framework's default stack (CORS, body\n * limit, request id) is a boot step of `initialize()`, so an invalid `configs.middlewares` value still fails here.\n * When the boot fails inside a component, one warning names it; the rejection is still the original error. When the\n * boot fails, the rejection is the original error. The application stays booted and is returned;\n * a failed boot leaves a half-booted instance, so build a new one rather than reuse it.\n *\n * It wraps `registerDynamicBindings` and `getBootSequence` on THIS instance only (an application's\n * own override of either still runs) and restores them whatever happens.\n *\n * It owns the process-wide `AuthorizationEnforcerRegistry` for the duration of the check: it resets it before it\n * boots, so a second boot in the same process (another probe, or a test boot after this one) does not fail with\n * `Enforcer already registered`. An application still running in the same process loses its enforcer registrations\n * and its authorize options, so its requests are then decided by the no-enforcer default (deny unless configured\n * otherwise): do not run the probe in a process that serves an application.\n *\n * @example\n * ```typescript\n * import { ApplicationBootAssertion } from '@venizia/ignis/testing';\n * import { test } from 'bun:test';\n * import { Application } from './application';\n *\n * test('the application boots offline', async () => {\n * await ApplicationBootAssertion.assert({\n * application: () => new Application({ scope: 'Application', config: { host: '127.0.0.1', port: 0, path: { base: '/', isStrict: true } } }),\n * options: { skipComponents: ['MailComponent'], allowNoControllers: true },\n * });\n * });\n * ```\n */\nexport class ApplicationBootAssertion {\n static async assert<Application extends BaseApplication>(opts: {\n application: Application | (() => Application | Promise<Application>);\n options?: IAssertApplicationBootsOptions;\n }): Promise<Application> {\n const { application, options = {} } = opts;\n const {\n keepDataSources = [],\n skipComponents = [],\n skipSteps = DEFAULT_SKIPPED_STEPS,\n verifyBindings = true,\n skipBindings = [],\n allowNoControllers = false,\n routes = true,\n } = options;\n\n for (const step of skipSteps) {\n if (!ServerBootSteps.isValid(step)) {\n fail(\n `Unknown boot step in skipSteps: '${String(step)}' | Expected one of: ${[...ServerBootSteps.SCHEME_SET].join(', ')}`,\n );\n }\n }\n\n let target: Application;\n\n if (typeof application === 'function') {\n const built = await application();\n target = built;\n } else {\n target = application;\n }\n\n if (\n bootedApplications.has(target) ||\n Object.keys(target['registeredBindings'] ?? {}).length > 0\n ) {\n fail(\n `This application instance was already booted | A failed or finished boot leaves registrations behind, so build a new instance (pass a factory) for each call`,\n );\n }\n\n bootedApplications.add(target);\n\n for (const name of WRAPPED_METHODS) {\n if (typeof target[name] !== 'function') {\n fail(\n `The kernel method '${name}' is missing on this application | The helper cannot keep a boot offline without it, so it refuses to boot`,\n );\n }\n }\n\n const skippedSteps = new Set<string>(skipSteps);\n const patches: IPatch[] = [];\n let sweepsSeen = 0;\n // The components whose `configure()` is running, innermost last: when the boot rejects, the last one is where it failed.\n const configuringComponents: string[] = [];\n\n const neutralise = async (entry: {\n namespace: string;\n binding: Binding<IConfigurable>;\n }): Promise<void> => {\n const { namespace, binding } = entry;\n const isDataSource = namespace === BindingNamespaces.DATASOURCE;\n const isComponent = namespace === BindingNamespaces.COMPONENT;\n\n if (!isDataSource && !isComponent) {\n return;\n }\n\n const instance = target.get<IConfigurable>({ key: binding.key, isOptional: false });\n\n if (typeof instance?.configure !== 'function') {\n return;\n }\n\n const shouldRun = isDataSource\n ? matchesTarget({ targets: keepDataSources, binding, instance })\n : !matchesTarget({ targets: skipComponents, binding, instance });\n\n if (shouldRun) {\n return;\n }\n\n patches.push(patchProperty({ object: instance, name: 'configure', value: async () => {} }));\n };\n\n const originalRegisterDynamicBindings: (opts: IDynamicBindingsOptions) => Promise<void> =\n target['registerDynamicBindings'];\n const originalGetBootSequence: () => Array<{ name: string }> = target['getBootSequence'];\n\n const wrappedRegister = async (sweepOptions: IDynamicBindingsOptions): Promise<void> => {\n sweepsSeen += 1;\n const userBefore = sweepOptions.onBeforeConfigure;\n const userAfter = sweepOptions.onAfterConfigure;\n\n return originalRegisterDynamicBindings.call(target, {\n ...sweepOptions,\n onBeforeConfigure: async ({ binding }) => {\n await neutralise({ namespace: sweepOptions.namespace, binding });\n\n if (sweepOptions.namespace === BindingNamespaces.COMPONENT) {\n const instance = target.get<IConfigurable>({ key: binding.key, isOptional: true });\n configuringComponents.push(String(instance?.constructor?.name ?? binding.key));\n }\n\n await userBefore?.({ binding });\n },\n onAfterConfigure: async ({ binding, instance }) => {\n if (sweepOptions.namespace === BindingNamespaces.COMPONENT) {\n configuringComponents.pop();\n }\n\n await userAfter?.({ binding, instance });\n },\n });\n };\n\n patches.push(\n patchProperty({ object: target, name: 'registerDynamicBindings', value: wrappedRegister }),\n );\n patches.push(\n patchProperty({\n object: target,\n name: 'getBootSequence',\n value: () =>\n originalGetBootSequence.call(target).filter((step) => !skippedSteps.has(step.name)),\n }),\n );\n\n if (target['registerDynamicBindings'] !== wrappedRegister) {\n patches.forEach((patch) => patch.restore());\n fail(\n `The wrap of 'registerDynamicBindings' did not take effect | Refusing to boot against real infrastructure`,\n );\n }\n\n const configs = target['configs'];\n const originalBootChecks = configs.bootChecks;\n const originalBinding = originalBootChecks?.binding;\n configs.bootChecks = {\n ...originalBootChecks,\n binding: {\n allowManual: originalBinding?.allowManual ?? true,\n allowOverride: originalBinding?.allowOverride ?? true,\n doVerify: false,\n },\n };\n\n AuthorizationEnforcerRegistry.getInstance().reset();\n\n try {\n if (!target.isBound({ key: CoreBindings.APPLICATION_INSTANCE })) {\n target.init();\n }\n\n await target.initialize();\n\n const sweepsExpected = [\n ServerBootSteps.REGISTER_DATA_SOURCES,\n ServerBootSteps.REGISTER_COMPONENTS,\n ServerBootSteps.REGISTER_CONTRIBUTED_DATA_SOURCES,\n ].some((step) => !skippedSteps.has(step));\n\n if (sweepsExpected && sweepsSeen === 0) {\n fail(\n `The boot never went through 'registerDynamicBindings' | The wrap did not take effect, so datasources may have been configured`,\n );\n }\n\n if (verifyBindings) {\n BindingVerifier.assertResolve({\n container: target,\n namespaces: [BindingNamespaces.SERVICE, BindingNamespaces.REPOSITORY],\n skip: skipBindings,\n scope: 'verifyBindings',\n });\n }\n\n if (\n !allowNoControllers &&\n target.findByTag({ tag: BindingNamespaces.CONTROLLER }).length === 0\n ) {\n fail(\n `The application registered no controller | A boot that registers nothing proves nothing: check the artifact index (for example the AutoArtifacts plugin under 'bun test'), or pass { allowNoControllers: true }`,\n );\n }\n\n if (routes) {\n assertNoDuplicateRoutes({ application: target });\n }\n\n return target;\n } catch (error) {\n const failing = configuringComponents.at(-1);\n\n if (failing) {\n target.logger\n .for('ApplicationBootAssertion.assert')\n .warn(\n `The boot failed inside component ${failing} | If it needs infrastructure, skipComponents: ['${failing}'] skips it, and skipBindings lists the services that depend on it`,\n );\n }\n\n throw error;\n } finally {\n for (const patch of patches.reverse()) {\n patch.restore();\n }\n\n if (originalBootChecks === undefined) {\n delete configs.bootChecks;\n } else {\n configs.bootChecks = originalBootChecks;\n }\n }\n }\n}\n"]}
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@hono/zod-openapi": "^1.6.3",
|
|
16
16
|
"@scalar/hono-api-reference": "^0.12.13",
|
|
17
|
-
"@venizia/ignis": "0.4.8
|
|
18
|
-
"@venizia/ignis-boot": "0.4.8
|
|
19
|
-
"@venizia/ignis-helpers": "0.4.8
|
|
17
|
+
"@venizia/ignis": "0.4.8",
|
|
18
|
+
"@venizia/ignis-boot": "0.4.8",
|
|
19
|
+
"@venizia/ignis-helpers": "0.4.8",
|
|
20
20
|
"hono": "^4.13.13",
|
|
21
21
|
"winston": "^3.19.0",
|
|
22
22
|
"winston-daily-rotate-file": "^5.0.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/bun": "^1.4.3",
|
|
27
|
-
"@venizia/dev-configs": "0.4.8
|
|
27
|
+
"@venizia/dev-configs": "0.4.8",
|
|
28
28
|
"eslint": "^10.13.0",
|
|
29
29
|
"oxlint": "1.89.0",
|
|
30
30
|
"oxlint-tsgolint": "7.0.2004",
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
"dependencies": {},
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/bun": "^1.4.3",
|
|
7
|
-
"@venizia/dev-configs": "0.4.8
|
|
8
|
-
"@venizia/ignis": "0.4.8
|
|
7
|
+
"@venizia/dev-configs": "0.4.8",
|
|
8
|
+
"@venizia/ignis": "0.4.8",
|
|
9
9
|
"eslint": "^10.13.0",
|
|
10
10
|
"oxlint": "1.89.0",
|
|
11
11
|
"oxlint-tsgolint": "7.0.2004",
|
|
12
12
|
"typescript": "^6.0.3"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@venizia/ignis": "0.4.8
|
|
15
|
+
"@venizia/ignis": "0.4.8"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"typecheck": "bun check",
|