@dcl/sdk-commands 7.30.2-39321726891.commit-9926e63 → 7.30.2-39796956377.commit-4223559
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/commands/deploy/deployment.d.ts +51 -0
- package/dist/commands/deploy/deployment.js +122 -0
- package/dist/commands/deploy/deployment.js.map +1 -0
- package/dist/commands/deploy/index.d.ts +3 -0
- package/dist/commands/deploy/index.js +74 -38
- package/dist/commands/deploy/index.js.map +1 -1
- package/dist/commands/deploy/routes.d.ts +27 -0
- package/dist/commands/deploy/routes.js +144 -0
- package/dist/commands/deploy/routes.js.map +1 -0
- package/dist/commands/deploy/state.d.ts +60 -0
- package/dist/commands/deploy/state.js +144 -0
- package/dist/commands/deploy/state.js.map +1 -0
- package/dist/commands/deploy/upload.d.ts +23 -0
- package/dist/commands/deploy/upload.js +120 -0
- package/dist/commands/deploy/upload.js.map +1 -0
- package/dist/commands/deploy/utils.d.ts +46 -6
- package/dist/commands/deploy/utils.js +115 -50
- package/dist/commands/deploy/utils.js.map +1 -1
- package/dist/logic/error.d.ts +1 -1
- package/dist/logic/error.js.map +1 -1
- package/dist/logic/fetch.d.ts +8 -0
- package/dist/logic/fetch.js +22 -0
- package/dist/logic/fetch.js.map +1 -1
- package/dist/run-dapp.d.ts +4 -0
- package/dist/run-dapp.js +9 -1
- package/dist/run-dapp.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/commands/deploy/routes.ts"],"names":[],"mappings":";;;AAsDA,0DAsHC;AA5KD,mCAAwC;AACxC,mCAAoC;AAMpC,6CAA6E;AAGhE,QAAA,oBAAoB,GAAG,aAAa,CAAA;AACpC,QAAA,yBAAyB,GAAG,KAAK,CAAA;AAC9C,4FAA4F;AAC/E,QAAA,wBAAwB,GAAG,IAAI,CAAA;AAC/B,QAAA,eAAe,GAAG,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MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type DeploymentPhase = 'awaiting-signature' | 'undeploying' | 'uploading' | 'deployed' | 'failed' | 'cancelled';
|
|
2
|
+
export type UploadStage = 'checking' | 'uploading' | 'processing';
|
|
3
|
+
export type DeploymentUpload = {
|
|
4
|
+
stage: UploadStage;
|
|
5
|
+
sentBytes: number;
|
|
6
|
+
totalBytes: number;
|
|
7
|
+
completedBatches: number | null;
|
|
8
|
+
totalBatches: number | null;
|
|
9
|
+
};
|
|
10
|
+
export type DeploymentResult = {
|
|
11
|
+
entityId: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
};
|
|
14
|
+
export type DeploymentError = {
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export type DeploymentState = {
|
|
19
|
+
phase: DeploymentPhase;
|
|
20
|
+
upload: DeploymentUpload | null;
|
|
21
|
+
result: DeploymentResult | null;
|
|
22
|
+
error: DeploymentError | null;
|
|
23
|
+
cancelRequested: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type UploadProgressUpdate = {
|
|
26
|
+
stage: UploadStage;
|
|
27
|
+
sentBytes: number;
|
|
28
|
+
totalBytes: number;
|
|
29
|
+
};
|
|
30
|
+
export type BatchProgressUpdate = {
|
|
31
|
+
completedBatches: number;
|
|
32
|
+
totalBatches: number;
|
|
33
|
+
};
|
|
34
|
+
export type DeploymentStateListener = (state: DeploymentState) => void;
|
|
35
|
+
export interface IDeploymentStateComponent {
|
|
36
|
+
/** Returns a snapshot of the current state. */
|
|
37
|
+
get(): DeploymentState;
|
|
38
|
+
isFinal(): boolean;
|
|
39
|
+
/** Moves a deployment in progress to `undeploying` or `uploading`. Ignored once final. */
|
|
40
|
+
setPhase(phase: 'undeploying' | 'uploading'): void;
|
|
41
|
+
/** Records byte-level progress. Notifications are throttled unless the stage changes. */
|
|
42
|
+
reportUpload(progress: UploadProgressUpdate): void;
|
|
43
|
+
/** Records batch progress of a partial upload, or `null` when the upload uses a single request. */
|
|
44
|
+
reportBatches(progress: BatchProgressUpdate | null): void;
|
|
45
|
+
deployed(result: DeploymentResult): void;
|
|
46
|
+
failed(error: DeploymentError): void;
|
|
47
|
+
/** Records that a cancellation was accepted while the outcome is still pending. Ignored once final. */
|
|
48
|
+
requestCancel(): void;
|
|
49
|
+
/** Ends as `cancelled`; `error` carries a caveat about the outcome, e.g. the world was already undeployed. */
|
|
50
|
+
cancelled(error?: DeploymentError): void;
|
|
51
|
+
/** Calls `listener` on every change until the returned function is called. */
|
|
52
|
+
subscribe(listener: DeploymentStateListener): () => void;
|
|
53
|
+
subscriberCount(): number;
|
|
54
|
+
}
|
|
55
|
+
export declare const FINAL_PHASES: ReadonlySet<DeploymentPhase>;
|
|
56
|
+
export declare const PROGRESS_NOTIFICATION_INTERVAL_MS = 250;
|
|
57
|
+
export declare function createDeploymentState(options?: {
|
|
58
|
+
progressIntervalMs?: number;
|
|
59
|
+
now?: () => number;
|
|
60
|
+
}): IDeploymentStateComponent;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROGRESS_NOTIFICATION_INTERVAL_MS = exports.FINAL_PHASES = void 0;
|
|
4
|
+
exports.createDeploymentState = createDeploymentState;
|
|
5
|
+
exports.FINAL_PHASES = new Set(['deployed', 'failed', 'cancelled']);
|
|
6
|
+
exports.PROGRESS_NOTIFICATION_INTERVAL_MS = 250;
|
|
7
|
+
function createDeploymentState(options = {}) {
|
|
8
|
+
const progressIntervalMs = options.progressIntervalMs ?? exports.PROGRESS_NOTIFICATION_INTERVAL_MS;
|
|
9
|
+
const now = options.now ?? Date.now;
|
|
10
|
+
const listeners = new Set();
|
|
11
|
+
let state = {
|
|
12
|
+
phase: 'awaiting-signature',
|
|
13
|
+
upload: null,
|
|
14
|
+
result: null,
|
|
15
|
+
error: null,
|
|
16
|
+
cancelRequested: false
|
|
17
|
+
};
|
|
18
|
+
let batches = {
|
|
19
|
+
completedBatches: null,
|
|
20
|
+
totalBatches: null
|
|
21
|
+
};
|
|
22
|
+
// Keeps sentBytes monotonic when an upload restarts (a partial upload falling back to a single request).
|
|
23
|
+
let restartOffset = 0;
|
|
24
|
+
let lastSentBytes = 0;
|
|
25
|
+
let lastNotification = 0;
|
|
26
|
+
let pendingTimer;
|
|
27
|
+
function snapshot() {
|
|
28
|
+
return {
|
|
29
|
+
...state,
|
|
30
|
+
upload: state.upload && { ...state.upload },
|
|
31
|
+
result: state.result && { ...state.result },
|
|
32
|
+
error: state.error && { ...state.error }
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function notify() {
|
|
36
|
+
if (pendingTimer) {
|
|
37
|
+
clearTimeout(pendingTimer);
|
|
38
|
+
pendingTimer = undefined;
|
|
39
|
+
}
|
|
40
|
+
lastNotification = now();
|
|
41
|
+
const current = snapshot();
|
|
42
|
+
for (const listener of Array.from(listeners)) {
|
|
43
|
+
try {
|
|
44
|
+
listener(current);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
listeners.delete(listener);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function notifyThrottled() {
|
|
52
|
+
const elapsed = now() - lastNotification;
|
|
53
|
+
if (elapsed >= progressIntervalMs) {
|
|
54
|
+
notify();
|
|
55
|
+
}
|
|
56
|
+
else if (!pendingTimer) {
|
|
57
|
+
pendingTimer = setTimeout(notify, progressIntervalMs - elapsed);
|
|
58
|
+
pendingTimer.unref?.();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function isFinal() {
|
|
62
|
+
return exports.FINAL_PHASES.has(state.phase);
|
|
63
|
+
}
|
|
64
|
+
function finish(next) {
|
|
65
|
+
if (isFinal())
|
|
66
|
+
return;
|
|
67
|
+
state = { ...state, ...next };
|
|
68
|
+
notify();
|
|
69
|
+
listeners.clear();
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
get: snapshot,
|
|
73
|
+
isFinal,
|
|
74
|
+
setPhase(phase) {
|
|
75
|
+
if (isFinal() || state.phase === phase)
|
|
76
|
+
return;
|
|
77
|
+
state = { ...state, phase };
|
|
78
|
+
notify();
|
|
79
|
+
},
|
|
80
|
+
reportUpload({ stage, sentBytes, totalBytes }) {
|
|
81
|
+
if (isFinal())
|
|
82
|
+
return;
|
|
83
|
+
if (sentBytes < lastSentBytes) {
|
|
84
|
+
restartOffset = state.upload?.sentBytes ?? 0;
|
|
85
|
+
}
|
|
86
|
+
lastSentBytes = sentBytes;
|
|
87
|
+
const previousStage = state.upload?.stage;
|
|
88
|
+
state = {
|
|
89
|
+
...state,
|
|
90
|
+
phase: 'uploading',
|
|
91
|
+
upload: {
|
|
92
|
+
stage,
|
|
93
|
+
sentBytes: restartOffset + sentBytes,
|
|
94
|
+
totalBytes: restartOffset + totalBytes,
|
|
95
|
+
...batches
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
if (previousStage === stage) {
|
|
99
|
+
notifyThrottled();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
notify();
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
reportBatches(progress) {
|
|
106
|
+
if (isFinal())
|
|
107
|
+
return;
|
|
108
|
+
batches = progress
|
|
109
|
+
? { completedBatches: progress.completedBatches, totalBatches: progress.totalBatches }
|
|
110
|
+
: { completedBatches: null, totalBatches: null };
|
|
111
|
+
if (!state.upload)
|
|
112
|
+
return;
|
|
113
|
+
state = { ...state, upload: { ...state.upload, ...batches } };
|
|
114
|
+
notifyThrottled();
|
|
115
|
+
},
|
|
116
|
+
deployed(result) {
|
|
117
|
+
finish({ phase: 'deployed', result: { ...result } });
|
|
118
|
+
},
|
|
119
|
+
failed(error) {
|
|
120
|
+
finish({ phase: 'failed', error: { ...error } });
|
|
121
|
+
},
|
|
122
|
+
requestCancel() {
|
|
123
|
+
if (isFinal() || state.cancelRequested)
|
|
124
|
+
return;
|
|
125
|
+
state = { ...state, cancelRequested: true };
|
|
126
|
+
notify();
|
|
127
|
+
},
|
|
128
|
+
cancelled(error) {
|
|
129
|
+
finish({ phase: 'cancelled', ...(error ? { error: { ...error } } : {}) });
|
|
130
|
+
},
|
|
131
|
+
subscribe(listener) {
|
|
132
|
+
if (isFinal())
|
|
133
|
+
return () => { };
|
|
134
|
+
listeners.add(listener);
|
|
135
|
+
return () => {
|
|
136
|
+
listeners.delete(listener);
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
subscriberCount() {
|
|
140
|
+
return listeners.size;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/commands/deploy/state.ts"],"names":[],"mappings":";;;AAuDA,sDAuIC;AA3IY,QAAA,YAAY,GAAiC,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAA;AAEzF,QAAA,iCAAiC,GAAG,GAAG,CAAA;AAEpD,SAAgB,qBAAqB,CACnC,UAA+D,EAAE;IAEjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,yCAAiC,CAAA;IAC1F,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAA;IACnC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAA;IAEpD,IAAI,KAAK,GAAoB;QAC3B,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,IAAI;QACX,eAAe,EAAE,KAAK;KACvB,CAAA;IACD,IAAI,OAAO,GAAqE;QAC9E,gBAAgB,EAAE,IAAI;QACtB,YAAY,EAAE,IAAI;KACnB,CAAA;IACD,yGAAyG;IACzG,IAAI,aAAa,GAAG,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AAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC,CAAA;QACH,CAAC;QACD,eAAe;YACb,OAAO,SAAS,CAAC,IAAI,CAAA;QACvB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ContentClient } from 'dcl-catalyst-client';
|
|
2
|
+
import { CliComponents } from '../../components';
|
|
3
|
+
import { IDeploymentStateComponent } from './state';
|
|
4
|
+
type DeploymentData = Parameters<ContentClient['deploy']>[0];
|
|
5
|
+
export type UploadResult = {
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
export type UploadOptions = {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
progress?: Pick<IDeploymentStateComponent, 'reportUpload' | 'reportBatches'>;
|
|
11
|
+
};
|
|
12
|
+
export declare const CONTENT_AVAILABILITY_TIMEOUT_MS = 30000;
|
|
13
|
+
export declare const MAX_SINGLE_REQUEST_BYTES: number;
|
|
14
|
+
export declare const MIN_PARTIAL_DEPLOYMENT_BYTES: number;
|
|
15
|
+
export declare const PARTIAL_BATCH_BYTES: number;
|
|
16
|
+
export declare const PARTIAL_BATCH_CONCURRENCY = 3;
|
|
17
|
+
/**
|
|
18
|
+
* Uploads a deployment of at least {@link MIN_PARTIAL_DEPLOYMENT_BYTES} in size-bounded batches when the
|
|
19
|
+
* client supports partial deployments, falling back to a single request for servers that don't support them.
|
|
20
|
+
* Smaller deployments always use a single request.
|
|
21
|
+
*/
|
|
22
|
+
export declare function uploadDeployment(components: Pick<CliComponents, 'logger'>, client: ContentClient, deployData: DeploymentData, options?: UploadOptions): Promise<UploadResult>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PARTIAL_BATCH_CONCURRENCY = exports.PARTIAL_BATCH_BYTES = exports.MIN_PARTIAL_DEPLOYMENT_BYTES = exports.MAX_SINGLE_REQUEST_BYTES = exports.CONTENT_AVAILABILITY_TIMEOUT_MS = void 0;
|
|
4
|
+
exports.uploadDeployment = uploadDeployment;
|
|
5
|
+
const dcl_catalyst_client_1 = require("dcl-catalyst-client");
|
|
6
|
+
const error_1 = require("../../logic/error");
|
|
7
|
+
const beautiful_logs_1 = require("../../logic/beautiful-logs");
|
|
8
|
+
const fetch_1 = require("../../logic/fetch");
|
|
9
|
+
const REQUEST_TIMEOUT_MS = 600000;
|
|
10
|
+
exports.CONTENT_AVAILABILITY_TIMEOUT_MS = 30000;
|
|
11
|
+
// The infrastructure in front of the content servers times out requests larger than ~200MB.
|
|
12
|
+
exports.MAX_SINGLE_REQUEST_BYTES = 200 * 1000 * 1000;
|
|
13
|
+
// Smaller scenes upload faster in one request than in batches.
|
|
14
|
+
exports.MIN_PARTIAL_DEPLOYMENT_BYTES = 50 * 1024 * 1024;
|
|
15
|
+
// Batches small enough that the server stores one while the next is still uploading.
|
|
16
|
+
exports.PARTIAL_BATCH_BYTES = 32 * 1024 * 1024;
|
|
17
|
+
exports.PARTIAL_BATCH_CONCURRENCY = 3;
|
|
18
|
+
function formatMegabytes(bytes) {
|
|
19
|
+
return `${(bytes / 1e6).toFixed(1)} MB`;
|
|
20
|
+
}
|
|
21
|
+
function batchSize(deployData) {
|
|
22
|
+
let largest = 0;
|
|
23
|
+
for (const file of deployData.files.values()) {
|
|
24
|
+
largest = Math.max(largest, file.byteLength);
|
|
25
|
+
}
|
|
26
|
+
return Math.max(exports.PARTIAL_BATCH_BYTES, largest);
|
|
27
|
+
}
|
|
28
|
+
function deploymentSize(deployData) {
|
|
29
|
+
let total = 0;
|
|
30
|
+
for (const file of deployData.files.values()) {
|
|
31
|
+
total += file.byteLength;
|
|
32
|
+
}
|
|
33
|
+
return total;
|
|
34
|
+
}
|
|
35
|
+
async function fetchAvailableContent(client, contentHashes, signal) {
|
|
36
|
+
try {
|
|
37
|
+
const availability = await (0, fetch_1.withDeadline)((deadline) => {
|
|
38
|
+
const init = { signal: deadline, rejectHttpErrors: true };
|
|
39
|
+
return client.isContentAvailable(contentHashes, init);
|
|
40
|
+
}, { timeoutMs: exports.CONTENT_AVAILABILITY_TIMEOUT_MS, signal });
|
|
41
|
+
if (!Array.isArray(availability))
|
|
42
|
+
throw new Error('unexpected response');
|
|
43
|
+
return new Set(availability.filter(({ available }) => available === true).map(({ cid }) => cid));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (signal?.aborted)
|
|
47
|
+
throw error;
|
|
48
|
+
const reason = error?.message ?? String(error);
|
|
49
|
+
throw new error_1.CliError('DEPLOY_CONTENT_CHECK_FAILED', `Couldn't check which content the server already has (${reason})`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// A single request only uploads the files missing on the server, plus the entity file.
|
|
53
|
+
async function missingBytes(client, deployData, signal) {
|
|
54
|
+
const contentHashes = Array.from(deployData.files.keys()).filter((hash) => hash !== deployData.entityId);
|
|
55
|
+
const available = contentHashes.length ? await fetchAvailableContent(client, contentHashes, signal) : new Set();
|
|
56
|
+
let total = 0;
|
|
57
|
+
for (const [hash, file] of deployData.files) {
|
|
58
|
+
if (!available.has(hash))
|
|
59
|
+
total += file.byteLength;
|
|
60
|
+
}
|
|
61
|
+
return total;
|
|
62
|
+
}
|
|
63
|
+
function uploadProgressReporter(progress) {
|
|
64
|
+
return (progress &&
|
|
65
|
+
(({ phase, sentBytes, totalBytes }) => progress.reportUpload({ stage: phase, sentBytes, totalBytes })));
|
|
66
|
+
}
|
|
67
|
+
async function uploadInSingleRequest(client, deployData, { signal, progress }) {
|
|
68
|
+
progress?.reportBatches(null);
|
|
69
|
+
const response = (await client.deploy(deployData, {
|
|
70
|
+
timeout: REQUEST_TIMEOUT_MS,
|
|
71
|
+
signal,
|
|
72
|
+
onUploadProgress: uploadProgressReporter(progress)
|
|
73
|
+
}));
|
|
74
|
+
if (response.status !== 200) {
|
|
75
|
+
throw new Error(await response.text());
|
|
76
|
+
}
|
|
77
|
+
return (await response.json());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Uploads a deployment of at least {@link MIN_PARTIAL_DEPLOYMENT_BYTES} in size-bounded batches when the
|
|
81
|
+
* client supports partial deployments, falling back to a single request for servers that don't support them.
|
|
82
|
+
* Smaller deployments always use a single request.
|
|
83
|
+
*/
|
|
84
|
+
async function uploadDeployment(components, client, deployData, options = {}) {
|
|
85
|
+
const { signal, progress } = options;
|
|
86
|
+
const size = deploymentSize(deployData);
|
|
87
|
+
if (size < exports.MIN_PARTIAL_DEPLOYMENT_BYTES) {
|
|
88
|
+
return uploadInSingleRequest(client, deployData, options);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
progress?.reportBatches({ completedBatches: 0, totalBatches: 1 });
|
|
92
|
+
const result = await client.deployPartial(deployData, {
|
|
93
|
+
timeout: REQUEST_TIMEOUT_MS,
|
|
94
|
+
signal,
|
|
95
|
+
maxBatchSizeBytes: batchSize(deployData),
|
|
96
|
+
concurrency: exports.PARTIAL_BATCH_CONCURRENCY,
|
|
97
|
+
onUploadProgress: uploadProgressReporter(progress),
|
|
98
|
+
onProgress: ({ uploadedBytes, totalBytes, completedBatches, totalBatches }) => {
|
|
99
|
+
progress?.reportBatches({ completedBatches, totalBatches });
|
|
100
|
+
(0, beautiful_logs_1.printProgressInfo)(components.logger, `Uploaded ${formatMegabytes(uploadedBytes)} of ${formatMegabytes(totalBytes)} ` +
|
|
101
|
+
`(batch ${completedBatches}/${totalBatches})`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return { message: result.message };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (!(error instanceof dcl_catalyst_client_1.PartialDeploymentNotSupportedError) || signal?.aborted) {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
const missing = size > exports.MAX_SINGLE_REQUEST_BYTES ? await missingBytes(client, deployData, signal) : size;
|
|
111
|
+
if (missing > exports.MAX_SINGLE_REQUEST_BYTES) {
|
|
112
|
+
throw new error_1.CliError('DEPLOY_PARTIAL_NOT_SUPPORTED', `The target server does not support batched uploads, and the content of this scene missing on it ` +
|
|
113
|
+
`(${formatMegabytes(missing)}) is too large to upload in a single request ` +
|
|
114
|
+
`(max ${formatMegabytes(exports.MAX_SINGLE_REQUEST_BYTES)}).`);
|
|
115
|
+
}
|
|
116
|
+
components.logger.warn('The target server does not support batched uploads, uploading in a single request.');
|
|
117
|
+
return uploadInSingleRequest(client, deployData, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../src/commands/deploy/upload.ts"],"names":[],"mappings":";;;AA4HA,4CA8CC;AA1KD,6DAK4B;AAE5B,6CAA4C;AAC5C,+DAA8D;AAC9D,6CAAgD;AAkBhD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEpB,QAAA,+BAA+B,GAAG,KAAK,CAAA;AAEpD,4FAA4F;AAC/E,QAAA,wBAAwB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;AAEzD,+DAA+D;AAClD,QAAA,4BAA4B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAE5D,qFAAqF;AACxE,QAAA,mBAAmB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AACtC,QAAA,yBAAyB,GAAG,CAAC,CAAA;AAE1C,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;AACzC,CAAC;AAED,SAAS,SAAS,CAAC,UAA0B;IAC3C,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE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AE,YAAY,EAAE,CAAC,CAAA;gBAC3D,IAAA,kCAAiB,EACf,UAAU,CAAC,MAAM,EACjB,YAAY,eAAe,CAAC,aAAa,CAAC,OAAO,eAAe,CAAC,UAAU,CAAC,GAAG;oBAC7E,UAAU,gBAAgB,IAAI,YAAY,GAAG,CAChD,CAAA;YACH,CAAC;SACF,CAAC,CAAA;QACF,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAA;IACpC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,CAAC,CAAC,KAAK,YAAY,wDAAkC,CAAC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YAC9E,MAAM,KAAK,CAAA;QACb,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,GAAG,gCAAwB,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACvG,IAAI,OAAO,GAAG,gCAAwB,EAAE,CAAC;YACvC,MAAM,IAAI,gBAAQ,CAChB,8BAA8B,EAC9B,kGAAkG;gBAChG,IAAI,eAAe,CAAC,OAAO,CAAC,+CAA+C;gBAC3E,QAAQ,eAAe,CAAC,gCAAwB,CAAC,IAAI,CACxD,CAAA;QACH,CAAC;QACD,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAA;QAC5G,OAAO,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -3,18 +3,47 @@ import { Lifecycle } from '@well-known-components/interfaces';
|
|
|
3
3
|
import { ContentClient } from 'dcl-catalyst-client';
|
|
4
4
|
import { CliComponents } from '../../components';
|
|
5
5
|
import { IFile } from '../../logic/scene-validations';
|
|
6
|
-
import { LinkerResponse } from '../../linker-dapp/routes';
|
|
7
6
|
import { IFuture } from '../../logic/future';
|
|
8
7
|
import { dAppOptions } from '../../run-dapp';
|
|
8
|
+
import { IDeploymentComponent } from './deployment';
|
|
9
|
+
/**
|
|
10
|
+
* Minimal undici-backed fetch component for the catalyst client. Replaces
|
|
11
|
+
* @well-known-components/fetch-component, which uses cross-fetch -> node-fetch v2
|
|
12
|
+
* and trips a gzip "Premature close" under keep-alive socket reuse on recent Node
|
|
13
|
+
* runtimes (nodejs/node#63989). Honors the `timeout`, `signal` and `abortController`
|
|
14
|
+
* options via an AbortController (until the headers arrive); `rejectHttpErrors` rejects
|
|
15
|
+
* non-2xx responses with an {@link HttpStatusError}. All other init fields (including
|
|
16
|
+
* `duplex` for streamed uploads) pass straight through to undici.fetch.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createFetchComponent(): {
|
|
19
|
+
fetch(url: string, init?: CatalystFetchInit): Promise<Response>;
|
|
20
|
+
};
|
|
21
|
+
export type CatalystFetchInit = RequestInit & {
|
|
22
|
+
timeout?: number;
|
|
23
|
+
abortController?: AbortController;
|
|
24
|
+
rejectHttpErrors?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare class HttpStatusError extends Error {
|
|
27
|
+
readonly status: number;
|
|
28
|
+
constructor(status: number);
|
|
29
|
+
}
|
|
9
30
|
export declare function getCatalyst(chainId?: ChainId, target?: string, targetContent?: string): Promise<{
|
|
10
31
|
client: ContentClient;
|
|
11
32
|
url: string;
|
|
12
33
|
}>;
|
|
13
34
|
export declare function buildDeleteScenesFromWorldPayload(worldName: string): string;
|
|
14
|
-
export declare function deleteWorldScenes(components: Pick<CliComponents, 'logger'>, worldName: string, deleteSignature: string, targetContent?: string): Promise<Response>;
|
|
15
|
-
export declare function getAddressAndSignature(components: CliComponents, awaitResponse: IFuture<void>, messageToSign: string, scene: Scene, files: IFile[], skipValidations: boolean, linkOptions: Omit<dAppOptions, 'uri'>,
|
|
35
|
+
export declare function deleteWorldScenes(components: Pick<CliComponents, 'logger'>, worldName: string, deleteSignature: string, targetContent?: string, signal?: AbortSignal): Promise<Response>;
|
|
36
|
+
export declare function getAddressAndSignature(components: CliComponents, awaitResponse: IFuture<void>, messageToSign: string, scene: Scene, files: IFile[], skipValidations: boolean, linkOptions: Omit<dAppOptions, 'uri'>, deployment: IDeploymentComponent, deployToken: string, deleteScenesFromWorldPayload?: string, targetContent?: string, multiScene?: boolean): Promise<{
|
|
16
37
|
program?: Lifecycle.ComponentBasedProgram<unknown>;
|
|
17
38
|
}>;
|
|
39
|
+
export declare const MIN_DEPLOY_TOKEN_LENGTH = 16;
|
|
40
|
+
/** The `--deploy-token` given to the CLI, or a random one for this run. */
|
|
41
|
+
export declare function resolveDeployToken(deployTokenArg?: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* The linker dapp reads the token that authorizes cancelling the deployment from its URL fragment, which is
|
|
44
|
+
* never sent in HTTP requests.
|
|
45
|
+
*/
|
|
46
|
+
export declare function deployLinkerUri(deployToken: string): string;
|
|
18
47
|
export declare function sceneHasWorldCfg(scene: Scene): boolean;
|
|
19
48
|
export interface SceneInfo {
|
|
20
49
|
baseParcel: string;
|
|
@@ -65,6 +94,17 @@ export declare function getScenesOnOtherParcels(existingScenes: WorldScene[], de
|
|
|
65
94
|
export declare function fetchWorldScenes(logger: {
|
|
66
95
|
info: (msg: string) => void;
|
|
67
96
|
}, worldName: string, targetContent?: string): Promise<WorldScene[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the entity is live on the content server. Worlds servers don't list entities by id, so a world
|
|
99
|
+
* is checked through its scenes.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isEntityPublished(client: Pick<ContentClient, 'fetchEntitiesByIds'>, entityId: string, options: {
|
|
102
|
+
world?: {
|
|
103
|
+
name: string;
|
|
104
|
+
targetContent: string;
|
|
105
|
+
};
|
|
106
|
+
timeoutMs: number;
|
|
107
|
+
}): Promise<boolean>;
|
|
68
108
|
export declare function promptUser(question: string): Promise<boolean>;
|
|
69
109
|
interface WorldPermissionsResponse {
|
|
70
110
|
permissions: {
|
|
@@ -80,11 +120,11 @@ interface WorldPermissionsResponse {
|
|
|
80
120
|
parcel_count: number;
|
|
81
121
|
}[]>;
|
|
82
122
|
}
|
|
83
|
-
export declare function fetchWorldPermissions(worldName: string, targetContent: string): Promise<WorldPermissionsResponse>;
|
|
84
|
-
export declare function fetchParcelPermissions(worldName: string, address: string, targetContent: string): Promise<string[]>;
|
|
123
|
+
export declare function fetchWorldPermissions(worldName: string, targetContent: string, signal?: AbortSignal): Promise<WorldPermissionsResponse>;
|
|
124
|
+
export declare function fetchParcelPermissions(worldName: string, address: string, targetContent: string, signal?: AbortSignal): Promise<string[]>;
|
|
85
125
|
export declare function checkWorldDeploymentPermission(logger: {
|
|
86
126
|
info: (msg: string) => void;
|
|
87
|
-
}, worldName: string, address: string, targetContent: string, deployingParcels: string[]): Promise<{
|
|
127
|
+
}, worldName: string, address: string, targetContent: string, deployingParcels: string[], signal?: AbortSignal): Promise<{
|
|
88
128
|
allowed: boolean;
|
|
89
129
|
deniedParcels?: string[];
|
|
90
130
|
}>;
|