@treasuredata/tdx 0.8.6 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/build-info.json +2 -2
- package/dist/cli-categories.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/cdp-api-client.js +1 -1
- package/dist/client/engage-api-client.js +1 -1
- package/dist/client/http-client.js +1 -1
- package/dist/client/llm-api-client.js +1 -1
- package/dist/client/rate-limiter.js +1 -1
- package/dist/client/td-api-client.js +1 -1
- package/dist/client/trino-api-client.js +1 -1
- package/dist/client/workflow-client.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-statusline-command.js +1 -1
- package/dist/commands/claude-usage-command.js +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/connection-command.js +1 -1
- package/dist/commands/context-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/journey-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/llm-proxy.js +1 -1
- package/dist/commands/parent-segment-command.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segment-create-command.js +1 -1
- package/dist/commands/segment-fields-command.js +1 -1
- package/dist/commands/segment-pull-command.js +1 -1
- package/dist/commands/segment-push-command.js +1 -1
- package/dist/commands/segment-update-command.js +1 -1
- package/dist/commands/segment-use-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/user-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.js +1 -1
- package/dist/core/credential-cache.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/keychain.js +1 -1
- package/dist/core/profile.js +1 -1
- package/dist/core/project-config.js +1 -1
- package/dist/core/session.js +1 -1
- package/dist/core/user-cache.js +1 -1
- package/dist/index.js +1 -1
- package/dist/proxy/anthropic-adapter.js +1 -1
- package/dist/proxy/claude-usage-tracker.js +1 -1
- package/dist/proxy/context-signature.js +1 -1
- package/dist/proxy/conversation-utils.js +1 -1
- package/dist/proxy/server.js +1 -1
- package/dist/proxy/session-cache.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/connection.js +1 -1
- package/dist/sdk/engage.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm.js +1 -1
- package/dist/sdk/query.js +1 -1
- package/dist/sdk/segment/child-segment-yaml.js +1 -1
- package/dist/sdk/segment/journey-yaml.js +1 -1
- package/dist/sdk/segment/parent-segment-preview.js +1 -1
- package/dist/sdk/segment/parent-segment-yaml.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/user.js +1 -1
- package/dist/sdk/workflow.js +1 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/agent-ref-parser.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/chat-cache.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/command-output.js +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/diff.js +1 -1
- package/dist/utils/fields-display.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/format-detector.js +1 -1
- package/dist/utils/formatters.js +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/llm-backup-utils.js +1 -1
- package/dist/utils/model-aliases.js +1 -1
- package/dist/utils/model-factors.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/process.js.map +1 -1
- package/dist/utils/prompt.js +1 -1
- package/dist/utils/segment-path-parser.js +1 -1
- package/dist/utils/segment-ref-parser.js +1 -1
- package/dist/utils/spinner.js +1 -1
- package/dist/utils/sql-parser.js +1 -1
- package/dist/utils/sse-parser.js +1 -1
- package/dist/utils/string-utils.js +1 -1
- package/dist/utils/table-ref-parser.js +1 -1
- package/dist/utils/tdx-config.js +1 -1
- package/dist/utils/tdx-logger.js +1 -1
- package/dist/utils/tree-formatter.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/dist/utils/workflow-utils.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a33_0x5ea83a=a33_0x38db;(function(_0x31bd8c,_0x126a44){const _0x29fca9=a33_0x38db,_0x3a402f=_0x31bd8c();while(!![]){try{const _0x4b0566=-parseInt(_0x29fca9(0x1db))/0x1+-parseInt(_0x29fca9(0x1d7))/0x2*(-parseInt(_0x29fca9(0x1d6))/0x3)+-parseInt(_0x29fca9(0x1e5))/0x4*(-parseInt(_0x29fca9(0x1d5))/0x5)+parseInt(_0x29fca9(0x1e6))/0x6+parseInt(_0x29fca9(0x1e3))/0x7+-parseInt(_0x29fca9(0x1d4))/0x8*(parseInt(_0x29fca9(0x1e2))/0x9)+parseInt(_0x29fca9(0x1e7))/0xa*(parseInt(_0x29fca9(0x1d9))/0xb);if(_0x4b0566===_0x126a44)break;else _0x3a402f['push'](_0x3a402f['shift']());}catch(_0x9c19ce){_0x3a402f['push'](_0x3a402f['shift']());}}}(a33_0x6251,0x81259));import{BaseCommand}from'./command.js';import{handleSDKOutput}from'../utils/command-output.js';function a33_0x6251(){const _0x118644=['\x27...','name','listFields','segment:fields','error','description','1054712cpFeau','250NfnZdI','56274jOatAj','10csXxUq','parentSegment','4653umAxPc','jsonl','527006YUPVeq','Error:\x20Parent\x20segment\x20name\x20is\x20required','Site:\x20','length','data','verbose','\x20field','45EKaqMz','2278255YAoyjU','site','45996nRyYoy','422442qZCXJm','15380MVndin','Usage:\x20tdx\x20segment\x20fields\x20<parent_name>','segment','✔\x20Found\x20'];a33_0x6251=function(){return _0x118644;};return a33_0x6251();}import{withSpinner}from'../utils/spinner.js';function a33_0x38db(_0x162974,_0x2df9d3){_0x162974=_0x162974-0x1cd;const _0x62514d=a33_0x6251();let _0x38db60=_0x62514d[_0x162974];return _0x38db60;}import{displayFieldsHumanReadable}from'../utils/fields-display.js';export class SegmentFieldsCommand extends BaseCommand{[a33_0x5ea83a(0x1cf)]=a33_0x5ea83a(0x1d1);[a33_0x5ea83a(0x1d3)]='List\x20available\x20fields\x20for\x20segmentation';async['execute'](_0x153999){const _0x474a58=a33_0x5ea83a,{options:_0x484062,args:_0x42fae1,tdx:_0x5e73a7}=_0x153999,_0x5c9040=_0x42fae1[0x0]||_0x484062[_0x474a58(0x1d8)];if(!_0x5c9040)return console[_0x474a58(0x1d2)](_0x474a58(0x1dc)),console[_0x474a58(0x1d2)](_0x474a58(0x1e8)),console['error']('\x20\x20Or\x20set\x20context:\x20tdx\x20use\x20parent_segment\x20<name>'),0x1;_0x484062[_0x474a58(0x1e0)]&&(console['error'](_0x474a58(0x1dd)+_0x484062[_0x474a58(0x1e4)]),console['error']('Parent\x20segment:\x20'+_0x5c9040));const _0x572bc4=await withSpinner('Listing\x20fields\x20for\x20\x27'+_0x5c9040+_0x474a58(0x1ce),()=>_0x5e73a7[_0x474a58(0x1e9)][_0x474a58(0x1d0)](_0x5c9040),{'verbose':_0x484062[_0x474a58(0x1e0)]}),_0x2764d2=_0x572bc4[_0x474a58(0x1df)];console[_0x474a58(0x1d2)](_0x474a58(0x1cd)+_0x2764d2[_0x474a58(0x1de)]+_0x474a58(0x1e1)+(_0x2764d2['length']!==0x1?'s':''));if(_0x484062['json']||_0x484062[_0x474a58(0x1da)])return await handleSDKOutput(_0x2764d2,_0x484062),0x0;return displayFieldsHumanReadable(_0x2764d2,_0x5c9040),0x0;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a34_0x2d11dc=a34_0x4c4a;(function(_0x48f00a,_0x45921b){const _0x46db84=a34_0x4c4a,_0xbb8424=_0x48f00a();while(!![]){try{const _0x454fdd=parseInt(_0x46db84(0x8b))/0x1+parseInt(_0x46db84(0x87))/0x2+parseInt(_0x46db84(0xb5))/0x3*(-parseInt(_0x46db84(0xd2))/0x4)+parseInt(_0x46db84(0xcd))/0x5+-parseInt(_0x46db84(0xba))/0x6+-parseInt(_0x46db84(0xbc))/0x7*(parseInt(_0x46db84(0xb9))/0x8)+parseInt(_0x46db84(0x91))/0x9*(parseInt(_0x46db84(0xab))/0xa);if(_0x454fdd===_0x45921b)break;else _0xbb8424['push'](_0xbb8424['shift']());}catch(_0x1d858a){_0xbb8424['push'](_0xbb8424['shift']());}}}(a34_0x3b85,0xc688b));import{BaseCommand}from'./command.js';import{withSpinner}from'../utils/spinner.js';import{generateDiff,formatDiffWithColors,hasChanges}from'../utils/diff.js';import{confirmKey}from'../utils/prompt.js';function a34_0x3b85(){const _0x5b8720=['parentFolderId','\x27...','Write\x20','\x20\x20Target:\x20','has','4236535zpUCiA','Fetching\x20parent\x20segment\x20info...','Fetching\x20users\x20for\x20email\x20resolution...','Found\x20tdx.json\x20at:\x20','Pull\x20child\x20segments\x20to\x20YAML\x20files','68668yfxfVD','utf-8','parent_segment','dirname','parentSegment','name','green','Fetching\x20activations...','push','303946MemqwK','\x0a[Dry\x20run]\x20No\x20files\x20were\x20written','attributes','all','471823AWIBfV','tdx.json','yellow','Fetching\x20folders...','from','segment','300249Zqtlvp','buildIdToNameMap','then','Resolving\x20parent\x20segment\x20\x27','Resolved\x20parent\x20name:\x20','Parent\x20segment:\x20','✔\x20Context\x20set:\x20','Fetching\x20connections\x20for\x20name\x20resolution...','Tip:\x20Run\x20`tdx\x20sg\x20pull\x20<parent_name>`\x20first\x20to\x20create\x20the\x20folder\x20structure','execute','repeat','cyan','Using\x20parent\x20segment:\x20','Fetching\x20segments...','hasChanges','red','\x20unchanged\x20files','.yml','session','\x20files?','dim','join','Usage:\x20tdx\x20sg\x20pull\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Pull\x20all\x20segments\x20(requires\x20context\x20or\x20tdx.json)','relativePath','yes','get','650cQTOmW','Site:\x20','verbose','filter','\x20segments','error','✔\x20All\x20files\x20are\x20up\x20to\x20date','No\x20segments\x20found\x20in\x20parent\x20segment\x20\x27','✔\x20Pulled\x20','description','39PqkSeF','set','absolutePath','data','15800zLrjpV','8615862ZhXGmj','diff','4137mznfIi','\x20changed\x20files','dryRun','\x20new\x20files','listSegments','resolveParentId','isNew','segment:pull','length','\x20=\x20','segmentFolderId','reduce'];a34_0x3b85=function(){return _0x5b8720;};return a34_0x3b85();}import{batchAsync}from'../utils/async.js';import{getSegmentRootDir,createTdxConfigContent,findTdxConfigPath,loadTdxConfig}from'../utils/tdx-config.js';import{saveSessionContext}from'../core/session.js';import{segmentWithActivationsToYaml,segmentToYamlString}from'../sdk/segment/child-segment-yaml.js';import a34_0x452505 from'chalk';import{existsSync,mkdirSync,readFileSync,writeFileSync,statSync}from'fs';import a34_0x2da008 from'path';import{sanitizeFileName}from'../utils/string-utils.js';export class SegmentPullCommand extends BaseCommand{[a34_0x2d11dc(0x83)]=a34_0x2d11dc(0xc3);[a34_0x2d11dc(0xb4)]=a34_0x2d11dc(0xd1);async[a34_0x2d11dc(0x9a)](_0x4416ff){const _0x4fcee2=a34_0x2d11dc,{options:_0x2042ec,args:_0x873c38,tdx:_0x35375e}=_0x4416ff,_0x286815=_0x2042ec,_0x11a2cb=_0x2042ec[_0x4fcee2(0x82)],_0x192066=_0x873c38[0x0],_0x33c0b9=findTdxConfigPath();let _0x3eb066,_0x50881d;if(!_0x192066&&_0x33c0b9){const _0x219dcf=loadTdxConfig(_0x33c0b9);_0x3eb066=_0x219dcf['parent_segment'],_0x50881d=a34_0x2da008[_0x4fcee2(0x81)](_0x33c0b9),_0x286815[_0x4fcee2(0xad)]&&(console['error']('Found\x20existing\x20tdx.json\x20at:\x20'+_0x33c0b9),console[_0x4fcee2(0xb0)](_0x4fcee2(0x9d)+_0x3eb066));}else{if(_0x192066){if(existsSync(_0x192066)&&statSync(_0x192066)['isDirectory']()){const _0x190e2a=findTdxConfigPath(_0x192066);if(_0x190e2a){const _0x13f347=loadTdxConfig(_0x190e2a);_0x3eb066=_0x13f347[_0x4fcee2(0x80)],_0x50881d=a34_0x2da008['dirname'](_0x190e2a),_0x286815[_0x4fcee2(0xad)]&&(console['error'](_0x4fcee2(0xd0)+_0x190e2a),console[_0x4fcee2(0xb0)](_0x4fcee2(0x9d)+_0x3eb066));}else return console[_0x4fcee2(0xb0)](a34_0x452505[_0x4fcee2(0xa0)]('Error:\x20No\x20tdx.json\x20found\x20in\x20or\x20above:\x20'+_0x192066+'\x0a')),console[_0x4fcee2(0xb0)](a34_0x452505['cyan'](_0x4fcee2(0x99))),0x1;}else _0x3eb066=_0x192066;}else _0x3eb066=_0x11a2cb;}if(!_0x3eb066)return console[_0x4fcee2(0xb0)](a34_0x452505[_0x4fcee2(0x8d)]('parent_segment\x20is\x20not\x20set.\x20Use\x20`tdx\x20sg\x20use\x20<parent_name>`\x20to\x20set\x20it.\x0a')),console[_0x4fcee2(0xb0)](_0x4fcee2(0xa7)),console[_0x4fcee2(0xb0)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20pull\x20<parent_name>\x20\x20\x20\x20\x20\x20#\x20Pull\x20all\x20segments\x20from\x20parent'),console[_0x4fcee2(0xb0)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20pull\x20<file_path>\x20\x20\x20\x20\x20\x20\x20\x20#\x20Pull\x20specific\x20segment\x20file'),0x1;_0x286815[_0x4fcee2(0xad)]&&(console[_0x4fcee2(0xb0)](_0x4fcee2(0xac)+_0x286815['site']),console[_0x4fcee2(0xb0)](_0x4fcee2(0x96)+_0x3eb066));const _0x238039=await withSpinner(_0x4fcee2(0x94)+_0x3eb066+_0x4fcee2(0xc9),()=>_0x35375e[_0x4fcee2(0x90)][_0x4fcee2(0xc1)](_0x3eb066),{'verbose':_0x286815[_0x4fcee2(0xad)]}),_0x5e0acd=_0x238039[_0x4fcee2(0xb8)],_0x4c47e5=await withSpinner(_0x4fcee2(0xce),()=>_0x35375e['segment']['getParent'](_0x5e0acd),{'verbose':_0x286815[_0x4fcee2(0xad)]}),_0x1b5915=_0x4c47e5[_0x4fcee2(0xb8)][_0x4fcee2(0x89)]['name'];_0x286815[_0x4fcee2(0xad)]&&console[_0x4fcee2(0xb0)](_0x4fcee2(0x95)+_0x1b5915);const [_0x3fae4f,_0x3f5c8a]=await Promise[_0x4fcee2(0x8a)]([withSpinner(_0x4fcee2(0x9e),()=>_0x35375e['segment'][_0x4fcee2(0xc0)](_0x5e0acd),{'verbose':_0x286815['verbose']}),withSpinner(_0x4fcee2(0x8e),()=>_0x35375e[_0x4fcee2(0x90)]['listFolders'](_0x5e0acd),{'verbose':_0x286815[_0x4fcee2(0xad)]})]),_0x5d8560=_0x3fae4f[_0x4fcee2(0xb8)],_0x1ea0a1=_0x3f5c8a[_0x4fcee2(0xb8)];if(_0x5d8560[_0x4fcee2(0xc4)]===0x0)return console['error'](a34_0x452505[_0x4fcee2(0x8d)](_0x4fcee2(0xb2)+_0x1b5915+'\x27')),0x0;const _0x143ac9=buildFolderPathMap(_0x1ea0a1),_0x4020a9=_0x50881d||getSegmentRootDir(sanitizeFileName(_0x3eb066)),_0x2d117d=new Map();await withSpinner(_0x4fcee2(0x85),async()=>{await batchAsync(_0x5d8560,async _0xe7ef9b=>{const _0xfc462c=a34_0x4c4a,_0x14aa97=await _0x35375e[_0xfc462c(0x90)]['listActivations'](_0x5e0acd,_0xe7ef9b['id']);_0x2d117d['set'](_0xe7ef9b['id'],_0x14aa97);});},{'verbose':_0x286815[_0x4fcee2(0xad)]});const _0x2476ae=await withSpinner(_0x4fcee2(0xcf),()=>_0x35375e['user']['buildIdToEmailMap'](),{'verbose':_0x286815[_0x4fcee2(0xad)]})['then'](_0x51805d=>_0x51805d[_0x4fcee2(0xb8)]),_0x2b790f=await withSpinner(_0x4fcee2(0x98),()=>_0x35375e['connection'][_0x4fcee2(0x92)](),{'verbose':_0x286815[_0x4fcee2(0xad)]})[_0x4fcee2(0x93)](_0x306360=>_0x306360[_0x4fcee2(0xb8)]),_0x511eb0=[],_0x1c056c=a34_0x2da008[_0x4fcee2(0xa6)](_0x4020a9,_0x4fcee2(0x8c)),_0x79e552=createTdxConfigContent(_0x1b5915);_0x511eb0[_0x4fcee2(0x86)](prepareFile(_0x1c056c,_0x79e552,_0x4020a9));const _0x347b61=new Map();for(const _0x4c3845 of _0x5d8560){const _0x22eddb=_0x4c3845[_0x4fcee2(0xc6)]?_0x143ac9[_0x4fcee2(0xaa)](_0x4c3845[_0x4fcee2(0xc6)])||'':'',_0x295b51=_0x2d117d[_0x4fcee2(0xaa)](_0x4c3845['id'])||[],_0x2c555d=segmentWithActivationsToYaml(_0x4c3845,_0x295b51,undefined,_0x2476ae,_0x2b790f),_0x18ea53=_0x22eddb?a34_0x2da008['join'](_0x4020a9,_0x22eddb):_0x4020a9,_0xb059c=sanitizeFileName(_0x4c3845[_0x4fcee2(0x83)]),_0x24dacf=getUniqueFileName(_0x18ea53,_0xb059c,_0x347b61),_0x581b94=a34_0x2da008[_0x4fcee2(0xa6)](_0x18ea53,_0x24dacf+_0x4fcee2(0xa2)),_0x1f2f80=segmentToYamlString(_0x2c555d);_0x511eb0[_0x4fcee2(0x86)](prepareFile(_0x581b94,_0x1f2f80,_0x4020a9));}const _0x1db58d=Array[_0x4fcee2(0x8f)](_0x2d117d['values']())[_0x4fcee2(0xc7)]((_0x16d46f,_0x23a220)=>_0x16d46f+_0x23a220['length'],0x0),_0x2eef1a=_0x511eb0['filter'](_0x153f65=>_0x153f65[_0x4fcee2(0xc2)]),_0x860f8=_0x511eb0[_0x4fcee2(0xae)](_0x5c1d72=>!_0x5c1d72[_0x4fcee2(0xc2)]&&_0x5c1d72['hasChanges']),_0x186b9f=_0x511eb0['filter'](_0x46b6e4=>!_0x46b6e4[_0x4fcee2(0xc2)]&&!_0x46b6e4[_0x4fcee2(0x9f)]);console[_0x4fcee2(0xb0)]('\x0aPull\x20summary\x20for\x20\x27'+_0x1b5915+'\x27:'),console[_0x4fcee2(0xb0)]('\x20\x20'+a34_0x452505[_0x4fcee2(0x9c)](_0x5d8560[_0x4fcee2(0xc4)]+_0x4fcee2(0xaf))+'\x20with\x20'+a34_0x452505[_0x4fcee2(0x9c)](_0x1db58d+'\x20activations')),console[_0x4fcee2(0xb0)]('\x20\x20'+a34_0x452505[_0x4fcee2(0x84)]('+\x20'+_0x2eef1a[_0x4fcee2(0xc4)]+_0x4fcee2(0xbf))),console[_0x4fcee2(0xb0)]('\x20\x20'+a34_0x452505[_0x4fcee2(0x8d)]('~\x20'+_0x860f8[_0x4fcee2(0xc4)]+_0x4fcee2(0xbd))),console[_0x4fcee2(0xb0)]('\x20\x20'+a34_0x452505['dim']('=\x20'+_0x186b9f[_0x4fcee2(0xc4)]+_0x4fcee2(0xa1))),console[_0x4fcee2(0xb0)](_0x4fcee2(0xcb)+a34_0x452505['cyan'](_0x4020a9)+'\x0a');if(_0x860f8[_0x4fcee2(0xc4)]>0x0)for(const _0x53d871 of _0x860f8){console[_0x4fcee2(0xb0)]('\x0aChanges\x20to\x20\x27'+_0x53d871[_0x4fcee2(0xa8)]+'\x27:'),console[_0x4fcee2(0xb0)]('─'[_0x4fcee2(0x9b)](0x3c)),console['error'](_0x53d871[_0x4fcee2(0xbb)]),console['error']('─'['repeat'](0x3c));}if(_0x286815[_0x4fcee2(0xbe)])return console[_0x4fcee2(0xb0)](a34_0x452505[_0x4fcee2(0x8d)](_0x4fcee2(0x88))),0x0;if(_0x2eef1a[_0x4fcee2(0xc4)]===0x0&&_0x860f8['length']===0x0)return console[_0x4fcee2(0xb0)](a34_0x452505[_0x4fcee2(0x84)](_0x4fcee2(0xb1))),saveSessionContext({'parent_segment':_0x1b5915},_0x286815[_0x4fcee2(0xa3)]),console[_0x4fcee2(0xb0)](a34_0x452505['green'](_0x4fcee2(0x97)+a34_0x452505['dim'](_0x4fcee2(0x80))+_0x4fcee2(0xc5)+a34_0x452505[_0x4fcee2(0x9c)](_0x1b5915))),0x0;if(!_0x286815[_0x4fcee2(0xa9)]&&(_0x2eef1a[_0x4fcee2(0xc4)]>0x0||_0x860f8[_0x4fcee2(0xc4)]>0x0)){const _0x85cef3=await confirmKey(_0x4fcee2(0xca)+(_0x2eef1a[_0x4fcee2(0xc4)]+_0x860f8[_0x4fcee2(0xc4)])+_0x4fcee2(0xa4));if(!_0x85cef3)return console[_0x4fcee2(0xb0)]('Aborted.'),0x1;}for(const _0x336582 of _0x511eb0){if(_0x336582[_0x4fcee2(0xc2)]||_0x336582[_0x4fcee2(0x9f)]){const _0x5203dd=a34_0x2da008['dirname'](_0x336582[_0x4fcee2(0xb7)]);!existsSync(_0x5203dd)&&mkdirSync(_0x5203dd,{'recursive':!![]}),writeFileSync(_0x336582['absolutePath'],_0x336582['content'],_0x4fcee2(0x7f));}}return console[_0x4fcee2(0xb0)](a34_0x452505[_0x4fcee2(0x84)](_0x4fcee2(0xb3)+(_0x2eef1a[_0x4fcee2(0xc4)]+_0x860f8[_0x4fcee2(0xc4)])+'\x20files\x20to\x20'+_0x4020a9)),saveSessionContext({'parent_segment':_0x1b5915},_0x286815[_0x4fcee2(0xa3)]),console['error'](a34_0x452505[_0x4fcee2(0x84)](_0x4fcee2(0x97)+a34_0x452505[_0x4fcee2(0xa5)](_0x4fcee2(0x80))+_0x4fcee2(0xc5)+a34_0x452505[_0x4fcee2(0x9c)](_0x1b5915))),0x0;}}function buildFolderPathMap(_0x49a57a){const _0x138ae2=a34_0x2d11dc,_0x1e98d4=new Map(),_0x5227e2=new Map();for(const _0x1928b2 of _0x49a57a){_0x5227e2['set'](_0x1928b2['id'],_0x1928b2);}const _0x86c986=new Set();for(const _0x568f05 of _0x49a57a){!_0x568f05[_0x138ae2(0xc8)]&&_0x86c986['add'](_0x568f05['id']);}function _0x27160b(_0x141486){const _0x19cb13=_0x138ae2;if(_0x1e98d4[_0x19cb13(0xcc)](_0x141486['id']))return _0x1e98d4['get'](_0x141486['id']);if(_0x86c986[_0x19cb13(0xcc)](_0x141486['id']))return _0x1e98d4[_0x19cb13(0xb6)](_0x141486['id'],''),'';if(_0x141486[_0x19cb13(0xc8)]){const _0xcd43b=_0x5227e2[_0x19cb13(0xaa)](_0x141486[_0x19cb13(0xc8)]);if(_0xcd43b){const _0x2aae4b=_0x27160b(_0xcd43b),_0x5147e0=_0x2aae4b?_0x2aae4b+'/'+_0x141486[_0x19cb13(0x83)]:_0x141486[_0x19cb13(0x83)];return _0x1e98d4['set'](_0x141486['id'],_0x5147e0),_0x5147e0;}}const _0x4487ea=_0x141486[_0x19cb13(0x83)];return _0x1e98d4[_0x19cb13(0xb6)](_0x141486['id'],_0x4487ea),_0x4487ea;}for(const _0x42f0b5 of _0x49a57a){_0x27160b(_0x42f0b5);}return _0x1e98d4;}function a34_0x4c4a(_0xc1e622,_0x4e7e02){_0xc1e622=_0xc1e622-0x7f;const _0x3b851d=a34_0x3b85();let _0x4c4a39=_0x3b851d[_0xc1e622];return _0x4c4a39;}function getUniqueFileName(_0xc13b04,_0x15d716,_0x500538){const _0x3bd509=a34_0x2d11dc,_0x4c487e=_0xc13b04+':'+_0x15d716,_0x202508=_0x500538[_0x3bd509(0xaa)](_0x4c487e)||0x0;_0x500538['set'](_0x4c487e,_0x202508+0x1);if(_0x202508===0x0)return _0x15d716;return _0x15d716+'-'+_0x202508;}function prepareFile(_0x5e970d,_0x4e25f2,_0x5571c5){const _0x12e19b=a34_0x2d11dc,_0x1cc1f2=a34_0x2da008['relative'](_0x5571c5,_0x5e970d);if(existsSync(_0x5e970d)){const _0x526956=readFileSync(_0x5e970d,_0x12e19b(0x7f)),_0x2a8cb7=generateDiff(_0x526956,_0x4e25f2),_0x156b72=hasChanges(_0x2a8cb7);return{'relativePath':_0x1cc1f2,'absolutePath':_0x5e970d,'content':_0x4e25f2,'isNew':![],'hasChanges':_0x156b72,'diff':_0x156b72?formatDiffWithColors(_0x2a8cb7):undefined};}return{'relativePath':_0x1cc1f2,'absolutePath':_0x5e970d,'content':_0x4e25f2,'isNew':!![],'hasChanges':![]};}
|
|
1
|
+
const a34_0x3b65a9=a34_0x2456;(function(_0x50e640,_0x1b21b0){const _0x1707d6=a34_0x2456,_0x3b9e4c=_0x50e640();while(!![]){try{const _0x20fd94=-parseInt(_0x1707d6(0x7f))/0x1+-parseInt(_0x1707d6(0xbb))/0x2*(-parseInt(_0x1707d6(0x6f))/0x3)+parseInt(_0x1707d6(0xa5))/0x4*(parseInt(_0x1707d6(0x76))/0x5)+parseInt(_0x1707d6(0xa8))/0x6*(-parseInt(_0x1707d6(0xbc))/0x7)+-parseInt(_0x1707d6(0x89))/0x8*(-parseInt(_0x1707d6(0x75))/0x9)+-parseInt(_0x1707d6(0x9a))/0xa*(-parseInt(_0x1707d6(0xab))/0xb)+parseInt(_0x1707d6(0x73))/0xc*(parseInt(_0x1707d6(0xa3))/0xd);if(_0x20fd94===_0x1b21b0)break;else _0x3b9e4c['push'](_0x3b9e4c['shift']());}catch(_0x3d27cd){_0x3b9e4c['push'](_0x3b9e4c['shift']());}}}(a34_0x25cb,0x81553));import{BaseCommand}from'./command.js';import{withSpinner}from'../utils/spinner.js';function a34_0x25cb(){const _0x306f0d=['yellow','green','\x20\x20Target:\x20','✔\x20Pulled\x20','has','utf-8','Usage:\x20tdx\x20sg\x20pull\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Pull\x20all\x20segments\x20(requires\x20context\x20or\x20tdx.json)','attributes','26bHSyEb','user','3151348cbEAVz','data','\x20files\x20to\x20','620754flAsWN','Found\x20existing\x20tdx.json\x20at:\x20','Fetching\x20users\x20for\x20email\x20resolution...','11oUhLvU','parent_segment','dirname','\x0aPull\x20summary\x20for\x20\x27','length','verbose','Resolved\x20parent\x20name:\x20','set','Fetching\x20activations...','\x20files?','absolutePath','\x0aChanges\x20to\x20\x27','dim','red','values','repeat','202lShHdY','49mFlqtQ','segment','cyan','tdx.json','join','Using\x20parent\x20segment:\x20','listFolders','\x27...','Aborted.','yes','listActivations','12309aBkeXe','site','get','resolveParentId','2334504YMnfcy','✔\x20Context\x20set:\x20','1107BgZQgH','5zixSgR','Fetching\x20connections\x20for\x20name\x20resolution...','listSegments','\x20new\x20files','reduce','Write\x20','execute','✔\x20All\x20files\x20are\x20up\x20to\x20date','Pull\x20child\x20segments\x20to\x20YAML\x20files','967266oBVofI','Tip:\x20Run\x20`tdx\x20sg\x20pull\x20<parent_name>`\x20first\x20to\x20create\x20the\x20folder\x20structure','description','getParent','then','all','filter','parentFolderId','buildIdToEmailMap','name','33544igOFFE','\x20activations','\x20=\x20','add','error','Fetching\x20parent\x20segment\x20info...','from','Fetching\x20segments...','hasChanges','\x20changed\x20files','diff','Fetching\x20folders...','isNew','parentSegment','segmentFolderId','\x20segments','segment:pull','1141630AvVYkz'];a34_0x25cb=function(){return _0x306f0d;};return a34_0x25cb();}import{generateDiff,formatDiffWithColors,hasChanges}from'../utils/diff.js';import{confirmKey}from'../utils/prompt.js';import{batchAsync}from'../utils/async.js';import{getSegmentRootDir,createTdxConfigContent,findTdxConfigPath,loadTdxConfig}from'../utils/tdx-config.js';import{saveSessionContext}from'../core/session.js';function a34_0x2456(_0x52c06e,_0x43bef9){_0x52c06e=_0x52c06e-0x69;const _0x25cb34=a34_0x25cb();let _0x24565a=_0x25cb34[_0x52c06e];return _0x24565a;}import{segmentWithActivationsToYaml,segmentToYamlString}from'../sdk/segment/child-segment-yaml.js';import a34_0x2a0149 from'chalk';import{existsSync,mkdirSync,readFileSync,writeFileSync,statSync}from'fs';import a34_0x2c162a from'path';import{sanitizeFileName}from'../utils/string-utils.js';export class SegmentPullCommand extends BaseCommand{[a34_0x3b65a9(0x88)]=a34_0x3b65a9(0x99);[a34_0x3b65a9(0x81)]=a34_0x3b65a9(0x7e);async[a34_0x3b65a9(0x7c)](_0x28612a){const _0x1a6909=a34_0x3b65a9,{options:_0x50e448,args:_0x524776,tdx:_0x5ad451}=_0x28612a,_0x14e67b=_0x50e448,_0xb3c61b=_0x50e448[_0x1a6909(0x96)],_0x493726=_0x524776[0x0],_0x3289cc=findTdxConfigPath();let _0x12e20b,_0x56dde8;if(!_0x493726&&_0x3289cc){const _0x5024c5=loadTdxConfig(_0x3289cc);_0x12e20b=_0x5024c5[_0x1a6909(0xac)],_0x56dde8=a34_0x2c162a[_0x1a6909(0xad)](_0x3289cc),_0x14e67b['verbose']&&(console[_0x1a6909(0x8d)](_0x1a6909(0xa9)+_0x3289cc),console[_0x1a6909(0x8d)](_0x1a6909(0x69)+_0x12e20b));}else{if(_0x493726){if(existsSync(_0x493726)&&statSync(_0x493726)['isDirectory']()){const _0x3e7ac3=findTdxConfigPath(_0x493726);if(_0x3e7ac3){const _0x4b0bb6=loadTdxConfig(_0x3e7ac3);_0x12e20b=_0x4b0bb6[_0x1a6909(0xac)],_0x56dde8=a34_0x2c162a['dirname'](_0x3e7ac3),_0x14e67b[_0x1a6909(0xb0)]&&(console['error']('Found\x20tdx.json\x20at:\x20'+_0x3e7ac3),console[_0x1a6909(0x8d)](_0x1a6909(0x69)+_0x12e20b));}else return console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0xb8)]('Error:\x20No\x20tdx.json\x20found\x20in\x20or\x20above:\x20'+_0x493726+'\x0a')),console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0xbe)](_0x1a6909(0x80))),0x1;}else _0x12e20b=_0x493726;}else _0x12e20b=_0xb3c61b;}if(!_0x12e20b)return console[_0x1a6909(0x8d)](a34_0x2a0149['yellow']('parent_segment\x20is\x20not\x20set.\x20Use\x20`tdx\x20sg\x20use\x20<parent_name>`\x20to\x20set\x20it.\x0a')),console[_0x1a6909(0x8d)](_0x1a6909(0xa1)),console['error']('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20pull\x20<parent_name>\x20\x20\x20\x20\x20\x20#\x20Pull\x20all\x20segments\x20from\x20parent'),console[_0x1a6909(0x8d)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20pull\x20<file_path>\x20\x20\x20\x20\x20\x20\x20\x20#\x20Pull\x20specific\x20segment\x20file'),0x1;_0x14e67b['verbose']&&(console[_0x1a6909(0x8d)]('Site:\x20'+_0x14e67b[_0x1a6909(0x70)]),console[_0x1a6909(0x8d)]('Parent\x20segment:\x20'+_0x12e20b));const _0x2e0543=await withSpinner('Resolving\x20parent\x20segment\x20\x27'+_0x12e20b+_0x1a6909(0x6b),()=>_0x5ad451[_0x1a6909(0xbd)][_0x1a6909(0x72)](_0x12e20b),{'verbose':_0x14e67b['verbose']}),_0x486575=_0x2e0543[_0x1a6909(0xa6)],_0x48a853=await withSpinner(_0x1a6909(0x8e),()=>_0x5ad451['segment'][_0x1a6909(0x82)](_0x486575),{'verbose':_0x14e67b['verbose']}),_0x93bef4=_0x48a853['data'][_0x1a6909(0xa2)][_0x1a6909(0x88)];_0x14e67b[_0x1a6909(0xb0)]&&console[_0x1a6909(0x8d)](_0x1a6909(0xb1)+_0x93bef4);const [_0x561130,_0xa188d0]=await Promise[_0x1a6909(0x84)]([withSpinner(_0x1a6909(0x90),()=>_0x5ad451['segment'][_0x1a6909(0x78)](_0x486575),{'verbose':_0x14e67b[_0x1a6909(0xb0)]}),withSpinner(_0x1a6909(0x94),()=>_0x5ad451[_0x1a6909(0xbd)][_0x1a6909(0x6a)](_0x486575),{'verbose':_0x14e67b['verbose']})]),_0x3b4c95=_0x561130['data'],_0x84144c=_0xa188d0[_0x1a6909(0xa6)];if(_0x3b4c95['length']===0x0)return console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0x9b)]('No\x20segments\x20found\x20in\x20parent\x20segment\x20\x27'+_0x93bef4+'\x27')),0x0;const _0x269ab8=buildFolderPathMap(_0x84144c),_0x47deba=_0x56dde8||getSegmentRootDir(sanitizeFileName(_0x12e20b)),_0x58eb24=new Map();await withSpinner(_0x1a6909(0xb3),async()=>{await batchAsync(_0x3b4c95,async _0x2ef2c6=>{const _0x4f3981=a34_0x2456,_0x3f628b=await _0x5ad451[_0x4f3981(0xbd)][_0x4f3981(0x6e)](_0x486575,_0x2ef2c6['id']);_0x58eb24['set'](_0x2ef2c6['id'],_0x3f628b);});},{'verbose':_0x14e67b[_0x1a6909(0xb0)]});const _0x556e2f=await withSpinner(_0x1a6909(0xaa),()=>_0x5ad451[_0x1a6909(0xa4)][_0x1a6909(0x87)](),{'verbose':_0x14e67b[_0x1a6909(0xb0)]})[_0x1a6909(0x83)](_0x11554e=>_0x11554e['data']),_0x3e30d8=await withSpinner(_0x1a6909(0x77),()=>_0x5ad451['connection']['buildIdToNameMap'](),{'verbose':_0x14e67b[_0x1a6909(0xb0)]})[_0x1a6909(0x83)](_0x31a00f=>_0x31a00f['data']),_0x532402=[],_0x4f98a8=a34_0x2c162a[_0x1a6909(0xc0)](_0x47deba,_0x1a6909(0xbf)),_0xe85cf0=createTdxConfigContent(_0x93bef4);_0x532402['push'](prepareFile(_0x4f98a8,_0xe85cf0,_0x47deba));const _0x1faca5=new Map();for(const _0x2e7f0e of _0x3b4c95){const _0x3a2589=_0x2e7f0e[_0x1a6909(0x97)]?_0x269ab8[_0x1a6909(0x71)](_0x2e7f0e[_0x1a6909(0x97)])||'':'',_0x75e6aa=_0x58eb24[_0x1a6909(0x71)](_0x2e7f0e['id'])||[],_0x2f4417=segmentWithActivationsToYaml(_0x2e7f0e,_0x75e6aa,undefined,_0x556e2f,_0x3e30d8),_0x22ebd2=_0x3a2589?a34_0x2c162a[_0x1a6909(0xc0)](_0x47deba,_0x3a2589):_0x47deba,_0x568166=sanitizeFileName(_0x2e7f0e[_0x1a6909(0x88)]),_0x5b7d23=getUniqueFileName(_0x22ebd2,_0x568166,_0x1faca5),_0x2a708f=a34_0x2c162a[_0x1a6909(0xc0)](_0x22ebd2,_0x5b7d23+'.yml'),_0x5162c0=segmentToYamlString(_0x2f4417);_0x532402['push'](prepareFile(_0x2a708f,_0x5162c0,_0x47deba));}const _0x559cdf=Array[_0x1a6909(0x8f)](_0x58eb24[_0x1a6909(0xb9)]())[_0x1a6909(0x7a)]((_0x1cdd68,_0x541013)=>_0x1cdd68+_0x541013[_0x1a6909(0xaf)],0x0),_0x458660=_0x532402[_0x1a6909(0x85)](_0x48966b=>_0x48966b[_0x1a6909(0x95)]),_0x120fc9=_0x532402[_0x1a6909(0x85)](_0x3f9cfc=>!_0x3f9cfc[_0x1a6909(0x95)]&&_0x3f9cfc['hasChanges']),_0x227545=_0x532402['filter'](_0x1bfa72=>!_0x1bfa72[_0x1a6909(0x95)]&&!_0x1bfa72[_0x1a6909(0x91)]);console['error'](_0x1a6909(0xae)+_0x93bef4+'\x27:'),console['error']('\x20\x20'+a34_0x2a0149['cyan'](_0x3b4c95[_0x1a6909(0xaf)]+_0x1a6909(0x98))+'\x20with\x20'+a34_0x2a0149[_0x1a6909(0xbe)](_0x559cdf+_0x1a6909(0x8a))),console[_0x1a6909(0x8d)]('\x20\x20'+a34_0x2a0149['green']('+\x20'+_0x458660[_0x1a6909(0xaf)]+_0x1a6909(0x79))),console[_0x1a6909(0x8d)]('\x20\x20'+a34_0x2a0149[_0x1a6909(0x9b)]('~\x20'+_0x120fc9[_0x1a6909(0xaf)]+_0x1a6909(0x92))),console[_0x1a6909(0x8d)]('\x20\x20'+a34_0x2a0149['dim']('=\x20'+_0x227545[_0x1a6909(0xaf)]+'\x20unchanged\x20files')),console[_0x1a6909(0x8d)](_0x1a6909(0x9d)+a34_0x2a0149[_0x1a6909(0xbe)](_0x47deba)+'\x0a');if(_0x120fc9[_0x1a6909(0xaf)]>0x0)for(const _0x50247c of _0x120fc9){console[_0x1a6909(0x8d)](_0x1a6909(0xb6)+_0x50247c['relativePath']+'\x27:'),console[_0x1a6909(0x8d)]('─'[_0x1a6909(0xba)](0x3c)),console[_0x1a6909(0x8d)](_0x50247c[_0x1a6909(0x93)]),console['error']('─'['repeat'](0x3c));}if(_0x14e67b['dryRun'])return console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0x9b)]('\x0a[Dry\x20run]\x20No\x20files\x20were\x20written')),0x0;if(_0x458660[_0x1a6909(0xaf)]===0x0&&_0x120fc9[_0x1a6909(0xaf)]===0x0)return console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0x9c)](_0x1a6909(0x7d))),saveSessionContext({'parent_segment':_0x93bef4},_0x14e67b['session']),console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0x9c)](_0x1a6909(0x74)+a34_0x2a0149[_0x1a6909(0xb7)](_0x1a6909(0xac))+_0x1a6909(0x8b)+a34_0x2a0149['cyan'](_0x93bef4))),0x0;if(!_0x14e67b[_0x1a6909(0x6d)]&&(_0x458660[_0x1a6909(0xaf)]>0x0||_0x120fc9['length']>0x0)){const _0x24318d=await confirmKey(_0x1a6909(0x7b)+(_0x458660[_0x1a6909(0xaf)]+_0x120fc9[_0x1a6909(0xaf)])+_0x1a6909(0xb4));if(!_0x24318d)return console['error'](_0x1a6909(0x6c)),0x1;}for(const _0x44064b of _0x532402){if(_0x44064b[_0x1a6909(0x95)]||_0x44064b[_0x1a6909(0x91)]){const _0xad9ebf=a34_0x2c162a[_0x1a6909(0xad)](_0x44064b[_0x1a6909(0xb5)]);!existsSync(_0xad9ebf)&&mkdirSync(_0xad9ebf,{'recursive':!![]}),writeFileSync(_0x44064b[_0x1a6909(0xb5)],_0x44064b['content'],_0x1a6909(0xa0));}}return console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0x9c)](_0x1a6909(0x9e)+(_0x458660['length']+_0x120fc9[_0x1a6909(0xaf)])+_0x1a6909(0xa7)+_0x47deba)),saveSessionContext({'parent_segment':_0x93bef4},_0x14e67b['session']),console[_0x1a6909(0x8d)](a34_0x2a0149[_0x1a6909(0x9c)](_0x1a6909(0x74)+a34_0x2a0149[_0x1a6909(0xb7)](_0x1a6909(0xac))+_0x1a6909(0x8b)+a34_0x2a0149[_0x1a6909(0xbe)](_0x93bef4))),0x0;}}function buildFolderPathMap(_0x1deb03){const _0x139767=a34_0x3b65a9,_0x2cc72c=new Map(),_0x4ba515=new Map();for(const _0x5ca0fa of _0x1deb03){_0x4ba515[_0x139767(0xb2)](_0x5ca0fa['id'],_0x5ca0fa);}const _0x479413=new Set();for(const _0x5cbd of _0x1deb03){!_0x5cbd['parentFolderId']&&_0x479413[_0x139767(0x8c)](_0x5cbd['id']);}function _0x114be2(_0x119dc8){const _0x4c854c=_0x139767;if(_0x2cc72c[_0x4c854c(0x9f)](_0x119dc8['id']))return _0x2cc72c[_0x4c854c(0x71)](_0x119dc8['id']);if(_0x479413[_0x4c854c(0x9f)](_0x119dc8['id']))return _0x2cc72c[_0x4c854c(0xb2)](_0x119dc8['id'],''),'';if(_0x119dc8[_0x4c854c(0x86)]){const _0x59789c=_0x4ba515[_0x4c854c(0x71)](_0x119dc8[_0x4c854c(0x86)]);if(_0x59789c){const _0x23becf=_0x114be2(_0x59789c),_0x54bbf1=_0x23becf?_0x23becf+'/'+_0x119dc8['name']:_0x119dc8[_0x4c854c(0x88)];return _0x2cc72c['set'](_0x119dc8['id'],_0x54bbf1),_0x54bbf1;}}const _0x3f0836=_0x119dc8['name'];return _0x2cc72c[_0x4c854c(0xb2)](_0x119dc8['id'],_0x3f0836),_0x3f0836;}for(const _0x1e7ff3 of _0x1deb03){_0x114be2(_0x1e7ff3);}return _0x2cc72c;}function getUniqueFileName(_0x27bfb4,_0x35b25f,_0x31fb3e){const _0x431f18=a34_0x3b65a9,_0x134ed6=_0x27bfb4+':'+_0x35b25f,_0x163f6c=_0x31fb3e[_0x431f18(0x71)](_0x134ed6)||0x0;_0x31fb3e[_0x431f18(0xb2)](_0x134ed6,_0x163f6c+0x1);if(_0x163f6c===0x0)return _0x35b25f;return _0x35b25f+'-'+_0x163f6c;}function prepareFile(_0x48e4ef,_0x28a978,_0x402133){const _0x10ba22=a34_0x3b65a9,_0x504bb4=a34_0x2c162a['relative'](_0x402133,_0x48e4ef);if(existsSync(_0x48e4ef)){const _0x44a8cf=readFileSync(_0x48e4ef,_0x10ba22(0xa0)),_0x348020=generateDiff(_0x44a8cf,_0x28a978),_0x42f0d2=hasChanges(_0x348020);return{'relativePath':_0x504bb4,'absolutePath':_0x48e4ef,'content':_0x28a978,'isNew':![],'hasChanges':_0x42f0d2,'diff':_0x42f0d2?formatDiffWithColors(_0x348020):undefined};}return{'relativePath':_0x504bb4,'absolutePath':_0x48e4ef,'content':_0x28a978,'isNew':!![],'hasChanges':![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a35_0x5a37db=a35_0x1302;(function(_0x172892,_0x64418b){const _0x45450a=a35_0x1302,_0x4f1789=_0x172892();while(!![]){try{const _0x2aeb75=parseInt(_0x45450a(0x134))/0x1*(-parseInt(_0x45450a(0x124))/0x2)+parseInt(_0x45450a(0x15c))/0x3+-parseInt(_0x45450a(0x135))/0x4+-parseInt(_0x45450a(0x159))/0x5*(parseInt(_0x45450a(0x188))/0x6)+parseInt(_0x45450a(0x162))/0x7*(-parseInt(_0x45450a(0x140))/0x8)+-parseInt(_0x45450a(0x119))/0x9+-parseInt(_0x45450a(0x154))/0xa*(-parseInt(_0x45450a(0x18a))/0xb);if(_0x2aeb75===_0x64418b)break;else _0x4f1789['push'](_0x4f1789['shift']());}catch(_0x57b6d9){_0x4f1789['push'](_0x4f1789['shift']());}}}(a35_0x8251,0xa627d));import{BaseCommand}from'./command.js';import{SDKError,ErrorCode,isHttp400Error,getErrorMessage}from'../sdk/errors.js';import{withSpinner}from'../utils/spinner.js';import{generateDiff,formatDiffWithColors,hasChanges}from'../utils/diff.js';import{confirmKey}from'../utils/prompt.js';import{batchAsync}from'../utils/async.js';import{getSegmentRootDir,findTdxConfig}from'../utils/tdx-config.js';import{segmentToYamlString,segmentWithActivationsToYaml,parseSegmentYamlFile,normalizeChildSegmentYaml,yamlToCreateRequest,yamlToUpdateRequest,yamlActivationToCreateRequest,yamlActivationToUpdateRequest,activationToYaml}from'../sdk/segment/child-segment-yaml.js';import a35_0x28e9b8 from'chalk';import{existsSync,readFileSync,statSync,readdirSync}from'fs';import a35_0x55cd94 from'path';import*as a35_0x45d4c3 from'yaml';import{sanitizeFileName}from'../utils/string-utils.js';function tryFindTdxConfig(_0x5dd658){try{return findTdxConfig(_0x5dd658);}catch{return null;}}function a35_0x1302(_0x284156,_0x2f8d7){_0x284156=_0x284156-0x10a;const _0x8251b7=a35_0x8251();let _0x1302ec=_0x8251b7[_0x284156];return _0x1302ec;}function resolveTDFolderPath(_0x22a55d,_0x57f96d,_0x3eeb90){if(!_0x57f96d)return _0x22a55d;return _0x22a55d?_0x3eeb90+'/'+_0x22a55d:_0x3eeb90;}export class SegmentPushCommand extends BaseCommand{[a35_0x5a37db(0x17c)]=a35_0x5a37db(0x125);['description']=a35_0x5a37db(0x17e);async[a35_0x5a37db(0x130)](_0x46a82e){const _0x5e1d94=a35_0x5a37db,{options:_0x350805,args:_0x13d98f,tdx:_0x893df7}=_0x46a82e,_0x1ebb5f=_0x350805,_0x51cab5=_0x350805[_0x5e1d94(0x11b)],_0x80a269=_0x13d98f[0x0];let _0x4b092f,_0x8b6035,_0x1040ba,_0x702f31;if(_0x80a269){if(existsSync(_0x80a269)&&statSync(_0x80a269)[_0x5e1d94(0x191)]()){const _0x30593f=tryFindTdxConfig(_0x80a269);if(_0x30593f)_0x4b092f=_0x30593f[_0x5e1d94(0x12d)][_0x5e1d94(0x113)],_0x8b6035=_0x80a269,_0x1040ba=_0x30593f[_0x5e1d94(0x10a)];else return console['error'](a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x152)+_0x80a269+'\x0a')),console['error'](a35_0x28e9b8['cyan'](_0x5e1d94(0x17a))),0x1;}else{if(existsSync(_0x80a269)&&statSync(_0x80a269)[_0x5e1d94(0x182)]()){const _0x5f10f8=a35_0x55cd94[_0x5e1d94(0x145)](_0x80a269),_0xb67d65=tryFindTdxConfig(_0x5f10f8);if(_0xb67d65)_0x4b092f=_0xb67d65[_0x5e1d94(0x12d)][_0x5e1d94(0x113)],_0x1040ba=_0xb67d65[_0x5e1d94(0x10a)],_0x8b6035=_0xb67d65['configDir'],_0x702f31=a35_0x55cd94['resolve'](_0x80a269);else return console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x152)+_0x5f10f8+'\x0a')),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x17d)](_0x5e1d94(0x17a))),0x1;}else _0x4b092f=_0x80a269;}}else{const _0x48355d=tryFindTdxConfig(process['cwd']());_0x48355d?(_0x4b092f=_0x48355d[_0x5e1d94(0x12d)]['parent_segment'],_0x8b6035=process['cwd'](),_0x1040ba=_0x48355d[_0x5e1d94(0x10a)]):_0x4b092f=_0x51cab5;}if(!_0x4b092f)return console[_0x5e1d94(0x127)](a35_0x28e9b8['yellow'](_0x5e1d94(0x158))),console[_0x5e1d94(0x127)](_0x5e1d94(0x18f)),console[_0x5e1d94(0x127)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20push\x20<parent_name>\x20\x20\x20\x20\x20\x20#\x20Push\x20all\x20segments\x20to\x20parent'),console[_0x5e1d94(0x127)](_0x5e1d94(0x116)),0x1;const _0x4f0d91=_0x8b6035||getSegmentRootDir(sanitizeFileName(_0x4b092f)),_0x10e7b3=_0x1040ba||_0x4f0d91,_0x15a04b=a35_0x55cd94[_0x5e1d94(0x15b)](_0x10e7b3,_0x4f0d91),_0x859ed2=_0x15a04b!==''&&_0x15a04b!=='.';if(!existsSync(_0x4f0d91))return console[_0x5e1d94(0x127)](a35_0x28e9b8['red'](_0x5e1d94(0x16e)+_0x4f0d91+'\x0a')),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x17d)](_0x5e1d94(0x17a))),0x1;_0x1ebb5f[_0x5e1d94(0x129)]&&(console[_0x5e1d94(0x127)]('Site:\x20'+_0x1ebb5f[_0x5e1d94(0x136)]),console[_0x5e1d94(0x127)](_0x5e1d94(0x11e)+_0x4b092f),console[_0x5e1d94(0x127)](_0x5e1d94(0x185)+_0x4f0d91),_0x859ed2&&console[_0x5e1d94(0x127)](_0x5e1d94(0x170)+_0x15a04b));const _0x359e95=await withSpinner('Resolving\x20parent\x20segment\x20\x27'+_0x4b092f+'\x27...',()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x132)](_0x4b092f),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]}),_0x5267ba=_0x359e95['data'],[_0x3fbe50,_0x1cee9f,_0x3763a1]=await Promise[_0x5e1d94(0x15d)]([withSpinner(_0x5e1d94(0x164),()=>_0x893df7['segment']['listSegments'](_0x5267ba),{'verbose':_0x1ebb5f['verbose']}),withSpinner(_0x5e1d94(0x139),()=>_0x893df7['segment']['listFolders'](_0x5267ba),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]}),withSpinner('Fetching\x20users\x20for\x20email\x20resolution...',()=>_0x893df7['user']['buildUserMaps'](),{'verbose':_0x1ebb5f['verbose']})[_0x5e1d94(0x16a)](_0xcf9384=>_0xcf9384['data'])]),_0x3ee7d0=_0x3fbe50[_0x5e1d94(0x176)],_0x3c9dc5=_0x1cee9f[_0x5e1d94(0x176)],{emailToId:_0x569917,idToEmail:_0xdf8787}=_0x3763a1,[_0x4af19a,_0x53182f]=await withSpinner(_0x5e1d94(0x115),async()=>{const _0x209467=_0x5e1d94,[_0x238433,_0x54dab6]=await Promise['all']([_0x893df7['connection'][_0x209467(0x156)](),_0x893df7['connection'][_0x209467(0x198)]()]);return[_0x238433,_0x54dab6];},{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]})[_0x5e1d94(0x16a)](_0x263776=>_0x263776[_0x5e1d94(0x176)]),_0x1717de=buildFolderPathToIdMap(_0x3c9dc5),_0x1a650d=new Map();for(const [_0x381129,_0x39add8]of _0x1717de[_0x5e1d94(0x17b)]()){_0x1a650d[_0x5e1d94(0x160)](_0x39add8,_0x381129);}const _0x560f8e=new Map();for(const _0xafe43a of _0x3ee7d0){const _0x834b61=_0xafe43a[_0x5e1d94(0x12c)]?_0x1a650d[_0x5e1d94(0x157)](_0xafe43a[_0x5e1d94(0x12c)][_0x5e1d94(0x179)]())||'':'',_0x2f7f7b=_0x834b61+':'+_0xafe43a[_0x5e1d94(0x17c)];_0x560f8e['set'](_0x2f7f7b,_0xafe43a);}let _0x1195a4;if(_0x702f31){if(!_0x702f31[_0x5e1d94(0x180)](_0x5e1d94(0x153))&&!_0x702f31[_0x5e1d94(0x180)](_0x5e1d94(0x181)))return console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x155)+_0x702f31+'\x0a')),0x1;_0x1195a4=[_0x702f31];}else _0x1195a4=findYamlFiles(_0x4f0d91);if(_0x1195a4[_0x5e1d94(0x122)]===0x0)return console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x165)+_0x4f0d91+'\x0a')),console['error'](a35_0x28e9b8[_0x5e1d94(0x17d)]('Tip:\x20Run\x20`tdx\x20sg\x20pull`\x20first\x20to\x20create\x20segment\x20files')),0x1;const _0xc5ac4d=[];for(const _0x738b67 of _0x1195a4){const _0x34633d=a35_0x55cd94[_0x5e1d94(0x15b)](_0x4f0d91,a35_0x55cd94[_0x5e1d94(0x145)](_0x738b67)),_0x47b40c=_0x34633d==='.'?'':_0x34633d,_0x24c335=readFileSync(_0x738b67,_0x5e1d94(0x128));try{const _0x9a35c0=parseSegmentYamlFile(_0x24c335),_0x55fc1d=normalizeChildSegmentYaml(_0x9a35c0);_0xc5ac4d[_0x5e1d94(0x166)]({'yamlConfig':_0x55fc1d,'folderPath':_0x47b40c,'sourcePath':_0x738b67});}catch(_0x5dfefe){return console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x12a)+_0x738b67+':\x20'+(_0x5dfefe instanceof Error?_0x5dfefe[_0x5e1d94(0x13e)]:_0x5dfefe))),0x1;}}if(_0xc5ac4d[_0x5e1d94(0x122)]===0x0)return console['error'](a35_0x28e9b8[_0x5e1d94(0x14c)](_0x5e1d94(0x177))),0x0;const _0x206f23=new Map();_0x3ee7d0[_0x5e1d94(0x122)]>0x0&&await withSpinner('Fetching\x20existing\x20activations...',async()=>{await batchAsync(_0x3ee7d0,async _0x39d6ae=>{const _0x45add7=a35_0x1302,_0x20b1b1=await _0x893df7[_0x45add7(0x18d)][_0x45add7(0x133)](_0x5267ba,_0x39d6ae['id']);_0x206f23['set'](_0x39d6ae['id'],_0x20b1b1);});},{'verbose':_0x1ebb5f['verbose']});const _0x475da2=[],_0x3cede8=new Set();for(const {yamlConfig:_0x14a1cb,folderPath:_0x1c8ab5,sourcePath:_0x2f6eaa}of _0xc5ac4d){const _0x351798=resolveTDFolderPath(_0x1c8ab5,_0x859ed2,_0x15a04b),_0x1188cb=_0x351798+':'+_0x14a1cb['name'],_0x1372e1=_0x560f8e['get'](_0x1188cb),_0x2e3b9e=_0x1372e1?_0x206f23[_0x5e1d94(0x157)](_0x1372e1['id'])||[]:[];if(_0x351798&&!_0x1717de['has'](_0x351798)){const _0x19afeb=_0x351798[_0x5e1d94(0x189)]('/');let _0x3abc0e='';for(const _0x25da94 of _0x19afeb){_0x3abc0e=_0x3abc0e?_0x3abc0e+'/'+_0x25da94:_0x25da94,!_0x1717de[_0x5e1d94(0x187)](_0x3abc0e)&&_0x3cede8['add'](_0x3abc0e);}}const _0xbef874=calculateActivationActions(_0x14a1cb[_0x5e1d94(0x16d)]||[],_0x2e3b9e,_0xdf8787,_0x53182f),_0x947025=segmentToYamlString(_0x14a1cb);let _0x28915f,_0x2eb434=![],_0x2b40c9;if(_0x1372e1){const _0x10364a=segmentWithActivationsToYaml(_0x1372e1,_0x2e3b9e,undefined,_0xdf8787,_0x53182f),_0x58f707=segmentToYamlString(_0x10364a);_0x28915f=generateDiff(_0x58f707,_0x947025),_0x2eb434=hasChanges(_0x28915f),_0x2eb434&&(_0x2b40c9=formatDiffWithColors(_0x28915f));}else _0x28915f=generateDiff('',_0x947025),_0x2b40c9=formatDiffWithColors(_0x28915f);_0x475da2['push']({'relativePath':_0x14a1cb[_0x5e1d94(0x17c)],'absolutePath':_0x2f6eaa,'yamlConfig':_0x14a1cb,'folderPath':_0x351798,'existingSegment':_0x1372e1,'existingActivations':_0x2e3b9e,'isNew':!_0x1372e1,'hasChanges':_0x2eb434,'diff':_0x2b40c9,'activationActions':_0xbef874});}let _0x3d4751=[];if(!_0x702f31){const _0x27df01=new Set();for(const {yamlConfig:_0x5eb6d6,folderPath:_0x4a38d5}of _0xc5ac4d){const _0x57ef1b=resolveTDFolderPath(_0x4a38d5,_0x859ed2,_0x15a04b);_0x27df01['add'](_0x57ef1b+':'+_0x5eb6d6[_0x5e1d94(0x17c)]);}_0x3d4751=_0x3ee7d0[_0x5e1d94(0x143)](_0x585b46=>{const _0x5a01fd=_0x5e1d94,_0x21407b=_0x585b46[_0x5a01fd(0x12c)]?_0x1a650d[_0x5a01fd(0x157)](_0x585b46[_0x5a01fd(0x12c)][_0x5a01fd(0x179)]())||'':'',_0xc39c6=_0x21407b+':'+_0x585b46[_0x5a01fd(0x17c)];if(_0x27df01['has'](_0xc39c6))return![];if(_0x859ed2)return _0x21407b===_0x15a04b||_0x21407b['startsWith'](_0x15a04b+'/');return!![];});}const _0x265980=_0x475da2[_0x5e1d94(0x143)](_0x3bc759=>_0x3bc759['isNew']),_0x567f20=_0x475da2[_0x5e1d94(0x143)](_0xf39102=>!_0xf39102[_0x5e1d94(0x14e)]&&_0xf39102[_0x5e1d94(0x10b)]),_0x4fcdd7=_0x475da2['filter'](_0x442235=>!_0x442235[_0x5e1d94(0x14e)]&&!_0x442235[_0x5e1d94(0x10b)]),_0x11f7d5=Array[_0x5e1d94(0x11c)](_0x3cede8)[_0x5e1d94(0x150)](),_0x3660f4=_0x1ebb5f[_0x5e1d94(0x138)]?_0x3d4751:[],_0x203e46=_0x475da2[_0x5e1d94(0x11d)](_0x4784e5=>_0x4784e5[_0x5e1d94(0x110)]),_0x117983=_0x203e46[_0x5e1d94(0x143)](_0x4e8210=>_0x4e8210['type']==='create'),_0x38317b=_0x203e46[_0x5e1d94(0x143)](_0x3faa9b=>_0x3faa9b[_0x5e1d94(0x190)]===_0x5e1d94(0x161)),_0x359c22=_0x203e46[_0x5e1d94(0x143)](_0x4e5584=>_0x4e5584['type']==='delete');console[_0x5e1d94(0x127)](_0x5e1d94(0x174)+_0x4b092f+'\x27:');_0x11f7d5[_0x5e1d94(0x122)]>0x0&&console[_0x5e1d94(0x127)]('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x163)]('📁\x20'+_0x11f7d5[_0x5e1d94(0x122)]+_0x5e1d94(0x146)));console['error']('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x16c)]('+\x20'+_0x265980['length']+_0x5e1d94(0x149))),console[_0x5e1d94(0x127)]('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x14c)]('~\x20'+_0x567f20['length']+_0x5e1d94(0x183)));if(_0x3660f4[_0x5e1d94(0x122)]>0x0)console['error']('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x12e)]('-\x20'+_0x3660f4[_0x5e1d94(0x122)]+'\x20segments\x20to\x20delete'));else _0x3d4751['length']>0x0&&!_0x1ebb5f[_0x5e1d94(0x138)]&&console['error']('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x195)]('\x20\x20'+_0x3d4751[_0x5e1d94(0x122)]+_0x5e1d94(0x15a)));console[_0x5e1d94(0x127)]('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x195)]('=\x20'+_0x4fcdd7[_0x5e1d94(0x122)]+'\x20unchanged\x20segments'));_0x203e46[_0x5e1d94(0x122)]>0x0&&(console[_0x5e1d94(0x127)](''),console['error']('\x20\x20Activations:'),_0x117983['length']>0x0&&console[_0x5e1d94(0x127)]('\x20\x20\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x16c)]('+\x20'+_0x117983['length']+_0x5e1d94(0x168))),_0x38317b[_0x5e1d94(0x122)]>0x0&&console['error'](_0x5e1d94(0x117)+a35_0x28e9b8[_0x5e1d94(0x14c)]('~\x20'+_0x38317b[_0x5e1d94(0x122)]+_0x5e1d94(0x14b))),_0x359c22[_0x5e1d94(0x122)]>0x0&&console[_0x5e1d94(0x127)]('\x20\x20\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x12e)]('-\x20'+_0x359c22[_0x5e1d94(0x122)]+_0x5e1d94(0x137))));console[_0x5e1d94(0x127)](_0x5e1d94(0x171)+a35_0x28e9b8[_0x5e1d94(0x17d)](_0x4f0d91)+'\x0a');if(_0x11f7d5[_0x5e1d94(0x122)]>0x0){console[_0x5e1d94(0x127)](_0x5e1d94(0x13a));for(const _0x266c9a of _0x11f7d5){console[_0x5e1d94(0x127)]('\x20\x20'+a35_0x28e9b8[_0x5e1d94(0x163)]('+')+'\x20'+_0x266c9a);}console[_0x5e1d94(0x127)]('');}if(_0x265980[_0x5e1d94(0x122)]>0x0)for(const _0xcc3451 of _0x265980){const _0xb89e0d=_0xcc3451[_0x5e1d94(0x10c)]?_0xcc3451[_0x5e1d94(0x10c)]+'/'+_0xcc3451[_0x5e1d94(0x120)][_0x5e1d94(0x17c)]:_0xcc3451[_0x5e1d94(0x120)][_0x5e1d94(0x17c)],_0x5a199e=_0xcc3451['yamlConfig'][_0x5e1d94(0x16d)]?.[_0x5e1d94(0x122)]||0x0,_0x16bdf8=_0x5a199e>0x0?a35_0x28e9b8[_0x5e1d94(0x195)]('\x20['+_0x5a199e+_0x5e1d94(0x148)):'';console[_0x5e1d94(0x127)]('\x0a'+a35_0x28e9b8[_0x5e1d94(0x16c)](_0x5e1d94(0x141))+'\x20'+_0xb89e0d+_0x16bdf8),console['error']('─'[_0x5e1d94(0x10f)](0x3c)),_0xcc3451[_0x5e1d94(0x18b)]&&console['error'](_0xcc3451[_0x5e1d94(0x18b)]),console[_0x5e1d94(0x127)]('─'[_0x5e1d94(0x10f)](0x3c));}if(_0x3660f4[_0x5e1d94(0x122)]>0x0)for(const _0x58365b of _0x3660f4){const _0x26710b=_0x58365b['segmentFolderId']?_0x1a650d[_0x5e1d94(0x157)](_0x58365b['segmentFolderId']['toString']())||'':'',_0x3dc624=_0x26710b?_0x26710b+'/'+_0x58365b['name']:_0x58365b['name'],_0x4553ee=_0x206f23['get'](_0x58365b['id'])||[],_0x4d5266=_0x4553ee[_0x5e1d94(0x122)]>0x0?a35_0x28e9b8['dim']('\x20['+_0x4553ee[_0x5e1d94(0x122)]+_0x5e1d94(0x148)):'';console[_0x5e1d94(0x127)]('\x0a'+a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x121))+'\x20'+_0x3dc624+_0x4d5266),console[_0x5e1d94(0x127)]('─'[_0x5e1d94(0x10f)](0x3c));const _0x2aae9b=segmentWithActivationsToYaml(_0x58365b,_0x4553ee,undefined,_0xdf8787,_0x53182f),_0xd6372e=segmentToYamlString(_0x2aae9b),_0xf255ea=generateDiff(_0xd6372e,'');console[_0x5e1d94(0x127)](formatDiffWithColors(_0xf255ea)),console[_0x5e1d94(0x127)]('─'[_0x5e1d94(0x10f)](0x3c));}const _0x533049=_0x475da2['filter'](_0x226ceb=>!_0x226ceb[_0x5e1d94(0x14e)]&&_0x226ceb[_0x5e1d94(0x18b)]);if(_0x533049['length']>0x0)for(const _0x2d185f of _0x533049){const _0x3c73bc=_0x2d185f[_0x5e1d94(0x10c)]?_0x2d185f[_0x5e1d94(0x10c)]+'/'+_0x2d185f[_0x5e1d94(0x120)][_0x5e1d94(0x17c)]:_0x2d185f[_0x5e1d94(0x120)][_0x5e1d94(0x17c)];console[_0x5e1d94(0x127)]('\x0a'+a35_0x28e9b8['yellow'](_0x5e1d94(0x173))+'\x20'+_0x3c73bc),console['error']('─'['repeat'](0x3c)),console[_0x5e1d94(0x127)](_0x2d185f['diff']),console[_0x5e1d94(0x127)]('─'[_0x5e1d94(0x10f)](0x3c));}if(_0x1ebb5f['dryRun'])return console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x14c)](_0x5e1d94(0x167))),0x0;const _0x25e9a6=_0x265980['length']>0x0||_0x567f20[_0x5e1d94(0x122)]>0x0||_0x3660f4[_0x5e1d94(0x122)]>0x0,_0x37878a=_0x203e46['length']>0x0,_0x1de886=_0x11f7d5['length']>0x0;if(!_0x25e9a6&&!_0x37878a&&!_0x1de886)return console['error'](a35_0x28e9b8[_0x5e1d94(0x16c)](_0x5e1d94(0x193))),0x0;const _0x9ba1d4=_0x265980['length']+_0x567f20[_0x5e1d94(0x122)]+_0x3660f4[_0x5e1d94(0x122)]+_0x11f7d5[_0x5e1d94(0x122)]+_0x203e46[_0x5e1d94(0x122)];if(!_0x1ebb5f[_0x5e1d94(0x11f)]&&_0x9ba1d4>0x0){const _0x562af0=await confirmKey(_0x5e1d94(0x114)+_0x9ba1d4+_0x5e1d94(0x112));if(!_0x562af0)return console['error']('Aborted.'),0x1;}for(const _0xddf6c9 of _0x11f7d5){const _0x302761=_0xddf6c9['split']('/'),_0x40a87b=_0x302761[_0x302761[_0x5e1d94(0x122)]-0x1],_0x4fd5e4=_0x302761[_0x5e1d94(0x131)](0x0,-0x1)[_0x5e1d94(0x12f)]('/'),_0x55e683=_0x1717de[_0x5e1d94(0x157)](_0x4fd5e4),_0x5b9bad={'name':_0x40a87b,'parentFolderId':_0x55e683},_0x2998d0=await withSpinner(_0x5e1d94(0x186)+_0xddf6c9+_0x5e1d94(0x196),()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x16b)](_0x5267ba,_0x5b9bad),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]});_0x1717de['set'](_0xddf6c9,_0x2998d0['data']['id']),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x163)]('✔\x20Created\x20folder\x20\x27'+_0xddf6c9+'\x27'));}let _0x8ef65=0x0,_0x379a08=0x0,_0x599437=0x0,_0x500783=0x0,_0x42c6cf=0x0,_0x12ddbe=0x0;const _0x9e5689=new Map();for(const _0x165d65 of _0x475da2){const _0x469edc=_0x165d65['folderPath']?_0x1717de[_0x5e1d94(0x157)](_0x165d65['folderPath']):undefined;let _0x43bd92;try{if(_0x165d65[_0x5e1d94(0x14e)]){const _0x428968=yamlToCreateRequest(_0x165d65['yamlConfig'],_0x469edc),_0x1d5337=await withSpinner('Creating\x20segment\x20\x27'+_0x165d65['yamlConfig'][_0x5e1d94(0x17c)]+_0x5e1d94(0x196),()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x169)](_0x5267ba,_0x428968),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]});_0x43bd92=_0x1d5337['data']['id'],_0x9e5689[_0x5e1d94(0x160)](_0x165d65[_0x5e1d94(0x120)]['name'],_0x43bd92),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x16c)](_0x5e1d94(0x126)+_0x165d65[_0x5e1d94(0x120)]['name']+'\x27')),_0x8ef65++;}else{if(_0x165d65[_0x5e1d94(0x10b)]){const _0x2d2cb3=yamlToUpdateRequest(_0x165d65[_0x5e1d94(0x120)]);_0x469edc!==_0x165d65['existingSegment']?.['segmentFolderId']&&(_0x2d2cb3[_0x5e1d94(0x12c)]=_0x469edc?parseInt(_0x469edc,0xa):undefined),await withSpinner(_0x5e1d94(0x13f)+_0x165d65['yamlConfig'][_0x5e1d94(0x17c)]+_0x5e1d94(0x196),()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x10e)](_0x5267ba,_0x165d65[_0x5e1d94(0x13d)]['id'],_0x2d2cb3),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]}),_0x43bd92=_0x165d65[_0x5e1d94(0x13d)]['id'],console[_0x5e1d94(0x127)](a35_0x28e9b8['yellow'](_0x5e1d94(0x15e)+_0x165d65[_0x5e1d94(0x120)]['name']+'\x27')),_0x379a08++;}else _0x43bd92=_0x165d65[_0x5e1d94(0x13d)]['id'];}}catch(_0x217bba){const _0x30c8a7=isHttp400Error(_0x217bba),_0x1d394c=_0x30c8a7?ErrorCode[_0x5e1d94(0x111)]:ErrorCode['SEGMENT_UPDATE_ERROR'],_0xcd6e74=getErrorMessage(_0x217bba);throw new SDKError(_0x1d394c,_0x5e1d94(0x12b)+(_0x165d65['isNew']?_0x5e1d94(0x172):_0x5e1d94(0x161))+_0x5e1d94(0x175)+_0x165d65['absolutePath']+_0x5e1d94(0x144)+_0xcd6e74,_0x217bba);}for(const _0x222f6e of _0x165d65[_0x5e1d94(0x110)]){try{if(_0x222f6e['type']===_0x5e1d94(0x172)&&_0x222f6e[_0x5e1d94(0x18c)]){const _0x57ed3d=yamlActivationToCreateRequest(_0x222f6e[_0x5e1d94(0x18c)],_0x569917,_0x4af19a);await withSpinner('Creating\x20activation\x20\x27'+_0x222f6e['name']+_0x5e1d94(0x196),()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x13b)](_0x5267ba,_0x43bd92,_0x57ed3d),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]}),console[_0x5e1d94(0x127)](a35_0x28e9b8['green']('\x20\x20✔\x20Created\x20activation\x20\x27'+_0x222f6e[_0x5e1d94(0x17c)]+'\x27')),_0x500783++;}else{if(_0x222f6e[_0x5e1d94(0x190)]==='update'&&_0x222f6e['yamlActivation']&&_0x222f6e[_0x5e1d94(0x16f)]){const _0x2b0c4c=yamlActivationToUpdateRequest(_0x222f6e[_0x5e1d94(0x18c)],_0x569917,_0x4af19a);await withSpinner(_0x5e1d94(0x123)+_0x222f6e['name']+_0x5e1d94(0x196),()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x14f)](_0x5267ba,_0x43bd92,_0x222f6e[_0x5e1d94(0x16f)]['id'],_0x2b0c4c),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]}),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x14c)](_0x5e1d94(0x17f)+_0x222f6e[_0x5e1d94(0x17c)]+'\x27')),_0x42c6cf++;}else _0x222f6e[_0x5e1d94(0x190)]==='delete'&&_0x222f6e[_0x5e1d94(0x16f)]&&(await withSpinner(_0x5e1d94(0x18e)+_0x222f6e['name']+_0x5e1d94(0x196),()=>_0x893df7['segment']['deleteActivation'](_0x5267ba,_0x43bd92,_0x222f6e['existingActivation']['id']),{'verbose':_0x1ebb5f[_0x5e1d94(0x129)]}),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x12e)](_0x5e1d94(0x197)+_0x222f6e[_0x5e1d94(0x17c)]+'\x27')),_0x12ddbe++);}}catch(_0x25c6a5){const _0x557189=isHttp400Error(_0x25c6a5),_0x18825d=_0x557189?ErrorCode[_0x5e1d94(0x151)]:ErrorCode[_0x5e1d94(0x10d)],_0x46e79b=getErrorMessage(_0x25c6a5);throw new SDKError(_0x18825d,_0x5e1d94(0x12b)+_0x222f6e[_0x5e1d94(0x190)]+_0x5e1d94(0x14a)+_0x222f6e[_0x5e1d94(0x17c)]+_0x5e1d94(0x11a)+_0x165d65[_0x5e1d94(0x14d)]+_0x5e1d94(0x144)+_0x46e79b,_0x25c6a5);}}}for(const _0x772cc2 of _0x3660f4){await withSpinner('Deleting\x20segment\x20\x27'+_0x772cc2[_0x5e1d94(0x17c)]+_0x5e1d94(0x196),()=>_0x893df7[_0x5e1d94(0x18d)][_0x5e1d94(0x147)](_0x772cc2['id']),{'verbose':_0x1ebb5f['verbose']}),console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x12e)]('✔\x20Deleted\x20segment\x20\x27'+_0x772cc2[_0x5e1d94(0x17c)]+'\x27')),_0x599437++;}const _0xf53f99=[];if(_0x8ef65>0x0)_0xf53f99[_0x5e1d94(0x166)](_0x8ef65+_0x5e1d94(0x15f));if(_0x379a08>0x0)_0xf53f99[_0x5e1d94(0x166)](_0x379a08+_0x5e1d94(0x13c));if(_0x599437>0x0)_0xf53f99[_0x5e1d94(0x166)](_0x599437+'\x20deleted');const _0x29c648=[];if(_0x500783>0x0)_0x29c648[_0x5e1d94(0x166)](_0x500783+_0x5e1d94(0x15f));if(_0x42c6cf>0x0)_0x29c648[_0x5e1d94(0x166)](_0x42c6cf+_0x5e1d94(0x13c));if(_0x12ddbe>0x0)_0x29c648['push'](_0x12ddbe+_0x5e1d94(0x184));return console[_0x5e1d94(0x127)](a35_0x28e9b8[_0x5e1d94(0x16c)](_0x5e1d94(0x192))),_0xf53f99[_0x5e1d94(0x122)]>0x0&&console[_0x5e1d94(0x127)](_0x5e1d94(0x142)+_0xf53f99['join'](',\x20')),_0x29c648[_0x5e1d94(0x122)]>0x0&&console[_0x5e1d94(0x127)]('\x20\x20Activations:\x20'+_0x29c648['join'](',\x20')),0x0;}}function a35_0x8251(){const _0xab34ab=['8mrpqxL','New\x20segment:','\x20\x20Segments:\x20','filter','\x0a\x20\x20','dirname','\x20folders\x20to\x20create','deleteSegment','\x20activations]','\x20new\x20segments','\x20activation\x20\x27','\x20to\x20update','yellow','absolutePath','isNew','updateActivation','sort','ACTIVATION_SYNTAX_ERROR','Error:\x20No\x20tdx.json\x20found\x20in\x20or\x20above:\x20','.yml','3020EWkXjW','Error:\x20File\x20must\x20have\x20.yml\x20or\x20.yaml\x20extension:\x20','buildNameToIdMap','get','parent_segment\x20is\x20not\x20set.\x20Use\x20`tdx\x20sg\x20use\x20<parent_name>`\x20to\x20set\x20it.\x0a','147935xpaBuM','\x20segments\x20on\x20server\x20not\x20in\x20YAML\x20(use\x20--delete\x20to\x20remove)','relative','63621QXxVoF','all','✔\x20Updated\x20segment\x20\x27','\x20created','set','update','1309749myOnme','blue','Fetching\x20existing\x20segments...','Error:\x20No\x20segment\x20YAML\x20files\x20found\x20in\x20','push','\x0a[Dry\x20run]\x20No\x20changes\x20were\x20made','\x20to\x20create','createSegment','then','createFolder','green','activations','Error:\x20Directory\x20not\x20found:\x20','existingActivation','Scoped\x20to\x20folder:\x20','\x20\x20Source:\x20','create','Changes\x20to:','\x0aPush\x20summary\x20for\x20\x27','\x20segment\x20from\x20file:\x20','data','No\x20segment\x20YAML\x20files\x20found','stringify','toString','Tip:\x20Run\x20`tdx\x20sg\x20pull\x20<parent_name>`\x20first\x20to\x20create\x20the\x20folder\x20structure','entries','name','cyan','Push\x20YAML\x20files\x20to\x20Treasure\x20Data\x20as\x20child\x20segments','\x20\x20✔\x20Updated\x20activation\x20\x27','endsWith','.yaml','isFile','\x20changed\x20segments','\x20deleted','Source\x20directory:\x20','Creating\x20folder\x20\x27','has','6MIaTOm','split','121759yWqRyL','diff','yamlActivation','segment','Deleting\x20activation\x20\x27','Usage:\x20tdx\x20sg\x20push\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Push\x20all\x20segments\x20(requires\x20context)','type','isDirectory','\x0a✔\x20Push\x20complete','✔\x20All\x20segments\x20and\x20activations\x20are\x20up\x20to\x20date','parentFolderId','dim','\x27...','\x20\x20✔\x20Deleted\x20activation\x20\x27','buildIdToNameMap','configDir','hasChanges','folderPath','ACTIVATION_UPDATE_ERROR','updateSegmentById','repeat','activationActions','SEGMENT_SYNTAX_ERROR','\x20changes?','parent_segment','Push\x20','Fetching\x20connections\x20for\x20name\x20resolution...','\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20push\x20<file_path>\x20\x20\x20\x20\x20\x20\x20\x20#\x20Push\x20specific\x20segment\x20file','\x20\x20\x20\x20','add','6675201mJpxWj','\x27\x20from\x20file:\x20','parentSegment','from','flatMap','Parent\x20segment:\x20','yes','yamlConfig','Delete\x20segment:','length','Updating\x20activation\x20\x27','4NoAFsK','segment:push','✔\x20Created\x20segment\x20\x27','error','utf-8','verbose','Error\x20parsing\x20','Failed\x20to\x20','segmentFolderId','config','red','join','execute','slice','resolveParentId','listActivations','238121eVLeEb','4995388QoRFTo','site','\x20to\x20delete','delete','Fetching\x20existing\x20folders...','Folders\x20to\x20create:','createActivation','\x20updated','existingSegment','message','Updating\x20segment\x20\x27'];a35_0x8251=function(){return _0xab34ab;};return a35_0x8251();}function buildFolderPathToIdMap(_0x413cc4){const _0x3e1604=a35_0x5a37db,_0x5d748c=new Map(),_0x405900=new Map();for(const _0x3171d5 of _0x413cc4){_0x405900[_0x3e1604(0x160)](_0x3171d5['id'],_0x3171d5);}const _0x5f2140=new Set();for(const _0xcc7ff8 of _0x413cc4){!_0xcc7ff8[_0x3e1604(0x194)]&&_0x5f2140[_0x3e1604(0x118)](_0xcc7ff8['id']);}function _0x48443e(_0x385d62){const _0x2f3698=_0x3e1604;if(_0x5f2140[_0x2f3698(0x187)](_0x385d62['id']))return'';if(_0x385d62['parentFolderId']){const _0x4a6cae=_0x405900[_0x2f3698(0x157)](_0x385d62[_0x2f3698(0x194)]);if(_0x4a6cae){const _0x41f0df=_0x48443e(_0x4a6cae);return _0x41f0df?_0x41f0df+'/'+_0x385d62[_0x2f3698(0x17c)]:_0x385d62[_0x2f3698(0x17c)];}}return _0x385d62['name'];}for(const _0x88ed7 of _0x413cc4){const _0x33e999=_0x48443e(_0x88ed7);_0x5d748c[_0x3e1604(0x160)](_0x33e999,_0x88ed7['id']);}return _0x5d748c;}function findYamlFiles(_0x4b5e79){const _0x7df514=[];function _0x4ce2b7(_0x4009bc){const _0x2b6841=a35_0x1302,_0x5448b0=readdirSync(_0x4009bc,{'withFileTypes':!![]});for(const _0x341ff0 of _0x5448b0){const _0x4a07ea=a35_0x55cd94['join'](_0x4009bc,_0x341ff0['name']);if(_0x341ff0[_0x2b6841(0x191)]())_0x4ce2b7(_0x4a07ea);else(_0x341ff0['name']['endsWith'](_0x2b6841(0x153))||_0x341ff0[_0x2b6841(0x17c)][_0x2b6841(0x180)](_0x2b6841(0x181)))&&_0x7df514[_0x2b6841(0x166)](_0x4a07ea);}}return _0x4ce2b7(_0x4b5e79),_0x7df514;}function calculateActivationActions(_0x217cdf,_0x1801f4,_0x371724,_0x5af2ec){const _0xb57c39=a35_0x5a37db,_0x50e9b6=[],_0x5b6871=new Map();for(const _0x11e1a6 of _0x1801f4){_0x5b6871[_0xb57c39(0x160)](_0x11e1a6['name'],_0x11e1a6);}const _0x440d95=new Map();for(const _0xd178be of _0x217cdf){_0x440d95[_0xb57c39(0x160)](_0xd178be[_0xb57c39(0x17c)],_0xd178be);}for(const _0x25cf82 of _0x217cdf){const _0xa84bf1=_0x5b6871['get'](_0x25cf82[_0xb57c39(0x17c)]);if(!_0xa84bf1)_0x50e9b6[_0xb57c39(0x166)]({'type':_0xb57c39(0x172),'name':_0x25cf82[_0xb57c39(0x17c)],'yamlActivation':_0x25cf82});else{const _0x1fdefa=activationToYaml(_0xa84bf1,_0x371724,_0x5af2ec),_0x212aae=a35_0x45d4c3[_0xb57c39(0x178)](_0x1fdefa),_0x273545=a35_0x45d4c3['stringify'](_0x25cf82);_0x212aae!==_0x273545&&_0x50e9b6['push']({'type':_0xb57c39(0x161),'name':_0x25cf82[_0xb57c39(0x17c)],'yamlActivation':_0x25cf82,'existingActivation':_0xa84bf1});}}for(const _0x52aae4 of _0x1801f4){!_0x440d95[_0xb57c39(0x187)](_0x52aae4['name'])&&_0x50e9b6[_0xb57c39(0x166)]({'type':'delete','name':_0x52aae4[_0xb57c39(0x17c)],'existingActivation':_0x52aae4});}return _0x50e9b6;}
|
|
1
|
+
const a35_0x573744=a35_0x99f9;(function(_0x1ed017,_0x3112ce){const _0x325ae4=a35_0x99f9,_0x2e0afe=_0x1ed017();while(!![]){try{const _0x33c6bd=parseInt(_0x325ae4(0x96))/0x1*(-parseInt(_0x325ae4(0xb0))/0x2)+-parseInt(_0x325ae4(0xaa))/0x3+-parseInt(_0x325ae4(0xfa))/0x4+-parseInt(_0x325ae4(0xa1))/0x5*(parseInt(_0x325ae4(0xcf))/0x6)+parseInt(_0x325ae4(0xc0))/0x7*(parseInt(_0x325ae4(0x90))/0x8)+parseInt(_0x325ae4(0xb8))/0x9*(parseInt(_0x325ae4(0x7d))/0xa)+-parseInt(_0x325ae4(0xce))/0xb*(-parseInt(_0x325ae4(0xdf))/0xc);if(_0x33c6bd===_0x3112ce)break;else _0x2e0afe['push'](_0x2e0afe['shift']());}catch(_0x5d1327){_0x2e0afe['push'](_0x2e0afe['shift']());}}}(a35_0x3645,0xf2c6e));import{BaseCommand}from'./command.js';import{SDKError,ErrorCode,isHttp400Error,getErrorMessage}from'../sdk/errors.js';import{withSpinner}from'../utils/spinner.js';import{generateDiff,formatDiffWithColors,hasChanges}from'../utils/diff.js';import{confirmKey}from'../utils/prompt.js';function a35_0x3645(){const _0x69b646=['\x27...','segmentFolderId','resolveParentId','isDirectory','sort','\x20folders\x20to\x20create','SEGMENT_SYNTAX_ERROR','34812LOJagj','isNew','blue','set','Changes\x20to:','No\x20segment\x20YAML\x20files\x20found','\x20\x20✔\x20Updated\x20activation\x20\x27','join','Failed\x20to\x20','Parent\x20segment:\x20','Updating\x20activation\x20\x27','all','existingActivation','type','Usage:\x20tdx\x20sg\x20push\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Push\x20all\x20segments\x20(requires\x20context)','resolve','\x20to\x20delete','\x20unchanged\x20segments','toString','diff','Source\x20directory:\x20','deleteSegment','data','yes','parentSegment','Creating\x20folder\x20\x27','✔\x20Created\x20segment\x20\x27','7440520LuyGUk','delete','parent_segment','parentFolderId','\x20\x20Activations:','\x27\x20from\x20file:\x20','Deleting\x20activation\x20\x27','connection','\x20new\x20segments','\x20activations]','New\x20segment:','yamlActivation','Site:\x20','\x0aPush\x20summary\x20for\x20\x27','from','Fetching\x20existing\x20activations...','dim','3760mnZaoY','Error:\x20File\x20must\x20have\x20.yml\x20or\x20.yaml\x20extension:\x20','cwd','split','\x20segments\x20on\x20server\x20not\x20in\x20YAML\x20(use\x20--delete\x20to\x20remove)','filter','updateSegmentById','segment:push','stringify','description','segment','Resolving\x20parent\x20segment\x20\x27','\x20changed\x20segments','\x20updated','cyan','hasChanges','\x0a[Dry\x20run]\x20No\x20changes\x20were\x20made','Deleting\x20segment\x20\x27','\x20deleted','802184mhShoc','Fetching\x20users\x20for\x20email\x20resolution...','verbose','startsWith','createActivation','update','1628834DikQxk','activationActions','ACTIVATION_UPDATE_ERROR','Aborted.','Updating\x20segment\x20\x27','.yml','yamlConfig','Delete\x20segment:','absolutePath','name','repeat','9072285PiEyFO','Fetching\x20connections\x20for\x20name\x20resolution...','has','existingSegment','📁\x20','get','\x20to\x20update','configDir','buildIdToNameMap','2825871BpgHVS','createFolder','\x20\x20✔\x20Created\x20activation\x20\x27','dirname','\x20segment\x20from\x20file:\x20','push','2ErUjjE','Folders\x20to\x20create:','\x20created','activations','user','\x20\x20Segments:\x20','create','error','17919kDaJbC','Tip:\x20Run\x20`tdx\x20sg\x20pull\x20<parent_name>`\x20first\x20to\x20create\x20the\x20folder\x20structure','flatMap','add','.yaml','Push\x20YAML\x20files\x20to\x20Treasure\x20Data\x20as\x20child\x20segments','site','green','7IvtlpQ','endsWith','\x20\x20✔\x20Deleted\x20activation\x20\x27','yellow','red','✔\x20Created\x20folder\x20\x27','then','\x20\x20Source:\x20','Scoped\x20to\x20folder:\x20','Error:\x20Directory\x20not\x20found:\x20','relative','deleteActivation','\x20changes?','folderPath','24233qShfRG','6CAByjF','config','SEGMENT_UPDATE_ERROR','updateActivation','length','\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20push\x20<file_path>\x20\x20\x20\x20\x20\x20\x20\x20#\x20Push\x20specific\x20segment\x20file','Tip:\x20Run\x20`tdx\x20sg\x20pull`\x20first\x20to\x20create\x20segment\x20files','\x20\x20\x20\x20','slice'];a35_0x3645=function(){return _0x69b646;};return a35_0x3645();}import{batchAsync}from'../utils/async.js';import{getSegmentRootDir,findTdxConfig}from'../utils/tdx-config.js';import{segmentToYamlString,segmentWithActivationsToYaml,parseSegmentYamlFile,normalizeChildSegmentYaml,yamlToCreateRequest,yamlToUpdateRequest,yamlActivationToCreateRequest,yamlActivationToUpdateRequest,activationToYaml}from'../sdk/segment/child-segment-yaml.js';import a35_0x526ed4 from'chalk';import{existsSync,readFileSync,statSync,readdirSync}from'fs';import a35_0x186522 from'path';import*as a35_0x4dfc51 from'yaml';import{sanitizeFileName}from'../utils/string-utils.js';function tryFindTdxConfig(_0x2f4af9){try{return findTdxConfig(_0x2f4af9);}catch{return null;}}function resolveTDFolderPath(_0x312df5,_0x1ad314,_0x1c7b35){if(!_0x1ad314)return _0x312df5;return _0x312df5?_0x1c7b35+'/'+_0x312df5:_0x1c7b35;}export class SegmentPushCommand extends BaseCommand{['name']=a35_0x573744(0x84);[a35_0x573744(0x86)]=a35_0x573744(0xbd);async['execute'](_0x5caaf4){const _0x1c8156=a35_0x573744,{options:_0x199607,args:_0x358e34,tdx:_0x2b54e0}=_0x5caaf4,_0x5b4148=_0x199607,_0x26dac7=_0x199607[_0x1c8156(0xf7)],_0x1c1459=_0x358e34[0x0];let _0xf21207,_0x2ee342,_0x40dac6,_0x7e331e;if(_0x1c1459){if(existsSync(_0x1c1459)&&statSync(_0x1c1459)['isDirectory']()){const _0xd29809=tryFindTdxConfig(_0x1c1459);if(_0xd29809)_0xf21207=_0xd29809[_0x1c8156(0xd0)]['parent_segment'],_0x2ee342=_0x1c1459,_0x40dac6=_0xd29809[_0x1c8156(0xa8)];else return console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xc4)]('Error:\x20No\x20tdx.json\x20found\x20in\x20or\x20above:\x20'+_0x1c1459+'\x0a')),console[_0x1c8156(0xb7)](a35_0x526ed4['cyan'](_0x1c8156(0xb9))),0x1;}else{if(existsSync(_0x1c1459)&&statSync(_0x1c1459)['isFile']()){const _0x55dca5=a35_0x186522[_0x1c8156(0xad)](_0x1c1459),_0x1156cb=tryFindTdxConfig(_0x55dca5);if(_0x1156cb)_0xf21207=_0x1156cb['config'][_0x1c8156(0x6e)],_0x40dac6=_0x1156cb['configDir'],_0x2ee342=_0x1156cb['configDir'],_0x7e331e=a35_0x186522[_0x1c8156(0xee)](_0x1c1459);else return console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xc4)]('Error:\x20No\x20tdx.json\x20found\x20in\x20or\x20above:\x20'+_0x55dca5+'\x0a')),console['error'](a35_0x526ed4['cyan'](_0x1c8156(0xb9))),0x1;}else _0xf21207=_0x1c1459;}}else{const _0x5b1bfe=tryFindTdxConfig(process[_0x1c8156(0x7f)]());_0x5b1bfe?(_0xf21207=_0x5b1bfe['config'][_0x1c8156(0x6e)],_0x2ee342=process[_0x1c8156(0x7f)](),_0x40dac6=_0x5b1bfe['configDir']):_0xf21207=_0x26dac7;}if(!_0xf21207)return console['error'](a35_0x526ed4['yellow']('parent_segment\x20is\x20not\x20set.\x20Use\x20`tdx\x20sg\x20use\x20<parent_name>`\x20to\x20set\x20it.\x0a')),console['error'](_0x1c8156(0xed)),console[_0x1c8156(0xb7)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20push\x20<parent_name>\x20\x20\x20\x20\x20\x20#\x20Push\x20all\x20segments\x20to\x20parent'),console[_0x1c8156(0xb7)](_0x1c8156(0xd4)),0x1;const _0x4bb15f=_0x2ee342||getSegmentRootDir(sanitizeFileName(_0xf21207)),_0x227337=_0x40dac6||_0x4bb15f,_0x404a9e=a35_0x186522[_0x1c8156(0xca)](_0x227337,_0x4bb15f),_0x5dcff4=_0x404a9e!==''&&_0x404a9e!=='.';if(!existsSync(_0x4bb15f))return console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xc4)](_0x1c8156(0xc9)+_0x4bb15f+'\x0a')),console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0x8b)](_0x1c8156(0xb9))),0x1;_0x5b4148[_0x1c8156(0x92)]&&(console[_0x1c8156(0xb7)](_0x1c8156(0x78)+_0x5b4148[_0x1c8156(0xbe)]),console[_0x1c8156(0xb7)](_0x1c8156(0xe8)+_0xf21207),console['error'](_0x1c8156(0xf3)+_0x4bb15f),_0x5dcff4&&console['error'](_0x1c8156(0xc8)+_0x404a9e));const _0x40c8fb=await withSpinner(_0x1c8156(0x88)+_0xf21207+_0x1c8156(0xd8),()=>_0x2b54e0[_0x1c8156(0x87)][_0x1c8156(0xda)](_0xf21207),{'verbose':_0x5b4148[_0x1c8156(0x92)]}),_0x4122f8=_0x40c8fb['data'],[_0x351ca8,_0x5c7997,_0x10485f]=await Promise[_0x1c8156(0xea)]([withSpinner('Fetching\x20existing\x20segments...',()=>_0x2b54e0[_0x1c8156(0x87)]['listSegments'](_0x4122f8),{'verbose':_0x5b4148[_0x1c8156(0x92)]}),withSpinner('Fetching\x20existing\x20folders...',()=>_0x2b54e0[_0x1c8156(0x87)]['listFolders'](_0x4122f8),{'verbose':_0x5b4148[_0x1c8156(0x92)]}),withSpinner(_0x1c8156(0x91),()=>_0x2b54e0[_0x1c8156(0xb4)]['buildUserMaps'](),{'verbose':_0x5b4148[_0x1c8156(0x92)]})[_0x1c8156(0xc6)](_0x578e36=>_0x578e36[_0x1c8156(0xf5)])]),_0x73686e=_0x351ca8[_0x1c8156(0xf5)],_0x57fbdd=_0x5c7997[_0x1c8156(0xf5)],{emailToId:_0x4d5d27,idToEmail:_0xb80adc}=_0x10485f,[_0x316853,_0x31f7c2]=await withSpinner(_0x1c8156(0xa2),async()=>{const _0x196eaa=_0x1c8156,[_0x13de62,_0x2c5927]=await Promise['all']([_0x2b54e0[_0x196eaa(0x73)]['buildNameToIdMap'](),_0x2b54e0[_0x196eaa(0x73)][_0x196eaa(0xa9)]()]);return[_0x13de62,_0x2c5927];},{'verbose':_0x5b4148['verbose']})[_0x1c8156(0xc6)](_0x1b0899=>_0x1b0899[_0x1c8156(0xf5)]),_0x6f5a5f=buildFolderPathToIdMap(_0x57fbdd),_0x2b39cb=new Map();for(const [_0x47f439,_0x3a6c24]of _0x6f5a5f['entries']()){_0x2b39cb[_0x1c8156(0xe2)](_0x3a6c24,_0x47f439);}const _0x3aeb97=new Map();for(const _0x460a3f of _0x73686e){const _0x735f2d=_0x460a3f[_0x1c8156(0xd9)]?_0x2b39cb[_0x1c8156(0xa6)](_0x460a3f[_0x1c8156(0xd9)][_0x1c8156(0xf1)]())||'':'',_0x53a39b=_0x735f2d+':'+_0x460a3f[_0x1c8156(0x9f)];_0x3aeb97[_0x1c8156(0xe2)](_0x53a39b,_0x460a3f);}let _0x39f0f5;if(_0x7e331e){if(!_0x7e331e[_0x1c8156(0xc1)](_0x1c8156(0x9b))&&!_0x7e331e[_0x1c8156(0xc1)](_0x1c8156(0xbc)))return console[_0x1c8156(0xb7)](a35_0x526ed4['red'](_0x1c8156(0x7e)+_0x7e331e+'\x0a')),0x1;_0x39f0f5=[_0x7e331e];}else _0x39f0f5=findYamlFiles(_0x4bb15f);if(_0x39f0f5[_0x1c8156(0xd3)]===0x0)return console['error'](a35_0x526ed4[_0x1c8156(0xc4)]('Error:\x20No\x20segment\x20YAML\x20files\x20found\x20in\x20'+_0x4bb15f+'\x0a')),console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0x8b)](_0x1c8156(0xd5))),0x1;const _0x27a31e=[];for(const _0x4336f7 of _0x39f0f5){const _0x4fb342=a35_0x186522['relative'](_0x4bb15f,a35_0x186522['dirname'](_0x4336f7)),_0x5d5024=_0x4fb342==='.'?'':_0x4fb342,_0x443aa8=readFileSync(_0x4336f7,'utf-8');try{const _0x190f3e=parseSegmentYamlFile(_0x443aa8),_0x65bb50=normalizeChildSegmentYaml(_0x190f3e);_0x27a31e[_0x1c8156(0xaf)]({'yamlConfig':_0x65bb50,'folderPath':_0x5d5024,'sourcePath':_0x4336f7});}catch(_0x5d92f9){return console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xc4)]('Error\x20parsing\x20'+_0x4336f7+':\x20'+(_0x5d92f9 instanceof Error?_0x5d92f9['message']:_0x5d92f9))),0x1;}}if(_0x27a31e['length']===0x0)return console['error'](a35_0x526ed4[_0x1c8156(0xc3)](_0x1c8156(0xe4))),0x0;const _0x38a02d=new Map();_0x73686e[_0x1c8156(0xd3)]>0x0&&await withSpinner(_0x1c8156(0x7b),async()=>{await batchAsync(_0x73686e,async _0x73b62e=>{const _0x81d60b=a35_0x99f9,_0x4770d5=await _0x2b54e0['segment']['listActivations'](_0x4122f8,_0x73b62e['id']);_0x38a02d[_0x81d60b(0xe2)](_0x73b62e['id'],_0x4770d5);});},{'verbose':_0x5b4148[_0x1c8156(0x92)]});const _0x2db2b5=[],_0x2ee17b=new Set();for(const {yamlConfig:_0x117e22,folderPath:_0x190cf4,sourcePath:_0x4156da}of _0x27a31e){const _0x18471d=resolveTDFolderPath(_0x190cf4,_0x5dcff4,_0x404a9e),_0x1e239c=_0x18471d+':'+_0x117e22[_0x1c8156(0x9f)],_0x406aad=_0x3aeb97[_0x1c8156(0xa6)](_0x1e239c),_0x4a7eb2=_0x406aad?_0x38a02d[_0x1c8156(0xa6)](_0x406aad['id'])||[]:[];if(_0x18471d&&!_0x6f5a5f[_0x1c8156(0xa3)](_0x18471d)){const _0x316d02=_0x18471d[_0x1c8156(0x80)]('/');let _0x1cccb7='';for(const _0x5bbb98 of _0x316d02){_0x1cccb7=_0x1cccb7?_0x1cccb7+'/'+_0x5bbb98:_0x5bbb98,!_0x6f5a5f['has'](_0x1cccb7)&&_0x2ee17b[_0x1c8156(0xbb)](_0x1cccb7);}}const _0x571118=calculateActivationActions(_0x117e22[_0x1c8156(0xb3)]||[],_0x4a7eb2,_0xb80adc,_0x31f7c2),_0x56c806=segmentToYamlString(_0x117e22);let _0x3bdc7a,_0x5d4e50=![],_0x512f9d;if(_0x406aad){const _0x4840c9=segmentWithActivationsToYaml(_0x406aad,_0x4a7eb2,undefined,_0xb80adc,_0x31f7c2),_0x1188b6=segmentToYamlString(_0x4840c9);_0x3bdc7a=generateDiff(_0x1188b6,_0x56c806),_0x5d4e50=hasChanges(_0x3bdc7a),_0x5d4e50&&(_0x512f9d=formatDiffWithColors(_0x3bdc7a));}else _0x3bdc7a=generateDiff('',_0x56c806),_0x512f9d=formatDiffWithColors(_0x3bdc7a);_0x2db2b5[_0x1c8156(0xaf)]({'relativePath':_0x117e22[_0x1c8156(0x9f)],'absolutePath':_0x4156da,'yamlConfig':_0x117e22,'folderPath':_0x18471d,'existingSegment':_0x406aad,'existingActivations':_0x4a7eb2,'isNew':!_0x406aad,'hasChanges':_0x5d4e50,'diff':_0x512f9d,'activationActions':_0x571118});}let _0x3b2e87=[];if(!_0x7e331e){const _0xcb2a2=new Set();for(const {yamlConfig:_0x2b3d06,folderPath:_0x206c65}of _0x27a31e){const _0x2688ba=resolveTDFolderPath(_0x206c65,_0x5dcff4,_0x404a9e);_0xcb2a2[_0x1c8156(0xbb)](_0x2688ba+':'+_0x2b3d06[_0x1c8156(0x9f)]);}_0x3b2e87=_0x73686e[_0x1c8156(0x82)](_0x3f6775=>{const _0x3d58a5=_0x1c8156,_0x3664fc=_0x3f6775[_0x3d58a5(0xd9)]?_0x2b39cb[_0x3d58a5(0xa6)](_0x3f6775['segmentFolderId']['toString']())||'':'',_0xae09f=_0x3664fc+':'+_0x3f6775[_0x3d58a5(0x9f)];if(_0xcb2a2['has'](_0xae09f))return![];if(_0x5dcff4)return _0x3664fc===_0x404a9e||_0x3664fc[_0x3d58a5(0x93)](_0x404a9e+'/');return!![];});}const _0x1b3466=_0x2db2b5[_0x1c8156(0x82)](_0x112986=>_0x112986[_0x1c8156(0xe0)]),_0x53ab62=_0x2db2b5[_0x1c8156(0x82)](_0x2eb294=>!_0x2eb294[_0x1c8156(0xe0)]&&_0x2eb294[_0x1c8156(0x8c)]),_0x161829=_0x2db2b5[_0x1c8156(0x82)](_0x47583d=>!_0x47583d['isNew']&&!_0x47583d[_0x1c8156(0x8c)]),_0x1122b8=Array[_0x1c8156(0x7a)](_0x2ee17b)[_0x1c8156(0xdc)](),_0x3948c6=_0x5b4148[_0x1c8156(0xfb)]?_0x3b2e87:[],_0x543ca2=_0x2db2b5[_0x1c8156(0xba)](_0x49146f=>_0x49146f[_0x1c8156(0x97)]),_0x32405d=_0x543ca2[_0x1c8156(0x82)](_0x32968a=>_0x32968a[_0x1c8156(0xec)]===_0x1c8156(0xb6)),_0xc79009=_0x543ca2[_0x1c8156(0x82)](_0x5b1238=>_0x5b1238['type']===_0x1c8156(0x95)),_0x36d646=_0x543ca2[_0x1c8156(0x82)](_0x39ea8f=>_0x39ea8f['type']==='delete');console['error'](_0x1c8156(0x79)+_0xf21207+'\x27:');_0x1122b8['length']>0x0&&console['error']('\x20\x20'+a35_0x526ed4[_0x1c8156(0xe1)](_0x1c8156(0xa5)+_0x1122b8[_0x1c8156(0xd3)]+_0x1c8156(0xdd)));console['error']('\x20\x20'+a35_0x526ed4[_0x1c8156(0xbf)]('+\x20'+_0x1b3466['length']+_0x1c8156(0x74))),console[_0x1c8156(0xb7)]('\x20\x20'+a35_0x526ed4[_0x1c8156(0xc3)]('~\x20'+_0x53ab62['length']+_0x1c8156(0x89)));if(_0x3948c6[_0x1c8156(0xd3)]>0x0)console[_0x1c8156(0xb7)]('\x20\x20'+a35_0x526ed4[_0x1c8156(0xc4)]('-\x20'+_0x3948c6[_0x1c8156(0xd3)]+'\x20segments\x20to\x20delete'));else _0x3b2e87[_0x1c8156(0xd3)]>0x0&&!_0x5b4148['delete']&&console[_0x1c8156(0xb7)]('\x20\x20'+a35_0x526ed4['dim']('\x20\x20'+_0x3b2e87[_0x1c8156(0xd3)]+_0x1c8156(0x81)));console[_0x1c8156(0xb7)]('\x20\x20'+a35_0x526ed4[_0x1c8156(0x7c)]('=\x20'+_0x161829[_0x1c8156(0xd3)]+_0x1c8156(0xf0)));_0x543ca2[_0x1c8156(0xd3)]>0x0&&(console['error'](''),console[_0x1c8156(0xb7)](_0x1c8156(0x70)),_0x32405d[_0x1c8156(0xd3)]>0x0&&console[_0x1c8156(0xb7)]('\x20\x20\x20\x20'+a35_0x526ed4[_0x1c8156(0xbf)]('+\x20'+_0x32405d['length']+'\x20to\x20create')),_0xc79009[_0x1c8156(0xd3)]>0x0&&console[_0x1c8156(0xb7)]('\x20\x20\x20\x20'+a35_0x526ed4['yellow']('~\x20'+_0xc79009[_0x1c8156(0xd3)]+_0x1c8156(0xa7))),_0x36d646[_0x1c8156(0xd3)]>0x0&&console['error'](_0x1c8156(0xd6)+a35_0x526ed4[_0x1c8156(0xc4)]('-\x20'+_0x36d646['length']+_0x1c8156(0xef))));console[_0x1c8156(0xb7)](_0x1c8156(0xc7)+a35_0x526ed4[_0x1c8156(0x8b)](_0x4bb15f)+'\x0a');if(_0x1122b8[_0x1c8156(0xd3)]>0x0){console[_0x1c8156(0xb7)](_0x1c8156(0xb1));for(const _0x278d9c of _0x1122b8){console[_0x1c8156(0xb7)]('\x20\x20'+a35_0x526ed4[_0x1c8156(0xe1)]('+')+'\x20'+_0x278d9c);}console[_0x1c8156(0xb7)]('');}if(_0x1b3466[_0x1c8156(0xd3)]>0x0)for(const _0x261eb0 of _0x1b3466){const _0x392b1c=_0x261eb0['folderPath']?_0x261eb0[_0x1c8156(0xcd)]+'/'+_0x261eb0['yamlConfig']['name']:_0x261eb0[_0x1c8156(0x9c)][_0x1c8156(0x9f)],_0x438c61=_0x261eb0[_0x1c8156(0x9c)][_0x1c8156(0xb3)]?.[_0x1c8156(0xd3)]||0x0,_0x38b289=_0x438c61>0x0?a35_0x526ed4[_0x1c8156(0x7c)]('\x20['+_0x438c61+_0x1c8156(0x75)):'';console[_0x1c8156(0xb7)]('\x0a'+a35_0x526ed4[_0x1c8156(0xbf)](_0x1c8156(0x76))+'\x20'+_0x392b1c+_0x38b289),console[_0x1c8156(0xb7)]('─'[_0x1c8156(0xa0)](0x3c)),_0x261eb0[_0x1c8156(0xf2)]&&console[_0x1c8156(0xb7)](_0x261eb0[_0x1c8156(0xf2)]),console[_0x1c8156(0xb7)]('─'['repeat'](0x3c));}if(_0x3948c6[_0x1c8156(0xd3)]>0x0)for(const _0x3238d2 of _0x3948c6){const _0x727eea=_0x3238d2[_0x1c8156(0xd9)]?_0x2b39cb[_0x1c8156(0xa6)](_0x3238d2[_0x1c8156(0xd9)][_0x1c8156(0xf1)]())||'':'',_0x404507=_0x727eea?_0x727eea+'/'+_0x3238d2[_0x1c8156(0x9f)]:_0x3238d2['name'],_0x2c0b6e=_0x38a02d[_0x1c8156(0xa6)](_0x3238d2['id'])||[],_0x150cee=_0x2c0b6e[_0x1c8156(0xd3)]>0x0?a35_0x526ed4[_0x1c8156(0x7c)]('\x20['+_0x2c0b6e[_0x1c8156(0xd3)]+_0x1c8156(0x75)):'';console[_0x1c8156(0xb7)]('\x0a'+a35_0x526ed4[_0x1c8156(0xc4)](_0x1c8156(0x9d))+'\x20'+_0x404507+_0x150cee),console[_0x1c8156(0xb7)]('─'[_0x1c8156(0xa0)](0x3c));const _0x103aae=segmentWithActivationsToYaml(_0x3238d2,_0x2c0b6e,undefined,_0xb80adc,_0x31f7c2),_0x1dd87e=segmentToYamlString(_0x103aae),_0x379ac4=generateDiff(_0x1dd87e,'');console[_0x1c8156(0xb7)](formatDiffWithColors(_0x379ac4)),console['error']('─'['repeat'](0x3c));}const _0xc36a91=_0x2db2b5[_0x1c8156(0x82)](_0x3f72d7=>!_0x3f72d7[_0x1c8156(0xe0)]&&_0x3f72d7[_0x1c8156(0xf2)]);if(_0xc36a91[_0x1c8156(0xd3)]>0x0)for(const _0x2289ad of _0xc36a91){const _0x4a7ff9=_0x2289ad[_0x1c8156(0xcd)]?_0x2289ad['folderPath']+'/'+_0x2289ad['yamlConfig'][_0x1c8156(0x9f)]:_0x2289ad[_0x1c8156(0x9c)][_0x1c8156(0x9f)];console['error']('\x0a'+a35_0x526ed4[_0x1c8156(0xc3)](_0x1c8156(0xe3))+'\x20'+_0x4a7ff9),console[_0x1c8156(0xb7)]('─'[_0x1c8156(0xa0)](0x3c)),console[_0x1c8156(0xb7)](_0x2289ad[_0x1c8156(0xf2)]),console[_0x1c8156(0xb7)]('─'['repeat'](0x3c));}if(_0x5b4148['dryRun'])return console['error'](a35_0x526ed4['yellow'](_0x1c8156(0x8d))),0x0;const _0x26853b=_0x1b3466[_0x1c8156(0xd3)]>0x0||_0x53ab62[_0x1c8156(0xd3)]>0x0||_0x3948c6[_0x1c8156(0xd3)]>0x0,_0x4f632f=_0x543ca2[_0x1c8156(0xd3)]>0x0,_0x141513=_0x1122b8['length']>0x0;if(!_0x26853b&&!_0x4f632f&&!_0x141513)return console[_0x1c8156(0xb7)](a35_0x526ed4['green']('✔\x20All\x20segments\x20and\x20activations\x20are\x20up\x20to\x20date')),0x0;const _0x5ab61d=_0x1b3466[_0x1c8156(0xd3)]+_0x53ab62[_0x1c8156(0xd3)]+_0x3948c6['length']+_0x1122b8[_0x1c8156(0xd3)]+_0x543ca2[_0x1c8156(0xd3)];if(!_0x5b4148[_0x1c8156(0xf6)]&&_0x5ab61d>0x0){const _0x2d07ce=await confirmKey('Push\x20'+_0x5ab61d+_0x1c8156(0xcc));if(!_0x2d07ce)return console[_0x1c8156(0xb7)](_0x1c8156(0x99)),0x1;}for(const _0x3c440e of _0x1122b8){const _0x3a0fe4=_0x3c440e['split']('/'),_0x2c2988=_0x3a0fe4[_0x3a0fe4[_0x1c8156(0xd3)]-0x1],_0x38c6ea=_0x3a0fe4[_0x1c8156(0xd7)](0x0,-0x1)[_0x1c8156(0xe6)]('/'),_0x4580ea=_0x6f5a5f[_0x1c8156(0xa6)](_0x38c6ea),_0x1fe18f={'name':_0x2c2988,'parentFolderId':_0x4580ea},_0x4a3dde=await withSpinner(_0x1c8156(0xf8)+_0x3c440e+'\x27...',()=>_0x2b54e0['segment'][_0x1c8156(0xab)](_0x4122f8,_0x1fe18f),{'verbose':_0x5b4148['verbose']});_0x6f5a5f[_0x1c8156(0xe2)](_0x3c440e,_0x4a3dde[_0x1c8156(0xf5)]['id']),console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xe1)](_0x1c8156(0xc5)+_0x3c440e+'\x27'));}let _0x1a64f2=0x0,_0x536b6c=0x0,_0x3ab7d5=0x0,_0x72ec77=0x0,_0x3c7aab=0x0,_0x38c1ad=0x0;const _0x5c3954=new Map();for(const _0x1c4d0d of _0x2db2b5){const _0x40ce2f=_0x1c4d0d[_0x1c8156(0xcd)]?_0x6f5a5f['get'](_0x1c4d0d[_0x1c8156(0xcd)]):undefined;let _0x3e75ec;try{if(_0x1c4d0d[_0x1c8156(0xe0)]){const _0x54b83b=yamlToCreateRequest(_0x1c4d0d[_0x1c8156(0x9c)],_0x40ce2f),_0x4a1f7b=await withSpinner('Creating\x20segment\x20\x27'+_0x1c4d0d['yamlConfig'][_0x1c8156(0x9f)]+'\x27...',()=>_0x2b54e0[_0x1c8156(0x87)]['createSegment'](_0x4122f8,_0x54b83b),{'verbose':_0x5b4148[_0x1c8156(0x92)]});_0x3e75ec=_0x4a1f7b[_0x1c8156(0xf5)]['id'],_0x5c3954['set'](_0x1c4d0d[_0x1c8156(0x9c)][_0x1c8156(0x9f)],_0x3e75ec),console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xbf)](_0x1c8156(0xf9)+_0x1c4d0d[_0x1c8156(0x9c)]['name']+'\x27')),_0x1a64f2++;}else{if(_0x1c4d0d['hasChanges']){const _0x3fb3dd=yamlToUpdateRequest(_0x1c4d0d[_0x1c8156(0x9c)]);_0x40ce2f!==_0x1c4d0d[_0x1c8156(0xa4)]?.[_0x1c8156(0xd9)]&&(_0x3fb3dd[_0x1c8156(0xd9)]=_0x40ce2f?parseInt(_0x40ce2f,0xa):undefined),await withSpinner(_0x1c8156(0x9a)+_0x1c4d0d['yamlConfig']['name']+_0x1c8156(0xd8),()=>_0x2b54e0[_0x1c8156(0x87)][_0x1c8156(0x83)](_0x4122f8,_0x1c4d0d['existingSegment']['id'],_0x3fb3dd),{'verbose':_0x5b4148['verbose']}),_0x3e75ec=_0x1c4d0d[_0x1c8156(0xa4)]['id'],console[_0x1c8156(0xb7)](a35_0x526ed4['yellow']('✔\x20Updated\x20segment\x20\x27'+_0x1c4d0d[_0x1c8156(0x9c)][_0x1c8156(0x9f)]+'\x27')),_0x536b6c++;}else _0x3e75ec=_0x1c4d0d[_0x1c8156(0xa4)]['id'];}}catch(_0x1bf8cf){const _0x35a673=isHttp400Error(_0x1bf8cf),_0x4c5362=_0x35a673?ErrorCode[_0x1c8156(0xde)]:ErrorCode[_0x1c8156(0xd1)],_0x5d13ce=getErrorMessage(_0x1bf8cf);throw new SDKError(_0x4c5362,'Failed\x20to\x20'+(_0x1c4d0d['isNew']?_0x1c8156(0xb6):_0x1c8156(0x95))+_0x1c8156(0xae)+_0x1c4d0d[_0x1c8156(0x9e)]+'\x0a\x20\x20'+_0x5d13ce,_0x1bf8cf);}for(const _0x382052 of _0x1c4d0d[_0x1c8156(0x97)]){try{if(_0x382052[_0x1c8156(0xec)]===_0x1c8156(0xb6)&&_0x382052[_0x1c8156(0x77)]){const _0x4c30dc=yamlActivationToCreateRequest(_0x382052[_0x1c8156(0x77)],_0x4d5d27,_0x316853);await withSpinner('Creating\x20activation\x20\x27'+_0x382052[_0x1c8156(0x9f)]+_0x1c8156(0xd8),()=>_0x2b54e0[_0x1c8156(0x87)][_0x1c8156(0x94)](_0x4122f8,_0x3e75ec,_0x4c30dc),{'verbose':_0x5b4148[_0x1c8156(0x92)]}),console['error'](a35_0x526ed4['green'](_0x1c8156(0xac)+_0x382052[_0x1c8156(0x9f)]+'\x27')),_0x72ec77++;}else{if(_0x382052[_0x1c8156(0xec)]===_0x1c8156(0x95)&&_0x382052[_0x1c8156(0x77)]&&_0x382052[_0x1c8156(0xeb)]){const _0x5047ee=yamlActivationToUpdateRequest(_0x382052['yamlActivation'],_0x4d5d27,_0x316853);await withSpinner(_0x1c8156(0xe9)+_0x382052['name']+'\x27...',()=>_0x2b54e0['segment'][_0x1c8156(0xd2)](_0x4122f8,_0x3e75ec,_0x382052[_0x1c8156(0xeb)]['id'],_0x5047ee),{'verbose':_0x5b4148['verbose']}),console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xc3)](_0x1c8156(0xe5)+_0x382052[_0x1c8156(0x9f)]+'\x27')),_0x3c7aab++;}else _0x382052[_0x1c8156(0xec)]===_0x1c8156(0xfb)&&_0x382052['existingActivation']&&(await withSpinner(_0x1c8156(0x72)+_0x382052['name']+_0x1c8156(0xd8),()=>_0x2b54e0[_0x1c8156(0x87)][_0x1c8156(0xcb)](_0x4122f8,_0x3e75ec,_0x382052[_0x1c8156(0xeb)]['id']),{'verbose':_0x5b4148[_0x1c8156(0x92)]}),console['error'](a35_0x526ed4[_0x1c8156(0xc4)](_0x1c8156(0xc2)+_0x382052[_0x1c8156(0x9f)]+'\x27')),_0x38c1ad++);}}catch(_0x2eb847){const _0x153b42=isHttp400Error(_0x2eb847),_0x1fff67=_0x153b42?ErrorCode['ACTIVATION_SYNTAX_ERROR']:ErrorCode[_0x1c8156(0x98)],_0x4a6ca1=getErrorMessage(_0x2eb847);throw new SDKError(_0x1fff67,_0x1c8156(0xe7)+_0x382052[_0x1c8156(0xec)]+'\x20activation\x20\x27'+_0x382052[_0x1c8156(0x9f)]+_0x1c8156(0x71)+_0x1c4d0d[_0x1c8156(0x9e)]+'\x0a\x20\x20'+_0x4a6ca1,_0x2eb847);}}}for(const _0x18a6e3 of _0x3948c6){await withSpinner(_0x1c8156(0x8e)+_0x18a6e3[_0x1c8156(0x9f)]+'\x27...',()=>_0x2b54e0[_0x1c8156(0x87)][_0x1c8156(0xf4)](_0x18a6e3['id']),{'verbose':_0x5b4148['verbose']}),console[_0x1c8156(0xb7)](a35_0x526ed4['red']('✔\x20Deleted\x20segment\x20\x27'+_0x18a6e3['name']+'\x27')),_0x3ab7d5++;}const _0x6cbb6a=[];if(_0x1a64f2>0x0)_0x6cbb6a[_0x1c8156(0xaf)](_0x1a64f2+'\x20created');if(_0x536b6c>0x0)_0x6cbb6a[_0x1c8156(0xaf)](_0x536b6c+_0x1c8156(0x8a));if(_0x3ab7d5>0x0)_0x6cbb6a['push'](_0x3ab7d5+'\x20deleted');const _0x43b2c6=[];if(_0x72ec77>0x0)_0x43b2c6[_0x1c8156(0xaf)](_0x72ec77+_0x1c8156(0xb2));if(_0x3c7aab>0x0)_0x43b2c6['push'](_0x3c7aab+_0x1c8156(0x8a));if(_0x38c1ad>0x0)_0x43b2c6['push'](_0x38c1ad+_0x1c8156(0x8f));return console[_0x1c8156(0xb7)](a35_0x526ed4[_0x1c8156(0xbf)]('\x0a✔\x20Push\x20complete')),_0x6cbb6a[_0x1c8156(0xd3)]>0x0&&console['error'](_0x1c8156(0xb5)+_0x6cbb6a[_0x1c8156(0xe6)](',\x20')),_0x43b2c6[_0x1c8156(0xd3)]>0x0&&console[_0x1c8156(0xb7)]('\x20\x20Activations:\x20'+_0x43b2c6[_0x1c8156(0xe6)](',\x20')),0x0;}}function buildFolderPathToIdMap(_0x4424d8){const _0x57536c=a35_0x573744,_0x53ac86=new Map(),_0xa315cc=new Map();for(const _0x4e6190 of _0x4424d8){_0xa315cc[_0x57536c(0xe2)](_0x4e6190['id'],_0x4e6190);}const _0x43c9ea=new Set();for(const _0x5083bf of _0x4424d8){!_0x5083bf['parentFolderId']&&_0x43c9ea[_0x57536c(0xbb)](_0x5083bf['id']);}function _0x204c49(_0x9c5a67){const _0x4bc4c6=_0x57536c;if(_0x43c9ea[_0x4bc4c6(0xa3)](_0x9c5a67['id']))return'';if(_0x9c5a67['parentFolderId']){const _0xf23eca=_0xa315cc['get'](_0x9c5a67[_0x4bc4c6(0x6f)]);if(_0xf23eca){const _0x3e3b04=_0x204c49(_0xf23eca);return _0x3e3b04?_0x3e3b04+'/'+_0x9c5a67['name']:_0x9c5a67[_0x4bc4c6(0x9f)];}}return _0x9c5a67[_0x4bc4c6(0x9f)];}for(const _0x1fad6a of _0x4424d8){const _0x5405ef=_0x204c49(_0x1fad6a);_0x53ac86[_0x57536c(0xe2)](_0x5405ef,_0x1fad6a['id']);}return _0x53ac86;}function findYamlFiles(_0x5038ab){const _0x26f2bf=[];function _0x1ad606(_0x2123c1){const _0x117043=a35_0x99f9,_0x3c2434=readdirSync(_0x2123c1,{'withFileTypes':!![]});for(const _0x59a0c8 of _0x3c2434){const _0x3a53da=a35_0x186522[_0x117043(0xe6)](_0x2123c1,_0x59a0c8[_0x117043(0x9f)]);if(_0x59a0c8[_0x117043(0xdb)]())_0x1ad606(_0x3a53da);else(_0x59a0c8[_0x117043(0x9f)][_0x117043(0xc1)]('.yml')||_0x59a0c8[_0x117043(0x9f)][_0x117043(0xc1)](_0x117043(0xbc)))&&_0x26f2bf[_0x117043(0xaf)](_0x3a53da);}}return _0x1ad606(_0x5038ab),_0x26f2bf;}function a35_0x99f9(_0x4d8b2a,_0x4391ef){_0x4d8b2a=_0x4d8b2a-0x6e;const _0x3645b7=a35_0x3645();let _0x99f981=_0x3645b7[_0x4d8b2a];return _0x99f981;}function calculateActivationActions(_0x3190ea,_0x3ee484,_0x1a99bd,_0x2746eb){const _0x277956=a35_0x573744,_0x8b813b=[],_0x5dbb3f=new Map();for(const _0x195d4e of _0x3ee484){_0x5dbb3f[_0x277956(0xe2)](_0x195d4e['name'],_0x195d4e);}const _0x5d4842=new Map();for(const _0x1d54c7 of _0x3190ea){_0x5d4842[_0x277956(0xe2)](_0x1d54c7[_0x277956(0x9f)],_0x1d54c7);}for(const _0x2350fd of _0x3190ea){const _0x59bc13=_0x5dbb3f['get'](_0x2350fd[_0x277956(0x9f)]);if(!_0x59bc13)_0x8b813b[_0x277956(0xaf)]({'type':_0x277956(0xb6),'name':_0x2350fd[_0x277956(0x9f)],'yamlActivation':_0x2350fd});else{const _0x38e028=activationToYaml(_0x59bc13,_0x1a99bd,_0x2746eb),_0x928a96=a35_0x4dfc51[_0x277956(0x85)](_0x38e028),_0x47702b=a35_0x4dfc51['stringify'](_0x2350fd);_0x928a96!==_0x47702b&&_0x8b813b[_0x277956(0xaf)]({'type':_0x277956(0x95),'name':_0x2350fd[_0x277956(0x9f)],'yamlActivation':_0x2350fd,'existingActivation':_0x59bc13});}}for(const _0x34905a of _0x3ee484){!_0x5d4842[_0x277956(0xa3)](_0x34905a['name'])&&_0x8b813b[_0x277956(0xaf)]({'type':'delete','name':_0x34905a[_0x277956(0x9f)],'existingActivation':_0x34905a});}return _0x8b813b;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a36_0x500a(_0x3007fc,_0x4949b1){_0x3007fc=_0x3007fc-0x80;const _0x99a427=a36_0x99a4();let _0x500a35=_0x99a427[_0x3007fc];return _0x500a35;}function a36_0x99a4(){const _0xff63e1=['9614108HzCpfo','Resolved\x20relative\x20path\x20to:\x20','11271240JigowQ','updateSegmentById','data','error','40852EsKIgy','Use:\x20tdx\x20segment\x20update\x20<path_to_segment>\x20[options]','4663000vCrSxZ','segmentName','5GsmfSC','length','Segment\x20ID\x20missing\x20from\x20resolved\x20path','yellow','segment:update','ruleFile','.\x20Only\x20child\x20segments\x20can\x20be\x20updated.','Error:\x20Cannot\x20update\x20','resolvePathToResource','12aBgNYS','verbose','Parent\x20ID:\x20','\x20\x20tdx\x20segment\x20update\x20\x22My\x20Audience/High\x20Value\x22\x20--description\x20\x22...\x22','✔\x20Updated\x20segment\x20\x27','type','Usage:\x20tdx\x20segment\x20update\x20<path>\x20[options]','32985139zsMLuK','Segment\x20ID:\x20','\x20\x20Use\x20`tdx\x20sg\x20push`\x20with\x20YAML\x20files\x20instead.\x0a','segment','4EdcBJC','Error:\x20Segment\x20path\x20or\x20name\x20is\x20required','segmentId','\x27...','\x20\x20tdx\x20segment\x20update\x20\x22High\x20Value\x22\x20--rule\x20\x27...\x27\x20\x20#\x20Relative\x20to\x20context','folder','rule','Updating\x20segment\x20\x27','description','Update\x20existing\x20child\x20segment','Resolving\x20path\x20\x27','7526814ZymQcq','includes','execute','370742bYyEaQ','⚠\x20Deprecation\x20warning:\x20`segment\x20update`\x20is\x20deprecated.','417gfkbuw','kind','parentId','27PBTKcz'];a36_0x99a4=function(){return _0xff63e1;};return a36_0x99a4();}const a36_0x47cd23=a36_0x500a;(function(_0x2ca5f9,_0x1e2cfb){const _0x433f20=a36_0x500a,_0x395992=_0x2ca5f9();while(!![]){try{const _0x21453c=-parseInt(_0x433f20(0x98))/0x1*(parseInt(_0x433f20(0xa6))/0x2)+parseInt(_0x433f20(0xa8))/0x3*(-parseInt(_0x433f20(0x80))/0x4)+-parseInt(_0x433f20(0x84))/0x5*(-parseInt(_0x433f20(0xa3))/0x6)+-parseInt(_0x433f20(0xac))/0x7+parseInt(_0x433f20(0xae))/0x8+parseInt(_0x433f20(0xab))/0x9*(-parseInt(_0x433f20(0x82))/0xa)+parseInt(_0x433f20(0x94))/0xb*(parseInt(_0x433f20(0x8d))/0xc);if(_0x21453c===_0x1e2cfb)break;else _0x395992['push'](_0x395992['shift']());}catch(_0x49fc99){_0x395992['push'](_0x395992['shift']());}}}(a36_0x99a4,0xb1e0c));import{BaseCommand}from'./command.js';import{handleSDKOutput}from'../utils/command-output.js';import{withSpinner}from'../utils/spinner.js';import{loadJSONFromOptions}from'../utils/json-loader.js';import{SDKError,ErrorCode}from'../sdk/index.js';import a36_0x191cef from'chalk';export class SegmentUpdateCommand extends BaseCommand{['name']=a36_0x47cd23(0x88);[a36_0x47cd23(0xa0)]=a36_0x47cd23(0xa1);async[a36_0x47cd23(0xa5)](_0x14e899){const _0x5a064d=a36_0x47cd23;console[_0x5a064d(0xb1)](a36_0x191cef[_0x5a064d(0x87)](_0x5a064d(0xa7))),console[_0x5a064d(0xb1)](a36_0x191cef[_0x5a064d(0x87)](_0x5a064d(0x96)));const {options:_0x4cc7e5,args:_0x552992,tdx:_0x17ad10}=_0x14e899,_0x11b872=_0x4cc7e5;if(_0x552992[_0x5a064d(0x85)]===0x0)return console[_0x5a064d(0xb1)](_0x5a064d(0x99)),console[_0x5a064d(0xb1)](_0x5a064d(0x93)),console[_0x5a064d(0xb1)]('Examples:'),console['error'](_0x5a064d(0x90)),console[_0x5a064d(0xb1)](_0x5a064d(0x9c)),0x1;const _0x1fbbdd=_0x552992[0x0],_0x2bef7b=_0x4cc7e5['segmentPath'];let _0x5bbdc3=_0x1fbbdd;_0x2bef7b&&!_0x1fbbdd[_0x5a064d(0xa4)]('/')&&(_0x5bbdc3=_0x2bef7b+'/'+_0x1fbbdd,_0x11b872['verbose']&&console[_0x5a064d(0xb1)](_0x5a064d(0xad)+_0x5bbdc3));const _0x1962be=await withSpinner(_0x5a064d(0xa2)+_0x5bbdc3+_0x5a064d(0x9b),()=>_0x17ad10[_0x5a064d(0x97)][_0x5a064d(0x8c)](_0x5bbdc3),{'verbose':_0x11b872['verbose']}),_0x9409d1=_0x1962be[_0x5a064d(0xb0)];_0x11b872['verbose']&&console[_0x5a064d(0xb1)]('Resolved\x20type:\x20'+_0x9409d1['type']);if(_0x9409d1[_0x5a064d(0x92)]!==_0x5a064d(0x97))return console['error'](_0x5a064d(0x8b)+_0x9409d1[_0x5a064d(0x92)]+_0x5a064d(0x8a)),console[_0x5a064d(0xb1)](_0x5a064d(0x81)),0x1;if(!_0x9409d1['segmentId'])throw new SDKError(ErrorCode['INTERNAL'],_0x5a064d(0x86));const _0x11712b=_0x9409d1[_0x5a064d(0xaa)],_0x33401b=_0x9409d1[_0x5a064d(0x9a)];_0x11b872[_0x5a064d(0x8e)]&&(console['error'](_0x5a064d(0x8f)+_0x11712b),console[_0x5a064d(0xb1)](_0x5a064d(0x95)+_0x33401b));let _0x54a9f7;if(_0x11b872['folder']){const _0xca6d54=_0x11b872[_0x5a064d(0x9d)],_0x409381=await withSpinner('Resolving\x20folder\x20\x27'+_0xca6d54+'\x27...',()=>_0x17ad10['segment']['resolveFolderId'](_0x11712b,_0xca6d54),{'verbose':_0x11b872['verbose']});_0x54a9f7=parseInt(_0x409381[_0x5a064d(0xb0)],0xa),_0x11b872['verbose']&&console['error']('Resolved\x20folder\x20ID:\x20'+_0x54a9f7);}const _0x9a4d9b=await loadJSONFromOptions(_0x11b872[_0x5a064d(0x9e)],_0x11b872[_0x5a064d(0x89)]),_0x53afc2={'name':_0x11b872['name'],'description':_0x11b872[_0x5a064d(0xa0)],'rule':_0x9a4d9b,'kind':_0x11b872['kind']!==undefined?parseInt(_0x11b872[_0x5a064d(0xa9)],0xa):undefined,'segmentFolderId':_0x54a9f7},_0x1628c7=await withSpinner(_0x5a064d(0x9f)+_0x9409d1[_0x5a064d(0x83)]+_0x5a064d(0x9b),()=>_0x17ad10[_0x5a064d(0x97)][_0x5a064d(0xaf)](_0x11712b,_0x33401b,_0x53afc2),{'verbose':_0x11b872[_0x5a064d(0x8e)]}),_0x5a0c1=_0x1628c7['data'];return console[_0x5a064d(0xb1)](_0x5a064d(0x91)+_0x5a0c1['name']+'\x27'),_0x5bbdc3!==_0x1fbbdd&&console[_0x5a064d(0xb1)]('\x20\x20\x20Path:\x20'+_0x5bbdc3),await handleSDKOutput([_0x5a0c1],_0x11b872),0x0;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a37_0x50fe(_0x985a4,_0x49b580){_0x985a4=_0x985a4-0x1e5;const _0x1be2cf=a37_0x1be2();let _0x50fe79=_0x1be2cf[_0x985a4];return _0x50fe79;}const a37_0x1a3324=a37_0x50fe;(function(_0x452a27,_0x465d26){const _0x3fe744=a37_0x50fe,_0x1faf1c=_0x452a27();while(!![]){try{const _0x669c60=-parseInt(_0x3fe744(0x208))/0x1+parseInt(_0x3fe744(0x1e7))/0x2*(-parseInt(_0x3fe744(0x218))/0x3)+parseInt(_0x3fe744(0x1fd))/0x4+-parseInt(_0x3fe744(0x214))/0x5+-parseInt(_0x3fe744(0x1fc))/0x6+parseInt(_0x3fe744(0x1ea))/0x7+-parseInt(_0x3fe744(0x21e))/0x8*(-parseInt(_0x3fe744(0x202))/0x9);if(_0x669c60===_0x465d26)break;else _0x1faf1c['push'](_0x1faf1c['shift']());}catch(_0x2b89f1){_0x1faf1c['push'](_0x1faf1c['shift']());}}}(a37_0x1be2,0x70bcd));import{existsSync,statSync}from'fs';import a37_0x43aa8a from'chalk';function a37_0x1be2(){const _0x22c459=['fullPath','folderId','length','cyan','\x27...','segmentPath','slice','2876595QnFDUR','segments','parent_segment','parentId','115143RxSURz','description','Error:\x20No\x20tdx.json\x20found\x20in\x20or\x20above:\x20','Use\x20\x22tdx\x20context\x22\x20to\x20see\x20all\x20context\x20parameters','data','execute','24049448VpNvBm','Site:\x20','log','error','Resolved\x20path\x20type:\x20','38FMtbRt','Resolved\x20relative\x20path\x20to:\x20','folderPath','1499218oqhUmg','segment','Folder\x20ID:\x20','Tip:\x20Run\x20`tdx\x20sg\x20pull\x20<parent_name>`\x20first\x20to\x20create\x20the\x20folder\x20structure','Set\x20current\x20segment/folder\x20context\x20for\x20navigation','parentName','Resolving\x20path\x20\x27','site','Target\x20path:\x20','isAbsolute','Use\x20an\x20absolute\x20path\x20or\x20set\x20context\x20with:\x20tdx\x20segment\x20use\x20<parent_name>','red','✔\x20Context\x20set\x20to:\x20','split','Use\x20\x22tdx\x20segments\x22\x20to\x20list\x20contents\x20in\x20this\x20context','\x20\x20tdx\x20segment\x20use\x20\x22My\x20Audience\x22','dim','Usage:\x20tdx\x20segment\x20use\x20<path>','5025318tdTDSh','937548tHLOSN','Examples:','Use:\x20tdx\x20segment\x20use\x20','isDirectory','Context\x20can\x20only\x20be\x20set\x20to\x20a\x20parent\x20segment\x20or\x20folder.','9biAKlx','name','join','config','verbose','Error:\x20Cannot\x20set\x20context\x20to\x20a\x20segment.','850858UHmgzm','resolvePathToResource','✔\x20Context\x20cleared.\x20Back\x20to\x20root.','\x20\x20tdx\x20segment\x20use\x20..\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Go\x20to\x20parent','green'];a37_0x1be2=function(){return _0x22c459;};return a37_0x1be2();}import{BaseCommand}from'./command.js';import{saveSessionContext}from'../core/session.js';import{withSpinner}from'../utils/spinner.js';import{parsePath,normalizePath}from'../utils/segment-path-parser.js';import{findTdxConfig}from'../utils/tdx-config.js';export class SegmentUseCommand extends BaseCommand{[a37_0x1a3324(0x203)]='segment:use';[a37_0x1a3324(0x219)]=a37_0x1a3324(0x1ee);async[a37_0x1a3324(0x21d)](_0x253ada){const _0x376a5c=a37_0x1a3324,{options:_0x4044ff,args:_0x4ca11d,tdx:_0xd3dbcc}=_0x253ada;if(_0x4ca11d['length']===0x0)return console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x1f5)]('Error:\x20Path\x20is\x20required\x0a')),console[_0x376a5c(0x1e5)](_0x376a5c(0x1fb)),console[_0x376a5c(0x1e5)](_0x376a5c(0x1fe)),console[_0x376a5c(0x1e5)](_0x376a5c(0x1f9)),console['error']('\x20\x20tdx\x20segment\x20use\x20\x22My\x20Audience/Marketing\x22'),console[_0x376a5c(0x1e5)]('\x20\x20tdx\x20segment\x20use\x20/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Clear\x20context'),console['error'](_0x376a5c(0x20b)),0x1;const _0x355880=_0x4ca11d[0x0],_0x3fcb51=_0x4044ff['session'];try{if(_0x355880==='/')return saveSessionContext({'segment_path':undefined},_0x3fcb51),console['log'](a37_0x43aa8a['green']('✔\x20Context\x20cleared.\x20Back\x20to\x20root.')),0x0;if(existsSync(_0x355880)&&statSync(_0x355880)[_0x376a5c(0x200)]()){let _0x17e7fb;try{_0x17e7fb=findTdxConfig(_0x355880);}catch{return console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x1f5)](_0x376a5c(0x21a)+_0x355880)),console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x210)](_0x376a5c(0x1ed))),0x1;}const _0x42a2ed=_0x17e7fb[_0x376a5c(0x205)][_0x376a5c(0x216)];return saveSessionContext({'segment_path':_0x42a2ed,'parent_segment':_0x42a2ed},_0x3fcb51),console[_0x376a5c(0x220)](a37_0x43aa8a[_0x376a5c(0x20c)](_0x376a5c(0x1f6)+a37_0x43aa8a[_0x376a5c(0x210)](_0x42a2ed))),0x0;}const _0x147d0c=_0x4044ff[_0x376a5c(0x212)];let _0x17f262=_0x355880;const _0x390861=parsePath(_0x355880);if(!_0x390861[_0x376a5c(0x1f3)]){if(!_0x147d0c)return console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x1f5)]('Error:\x20No\x20context\x20set.\x20Cannot\x20use\x20relative\x20path.')),console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x210)](_0x376a5c(0x1f4))),0x1;if(_0x355880==='..'){const _0x363326=_0x147d0c[_0x376a5c(0x1f7)]('/')[_0x376a5c(0x213)](0x0,-0x1)[_0x376a5c(0x204)]('/');_0x17f262=_0x363326||'/';}else _0x355880==='.'?_0x17f262=_0x147d0c:_0x17f262=_0x147d0c+'/'+_0x355880;_0x4044ff[_0x376a5c(0x206)]&&console[_0x376a5c(0x1e5)](_0x376a5c(0x1e8)+_0x17f262);}if(_0x17f262==='/'||_0x17f262==='')return saveSessionContext({'segment_path':undefined},_0x3fcb51),console[_0x376a5c(0x220)](a37_0x43aa8a['green'](_0x376a5c(0x20a))),0x0;_0x17f262=normalizePath(_0x17f262);const _0x6535c=parsePath(_0x17f262)[_0x376a5c(0x215)];if(_0x6535c[_0x376a5c(0x20f)]===0x0)return saveSessionContext({'segment_path':undefined},_0x3fcb51),console[_0x376a5c(0x220)](a37_0x43aa8a[_0x376a5c(0x20c)]('✔\x20Context\x20cleared.\x20Back\x20to\x20root.')),0x0;_0x4044ff[_0x376a5c(0x206)]&&(console[_0x376a5c(0x1e5)](_0x376a5c(0x21f)+_0x4044ff[_0x376a5c(0x1f1)]),console[_0x376a5c(0x1e5)](_0x376a5c(0x1f2)+_0x17f262));const _0xc13493=await withSpinner(_0x376a5c(0x1f0)+_0x17f262+_0x376a5c(0x211),()=>_0xd3dbcc['segment'][_0x376a5c(0x209)](_0x17f262),{'verbose':_0x4044ff[_0x376a5c(0x206)]}),_0x389e0c=_0xc13493[_0x376a5c(0x21c)];_0x4044ff['verbose']&&(console['error'](_0x376a5c(0x1e6)+_0x389e0c['type']),console[_0x376a5c(0x1e5)]('Parent\x20ID:\x20'+_0x389e0c[_0x376a5c(0x217)]),_0x389e0c[_0x376a5c(0x20e)]&&console[_0x376a5c(0x1e5)](_0x376a5c(0x1ec)+_0x389e0c[_0x376a5c(0x20e)]));if(_0x389e0c['type']===_0x376a5c(0x1eb))return console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x1f5)](_0x376a5c(0x207))),console['error'](_0x376a5c(0x201)),console[_0x376a5c(0x1e5)](a37_0x43aa8a[_0x376a5c(0x210)](_0x376a5c(0x1ff)+_0x389e0c[_0x376a5c(0x1ef)]+(_0x389e0c['folderPath']?'/'+_0x389e0c[_0x376a5c(0x1e9)][_0x376a5c(0x204)]('/'):''))),0x1;return saveSessionContext({'segment_path':_0x389e0c[_0x376a5c(0x20d)],'parent_segment':_0x389e0c[_0x376a5c(0x1ef)]},_0x3fcb51),console[_0x376a5c(0x220)](a37_0x43aa8a[_0x376a5c(0x20c)](_0x376a5c(0x1f6)+a37_0x43aa8a[_0x376a5c(0x210)](_0x389e0c[_0x376a5c(0x20d)]))),_0x4044ff['verbose']&&(console['error'](a37_0x43aa8a[_0x376a5c(0x1fa)](_0x376a5c(0x1f8))),console['error'](a37_0x43aa8a[_0x376a5c(0x1fa)](_0x376a5c(0x21b)))),0x0;}catch(_0x258c39){throw _0x258c39;}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a38_0x292ed6=a38_0x34a3;(function(_0x365d84,_0x31f9e6){const _0xd5d83c=a38_0x34a3,_0x4c6d9d=_0x365d84();while(!![]){try{const _0x336c4a=parseInt(_0xd5d83c(0x1f4))/0x1*(parseInt(_0xd5d83c(0x1cc))/0x2)+-parseInt(_0xd5d83c(0x1c8))/0x3*(parseInt(_0xd5d83c(0x1ec))/0x4)+-parseInt(_0xd5d83c(0x1f3))/0x5*(parseInt(_0xd5d83c(0x1db))/0x6)+parseInt(_0xd5d83c(0x1d4))/0x7*(-parseInt(_0xd5d83c(0x1d6))/0x8)+-parseInt(_0xd5d83c(0x1cf))/0x9+-parseInt(_0xd5d83c(0x1d9))/0xa+parseInt(_0xd5d83c(0x1c6))/0xb*(parseInt(_0xd5d83c(0x1c9))/0xc);if(_0x336c4a===_0x31f9e6)break;else _0x4c6d9d['push'](_0x4c6d9d['shift']());}catch(_0x5b3911){_0x4c6d9d['push'](_0x4c6d9d['shift']());}}}(a38_0x27a2,0x86ad5));function a38_0x27a2(){const _0x24230c=['Resolving\x20parent\x20segment\x20\x27','includes','List\x20folders\x20and\x20child\x20segments','folder','json','sort','Site:\x20','listWithPattern','\x5c$&','test','Recursive\x20mode:\x20enabled','recursive','82676JIJFxS','\x20\x20tdx\x20sg\x20use\x20\x22My\x20Audience\x22','segment','✔\x20Found\x20',']\x20matching\x20\x27','map','listUnified','5vlvwFO','26ZHPpel','listRecursive','parentSegment','format','Error:\x20','Listing\x20folders\x20and\x20segments...','Building\x20hierarchy\x20tree...','cause','Error:\x20No\x20parent\x20segment\x20context\x20set.','jsonl','\x20folder','✔\x20Built\x20tree\x20with\x20','parentId','message','log','replace','error','Parent\x20segment\x20context:\x20','length','site','filter','\x27...','verbose','name','description','30974779cqlqRX','folderId','81cDMUed','12oqVPVG','/e/','resolvePathToResource','78120rhZxzM','Parent\x20ID:\x20','dim','7552224hUNyTA','\x20\x20tdx\x20sg\x20pull\x20\x22My\x20Audience\x22','web','localeCompare','No\x20items\x20match\x20pattern:\x20','28byzILH','(not\x20set)','1113944AkhUfH','Folder\x20ID:\x20','execute','2757480awmfhP','/app/ps/','6299358IjKsmg','\x20segment','Use\x20tdx\x20ps\x20list\x20to\x20see\x20available\x20parent\x20segments.','Resolving\x20path\x20\x27','data'];a38_0x27a2=function(){return _0x24230c;};return a38_0x27a2();}import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';function a38_0x34a3(_0x4883a8,_0x280fd4){_0x4883a8=_0x4883a8-0x1c4;const _0x27a2a0=a38_0x27a2();let _0x34a347=_0x27a2a0[_0x4883a8];return _0x34a347;}import{handleSDKOutput}from'../utils/command-output.js';import{withSpinner}from'../utils/spinner.js';import{formatFlatList,formatTree}from'../utils/tree-formatter.js';import{getConsoleNextUrl}from'../types/endpoints.js';import a38_0x5ab810 from'chalk';export class SegmentsCommand extends BaseCommand{[a38_0x292ed6(0x1c4)]='segments';[a38_0x292ed6(0x1c5)]=a38_0x292ed6(0x1e2);async[a38_0x292ed6(0x1d8)](_0x5f181d){const _0x1a5f60=a38_0x292ed6,{options:_0x2c54b7,args:_0x5f286e}=_0x5f181d,_0x1b4e81=_0x2c54b7[_0x1a5f60(0x1eb)],_0x4c4b6d=_0x5f286e[0x0];try{const _0xe13d60=_0x2c54b7[_0x1a5f60(0x1f6)];_0x2c54b7[_0x1a5f60(0x20a)]&&(console['error'](_0x1a5f60(0x1e6)+_0x2c54b7[_0x1a5f60(0x207)]),console[_0x1a5f60(0x204)](_0x1a5f60(0x205)+(_0xe13d60||_0x1a5f60(0x1d5))),_0x4c4b6d&&console[_0x1a5f60(0x204)]('Folder/pattern\x20arg:\x20'+_0x4c4b6d),_0x1b4e81&&console['error'](_0x1a5f60(0x1ea)));if(!_0xe13d60)return console['error'](_0x1a5f60(0x1fc)),console['error'](''),console['error']('Set\x20a\x20parent\x20segment\x20context\x20first:'),console['error'](_0x1a5f60(0x1d0)),console[_0x1a5f60(0x204)](_0x1a5f60(0x1ed)),console[_0x1a5f60(0x204)](''),console[_0x1a5f60(0x204)](_0x1a5f60(0x1dd)),0x1;const _0x26aa64=_0x4c4b6d&&(_0x4c4b6d['includes']('*')||_0x4c4b6d[_0x1a5f60(0x1e1)]('?'));if(_0x26aa64)return await this[_0x1a5f60(0x1e7)](_0x5f181d,_0xe13d60,_0x4c4b6d);const _0x124f73=_0x4c4b6d?_0xe13d60+'/'+_0x4c4b6d:_0xe13d60;return _0x1b4e81?await this[_0x1a5f60(0x1f5)](_0x5f181d,_0x124f73):await this[_0x1a5f60(0x1f2)](_0x5f181d,_0x124f73);}catch(_0x1e4142){if(_0x1e4142 instanceof SDKError)return console['error'](_0x1a5f60(0x1f8)+_0x1e4142[_0x1a5f60(0x201)]),_0x1e4142[_0x1a5f60(0x1fb)]&&console['error']('\x20\x20Cause:\x20'+_0x1e4142['cause']),0x1;throw _0x1e4142;}}async['listWithPattern'](_0x748acd,_0x539d4e,_0x4fd78b){const _0x4e4c3f=a38_0x292ed6,{options:_0x3c97d1,tdx:_0x5bca1b}=_0x748acd,_0x524699=_0x3c97d1[_0x4e4c3f(0x1d1)],_0x27d766=await withSpinner(_0x4e4c3f(0x1e0)+_0x539d4e+_0x4e4c3f(0x209),()=>_0x5bca1b['segment']['resolvePathToResource'](_0x539d4e),{'verbose':_0x3c97d1[_0x4e4c3f(0x20a)]}),_0x213cc7=_0x27d766[_0x4e4c3f(0x1df)],_0x223a89=await withSpinner(_0x4e4c3f(0x1f9),()=>_0x5bca1b[_0x4e4c3f(0x1ee)][_0x4e4c3f(0x1f2)](_0x213cc7[_0x4e4c3f(0x200)],_0x213cc7[_0x4e4c3f(0x1c7)]),{'verbose':_0x3c97d1['verbose']}),{folders:_0x2b759a,segments:_0x20bc39}=_0x223a89['data'],_0x26818c=_0x4fd78b['replace'](/[.+^${}()|[\]\\]/g,_0x4e4c3f(0x1e8))[_0x4e4c3f(0x203)](/\*/g,'.*')[_0x4e4c3f(0x203)](/\?/g,'.'),_0x39ebdb=new RegExp('^'+_0x26818c+'$','i'),_0x459ba9=_0x2b759a[_0x4e4c3f(0x208)](_0x30c9a6=>_0x39ebdb['test'](_0x30c9a6[_0x4e4c3f(0x1c4)])),_0x5bed55=_0x20bc39[_0x4e4c3f(0x208)](_0x38e208=>_0x39ebdb[_0x4e4c3f(0x1e9)](_0x38e208[_0x4e4c3f(0x1c4)])),_0x4e20c2=_0x459ba9['length']+_0x5bed55[_0x4e4c3f(0x206)];console[_0x4e4c3f(0x204)](_0x4e4c3f(0x1ef)+_0x459ba9['length']+_0x4e4c3f(0x1fe)+(_0x459ba9['length']!==0x1?'s':'')+'\x20and\x20'+_0x5bed55['length']+_0x4e4c3f(0x1dc)+(_0x5bed55[_0x4e4c3f(0x206)]!==0x1?'s':'')+'\x20matching\x20\x27'+_0x4fd78b+'\x27');const _0x562865=_0x7453f=>{const _0x3be87f=_0x4e4c3f;return getConsoleNextUrl(_0x3c97d1[_0x3be87f(0x207)],_0x3be87f(0x1da)+_0x213cc7[_0x3be87f(0x200)]+_0x3be87f(0x1ca)+_0x7453f);},_0x5b737a=_0x3c97d1[_0x4e4c3f(0x1f7)]===_0x4e4c3f(0x1e4)||_0x3c97d1[_0x4e4c3f(0x1f7)]===_0x4e4c3f(0x1fd);if(_0x5b737a){const _0xe2fc83=[..._0x459ba9[_0x4e4c3f(0x1f1)](_0xaad1bd=>({..._0xaad1bd,'type':'folder'})),..._0x5bed55[_0x4e4c3f(0x1f1)](_0xdf68cf=>({..._0xdf68cf,'type':_0x4e4c3f(0x1ee),'url':_0x562865(_0xdf68cf['id'])}))][_0x4e4c3f(0x1e5)]((_0x2f4fd4,_0x275109)=>_0x2f4fd4[_0x4e4c3f(0x1c4)]['localeCompare'](_0x275109[_0x4e4c3f(0x1c4)]));await handleSDKOutput(_0xe2fc83,_0x3c97d1);}else{if(_0x4e20c2===0x0)console['log'](_0x4e4c3f(0x1d3)+_0x4fd78b);else{console[_0x4e4c3f(0x202)](a38_0x5ab810[_0x4e4c3f(0x1ce)]('['+_0x539d4e+_0x4e4c3f(0x1f0)+_0x4fd78b+'\x27'));const _0x242727=formatFlatList(_0x459ba9,_0x5bed55,{'showMetadata':!![],'showUrl':_0x524699,'getSegmentUrl':_0x562865});console[_0x4e4c3f(0x202)](_0x242727);}}return 0x0;}async['listUnified'](_0x1e5475,_0xd2f393){const _0x2fa56d=a38_0x292ed6,{options:_0x312bf7,tdx:_0x4ce1be}=_0x1e5475,_0x4cf655=_0x312bf7['web'],_0x141857=await withSpinner(_0x2fa56d(0x1de)+_0xd2f393+_0x2fa56d(0x209),()=>_0x4ce1be[_0x2fa56d(0x1ee)][_0x2fa56d(0x1cb)](_0xd2f393),{'verbose':_0x312bf7[_0x2fa56d(0x20a)]}),_0x1e9e84=_0x141857['data'];_0x312bf7[_0x2fa56d(0x20a)]&&(console[_0x2fa56d(0x204)](_0x2fa56d(0x1cd)+_0x1e9e84[_0x2fa56d(0x200)]),_0x1e9e84['folderId']&&console[_0x2fa56d(0x204)](_0x2fa56d(0x1d7)+_0x1e9e84['folderId']));const _0xc96a08=await withSpinner(_0x2fa56d(0x1f9),()=>_0x4ce1be[_0x2fa56d(0x1ee)][_0x2fa56d(0x1f2)](_0x1e9e84[_0x2fa56d(0x200)],_0x1e9e84[_0x2fa56d(0x1c7)]),{'verbose':_0x312bf7[_0x2fa56d(0x20a)]}),{folders:_0x5f2487,segments:_0x34618d}=_0xc96a08[_0x2fa56d(0x1df)],_0x485173=_0x5f2487[_0x2fa56d(0x206)]+_0x34618d[_0x2fa56d(0x206)];console[_0x2fa56d(0x204)](_0x2fa56d(0x1ef)+_0x5f2487[_0x2fa56d(0x206)]+_0x2fa56d(0x1fe)+(_0x5f2487[_0x2fa56d(0x206)]!==0x1?'s':'')+'\x20and\x20'+_0x34618d[_0x2fa56d(0x206)]+_0x2fa56d(0x1dc)+(_0x34618d['length']!==0x1?'s':''));const _0x23e0c8=_0x5c5728=>{const _0x15115d=_0x2fa56d;return getConsoleNextUrl(_0x312bf7[_0x15115d(0x207)],_0x15115d(0x1da)+_0x1e9e84[_0x15115d(0x200)]+'/e/'+_0x5c5728);},_0x2b0783=_0x312bf7[_0x2fa56d(0x1f7)]==='json'||_0x312bf7[_0x2fa56d(0x1f7)]==='jsonl';if(_0x2b0783){const _0xc46c4=[..._0x5f2487[_0x2fa56d(0x1f1)](_0x5331b6=>({..._0x5331b6,'type':_0x2fa56d(0x1e3)})),..._0x34618d[_0x2fa56d(0x1f1)](_0x853392=>({..._0x853392,'type':_0x2fa56d(0x1ee),'url':_0x23e0c8(_0x853392['id'])}))][_0x2fa56d(0x1e5)]((_0x247937,_0x5b4616)=>_0x247937[_0x2fa56d(0x1c4)][_0x2fa56d(0x1d2)](_0x5b4616[_0x2fa56d(0x1c4)]));await handleSDKOutput(_0xc46c4,_0x312bf7);}else{if(_0x485173===0x0)console[_0x2fa56d(0x202)](a38_0x5ab810[_0x2fa56d(0x1ce)]('['+_0xd2f393+']')),console[_0x2fa56d(0x202)]('(empty)');else{console[_0x2fa56d(0x202)](a38_0x5ab810[_0x2fa56d(0x1ce)]('['+_0xd2f393+']'));const _0x5de6d9=formatFlatList(_0x5f2487,_0x34618d,{'showMetadata':!![],'showUrl':_0x4cf655,'getSegmentUrl':_0x23e0c8});console[_0x2fa56d(0x202)](_0x5de6d9);}}return 0x0;}async[a38_0x292ed6(0x1f5)](_0x36d42a,_0x3e3cf6){const _0x540e1b=a38_0x292ed6,{options:_0x4d8b73,tdx:_0x427169}=_0x36d42a,_0x2ac378=_0x4d8b73[_0x540e1b(0x1d1)],_0x12463a=await withSpinner(_0x540e1b(0x1de)+_0x3e3cf6+_0x540e1b(0x209),()=>_0x427169[_0x540e1b(0x1ee)][_0x540e1b(0x1cb)](_0x3e3cf6),{'verbose':_0x4d8b73[_0x540e1b(0x20a)]}),_0x4ff694=_0x12463a[_0x540e1b(0x1df)];_0x4d8b73[_0x540e1b(0x20a)]&&(console[_0x540e1b(0x204)](_0x540e1b(0x1cd)+_0x4ff694[_0x540e1b(0x200)]),_0x4ff694[_0x540e1b(0x1c7)]&&console[_0x540e1b(0x204)](_0x540e1b(0x1d7)+_0x4ff694['folderId']));const _0x410a36=_0x4d8b73['maxDepth']||0xa,_0x5d87e3=await withSpinner(_0x540e1b(0x1fa),()=>_0x427169[_0x540e1b(0x1ee)]['listRecursive'](_0x4ff694[_0x540e1b(0x200)],_0x4ff694[_0x540e1b(0x1c7)],0x0,_0x410a36),{'verbose':_0x4d8b73[_0x540e1b(0x20a)]}),_0x47d5df=_0x5d87e3[_0x540e1b(0x1df)];console[_0x540e1b(0x204)](_0x540e1b(0x1ff)+_0x47d5df[_0x540e1b(0x206)]+'\x20top-level\x20items');const _0x55575d=_0x328769=>{const _0x51a7a4=_0x540e1b;return getConsoleNextUrl(_0x4d8b73[_0x51a7a4(0x207)],_0x51a7a4(0x1da)+_0x4ff694[_0x51a7a4(0x200)]+_0x51a7a4(0x1ca)+_0x328769);};if(_0x4d8b73[_0x540e1b(0x1f7)]===_0x540e1b(0x1e4)||_0x4d8b73[_0x540e1b(0x1f7)]===_0x540e1b(0x1fd))await handleSDKOutput(_0x47d5df,_0x4d8b73);else{console['log'](a38_0x5ab810[_0x540e1b(0x1ce)]('['+_0x3e3cf6+']'));const _0x276675=formatTree(_0x47d5df,{'showMetadata':!![],'showUrl':_0x2ac378,'getSegmentUrl':_0x55575d});console['log'](_0x276675);}return 0x0;}}
|
package/dist/commands/show.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a39_0xfcb0fe=a39_0x1d37;(function(_0x141afd,_0x8b11ea){const _0x2fba92=a39_0x1d37,_0x156563=_0x141afd();while(!![]){try{const _0x411347=-parseInt(_0x2fba92(0x1e5))/0x1+-parseInt(_0x2fba92(0x1e9))/0x2*(parseInt(_0x2fba92(0x1f0))/0x3)+-parseInt(_0x2fba92(0x1e6))/0x4*(-parseInt(_0x2fba92(0x1d0))/0x5)+-parseInt(_0x2fba92(0x1eb))/0x6*(-parseInt(_0x2fba92(0x1f8))/0x7)+-parseInt(_0x2fba92(0x1ef))/0x8*(parseInt(_0x2fba92(0x1f6))/0x9)+-parseInt(_0x2fba92(0x1e8))/0xa*(-parseInt(_0x2fba92(0x1d7))/0xb)+-parseInt(_0x2fba92(0x1dd))/0xc*(-parseInt(_0x2fba92(0x1e3))/0xd);if(_0x411347===_0x8b11ea)break;else _0x156563['push'](_0x156563['shift']());}catch(_0x2f6b93){_0x156563['push'](_0x156563['shift']());}}}(a39_0x2ebd,0xd917a));import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';import{handleSDKOutput}from'../utils/command-output.js';function a39_0x2ebd(){const _0x349a9f=['27PBgqBm','execute','301SnggNj','✔\x20Retrieved\x20','Site:\x20','show','catalog','site','...','5TxLJIc','\x20row','name','\x20\x20Cause:\x20','data','limit','Error:\x20','80454DNPlfg','\x20\x20\x20or:\x20tdx\x20show\x20<table>\x20--database\x20<database>','Too\x20many\x20arguments\x0aUsage:\x20tdx\x20show\x20<database.table>\x0a\x20\x20\x20or:\x20tdx\x20show\x20<table>\x20--database\x20<database>\x0a\x0aRun\x20\x27tdx\x20show\x20--help\x27\x20for\x20more\x20options','Table:\x20','Database:\x20','showTable','1107084RhPxKV','Catalog:\x20','Limit:\x20','error','verbose','query','195kxxFwy','validate','1363117NeyeYY','3190996GKYnll','length','350rmSHWl','104564diXTjm','Show\x20table\x20contents','115380UiMriB','Querying\x20','cause','✔\x20Query\x20successful\x20-\x200\x20rows\x20returned','328968WRTIeX','51dPafMC','Usage:\x20tdx\x20show\x20<database.table>','database','table','args','description'];a39_0x2ebd=function(){return _0x349a9f;};return a39_0x2ebd();}function a39_0x1d37(_0x5b817f,_0x1d1346){_0x5b817f=_0x5b817f-0x1cc;const _0x2ebde2=a39_0x2ebd();let _0x1d371f=_0x2ebde2[_0x5b817f];return _0x1d371f;}import{parseTableReference,validateTableDescribeReference}from'../utils/table-ref-parser.js';import{withSpinner}from'../utils/spinner.js';import{DEFAULT_DISPLAY_LIMIT,resolveLimit}from'../utils/constants.js';export class ShowCommand extends BaseCommand{[a39_0xfcb0fe(0x1d2)]=a39_0xfcb0fe(0x1cc);[a39_0xfcb0fe(0x1f5)]=a39_0xfcb0fe(0x1ea);async[a39_0xfcb0fe(0x1f7)](_0x275372){const _0x306c66=a39_0xfcb0fe;return this[_0x306c66(0x1dc)](_0x275372);}async[a39_0xfcb0fe(0x1dc)](_0x117662){const _0x500e70=a39_0xfcb0fe,{options:_0x5851d9,args:_0x154d58,tdx:_0x3cea9e}=_0x117662;let _0x56c35f;try{_0x56c35f=parseTableReference(_0x154d58[0x0]);const _0x25f7b3=_0x5851d9[_0x500e70(0x1f2)];!_0x56c35f['database']&&_0x25f7b3&&(_0x56c35f['database']=_0x25f7b3);const _0x2ef27f=validateTableDescribeReference(_0x56c35f);if(_0x2ef27f)return console[_0x500e70(0x1e0)](_0x500e70(0x1d6)+_0x2ef27f),console[_0x500e70(0x1e0)](_0x500e70(0x1f1)),console['error']('\x20\x20\x20or:\x20tdx\x20show\x20<catalog.database.table>'),console[_0x500e70(0x1e0)](_0x500e70(0x1d8)),0x1;}catch(_0x274cf9){return console['error'](_0x500e70(0x1d6)+_0x274cf9['message']),console[_0x500e70(0x1e0)](_0x500e70(0x1f1)),console[_0x500e70(0x1e0)]('\x20\x20\x20or:\x20tdx\x20show\x20<catalog.database.table>'),console[_0x500e70(0x1e0)](_0x500e70(0x1d8)),0x1;}const _0x523ba6=_0x56c35f[_0x500e70(0x1cd)],_0xb6649c=_0x56c35f[_0x500e70(0x1f2)],_0x3b54ff=_0x56c35f[_0x500e70(0x1f3)],_0x4f1ddb=resolveLimit(_0x5851d9[_0x500e70(0x1d5)],DEFAULT_DISPLAY_LIMIT);try{_0x5851d9[_0x500e70(0x1e1)]&&(console[_0x500e70(0x1e0)](_0x500e70(0x1fa)+_0x5851d9[_0x500e70(0x1ce)]),_0x523ba6&&console[_0x500e70(0x1e0)](_0x500e70(0x1de)+_0x523ba6),console[_0x500e70(0x1e0)](_0x500e70(0x1db)+_0xb6649c),console[_0x500e70(0x1e0)](_0x500e70(0x1da)+_0x3b54ff),console['error'](_0x500e70(0x1df)+_0x4f1ddb));const _0x1674dd=_0x523ba6?_0x523ba6+'.'+_0xb6649c+'.'+_0x3b54ff:_0xb6649c+'.'+_0x3b54ff,_0x3054d5=await withSpinner(_0x500e70(0x1ec)+_0x1674dd+_0x500e70(0x1cf),()=>_0x3cea9e[_0x500e70(0x1e2)]['showTable'](_0xb6649c,_0x3b54ff,_0x4f1ddb,_0x523ba6),{'verbose':_0x5851d9[_0x500e70(0x1e1)]}),_0x29e703=_0x3054d5[_0x500e70(0x1d4)],_0x175cf5=_0x29e703['data'];return _0x175cf5['length']===0x0?console[_0x500e70(0x1e0)](_0x500e70(0x1ee)):console[_0x500e70(0x1e0)](_0x500e70(0x1f9)+_0x175cf5[_0x500e70(0x1e7)]+_0x500e70(0x1d1)+(_0x175cf5['length']!==0x1?'s':'')+'\x20from\x20'+_0x1674dd),await handleSDKOutput(_0x175cf5,_0x5851d9),0x0;}catch(_0xb3489d){if(_0xb3489d instanceof SDKError)return console[_0x500e70(0x1e0)]('Error:\x20'+_0xb3489d['message']),_0xb3489d[_0x500e70(0x1ed)]&&console['error'](_0x500e70(0x1d3)+_0xb3489d[_0x500e70(0x1ed)]),0x1;throw _0xb3489d;}}[a39_0xfcb0fe(0x1e4)](_0x4a596a){const _0x2ca0f5=a39_0xfcb0fe;if(_0x4a596a[_0x2ca0f5(0x1f4)][_0x2ca0f5(0x1e7)]===0x0)return'Usage:\x20tdx\x20show\x20<database.table>\x0a\x20\x20\x20or:\x20tdx\x20show\x20<catalog.database.table>\x0a\x20\x20\x20or:\x20tdx\x20show\x20<table>\x20--database\x20<database>\x0a\x20\x20\x20or:\x20tdx\x20show\x20<table>\x20--in\x20<database>\x0a\x0aRun\x20\x27tdx\x20show\x20--help\x27\x20for\x20more\x20options';if(_0x4a596a[_0x2ca0f5(0x1f4)][_0x2ca0f5(0x1e7)]>0x1)return _0x2ca0f5(0x1d9);return undefined;}}
|
package/dist/commands/tables.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a40_0x1e80(_0x1131d4,_0x1b9b45){_0x1131d4=_0x1131d4-0x7b;const _0x26bcf0=a40_0x26bc();let _0x1e8019=_0x26bcf0[_0x1131d4];return _0x1e8019;}const a40_0x3258fb=a40_0x1e80;(function(_0xb25894,_0x7122cc){const _0x1ff936=a40_0x1e80,_0x52d776=_0xb25894();while(!![]){try{const _0x2456bb=-parseInt(_0x1ff936(0x94))/0x1+-parseInt(_0x1ff936(0x97))/0x2*(parseInt(_0x1ff936(0x95))/0x3)+-parseInt(_0x1ff936(0x83))/0x4+-parseInt(_0x1ff936(0xa9))/0x5*(-parseInt(_0x1ff936(0x7c))/0x6)+parseInt(_0x1ff936(0xa2))/0x7*(-parseInt(_0x1ff936(0xa1))/0x8)+-parseInt(_0x1ff936(0x82))/0x9+parseInt(_0x1ff936(0x8a))/0xa*(parseInt(_0x1ff936(0xa6))/0xb);if(_0x2456bb===_0x7122cc)break;else _0x52d776['push'](_0x52d776['shift']());}catch(_0x892123){_0x52d776['push'](_0x52d776['shift']());}}}(a40_0x26bc,0x32242));import{BaseCommand}from'./command.js';import{SDKError}from'../sdk/index.js';import{handleSDKOutput}from'../utils/command-output.js';function a40_0x26bc(){const _0x365d44=['Listing\x20tables...','data','\x27\x20may\x20not\x20exist\x20or\x20contains\x20no\x20tables','Database:\x20','1041470mxSpPV','site','verbose','length','\x20\x20tdx\x20tables\x20\x22mydb.*\x22\x20\x20\x20\x20\x20\x20\x20\x20->\x20all\x20tables\x20from\x20mydb','database','.*\x22','\x20\x20tdx\x20tables\x20\x22*.user*\x22\x20\x20\x20\x20\x20\x20\x20->\x20tables\x20matching\x20user*\x20across\x20databases','description','limit','6574ZLjxzy','722151DACgWd','\x20\x20tdx\x20tables\x20users\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20->\x20table\x20\x22users\x22\x20across\x20all\x20databases','2QoipDa','Database\x20\x27','table','listTables','\x20\x20Cause:\x20','\x27\x20across\x20all\x20databases.','tables','includes','Database:\x20all','\x20\x20Or:\x20\x20tdx\x20tables\x20--database\x20','8iTcUbw','3115dfHxpr','\x20table','error','Note:\x20\x27','99mnSGit','List\x20tables\x20in\x20a\x20database','cause','5LLJNpV','\x20\x20tdx\x20tables\x20--in\x20mydb\x20\x20\x20\x20\x20\x20\x20->\x20all\x20tables\x20from\x20mydb','Error:\x20','1728852CPJnje','\x20\x20Use:\x20tdx\x20tables\x20\x22','\x20\x20tdx\x20tables\x20\x22mydb.users\x22\x20\x20\x20\x20->\x20table\x20\x22users\x22\x20in\x20database\x20mydb','Table\x20pattern:\x20','message','Site:\x20','3390408PJzXcn','1582556CCJHpZ','Error:\x20Pattern\x20\x27','\x27\x20is\x20ambiguous.'];a40_0x26bc=function(){return _0x365d44;};return a40_0x26bc();}import{parseTableReference}from'../utils/table-ref-parser.js';import{DEFAULT_LISTING_LIMIT,resolveLimit}from'../utils/constants.js';import{withSpinner}from'../utils/spinner.js';export class TablesCommand extends BaseCommand{['name']=a40_0x3258fb(0x9d);[a40_0x3258fb(0x92)]=a40_0x3258fb(0xa7);async['execute'](_0x143f0f){const _0x32d61f=a40_0x3258fb,{options:_0x59bead,args:_0x551fc6,tdx:_0x163f22}=_0x143f0f;let _0x46a1f1;if(_0x551fc6['length']===0x0)_0x46a1f1={'database':undefined,'table':undefined,'original':''};else{if(_0x551fc6[_0x32d61f(0x8d)]===0x1)try{_0x46a1f1=parseTableReference(_0x551fc6[0x0]);if(_0x46a1f1[_0x32d61f(0x99)]&&!_0x46a1f1[_0x32d61f(0x8f)]&&!_0x46a1f1[_0x32d61f(0x99)][_0x32d61f(0x9e)]('*')&&!_0x46a1f1[_0x32d61f(0x99)]['includes']('?'))return console[_0x32d61f(0xa4)](_0x32d61f(0x84)+_0x551fc6[0x0]+_0x32d61f(0x85)),console['error']('Did\x20you\x20mean\x20to\x20list\x20all\x20tables\x20from\x20database\x20\x27'+_0x46a1f1[_0x32d61f(0x99)]+'\x27?'),console[_0x32d61f(0xa4)](_0x32d61f(0x7d)+_0x46a1f1['table']+_0x32d61f(0x90)),console[_0x32d61f(0xa4)]('\x20\x20Or:\x20\x20tdx\x20tables\x20--in\x20'+_0x46a1f1['table']),console[_0x32d61f(0xa4)](_0x32d61f(0xa0)+_0x46a1f1[_0x32d61f(0x99)]),console[_0x32d61f(0xa4)](''),console['error'](_0x32d61f(0xa5)+_0x551fc6[0x0]+'\x27\x20without\x20wildcards\x20would\x20search\x20for\x20tables\x20named\x20\x27'+_0x46a1f1[_0x32d61f(0x99)]+_0x32d61f(0x9c)),0x1;}catch(_0x1e328b){return console['error'](_0x32d61f(0x7b)+_0x1e328b[_0x32d61f(0x80)]),0x1;}else return console['error']('Error:\x20Too\x20many\x20arguments.\x20Use\x20single\x20argument:'),console[_0x32d61f(0xa4)](_0x32d61f(0x96)),console[_0x32d61f(0xa4)](_0x32d61f(0x8e)),console['error'](_0x32d61f(0x7e)),console[_0x32d61f(0xa4)](_0x32d61f(0x91)),console[_0x32d61f(0xa4)]('Or\x20use\x20--in\x20flag:'),console[_0x32d61f(0xa4)](_0x32d61f(0xaa)),0x1;}const _0x3ddaaa=_0x59bead[_0x32d61f(0x8f)];!_0x46a1f1['database']&&_0x3ddaaa&&(_0x46a1f1[_0x32d61f(0x8f)]=_0x3ddaaa);try{const _0x5eaade=_0x5a1ef3=>_0x5a1ef3&&(_0x5a1ef3[_0x32d61f(0x9e)]('*')||_0x5a1ef3[_0x32d61f(0x9e)]('?')),_0x1336ff=_0x5eaade(_0x46a1f1[_0x32d61f(0x8f)]);_0x59bead[_0x32d61f(0x8c)]&&(console[_0x32d61f(0xa4)](_0x32d61f(0x81)+_0x59bead[_0x32d61f(0x8b)]),_0x46a1f1[_0x32d61f(0x8f)]?_0x1336ff?console[_0x32d61f(0xa4)]('Database\x20pattern:\x20'+_0x46a1f1[_0x32d61f(0x8f)]):console[_0x32d61f(0xa4)](_0x32d61f(0x89)+_0x46a1f1[_0x32d61f(0x8f)]):console['error'](_0x32d61f(0x9f)),_0x46a1f1[_0x32d61f(0x99)]&&console[_0x32d61f(0xa4)](_0x32d61f(0x7f)+_0x46a1f1['table']));const _0x2da632=_0x46a1f1[_0x32d61f(0x8f)]&&!_0x1336ff?_0x46a1f1[_0x32d61f(0x8f)]:undefined,_0x14468c=_0x1336ff?_0x46a1f1[_0x32d61f(0x8f)]:undefined,_0x3d5a52=_0x46a1f1[_0x32d61f(0x99)],_0x4cb9d2=resolveLimit(_0x59bead[_0x32d61f(0x93)],DEFAULT_LISTING_LIMIT),_0x17afc4=await withSpinner(_0x32d61f(0x86),()=>_0x163f22['query'][_0x32d61f(0x9a)](_0x2da632,_0x3d5a52,_0x14468c,_0x4cb9d2),{'verbose':_0x59bead['verbose']}),_0x356a42=_0x17afc4[_0x32d61f(0x87)];if(_0x356a42[_0x32d61f(0x8d)]===0x0&&_0x46a1f1[_0x32d61f(0x8f)]&&!_0x1336ff)return console[_0x32d61f(0xa4)]('✖\x20No\x20tables\x20found'),console[_0x32d61f(0xa4)](_0x32d61f(0x98)+_0x46a1f1[_0x32d61f(0x8f)]+_0x32d61f(0x88)),0x1;return console['error']('✔\x20Found\x20'+_0x356a42[_0x32d61f(0x8d)]+_0x32d61f(0xa3)+(_0x356a42[_0x32d61f(0x8d)]!==0x1?'s':'')),await handleSDKOutput(_0x356a42,{..._0x59bead,'limit':_0x4cb9d2}),0x0;}catch(_0x565386){if(_0x565386 instanceof SDKError)return console[_0x32d61f(0xa4)](_0x32d61f(0x7b)+_0x565386[_0x32d61f(0x80)]),_0x565386['cause']&&console[_0x32d61f(0xa4)](_0x32d61f(0x9b)+_0x565386[_0x32d61f(0xa8)]),0x1;throw _0x565386;}}['validate'](_0x42ec40){return undefined;}}
|