@dcl/sdk-commands 7.33.1-44149226847.commit-7d1c56d → 7.33.1-45222477492.commit-218d1ca
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 +0 -48
- package/dist/commands/start/index.d.ts +0 -1
- package/dist/commands/start/index.js +6 -24
- package/dist/commands/start/index.js.map +1 -1
- package/dist/commands/start/server/routes.d.ts +1 -1
- package/dist/commands/start/server/routes.js +2 -6
- package/dist/commands/start/server/routes.js.map +1 -1
- package/dist/commands/start/utils.d.ts +0 -32
- package/dist/commands/start/utils.js +0 -72
- package/dist/commands/start/utils.js.map +1 -1
- package/dist/components/analytics.d.ts +1 -75
- package/dist/components/analytics.js +2 -3
- package/dist/components/analytics.js.map +1 -1
- package/dist/logic/bundle.js +0 -32
- package/dist/logic/bundle.js.map +1 -1
- package/dist/logic/config.d.ts +0 -1
- package/dist/logic/config.js +0 -7
- package/dist/logic/config.js.map +1 -1
- package/dist/logic/error.d.ts +1 -1
- package/dist/logic/error.js.map +1 -1
- package/dist/logic/exec.d.ts +0 -1
- package/dist/logic/exec.js +2 -2
- package/dist/logic/exec.js.map +1 -1
- package/dist/logic/lang.js +1 -1
- package/dist/logic/project-files.js +0 -2
- package/dist/logic/project-files.js.map +1 -1
- package/dist/logic/scene-validations.d.ts +1 -8
- package/dist/logic/scene-validations.js.map +1 -1
- package/dist/run-command.js +2 -3
- package/dist/run-command.js.map +1 -1
- package/package.json +4 -5
- package/dist/commands/scene-insights/actions.d.ts +0 -63
- package/dist/commands/scene-insights/actions.js +0 -106
- package/dist/commands/scene-insights/actions.js.map +0 -1
- package/dist/commands/scene-insights/client.d.ts +0 -51
- package/dist/commands/scene-insights/client.js +0 -294
- package/dist/commands/scene-insights/client.js.map +0 -1
- package/dist/commands/scene-insights/format.d.ts +0 -23
- package/dist/commands/scene-insights/format.js +0 -143
- package/dist/commands/scene-insights/format.js.map +0 -1
- package/dist/commands/scene-insights/index.d.ts +0 -51
- package/dist/commands/scene-insights/index.js +0 -327
- package/dist/commands/scene-insights/index.js.map +0 -1
- package/dist/commands/scene-insights/inputs.d.ts +0 -49
- package/dist/commands/scene-insights/inputs.js +0 -166
- package/dist/commands/scene-insights/inputs.js.map +0 -1
- package/dist/commands/scene-insights/session-store.d.ts +0 -43
- package/dist/commands/scene-insights/session-store.js +0 -132
- package/dist/commands/scene-insights/session-store.js.map +0 -1
- package/dist/commands/scene-insights/session.d.ts +0 -46
- package/dist/commands/scene-insights/session.js +0 -92
- package/dist/commands/scene-insights/session.js.map +0 -1
- package/dist/commands/scene-insights/sign-in.d.ts +0 -48
- package/dist/commands/scene-insights/sign-in.js +0 -125
- package/dist/commands/scene-insights/sign-in.js.map +0 -1
- package/dist/commands/scene-insights/signature-validation.d.ts +0 -6
- package/dist/commands/scene-insights/signature-validation.js +0 -100
- package/dist/commands/scene-insights/signature-validation.js.map +0 -1
- package/dist/commands/scene-insights/types.d.ts +0 -61
- package/dist/commands/scene-insights/types.js +0 -4
- package/dist/commands/scene-insights/types.js.map +0 -1
- package/dist/commands/sdk-server-logs/index.d.ts +0 -24
- package/dist/commands/sdk-server-logs/index.js +0 -315
- package/dist/commands/sdk-server-logs/index.js.map +0 -1
- package/dist/commands/start/dcl-env.d.ts +0 -16
- package/dist/commands/start/dcl-env.js +0 -51
- package/dist/commands/start/dcl-env.js.map +0 -1
- package/dist/commands/start/multiplayer-server.d.ts +0 -35
- package/dist/commands/start/multiplayer-server.js +0 -244
- package/dist/commands/start/multiplayer-server.js.map +0 -1
- package/dist/commands/start/server/runtime-env.d.ts +0 -84
- package/dist/commands/start/server/runtime-env.js +0 -415
- package/dist/commands/start/server/runtime-env.js.map +0 -1
- package/dist/commands/start/server/storage-service.d.ts +0 -8
- package/dist/commands/start/server/storage-service.js +0 -243
- package/dist/commands/start/server/storage-service.js.map +0 -1
- package/dist/commands/storage/env.d.ts +0 -5
- package/dist/commands/storage/env.js +0 -86
- package/dist/commands/storage/env.js.map +0 -1
- package/dist/commands/storage/index.d.ts +0 -26
- package/dist/commands/storage/index.js +0 -142
- package/dist/commands/storage/index.js.map +0 -1
- package/dist/commands/storage/player.d.ts +0 -5
- package/dist/commands/storage/player.js +0 -143
- package/dist/commands/storage/player.js.map +0 -1
- package/dist/commands/storage/scene.d.ts +0 -5
- package/dist/commands/storage/scene.js +0 -105
- package/dist/commands/storage/scene.js.map +0 -1
- package/dist/commands/storage/shared.d.ts +0 -62
- package/dist/commands/storage/shared.js +0 -260
- package/dist/commands/storage/shared.js.map +0 -1
- package/dist/commands/storage/types.d.ts +0 -56
- package/dist/commands/storage/types.js +0 -23
- package/dist/commands/storage/types.js.map +0 -1
- package/dist/logic/auth-chain-headers.d.ts +0 -11
- package/dist/logic/auth-chain-headers.js +0 -25
- package/dist/logic/auth-chain-headers.js.map +0 -1
- package/dist/logic/lsd-realm.d.ts +0 -5
- package/dist/logic/lsd-realm.js +0 -28
- package/dist/logic/lsd-realm.js.map +0 -1
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXIT_CODES = exports.args = void 0;
|
|
4
|
-
exports.help = help;
|
|
5
|
-
exports.main = main;
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const args_1 = require("../../logic/args");
|
|
8
|
-
const error_1 = require("../../logic/error");
|
|
9
|
-
const account_1 = require("../../logic/account");
|
|
10
|
-
const workspace_validations_1 = require("../../logic/workspace-validations");
|
|
11
|
-
const scene_validations_1 = require("../../logic/scene-validations");
|
|
12
|
-
const actions_1 = require("./actions");
|
|
13
|
-
const client_1 = require("./client");
|
|
14
|
-
const inputs_1 = require("./inputs");
|
|
15
|
-
const session_store_1 = require("./session-store");
|
|
16
|
-
const sign_in_1 = require("./sign-in");
|
|
17
|
-
const signature_validation_1 = require("./signature-validation");
|
|
18
|
-
exports.args = (0, args_1.declareArgs)({
|
|
19
|
-
'--help': Boolean,
|
|
20
|
-
'-h': '--help',
|
|
21
|
-
'--dir': String,
|
|
22
|
-
'--world': String,
|
|
23
|
-
'-w': '--world',
|
|
24
|
-
'--position': String,
|
|
25
|
-
'--target': String,
|
|
26
|
-
'-t': '--target',
|
|
27
|
-
'--trust-target': Boolean,
|
|
28
|
-
'--port': Number,
|
|
29
|
-
'-p': '--port',
|
|
30
|
-
'--https': Boolean,
|
|
31
|
-
'--no-browser': Boolean,
|
|
32
|
-
'-b': '--no-browser',
|
|
33
|
-
'--from': String,
|
|
34
|
-
'--to': String,
|
|
35
|
-
'--level': String,
|
|
36
|
-
'-l': '--level',
|
|
37
|
-
'--source': String,
|
|
38
|
-
'--query': String,
|
|
39
|
-
'-q': '--query',
|
|
40
|
-
'--execution': String,
|
|
41
|
-
'--limit': Number,
|
|
42
|
-
'-n': '--limit',
|
|
43
|
-
'--order': String,
|
|
44
|
-
'--lines': Number,
|
|
45
|
-
'--for': String,
|
|
46
|
-
'--step': Number,
|
|
47
|
-
'--json': Boolean
|
|
48
|
-
});
|
|
49
|
-
const DEFAULT_SERVER = 'https://multiplayer-scenes-insights-service.decentraland.org';
|
|
50
|
-
const QUERY_SUBCOMMANDS = ['logs', 'tail', 'metrics', 'executions'];
|
|
51
|
-
const SESSION_SUBCOMMANDS = ['login', 'logout', 'session'];
|
|
52
|
-
const TARGET_FLAGS = ['--target', '--trust-target'];
|
|
53
|
-
const SIGN_IN_FLAGS = ['--port', '--no-browser', '--https'];
|
|
54
|
-
const SCENE_FLAGS = [...TARGET_FLAGS, ...SIGN_IN_FLAGS, '--world', '--position', '--dir'];
|
|
55
|
-
/** The flags each subcommand reads, besides --help and --json; any other is refused rather than ignored. */
|
|
56
|
-
const FLAGS_BY_SUBCOMMAND = {
|
|
57
|
-
login: [...TARGET_FLAGS, ...SIGN_IN_FLAGS],
|
|
58
|
-
logout: [],
|
|
59
|
-
session: [...TARGET_FLAGS],
|
|
60
|
-
logs: [...SCENE_FLAGS, '--from', '--to', '--level', '--source', '--query', '--execution', '--limit', '--order'],
|
|
61
|
-
tail: [...SCENE_FLAGS, '--for', '--lines', '--level', '--query'],
|
|
62
|
-
metrics: [...SCENE_FLAGS, '--from', '--to', '--step', '--execution'],
|
|
63
|
-
executions: [...SCENE_FLAGS, '--from', '--to']
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Exit codes, so a script or an agent can tell what to do next without parsing messages:
|
|
67
|
-
* 2 fix the arguments, 3 have a person sign in, 4 use an address with access, 5 check the scene,
|
|
68
|
-
* 6 try again later. Anything else exits with 1.
|
|
69
|
-
*/
|
|
70
|
-
exports.EXIT_CODES = {
|
|
71
|
-
SCENE_INSIGHTS_INVALID_ARGUMENT: 2,
|
|
72
|
-
SCENE_INSIGHTS_MISSING_SCENE: 2,
|
|
73
|
-
SCENE_INSIGHTS_UNSAFE_SESSION_FILE: 2,
|
|
74
|
-
SCENE_INSIGHTS_SESSION_REQUIRED: 3,
|
|
75
|
-
SCENE_INSIGHTS_UNAUTHORIZED: 3,
|
|
76
|
-
SCENE_INSIGHTS_INVALID_SIGNATURE: 3,
|
|
77
|
-
SCENE_INSIGHTS_UNSUPPORTED_WALLET: 3,
|
|
78
|
-
SCENE_INSIGHTS_FORBIDDEN: 4,
|
|
79
|
-
SCENE_INSIGHTS_NOT_FOUND: 5,
|
|
80
|
-
SCENE_INSIGHTS_UNAVAILABLE: 6
|
|
81
|
-
};
|
|
82
|
-
function help(options) {
|
|
83
|
-
options.components.logger.log(`
|
|
84
|
-
Usage: 'sdk-commands scene-insights <subcommand> [options]'
|
|
85
|
-
Reads the persisted logs and metrics of an authoritative multiplayer scene (kept for 7 days)
|
|
86
|
-
from multiplayer-scenes-insights-service. The signed-in address must be in the scene's
|
|
87
|
-
logsPermissions, the World's owner, or a World deployment collaborator whose grant covers
|
|
88
|
-
the whole World or every deployed parcel of the scene. For Genesis City, the owner or
|
|
89
|
-
delegated LAND manager (operator, updateOperator, updateManager, approvedForAll) of the
|
|
90
|
-
deployed scene's base parcel also has access, without a logsPermissions edit or redeploy.
|
|
91
|
-
Anyone currently authorized can read all retained history under that scene key.
|
|
92
|
-
Access changes are not immediate: defaults are 60-second permission caches and 5-minute
|
|
93
|
-
tail rechecks (roughly 6 minutes to observe revocation on an open tail). Configuration and
|
|
94
|
-
bounded capacity-failure grace periods can extend this; it is not a strict deadline.
|
|
95
|
-
|
|
96
|
-
Sign in once with "login": it opens the browser for your wallet to sign, and the session is
|
|
97
|
-
saved for up to 12 hours (bounded by the parent session) at:
|
|
98
|
-
${(0, session_store_1.getSessionFilePath)()}
|
|
99
|
-
Override the parent directory with ${session_store_1.SESSION_DIR_ENV} (uses its .dcl folder).
|
|
100
|
-
It grants read-only Insights access to logs, metrics and executions. Never share, commit
|
|
101
|
-
or deploy the session file: it contains a temporary private signing key and delegation.
|
|
102
|
-
"logout" deletes the local copy; leaked copies can remain usable until expiry.
|
|
103
|
-
The SDK excludes .dcl from deployment, adds a .gitignore in the session folder, and refuses
|
|
104
|
-
tracked session files. Custom upload/archive scripts must exclude credentials too.
|
|
105
|
-
With DCL_PRIVATE_KEY set, requests are signed with that key and nothing is saved.
|
|
106
|
-
Contract wallets use Ethereum RPC: Mainnet for .org, Sepolia for .zone. Use the same --target
|
|
107
|
-
for login, session and reads. Set DCL_SCENE_INSIGHTS_RPC_URL for a custom target's network.
|
|
108
|
-
Without a terminal (scripts, AI agents) a missing session is an error, never a browser prompt.
|
|
109
|
-
|
|
110
|
-
Runs from any directory with --world and/or --position; otherwise reads scene.json
|
|
111
|
-
(worldConfiguration.name and scene.base).
|
|
112
|
-
|
|
113
|
-
Subcommands:
|
|
114
|
-
login Sign in (always asks for a new signature)
|
|
115
|
-
session Show the signed-in address and when the session expires
|
|
116
|
-
logout Remove the saved session
|
|
117
|
-
logs Search the logs; prints the newest --limit lines, oldest first
|
|
118
|
-
tail Follow new log lines live (reconnects and resumes on its own)
|
|
119
|
-
metrics [name] List the metrics with data, or chart one (cpu.run_ms is short
|
|
120
|
-
for dcl.scene.cpu.run_ms)
|
|
121
|
-
executions List the scene's executions (deployments and restarts)
|
|
122
|
-
|
|
123
|
-
Scene:
|
|
124
|
-
-w, --world [name] World name (myworld, myworld.dcl.eth or any ENS name)
|
|
125
|
-
--position [x,y] A parcel of the scene: Genesis City, or one scene of a multi-scene
|
|
126
|
-
World (use the =value form for negative coordinates)
|
|
127
|
-
--dir [path] Project directory for the scene.json fallback
|
|
128
|
-
|
|
129
|
-
Time range (logs, metrics, executions):
|
|
130
|
-
--from [time] Start: a duration back from now (15m, 2h, 7d), epoch ms, or
|
|
131
|
-
ISO-8601 with an offset. Default: 1 hour ago (24 hours for
|
|
132
|
-
metric names and executions)
|
|
133
|
-
--to [time] End, same formats. Default: now
|
|
134
|
-
|
|
135
|
-
logs:
|
|
136
|
-
-l, --level [level] Minimum level: debug, info, warn or error
|
|
137
|
-
-q, --query [text] Literal text to match (case-insensitive)
|
|
138
|
-
--source [list] Comma-separated sources: scene, engine, stderr
|
|
139
|
-
--execution [id] Only this execution (see "executions")
|
|
140
|
-
-n, --limit [n] Lines to print, 1-10000 (default 100)
|
|
141
|
-
--order [order] desc (default) prints the newest lines, asc the oldest
|
|
142
|
-
|
|
143
|
-
tail:
|
|
144
|
-
--for [time] Stop after this long (30s, 5m, at most 24d); default: until CTRL+C
|
|
145
|
-
--lines [n] Replay the newest n lines first, 0-1000 (default 0)
|
|
146
|
-
-l, --level, -q, --query Filter the followed lines
|
|
147
|
-
|
|
148
|
-
metrics:
|
|
149
|
-
--step [s] Bucket width in seconds, 10-86400 (default: ~300 buckets)
|
|
150
|
-
--execution [id] Only this execution
|
|
151
|
-
|
|
152
|
-
Other options:
|
|
153
|
-
--json Print JSON to stdout (one object per log line), and errors as
|
|
154
|
-
{"error":{"code","message","exitCode"}} on stderr
|
|
155
|
-
-t, --target [URL] Insights service URL (default: ${DEFAULT_SERVER}); only
|
|
156
|
-
https hosts under decentraland.org or decentraland.zone
|
|
157
|
-
--trust-target Allow any --target. It receives signed requests it could replay
|
|
158
|
-
-p, --port [port] Select a custom port for the linker dApp
|
|
159
|
-
-b, --no-browser Do not open a new browser window
|
|
160
|
-
--https Use HTTPS for the linker dApp
|
|
161
|
-
-h, --help Displays complete help
|
|
162
|
-
|
|
163
|
-
Exit codes:
|
|
164
|
-
0 success, 1 other failure, 2 invalid arguments, 3 sign-in needed (run login),
|
|
165
|
-
4 the address has no access to the scene, 5 scene not found, 6 service unavailable
|
|
166
|
-
|
|
167
|
-
Examples:
|
|
168
|
-
- Sign in, then read the errors of the last 6 hours of the World in scene.json:
|
|
169
|
-
$ sdk-commands scene-insights login
|
|
170
|
-
$ sdk-commands scene-insights logs --from 6h --level error
|
|
171
|
-
|
|
172
|
-
- Search a World from any directory:
|
|
173
|
-
$ sdk-commands scene-insights logs --world myworld --query "player joined" --limit 500
|
|
174
|
-
|
|
175
|
-
- Follow a Genesis City scene for 2 minutes, replaying the last 50 lines:
|
|
176
|
-
$ sdk-commands scene-insights tail --position=-125,-96 --lines 50 --for 2m
|
|
177
|
-
|
|
178
|
-
- Chart heap usage over the last day, one point per 10 minutes:
|
|
179
|
-
$ sdk-commands scene-insights metrics mem.heap_used --from 1d --step 600
|
|
180
|
-
|
|
181
|
-
- Use the development (.zone) service, signing with a private key:
|
|
182
|
-
$ DCL_PRIVATE_KEY=0x... sdk-commands scene-insights executions --world myworld \\
|
|
183
|
-
--target https://multiplayer-scenes-insights-service.decentraland.zone
|
|
184
|
-
`);
|
|
185
|
-
}
|
|
186
|
-
/** Resolves the scene from --world/--position, falling back to scene.json. */
|
|
187
|
-
async function resolveTarget(options) {
|
|
188
|
-
const worldArg = options.args['--world'];
|
|
189
|
-
const positionArg = options.args['--position'];
|
|
190
|
-
if (worldArg || positionArg) {
|
|
191
|
-
return (0, inputs_1.buildSceneTarget)(worldArg ? (0, inputs_1.normalizeWorldName)(worldArg) : undefined, positionArg ? (0, inputs_1.normalizeParcel)(positionArg) : undefined);
|
|
192
|
-
}
|
|
193
|
-
const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
|
|
194
|
-
await (0, workspace_validations_1.getValidWorkspace)(options.components, projectRoot);
|
|
195
|
-
const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
|
|
196
|
-
const world = sceneJson.worldConfiguration?.name;
|
|
197
|
-
const base = sceneJson.scene?.base;
|
|
198
|
-
return (0, inputs_1.buildSceneTarget)(world ? (0, inputs_1.normalizeWorldName)(world) : undefined, base ? (0, inputs_1.normalizeParcel)(base) : undefined);
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Runs a subcommand. With --json it returns the result for the CLI to print as JSON (the tail
|
|
202
|
-
* streams its own JSON lines and returns nothing), and an error is written as JSON on stderr.
|
|
203
|
-
*/
|
|
204
|
-
async function main(options) {
|
|
205
|
-
const json = !!options.args['--json'];
|
|
206
|
-
try {
|
|
207
|
-
return await run(options);
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
if (!(error instanceof error_1.CliError))
|
|
211
|
-
throw error;
|
|
212
|
-
process.exitCode = exports.EXIT_CODES[error.name] ?? 1;
|
|
213
|
-
if (!json)
|
|
214
|
-
throw error;
|
|
215
|
-
process.stderr.write(JSON.stringify({ error: { code: error.name, message: error.message, exitCode: process.exitCode } }) + '\n');
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
async function run(options) {
|
|
219
|
-
const { components } = options;
|
|
220
|
-
const a = options.args;
|
|
221
|
-
const [subcommand, ...positionals] = a._.filter((arg) => !arg.startsWith('-'));
|
|
222
|
-
if (!subcommand || ![...QUERY_SUBCOMMANDS, ...SESSION_SUBCOMMANDS].includes(subcommand)) {
|
|
223
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `${subcommand ? `Unknown subcommand "${subcommand}"` : 'Missing subcommand'}. Use: ` +
|
|
224
|
-
`${[...SESSION_SUBCOMMANDS, ...QUERY_SUBCOMMANDS].join(', ')}\n` +
|
|
225
|
-
'Run "sdk-commands scene-insights --help" for more information.');
|
|
226
|
-
}
|
|
227
|
-
const maxPositionals = subcommand === 'metrics' ? 1 : 0;
|
|
228
|
-
if (positionals.length > maxPositionals) {
|
|
229
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Unexpected argument "${positionals[maxPositionals]}" for ${subcommand}`);
|
|
230
|
-
}
|
|
231
|
-
const allowed = new Set(['--help', '--json', ...FLAGS_BY_SUBCOMMAND[subcommand]]);
|
|
232
|
-
const unused = Object.keys(a).filter((flag) => flag !== '_' && !allowed.has(flag));
|
|
233
|
-
if (unused.length > 0) {
|
|
234
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `${unused.join(', ')} ${unused.length === 1 ? 'does' : 'do'} not apply to ${subcommand}`);
|
|
235
|
-
}
|
|
236
|
-
const [positional] = positionals;
|
|
237
|
-
const baseUrl = a['--target'] ? (0, inputs_1.parseTarget)(a['--target'], !!a['--trust-target']) : DEFAULT_SERVER;
|
|
238
|
-
const file = (0, session_store_1.getSessionFilePath)();
|
|
239
|
-
const write = (line) => process.stdout.write(line + '\n');
|
|
240
|
-
const sessionOptions = {
|
|
241
|
-
file,
|
|
242
|
-
targetUrl: baseUrl,
|
|
243
|
-
linkOptions: { linkerPort: a['--port'], openBrowser: !a['--no-browser'], isHttps: !!a['--https'] },
|
|
244
|
-
interactive: !!process.stdin.isTTY
|
|
245
|
-
};
|
|
246
|
-
if (subcommand === 'logout') {
|
|
247
|
-
const removed = await (0, session_store_1.deleteSession)(components, file);
|
|
248
|
-
components.logger.info(removed ? `Signed out; removed ${file}` : 'There was no saved session');
|
|
249
|
-
return { removed, file };
|
|
250
|
-
}
|
|
251
|
-
if (subcommand === 'session') {
|
|
252
|
-
if (process.env.DCL_PRIVATE_KEY) {
|
|
253
|
-
const { address } = (0, account_1.createWallet)(process.env.DCL_PRIVATE_KEY);
|
|
254
|
-
if (!a['--json'])
|
|
255
|
-
write(`Signing as ${address} with DCL_PRIVATE_KEY`);
|
|
256
|
-
return { address, expiration: null, source: 'DCL_PRIVATE_KEY' };
|
|
257
|
-
}
|
|
258
|
-
const saved = await (0, session_store_1.loadSession)(components, file, Date.now(), (0, signature_validation_1.createInsightsProvider)(baseUrl));
|
|
259
|
-
if (!saved) {
|
|
260
|
-
throw new error_1.CliError('SCENE_INSIGHTS_SESSION_REQUIRED', 'Not signed in; run "sdk-commands scene-insights login"');
|
|
261
|
-
}
|
|
262
|
-
const { address, expiration } = saved.session;
|
|
263
|
-
if (!a['--json'])
|
|
264
|
-
write(`Signed in as ${address} until ${expiration.toISOString()} (${file})`);
|
|
265
|
-
return { address, expiration: expiration.toISOString(), source: file };
|
|
266
|
-
}
|
|
267
|
-
if (subcommand === 'login') {
|
|
268
|
-
const { session, source } = await (0, sign_in_1.getSession)(components, { label: 'scene insights' }, { ...sessionOptions, interactive: true, forceNew: true });
|
|
269
|
-
if (source === 'private-key') {
|
|
270
|
-
components.logger.info(`DCL_PRIVATE_KEY is set: requests are signed as ${session.address}, nothing to save`);
|
|
271
|
-
return { address: session.address, expiration: null, source: 'DCL_PRIVATE_KEY' };
|
|
272
|
-
}
|
|
273
|
-
components.logger.info(`Signed in as ${session.address} until ${session.expiration.toISOString()}; saved to ${file}`);
|
|
274
|
-
return { address: session.address, expiration: session.expiration.toISOString(), source: file };
|
|
275
|
-
}
|
|
276
|
-
// validate every flag before resolving the scene or signing
|
|
277
|
-
const from = a['--from'] ? (0, inputs_1.parseTime)(a['--from'], '--from') : undefined;
|
|
278
|
-
const to = a['--to'] ? (0, inputs_1.parseTime)(a['--to'], '--to') : undefined;
|
|
279
|
-
const level = a['--level'] ? (0, inputs_1.parseLevel)(a['--level']) : undefined;
|
|
280
|
-
const order = a['--order'] ?? 'desc';
|
|
281
|
-
if (order !== 'asc' && order !== 'desc') {
|
|
282
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', '--order must be asc or desc');
|
|
283
|
-
}
|
|
284
|
-
const limit = (0, inputs_1.parseInteger)(a['--limit'] ?? 100, '--limit', 1, 10000);
|
|
285
|
-
const lines = a['--lines'] !== undefined ? (0, inputs_1.parseInteger)(a['--lines'], '--lines', 0, 1000) : undefined;
|
|
286
|
-
const followFor = a['--for'] !== undefined ? (0, inputs_1.parseDuration)(a['--for'], '--for') : undefined;
|
|
287
|
-
const step = a['--step'] !== undefined ? (0, inputs_1.parseInteger)(a['--step'], '--step', 10, 86400) : undefined;
|
|
288
|
-
const query = a['--query'];
|
|
289
|
-
if (query !== undefined && (query.length < 1 || query.length > 256)) {
|
|
290
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', '--query must be 1 to 256 characters');
|
|
291
|
-
}
|
|
292
|
-
const metric = positional ? (0, inputs_1.normalizeMetricName)(positional) : undefined;
|
|
293
|
-
const target = await resolveTarget(options);
|
|
294
|
-
components.logger.info(`Scene insights for ${target.label} (${baseUrl})`);
|
|
295
|
-
const { session } = await (0, sign_in_1.getSession)(components, target, sessionOptions);
|
|
296
|
-
components.logger.info(`Signed in as ${session.address}`);
|
|
297
|
-
const client = (0, client_1.createInsightsClient)(components, baseUrl, session, target.metadata);
|
|
298
|
-
const output = {
|
|
299
|
-
write,
|
|
300
|
-
note: (message) => components.logger.info(message),
|
|
301
|
-
json: !!a['--json'],
|
|
302
|
-
color: !!process.stdout.isTTY && !process.env.NO_COLOR && process.env.FORCE_COLOR !== '0'
|
|
303
|
-
};
|
|
304
|
-
const common = { from, to };
|
|
305
|
-
switch (subcommand) {
|
|
306
|
-
case 'logs':
|
|
307
|
-
return (0, actions_1.runLogs)(client, { ...common, level, source: a['--source'], query, execution: a['--execution'], limit, order }, output);
|
|
308
|
-
case 'tail': {
|
|
309
|
-
const controller = new AbortController();
|
|
310
|
-
const stop = () => controller.abort();
|
|
311
|
-
process.on('SIGINT', stop);
|
|
312
|
-
const timer = followFor !== undefined ? setTimeout(stop, followFor) : undefined;
|
|
313
|
-
try {
|
|
314
|
-
return await (0, actions_1.runTail)(client, { lines, level, query, signal: controller.signal }, output);
|
|
315
|
-
}
|
|
316
|
-
finally {
|
|
317
|
-
clearTimeout(timer);
|
|
318
|
-
process.off('SIGINT', stop);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
case 'metrics':
|
|
322
|
-
return (0, actions_1.runMetrics)(client, { ...common, metric, step, execution: a['--execution'] }, output);
|
|
323
|
-
case 'executions':
|
|
324
|
-
return (0, actions_1.runExecutions)(client, common, output);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/scene-insights/index.ts"],"names":[],"mappings":";;;AAoGA,oBAuGC;AAyBD,oBAYC;AAhPD,+BAA8B;AAG9B,2CAA8C;AAE9C,6CAA0D;AAC1D,iDAAkD;AAClD,6EAAqE;AACrE,qEAAiE;AACjE,uCAA+E;AAC/E,qCAA+C;AAC/C,qCAWiB;AACjB,mDAAiG;AACjG,uCAAsD;AACtD,iEAA+D;AAOlD,QAAA,IAAI,GAAG,IAAA,kBAAW,EAAC;IAC9B,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,MAAM;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,SAAS;IACf,YAAY,EAAE,MAAM;IACpB,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,UAAU;IAChB,gBAAgB,EAAE,OAAO;IACzB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,OAAO;IAClB,cAAc,EAAE,OAAO;IACvB,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,SAAS;IACf,aAAa,EAAE,M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CAAA;YAC1B,MAAM,KAAK,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YAC/E,IAAI,CAAC;gBACH,OAAO,MAAM,IAAA,iBAAO,EAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAA;YAC1F,CAAC;oBAAS,CAAC;gBACT,YAAY,CAAC,KAAK,CAAC,CAAA;gBACnB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC;QACD,KAAK,SAAS;YACZ,OAAO,IAAA,oBAAU,EAAC,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QAC7F,KAAK,YAAY;YACf,OAAO,IAAA,uBAAa,EAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/** The scene a request targets, as the insights service reads it from the signed metadata. */
|
|
2
|
-
export interface SceneTarget {
|
|
3
|
-
/** Human-readable description, for the terminal and the linker dApp */
|
|
4
|
-
label: string;
|
|
5
|
-
/** Signed `x-identity-metadata` JSON */
|
|
6
|
-
metadata: string;
|
|
7
|
-
/** World name sent as `sceneId`, when the scene is in a World */
|
|
8
|
-
world?: string;
|
|
9
|
-
/** Parcel sent as `parcel`, when one was given or read from scene.json */
|
|
10
|
-
parcel?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
13
|
-
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
14
|
-
/**
|
|
15
|
-
* Normalizes a World name the way creators type it: `foo`, `foo.dcl.eth` or any other ENS name
|
|
16
|
-
* (`foo.eth`). Names without an `.eth` suffix are DCL names.
|
|
17
|
-
*/
|
|
18
|
-
export declare function normalizeWorldName(raw: string): string;
|
|
19
|
-
/** Normalizes `x,y` parcel coordinates (spaces and leading zeros removed). */
|
|
20
|
-
export declare function normalizeParcel(raw: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Builds the scene target. A World is addressed by name (`sceneId`), plus the parcel of one of its
|
|
23
|
-
* scenes when it has several; a Genesis City scene by any of its parcels.
|
|
24
|
-
*/
|
|
25
|
-
export declare function buildSceneTarget(world: string | undefined, parcel: string | undefined): SceneTarget;
|
|
26
|
-
/**
|
|
27
|
-
* Parses a `--from`/`--to` value into the ISO-8601 form the service expects. Accepts `now`, a
|
|
28
|
-
* duration back from now (`30s`, `15m`, `2h`, `7d`), epoch milliseconds (13 digits) or ISO-8601
|
|
29
|
-
* with an explicit offset (`2026-10-01T12:00:00Z`, `2026-10-01T09:00:00-03:00`). A duration of 7
|
|
30
|
-
* days or more means the whole retention window, ending a minute short of it.
|
|
31
|
-
*/
|
|
32
|
-
export declare function parseTime(raw: string, flag: string, now?: number): string;
|
|
33
|
-
/** Parses a duration (`30s`, `5m`, `2h`, `1d`, up to 24 days) into milliseconds. */
|
|
34
|
-
export declare function parseDuration(raw: string, flag: string): number;
|
|
35
|
-
/**
|
|
36
|
-
* Validates a `--target` URL. Without `trustAny`, only https Decentraland hosts are accepted: the
|
|
37
|
-
* signed headers don't name the host, so another server receiving them could replay them.
|
|
38
|
-
*/
|
|
39
|
-
export declare function parseTarget(raw: string, trustAny: boolean): string;
|
|
40
|
-
/** Validates a `--level` value. */
|
|
41
|
-
export declare function parseLevel(raw: string): LogLevel;
|
|
42
|
-
/** Validates an integer flag inside [min, max]. */
|
|
43
|
-
export declare function parseInteger(value: number, flag: string, min: number, max: number): number;
|
|
44
|
-
/**
|
|
45
|
-
* Expands a metric name, so `cpu.run_ms` can be typed for `dcl.scene.cpu.run_ms`.
|
|
46
|
-
*
|
|
47
|
-
* @throws {CliError} SCENE_INSIGHTS_INVALID_ARGUMENT when the result is not `dcl.scene.<group>.<field>`
|
|
48
|
-
*/
|
|
49
|
-
export declare function normalizeMetricName(raw: string): string;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LOG_LEVELS = void 0;
|
|
4
|
-
exports.normalizeWorldName = normalizeWorldName;
|
|
5
|
-
exports.normalizeParcel = normalizeParcel;
|
|
6
|
-
exports.buildSceneTarget = buildSceneTarget;
|
|
7
|
-
exports.parseTime = parseTime;
|
|
8
|
-
exports.parseDuration = parseDuration;
|
|
9
|
-
exports.parseTarget = parseTarget;
|
|
10
|
-
exports.parseLevel = parseLevel;
|
|
11
|
-
exports.parseInteger = parseInteger;
|
|
12
|
-
exports.normalizeMetricName = normalizeMetricName;
|
|
13
|
-
const error_1 = require("../../logic/error");
|
|
14
|
-
exports.LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
15
|
-
/** The service refuses ranges longer than its 7-day retention. */
|
|
16
|
-
const MAX_RANGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
17
|
-
/**
|
|
18
|
-
* Room for the time between computing `from` here and the service resolving its own "now": a
|
|
19
|
-
* duration of exactly 7 days would otherwise always arrive a few milliseconds over the limit.
|
|
20
|
-
*/
|
|
21
|
-
const RANGE_SLACK_MS = 60 * 1000;
|
|
22
|
-
const DURATION_UNITS_MS = {
|
|
23
|
-
s: 1000,
|
|
24
|
-
m: 60 * 1000,
|
|
25
|
-
h: 60 * 60 * 1000,
|
|
26
|
-
d: 24 * 60 * 60 * 1000
|
|
27
|
-
};
|
|
28
|
-
/** setTimeout fires at once past 2^31-1 ms (about 24.8 days). */
|
|
29
|
-
const MAX_DURATION_DAYS = 24;
|
|
30
|
-
/** The hosts a session is meant for; the signature doesn't cover the host, so anywhere else could replay it. */
|
|
31
|
-
const TRUSTED_TARGET_DOMAINS = ['decentraland.org', 'decentraland.zone'];
|
|
32
|
-
/**
|
|
33
|
-
* Normalizes a World name the way creators type it: `foo`, `foo.dcl.eth` or any other ENS name
|
|
34
|
-
* (`foo.eth`). Names without an `.eth` suffix are DCL names.
|
|
35
|
-
*/
|
|
36
|
-
function normalizeWorldName(raw) {
|
|
37
|
-
const name = raw.trim().toLowerCase();
|
|
38
|
-
if (!/^[a-z0-9][a-z0-9.-]*$/.test(name)) {
|
|
39
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid --world "${raw}"`);
|
|
40
|
-
}
|
|
41
|
-
return name.endsWith('.eth') ? name : `${name}.dcl.eth`;
|
|
42
|
-
}
|
|
43
|
-
/** Normalizes `x,y` parcel coordinates (spaces and leading zeros removed). */
|
|
44
|
-
function normalizeParcel(raw) {
|
|
45
|
-
const match = raw.trim().match(/^(-?\d+)\s*,\s*(-?\d+)$/);
|
|
46
|
-
if (!match) {
|
|
47
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid --position "${raw}"; expected "x,y" with integer coordinates`);
|
|
48
|
-
}
|
|
49
|
-
return `${parseInt(match[1], 10)},${parseInt(match[2], 10)}`;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Builds the scene target. A World is addressed by name (`sceneId`), plus the parcel of one of its
|
|
53
|
-
* scenes when it has several; a Genesis City scene by any of its parcels.
|
|
54
|
-
*/
|
|
55
|
-
function buildSceneTarget(world, parcel) {
|
|
56
|
-
if (world) {
|
|
57
|
-
return {
|
|
58
|
-
label: parcel ? `${world} ${parcel}` : world,
|
|
59
|
-
metadata: JSON.stringify({ sceneId: world, realmName: world, ...(parcel && { parcel }) }),
|
|
60
|
-
world,
|
|
61
|
-
parcel
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (!parcel) {
|
|
65
|
-
throw new error_1.CliError('SCENE_INSIGHTS_MISSING_SCENE', 'Provide --world (with an optional --position) for a World, or --position for a Genesis City scene');
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
label: `Genesis City ${parcel}`,
|
|
69
|
-
metadata: JSON.stringify({ parcel, realmName: 'main' }),
|
|
70
|
-
parcel
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Parses a `--from`/`--to` value into the ISO-8601 form the service expects. Accepts `now`, a
|
|
75
|
-
* duration back from now (`30s`, `15m`, `2h`, `7d`), epoch milliseconds (13 digits) or ISO-8601
|
|
76
|
-
* with an explicit offset (`2026-10-01T12:00:00Z`, `2026-10-01T09:00:00-03:00`). A duration of 7
|
|
77
|
-
* days or more means the whole retention window, ending a minute short of it.
|
|
78
|
-
*/
|
|
79
|
-
function parseTime(raw, flag, now = Date.now()) {
|
|
80
|
-
const value = raw.trim();
|
|
81
|
-
if (value === 'now') {
|
|
82
|
-
return new Date(now).toISOString();
|
|
83
|
-
}
|
|
84
|
-
const duration = value.match(/^(\d+)([smhd])$/);
|
|
85
|
-
if (duration) {
|
|
86
|
-
const ms = parseInt(duration[1], 10) * DURATION_UNITS_MS[duration[2]];
|
|
87
|
-
return new Date(now - Math.min(ms, MAX_RANGE_MS - RANGE_SLACK_MS)).toISOString();
|
|
88
|
-
}
|
|
89
|
-
if (/^\d{13}$/.test(value)) {
|
|
90
|
-
return new Date(parseInt(value, 10)).toISOString();
|
|
91
|
-
}
|
|
92
|
-
const hasOffset = /(Z|[+-]\d{2}:?\d{2})$/i.test(value);
|
|
93
|
-
const parsed = Date.parse(value);
|
|
94
|
-
if (!hasOffset || Number.isNaN(parsed)) {
|
|
95
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid ${flag} "${raw}"; use a duration back from now (15m, 2h, 7d), epoch milliseconds or ISO-8601 with an offset (2026-10-01T12:00:00Z)`);
|
|
96
|
-
}
|
|
97
|
-
return new Date(parsed).toISOString();
|
|
98
|
-
}
|
|
99
|
-
/** Parses a duration (`30s`, `5m`, `2h`, `1d`, up to 24 days) into milliseconds. */
|
|
100
|
-
function parseDuration(raw, flag) {
|
|
101
|
-
const duration = raw.trim().match(/^(\d+)([smhd])$/);
|
|
102
|
-
const ms = duration ? parseInt(duration[1], 10) * DURATION_UNITS_MS[duration[2]] : 0;
|
|
103
|
-
if (!(ms > 0)) {
|
|
104
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid ${flag} "${raw}"; use a duration such as 30s, 5m or 2h`);
|
|
105
|
-
}
|
|
106
|
-
if (ms > MAX_DURATION_DAYS * DURATION_UNITS_MS.d) {
|
|
107
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `${flag} must be at most ${MAX_DURATION_DAYS}d`);
|
|
108
|
-
}
|
|
109
|
-
return ms;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Validates a `--target` URL. Without `trustAny`, only https Decentraland hosts are accepted: the
|
|
113
|
-
* signed headers don't name the host, so another server receiving them could replay them.
|
|
114
|
-
*/
|
|
115
|
-
function parseTarget(raw, trustAny) {
|
|
116
|
-
let url;
|
|
117
|
-
try {
|
|
118
|
-
url = new URL(raw);
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
url = undefined;
|
|
122
|
-
}
|
|
123
|
-
if (!url || !['http:', 'https:'].includes(url.protocol) || url.search || url.hash || url.username || url.password) {
|
|
124
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid --target "${raw}"; expected an http(s) URL`);
|
|
125
|
-
}
|
|
126
|
-
const hostname = url.hostname;
|
|
127
|
-
const trusted = url.protocol === 'https:' &&
|
|
128
|
-
TRUSTED_TARGET_DOMAINS.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
|
|
129
|
-
if (!trusted && !trustAny) {
|
|
130
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `--target "${raw}" is not an https host under ${TRUSTED_TARGET_DOMAINS.join(' or ')}. It would receive signed ` +
|
|
131
|
-
'headers it could replay against the real service; pass --trust-target to send them anyway');
|
|
132
|
-
}
|
|
133
|
-
return raw;
|
|
134
|
-
}
|
|
135
|
-
/** Validates a `--level` value. */
|
|
136
|
-
function parseLevel(raw) {
|
|
137
|
-
const level = raw.trim().toLowerCase();
|
|
138
|
-
if (!exports.LOG_LEVELS.includes(level)) {
|
|
139
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid --level "${raw}"; use ${exports.LOG_LEVELS.join(', ')}`);
|
|
140
|
-
}
|
|
141
|
-
return level;
|
|
142
|
-
}
|
|
143
|
-
/** Validates an integer flag inside [min, max]. */
|
|
144
|
-
function parseInteger(value, flag, min, max) {
|
|
145
|
-
if (!Number.isInteger(value) || value < min || value > max) {
|
|
146
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `${flag} must be an integer between ${min} and ${max}`);
|
|
147
|
-
}
|
|
148
|
-
return value;
|
|
149
|
-
}
|
|
150
|
-
/** The metric names the insights service serves: `dcl.scene.<group>.<field>`. */
|
|
151
|
-
const METRIC_NAME_PATTERN = /^dcl\.scene\.[a-z0-9_]+\.[a-z0-9_]+$/;
|
|
152
|
-
/**
|
|
153
|
-
* Expands a metric name, so `cpu.run_ms` can be typed for `dcl.scene.cpu.run_ms`.
|
|
154
|
-
*
|
|
155
|
-
* @throws {CliError} SCENE_INSIGHTS_INVALID_ARGUMENT when the result is not `dcl.scene.<group>.<field>`
|
|
156
|
-
*/
|
|
157
|
-
function normalizeMetricName(raw) {
|
|
158
|
-
const trimmed = raw.trim();
|
|
159
|
-
const name = trimmed.startsWith('dcl.scene.') ? trimmed : `dcl.scene.${trimmed}`;
|
|
160
|
-
// checked here because the name becomes a path segment: `..` or `/` would change the path
|
|
161
|
-
if (!METRIC_NAME_PATTERN.test(name)) {
|
|
162
|
-
throw new error_1.CliError('SCENE_INSIGHTS_INVALID_ARGUMENT', `Invalid metric "${raw}": expected <group>.<field> (lowercase letters, digits and _), e.g. cpu.run_ms`);
|
|
163
|
-
}
|
|
164
|
-
return name;
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=inputs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.js","sourceRoot":"","sources":["../../../src/commands/scene-insights/inputs.ts"],"names":[],"mappings":";;;AAyCA,gDAMC;AAGD,0CASC;AAMD,4CAoBC;AAQD,8BAyBC;AAGD,sCAaC;AAMD,kCAsBC;AAGD,gCAMC;AAGD,oCAKC;AAUD,kDAWC;AAxMD,6CAA4C;AAc/B,QAAA,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAA;AAGrE,kEAAkE;AAClE,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAC5C;;;GAGG;AACH,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAA;AAEhC,MAAM,iBAAiB,GAA2B;IAChD,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,EAAE,GAAG,IAAI;IACZ,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACjB,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;CACvB,CAAA;AACD,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAE5B,gHAAgH;AAChH,MAAM,sBAAsB,GAAG,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAA;AAExE;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACrC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,gBAAQ,CAAC,iCAAiC,EAAE,oBAAoB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,CAAC;AAED,iFAAiF;AACjF,MAAM,mBAAmB,GAAG,sCAAsC,CAAA;AAElE;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,GAAW;IAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,OAAO,EAAE,CAAA;IAChF,0FAA0F;IAC1F,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,gBAAQ,CAChB,iCAAiC,EACjC,mBAAmB,GAAG,gFAAgF,CACvG,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { AuthChainProvider } from '@dcl/crypto-middleware';
|
|
2
|
-
import { AuthChain, AuthIdentity } from '@dcl/crypto';
|
|
3
|
-
import { CliComponents } from '../../components';
|
|
4
|
-
import { InsightsSession } from './session';
|
|
5
|
-
/** Environment variable naming the folder whose .dcl/ holds the session, e.g. a sandbox an agent can read. */
|
|
6
|
-
export declare const SESSION_DIR_ENV = "DCL_SCENE_INSIGHTS_SESSION_DIR";
|
|
7
|
-
/**
|
|
8
|
-
* What is saved after a browser signature: the ephemeral key the wallet delegated to, and the
|
|
9
|
-
* delegation. Until it expires it signs requests as the wallet, so it is written readable only by
|
|
10
|
-
* the user and removed by `scene-insights logout`.
|
|
11
|
-
*/
|
|
12
|
-
export interface SavedSession {
|
|
13
|
-
version: 1;
|
|
14
|
-
address: string;
|
|
15
|
-
expiration: string;
|
|
16
|
-
ephemeralIdentity: AuthIdentity['ephemeralIdentity'];
|
|
17
|
-
authChain: AuthChain;
|
|
18
|
-
}
|
|
19
|
-
export declare function getSessionFilePath(base?: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Reads the saved session. Returns undefined when there is none, it is malformed, it expires within
|
|
22
|
-
* a minute, or its delegation does not verify (tampered, or not a delegation to its key).
|
|
23
|
-
*/
|
|
24
|
-
export declare function loadSession(components: Pick<CliComponents, 'fs'>, file: string, now?: number, provider?: AuthChainProvider): Promise<{
|
|
25
|
-
session: InsightsSession;
|
|
26
|
-
saved: SavedSession;
|
|
27
|
-
} | undefined>;
|
|
28
|
-
/**
|
|
29
|
-
* Refuses a session file git already tracks, e.g. a .dcl folder committed before it ignored
|
|
30
|
-
* itself: its .gitignore doesn't stop a tracked file being committed again.
|
|
31
|
-
*
|
|
32
|
-
* @throws CliError `SCENE_INSIGHTS_UNSAFE_SESSION_FILE` when git tracks it.
|
|
33
|
-
*/
|
|
34
|
-
export declare function assertSessionFileIsNotTracked(file: string): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Saves the session readable only by the user (0600, in a 0700 directory), replacing any other.
|
|
37
|
-
* Its folder's .gitignore ignores everything in it, so git never commits it.
|
|
38
|
-
*
|
|
39
|
-
* @throws CliError `SCENE_INSIGHTS_UNSAFE_SESSION_FILE` when git tracks the file.
|
|
40
|
-
*/
|
|
41
|
-
export declare function saveSession(components: Pick<CliComponents, 'fs'>, file: string, ephemeralIdentity: AuthIdentity['ephemeralIdentity'], expiration: Date, authChain: AuthChain): Promise<void>;
|
|
42
|
-
/** Removes the saved session. Returns whether there was one. */
|
|
43
|
-
export declare function deleteSession(components: Pick<CliComponents, 'fs'>, file: string): Promise<boolean>;
|