cabloy 5.1.102 → 5.1.103
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/.cabloy-version +1 -1
- package/CHANGELOG.md +29 -0
- package/CLAUDE.local.md +4 -0
- package/cabloy-docs/.vitepress/config.mjs +3 -0
- package/cabloy-docs/backend/file-guide.md +148 -0
- package/cabloy-docs/backend/image-guide.md +40 -40
- package/cabloy-docs/backend/jwt-guide.md +21 -0
- package/cabloy-docs/frontend/file-guide.md +147 -0
- package/cabloy-docs/frontend/image-guide.md +18 -9
- package/cabloy-docs/frontend/model-state-guide.md +12 -0
- package/cabloy-docs/frontend/use-state-data-best-practices.md +54 -0
- package/cabloy-docs/fullstack/file-workflow.md +135 -0
- package/cabloy-docs/fullstack/image-workflow.md +12 -3
- package/package.json +1 -1
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/src/suite/a-training/modules/training-record/src/.metadata/index.ts +30 -4
- package/vona/src/suite/a-training/modules/training-record/src/bean/fileScene.dossierFile.ts +1 -1
- package/vona/src/suite/a-training/modules/training-record/src/bean/imageScene.sceneImage.ts +1 -0
- package/vona/src/suite/a-training/modules/training-record/src/dto/recordSelectResItem.tsx +8 -6
- package/vona/src/suite/a-training/modules/training-record/src/dto/recordView.tsx +8 -6
- package/vona/src/suite/a-training/modules/training-record/src/index.ts +0 -1
- package/vona/src/suite/a-training/modules/training-record/src/lib/index.ts +0 -1
- package/vona/src/suite/a-training/modules/training-record/test/record.test.ts +10 -12
- package/vona/src/suite/a-training/modules/training-student/src/bean/imageScene.studentImage.ts +1 -0
- package/vona/src/suite/a-training/modules/training-student/src/dto/detailRecordBase.tsx +9 -10
- package/vona/src/suite/a-training/modules/training-student/test/student.test.ts +2 -2
- package/vona/src/suite-vendor/a-file/modules/a-file/package.json +3 -2
- package/vona/src/suite-vendor/a-file/modules/a-file/src/.metadata/index.ts +155 -35
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/bean.file.ts +283 -54
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/bean.fileUploadPolicy.ts +46 -63
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/meta.index.ts +12 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/meta.redlock.ts +1 -1
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/meta.version.ts +3 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/schedule.fileDraftPrune.ts +29 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/serializerTransform.resolveView.ts +45 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/bean/serializerTransform.resolveViews.ts +45 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/config/config.ts +6 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/controller/file.ts +64 -56
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDirectUploadFinalizeRequest.ts +13 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDirectUploadFinalizeResponse.ts +10 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDirectUploadRequest.ts +0 -3
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDirectUploadResponse.ts +2 -14
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileDownloadRequest.ts +3 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadPolicyResponse.ts +3 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/dto/fileUploadResponse.ts +0 -25
- package/vona/src/{suite/a-training/modules/training-record/src/dto/recordDossierFileView.ts → suite-vendor/a-file/modules/a-file/src/dto/fileView.ts} +3 -15
- package/vona/src/suite-vendor/a-file/modules/a-file/src/entity/file.ts +10 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/lib/fileUploadUrl.ts +329 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/lib/index.ts +1 -0
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/file.ts +51 -10
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/fileProvider.ts +8 -3
- package/vona/src/suite-vendor/a-file/modules/a-file/src/types/fileScene.ts +1 -1
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/package.json +1 -1
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/bean/fileProvider.cloudflare.ts +12 -4
- package/vona/src/suite-vendor/a-file/modules/file-cloudflare/src/service/fileCloudflare.ts +52 -18
- package/vona/src/suite-vendor/a-file/modules/file-native/package.json +1 -1
- package/vona/src/suite-vendor/a-file/modules/file-native/src/bean/fileProvider.native.ts +5 -5
- package/vona/src/suite-vendor/a-file/modules/file-native/src/service/fileNative.ts +7 -8
- package/vona/src/suite-vendor/a-file/package.json +4 -4
- package/vona/src/suite-vendor/a-image/modules/a-image/package.json +1 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/.metadata/index.ts +16 -19
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/bean.image.ts +99 -74
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/bean.imageUploadPolicy.ts +28 -68
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/meta.version.ts +1 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/serializerTransform.resolveView.ts +3 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/bean/serializerTransform.resolveViews.ts +3 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/config/config.ts +4 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/controller/image.ts +78 -34
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageDeliveryRequest.ts +3 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageDirectUploadRequest.ts +0 -3
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageDirectUploadResponse.ts +1 -27
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadPolicyResponse.ts +6 -0
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadResponse.ts +2 -36
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadUrlRequest.ts +0 -3
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageView.ts +4 -27
- package/vona/src/suite-vendor/a-image/modules/a-image/src/entity/image.ts +1 -1
- package/vona/src/suite-vendor/a-image/modules/a-image/src/types/image.ts +36 -29
- package/vona/src/suite-vendor/a-image/modules/a-image/src/types/imageProvider.ts +4 -4
- package/vona/src/suite-vendor/a-image/modules/a-image/src/types/imageScene.ts +1 -0
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/package.json +1 -1
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/bean/imageProvider.cloudflare.ts +8 -11
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/lib/cloudflareImageUrl.ts +4 -16
- package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/service/imageCloudflare.ts +17 -16
- package/vona/src/suite-vendor/a-image/modules/image-native/package.json +2 -6
- package/vona/src/suite-vendor/a-image/modules/image-native/src/.metadata/index.ts +0 -37
- package/vona/src/suite-vendor/a-image/modules/image-native/src/bean/imageProvider.native.ts +13 -36
- package/vona/src/suite-vendor/a-image/modules/image-native/src/service/imageNative.ts +100 -113
- package/vona/src/suite-vendor/a-image/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/src/config/config.ts +3 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/src/service/jwtClient.ts +9 -4
- package/vona/src/suite-vendor/a-vona/modules/a-upload/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-upload/src/bean/interceptor.upload.ts +113 -64
- package/vona/src/suite-vendor/a-vona/package.json +1 -1
- package/zova/packages-zova/zova/package.json +2 -2
- package/zova/src/suite/a-home/modules/home-api/src/api/openapi/schemas.ts +50 -12
- package/zova/src/suite/a-home/modules/home-api/src/api/openapi/types.ts +610 -114
- package/zova/src/suite/a-home/modules/home-passport/src/model/passport.ts +44 -1
- package/zova/src/suite/a-training/modules/training-student/src/api/openapi/schemas.ts +50 -12
- package/zova/src/suite/a-training/modules/training-student/src/api/openapi/types.ts +610 -114
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/.metadata/index.ts +16 -12
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/file.ts +25 -25
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/schemas.ts +18 -24
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/types.ts +228 -291
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/apiSchema/file.ts +5 -5
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/bean/tableCell.file.tsx +23 -5
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/component/formFieldFile/controller.tsx +72 -43
- package/zova/src/suite/cabloy-basic/modules/basic-file/src/lib/file.ts +22 -4
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/.metadata/index.ts +16 -42
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/image.ts +5 -25
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/openapi/schemas.ts +10 -24
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/openapi/types.ts +216 -333
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/apiSchema/image.ts +0 -5
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/bean/tableCell.image.tsx +38 -12
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/component/formFieldImage/controller.tsx +79 -32
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/lib/preview.ts +22 -4
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/types/image.ts +3 -4
- package/zova/src/suite-vendor/a-zova/modules/a-model/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/lib/utils.ts +29 -1
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/types/query.ts +2 -2
- package/zova/src/suite-vendor/a-zova/package.json +2 -2
- package/vona/src/suite/a-training/modules/training-record/src/lib/resolveDossierFiles.ts +0 -34
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadTokenRequest.ts +0 -24
- package/vona/src/suite-vendor/a-image/modules/a-image/src/dto/imageUploadTokenResponse.ts +0 -16
- package/vona/src/suite-vendor/a-image/modules/image-native/src/controller/image.ts +0 -57
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/imageNativeImage.ts +0 -31
- package/zova/src/suite/cabloy-basic/modules/basic-image/src/apiSchema/imageNativeImage.ts +0 -13
package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/bean/imageProvider.cloudflare.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
IDecoratorImageProviderOptions,
|
|
3
|
-
IImageDeliveryOptions,
|
|
4
3
|
IImageDirectUploadInput,
|
|
4
|
+
IImageProviderDeliveryOptions,
|
|
5
5
|
IImageDownloadResult,
|
|
6
6
|
IImageProviderClientOptions,
|
|
7
7
|
IImageProviderClientRecord,
|
|
@@ -37,6 +37,7 @@ export interface IImageProviderOptionsCloudflare extends IDecoratorImageProvider
|
|
|
37
37
|
|
|
38
38
|
@ImageProvider<IImageProviderOptionsCloudflare>({
|
|
39
39
|
base: {
|
|
40
|
+
public: true,
|
|
40
41
|
signedDeliveryKind: 'provider',
|
|
41
42
|
variants: {
|
|
42
43
|
original: {},
|
|
@@ -92,7 +93,7 @@ export class ImageProviderCloudflare
|
|
|
92
93
|
size: image.size,
|
|
93
94
|
width: image.width,
|
|
94
95
|
height: image.height,
|
|
95
|
-
|
|
96
|
+
public: image.public ?? clientOptions.public,
|
|
96
97
|
variants: image.variants ?? clientOptions.variants,
|
|
97
98
|
meta: image.meta,
|
|
98
99
|
deliveryBaseUrl: image.deliveryBaseUrl ?? clientOptions.deliveryBaseUrl,
|
|
@@ -112,7 +113,7 @@ export class ImageProviderCloudflare
|
|
|
112
113
|
request: IImageVariantRequest,
|
|
113
114
|
clientOptions: IImageProviderCloudflareClientOptions,
|
|
114
115
|
_options: IImageProviderOptionsCloudflare,
|
|
115
|
-
deliveryOptions?:
|
|
116
|
+
deliveryOptions?: IImageProviderDeliveryOptions,
|
|
116
117
|
) {
|
|
117
118
|
const variants = image.variants ?? clientOptions.variants;
|
|
118
119
|
const resolved = resolveImageVariantRequestToTransform(request, 'original', variants);
|
|
@@ -123,7 +124,7 @@ export class ImageProviderCloudflare
|
|
|
123
124
|
{
|
|
124
125
|
...clientOptions,
|
|
125
126
|
deliveryBaseUrl: image.deliveryBaseUrl ?? clientOptions.deliveryBaseUrl,
|
|
126
|
-
|
|
127
|
+
public: image.public ?? clientOptions.public,
|
|
127
128
|
},
|
|
128
129
|
deliveryOptions,
|
|
129
130
|
);
|
|
@@ -134,18 +135,14 @@ export class ImageProviderCloudflare
|
|
|
134
135
|
request: IImageVariantRequest,
|
|
135
136
|
clientOptions: IImageProviderCloudflareClientOptions,
|
|
136
137
|
options: IImageProviderOptionsCloudflare,
|
|
137
|
-
deliveryOptions?:
|
|
138
|
+
deliveryOptions?: IImageProviderDeliveryOptions,
|
|
138
139
|
): Promise<IImageDownloadResult> {
|
|
139
140
|
return {
|
|
140
141
|
kind: 'url',
|
|
141
142
|
url: await this.getVariantUrl(image, request, clientOptions, options, deliveryOptions),
|
|
142
143
|
filename: image.filename,
|
|
143
144
|
contentType: image.contentType,
|
|
144
|
-
signed: !!
|
|
145
|
-
deliveryOptions?.signed ??
|
|
146
|
-
image.requireSignedURLs ??
|
|
147
|
-
clientOptions.requireSignedURLs
|
|
148
|
-
),
|
|
145
|
+
signed: !!deliveryOptions?.protected,
|
|
149
146
|
};
|
|
150
147
|
}
|
|
151
148
|
|
|
@@ -154,7 +151,7 @@ export class ImageProviderCloudflare
|
|
|
154
151
|
variantName: TypeImageProviderResolvedVariantName,
|
|
155
152
|
transformOptions: Record<string, any>,
|
|
156
153
|
clientOptions: IImageProviderCloudflareClientOptions,
|
|
157
|
-
deliveryOptions?:
|
|
154
|
+
deliveryOptions?: IImageProviderDeliveryOptions,
|
|
158
155
|
) {
|
|
159
156
|
return this.scope.service.imageCloudflare.buildVariantUrl(
|
|
160
157
|
image,
|
package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/lib/cloudflareImageUrl.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
IImageProviderDeliveryOptions,
|
|
3
3
|
IImageTransformOptions,
|
|
4
4
|
TypeImageVariantName,
|
|
5
5
|
} from 'vona-module-a-image';
|
|
6
6
|
|
|
7
7
|
import { createHmac } from 'node:crypto';
|
|
8
8
|
|
|
9
|
-
export interface ICloudflareImageUrlOptions extends
|
|
9
|
+
export interface ICloudflareImageUrlOptions extends IImageProviderDeliveryOptions {
|
|
10
10
|
accountHash?: string;
|
|
11
11
|
deliveryBaseUrl?: string;
|
|
12
12
|
signingKey?: string;
|
|
@@ -25,7 +25,7 @@ export function buildCloudflareImageUrl(
|
|
|
25
25
|
? buildCloudflareTransformPath(transformOptions)
|
|
26
26
|
: normalizeCloudflareVariantName(variantName);
|
|
27
27
|
const url = new URL(`${baseUrl}/${resourcePath}/${variantPath}`);
|
|
28
|
-
if (options.
|
|
28
|
+
if (options.protected) {
|
|
29
29
|
signCloudflareImageUrl(url, options);
|
|
30
30
|
}
|
|
31
31
|
return url.toString();
|
|
@@ -94,19 +94,7 @@ export function signCloudflareImageUrl(url: URL, options: ICloudflareImageUrlOpt
|
|
|
94
94
|
url.searchParams.set('sig', sig);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
function resolveExpiryTimestamp(options:
|
|
98
|
-
if (options.expiresAt !== undefined) {
|
|
99
|
-
const value =
|
|
100
|
-
options.expiresAt instanceof Date
|
|
101
|
-
? options.expiresAt.getTime()
|
|
102
|
-
: typeof options.expiresAt === 'string'
|
|
103
|
-
? new Date(options.expiresAt).getTime()
|
|
104
|
-
: Number(options.expiresAt);
|
|
105
|
-
if (!Number.isFinite(value)) {
|
|
106
|
-
throw new TypeError(`Invalid expiresAt for signed delivery: ${String(options.expiresAt)}`);
|
|
107
|
-
}
|
|
108
|
-
return Math.floor(value / 1000);
|
|
109
|
-
}
|
|
97
|
+
function resolveExpiryTimestamp(options: IImageProviderDeliveryOptions) {
|
|
110
98
|
const expiresIn = options.expiresIn ?? 60 * 10;
|
|
111
99
|
return Math.floor(Date.now() / 1000) + expiresIn;
|
|
112
100
|
}
|
package/vona/src/suite-vendor/a-image/modules/image-cloudflare/src/service/imageCloudflare.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
EntityImage,
|
|
3
|
-
IImageDeliveryOptions,
|
|
4
3
|
IImageDirectUploadInput,
|
|
4
|
+
IImageProviderDeliveryOptions,
|
|
5
5
|
IImageProviderDirectUploadResource,
|
|
6
6
|
IImageProviderResource,
|
|
7
7
|
IImageUploadInput,
|
|
@@ -32,6 +32,7 @@ interface ICloudflareImageResult {
|
|
|
32
32
|
id: string;
|
|
33
33
|
filename?: string;
|
|
34
34
|
uploaded?: string;
|
|
35
|
+
// Cloudflare upstream field; app-level contract should use `public`.
|
|
35
36
|
requireSignedURLs?: boolean;
|
|
36
37
|
variants?: string[];
|
|
37
38
|
metadata?: Record<string, unknown>;
|
|
@@ -63,7 +64,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
63
64
|
const filename = input.filename ?? path.basename(input.file);
|
|
64
65
|
form.append('file', new Blob([buffer], { type: input.contentType }), filename);
|
|
65
66
|
this._appendUploadFields(form, {
|
|
66
|
-
requireSignedURLs: input.
|
|
67
|
+
requireSignedURLs: input.public === undefined ? undefined : !input.public,
|
|
67
68
|
metadata: input.meta,
|
|
68
69
|
});
|
|
69
70
|
const result = await this._request<ICloudflareImageResult>(normalized, '/images/v1', {
|
|
@@ -76,7 +77,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
76
77
|
contentType: input.contentType,
|
|
77
78
|
size: input.size ?? Number(stat.size),
|
|
78
79
|
meta: input.meta,
|
|
79
|
-
|
|
80
|
+
public: input.public,
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -88,7 +89,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
88
89
|
const form = new FormData();
|
|
89
90
|
form.append('url', input.url);
|
|
90
91
|
this._appendUploadFields(form, {
|
|
91
|
-
requireSignedURLs: input.
|
|
92
|
+
requireSignedURLs: input.public === undefined ? undefined : !input.public,
|
|
92
93
|
metadata: input.meta,
|
|
93
94
|
});
|
|
94
95
|
const result = await this._request<ICloudflareImageResult>(normalized, '/images/v1', {
|
|
@@ -99,7 +100,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
99
100
|
filename: input.filename ?? result.filename,
|
|
100
101
|
contentType: input.contentType,
|
|
101
102
|
meta: input.meta,
|
|
102
|
-
|
|
103
|
+
public: input.public,
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
|
|
@@ -110,7 +111,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
110
111
|
const normalized = this._normalizeClientOptions(options);
|
|
111
112
|
const form = new FormData();
|
|
112
113
|
this._appendUploadFields(form, {
|
|
113
|
-
requireSignedURLs: input.
|
|
114
|
+
requireSignedURLs: input.public === undefined ? undefined : !input.public,
|
|
114
115
|
metadata: input.meta,
|
|
115
116
|
expiry: input.expiry,
|
|
116
117
|
id: input.customId,
|
|
@@ -127,7 +128,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
127
128
|
filename: input.filename,
|
|
128
129
|
contentType: input.contentType,
|
|
129
130
|
meta: input.meta,
|
|
130
|
-
|
|
131
|
+
public: input.public,
|
|
131
132
|
});
|
|
132
133
|
return {
|
|
133
134
|
...resource,
|
|
@@ -137,7 +138,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
async finalizeDirectUpload(
|
|
140
|
-
image: Pick<EntityImage, 'resourceId' | 'filename' | 'meta' | '
|
|
141
|
+
image: Pick<EntityImage, 'resourceId' | 'filename' | 'meta' | 'public'>,
|
|
141
142
|
options: IImageProviderCloudflareClientOptions,
|
|
142
143
|
): Promise<IImageProviderResource | undefined> {
|
|
143
144
|
const normalized = this._normalizeClientOptions(options);
|
|
@@ -152,7 +153,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
152
153
|
return this._mapImageResource(result, normalized, {
|
|
153
154
|
filename: result.filename ?? result.meta?.filename ?? image.filename,
|
|
154
155
|
meta: image.meta,
|
|
155
|
-
|
|
156
|
+
public: image.public,
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
|
|
@@ -173,19 +174,18 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
buildVariantUrl(
|
|
176
|
-
image: Pick<EntityImage, 'resourceId' | 'deliveryBaseUrl' | '
|
|
177
|
+
image: Pick<EntityImage, 'resourceId' | 'deliveryBaseUrl' | 'public'>,
|
|
177
178
|
variantName: string | 'custom',
|
|
178
179
|
transformOptions: Record<string, any>,
|
|
179
180
|
options: IImageProviderCloudflareClientOptions,
|
|
180
|
-
deliveryOptions?:
|
|
181
|
+
deliveryOptions?: IImageProviderDeliveryOptions,
|
|
181
182
|
) {
|
|
182
183
|
const normalized = this._normalizeClientOptions(options);
|
|
183
184
|
return buildCloudflareImageUrl(image.resourceId, variantName as any, transformOptions, {
|
|
184
185
|
accountHash: normalized.accountHash,
|
|
185
186
|
deliveryBaseUrl: image.deliveryBaseUrl ?? normalized.deliveryBaseUrl,
|
|
186
187
|
signingKey: normalized.signingKey,
|
|
187
|
-
|
|
188
|
-
expiresAt: deliveryOptions?.expiresAt,
|
|
188
|
+
protected: deliveryOptions?.protected ?? !(image.public ?? normalized.public ?? true),
|
|
189
189
|
expiresIn: deliveryOptions?.expiresIn,
|
|
190
190
|
});
|
|
191
191
|
}
|
|
@@ -277,7 +277,7 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
277
277
|
contentType?: string;
|
|
278
278
|
size?: number;
|
|
279
279
|
meta?: Record<string, unknown>;
|
|
280
|
-
|
|
280
|
+
public?: boolean;
|
|
281
281
|
},
|
|
282
282
|
): IImageProviderResource {
|
|
283
283
|
const deliveryBaseUrl =
|
|
@@ -288,8 +288,9 @@ export class ServiceImageCloudflare extends BeanBase {
|
|
|
288
288
|
filename: data.filename ?? result.filename,
|
|
289
289
|
contentType: data.contentType,
|
|
290
290
|
size: data.size,
|
|
291
|
-
|
|
292
|
-
data.
|
|
291
|
+
public:
|
|
292
|
+
data.public ??
|
|
293
|
+
(result.requireSignedURLs !== undefined ? !result.requireSignedURLs : options.public),
|
|
293
294
|
variants: options.variants,
|
|
294
295
|
meta: data.meta,
|
|
295
296
|
deliveryBaseUrl,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-image-native",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Vona Module"
|
|
@@ -46,11 +46,7 @@
|
|
|
46
46
|
"title": "image-native",
|
|
47
47
|
"vonaModule": {
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"a-
|
|
50
|
-
"a-image": "5.0.0",
|
|
51
|
-
"a-upload": "5.0.0",
|
|
52
|
-
"a-user": "5.0.0",
|
|
53
|
-
"a-web": "5.0.0"
|
|
49
|
+
"a-image": "5.0.0"
|
|
54
50
|
},
|
|
55
51
|
"globalDependencies": {
|
|
56
52
|
"sharp": true
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// eslint-disable
|
|
2
|
-
import type { TypeControllerOptionsActions } from 'vona-module-a-openapi';
|
|
3
2
|
/** service: begin */
|
|
4
3
|
export * from '../service/imageNative.ts';
|
|
5
4
|
|
|
@@ -73,42 +72,6 @@ export interface IModuleImageProvider {
|
|
|
73
72
|
'native': ImageProviderNative;
|
|
74
73
|
}
|
|
75
74
|
/** imageProvider: end */
|
|
76
|
-
/** controller: begin */
|
|
77
|
-
export * from '../controller/image.ts';
|
|
78
|
-
import type { IControllerOptionsImage } from '../controller/image.ts';
|
|
79
|
-
import 'vona-module-a-web';
|
|
80
|
-
declare module 'vona-module-a-web' {
|
|
81
|
-
export interface IControllerRecord {
|
|
82
|
-
'image-native:image': IControllerOptionsImage;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
declare module 'vona-module-image-native' {
|
|
86
|
-
export interface ControllerImage {
|
|
87
|
-
/** @internal */
|
|
88
|
-
get scope(): ScopeModuleImageNative;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface ControllerImage {
|
|
92
|
-
get $beanFullName(): 'image-native.controller.image';
|
|
93
|
-
get $onionName(): 'image-native:image';
|
|
94
|
-
get $onionOptions(): IControllerOptionsImage;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/** controller: end */
|
|
98
|
-
/** controller: begin */
|
|
99
|
-
// @ts-ignore ignore
|
|
100
|
-
import type { ControllerImage } from '../controller/image.ts';
|
|
101
|
-
declare module 'vona-module-image-native' {
|
|
102
|
-
export interface IControllerOptionsImage {
|
|
103
|
-
actions?: TypeControllerOptionsActions<ControllerImage>;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
declare module 'vona-module-a-web' {
|
|
107
|
-
export interface IApiPathPostRecord {
|
|
108
|
-
'/image-native/direct-upload/:resourceId': undefined;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/** controller: end */
|
|
112
75
|
/** config: begin */
|
|
113
76
|
export * from '../config/config.ts';
|
|
114
77
|
import type { config } from '../config/config.ts';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
IDecoratorImageProviderOptions,
|
|
3
|
-
IImageDeliveryOptions,
|
|
4
|
-
IImageDirectUploadInput,
|
|
5
3
|
IImageDownloadResult,
|
|
4
|
+
IImageProviderDeliveryOptions,
|
|
6
5
|
IImageProviderClientOptions,
|
|
7
6
|
IImageProviderClientRecord,
|
|
8
7
|
IImageProviderExecute,
|
|
@@ -12,7 +11,6 @@ import type {
|
|
|
12
11
|
} from 'vona-module-a-image';
|
|
13
12
|
import type { EntityImage } from 'vona-module-a-image';
|
|
14
13
|
|
|
15
|
-
import fse from 'fs-extra';
|
|
16
14
|
import { BeanBase } from 'vona';
|
|
17
15
|
import { ImageProvider } from 'vona-module-a-image';
|
|
18
16
|
|
|
@@ -20,8 +18,6 @@ export interface IImageProviderNativeClientRecord extends IImageProviderClientRe
|
|
|
20
18
|
|
|
21
19
|
export interface IImageProviderNativeClientOptions extends IImageProviderClientOptions {
|
|
22
20
|
subdir?: string;
|
|
23
|
-
signingKey?: string;
|
|
24
|
-
tokenName?: string;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
export interface IImageProviderOptionsNative extends IDecoratorImageProviderOptions<
|
|
@@ -32,6 +28,7 @@ export interface IImageProviderOptionsNative extends IDecoratorImageProviderOpti
|
|
|
32
28
|
@ImageProvider<IImageProviderOptionsNative>({
|
|
33
29
|
base: {
|
|
34
30
|
subdir: 'default',
|
|
31
|
+
public: false,
|
|
35
32
|
signedDeliveryKind: 'proxy',
|
|
36
33
|
},
|
|
37
34
|
})
|
|
@@ -53,22 +50,6 @@ export class ImageProviderNative
|
|
|
53
50
|
};
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
async createDirectUpload(
|
|
57
|
-
input: IImageDirectUploadInput,
|
|
58
|
-
clientOptions: IImageProviderNativeClientOptions,
|
|
59
|
-
_options: IImageProviderOptionsNative,
|
|
60
|
-
) {
|
|
61
|
-
return await this.scope.service.imageNative.createDirectUpload(input, clientOptions);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async finalizeDirectUpload(
|
|
65
|
-
image: EntityImage,
|
|
66
|
-
clientOptions: IImageProviderNativeClientOptions,
|
|
67
|
-
_options: IImageProviderOptionsNative,
|
|
68
|
-
) {
|
|
69
|
-
return await this.scope.service.imageNative.finalizeDirectUpload(image, clientOptions);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
53
|
async get(
|
|
73
54
|
image: EntityImage,
|
|
74
55
|
clientOptions: IImageProviderNativeClientOptions,
|
|
@@ -81,7 +62,7 @@ export class ImageProviderNative
|
|
|
81
62
|
size: image.size,
|
|
82
63
|
width: image.width,
|
|
83
64
|
height: image.height,
|
|
84
|
-
|
|
65
|
+
public: image.public ?? clientOptions.public,
|
|
85
66
|
variants: image.variants,
|
|
86
67
|
meta: image.meta,
|
|
87
68
|
storagePath: image.storagePath,
|
|
@@ -102,7 +83,7 @@ export class ImageProviderNative
|
|
|
102
83
|
request: IImageVariantRequest,
|
|
103
84
|
clientOptions: IImageProviderNativeClientOptions,
|
|
104
85
|
_options: IImageProviderOptionsNative,
|
|
105
|
-
deliveryOptions?:
|
|
86
|
+
deliveryOptions?: IImageProviderDeliveryOptions,
|
|
106
87
|
) {
|
|
107
88
|
return await this.scope.service.imageNative.getVariantUrl(
|
|
108
89
|
image,
|
|
@@ -111,6 +92,7 @@ export class ImageProviderNative
|
|
|
111
92
|
...clientOptions,
|
|
112
93
|
subdir: clientOptions.subdir ?? 'default',
|
|
113
94
|
deliveryBaseUrl: image.deliveryBaseUrl ?? clientOptions.deliveryBaseUrl,
|
|
95
|
+
public: image.public ?? clientOptions.public,
|
|
114
96
|
},
|
|
115
97
|
deliveryOptions,
|
|
116
98
|
);
|
|
@@ -121,21 +103,16 @@ export class ImageProviderNative
|
|
|
121
103
|
request: IImageVariantRequest,
|
|
122
104
|
clientOptions: IImageProviderNativeClientOptions,
|
|
123
105
|
options: IImageProviderOptionsNative,
|
|
124
|
-
deliveryOptions?:
|
|
106
|
+
deliveryOptions?: IImageProviderDeliveryOptions,
|
|
125
107
|
): Promise<IImageDownloadResult> {
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
request.variantName === 'original' &&
|
|
130
|
-
!request.transformOptions
|
|
131
|
-
) {
|
|
132
|
-
const buffer = image.storagePath ? await fse.readFile(image.storagePath) : undefined;
|
|
133
|
-
if (buffer) {
|
|
108
|
+
if ((deliveryOptions?.responseMode ?? 'auto') !== 'url') {
|
|
109
|
+
const result = await this.scope.service.imageNative.downloadBuffer(image, request);
|
|
110
|
+
if (result) {
|
|
134
111
|
return {
|
|
135
112
|
kind: 'buffer',
|
|
136
|
-
buffer,
|
|
137
|
-
filename:
|
|
138
|
-
contentType:
|
|
113
|
+
buffer: result.buffer,
|
|
114
|
+
filename: result.filename,
|
|
115
|
+
contentType: result.contentType,
|
|
139
116
|
signed: false,
|
|
140
117
|
};
|
|
141
118
|
}
|
|
@@ -145,7 +122,7 @@ export class ImageProviderNative
|
|
|
145
122
|
url: await this.getVariantUrl(image, request, clientOptions, options, deliveryOptions),
|
|
146
123
|
filename: image.filename,
|
|
147
124
|
contentType: image.contentType,
|
|
148
|
-
signed: !!deliveryOptions?.
|
|
125
|
+
signed: !!deliveryOptions?.protected,
|
|
149
126
|
};
|
|
150
127
|
}
|
|
151
128
|
}
|