@venizia/ignis 0.4.8-16 → 0.4.8-17
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/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +4 -1
- 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 +2 -1
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +2 -2
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +1 -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/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/helpers/transporters/amazon-ses-transporter.helper.js +7 -2
- 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.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.map +1 -1
- package/dist/esm/components/mail/services/mail.service.d.ts +1 -2
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +3 -4
- package/dist/esm/components/mail/services/template.service.js +1 -1
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/header.utility.d.ts +1 -1
- package/dist/esm/components/mail/utilities/header.utility.js +1 -1
- package/dist/esm/components/mail/utilities/header.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/static-asset/common/types.d.ts +35 -13
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +2 -2
- package/dist/esm/components/static-asset/controller/routes/context.d.ts +4 -3
- package/dist/esm/components/static-asset/controller/routes/context.js.map +1 -1
- package/dist/esm/components/static-asset/utilities/meta-link.utility.d.ts +5 -5
- package/dist/esm/components/static-asset/utilities/meta-link.utility.js.map +1 -1
- package/dist/esm/components/static-asset/utilities/toggle.utility.d.ts +3 -11
- package/dist/esm/components/static-asset/utilities/toggle.utility.js +3 -14
- package/dist/esm/components/static-asset/utilities/toggle.utility.js.map +1 -1
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AnyType } from '@venizia/ignis-helpers/common';
|
|
2
1
|
import type { IMailTransport, TMailOptions } from '../common/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Type guards for the mail component. Each takes its value as a positional parameter, not an options
|
|
@@ -7,8 +6,8 @@ import type { IMailTransport, TMailOptions } from '../common/index.js';
|
|
|
7
6
|
*/
|
|
8
7
|
export declare class MailTypeUtility {
|
|
9
8
|
/** Whether `value` is a transport: `send` and `verify` are functions, and `close` is a function or absent. */
|
|
10
|
-
static isTransport(value:
|
|
9
|
+
static isTransport(value: unknown): value is IMailTransport;
|
|
11
10
|
/** Whether `options` has a string `provider` and a truthy `config`; the shape of `config` is not checked. */
|
|
12
|
-
static isValidOptions(options:
|
|
11
|
+
static isValidOptions(options: unknown): options is TMailOptions;
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=type.utility.d.ts.map
|
|
@@ -9,14 +9,14 @@ export class MailTypeUtility {
|
|
|
9
9
|
if (!value || typeof value !== 'object') {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
if (typeof transport.send !== 'function') {
|
|
12
|
+
if (typeof Reflect.get(value, 'send') !== 'function') {
|
|
14
13
|
return false;
|
|
15
14
|
}
|
|
16
|
-
if (typeof
|
|
15
|
+
if (typeof Reflect.get(value, 'verify') !== 'function') {
|
|
17
16
|
return false;
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
const close = Reflect.get(value, 'close');
|
|
19
|
+
if (close !== undefined && typeof close !== 'function') {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
return true;
|
|
@@ -26,11 +26,10 @@ export class MailTypeUtility {
|
|
|
26
26
|
if (!options || typeof options !== 'object') {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
if (typeof opts.provider !== 'string') {
|
|
29
|
+
if (typeof Reflect.get(options, 'provider') !== 'string') {
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
|
-
if (!
|
|
32
|
+
if (!Reflect.get(options, 'config')) {
|
|
34
33
|
return false;
|
|
35
34
|
}
|
|
36
35
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/type.utility.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/type.utility.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B,8GAA8G;IAC9G,MAAM,CAAC,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;YACrD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,UAAU,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEnD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6GAA6G;IAC7G,MAAM,CAAC,cAAc,CAAC,OAAgB;QACpC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { IMailTransport, TMailOptions } from '../common';\n\n/**\n * Type guards for the mail component. Each takes its value as a positional parameter, not an options\n * object (V-C-02): a type predicate narrows its own parameter, so `{ value }` could not narrow the\n * caller's variable.\n */\nexport class MailTypeUtility {\n /** Whether `value` is a transport: `send` and `verify` are functions, and `close` is a function or absent. */\n static isTransport(value: unknown): value is IMailTransport {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n if (typeof Reflect.get(value, 'send') !== 'function') {\n return false;\n }\n\n if (typeof Reflect.get(value, 'verify') !== 'function') {\n return false;\n }\n\n const close: unknown = Reflect.get(value, 'close');\n\n if (close !== undefined && typeof close !== 'function') {\n return false;\n }\n\n return true;\n }\n\n /** Whether `options` has a string `provider` and a truthy `config`; the shape of `config` is not checked. */\n static isValidOptions(options: unknown): options is TMailOptions {\n if (!options || typeof options !== 'object') {\n return false;\n }\n\n if (typeof Reflect.get(options, 'provider') !== 'string') {\n return false;\n }\n\n if (!Reflect.get(options, 'config')) {\n return false;\n }\n\n return true;\n }\n}\n"]}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import type { BaseRestController, IAuthRouteConfig, TRouteAuthConfig, TRouteContext } from '../../../base/index.js';
|
|
2
2
|
import type { z } from '@hono/zod-openapi';
|
|
3
3
|
import type { IDuration } from '@venizia/ignis-helpers/common';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TTableInsert, TTableObject } from '@venizia/ignis-connectors/postgres';
|
|
5
|
+
import type { TWhere } from '@venizia/ignis-filter';
|
|
6
|
+
import type { TToggle } from '@venizia/ignis-kernel';
|
|
5
7
|
import type { DiskHelper, IBucketRef, IFileStat, IObjectLocation, IObjectRef, IStorageHelper, IUploadResult, StorageTypes, TUploadNaming } from '@venizia/ignis-helpers';
|
|
6
8
|
import type { BunS3Helper } from '@venizia/ignis-helpers/bun-s3';
|
|
7
9
|
import type { TConstValue, TValueOrAsyncResolver, ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
8
|
-
import type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models/index.js';
|
|
10
|
+
import type { TMetaLink, TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models/index.js';
|
|
9
11
|
import type { StaticAssetRouteKeys, TStaticAssetTokenStage } from './constants.js';
|
|
10
12
|
import type { StaticAssetPinnedFile } from '../utilities/pinned-file.utility.js';
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
* the options. One shape for every switch, so an option is never read from a feature that is off.
|
|
14
|
-
*/
|
|
15
|
-
export type TToggle<Options extends object = Record<never, never>> = {
|
|
16
|
-
use: false;
|
|
17
|
-
} | ({
|
|
18
|
-
use: true;
|
|
19
|
-
} & Options);
|
|
13
|
+
/** The toggle type, shared with the controllers: defined in the kernel. */
|
|
14
|
+
export type { TToggle };
|
|
20
15
|
/** The storage backends a static asset entry can serve from: the helpers that declare one. */
|
|
21
16
|
export type TStaticAssetStorageType = typeof StorageTypes.DISK | typeof StorageTypes.BUN_S3;
|
|
22
17
|
/** Decides the key one uploaded file is stored under. `defaultKey` is what IGNIS would have written - the scope and the default naming - so the hook may keep it, extend it or ignore it. */
|
|
@@ -162,9 +157,37 @@ export interface IStaticAssetValidateResult<Issue> extends IStaticAssetValidatio
|
|
|
162
157
|
export type TStaticAssetUploadPolicyRequest = {
|
|
163
158
|
files: TStaticAssetUploadPolicyFile[];
|
|
164
159
|
};
|
|
160
|
+
/** The repository verbs the component calls, on MetaLink rows. A `DefaultCRUDRepository` over any `TMetaLinkCompatibleSchema` table satisfies it, and so does a small fake in a test. The contract checks the select row only (see the static-asset usage page for what that leaves to the table). */
|
|
161
|
+
export interface IMetaLinkRepository {
|
|
162
|
+
create(opts: {
|
|
163
|
+
data: TTableInsert<TMetaLinkSchema>;
|
|
164
|
+
}): Promise<{
|
|
165
|
+
count: number;
|
|
166
|
+
data: TMetaLink;
|
|
167
|
+
}>;
|
|
168
|
+
updateBy(opts: {
|
|
169
|
+
data: Partial<TTableInsert<TMetaLinkSchema>>;
|
|
170
|
+
where: TWhere<TMetaLink>;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
count: number;
|
|
173
|
+
data: TMetaLink[] | null;
|
|
174
|
+
}>;
|
|
175
|
+
updateById(opts: {
|
|
176
|
+
id: string;
|
|
177
|
+
data: Partial<TTableInsert<TMetaLinkSchema>>;
|
|
178
|
+
}): Promise<{
|
|
179
|
+
count: number;
|
|
180
|
+
data: TMetaLink;
|
|
181
|
+
}>;
|
|
182
|
+
deleteBy(opts: {
|
|
183
|
+
where: TWhere<TMetaLink>;
|
|
184
|
+
}): Promise<{
|
|
185
|
+
count: number;
|
|
186
|
+
}>;
|
|
187
|
+
}
|
|
165
188
|
/** The MetaLink table belongs to the application. `Schema` defaults to the table IGNIS ships, and widens to any table whose row carries the same fields. */
|
|
166
189
|
export type TMetaLinkConfig<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {
|
|
167
|
-
repository: TValueOrAsyncResolver<
|
|
190
|
+
repository: TValueOrAsyncResolver<IMetaLinkRepository>;
|
|
168
191
|
createMetaLink?: (opts: {
|
|
169
192
|
uploadResult: IUploadResult;
|
|
170
193
|
fileStat: IFileStat;
|
|
@@ -297,5 +320,4 @@ export interface IStaticAssetCommitTokenPayload {
|
|
|
297
320
|
/** Present from `VALIDATED` on: `commit` copies only content that still matches it. */
|
|
298
321
|
pin?: IStaticAssetPin;
|
|
299
322
|
}
|
|
300
|
-
export {};
|
|
301
323
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BaseRestController, IAuthRouteConfig, TRouteAuthConfig, TRouteContext } from '@/base';\nimport type { z } from '@hono/zod-openapi';\nimport type { IDuration } from '@venizia/ignis-helpers/common';\nimport type { DefaultCRUDRepository, TTableObject } from '@venizia/ignis-connectors/postgres';\nimport type {\n DiskHelper,\n IBucketRef,\n IFileStat,\n IObjectLocation,\n IObjectRef,\n IStorageHelper,\n IUploadResult,\n StorageTypes,\n TUploadNaming,\n} from '@venizia/ignis-helpers';\nimport type { BunS3Helper } from '@venizia/ignis-helpers/bun-s3';\nimport type {\n TConstValue,\n TValueOrAsyncResolver,\n ValueOrPromise,\n} from '@venizia/ignis-helpers/common';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models';\nimport type { StaticAssetRouteKeys, TStaticAssetTokenStage } from './constants';\nimport type { StaticAssetPinnedFile } from '../utilities/pinned-file.utility';\n\n/**\n * A feature that is on or off. `{ use: false }` is the whole off state; `{ use: true, ... }` carries\n * the options. One shape for every switch, so an option is never read from a feature that is off.\n */\nexport type TToggle<Options extends object = Record<never, never>> =\n | { use: false }\n | ({ use: true } & Options);\n\n/** The storage backends a static asset entry can serve from: the helpers that declare one. */\nexport type TStaticAssetStorageType = typeof StorageTypes.DISK | typeof StorageTypes.BUN_S3;\n\n/** Decides the key one uploaded file is stored under. `defaultKey` is what IGNIS would have written - the scope and the default naming - so the hook may keep it, extend it or ignore it. */\nexport type TStaticAssetObjectKeyResolver = (opts: {\n bucket: IBucketRef;\n file: TUploadNaming;\n defaultKey: string;\n}) => string;\n\n/** Adds routes of the application's own. Registration order decides a path collision, so the same shape serves both the before and the after hook. */\nexport type TStaticAssetDefineExtraRoutes = (opts: {\n controller: BaseRestController;\n helper: IStorageHelper;\n basePath: string;\n}) => void;\n\n/** Path parameters of the object routes. */\nexport type TStaticAssetObjectParams = { objectName: string };\n\n/** Labels recorded on the MetaLink row of an uploaded object. */\nexport type TStaticAssetUploadLabels = {\n principalType?: string;\n principalId?: string;\n variant?: string;\n /** Display order within the principal. Caller-supplied: deriving it would be a non-atomic read of `max(sequence)` then a write of `max + 1`. */\n sequence?: number;\n};\n\n/** Application-chosen strings the commit token signs for one file. The token is signed, not encrypted: no secrets. */\nexport type TStaticAssetTokenMetadata = Record<string, string>;\n\n/** One file of an upload-policy request. `metadata` is the client's hint: `resolvers.metadata` reads it, and only what that returns is signed. */\nexport type TStaticAssetUploadPolicyFile = {\n fileName: string;\n contentType?: string;\n size?: number;\n metadata?: TStaticAssetTokenMetadata;\n};\n\n/** The decisions of a direct upload that belong to the application, each made on a different call. */\nexport type TStaticAssetDirectUploadResolvers = {\n /**\n * Who the upload belongs to. Called on every direct-upload route: the policy route signs the\n * answer into the commit token, and the other routes refuse a token whose owner differs.\n */\n owner: (opts: { context: TRouteContext }) => ValueOrPromise<string>;\n\n /** Per file, at policy time: what the token signs for it, readable again at validate and commit. Absent, a client that sends `metadata` is refused. */\n metadata?: (opts: {\n context: TRouteContext;\n file: TStaticAssetUploadPolicyFile;\n }) => ValueOrPromise<TStaticAssetTokenMetadata>;\n\n commit?: {\n /** At commit time: the final key, in the same bucket and inside the `keyPrefix`. Absent keeps `defaultKey`. */\n destination?: (opts: {\n owner: string;\n metadata: TStaticAssetTokenMetadata;\n file: { fileName: string };\n defaultKey: string;\n }) => ValueOrPromise<{ key: string }>;\n };\n};\n\n/** Enables the signed-policy upload flow, where the client posts bytes straight to the storage and IGNIS only signs the permission and verifies the commit. */\nexport type TStaticAssetDirectUploadOptions = {\n /**\n * Who may use direct upload. Guards every direct-upload route. There is no safe default for a\n * route that hands out a write credential, so leaving it out is allowed only when the entry's\n * `auth` already authenticates or authorizes: then `auth` is the gate. With neither, the\n * component refuses to start.\n */\n authorize?: (opts: { context: TRouteContext }) => ValueOrPromise<boolean>;\n\n /** What the application decides about an upload; `owner` is required, the rest is optional. */\n resolvers: TStaticAssetDirectUploadResolvers;\n\n /** Signs the commit token. Keep it out of the repository and out of the client. */\n secretKey: string;\n\n /** The ceiling the policy carries as `content-length-range`. A signed PUT cannot express this at all, which is why this is a POST policy. */\n maxBytes: number;\n\n /**\n * The most files one upload-policy request may name; more is a 422.\n *\n * @default StaticAssetDefaults.MAX_UPLOAD_FILES (20)\n */\n maxFiles?: number;\n\n /**\n * Where a policy may write: not empty, ends with `/`, made of valid key segments, and neither\n * inside the entry's `keyPrefix` nor containing it - a pending object must never be readable\n * through the entry's own routes. The final key is NEVER in a policy, so content cannot be\n * replaced after the commit. The lifecycle rule that collects abandoned uploads targets this prefix.\n *\n * @default 'pending/'\n */\n pendingPrefix?: string;\n\n expires?: {\n /**\n * How long the browser may post the bytes: the POST policy's lifetime.\n *\n * @default StoragePresignDefaults.POST_EXPIRES_IN\n */\n upload?: IDuration;\n\n /**\n * How long the commit token stays good, for validating and committing after the upload. The\n * pending object must outlive it, so the lifecycle rule on `pendingPrefix` has to be longer still.\n *\n * @default `upload`\n */\n commit?: IDuration;\n };\n\n /**\n * Checks the pending file. On, the component registers `POST {base}/upload-validate`, which\n * answers the token `commit` takes, and `commit` accepts no other.\n * Build it with `StaticAssetValidation.define`.\n */\n validation: TToggle<IStaticAssetValidation<z.ZodType>>;\n};\n\n/** What a validation answers: whether the file may be committed, and the problems the user should see. */\nexport interface IStaticAssetValidationResult<Issue> {\n isValid: boolean;\n issues: Issue[];\n}\n\n/**\n * The application's own check of an uploaded file, run on the PENDING object before anything is\n * committed. The component owns the route and the refusal; the application owns only this logic.\n * Build it with `StaticAssetValidation.define` so the handler is typed by `issueSchema`.\n */\nexport interface IStaticAssetValidation<IssueSchema extends z.ZodType> {\n /** The shape of ONE issue. It types the handler's answer and documents the route's response. */\n issueSchema: IssueSchema;\n\n /** Runs once per `upload-validate`. Read the file through `file`: every read is pinned to the content `commit` will copy. */\n handler: (opts: {\n file: StaticAssetPinnedFile;\n owner: string;\n metadata: TStaticAssetTokenMetadata;\n }) => ValueOrPromise<IStaticAssetValidationResult<z.infer<IssueSchema>>>;\n}\n\n/** What `validate` answers. `commitToken` is present only when the file is valid: it is the token `commit` takes. */\nexport interface IStaticAssetValidateResult<Issue> extends IStaticAssetValidationResult<Issue> {\n commitToken?: string;\n}\n\n/** Body of the upload policy route: the files the client intends to upload. */\nexport type TStaticAssetUploadPolicyRequest = { files: TStaticAssetUploadPolicyFile[] };\n\n/** The MetaLink table belongs to the application. `Schema` defaults to the table IGNIS ships, and widens to any table whose row carries the same fields. */\nexport type TMetaLinkConfig<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {\n repository: TValueOrAsyncResolver<DefaultCRUDRepository<Schema>>;\n createMetaLink?: (opts: {\n uploadResult: IUploadResult;\n fileStat: IFileStat;\n /** The caller's labels: form fields on an upload, beside the commit token on a direct one. */\n labels: TStaticAssetUploadLabels;\n }) => ValueOrPromise<{ count: number; data: TTableObject<Schema> }>;\n};\n\n/** The part of a built-in route an application may change. `authenticate` and `authorize` replace the entry's `auth` for this route, and `{ skip: true }` leaves it open. */\nexport type TStaticAssetRouteConfig = Partial<\n Omit<IAuthRouteConfig, 'method' | 'request' | 'responses' | 'authenticate' | 'authorize'>\n> &\n TRouteAuthConfig;\n\n/** Authentication and authorization for every built-in route of an entry; a route's own `authenticate`/`authorize` replaces it for that route. */\nexport type TStaticAssetAuth = TRouteAuthConfig & {\n /**\n * `{ use: true }` leaves `getObjectByName` and `downloadObjectByName` unauthenticated, so a\n * browser can show an image without a token. `listObjects` is NOT public: listing a bucket is not\n * reading an object.\n *\n * @default { use: false }\n */\n publicRead?: TToggle;\n};\n\n/** The name of a built-in route, the key of `routes`. */\nexport type TStaticAssetRouteKey = TConstValue<typeof StaticAssetRouteKeys>;\n\n/**\n * What each built-in route does: `{ use: false }` turns it off, `{ use: true, ... }` turns it on\n * with those overrides. A route left out is on as built.\n */\nexport type TStaticAssetRoutes = Partial<\n Record<TStaticAssetRouteKey, TToggle<TStaticAssetRouteConfig>>\n>;\n\n/** Uploading through the application: the browser sends the bytes to `POST /objects` and the application writes them to the storage. */\nexport type TStaticAssetServerUploadOptions = {\n /** Largest file the route accepts. Absent means no ceiling. Checked against `content-length` before the body is read, then per file after parsing. */\n maxBytes?: number;\n\n /**\n * The most file parts one request may carry; more is refused with 413 before anything is written.\n *\n * @default StaticAssetDefaults.MAX_UPLOAD_FILES (20)\n */\n maxFiles?: number;\n\n /** The one hook that decides the key an uploaded file is stored under. Absent keeps the default naming. Under a `keyPrefix` a key outside the scope is refused, never rewritten. */\n objectKey?: TStaticAssetObjectKeyResolver;\n};\n\n/** Direct upload is a POST policy, which only S3 can sign, and its pending objects stay out of the served scope only when the entry has a `keyPrefix`. */\ntype TStaticAssetDirectUploadScope =\n | { keyPrefix?: string; directUpload: { use: false } }\n | { keyPrefix: string; directUpload: { use: true } & TStaticAssetDirectUploadOptions };\n\n/** The storage helper decides which direct upload shapes are possible. */\ntype TStaticAssetStorage =\n | ({ helper: BunS3Helper } & TStaticAssetDirectUploadScope)\n | { helper: DiskHelper; keyPrefix?: string; directUpload: { use: false } };\n\n/** One storage backend with its generated controller. Every switch is a toggle; a toggle left out is a type error, so nothing is on or off by accident. */\nexport type TStaticAssetEntry<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {\n basePath: string;\n\n /** The controller's name. Absent, it is derived from the entry's key. */\n name?: string;\n\n /** The single bucket every route uses. The function form is read per request, so an environment variable can be read lazily. */\n bucket: TValueOrAsyncResolver<string>;\n\n /**\n * The key scope this entry owns, e.g. `inventory/`. Every route refuses a key outside it as a\n * 404 without calling the storage, `listObjects` lists only inside it, and an upload key must\n * land inside it. `maxFolderDepth` counts the folders below it. Required with\n * `directUpload`: it keeps the pending prefix outside everything the routes serve.\n *\n * @default every key in the bucket\n */\n keyPrefix?: string;\n\n /**\n * Folders a key may nest below the `keyPrefix`, for every route of the entry: reads and deletes\n * too, so it holds for keys that arrive by direct upload or ingest.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * `true` serves a raw nested object path (`/objects/photos/2024/f.jpg`) - a URL shape change; a percent-encoded path keeps working either way.\n *\n * @default false\n */\n rawObjectPath?: boolean;\n\n /** The link stored and returned for an object. Absent builds the URL of this controller's own object route. */\n link?: (opts: IObjectLocation) => string;\n\n /** Authentication and authorization of every built-in route of this entry. Absent leaves every route open; `publicRead` is the only way a read route is public on purpose. */\n auth?: TStaticAssetAuth;\n\n serverUpload: TToggle<TStaticAssetServerUploadOptions>;\n\n /** Every upload also writes a MetaLink row, and the object's deletion removes it. */\n metaLink: TToggle<TMetaLinkConfig<Schema>>;\n\n routes?: TStaticAssetRoutes;\n\n extend?: {\n /** Registered BEFORE every built-in route, so a literal path wins over the catch-all `rawObjectPath` produces. Hono matches in registration order. */\n before?: TStaticAssetDefineExtraRoutes;\n /** Registered after every built-in route. */\n after?: TStaticAssetDefineExtraRoutes;\n };\n} & TStaticAssetStorage;\n\n/** Static asset entries keyed by an application-chosen name; each key becomes one controller. */\nexport type TStaticAssetComponentOptions<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> = Record<string, TStaticAssetEntry<Schema>>;\n\n/** The content a validation read: the ETag, and the version id when the storage has real versions. */\nexport interface IStaticAssetPin {\n etag: string;\n versionId?: string;\n}\n\n/**\n * What a commit token binds: the pending object a policy was issued for, when the grant dies and,\n * who it was issued to and the application's own metadata for the file.\n */\nexport interface IStaticAssetCommitTokenPayload {\n bucket: IBucketRef;\n object: IObjectRef;\n expiresAt: number;\n /** The token commits only for this owner. */\n owner: string;\n /** What `resolvers.metadata` returned for the file; `{}` without one. Signed, not encrypted. */\n metadata: TStaticAssetTokenMetadata;\n stage: TStaticAssetTokenStage;\n /** Present from `VALIDATED` on: `commit` copies only content that still matches it. */\n pin?: IStaticAssetPin;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BaseRestController, IAuthRouteConfig, TRouteAuthConfig, TRouteContext } from '@/base';\nimport type { z } from '@hono/zod-openapi';\nimport type { IDuration } from '@venizia/ignis-helpers/common';\nimport type { TTableInsert, TTableObject } from '@venizia/ignis-connectors/postgres';\nimport type { TWhere } from '@venizia/ignis-filter';\nimport type { TToggle } from '@venizia/ignis-kernel';\nimport type {\n DiskHelper,\n IBucketRef,\n IFileStat,\n IObjectLocation,\n IObjectRef,\n IStorageHelper,\n IUploadResult,\n StorageTypes,\n TUploadNaming,\n} from '@venizia/ignis-helpers';\nimport type { BunS3Helper } from '@venizia/ignis-helpers/bun-s3';\nimport type {\n TConstValue,\n TValueOrAsyncResolver,\n ValueOrPromise,\n} from '@venizia/ignis-helpers/common';\nimport type { TMetaLink, TMetaLinkCompatibleSchema, TMetaLinkSchema } from '../models';\nimport type { StaticAssetRouteKeys, TStaticAssetTokenStage } from './constants';\nimport type { StaticAssetPinnedFile } from '../utilities/pinned-file.utility';\n\n/** The toggle type, shared with the controllers: defined in the kernel. */\nexport type { TToggle };\n\n/** The storage backends a static asset entry can serve from: the helpers that declare one. */\nexport type TStaticAssetStorageType = typeof StorageTypes.DISK | typeof StorageTypes.BUN_S3;\n\n/** Decides the key one uploaded file is stored under. `defaultKey` is what IGNIS would have written - the scope and the default naming - so the hook may keep it, extend it or ignore it. */\nexport type TStaticAssetObjectKeyResolver = (opts: {\n bucket: IBucketRef;\n file: TUploadNaming;\n defaultKey: string;\n}) => string;\n\n/** Adds routes of the application's own. Registration order decides a path collision, so the same shape serves both the before and the after hook. */\nexport type TStaticAssetDefineExtraRoutes = (opts: {\n controller: BaseRestController;\n helper: IStorageHelper;\n basePath: string;\n}) => void;\n\n/** Path parameters of the object routes. */\nexport type TStaticAssetObjectParams = { objectName: string };\n\n/** Labels recorded on the MetaLink row of an uploaded object. */\nexport type TStaticAssetUploadLabels = {\n principalType?: string;\n principalId?: string;\n variant?: string;\n /** Display order within the principal. Caller-supplied: deriving it would be a non-atomic read of `max(sequence)` then a write of `max + 1`. */\n sequence?: number;\n};\n\n/** Application-chosen strings the commit token signs for one file. The token is signed, not encrypted: no secrets. */\nexport type TStaticAssetTokenMetadata = Record<string, string>;\n\n/** One file of an upload-policy request. `metadata` is the client's hint: `resolvers.metadata` reads it, and only what that returns is signed. */\nexport type TStaticAssetUploadPolicyFile = {\n fileName: string;\n contentType?: string;\n size?: number;\n metadata?: TStaticAssetTokenMetadata;\n};\n\n/** The decisions of a direct upload that belong to the application, each made on a different call. */\nexport type TStaticAssetDirectUploadResolvers = {\n /**\n * Who the upload belongs to. Called on every direct-upload route: the policy route signs the\n * answer into the commit token, and the other routes refuse a token whose owner differs.\n */\n owner: (opts: { context: TRouteContext }) => ValueOrPromise<string>;\n\n /** Per file, at policy time: what the token signs for it, readable again at validate and commit. Absent, a client that sends `metadata` is refused. */\n metadata?: (opts: {\n context: TRouteContext;\n file: TStaticAssetUploadPolicyFile;\n }) => ValueOrPromise<TStaticAssetTokenMetadata>;\n\n commit?: {\n /** At commit time: the final key, in the same bucket and inside the `keyPrefix`. Absent keeps `defaultKey`. */\n destination?: (opts: {\n owner: string;\n metadata: TStaticAssetTokenMetadata;\n file: { fileName: string };\n defaultKey: string;\n }) => ValueOrPromise<{ key: string }>;\n };\n};\n\n/** Enables the signed-policy upload flow, where the client posts bytes straight to the storage and IGNIS only signs the permission and verifies the commit. */\nexport type TStaticAssetDirectUploadOptions = {\n /**\n * Who may use direct upload. Guards every direct-upload route. There is no safe default for a\n * route that hands out a write credential, so leaving it out is allowed only when the entry's\n * `auth` already authenticates or authorizes: then `auth` is the gate. With neither, the\n * component refuses to start.\n */\n authorize?: (opts: { context: TRouteContext }) => ValueOrPromise<boolean>;\n\n /** What the application decides about an upload; `owner` is required, the rest is optional. */\n resolvers: TStaticAssetDirectUploadResolvers;\n\n /** Signs the commit token. Keep it out of the repository and out of the client. */\n secretKey: string;\n\n /** The ceiling the policy carries as `content-length-range`. A signed PUT cannot express this at all, which is why this is a POST policy. */\n maxBytes: number;\n\n /**\n * The most files one upload-policy request may name; more is a 422.\n *\n * @default StaticAssetDefaults.MAX_UPLOAD_FILES (20)\n */\n maxFiles?: number;\n\n /**\n * Where a policy may write: not empty, ends with `/`, made of valid key segments, and neither\n * inside the entry's `keyPrefix` nor containing it - a pending object must never be readable\n * through the entry's own routes. The final key is NEVER in a policy, so content cannot be\n * replaced after the commit. The lifecycle rule that collects abandoned uploads targets this prefix.\n *\n * @default 'pending/'\n */\n pendingPrefix?: string;\n\n expires?: {\n /**\n * How long the browser may post the bytes: the POST policy's lifetime.\n *\n * @default StoragePresignDefaults.POST_EXPIRES_IN\n */\n upload?: IDuration;\n\n /**\n * How long the commit token stays good, for validating and committing after the upload. The\n * pending object must outlive it, so the lifecycle rule on `pendingPrefix` has to be longer still.\n *\n * @default `upload`\n */\n commit?: IDuration;\n };\n\n /**\n * Checks the pending file. On, the component registers `POST {base}/upload-validate`, which\n * answers the token `commit` takes, and `commit` accepts no other.\n * Build it with `StaticAssetValidation.define`.\n */\n validation: TToggle<IStaticAssetValidation<z.ZodType>>;\n};\n\n/** What a validation answers: whether the file may be committed, and the problems the user should see. */\nexport interface IStaticAssetValidationResult<Issue> {\n isValid: boolean;\n issues: Issue[];\n}\n\n/**\n * The application's own check of an uploaded file, run on the PENDING object before anything is\n * committed. The component owns the route and the refusal; the application owns only this logic.\n * Build it with `StaticAssetValidation.define` so the handler is typed by `issueSchema`.\n */\nexport interface IStaticAssetValidation<IssueSchema extends z.ZodType> {\n /** The shape of ONE issue. It types the handler's answer and documents the route's response. */\n issueSchema: IssueSchema;\n\n /** Runs once per `upload-validate`. Read the file through `file`: every read is pinned to the content `commit` will copy. */\n handler: (opts: {\n file: StaticAssetPinnedFile;\n owner: string;\n metadata: TStaticAssetTokenMetadata;\n }) => ValueOrPromise<IStaticAssetValidationResult<z.infer<IssueSchema>>>;\n}\n\n/** What `validate` answers. `commitToken` is present only when the file is valid: it is the token `commit` takes. */\nexport interface IStaticAssetValidateResult<Issue> extends IStaticAssetValidationResult<Issue> {\n commitToken?: string;\n}\n\n/** Body of the upload policy route: the files the client intends to upload. */\nexport type TStaticAssetUploadPolicyRequest = { files: TStaticAssetUploadPolicyFile[] };\n\n/** The repository verbs the component calls, on MetaLink rows. A `DefaultCRUDRepository` over any `TMetaLinkCompatibleSchema` table satisfies it, and so does a small fake in a test. The contract checks the select row only (see the static-asset usage page for what that leaves to the table). */\nexport interface IMetaLinkRepository {\n create(opts: {\n data: TTableInsert<TMetaLinkSchema>;\n }): Promise<{ count: number; data: TMetaLink }>;\n updateBy(opts: {\n data: Partial<TTableInsert<TMetaLinkSchema>>;\n where: TWhere<TMetaLink>;\n }): Promise<{ count: number; data: TMetaLink[] | null }>;\n updateById(opts: {\n id: string;\n data: Partial<TTableInsert<TMetaLinkSchema>>;\n }): Promise<{ count: number; data: TMetaLink }>;\n deleteBy(opts: { where: TWhere<TMetaLink> }): Promise<{ count: number }>;\n}\n\n/** The MetaLink table belongs to the application. `Schema` defaults to the table IGNIS ships, and widens to any table whose row carries the same fields. */\nexport type TMetaLinkConfig<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {\n repository: TValueOrAsyncResolver<IMetaLinkRepository>;\n createMetaLink?: (opts: {\n uploadResult: IUploadResult;\n fileStat: IFileStat;\n /** The caller's labels: form fields on an upload, beside the commit token on a direct one. */\n labels: TStaticAssetUploadLabels;\n }) => ValueOrPromise<{ count: number; data: TTableObject<Schema> }>;\n};\n\n/** The part of a built-in route an application may change. `authenticate` and `authorize` replace the entry's `auth` for this route, and `{ skip: true }` leaves it open. */\nexport type TStaticAssetRouteConfig = Partial<\n Omit<IAuthRouteConfig, 'method' | 'request' | 'responses' | 'authenticate' | 'authorize'>\n> &\n TRouteAuthConfig;\n\n/** Authentication and authorization for every built-in route of an entry; a route's own `authenticate`/`authorize` replaces it for that route. */\nexport type TStaticAssetAuth = TRouteAuthConfig & {\n /**\n * `{ use: true }` leaves `getObjectByName` and `downloadObjectByName` unauthenticated, so a\n * browser can show an image without a token. `listObjects` is NOT public: listing a bucket is not\n * reading an object.\n *\n * @default { use: false }\n */\n publicRead?: TToggle;\n};\n\n/** The name of a built-in route, the key of `routes`. */\nexport type TStaticAssetRouteKey = TConstValue<typeof StaticAssetRouteKeys>;\n\n/**\n * What each built-in route does: `{ use: false }` turns it off, `{ use: true, ... }` turns it on\n * with those overrides. A route left out is on as built.\n */\nexport type TStaticAssetRoutes = Partial<\n Record<TStaticAssetRouteKey, TToggle<TStaticAssetRouteConfig>>\n>;\n\n/** Uploading through the application: the browser sends the bytes to `POST /objects` and the application writes them to the storage. */\nexport type TStaticAssetServerUploadOptions = {\n /** Largest file the route accepts. Absent means no ceiling. Checked against `content-length` before the body is read, then per file after parsing. */\n maxBytes?: number;\n\n /**\n * The most file parts one request may carry; more is refused with 413 before anything is written.\n *\n * @default StaticAssetDefaults.MAX_UPLOAD_FILES (20)\n */\n maxFiles?: number;\n\n /** The one hook that decides the key an uploaded file is stored under. Absent keeps the default naming. Under a `keyPrefix` a key outside the scope is refused, never rewritten. */\n objectKey?: TStaticAssetObjectKeyResolver;\n};\n\n/** Direct upload is a POST policy, which only S3 can sign, and its pending objects stay out of the served scope only when the entry has a `keyPrefix`. */\ntype TStaticAssetDirectUploadScope =\n | { keyPrefix?: string; directUpload: { use: false } }\n | { keyPrefix: string; directUpload: { use: true } & TStaticAssetDirectUploadOptions };\n\n/** The storage helper decides which direct upload shapes are possible. */\ntype TStaticAssetStorage =\n | ({ helper: BunS3Helper } & TStaticAssetDirectUploadScope)\n | { helper: DiskHelper; keyPrefix?: string; directUpload: { use: false } };\n\n/** One storage backend with its generated controller. Every switch is a toggle; a toggle left out is a type error, so nothing is on or off by accident. */\nexport type TStaticAssetEntry<Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema> = {\n basePath: string;\n\n /** The controller's name. Absent, it is derived from the entry's key. */\n name?: string;\n\n /** The single bucket every route uses. The function form is read per request, so an environment variable can be read lazily. */\n bucket: TValueOrAsyncResolver<string>;\n\n /**\n * The key scope this entry owns, e.g. `inventory/`. Every route refuses a key outside it as a\n * 404 without calling the storage, `listObjects` lists only inside it, and an upload key must\n * land inside it. `maxFolderDepth` counts the folders below it. Required with\n * `directUpload`: it keeps the pending prefix outside everything the routes serve.\n *\n * @default every key in the bucket\n */\n keyPrefix?: string;\n\n /**\n * Folders a key may nest below the `keyPrefix`, for every route of the entry: reads and deletes\n * too, so it holds for keys that arrive by direct upload or ingest.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * `true` serves a raw nested object path (`/objects/photos/2024/f.jpg`) - a URL shape change; a percent-encoded path keeps working either way.\n *\n * @default false\n */\n rawObjectPath?: boolean;\n\n /** The link stored and returned for an object. Absent builds the URL of this controller's own object route. */\n link?: (opts: IObjectLocation) => string;\n\n /** Authentication and authorization of every built-in route of this entry. Absent leaves every route open; `publicRead` is the only way a read route is public on purpose. */\n auth?: TStaticAssetAuth;\n\n serverUpload: TToggle<TStaticAssetServerUploadOptions>;\n\n /** Every upload also writes a MetaLink row, and the object's deletion removes it. */\n metaLink: TToggle<TMetaLinkConfig<Schema>>;\n\n routes?: TStaticAssetRoutes;\n\n extend?: {\n /** Registered BEFORE every built-in route, so a literal path wins over the catch-all `rawObjectPath` produces. Hono matches in registration order. */\n before?: TStaticAssetDefineExtraRoutes;\n /** Registered after every built-in route. */\n after?: TStaticAssetDefineExtraRoutes;\n };\n} & TStaticAssetStorage;\n\n/** Static asset entries keyed by an application-chosen name; each key becomes one controller. */\nexport type TStaticAssetComponentOptions<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> = Record<string, TStaticAssetEntry<Schema>>;\n\n/** The content a validation read: the ETag, and the version id when the storage has real versions. */\nexport interface IStaticAssetPin {\n etag: string;\n versionId?: string;\n}\n\n/**\n * What a commit token binds: the pending object a policy was issued for, when the grant dies and,\n * who it was issued to and the application's own metadata for the file.\n */\nexport interface IStaticAssetCommitTokenPayload {\n bucket: IBucketRef;\n object: IObjectRef;\n expiresAt: number;\n /** The token commits only for this owner. */\n owner: string;\n /** What `resolvers.metadata` returned for the file; `{}` without one. Signed, not encrypted. */\n metadata: TStaticAssetTokenMetadata;\n stage: TStaticAssetTokenStage;\n /** Present from `VALIDATED` on: `commit` copies only content that still matches it. */\n pin?: IStaticAssetPin;\n}\n"]}
|
|
@@ -21,8 +21,8 @@ export declare class StaticAssetControllerFactory {
|
|
|
21
21
|
scope: string;
|
|
22
22
|
args: unknown;
|
|
23
23
|
task: () => Promise<R>;
|
|
24
|
-
}): Promise<
|
|
25
|
-
normalizeCountData<ResponseSchema
|
|
24
|
+
}): Promise<R>;
|
|
25
|
+
normalizeCountData<ResponseSchema, RequestContext extends import("@venizia/ignis-kernel").TRouteContext<import("hono").Env> = import("@venizia/ignis-kernel").TRouteContext<import("hono").Env>, ResponseData extends {
|
|
26
26
|
count: number;
|
|
27
27
|
data?: import("@venizia/ignis-helpers").TNullable<ResponseSchema>;
|
|
28
28
|
} = {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { BaseRestController, TRouteContext, TRouteHandler } from '../../../../base/controllers/index.js';
|
|
2
2
|
import type { IAuthRouteConfig } from '../../../../base/index.js';
|
|
3
3
|
import type { IBucketRef, IObjectRef } from '@venizia/ignis-helpers';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TConstValue } from '@venizia/ignis-helpers/common';
|
|
5
5
|
import { type TStaticAssetRouteKey } from '../../common/index.js';
|
|
6
6
|
import type { StaticAssetUploadCommitService, StaticAssetUploadPolicyService } from '../../services/index.js';
|
|
7
|
+
import type { TMetaLinkCompatibleSchema } from '../../models/index.js';
|
|
7
8
|
import type { IStaticAssetResolvedEntry } from '../../utilities/entry.utility.js';
|
|
8
9
|
import type { TStaticAssetRouteOverride } from '../../utilities/route-options.utility.js';
|
|
9
10
|
/** The part of an entry a route belongs to: a route is registered only when its feature is on. */
|
|
@@ -16,10 +17,10 @@ export declare class StaticAssetFeatures {
|
|
|
16
17
|
}
|
|
17
18
|
export type TStaticAssetFeature = TConstValue<typeof StaticAssetFeatures>;
|
|
18
19
|
/** What every route reads: the entry, resolved once, plus what only the running controller has. The table is erased at this seam on purpose: inside the routes every read and write is on MetaLink COLUMNS. */
|
|
19
|
-
export interface IStaticAssetRouteEnv extends Omit<IStaticAssetResolvedEntry<
|
|
20
|
+
export interface IStaticAssetRouteEnv extends Omit<IStaticAssetResolvedEntry<TMetaLinkCompatibleSchema>, 'directUpload'> {
|
|
20
21
|
logger: BaseRestController['logger'];
|
|
21
22
|
/** The resolved options with the services the component bound: the instances an application resolves from the container. */
|
|
22
|
-
directUpload?: NonNullable<IStaticAssetResolvedEntry<
|
|
23
|
+
directUpload?: NonNullable<IStaticAssetResolvedEntry<TMetaLinkCompatibleSchema>['directUpload']> & {
|
|
23
24
|
policyService: Pick<StaticAssetUploadPolicyService, 'issuePolicies'>;
|
|
24
25
|
commitService: Pick<StaticAssetUploadCommitService, 'commit' | 'validate'>;
|
|
25
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/components/static-asset/controller/routes/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,iBAAiB,GAGlB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/components/static-asset/controller/routes/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AAOtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAG/E,kGAAkG;AAClG,MAAM,OAAO,mBAAmB;aACd,WAAM,GAAG,QAAQ,CAAC;aAClB,kBAAa,GAAG,cAAc,CAAC;aAC/B,kBAAa,GAAG,cAAc,CAAC;aAC/B,eAAU,GAAG,YAAY,CAAC;aAC1B,cAAS,GAAG,UAAU,CAAC;;AAqCzC,MAAM,OAAO,uBAAuB;IAClC,sHAAsH;IACtH,MAAM,CAAC,cAAc,CAAI,IAA4D;QACnF,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oBAAoB,IAAI,CAAC,OAAO,gCAAgC,IAAI,CAAC,OAAO,SAAS;aAC/F,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,IAK1B;QACC,MAAM,EAAE,GAAG,EAA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from '@/base';\nimport type { IBucketRef, IObjectRef } from '@venizia/ignis-helpers';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n StaticAssetErrors,\n type TStaticAssetObjectParams,\n type TStaticAssetRouteKey,\n} from '../../common';\nimport type {\n StaticAssetUploadCommitService,\n StaticAssetUploadPolicyService,\n} from '../../services';\nimport type { TMetaLinkCompatibleSchema } from '../../models';\nimport type { IStaticAssetResolvedEntry } from '../../utilities/entry.utility';\nimport { StaticAssetKeyScopeUtility } from '../../utilities/key-scope.utility';\nimport type { TStaticAssetRouteOverride } from '../../utilities/route-options.utility';\n\n/** The part of an entry a route belongs to: a route is registered only when its feature is on. */\nexport class StaticAssetFeatures {\n static readonly OBJECT = 'object';\n static readonly SERVER_UPLOAD = 'serverUpload';\n static readonly DIRECT_UPLOAD = 'directUpload';\n static readonly VALIDATION = 'validation';\n static readonly META_LINK = 'metaLink';\n}\n\nexport type TStaticAssetFeature = TConstValue<typeof StaticAssetFeatures>;\n\n/** What every route reads: the entry, resolved once, plus what only the running controller has. The table is erased at this seam on purpose: inside the routes every read and write is on MetaLink COLUMNS. */\nexport interface IStaticAssetRouteEnv extends Omit<\n IStaticAssetResolvedEntry<TMetaLinkCompatibleSchema>,\n 'directUpload'\n> {\n logger: BaseRestController['logger'];\n /** The resolved options with the services the component bound: the instances an application resolves from the container. */\n directUpload?: NonNullable<\n IStaticAssetResolvedEntry<TMetaLinkCompatibleSchema>['directUpload']\n > & {\n policyService: Pick<StaticAssetUploadPolicyService, 'issuePolicies'>;\n commitService: Pick<StaticAssetUploadCommitService, 'commit' | 'validate'>;\n };\n}\n\nexport interface IStaticAssetRoute {\n key: TStaticAssetRouteKey;\n feature: TStaticAssetFeature;\n\n /** The OpenAPI definition and the handler of one route, side by side. */\n build: (env: IStaticAssetRouteEnv) => {\n config: IAuthRouteConfig;\n handler: TRouteHandler;\n };\n\n /** Middleware the route adds after the application's own. */\n middleware?: (opts: {\n env: IStaticAssetRouteEnv;\n own: TStaticAssetRouteOverride['middleware'];\n }) => TStaticAssetRouteOverride['middleware'];\n}\n\nexport class StaticAssetRouteUtility {\n /** A route builder reaches for an option its feature guarantees; a miss is a bug in the table, never in the input. */\n static requireFeature<T>(opts: { value: T | undefined; feature: TStaticAssetFeature }): T {\n if (opts.value === undefined) {\n throw getError({\n message: `[static-asset] a ${opts.feature} route was built without its ${opts.feature} option`,\n });\n }\n\n return opts.value;\n }\n\n /**\n * The bucket, and for an object route the key, one request names - checked and scoped before any\n * storage call, so a key outside the scope is never even probed.\n */\n static async resolveTarget(opts: {\n ctx: TRouteContext;\n env: IStaticAssetRouteEnv;\n /** An object route also names a key. */\n isObject?: boolean;\n }): Promise<{ bucket: IBucketRef; object: IObjectRef }> {\n const { ctx, env, isObject = false } = opts;\n // Read per request: an application may read an environment variable lazily.\n const bucketName = await ResolverUtility.resolveValueAsync({ value: env.bucket });\n\n if (!env.helper.isValidBucketName({ bucket: { name: bucketName } })) {\n throw getError({ error: StaticAssetErrors.BUCKET_NAME_INVALID });\n }\n\n if (!isObject) {\n return { bucket: { name: bucketName }, object: { key: '' } };\n }\n\n const { objectName: key } = ctx.req.valid<TStaticAssetObjectParams>('param');\n\n if (!env.helper.isValidObjectKey({ object: { key }, maxDepth: env.objectKeyMaxDepth })) {\n throw getError({ error: StaticAssetErrors.OBJECT_NAME_INVALID });\n }\n\n StaticAssetKeyScopeUtility.assertInScope({ key, keyPrefix: env.keyPrefix });\n\n return { bucket: { name: bucketName }, object: { key } };\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IBucketRef, IFileStat, IObjectRef, IStorageHelper, IUploadResult } from '@venizia/ignis-helpers';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TMetaLink, TMetaLinkCompatibleSchema } from '../models/index.js';
|
|
3
3
|
import type { TMetaLinkConfig, TStaticAssetStorageType, TStaticAssetUploadLabels } from '../common/index.js';
|
|
4
4
|
export declare class StaticAssetMetaLinkUtility {
|
|
5
5
|
/** What a stat says about one stored object: the columns a refresh rewrites and a new row starts from. */
|
|
@@ -14,20 +14,20 @@ export declare class StaticAssetMetaLinkUtility {
|
|
|
14
14
|
}): IUploadResult;
|
|
15
15
|
/** 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. */
|
|
16
16
|
static createRow(opts: {
|
|
17
|
-
metaLink: TMetaLinkConfig<
|
|
17
|
+
metaLink: TMetaLinkConfig<TMetaLinkCompatibleSchema>;
|
|
18
18
|
helper: IStorageHelper;
|
|
19
19
|
storage: TStaticAssetStorageType;
|
|
20
20
|
uploadResult: IUploadResult;
|
|
21
21
|
fileStat: IFileStat;
|
|
22
22
|
labels: TStaticAssetUploadLabels;
|
|
23
|
-
}): Promise<
|
|
23
|
+
}): Promise<TMetaLink>;
|
|
24
24
|
/**
|
|
25
25
|
* Rewrites the stored-object facts on every row of the pair. Rows per pair are deliberately not
|
|
26
26
|
* unique, and each keeps its own labels and storage type. A `createMetaLink` hook owns `link` and
|
|
27
27
|
* `metadata`, so with one only the stat columns change; without one, `metadata` is merged per row.
|
|
28
28
|
*/
|
|
29
29
|
static refreshRows(opts: {
|
|
30
|
-
metaLink: TMetaLinkConfig<
|
|
30
|
+
metaLink: TMetaLinkConfig<TMetaLinkCompatibleSchema>;
|
|
31
31
|
helper: IStorageHelper;
|
|
32
32
|
bucket: IBucketRef;
|
|
33
33
|
object: IObjectRef;
|
|
@@ -35,7 +35,7 @@ export declare class StaticAssetMetaLinkUtility {
|
|
|
35
35
|
fileStat: IFileStat;
|
|
36
36
|
}): Promise<{
|
|
37
37
|
count: number;
|
|
38
|
-
data:
|
|
38
|
+
data: TMetaLink[];
|
|
39
39
|
}>;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=meta-link.utility.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-link.utility.js","s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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 {
|
|
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,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;YACrF,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAED,0HAA0H;IAC1H,MAAM,CAAC,uBAAuB,CAAC,IAM9B;QACC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAExD,OAAO;YACL,MAAM;YACN,MAAM,EAAE;gBACN,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;aACzF;Y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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"]}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
/** Reads the `{ use }` switches an entry is written with. */
|
|
3
|
-
export declare class StaticAssetToggleUtility {
|
|
4
|
-
/** The only place a toggle's `use` is read. Narrowing here is what lets every caller reach the options without a cast. */
|
|
5
|
-
static isUsed<Options extends object>(toggle: TToggle<Options> | undefined): toggle is Extract<TToggle<Options>, {
|
|
6
|
-
use: true;
|
|
7
|
-
}>;
|
|
8
|
-
/** The options of a toggle that is on, without `use`; `undefined` when it is off or absent. */
|
|
9
|
-
static pick<Options extends object>(toggle: TToggle<Options> | undefined): Omit<Extract<TToggle<Options>, {
|
|
10
|
-
use: true;
|
|
11
|
-
}>, 'use'> | undefined;
|
|
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 {
|
|
12
4
|
}
|
|
13
5
|
//# sourceMappingURL=toggle.utility.d.ts.map
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
static isUsed(toggle) {
|
|
5
|
-
return toggle !== undefined && toggle.use;
|
|
6
|
-
}
|
|
7
|
-
/** The options of a toggle that is on, without `use`; `undefined` when it is off or absent. */
|
|
8
|
-
static pick(toggle) {
|
|
9
|
-
if (!StaticAssetToggleUtility.isUsed(toggle)) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const { use: _use, ...options } = toggle;
|
|
13
|
-
return options;
|
|
14
|
-
}
|
|
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 {
|
|
15
4
|
}
|
|
16
5
|
//# sourceMappingURL=toggle.utility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/toggle.utility.ts"],"names":[],"mappings":"
|
|
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,
|