@dcl/sdk-commands 7.20.1 → 7.20.2-22102228700.commit-61000fc

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.
Files changed (55) hide show
  1. package/dist/commands/sdk-server-logs/index.d.ts +23 -0
  2. package/dist/commands/sdk-server-logs/index.js +271 -0
  3. package/dist/commands/sdk-server-logs/index.js.map +1 -0
  4. package/dist/commands/start/hammurabi-server.d.ts +19 -0
  5. package/dist/commands/start/hammurabi-server.js +78 -0
  6. package/dist/commands/start/hammurabi-server.js.map +1 -0
  7. package/dist/commands/start/index.d.ts +1 -0
  8. package/dist/commands/start/index.js +23 -4
  9. package/dist/commands/start/index.js.map +1 -1
  10. package/dist/commands/start/server/routes.js +2 -0
  11. package/dist/commands/start/server/routes.js.map +1 -1
  12. package/dist/commands/start/server/runtime-env.d.ts +71 -0
  13. package/dist/commands/start/server/runtime-env.js +226 -0
  14. package/dist/commands/start/server/runtime-env.js.map +1 -0
  15. package/dist/commands/start/server/storage-service.d.ts +8 -0
  16. package/dist/commands/start/server/storage-service.js +156 -0
  17. package/dist/commands/start/server/storage-service.js.map +1 -0
  18. package/dist/commands/start/types.d.ts +3 -0
  19. package/dist/commands/start/utils.d.ts +34 -0
  20. package/dist/commands/start/utils.js +104 -0
  21. package/dist/commands/start/utils.js.map +1 -1
  22. package/dist/commands/storage/env.d.ts +5 -0
  23. package/dist/commands/storage/env.js +86 -0
  24. package/dist/commands/storage/env.js.map +1 -0
  25. package/dist/commands/storage/index.d.ts +26 -0
  26. package/dist/commands/storage/index.js +130 -0
  27. package/dist/commands/storage/index.js.map +1 -0
  28. package/dist/commands/storage/player.d.ts +5 -0
  29. package/dist/commands/storage/player.js +143 -0
  30. package/dist/commands/storage/player.js.map +1 -0
  31. package/dist/commands/storage/scene.d.ts +5 -0
  32. package/dist/commands/storage/scene.js +105 -0
  33. package/dist/commands/storage/scene.js.map +1 -0
  34. package/dist/commands/storage/shared.d.ts +62 -0
  35. package/dist/commands/storage/shared.js +249 -0
  36. package/dist/commands/storage/shared.js.map +1 -0
  37. package/dist/commands/storage/types.d.ts +56 -0
  38. package/dist/commands/storage/types.js +23 -0
  39. package/dist/commands/storage/types.js.map +1 -0
  40. package/dist/components/analytics.d.ts +66 -0
  41. package/dist/components/analytics.js.map +1 -1
  42. package/dist/logic/auth-chain-headers.d.ts +11 -0
  43. package/dist/logic/auth-chain-headers.js +25 -0
  44. package/dist/logic/auth-chain-headers.js.map +1 -0
  45. package/dist/logic/bundle.js +16 -0
  46. package/dist/logic/bundle.js.map +1 -1
  47. package/dist/logic/error.d.ts +1 -1
  48. package/dist/logic/error.js.map +1 -1
  49. package/dist/logic/exec.d.ts +1 -0
  50. package/dist/logic/exec.js +2 -2
  51. package/dist/logic/exec.js.map +1 -1
  52. package/dist/logic/lang.js +1 -1
  53. package/dist/logic/scene-validations.d.ts +9 -1
  54. package/dist/logic/scene-validations.js.map +1 -1
  55. package/package.json +3 -3
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleEnv = void 0;
4
+ const path_1 = require("path");
5
+ const error_1 = require("../../logic/error");
6
+ const beautiful_logs_1 = require("../../logic/beautiful-logs");
7
+ const shared_1 = require("./shared");
8
+ /**
9
+ * Handles environment variable operations in the server-side storage service (set, delete, clear)
10
+ */
11
+ const handleEnv = async (action, key, options) => {
12
+ const { logger, analytics } = options.components;
13
+ const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
14
+ // Common setup: validate action, workspace, and world
15
+ const { baseURL, worldName, baseParcel, parcels } = await (0, shared_1.setupStorageCommand)(options.components, projectRoot, action, options.args['--target'], ['set', 'delete', 'clear']);
16
+ // Linker dApp options
17
+ const linkOptions = (0, shared_1.getLinkerDappOptions)(options.args);
18
+ // Handle actions
19
+ if (action === 'set') {
20
+ // SET operation
21
+ if (!key) {
22
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage env set KEY --value VALUE');
23
+ }
24
+ const value = options.args['--value'];
25
+ if (value === undefined) {
26
+ throw new error_1.CliError('STORAGE_MISSING_VALUE', 'Missing --value option. Usage: storage env set KEY --value VALUE');
27
+ }
28
+ logger.info(`Setting environment variable '${key}' to ${baseURL}`);
29
+ const url = `${baseURL}/env/${encodeURIComponent(key)}`;
30
+ const info = (0, shared_1.createStorageInfo)('env', 'set', url, worldName, baseParcel, parcels, key, value);
31
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'PUT', url, { value });
32
+ if (result.success) {
33
+ analytics.track('Storage Env Set Success', { key });
34
+ (0, beautiful_logs_1.printSuccess)(logger, `Environment variable '${key}' set successfully!`, '');
35
+ }
36
+ else {
37
+ analytics.track('Storage Env Set Failure', { key });
38
+ (0, beautiful_logs_1.printError)(logger, `Failed to set environment variable '${key}':`, new Error(result.error || 'Unknown error'));
39
+ }
40
+ }
41
+ else if (action === 'delete') {
42
+ // DELETE operation
43
+ if (!key) {
44
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage env delete KEY');
45
+ }
46
+ logger.info(`Deleting environment variable '${key}' from ${baseURL}`);
47
+ const url = `${baseURL}/env/${encodeURIComponent(key)}`;
48
+ const info = (0, shared_1.createStorageInfo)('env', 'delete', url, worldName, baseParcel, parcels, key);
49
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url);
50
+ if (result.success) {
51
+ analytics.track('Storage Env Delete Success', { key });
52
+ (0, beautiful_logs_1.printSuccess)(logger, `Environment variable '${key}' deleted successfully!`, '');
53
+ }
54
+ else {
55
+ analytics.track('Storage Env Delete Failure', { key });
56
+ (0, beautiful_logs_1.printError)(logger, `Failed to delete environment variable '${key}':`, new Error(result.error || 'Unknown error'));
57
+ }
58
+ }
59
+ else if (action === 'clear') {
60
+ // CLEAR operation
61
+ const hasConfirm = options.args['--confirm'];
62
+ if (!hasConfirm) {
63
+ const confirmed = await (0, shared_1.confirmAction)('Are you sure you want to delete ALL environment variables? This cannot be undone.');
64
+ if (!confirmed) {
65
+ logger.info('Operation cancelled.');
66
+ return;
67
+ }
68
+ }
69
+ logger.info(`Clearing all environment variables from ${baseURL}`);
70
+ const url = `${baseURL}/env`;
71
+ const info = (0, shared_1.createStorageInfo)('env', 'clear', url, worldName, baseParcel, parcels);
72
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url, undefined, {
73
+ 'X-Confirm-Delete-All': 'true'
74
+ });
75
+ if (result.success) {
76
+ analytics.track('Storage Env Clear Success', {});
77
+ (0, beautiful_logs_1.printSuccess)(logger, 'All environment variables cleared successfully!', '');
78
+ }
79
+ else {
80
+ analytics.track('Storage Env Clear Failure', {});
81
+ (0, beautiful_logs_1.printError)(logger, 'Failed to clear environment variables:', new Error(result.error || 'Unknown error'));
82
+ }
83
+ }
84
+ };
85
+ exports.handleEnv = handleEnv;
86
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/commands/storage/env.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAE9B,6CAA4C;AAC5C,+DAAqE;AACrE,qCAMiB;AAEjB;;GAEG;AACI,MAAM,SAAS,GAAG,KAAK,EAAE,MAAc,EAAE,GAAuB,EAAE,OAAgB,EAAiB,EAAE;IAC1G,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAA;IAChD,MAAM,WAAW,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAA;IAExE,sDAAsD;IACtD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,4BAAmB,EAC3E,OAAO,CAAC,UAAU,EAClB,WAAW,EACX,MA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AAC;AACH,CAAC,CAAA;AA7FY,QAAA,SAAS,aA6FrB"}
@@ -0,0 +1,26 @@
1
+ import { Result } from 'arg';
2
+ import { CliComponents } from '../../components';
3
+ export interface Options {
4
+ args: Result<typeof args>;
5
+ components: CliComponents;
6
+ }
7
+ export declare const args: {
8
+ '--help': BooleanConstructor;
9
+ '-h': string;
10
+ '--dir': StringConstructor;
11
+ '--target': StringConstructor;
12
+ '-t': string;
13
+ '--port': NumberConstructor;
14
+ '-p': string;
15
+ '--https': BooleanConstructor;
16
+ '--no-browser': BooleanConstructor;
17
+ '-b': string;
18
+ '--value': StringConstructor;
19
+ '-v': string;
20
+ '--address': StringConstructor;
21
+ '-a': string;
22
+ '--confirm': BooleanConstructor;
23
+ '-c': string;
24
+ };
25
+ export declare function help(options: Options): void;
26
+ export declare function main(options: Options): Promise<void>;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.args = void 0;
4
+ exports.help = help;
5
+ exports.main = main;
6
+ const args_1 = require("../../logic/args");
7
+ const error_1 = require("../../logic/error");
8
+ const env_1 = require("./env");
9
+ const scene_1 = require("./scene");
10
+ const player_1 = require("./player");
11
+ exports.args = (0, args_1.declareArgs)({
12
+ '--help': Boolean,
13
+ '-h': '--help',
14
+ '--dir': String,
15
+ '--target': String,
16
+ '-t': '--target',
17
+ '--port': Number,
18
+ '-p': '--port',
19
+ '--https': Boolean,
20
+ '--no-browser': Boolean,
21
+ '-b': '--no-browser',
22
+ '--value': String,
23
+ '-v': '--value',
24
+ '--address': String,
25
+ '-a': '--address',
26
+ '--confirm': Boolean,
27
+ '-c': '--confirm'
28
+ });
29
+ const STORAGE_SERVER_ORG = 'https://storage.decentraland.org';
30
+ function help(options) {
31
+ options.components.logger.log(`
32
+ Usage: 'sdk-commands storage [subcommand] [action] [KEY] [options]'
33
+ Manages server-side storage including environment variables, scene storage, and player storage.
34
+ This data is stored in Decentraland's remote storage service, not in the local filesystem.
35
+ Requires a scene.json with worldConfiguration.name in the project directory.
36
+
37
+ Subcommands:
38
+ env Manage environment variables
39
+ scene Manage scene storage
40
+ player Manage player storage
41
+
42
+ Options:
43
+ -h, --help Displays complete help
44
+ -v, --value [value] The value to set for a storage key
45
+ -a, --address [addr] Player address (for player storage operations)
46
+ -c, --confirm Skip confirmation prompts for destructive operations
47
+ -t, --target [URL] Target storage server URL (default: ${STORAGE_SERVER_ORG})
48
+ --dir [path] Path to the project directory
49
+ -p, --port [port] Select a custom port for the linker dApp
50
+ -b, --no-browser Do not open a new browser window
51
+ --https Use HTTPS for the linker dApp
52
+
53
+ Target options:
54
+ - https://storage.decentraland.org (production - default)
55
+ - https://storage.decentraland.zone (staging)
56
+ - http://localhost:<port> (local development)
57
+
58
+ Environment Variables (storage env):
59
+ storage env set KEY --value VALUE Set an environment variable
60
+ storage env delete KEY Delete an environment variable
61
+ storage env clear --confirm Delete all environment variables
62
+
63
+ Scene Storage (storage scene):
64
+ storage scene set KEY --value VALUE Set a scene storage value
65
+ storage scene get KEY Get a scene storage value
66
+ storage scene delete KEY Delete a scene storage value
67
+ storage scene clear --confirm Delete all scene storage data
68
+
69
+ Player Storage (storage player):
70
+ storage player set KEY --value VALUE --address 0xABCD Set a player storage value
71
+ storage player get KEY --address 0xABCD Get a player storage value
72
+ storage player delete KEY --address 0xABCD Delete a player storage value
73
+ storage player clear --address 0xABCD --confirm Delete all data for a player
74
+ storage player clear --confirm Delete all player data (all players)
75
+
76
+ Examples:
77
+ - Set an environment variable:
78
+ $ sdk-commands storage env set API_KEY --value "my-secret-key"
79
+
80
+ - Get a scene storage value:
81
+ $ sdk-commands storage scene get high_score
82
+
83
+ - Set player storage:
84
+ $ sdk-commands storage player set level --value 10 --address 0x1234...
85
+
86
+ - Clear all environment variables with confirmation:
87
+ $ sdk-commands storage env clear --confirm
88
+
89
+ - Deploy to staging:
90
+ $ sdk-commands storage env set MY_KEY --value my_value --target https://storage.decentraland.zone
91
+
92
+ - Deploy to local development server:
93
+ $ sdk-commands storage scene set test_key --value test_value --target http://localhost:8000
94
+ `);
95
+ }
96
+ async function main(options) {
97
+ // Parse positional arguments: storage [subcommand] [action] [KEY?]
98
+ const positionalArgs = options.args._.filter((arg) => !arg.startsWith('-'));
99
+ if (positionalArgs.length === 0) {
100
+ throw new error_1.CliError('STORAGE_MISSING_SUBCOMMAND', 'Missing subcommand. Usage: storage [env|scene|player] [action] [KEY] [options]\nRun "sdk-commands storage --help" for more information.');
101
+ }
102
+ const [subcommand, action, key] = positionalArgs;
103
+ // Validate subcommand
104
+ if (!['env', 'scene', 'player'].includes(subcommand)) {
105
+ throw new error_1.CliError('STORAGE_INVALID_SUBCOMMAND', `Invalid subcommand '${subcommand}'. Use: env, scene, or player\nRun "sdk-commands storage --help" for more information.`);
106
+ }
107
+ // Validate action is provided
108
+ if (!action) {
109
+ throw new error_1.CliError('STORAGE_MISSING_ACTION', `Missing action for '${subcommand}'. Run "sdk-commands storage --help" for more information.`);
110
+ }
111
+ // Route to appropriate handler
112
+ try {
113
+ if (subcommand === 'env') {
114
+ await (0, env_1.handleEnv)(action, key, options);
115
+ }
116
+ else if (subcommand === 'scene') {
117
+ await (0, scene_1.handleScene)(action, key, options);
118
+ }
119
+ else if (subcommand === 'player') {
120
+ await (0, player_1.handlePlayer)(action, key, options);
121
+ }
122
+ }
123
+ catch (error) {
124
+ if (error instanceof error_1.CliError) {
125
+ throw error;
126
+ }
127
+ throw new error_1.CliError('STORAGE_OPERATION_FAILED', `Storage operation failed: ${error.message}`);
128
+ }
129
+ }
130
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/storage/index.ts"],"names":[],"mappings":";;;AAkCA,oBAiEC;AAED,oBA4CC;AAhJD,2CAA8C;AAE9C,6CAA4C;AAC5C,+BAAiC;AACjC,mCAAqC;AACrC,qCAAuC;AAO1B,QAAA,IAAI,GAAG,IAAA,kBAAW,EAAC;IAC9B,QAAQ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uB,UAAU,wFAAwF,CAC1H,CAAA;IACH,CAAC;IAED,8BAA8B;IAC9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,gBAAQ,CAChB,wBAAwB,EACxB,uBAAuB,UAAU,4DAA4D,CAC9F,CAAA;IACH,CAAC;IAED,+BAA+B;IAC/B,IAAI,CAAC;QACH,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YACzB,MAAM,IAAA,eAAS,EAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QACvC,CAAC;aAAM,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;YAClC,MAAM,IAAA,mBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QACzC,CAAC;aAAM,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YACnC,MAAM,IAAA,qBAAY,EAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAQ,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAA;QACb,CAAC;QACD,MAAM,IAAI,gBAAQ,CAAC,0BAA0B,EAAE,6BAA8B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;IACzG,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Options } from './types';
2
+ /**
3
+ * Handles player storage operations in the server-side storage service (get, set, delete, clear)
4
+ */
5
+ export declare const handlePlayer: (action: string, key: string | undefined, options: Options) => Promise<void>;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handlePlayer = void 0;
4
+ const path_1 = require("path");
5
+ const error_1 = require("../../logic/error");
6
+ const beautiful_logs_1 = require("../../logic/beautiful-logs");
7
+ const shared_1 = require("./shared");
8
+ /**
9
+ * Handles player storage operations in the server-side storage service (get, set, delete, clear)
10
+ */
11
+ const handlePlayer = async (action, key, options) => {
12
+ const { logger, analytics } = options.components;
13
+ const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
14
+ // Common setup: validate action, workspace, and world
15
+ const { baseURL, worldName, baseParcel, parcels } = await (0, shared_1.setupStorageCommand)(options.components, projectRoot, action, options.args['--target'], ['get', 'set', 'delete', 'clear']);
16
+ // Get address (required for get/set/delete, optional for clear)
17
+ const address = options.args['--address'];
18
+ // Linker dApp options
19
+ const linkOptions = (0, shared_1.getLinkerDappOptions)(options.args);
20
+ // Handle actions
21
+ if (action === 'get') {
22
+ // GET operation
23
+ if (!address) {
24
+ throw new error_1.CliError('STORAGE_MISSING_ADDRESS', 'Missing --address option. Usage: storage player get KEY --address 0x...');
25
+ }
26
+ if (!key) {
27
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage player get KEY --address 0x...');
28
+ }
29
+ logger.info(`Getting player storage value '${key}' for ${address} from ${baseURL}`);
30
+ const url = `${baseURL}/players/${encodeURIComponent(address)}/values/${encodeURIComponent(key)}`;
31
+ const info = (0, shared_1.createStorageInfo)('player', 'get', url, worldName, baseParcel, parcels, key, undefined, address);
32
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'GET', url);
33
+ if (result.success) {
34
+ analytics.track('Storage Player Get Success', { key, address });
35
+ logger.log(`\nValue for '${key}' (${address}):`);
36
+ logger.log(JSON.stringify(result.data, null, 2));
37
+ }
38
+ else {
39
+ analytics.track('Storage Player Get Failure', { key, address });
40
+ (0, beautiful_logs_1.printError)(logger, `Failed to get player storage value '${key}' for ${address}:`, new Error(result.error || 'Unknown error'));
41
+ }
42
+ }
43
+ else if (action === 'set') {
44
+ // SET operation
45
+ if (!address) {
46
+ throw new error_1.CliError('STORAGE_MISSING_ADDRESS', 'Missing --address option. Usage: storage player set KEY --value VALUE --address 0x...');
47
+ }
48
+ if (!key) {
49
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage player set KEY --value VALUE --address 0x...');
50
+ }
51
+ const value = options.args['--value'];
52
+ if (value === undefined) {
53
+ throw new error_1.CliError('STORAGE_MISSING_VALUE', 'Missing --value option. Usage: storage player set KEY --value VALUE --address 0x...');
54
+ }
55
+ logger.info(`Setting player storage value '${key}' for ${address} to ${baseURL}`);
56
+ const url = `${baseURL}/players/${encodeURIComponent(address)}/values/${encodeURIComponent(key)}`;
57
+ const info = (0, shared_1.createStorageInfo)('player', 'set', url, worldName, baseParcel, parcels, key, value, address);
58
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'PUT', url, { value });
59
+ if (result.success) {
60
+ analytics.track('Storage Player Set Success', { key, address });
61
+ (0, beautiful_logs_1.printSuccess)(logger, `Player storage value '${key}' for ${address} set successfully!`, '');
62
+ }
63
+ else {
64
+ analytics.track('Storage Player Set Failure', { key, address });
65
+ (0, beautiful_logs_1.printError)(logger, `Failed to set player storage value '${key}' for ${address}:`, new Error(result.error || 'Unknown error'));
66
+ }
67
+ }
68
+ else if (action === 'delete') {
69
+ // DELETE operation
70
+ if (!address) {
71
+ throw new error_1.CliError('STORAGE_MISSING_ADDRESS', 'Missing --address option. Usage: storage player delete KEY --address 0x...');
72
+ }
73
+ if (!key) {
74
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage player delete KEY --address 0x...');
75
+ }
76
+ logger.info(`Deleting player storage value '${key}' for ${address} from ${baseURL}`);
77
+ const url = `${baseURL}/players/${encodeURIComponent(address)}/values/${encodeURIComponent(key)}`;
78
+ const info = (0, shared_1.createStorageInfo)('player', 'delete', url, worldName, baseParcel, parcels, key, undefined, address);
79
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url);
80
+ if (result.success) {
81
+ analytics.track('Storage Player Delete Success', { key, address });
82
+ (0, beautiful_logs_1.printSuccess)(logger, `Player storage value '${key}' for ${address} deleted successfully!`, '');
83
+ }
84
+ else {
85
+ analytics.track('Storage Player Delete Failure', { key, address });
86
+ (0, beautiful_logs_1.printError)(logger, `Failed to delete player storage value '${key}' for ${address}:`, new Error(result.error || 'Unknown error'));
87
+ }
88
+ }
89
+ else if (action === 'clear') {
90
+ // CLEAR operation
91
+ const hasConfirm = options.args['--confirm'];
92
+ if (address) {
93
+ // Clear specific player
94
+ if (!hasConfirm) {
95
+ const confirmed = await (0, shared_1.confirmAction)(`Are you sure you want to delete ALL storage data for player ${address}? This cannot be undone.`);
96
+ if (!confirmed) {
97
+ logger.info('Operation cancelled.');
98
+ return;
99
+ }
100
+ }
101
+ logger.info(`Clearing all storage data for player ${address} from ${baseURL}`);
102
+ const url = `${baseURL}/players/${encodeURIComponent(address)}/values`;
103
+ const info = (0, shared_1.createStorageInfo)('player', 'clear', url, worldName, baseParcel, parcels, undefined, undefined, address);
104
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url, undefined, {
105
+ 'X-Confirm-Delete-All': 'true'
106
+ });
107
+ if (result.success) {
108
+ analytics.track('Storage Player Clear Success', { address });
109
+ (0, beautiful_logs_1.printSuccess)(logger, `All storage data for player ${address} cleared successfully!`, '');
110
+ }
111
+ else {
112
+ analytics.track('Storage Player Clear Failure', { address });
113
+ (0, beautiful_logs_1.printError)(logger, `Failed to clear storage data for player ${address}:`, new Error(result.error || 'Unknown error'));
114
+ }
115
+ }
116
+ else {
117
+ // Clear all players
118
+ if (!hasConfirm) {
119
+ const confirmed = await (0, shared_1.confirmAction)('Are you sure you want to delete ALL player storage data for ALL players? This cannot be undone.');
120
+ if (!confirmed) {
121
+ logger.info('Operation cancelled.');
122
+ return;
123
+ }
124
+ }
125
+ logger.info(`Clearing all player storage data from ${baseURL}`);
126
+ const url = `${baseURL}/players`;
127
+ const info = (0, shared_1.createStorageInfo)('player', 'clear', url, worldName, baseParcel, parcels);
128
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url, undefined, {
129
+ 'X-Confirm-Delete-All': 'true'
130
+ });
131
+ if (result.success) {
132
+ analytics.track('Storage Player Clear All Success', {});
133
+ (0, beautiful_logs_1.printSuccess)(logger, 'All player storage data cleared successfully!', '');
134
+ }
135
+ else {
136
+ analytics.track('Storage Player Clear All Failure', {});
137
+ (0, beautiful_logs_1.printError)(logger, 'Failed to clear all player storage data:', new Error(result.error || 'Unknown error'));
138
+ }
139
+ }
140
+ }
141
+ };
142
+ exports.handlePlayer = handlePlayer;
143
+ //# sourceMappingURL=player.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"player.js","sourceRoot":"","sources":["../../../src/commands/storage/player.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAE9B,6CAA4C;AAC5C,+DAAqE;AACrE,qCAMiB;AAEjB;;GAEG;AACI,MAAM,YAAY,GAAG,KAAK,EAAE,MAAc,EAAE,GAAuB,EAAE,OAAgB,EAAiB,EAAE;IAC7G,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAA;IAChD,MAAM,WAAW,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAA;IAExE,sDAAsD;IACtD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,4BAAmB,EAC3E,OAAO,CAAC,UAAU,EAClB,WAAW,EACX,MAAM,EACN,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EACxB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAClC,CAAA;IAED,gEAAgE;IAChE,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAEzC,sBAAsB;IACtB,MAAM,WAAW,GAAG,IAAA,6BAAoB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtD,iB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AC,CAAA;YAEF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,SAAS,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAA;gBACvD,IAAA,6BAAY,EAAC,MAAM,EAAE,+CAA+C,EAAE,EAAE,CAAC,CAAA;YAC3E,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAA;gBACvD,IAAA,2BAAU,EAAC,MAAM,EAAE,0CAA0C,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,eAAe,CAAC,CAAC,CAAA;YAC5G,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AA5MY,QAAA,YAAY,gBA4MxB"}
@@ -0,0 +1,5 @@
1
+ import { Options } from './types';
2
+ /**
3
+ * Handles scene storage operations in the server-side storage service (get, set, delete, clear)
4
+ */
5
+ export declare const handleScene: (action: string, key: string | undefined, options: Options) => Promise<void>;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleScene = void 0;
4
+ const path_1 = require("path");
5
+ const error_1 = require("../../logic/error");
6
+ const beautiful_logs_1 = require("../../logic/beautiful-logs");
7
+ const shared_1 = require("./shared");
8
+ /**
9
+ * Handles scene storage operations in the server-side storage service (get, set, delete, clear)
10
+ */
11
+ const handleScene = async (action, key, options) => {
12
+ const { logger, analytics } = options.components;
13
+ const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
14
+ // Common setup: validate action, workspace, and world
15
+ const { baseURL, worldName, baseParcel, parcels } = await (0, shared_1.setupStorageCommand)(options.components, projectRoot, action, options.args['--target'], ['get', 'set', 'delete', 'clear']);
16
+ // Linker dApp options
17
+ const linkOptions = (0, shared_1.getLinkerDappOptions)(options.args);
18
+ // Handle actions
19
+ if (action === 'get') {
20
+ // GET operation
21
+ if (!key) {
22
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage scene get KEY');
23
+ }
24
+ logger.info(`Getting scene storage value '${key}' from ${baseURL}`);
25
+ const url = `${baseURL}/values/${encodeURIComponent(key)}`;
26
+ const info = (0, shared_1.createStorageInfo)('scene', 'get', url, worldName, baseParcel, parcels, key);
27
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'GET', url);
28
+ if (result.success) {
29
+ analytics.track('Storage Scene Get Success', { key });
30
+ logger.log(`\nValue for '${key}':`);
31
+ logger.log(JSON.stringify(result.data, null, 2));
32
+ }
33
+ else {
34
+ analytics.track('Storage Scene Get Failure', { key });
35
+ (0, beautiful_logs_1.printError)(logger, `Failed to get scene storage value '${key}':`, new Error(result.error || 'Unknown error'));
36
+ }
37
+ }
38
+ else if (action === 'set') {
39
+ // SET operation
40
+ if (!key) {
41
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage scene set KEY --value VALUE');
42
+ }
43
+ const value = options.args['--value'];
44
+ if (value === undefined) {
45
+ throw new error_1.CliError('STORAGE_MISSING_VALUE', 'Missing --value option. Usage: storage scene set KEY --value VALUE');
46
+ }
47
+ logger.info(`Setting scene storage value '${key}' to ${baseURL}`);
48
+ const url = `${baseURL}/values/${encodeURIComponent(key)}`;
49
+ const info = (0, shared_1.createStorageInfo)('scene', 'set', url, worldName, baseParcel, parcels, key, value);
50
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'PUT', url, { value });
51
+ if (result.success) {
52
+ analytics.track('Storage Scene Set Success', { key });
53
+ (0, beautiful_logs_1.printSuccess)(logger, `Scene storage value '${key}' set successfully!`, '');
54
+ }
55
+ else {
56
+ analytics.track('Storage Scene Set Failure', { key });
57
+ (0, beautiful_logs_1.printError)(logger, `Failed to set scene storage value '${key}':`, new Error(result.error || 'Unknown error'));
58
+ }
59
+ }
60
+ else if (action === 'delete') {
61
+ // DELETE operation
62
+ if (!key) {
63
+ throw new error_1.CliError('STORAGE_MISSING_KEY', 'Missing KEY argument. Usage: storage scene delete KEY');
64
+ }
65
+ logger.info(`Deleting scene storage value '${key}' from ${baseURL}`);
66
+ const url = `${baseURL}/values/${encodeURIComponent(key)}`;
67
+ const info = (0, shared_1.createStorageInfo)('scene', 'delete', url, worldName, baseParcel, parcels, key);
68
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url);
69
+ if (result.success) {
70
+ analytics.track('Storage Scene Delete Success', { key });
71
+ (0, beautiful_logs_1.printSuccess)(logger, `Scene storage value '${key}' deleted successfully!`, '');
72
+ }
73
+ else {
74
+ analytics.track('Storage Scene Delete Failure', { key });
75
+ (0, beautiful_logs_1.printError)(logger, `Failed to delete scene storage value '${key}':`, new Error(result.error || 'Unknown error'));
76
+ }
77
+ }
78
+ else if (action === 'clear') {
79
+ // CLEAR operation
80
+ const hasConfirm = options.args['--confirm'];
81
+ if (!hasConfirm) {
82
+ const confirmed = await (0, shared_1.confirmAction)('Are you sure you want to delete ALL scene storage data? This cannot be undone.');
83
+ if (!confirmed) {
84
+ logger.info('Operation cancelled.');
85
+ return;
86
+ }
87
+ }
88
+ logger.info(`Clearing all scene storage data from ${baseURL}`);
89
+ const url = `${baseURL}/values`;
90
+ const info = (0, shared_1.createStorageInfo)('scene', 'clear', url, worldName, baseParcel, parcels);
91
+ const result = await (0, shared_1.makeAuthenticatedRequest)(options.components, info, linkOptions, 'DELETE', url, undefined, {
92
+ 'X-Confirm-Delete-All': 'true'
93
+ });
94
+ if (result.success) {
95
+ analytics.track('Storage Scene Clear Success', {});
96
+ (0, beautiful_logs_1.printSuccess)(logger, 'All scene storage data cleared successfully!', '');
97
+ }
98
+ else {
99
+ analytics.track('Storage Scene Clear Failure', {});
100
+ (0, beautiful_logs_1.printError)(logger, 'Failed to clear scene storage data:', new Error(result.error || 'Unknown error'));
101
+ }
102
+ }
103
+ };
104
+ exports.handleScene = handleScene;
105
+ //# sourceMappingURL=scene.js.map
@@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C,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE;YAC7G,sBAAsB,EAAE,MAAM;SAC/B,CAAC,CAAA;QAEF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,SAAS,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAA;YAClD,IAAA,6BAAY,EAAC,MAAM,EAAE,8CAA8C,EAAE,EAAE,CAAC,CAAA;QAC1E,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAA;YAClD,IAAA,2BAAU,EAAC,MAAM,EAAE,qCAAqC,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,eAAe,CAAC,CAAC,CAAA;QACvG,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAlHY,QAAA,WAAW,eAkHvB"}
@@ -0,0 +1,62 @@
1
+ import { IFuture } from 'fp-future';
2
+ import { Lifecycle } from '@well-known-components/interfaces';
3
+ import { CliComponents } from '../../components';
4
+ import { LinkerResponse } from '../../linker-dapp/routes';
5
+ import { StorageInfo, LinkerOptions, StorageType } from './types';
6
+ /**
7
+ * Validates workspace and extracts world configuration for server-side storage operations
8
+ */
9
+ export declare const validateWorkspaceAndWorld: (components: CliComponents, projectRoot: string, baseURL: string) => Promise<{
10
+ worldName: string | undefined;
11
+ baseParcel: string;
12
+ parcels: string[];
13
+ }>;
14
+ /**
15
+ * Builds metadata for server-side storage service requests (ADR-44 format)
16
+ */
17
+ export declare const buildStorageMetadata: (worldName: string | undefined, baseParcel: string) => string;
18
+ /**
19
+ * Confirms an action with the user
20
+ * Accepts: yes, y, no, n (case insensitive)
21
+ */
22
+ export declare const confirmAction: (message: string) => Promise<boolean>;
23
+ /**
24
+ * Extracts linker dApp options from command arguments
25
+ */
26
+ export declare const getLinkerDappOptions: (args: {
27
+ "--port"?: number;
28
+ "--no-browser"?: boolean;
29
+ "--https"?: boolean;
30
+ }) => LinkerOptions;
31
+ /**
32
+ * Common setup for server-side storage commands: validates action, workspace, and world configuration
33
+ */
34
+ export declare const setupStorageCommand: (components: CliComponents, projectRoot: string, action: string, targetArg: string | undefined, validActions: string[]) => Promise<{
35
+ baseURL: string;
36
+ worldName: string | undefined;
37
+ baseParcel: string;
38
+ parcels: string[];
39
+ }>;
40
+ export type StorageOperationResult = {
41
+ success: boolean;
42
+ data?: any;
43
+ error?: string;
44
+ };
45
+ /**
46
+ * Gets authentication (private key or linker dApp) and executes callback with signed headers
47
+ */
48
+ export declare const getAuthHeaders: (components: CliComponents, awaitResponse: IFuture<void>, info: StorageInfo, linkOptions: LinkerOptions, deployCallback: (response: LinkerResponse) => Promise<StorageOperationResult>) => Promise<{
49
+ program?: Lifecycle.ComponentBasedProgram<unknown>;
50
+ }>;
51
+ /**
52
+ * Makes an authenticated request to the server-side storage service
53
+ */
54
+ export declare const makeAuthenticatedRequest: (components: CliComponents, info: StorageInfo, linkOptions: LinkerOptions, method: "GET" | "PUT" | "DELETE", url: string, body?: any, additionalHeaders?: Record<string, string>) => Promise<StorageOperationResult>;
55
+ /**
56
+ * Gets the base URL for server-side storage service operations
57
+ */
58
+ export declare const getStorageBaseUrl: (targetArg?: string) => string;
59
+ /**
60
+ * Creates storage info object for signing server-side storage service requests
61
+ */
62
+ export declare const createStorageInfo: (storageType: StorageType, action: "get" | "set" | "delete" | "clear", url: string, worldName: string | undefined, baseParcel: string, parcels: string[], key?: string, value?: string, address?: string) => StorageInfo;