@cardinali-studio/adminkit 2.2.49 → 2.2.51
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/app/App.js +6 -6
- package/dist/app/app.css +110 -1
- package/dist/app/delivery.js +7 -7
- package/dist/app/guide/TransferGuide.js +1 -1
- package/dist/app/lib/deliveries.d.ts +6 -0
- package/dist/app/lib/delivery-capabilities.d.ts +31 -0
- package/dist/app/lib/delivery-capabilities.js +115 -0
- package/dist/app/lib/delivery-checkpoint-pipeline.d.ts +81 -0
- package/dist/app/lib/delivery-checkpoint-pipeline.js +195 -0
- package/dist/app/lib/delivery-finalize.d.ts +21 -0
- package/dist/app/lib/delivery-finalize.js +42 -0
- package/dist/app/lib/delivery-multipart-large.d.ts +18 -0
- package/dist/app/lib/delivery-multipart-large.js +28 -0
- package/dist/app/lib/delivery-network.d.ts +7 -1
- package/dist/app/lib/delivery-network.js +85 -18
- package/dist/app/lib/delivery-part-pipeline.d.ts +79 -0
- package/dist/app/lib/delivery-part-pipeline.js +270 -0
- package/dist/app/lib/delivery-upload-coordinator.d.ts +112 -0
- package/dist/app/lib/delivery-upload-coordinator.js +229 -0
- package/dist/app/lib/delivery-upload.d.ts +19 -3
- package/dist/app/lib/delivery-upload.js +226 -29
- package/dist/app/lib/upload-queue.d.ts +5 -0
- package/dist/app/lib/upload-queue.js +54 -29
- package/dist/app/routes/Deliveries.d.ts +9 -3
- package/dist/app/routes/Deliveries.js +318 -189
- package/dist/app/routes/DeliveryDashboard.js +1 -1
- package/dist/app/routes/DeliveryEmail.d.ts +8 -1
- package/dist/app/routes/DeliveryEmail.js +63 -23
- package/dist/app/routes/DeliveryRecipientPreview.d.ts +14 -0
- package/dist/app/routes/DeliveryRecipientPreview.js +49 -0
- package/dist/app/routes/Overview.js +5 -5
- package/dist/app/routes/UploadDock.js +4 -3
- package/dist/form/media/MediaGrid.js +1 -1
- package/dist/functions/_shared/b2.js +98 -19
- package/dist/functions/_shared/delivery-activation.js +98 -0
- package/dist/functions/_shared/delivery-download-bundle.js +280 -0
- package/dist/functions/_shared/delivery-email.js +92 -13
- package/dist/functions/_shared/delivery-file-names.js +19 -0
- package/dist/functions/_shared/delivery-finalization-paid.js +31 -0
- package/dist/functions/_shared/delivery-finalization-storage.js +64 -0
- package/dist/functions/_shared/delivery-manifest-free.js +74 -0
- package/dist/functions/_shared/delivery-manifest.js +277 -20
- package/dist/functions/_shared/delivery-multipart-verification.js +68 -0
- package/dist/functions/_shared/delivery-request.js +74 -0
- package/dist/functions/_shared/delivery-storage-access.js +14 -0
- package/dist/functions/_shared/delivery-upload-admission.js +221 -0
- package/dist/functions/_shared/delivery-upload-contract.js +44 -0
- package/dist/functions/_shared/delivery-upload-free.js +80 -0
- package/dist/functions/_shared/delivery-upload-policy.js +64 -0
- package/dist/functions/_shared/delivery-upload-session.js +365 -0
- package/dist/functions/_shared/delivery-work-budget.js +49 -0
- package/dist/functions/api/deliveries.js +58 -17
- package/dist/functions/api/delivery/multipart.js +152 -15
- package/dist/functions/delivery-public/assets/client.js +59 -54
- package/dist/functions/delivery-public/assets/delivery.css +6 -2
- package/dist/functions/delivery-public/index.js +43 -15
- package/dist/functions/delivery-public/migrations/0015_delivery_activation_intents.sql +12 -0
- package/dist/functions/delivery-public/migrations/0016_delivery_multipart_verification.sql +16 -0
- package/dist/functions/delivery-public/migrations/0017_delivery_upload_admission.sql +38 -0
- package/dist/functions/delivery-public/migrations/0018_delivery_upload_sessions.sql +26 -0
- package/dist/functions/delivery-public/migrations/0019_delivery_manifest_fragments.sql +27 -0
- package/dist/functions/delivery-public/migrations/0020_delivery_email_reply_to.sql +1 -0
- package/dist/functions/index.js +3 -1
- package/dist/theme.css +2 -1
- package/package.json +1 -1
|
@@ -15,13 +15,16 @@
|
|
|
15
15
|
* App.tsx ricarica l'elenco quando uno finisce (`useUploadCompletions`)
|
|
16
16
|
*/
|
|
17
17
|
import { useSyncExternalStore } from "react";
|
|
18
|
+
import { COMMON_FINALIZATION_ROLLOUT_ENABLED, finalizeDeliveryCommon } from './delivery-finalize.js';
|
|
18
19
|
import { UploadCancelled, uploadDeliveryPackage, } from "./delivery-upload.js";
|
|
19
|
-
import { deliveryJson } from "./delivery-network.js";
|
|
20
|
+
import { deliveryJson, transferErrorMessage } from "./delivery-network.js";
|
|
21
|
+
import { DeliveryUploadCoordinator, assertUploadCoordinatorSelection } from './delivery-upload-coordinator.js';
|
|
20
22
|
/* ---- lo stato ------------------------------------------------------------------------ */
|
|
21
23
|
let jobs = [];
|
|
22
24
|
let completions = 0;
|
|
23
25
|
const gates = new Map();
|
|
24
26
|
const running = new Map();
|
|
27
|
+
const coordinators = new Map();
|
|
25
28
|
const retries = new Map();
|
|
26
29
|
const listeners = new Set();
|
|
27
30
|
function emit() {
|
|
@@ -60,6 +63,8 @@ export function isBusy(job) {
|
|
|
60
63
|
file e a ogni parte, e questa promessa lo tiene fermo finché non si riprende. */
|
|
61
64
|
export class Gate {
|
|
62
65
|
id;
|
|
66
|
+
writerToken;
|
|
67
|
+
json;
|
|
63
68
|
controller = new AbortController();
|
|
64
69
|
signal = this.controller.signal;
|
|
65
70
|
waitingRequests = 0;
|
|
@@ -113,6 +118,25 @@ export function startUpload(input) {
|
|
|
113
118
|
async function run(input, gate) {
|
|
114
119
|
const id = input.packageId;
|
|
115
120
|
try {
|
|
121
|
+
assertUploadCoordinatorSelection(input.uploadSession);
|
|
122
|
+
if (input.uploadSession) {
|
|
123
|
+
// Restore writer identity before opening a session with a recoverable
|
|
124
|
+
// pending unit. The streaming engine will reuse this same stored token.
|
|
125
|
+
const key = `adminkit-delivery-writer:${id}`;
|
|
126
|
+
gate.writerToken = localStorage.getItem(key) || crypto.randomUUID();
|
|
127
|
+
localStorage.setItem(key, gate.writerToken);
|
|
128
|
+
const coordinator = new DeliveryUploadCoordinator(input.deliveryId, input.uploadSession);
|
|
129
|
+
coordinators.set(id, coordinator);
|
|
130
|
+
const session = await coordinator.open(gate);
|
|
131
|
+
if (session.contract.selection.sourceFingerprint !== input.sourceFingerprint ||
|
|
132
|
+
session.contract.selection.fileCount !== input.files.length ||
|
|
133
|
+
session.contract.selection.sourceBytes !== input.files.reduce((n, f) => n + f.size, 0) ||
|
|
134
|
+
session.contract.selection.galleryEnabled !== input.options.galleryEnabled ||
|
|
135
|
+
session.contract.selection.webEnabled !== input.options.webEnabled ||
|
|
136
|
+
session.contract.selection.webFormat !== (input.options.webFormat || 'webp'))
|
|
137
|
+
throw new Error('Selezione diversa dal contratto della sessione');
|
|
138
|
+
gate.json = (url, body, control) => coordinator.json(url, body, control);
|
|
139
|
+
}
|
|
116
140
|
const retry = retries.get(id);
|
|
117
141
|
if (retry?.cleanup)
|
|
118
142
|
throw new UploadCancelled();
|
|
@@ -121,24 +145,29 @@ async function run(input, gate) {
|
|
|
121
145
|
fotografo sta guardando un'altra sezione, devono succedere lo stesso. */
|
|
122
146
|
retries.set(id, { input, result });
|
|
123
147
|
await gate.gate();
|
|
124
|
-
if (result.manifest.version === 2) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
148
|
+
if ((coordinators.has(id) || COMMON_FINALIZATION_ROLLOUT_ENABLED) && result.manifest.version === 2) {
|
|
149
|
+
await finalizeDeliveryCommon(input.deliveryId, id, gate);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (result.manifest.version === 2) {
|
|
153
|
+
let done = false;
|
|
154
|
+
while (!done) {
|
|
155
|
+
await gate.gate();
|
|
156
|
+
const step = await deliveryJson("/admin/api/deliveries", {
|
|
157
|
+
action: "manifestFinalize", id: input.deliveryId, packageId: id,
|
|
158
|
+
}, gate);
|
|
159
|
+
done = step.done;
|
|
160
|
+
}
|
|
132
161
|
}
|
|
162
|
+
else
|
|
163
|
+
await deliveryJson("/admin/api/deliveries", {
|
|
164
|
+
action: "finalizePackage", id: input.deliveryId, packageId: id,
|
|
165
|
+
manifest: result.manifest, fileCount: result.fileCount,
|
|
166
|
+
sourceBytes: result.sourceBytes, storedBytes: result.storedBytes,
|
|
167
|
+
}, gate);
|
|
168
|
+
await gate.gate();
|
|
169
|
+
await deliveryJson("/admin/api/deliveries", { action: "activate", id: input.deliveryId, packageId: id }, gate);
|
|
133
170
|
}
|
|
134
|
-
else
|
|
135
|
-
await deliveryJson("/admin/api/deliveries", {
|
|
136
|
-
action: "finalizePackage", id: input.deliveryId, packageId: id,
|
|
137
|
-
manifest: result.manifest, fileCount: result.fileCount,
|
|
138
|
-
sourceBytes: result.sourceBytes, storedBytes: result.storedBytes,
|
|
139
|
-
}, gate);
|
|
140
|
-
await gate.gate();
|
|
141
|
-
await deliveryJson("/admin/api/deliveries", { action: "activate", id: input.deliveryId, packageId: id }, gate);
|
|
142
171
|
await gate.gate();
|
|
143
172
|
retries.delete(id);
|
|
144
173
|
patch(id, { state: "done", progress: null, skipped: result.manifest.skipped.length });
|
|
@@ -155,18 +184,22 @@ async function run(input, gate) {
|
|
|
155
184
|
retries.delete(id);
|
|
156
185
|
jobs = jobs.filter((job) => job.id !== id);
|
|
157
186
|
}
|
|
158
|
-
catch
|
|
187
|
+
catch {
|
|
159
188
|
retries.set(id, { input, cleanup: true });
|
|
160
|
-
patch(id, { state: "failed", retryable: true, error: "
|
|
189
|
+
patch(id, { state: "failed", retryable: true, error: "Caricamento interrotto. Premi Riprova per rimuovere i file incompleti." });
|
|
161
190
|
}
|
|
162
191
|
}
|
|
163
192
|
else {
|
|
164
193
|
if (!retries.has(id))
|
|
165
194
|
retries.set(id, { input });
|
|
166
|
-
patch(id, { state: "failed", progress: null, retryable: true, error:
|
|
195
|
+
patch(id, { state: "failed", progress: null, retryable: true, error: transferErrorMessage(error) });
|
|
167
196
|
}
|
|
168
197
|
}
|
|
169
198
|
finally {
|
|
199
|
+
const coordinator = coordinators.get(id);
|
|
200
|
+
if (coordinator)
|
|
201
|
+
await coordinator.pause(gate).catch(() => { });
|
|
202
|
+
coordinators.delete(id);
|
|
170
203
|
gates.delete(id);
|
|
171
204
|
completions += 1;
|
|
172
205
|
emit();
|
|
@@ -178,6 +211,7 @@ export function pauseUpload(id) {
|
|
|
178
211
|
return;
|
|
179
212
|
gate.paused = true;
|
|
180
213
|
patch(id, { state: "paused" });
|
|
214
|
+
void coordinators.get(id)?.pause(gate).catch(() => { });
|
|
181
215
|
}
|
|
182
216
|
export function resumeUpload(id) {
|
|
183
217
|
const gate = gates.get(id);
|
|
@@ -213,12 +247,3 @@ export function dismissUpload(id) {
|
|
|
213
247
|
export function hasRunningUploads() {
|
|
214
248
|
return jobs.some((job) => job.state === "running");
|
|
215
249
|
}
|
|
216
|
-
function readable(error) {
|
|
217
|
-
const raw = error instanceof Error ? error.message : String(error);
|
|
218
|
-
if ((error instanceof DOMException && error.name === "NotReadableError") ||
|
|
219
|
-
raw.includes("requested file could not be read")) {
|
|
220
|
-
return "Il browser non riesce più a leggere uno dei file scelti. " +
|
|
221
|
-
"Riseleziona la stessa cartella e premi «Riprendi».";
|
|
222
|
-
}
|
|
223
|
-
return raw;
|
|
224
|
-
}
|
|
@@ -2,6 +2,10 @@ import type { Delivery, DeliverySettings as DeliverySettingsModel, DeliverySumma
|
|
|
2
2
|
type DeliveryAction = <T>(payload: Record<string, unknown>, options?: {
|
|
3
3
|
reload?: boolean;
|
|
4
4
|
}) => Promise<T>;
|
|
5
|
+
export declare function DeliveryNavHeading({ settingsOpen, onSettings }: {
|
|
6
|
+
settingsOpen: boolean;
|
|
7
|
+
onSettings: () => void;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
5
9
|
export declare function NewDeliveryButton({ onCreate, disabled }: {
|
|
6
10
|
onCreate: () => void;
|
|
7
11
|
disabled?: boolean;
|
|
@@ -17,6 +21,7 @@ export declare function DeliveriesTotal({ rows }: {
|
|
|
17
21
|
}): import("react").JSX.Element | null;
|
|
18
22
|
interface WorkspaceProps {
|
|
19
23
|
delivery: Delivery | null;
|
|
24
|
+
defaultHeroes?: string[];
|
|
20
25
|
busy: boolean;
|
|
21
26
|
onAction: DeliveryAction;
|
|
22
27
|
onRefresh: () => Promise<void>;
|
|
@@ -26,11 +31,12 @@ interface WorkspaceProps {
|
|
|
26
31
|
onOpen: (id: string) => void;
|
|
27
32
|
onSelected: (id: string) => void;
|
|
28
33
|
}
|
|
29
|
-
export declare function DeliveryWorkspace({ delivery: fromServer, busy, onAction, onRefresh, onReload, onRead, onDeleted, onOpen, onSelected, }: WorkspaceProps): import("react").JSX.Element;
|
|
30
|
-
export declare function DeliverySettings({ settings, onAction, pickMedia }: {
|
|
34
|
+
export declare function DeliveryWorkspace({ delivery: fromServer, defaultHeroes, busy, onAction, onRefresh, onReload, onRead, onDeleted, onOpen, onSelected, }: WorkspaceProps): import("react").JSX.Element;
|
|
35
|
+
export declare function DeliverySettings({ settings, onAction, onReload, pickMedia }: {
|
|
31
36
|
settings: DeliverySettingsModel;
|
|
32
37
|
onAction: DeliveryAction;
|
|
33
|
-
|
|
38
|
+
onReload: () => Promise<void>;
|
|
39
|
+
pickMedia?: (options: {
|
|
34
40
|
multiple: boolean;
|
|
35
41
|
}) => Promise<string[] | null>;
|
|
36
42
|
}): import("react").JSX.Element;
|