@treasuredata/tdx 2026.3.10 → 2026.3.11
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 +3 -3
- package/dist/cli-categories.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/agent-command.js +1 -1
- package/dist/commands/agent-test-command.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/auth-login-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/databases.js +1 -1
- package/dist/commands/delivery-command.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-campaign-pull-command.js +1 -1
- package/dist/commands/engage-campaign-push-command.js +1 -1
- package/dist/commands/engage-campaign-validate-command.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/engage-template-pull-command.js +1 -1
- package/dist/commands/engage-template-push-command.js +1 -1
- package/dist/commands/engage-template-validate-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/journey-command.js +1 -1
- package/dist/commands/journey-validate-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/mcp-command.js +1 -1
- package/dist/commands/parent-segment-command.js +1 -1
- package/dist/commands/profile-command.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/schedule-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/segment-validate-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/status-command.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/unset-command.js +1 -1
- package/dist/commands/upgrade-command.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/command-output.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/connection-cache.js +1 -1
- package/dist/core/constants.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/oauth-keychain.js +1 -1
- package/dist/core/oauth.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/core/version.js +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/tools/index.js +1 -1
- package/dist/mcp/tools/tdx-run.js +1 -1
- package/dist/mcp/tools/tdx-search.js +1 -1
- package/dist/mcp/utils.js +1 -1
- package/dist/proxy/claude-usage-tracker.js +1 -1
- package/dist/proxy/passthrough-server.js +1 -1
- package/dist/proxy/sse-usage-parser.js +1 -1
- package/dist/sdk/agent/agent-config.js +1 -1
- package/dist/sdk/agent/agent-ref-parser.js +1 -1
- package/dist/sdk/agent/agent-yaml.js +1 -1
- package/dist/sdk/agent/test/evaluator.js +1 -1
- package/dist/sdk/agent/test/executor.js +1 -1
- package/dist/sdk/agent/test/index.js +1 -1
- package/dist/sdk/agent/test/output.js +1 -1
- package/dist/sdk/agent/test/parser.js +1 -1
- package/dist/sdk/agent/tool-target-registry.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/client/cdp-api-client.js +1 -1
- package/dist/sdk/client/delivery-api-client.js +1 -1
- package/dist/sdk/client/endpoints.js +1 -1
- package/dist/sdk/client/engage-api-client.js +1 -1
- package/dist/sdk/client/http-client.js +1 -1
- package/dist/sdk/client/llm-api-client.js +1 -1
- package/dist/sdk/client/oauth-refresh.js +1 -1
- package/dist/sdk/client/rate-limiter.js +1 -1
- package/dist/sdk/client/td-api-client.js +1 -1
- package/dist/sdk/client/trino-api-client.js +1 -1
- package/dist/sdk/client/workflow-client.js +1 -1
- package/dist/sdk/connection-validator.js +1 -1
- package/dist/sdk/connection.js +1 -1
- package/dist/sdk/delivery.js +1 -1
- package/dist/sdk/engage/campaign-pull.js +1 -1
- package/dist/sdk/engage/campaign-push.js +1 -1
- package/dist/sdk/engage/campaign-validator.js +1 -1
- package/dist/sdk/engage/campaign-yaml.js +1 -1
- package/dist/sdk/engage/template-pull.js +1 -1
- package/dist/sdk/engage/template-push.js +1 -1
- package/dist/sdk/engage/template-validator.js +1 -1
- package/dist/sdk/engage/template-yaml.js +1 -1
- package/dist/sdk/engage/types/campaign-def.js +1 -1
- package/dist/sdk/engage/types/campaign-schema.js +1 -1
- package/dist/sdk/engage/types/template-schema.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/io/index.js +1 -1
- package/dist/sdk/io/node-filesystem.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/journey.js +1 -1
- package/dist/sdk/llm/chat-cache.js +1 -1
- package/dist/sdk/llm/index.js +1 -1
- package/dist/sdk/llm/llm-backup-utils.js +1 -1
- package/dist/sdk/llm/model-factors.js +1 -1
- package/dist/sdk/personalization.js +1 -1
- package/dist/sdk/query/index.js +1 -1
- package/dist/sdk/query/sql-parser.js +1 -1
- package/dist/sdk/realtime.js +1 -1
- package/dist/sdk/schedule.js +1 -1
- package/dist/sdk/segment/child-segment-yaml.js +1 -1
- package/dist/sdk/segment/fields-display.js +1 -1
- package/dist/sdk/segment/file-discovery.js +1 -1
- package/dist/sdk/segment/journey-utils.js +1 -1
- package/dist/sdk/segment/journey-validator.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/pull-workflow.js +1 -1
- package/dist/sdk/segment/push-recovery.js +1 -1
- package/dist/sdk/segment/push-workflow.js +1 -1
- package/dist/sdk/segment/resolution-context.js +1 -1
- package/dist/sdk/segment/segment-path-parser.js +1 -1
- package/dist/sdk/segment/segment-ref-parser.js +1 -1
- package/dist/sdk/segment/segment-validator.js +1 -1
- package/dist/sdk/segment/target-resolution.js +1 -1
- package/dist/sdk/segment/tdx-config.js +1 -1
- package/dist/sdk/segment/types/activation-schema.js +1 -1
- package/dist/sdk/segment/types/journey-def.js +1 -1
- package/dist/sdk/segment/types/journey-schema.js +1 -1
- package/dist/sdk/segment/types/segment-def.js +1 -1
- package/dist/sdk/segment/types/segment-schema.js +1 -1
- package/dist/sdk/segment/validate-files.js +1 -1
- package/dist/sdk/segment/yaml-validator.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/types/index.js +1 -1
- package/dist/sdk/types/progress.js +1 -1
- package/dist/sdk/user.js +1 -1
- package/dist/sdk/util/format-detector.js +1 -1
- package/dist/sdk/util/formatters.js +1 -1
- package/dist/sdk/util/index.js +1 -1
- package/dist/sdk/util/paginate.js +1 -1
- package/dist/sdk/util/tree-formatter.js +1 -1
- package/dist/sdk/workflow/archive-validation.js +1 -1
- package/dist/sdk/workflow/clone-workflow.js +1 -1
- package/dist/sdk/workflow/index.js +1 -1
- package/dist/sdk/workflow/pull-workflow.js +1 -1
- package/dist/sdk/workflow/push-workflow.js +1 -1
- package/dist/sdk/workflow/tdx-config.js +1 -1
- package/dist/sdk/workflow/workflow-utils.js +1 -1
- package/dist/test-utils/command-runner.js +1 -1
- package/dist/test-utils/factories.js +1 -1
- package/dist/test-utils/fixtures.js +1 -1
- package/dist/test-utils/http-mock.js +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/utils/async.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/diff.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/file-reader.js +1 -1
- package/dist/utils/github-releases.js +1 -1
- package/dist/utils/global-cache.js +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/local-cache.js +1 -1
- package/dist/utils/logger/formatters/default-formatter.js +1 -1
- package/dist/utils/logger/formatters/index.js +1 -1
- package/dist/utils/logger/handlers/console-handler.js +1 -1
- package/dist/utils/logger/handlers/file-handler.js +1 -1
- package/dist/utils/logger/handlers/index.js +1 -1
- package/dist/utils/logger/handlers/null-handler.js +1 -1
- package/dist/utils/logger/index.js +1 -1
- package/dist/utils/logger/logger.js +1 -1
- package/dist/utils/logger/types.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/prompt.js +1 -1
- package/dist/utils/spinner.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-logger.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a33_0x243ee6=a33_0x2e4e;function a33_0x22ce(){const _0x5e9133=['elapsedTimeMillis','file','19131jxvmJQ','error','processedRows','length','297530YnOlfX','2643000ZksMhn','push','jobId','Catalog:\x20','name','state','Statement\x20','Usage:\x20tdx\x20query\x20\x22SELECT\x20*\x20FROM\x20table\x22\x0a\x20\x20\x20or:\x20tdx\x20query\x20query.sql\x0a\x20\x20\x20or:\x20echo\x20\x22SELECT\x201\x22\x20|\x20tdx\x20query\x20-\x0a\x0aRun\x20\x27tdx\x20query\x20--help\x27\x20for\x20more\x20options','\x20splits','data','No\x20SQL\x20provided','Run\x20Trino\x20queries\x20(streaming)','1113196xZOscS','execute','message','Executing\x20query\x20[','Schema:\x20','verbose','1554FusEUv','SQL:\x20','completedSplits','\x20rows\x20','6BoexFC','setPhase','stats','args','Error:\x20','11871eJihyi','2930arrDsq','257976dXqBeP','2946060CTUPLy','site','Executing\x20statement\x20','Site:\x20','information_schema','options','output','\x0aAll\x20results\x20saved\x20to\x20','setJobId','originalMessage','\x20[Job\x20ID:\x20'];a33_0x22ce=function(){return _0x5e9133;};return a33_0x22ce();}(function(_0x5e174b,_0x48f8a6){const _0x80320c=a33_0x2e4e,_0x177b53=_0x5e174b();while(!![]){try{const _0x503812=-parseInt(_0x80320c(0x6a))/0x1*(-parseInt(_0x80320c(0x81))/0x2)+parseInt(_0x80320c(0x89))/0x3+parseInt(_0x80320c(0x77))/0x4+-parseInt(_0x80320c(0x6b))/0x5+parseInt(_0x80320c(0x7d))/0x6*(-parseInt(_0x80320c(0x96))/0x7)+-parseInt(_0x80320c(0x88))/0x8+parseInt(_0x80320c(0x86))/0x9*(-parseInt(_0x80320c(0x87))/0xa);if(_0x503812===_0x48f8a6)break;else _0x177b53['push'](_0x177b53['shift']());}catch(_0x41bf25){_0x177b53['push'](_0x177b53['shift']());}}}(a33_0x22ce,0x79854));import{BaseCommand}from'./command.js';function a33_0x2e4e(_0x46a5cc,_0x41602b){_0x46a5cc=_0x46a5cc-0x67;const _0x22cea8=a33_0x22ce();let _0x2e4e52=_0x22cea8[_0x46a5cc];return _0x2e4e52;}import{SDKError}from'../sdk/index.js';import{handleQueryOutput,formatQueryOutput,resolveOutputOptions}from'../core/command-output.js';import{readSqlStatementsFromFile,readSqlStatementsFromStdin,splitSqlStatements,isSqlFilePath}from'../sdk/query/sql-parser.js';import{writeFileSync}from'fs';import{withProgressSpinner,formatElapsed}from'../utils/spinner.js';import{formatRows}from'../sdk/util/formatters.js';export class QueryCommand extends BaseCommand{[a33_0x243ee6(0x6f)]='query';['description']=a33_0x243ee6(0x76);async[a33_0x243ee6(0x78)](_0x56439f){const _0x56df7f=a33_0x243ee6,{options:_0x2ced2d,args:_0x3971c3,tdx:_0x387023}=_0x56439f,_0x3cf736={..._0x2ced2d,'limitStructuredFormats':!![]},_0x52d30e=_0x3971c3[0x0],_0x19bb9b=_0x2ced2d[_0x56df7f(0x95)];let _0x1989f3;try{if(_0x19bb9b)_0x1989f3=readSqlStatementsFromFile(_0x19bb9b);else{if(_0x52d30e==='-')_0x1989f3=await readSqlStatementsFromStdin();else{if(_0x52d30e&&isSqlFilePath(_0x52d30e))_0x1989f3=readSqlStatementsFromFile(_0x52d30e);else{if(_0x52d30e)_0x1989f3=splitSqlStatements(_0x52d30e);else throw new Error(_0x56df7f(0x75));}}}}catch(_0x36405a){return console['error'](_0x56df7f(0x85)+_0x36405a[_0x56df7f(0x79)]),0x1;}const _0x58fabf=_0x2ced2d['database']||_0x56df7f(0x8d),_0x2fad79=_0x2ced2d['catalog'];try{const _0x4f0f86=[],_0x2e9e43=!!_0x2ced2d['output'];for(let _0x7de549=0x0;_0x7de549<_0x1989f3[_0x56df7f(0x69)];_0x7de549++){const _0x32e516=_0x1989f3[_0x7de549],_0x5b8f8d=_0x7de549+0x1,_0x21bebb=_0x1989f3[_0x56df7f(0x69)],_0x2eaa43=_0x21bebb>0x1;_0x2ced2d[_0x56df7f(0x7c)]&&(console['error']('\x0a'+(_0x2eaa43?_0x56df7f(0x71)+_0x5b8f8d+'/'+_0x21bebb+':':'')),console[_0x56df7f(0x67)](_0x56df7f(0x8c)+_0x2ced2d[_0x56df7f(0x8a)]),console['error'](_0x56df7f(0x6e)+(_0x2fad79||'td')),console[_0x56df7f(0x67)](_0x56df7f(0x7b)+_0x58fabf),console['error'](_0x56df7f(0x7e)+_0x32e516));const _0x20aafd=_0x2eaa43?_0x56df7f(0x8b)+_0x5b8f8d+'/'+_0x21bebb+'...':'Executing\x20query...';try{const _0x43168d=await withProgressSpinner(_0x20aafd,async _0x5a07ea=>{const _0x549816=_0x56df7f,_0x406c53=await _0x387023['query'][_0x549816(0x78)](_0x32e516,{'catalog':_0x2fad79,'schema':_0x58fabf,'onJobId':_0x5368f1=>{const _0x453c67=_0x549816;_0x5a07ea[_0x453c67(0x91)](_0x5368f1);},'onProgress':_0x5770d2=>{const _0x43adce=_0x549816;_0x5a07ea[_0x43adce(0x82)](_0x43adce(0x7a)+_0x5770d2[_0x43adce(0x70)]+']'),_0x5a07ea['setExtra'](formatRows(_0x5770d2[_0x43adce(0x68)])+_0x43adce(0x80)+_0x5770d2[_0x43adce(0x7f)]+'/'+_0x5770d2['totalSplits']+_0x43adce(0x73));}});return _0x406c53;},{'verbose':_0x2ced2d[_0x56df7f(0x7c)]}),_0x2eb91c=_0x43168d[_0x56df7f(0x74)],_0x2e7358=_0x2eb91c[_0x56df7f(0x6d)]?_0x56df7f(0x93)+_0x2eb91c[_0x56df7f(0x6d)]+']':'',_0x3d5d7a=_0x2eaa43?_0x56df7f(0x71)+_0x5b8f8d+'/'+_0x21bebb+'\x20-\x20':'';console[_0x56df7f(0x67)]('✔\x20'+_0x3d5d7a+'Query\x20completed:\x20Processed\x20'+formatRows(_0x2eb91c[_0x56df7f(0x83)][_0x56df7f(0x68)])+_0x56df7f(0x80)+('in\x20'+formatElapsed(_0x2eb91c[_0x56df7f(0x83)][_0x56df7f(0x94)])+_0x2e7358));if(_0x2eaa43&&_0x2e9e43){const _0x374610=resolveOutputOptions(_0x3cf736),_0x31788f=await formatQueryOutput(_0x2eb91c,_0x374610);_0x4f0f86[_0x56df7f(0x6c)](_0x31788f);}else await handleQueryOutput(_0x2eb91c,_0x3cf736);}catch(_0x1795fc){const _0x23a944=_0x2eaa43?_0x56df7f(0x71)+_0x5b8f8d+'/'+_0x21bebb+':\x0a':'',_0x3967a9=_0x1795fc instanceof SDKError?_0x1795fc[_0x56df7f(0x92)]:_0x1795fc[_0x56df7f(0x79)];return console[_0x56df7f(0x67)](''+_0x23a944+_0x3967a9),0x1;}}if(_0x1989f3[_0x56df7f(0x69)]>0x1&&_0x2e9e43&&_0x4f0f86[_0x56df7f(0x69)]>0x0){const _0x28bdf2=_0x4f0f86['join']('\x0a');writeFileSync(_0x2ced2d['output'],_0x28bdf2),console[_0x56df7f(0x67)](_0x56df7f(0x90)+_0x2ced2d[_0x56df7f(0x8f)]);}return 0x0;}catch(_0x44800d){throw _0x44800d;}}['validate'](_0xacdb49){const _0x27d8ea=a33_0x243ee6,_0x4a1f88=_0xacdb49[_0x27d8ea(0x84)][0x0],_0x597e64=_0xacdb49[_0x27d8ea(0x8e)]['file'];if(!_0x4a1f88&&!_0x597e64)return _0x27d8ea(0x72);if(_0x4a1f88&&_0x597e64)return'Cannot\x20specify\x20both\x20SQL\x20argument\x20and\x20--file\x20option';return undefined;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function a34_0x417a(){const _0x39b041=['Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20update\x20<name>\x20[options]','name','engineVersion','has_next_page','delete','\x20\x20Database:\x20','27589991GeHbKU','args','start_at','delay','verbose','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20delete\x20<name>','priority','getTime','trim','query','Getting\x20schedule\x20details...','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20history\x20<name>\x20[--from\x20<n>]\x20[--to\x20<n>]','data','last_job','trino','nextRun','num','toLocaleDateString','status','show','\x20\x20Type:\x20','next_run_at','(unnamed)','update','execute','ies','validate','substring','16433280Lngkrv','Getting\x20schedule\x20history...','\x20execution','user_name','padEnd','output','format','created_at','cyan','schedule:show','\x20(use\x20--limit\x20to\x20see\x20more)','schedules','retry_limit','result','11JIfNTx','round','Updating\x20schedule:\x20','map','retryLimit','statusIcon','\x20\x20Cron:\x20','schedule:list','length','options','time_zone','/app/queries/editor?queryId=','create','keys','success','Found\x20','error','\x20\x20Job\x20ID:\x20','timezone','just\x20now','Running\x20schedule...','886554ohIcKn','type','soon','Showing\x20first\x20','19984toXLxg','2548SUGGAc','Updating\x20schedule...','time','max','Running\x20schedule:\x20','No\x20scheduled\x20queries\x20found','Database\x20is\x20required\x0aUsage:\x20job\x20schedule\x20create\x20<name>\x20-d\x20<db>\x20--file\x20<path>\x20[options]','Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20schedule\x20\x22','7iaattV','join','\x22...','Failed\x20to\x20read\x20file:\x20','utf-8','from','lastRun','never','end_at','h\x20ago','green','in\x20','schedule:history','\x20\x20Timezone:\x20','13310qryXod','repeat','listQueries','user','\x20created','3785358eiBKyi','abs','Cancelled','cron','schedule:delete','List\x20scheduled\x20queries','d\x20ago','jsonl','INVALID_ARGUMENT','updated_at','history','Query\x20file\x20is\x20empty','engine_version','2484jTTSiN','entries','scheduled_at','Show\x20schedule\x20execution\x20history','database','Run\x20a\x20scheduled\x20query\x20immediately','description','file','schedule:create','tsv','red','Searching\x20scheduled\x20queries\x20matching\x20\x22','limit','pagination','job_id','ended_at','317742ggQktB','Schedule\x20updated:\x20','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20run\x20<name>\x20[--time\x20<iso8601>]\x20[--num\x20<1-10>]','schedule:run'];a34_0x417a=function(){return _0x39b041;};return a34_0x417a();}const a34_0x1ef183=a34_0x4faa;(function(_0x46276b,_0x35b6c5){const _0x3f2f46=a34_0x4faa,_0x3616c0=_0x46276b();while(!![]){try{const _0x34d54a=parseInt(_0x3f2f46(0x249))/0x1*(-parseInt(_0x3f2f46(0x215))/0x2)+parseInt(_0x3f2f46(0x25e))/0x3+parseInt(_0x3f2f46(0x263))/0x4*(-parseInt(_0x3f2f46(0x1f3))/0x5)+-parseInt(_0x3f2f46(0x1f8))/0x6*(-parseInt(_0x3f2f46(0x26b))/0x7)+-parseInt(_0x3f2f46(0x262))/0x8*(parseInt(_0x3f2f46(0x205))/0x9)+parseInt(_0x3f2f46(0x23b))/0xa+parseInt(_0x3f2f46(0x21f))/0xb;if(_0x34d54a===_0x35b6c5)break;else _0x3616c0['push'](_0x3616c0['shift']());}catch(_0x11c089){_0x3616c0['push'](_0x3616c0['shift']());}}}(a34_0x417a,0xe6c2d));import{BaseCommand}from'./command.js';import{SDKError,ErrorCode}from'../sdk/index.js';import{handleSDKOutput,handleSingleObjectOutput,writeOutput}from'../core/command-output.js';function a34_0x4faa(_0xb0d9d8,_0x433229){_0xb0d9d8=_0xb0d9d8-0x1e8;const _0x417aa8=a34_0x417a();let _0x4faac9=_0x417aa8[_0xb0d9d8];return _0x4faac9;}import{withSpinner}from'../utils/spinner.js';import{confirm}from'../utils/prompt.js';import{readFileSync}from'fs';import{DEFAULT_DISPLAY_LIMIT,resolveLimit}from'../core/constants.js';import{getConsoleUrl}from'../sdk/client/endpoints.js';import{hyperlink}from'../sdk/util/formatters.js';import a34_0xc4b67b from'chalk';function formatRelativeTime(_0x26f2a6){const _0x2f26b5=a34_0x4faa,_0x426c4b=new Date(_0x26f2a6),_0x510a10=new Date(),_0x2dd5d8=_0x426c4b['getTime']()-_0x510a10[_0x2f26b5(0x226)](),_0x1c0c58=Math[_0x2f26b5(0x1f9)](_0x2dd5d8)/0x3e8,_0x41f00e=_0x2dd5d8<0x0;if(_0x1c0c58<0x3c)return _0x41f00e?_0x2f26b5(0x25c):_0x2f26b5(0x260);else{if(_0x1c0c58<0xe10){const _0x187039=Math[_0x2f26b5(0x24a)](_0x1c0c58/0x3c);return _0x41f00e?_0x187039+'m\x20ago':_0x2f26b5(0x1f0)+_0x187039+'m';}else{if(_0x1c0c58<0x15180){const _0x5b5933=Math[_0x2f26b5(0x24a)](_0x1c0c58/0xe10);return _0x41f00e?_0x5b5933+_0x2f26b5(0x1ee):_0x2f26b5(0x1f0)+_0x5b5933+'h';}else{if(_0x1c0c58<0x93a80){const _0x3922d7=Math[_0x2f26b5(0x24a)](_0x1c0c58/0x15180);return _0x41f00e?_0x3922d7+_0x2f26b5(0x1fe):_0x2f26b5(0x1f0)+_0x3922d7+'d';}else return _0x426c4b[_0x2f26b5(0x230)]();}}}}export class ScheduleListCommand extends BaseCommand{[a34_0x1ef183(0x21a)]=a34_0x1ef183(0x250);['description']=a34_0x1ef183(0x1fd);async['execute'](_0x358875){const _0x32c223=a34_0x1ef183,{options:_0x39320c,args:_0xe033fb,tdx:_0xa795ff}=_0x358875,_0x52e75c=resolveLimit(_0x39320c[_0x32c223(0x211)],DEFAULT_DISPLAY_LIMIT),_0x3bcc96=_0xe033fb[0x0],_0x544237=_0x3bcc96?_0x32c223(0x210)+_0x3bcc96+_0x32c223(0x26d):'Listing\x20scheduled\x20queries...',_0x4d939d=await withSpinner(_0x544237,()=>_0xa795ff[_0x32c223(0x246)][_0x32c223(0x1f5)]({'limit':_0x52e75c,'scheduled':!![],'pattern':_0x3bcc96}),{'verbose':_0x39320c['verbose']}),_0x99cdf=_0x4d939d['data']['queries'],_0x467cb1=_0x4d939d[_0x32c223(0x22b)][_0x32c223(0x212)][_0x32c223(0x21c)],_0x9de846=_0x3bcc96?'\x20matching\x20\x22'+_0x3bcc96+'\x22':'';_0x467cb1?console['error'](_0x32c223(0x261)+_0x99cdf[_0x32c223(0x251)]+'\x20schedules'+_0x9de846+_0x32c223(0x245)):console[_0x32c223(0x259)](_0x32c223(0x258)+_0x99cdf[_0x32c223(0x251)]+'\x20scheduled\x20quer'+(_0x99cdf['length']!==0x1?_0x32c223(0x238):'y')+_0x9de846);if(_0x39320c[_0x32c223(0x241)]==='json'||_0x39320c[_0x32c223(0x241)]===_0x32c223(0x1ff)||_0x39320c[_0x32c223(0x241)]==='table'||_0x39320c[_0x32c223(0x241)]===_0x32c223(0x20e)){const _0x1d9dbe=_0x99cdf['map'](_0x4711a0=>({'id':_0x4711a0['id'],'name':_0x4711a0['name'],'cron':_0x4711a0[_0x32c223(0x1fb)],'database':_0x4711a0[_0x32c223(0x209)]?.[_0x32c223(0x21a)],'type':_0x4711a0[_0x32c223(0x25f)],'timezone':_0x4711a0[_0x32c223(0x253)],'user_name':_0x4711a0[_0x32c223(0x1f6)]?.[_0x32c223(0x21a)],'updated_at':_0x4711a0[_0x32c223(0x201)],'next_run_at':_0x4711a0[_0x32c223(0x234)],'last_job_status':_0x4711a0['last_job']?.[_0x32c223(0x231)]}));await handleSDKOutput(_0x1d9dbe,_0x39320c);}else{if(_0x99cdf[_0x32c223(0x251)]===0x0)console['log'](_0x32c223(0x268));else{const _0x55c97c=_0x39320c['site'],_0x179308=_0x99cdf[_0x32c223(0x24c)](_0x1633df=>{const _0x425d3d=_0x32c223,_0x1e6861=_0x1633df[_0x425d3d(0x22c)]?.[_0x425d3d(0x231)]?_0x1633df['last_job'][_0x425d3d(0x231)]===_0x425d3d(0x257)?'✓':'✗':'-',_0x30a5e8=_0x1633df[_0x425d3d(0x22c)]?.['ended_at']?formatRelativeTime(_0x1633df[_0x425d3d(0x22c)][_0x425d3d(0x214)]):_0x425d3d(0x1ec),_0x2e9bbd=_0x1633df[_0x425d3d(0x234)]?formatRelativeTime(_0x1633df['next_run_at']):'-',_0x2a51ca=_0x1633df[_0x425d3d(0x1fb)]||'',_0x4b5a94=_0x1633df['name']||_0x425d3d(0x235),_0x2a73fe=getConsoleUrl(_0x55c97c,_0x425d3d(0x254)+_0x1633df['id']);return{'statusIcon':_0x1e6861,'lastRun':_0x30a5e8,'nextRun':_0x2e9bbd,'cron':_0x2a51ca,'name':_0x4b5a94,'queryUrl':_0x2a73fe,'status':_0x1633df[_0x425d3d(0x22c)]?.[_0x425d3d(0x231)]};}),_0x2dbd03=Math[_0x32c223(0x266)](..._0x179308[_0x32c223(0x24c)](_0x438400=>_0x438400[_0x32c223(0x1eb)]['length'])),_0x5bb21f=Math[_0x32c223(0x266)](..._0x179308[_0x32c223(0x24c)](_0x31e33b=>_0x31e33b[_0x32c223(0x22e)][_0x32c223(0x251)])),_0x4357bb=Math['max'](..._0x179308[_0x32c223(0x24c)](_0x1db5e8=>_0x1db5e8[_0x32c223(0x1fb)][_0x32c223(0x251)])),_0x310644=_0x179308[_0x32c223(0x24c)](_0x55882b=>{const _0xbbce0d=_0x32c223,_0x1e7b48=_0x55882b[_0xbbce0d(0x231)]==='success'?a34_0xc4b67b[_0xbbce0d(0x1ef)](_0x55882b[_0xbbce0d(0x24e)]):_0x55882b[_0xbbce0d(0x231)]===_0xbbce0d(0x259)?a34_0xc4b67b[_0xbbce0d(0x20f)](_0x55882b[_0xbbce0d(0x24e)]):a34_0xc4b67b['dim'](_0x55882b['statusIcon']),_0x4045a2=_0x55882b[_0xbbce0d(0x1eb)][_0xbbce0d(0x23f)](_0x2dbd03),_0x94dab=_0x55882b[_0xbbce0d(0x22e)][_0xbbce0d(0x23f)](_0x5bb21f),_0x11d627=_0x55882b[_0xbbce0d(0x1fb)]?a34_0xc4b67b[_0xbbce0d(0x243)](_0x55882b[_0xbbce0d(0x1fb)][_0xbbce0d(0x23f)](_0x4357bb)):'\x20'[_0xbbce0d(0x1f4)](_0x4357bb),_0x597ba2=hyperlink(_0x55882b['name'],_0x55882b['queryUrl']);return'📅\x20'+_0x1e7b48+'\x20'+_0x4045a2+'\x20\x20→\x20'+_0x94dab+'\x20\x20'+_0x11d627+'\x20\x20'+_0x597ba2;});await writeOutput(_0x310644[_0x32c223(0x26c)]('\x0a'),_0x39320c[_0x32c223(0x240)],'list');}}return 0x0;}}export class ScheduleShowCommand extends BaseCommand{[a34_0x1ef183(0x21a)]=a34_0x1ef183(0x244);[a34_0x1ef183(0x20b)]='Show\x20schedule\x20details';['validate'](_0x3f6562){const _0x48a723=a34_0x1ef183,_0x405a26=_0x3f6562[_0x48a723(0x220)][0x0];if(!_0x405a26)return'Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20show\x20<name>';return undefined;}async[a34_0x1ef183(0x237)](_0xd1481e){const _0x2222a3=a34_0x1ef183,{options:_0xee9a3d,args:_0x117698,tdx:_0x2de8b1}=_0xd1481e,_0x48d62e=_0x117698[0x0],_0x3ab39a=await withSpinner(_0x2222a3(0x229),()=>_0x2de8b1['schedules'][_0x2222a3(0x232)](_0x48d62e),{'verbose':_0xee9a3d['verbose']}),_0x225418=_0x3ab39a[_0x2222a3(0x22b)],_0x5a1a22={'name':_0x225418[_0x2222a3(0x21a)],'cron':_0x225418[_0x2222a3(0x1fb)],'database':_0x225418['database'],'type':_0x225418[_0x2222a3(0x25f)],'timezone':_0x225418[_0x2222a3(0x25b)],'user_name':_0x225418[_0x2222a3(0x23e)],'created_at':_0x225418[_0x2222a3(0x242)],'engine_version':_0x225418[_0x2222a3(0x204)],'executing_user_id':_0x225418['executing_user_id'],'query':_0x225418['query'],'delay':_0x225418[_0x2222a3(0x222)],'priority':_0x225418['priority'],'retry_limit':_0x225418[_0x2222a3(0x247)],..._0x225418['result']&&{'result':_0x225418[_0x2222a3(0x248)]}};return await handleSingleObjectOutput(_0x5a1a22,_0xee9a3d),0x0;}}export class ScheduleCreateCommand extends BaseCommand{['name']=a34_0x1ef183(0x20d);[a34_0x1ef183(0x20b)]='Create\x20a\x20scheduled\x20query';['validate'](_0x256874){const _0x1b06c9=a34_0x1ef183,_0x787fc7=_0x256874[_0x1b06c9(0x220)][0x0];if(!_0x787fc7)return'Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20create\x20<name>\x20-d\x20<db>\x20--file\x20<path>\x20[options]';const _0x5c0029=_0x256874[_0x1b06c9(0x252)];if(!_0x5c0029[_0x1b06c9(0x209)])return _0x1b06c9(0x269);return undefined;}async['execute'](_0x16e060){const _0x57f9c3=a34_0x1ef183,{options:_0x547e98,args:_0x3c48a4,tdx:_0x415ee3}=_0x16e060,_0x15454d=_0x3c48a4[0x0],_0x2baaf7=_0x547e98,_0x24e991=_0x2baaf7[_0x57f9c3(0x209)],_0x1e9a66=_0x2baaf7[_0x57f9c3(0x20c)],_0xd6d211=_0x2baaf7[_0x57f9c3(0x25f)]||_0x57f9c3(0x22d);let _0x2710de;try{_0x2710de=readFileSync(_0x1e9a66,_0x57f9c3(0x1e9))[_0x57f9c3(0x227)]();}catch(_0x2acc3e){throw new SDKError(ErrorCode[_0x57f9c3(0x200)],'Failed\x20to\x20read\x20file:\x20'+_0x1e9a66,_0x2acc3e instanceof Error?_0x2acc3e:undefined);}if(!_0x2710de)throw new SDKError(ErrorCode[_0x57f9c3(0x200)],_0x57f9c3(0x203));const _0x238be7={'database':_0x24e991,'query':_0x2710de,'type':_0xd6d211};if(_0x2baaf7[_0x57f9c3(0x1fb)])_0x238be7[_0x57f9c3(0x1fb)]=_0x2baaf7[_0x57f9c3(0x1fb)];if(_0x2baaf7[_0x57f9c3(0x25b)])_0x238be7[_0x57f9c3(0x25b)]=_0x2baaf7[_0x57f9c3(0x25b)];if(_0x2baaf7[_0x57f9c3(0x222)]!==undefined)_0x238be7[_0x57f9c3(0x222)]=Number(_0x2baaf7['delay']);if(_0x2baaf7['priority']!==undefined)_0x238be7[_0x57f9c3(0x225)]=Number(_0x2baaf7['priority']);if(_0x2baaf7[_0x57f9c3(0x24d)]!==undefined)_0x238be7[_0x57f9c3(0x247)]=Number(_0x2baaf7[_0x57f9c3(0x24d)]);if(_0x2baaf7[_0x57f9c3(0x21b)])_0x238be7[_0x57f9c3(0x204)]=_0x2baaf7['engineVersion'];if(_0x2baaf7[_0x57f9c3(0x248)])_0x238be7[_0x57f9c3(0x248)]=_0x2baaf7[_0x57f9c3(0x248)];if(_0x547e98[_0x57f9c3(0x223)]){console['error']('Creating\x20schedule:\x20'+_0x15454d),console[_0x57f9c3(0x259)](_0x57f9c3(0x21e)+_0x24e991),console[_0x57f9c3(0x259)](_0x57f9c3(0x233)+_0xd6d211);if(_0x238be7['cron'])console[_0x57f9c3(0x259)](_0x57f9c3(0x24f)+_0x238be7[_0x57f9c3(0x1fb)]);if(_0x238be7['timezone'])console[_0x57f9c3(0x259)](_0x57f9c3(0x1f2)+_0x238be7[_0x57f9c3(0x25b)]);}const _0x1c81b9=await withSpinner('Creating\x20schedule...',()=>_0x415ee3[_0x57f9c3(0x246)][_0x57f9c3(0x255)](_0x15454d,_0x238be7),{'verbose':_0x547e98[_0x57f9c3(0x223)]});return console['error']('Schedule\x20created:\x20'+_0x1c81b9[_0x57f9c3(0x22b)][_0x57f9c3(0x21a)]),await handleSingleObjectOutput(_0x1c81b9[_0x57f9c3(0x22b)],_0x547e98),0x0;}}export class ScheduleUpdateCommand extends BaseCommand{[a34_0x1ef183(0x21a)]='schedule:update';[a34_0x1ef183(0x20b)]='Update\x20a\x20scheduled\x20query';[a34_0x1ef183(0x239)](_0x4a0cbd){const _0x5f4722=a34_0x1ef183,_0x124d36=_0x4a0cbd[_0x5f4722(0x220)][0x0];if(!_0x124d36)return _0x5f4722(0x219);return undefined;}async[a34_0x1ef183(0x237)](_0x858d78){const _0xee1156=a34_0x1ef183,{options:_0x467d34,args:_0x324623,tdx:_0x3ce21e}=_0x858d78,_0x65f03d=_0x324623[0x0],_0x1b241c=_0x467d34,_0x4c36a9={};if(_0x1b241c[_0xee1156(0x209)])_0x4c36a9[_0xee1156(0x209)]=_0x1b241c['database'];if(_0x1b241c[_0xee1156(0x25f)])_0x4c36a9['type']=_0x1b241c['type'];if(_0x1b241c[_0xee1156(0x1fb)])_0x4c36a9[_0xee1156(0x1fb)]=_0x1b241c[_0xee1156(0x1fb)];if(_0x1b241c[_0xee1156(0x25b)])_0x4c36a9['timezone']=_0x1b241c['timezone'];if(_0x1b241c[_0xee1156(0x222)]!==undefined)_0x4c36a9['delay']=Number(_0x1b241c[_0xee1156(0x222)]);if(_0x1b241c[_0xee1156(0x225)]!==undefined)_0x4c36a9[_0xee1156(0x225)]=Number(_0x1b241c['priority']);if(_0x1b241c['retryLimit']!==undefined)_0x4c36a9[_0xee1156(0x247)]=Number(_0x1b241c['retryLimit']);if(_0x1b241c[_0xee1156(0x21b)])_0x4c36a9[_0xee1156(0x204)]=_0x1b241c[_0xee1156(0x21b)];if(_0x1b241c[_0xee1156(0x248)])_0x4c36a9[_0xee1156(0x248)]=_0x1b241c[_0xee1156(0x248)];if(_0x1b241c[_0xee1156(0x20c)])try{_0x4c36a9[_0xee1156(0x228)]=readFileSync(_0x1b241c['file'],'utf-8')[_0xee1156(0x227)]();}catch(_0x327a4b){throw new SDKError(ErrorCode[_0xee1156(0x200)],_0xee1156(0x1e8)+_0x1b241c['file'],_0x327a4b instanceof Error?_0x327a4b:undefined);}if(Object[_0xee1156(0x256)](_0x4c36a9)[_0xee1156(0x251)]===0x0)throw new SDKError(ErrorCode[_0xee1156(0x200)],'At\x20least\x20one\x20option\x20must\x20be\x20provided\x20to\x20update');if(_0x467d34['verbose']){console['error'](_0xee1156(0x24b)+_0x65f03d);for(const [_0x154540,_0x59f664]of Object[_0xee1156(0x206)](_0x4c36a9)){_0x154540===_0xee1156(0x228)?console['error']('\x20\x20'+_0x154540+':\x20'+_0x59f664[_0xee1156(0x23a)](0x0,0x32)+'...'):console['error']('\x20\x20'+_0x154540+':\x20'+_0x59f664);}}const _0x5a83c7=await withSpinner(_0xee1156(0x264),()=>_0x3ce21e['schedules'][_0xee1156(0x236)](_0x65f03d,_0x4c36a9),{'verbose':_0x467d34[_0xee1156(0x223)]});return console[_0xee1156(0x259)](_0xee1156(0x216)+_0x5a83c7[_0xee1156(0x22b)][_0xee1156(0x21a)]),await handleSingleObjectOutput(_0x5a83c7[_0xee1156(0x22b)],_0x467d34),0x0;}}export class ScheduleDeleteCommand extends BaseCommand{[a34_0x1ef183(0x21a)]=a34_0x1ef183(0x1fc);[a34_0x1ef183(0x20b)]='Delete\x20a\x20scheduled\x20query';[a34_0x1ef183(0x239)](_0x280aa5){const _0x1f0495=a34_0x1ef183,_0x4b5fdb=_0x280aa5['args'][0x0];if(!_0x4b5fdb)return _0x1f0495(0x224);return undefined;}async['execute'](_0x582d7a){const _0x1e6910=a34_0x1ef183,{options:_0x2fd486,args:_0x5d1132,tdx:_0x5de99e}=_0x582d7a,_0x31b8ca=_0x5d1132[0x0];if(!_0x2fd486['yes']){const _0x3b483b=await confirm(_0x1e6910(0x26a)+_0x31b8ca+'\x22?');if(!_0x3b483b)return console['error'](_0x1e6910(0x1fa)),0x0;}const _0x48763c=await withSpinner('Deleting\x20schedule...',()=>_0x5de99e[_0x1e6910(0x246)][_0x1e6910(0x21d)](_0x31b8ca),{'verbose':_0x2fd486['verbose']});return console[_0x1e6910(0x259)]('Schedule\x20deleted:\x20'+_0x48763c[_0x1e6910(0x22b)][_0x1e6910(0x21a)]),0x0;}}export class ScheduleRunCommand extends BaseCommand{[a34_0x1ef183(0x21a)]=a34_0x1ef183(0x218);[a34_0x1ef183(0x20b)]=a34_0x1ef183(0x20a);[a34_0x1ef183(0x239)](_0x2890ce){const _0x384e0a=a34_0x1ef183,_0x2e1297=_0x2890ce[_0x384e0a(0x220)][0x0];if(!_0x2e1297)return _0x384e0a(0x217);return undefined;}async[a34_0x1ef183(0x237)](_0x501d0a){const _0x1ec42e=a34_0x1ef183,{options:_0x139a64,args:_0x51cff3,tdx:_0x4f093b}=_0x501d0a,_0x3dcfda=_0x51cff3[0x0],_0x4ce5cc=_0x139a64,_0x5f427c=_0x4ce5cc[_0x1ec42e(0x265)],_0x51bc7a=_0x4ce5cc[_0x1ec42e(0x22f)]!==undefined?Number(_0x4ce5cc[_0x1ec42e(0x22f)]):undefined;if(_0x139a64[_0x1ec42e(0x223)]){console['error'](_0x1ec42e(0x267)+_0x3dcfda);if(_0x5f427c)console[_0x1ec42e(0x259)]('\x20\x20Time:\x20'+_0x5f427c);if(_0x51bc7a)console[_0x1ec42e(0x259)]('\x20\x20Num:\x20'+_0x51bc7a);}const _0x2aeb9c=await withSpinner(_0x1ec42e(0x25d),()=>_0x4f093b[_0x1ec42e(0x246)]['run'](_0x3dcfda,{'time':_0x5f427c,'num':_0x51bc7a}),{'verbose':_0x139a64[_0x1ec42e(0x223)]}),_0x18096c=_0x2aeb9c[_0x1ec42e(0x22b)]['jobs'];console[_0x1ec42e(0x259)]('Schedule\x20run\x20submitted:\x20'+_0x18096c[_0x1ec42e(0x251)]+'\x20job'+(_0x18096c[_0x1ec42e(0x251)]!==0x1?'s':'')+_0x1ec42e(0x1f7));for(const _0x53b27a of _0x18096c){console[_0x1ec42e(0x259)](_0x1ec42e(0x25a)+_0x53b27a[_0x1ec42e(0x213)]);}return await handleSDKOutput(_0x18096c,_0x139a64),0x0;}}export class ScheduleHistoryCommand extends BaseCommand{[a34_0x1ef183(0x21a)]=a34_0x1ef183(0x1f1);[a34_0x1ef183(0x20b)]=a34_0x1ef183(0x208);[a34_0x1ef183(0x239)](_0x4fd38d){const _0x2161a7=a34_0x1ef183,_0x43df09=_0x4fd38d[_0x2161a7(0x220)][0x0];if(!_0x43df09)return _0x2161a7(0x22a);return undefined;}async[a34_0x1ef183(0x237)](_0x10c339){const _0x1c5d72=a34_0x1ef183,{options:_0x13c4fd,args:_0x4a3772,tdx:_0x19f1b4}=_0x10c339,_0x5db886=_0x4a3772[0x0],_0x25dd5a=_0x13c4fd,_0x16ebed=_0x25dd5a[_0x1c5d72(0x1ea)]!==undefined?Number(_0x25dd5a[_0x1c5d72(0x1ea)]):undefined,_0x2db185=_0x25dd5a['to']!==undefined?Number(_0x25dd5a['to']):undefined,_0x58cedc=await withSpinner(_0x1c5d72(0x23c),()=>_0x19f1b4[_0x1c5d72(0x246)]['history'](_0x5db886,{'from':_0x16ebed,'to':_0x2db185}),{'verbose':_0x13c4fd['verbose']}),_0x37bc02=_0x58cedc[_0x1c5d72(0x22b)];console[_0x1c5d72(0x259)](_0x1c5d72(0x258)+_0x37bc02['count']+_0x1c5d72(0x23d)+(_0x37bc02['count']!==0x1?'s':'')+'\x20(showing\x20'+_0x37bc02[_0x1c5d72(0x1ea)]+'-'+_0x37bc02['to']+')');const _0x163cc6=_0x37bc02[_0x1c5d72(0x202)][_0x1c5d72(0x24c)](_0x5d4e6c=>({'job_id':_0x5d4e6c['job_id'],'type':_0x5d4e6c[_0x1c5d72(0x25f)],'status':_0x5d4e6c[_0x1c5d72(0x231)],'scheduled_at':_0x5d4e6c[_0x1c5d72(0x207)],'created_at':_0x5d4e6c[_0x1c5d72(0x242)],'start_at':_0x5d4e6c[_0x1c5d72(0x221)],'end_at':_0x5d4e6c[_0x1c5d72(0x1ed)]}));return await handleSDKOutput(_0x163cc6,_0x13c4fd),0x0;}}
|
|
1
|
+
const a34_0x554f9a=a34_0x3cff;(function(_0x1e96cf,_0x1af5ff){const _0x1869fe=a34_0x3cff,_0xa8845f=_0x1e96cf();while(!![]){try{const _0x457d0a=-parseInt(_0x1869fe(0x10b))/0x1*(parseInt(_0x1869fe(0xc0))/0x2)+-parseInt(_0x1869fe(0xbb))/0x3*(parseInt(_0x1869fe(0xd7))/0x4)+-parseInt(_0x1869fe(0x130))/0x5+parseInt(_0x1869fe(0x116))/0x6+parseInt(_0x1869fe(0xd0))/0x7+parseInt(_0x1869fe(0xb1))/0x8+-parseInt(_0x1869fe(0xd9))/0x9*(parseInt(_0x1869fe(0xdc))/0xa);if(_0x457d0a===_0x1af5ff)break;else _0xa8845f['push'](_0xa8845f['shift']());}catch(_0x46b1e0){_0xa8845f['push'](_0xa8845f['shift']());}}}(a34_0x4b72,0x5f923));import{BaseCommand}from'./command.js';import{SDKError,ErrorCode}from'../sdk/index.js';import{handleSDKOutput,handleSingleObjectOutput,writeOutput}from'../core/command-output.js';import{withSpinner}from'../utils/spinner.js';import{confirm}from'../utils/prompt.js';function a34_0x3cff(_0x41c8fe,_0x589799){_0x41c8fe=_0x41c8fe-0xae;const _0x4b7201=a34_0x4b72();let _0x3cff34=_0x4b7201[_0x41c8fe];return _0x3cff34;}import{readFileSync}from'fs';import{DEFAULT_DISPLAY_LIMIT,resolveLimit}from'../core/constants.js';import{getConsoleUrl}from'../sdk/client/endpoints.js';import{hyperlink}from'../sdk/util/formatters.js';import a34_0x4b19e1 from'chalk';function formatRelativeTime(_0xe6597d){const _0x2fe353=a34_0x3cff,_0xef3ae2=new Date(_0xe6597d),_0x221dad=new Date(),_0x7f209b=_0xef3ae2['getTime']()-_0x221dad['getTime'](),_0x3efbb0=Math[_0x2fe353(0xca)](_0x7f209b)/0x3e8,_0x575fce=_0x7f209b<0x0;if(_0x3efbb0<0x3c)return _0x575fce?_0x2fe353(0xfe):_0x2fe353(0xde);else{if(_0x3efbb0<0xe10){const _0x4398ba=Math['round'](_0x3efbb0/0x3c);return _0x575fce?_0x4398ba+'m\x20ago':_0x2fe353(0xef)+_0x4398ba+'m';}else{if(_0x3efbb0<0x15180){const _0x168ee8=Math[_0x2fe353(0xd4)](_0x3efbb0/0xe10);return _0x575fce?_0x168ee8+_0x2fe353(0xf4):_0x2fe353(0xef)+_0x168ee8+'h';}else{if(_0x3efbb0<0x93a80){const _0x51dabe=Math[_0x2fe353(0xd4)](_0x3efbb0/0x15180);return _0x575fce?_0x51dabe+_0x2fe353(0x11d):_0x2fe353(0xef)+_0x51dabe+'d';}else return _0xef3ae2[_0x2fe353(0x13a)]();}}}}export class ScheduleListCommand extends BaseCommand{[a34_0x554f9a(0xf0)]=a34_0x554f9a(0xf6);[a34_0x554f9a(0x134)]=a34_0x554f9a(0x138);async[a34_0x554f9a(0xd2)](_0x28dc37){const _0x4028cb=a34_0x554f9a,{options:_0x15cb5f,args:_0x4e4e01,tdx:_0x1f1b07}=_0x28dc37,_0x50c8b7=resolveLimit(_0x15cb5f[_0x4028cb(0x131)],DEFAULT_DISPLAY_LIMIT),_0x125383=_0x4e4e01[0x0],_0x4c7a90=_0x125383?_0x4028cb(0x133)+_0x125383+'\x22...':_0x4028cb(0x121),_0x5f4ccd=await withSpinner(_0x4c7a90,()=>_0x1f1b07['schedules'][_0x4028cb(0x104)]({'limit':_0x50c8b7,'scheduled':!![],'pattern':_0x125383}),{'verbose':_0x15cb5f[_0x4028cb(0x129)]}),_0x36d5fd=_0x5f4ccd[_0x4028cb(0xeb)]['queries'],_0x315659=_0x5f4ccd['data'][_0x4028cb(0xb3)]['has_next_page'],_0x1b8d3e=_0x125383?_0x4028cb(0xce)+_0x125383+'\x22':'';_0x315659?console[_0x4028cb(0x125)]('Showing\x20first\x20'+_0x36d5fd[_0x4028cb(0x12d)]+_0x4028cb(0xd1)+_0x1b8d3e+_0x4028cb(0x12f)):console[_0x4028cb(0x125)](_0x4028cb(0xf1)+_0x36d5fd[_0x4028cb(0x12d)]+_0x4028cb(0xdb)+(_0x36d5fd['length']!==0x1?_0x4028cb(0x105):'y')+_0x1b8d3e);if(_0x15cb5f[_0x4028cb(0x115)]===_0x4028cb(0x12b)||_0x15cb5f[_0x4028cb(0x115)]===_0x4028cb(0x10d)||_0x15cb5f['format']===_0x4028cb(0xd3)||_0x15cb5f[_0x4028cb(0x115)]===_0x4028cb(0xd6)){const _0x1849fe=_0x36d5fd[_0x4028cb(0xe6)](_0x40e708=>({'id':_0x40e708['id'],'name':_0x40e708['name'],'cron':_0x40e708[_0x4028cb(0xe7)],'database':_0x40e708['database']?.['name'],'type':_0x40e708[_0x4028cb(0x132)],'timezone':_0x40e708[_0x4028cb(0xff)],'user_name':_0x40e708['user']?.['name'],'updated_at':_0x40e708[_0x4028cb(0xb0)],'next_run_at':_0x40e708[_0x4028cb(0x111)],'last_job_status':_0x40e708[_0x4028cb(0xd8)]?.[_0x4028cb(0x112)]}));await handleSDKOutput(_0x1849fe,_0x15cb5f);}else{if(_0x36d5fd[_0x4028cb(0x12d)]===0x0)console[_0x4028cb(0x128)](_0x4028cb(0x108));else{const _0xee6e91=_0x15cb5f[_0x4028cb(0x120)],_0x37be95=_0x36d5fd[_0x4028cb(0xe6)](_0x522545=>{const _0x3b85dc=_0x4028cb,_0x22effb=_0x522545[_0x3b85dc(0xd8)]?.['status']?_0x522545[_0x3b85dc(0xd8)][_0x3b85dc(0x112)]===_0x3b85dc(0xe9)?'✓':'✗':'-',_0x3c570c=_0x522545[_0x3b85dc(0xd8)]?.['ended_at']?formatRelativeTime(_0x522545[_0x3b85dc(0xd8)]['ended_at']):'never',_0x5e14f7=_0x522545[_0x3b85dc(0x111)]?formatRelativeTime(_0x522545[_0x3b85dc(0x111)]):'-',_0x5a07f4=_0x522545['cron']||'',_0x5166eb=_0x522545['name']||_0x3b85dc(0x11e),_0x502793=getConsoleUrl(_0xee6e91,_0x3b85dc(0x135)+_0x522545['id']);return{'statusIcon':_0x22effb,'lastRun':_0x3c570c,'nextRun':_0x5e14f7,'cron':_0x5a07f4,'name':_0x5166eb,'queryUrl':_0x502793,'status':_0x522545[_0x3b85dc(0xd8)]?.[_0x3b85dc(0x112)]};}),_0x43c666=Math[_0x4028cb(0x127)](..._0x37be95['map'](_0x395809=>_0x395809[_0x4028cb(0xb5)][_0x4028cb(0x12d)])),_0x3148bd=Math[_0x4028cb(0x127)](..._0x37be95[_0x4028cb(0xe6)](_0x32c3df=>_0x32c3df[_0x4028cb(0xf2)][_0x4028cb(0x12d)])),_0x193217=Math['max'](..._0x37be95[_0x4028cb(0xe6)](_0x416126=>_0x416126['cron'][_0x4028cb(0x12d)])),_0x2f8848=_0x37be95['map'](_0xf941f5=>{const _0x19e4fb=_0x4028cb,_0x5f8b01=_0xf941f5['status']===_0x19e4fb(0xe9)?a34_0x4b19e1[_0x19e4fb(0xd5)](_0xf941f5[_0x19e4fb(0x10e)]):_0xf941f5['status']===_0x19e4fb(0x125)?a34_0x4b19e1['red'](_0xf941f5[_0x19e4fb(0x10e)]):a34_0x4b19e1[_0x19e4fb(0xcb)](_0xf941f5[_0x19e4fb(0x10e)]),_0x389bc1=_0xf941f5[_0x19e4fb(0xb5)][_0x19e4fb(0x10c)](_0x43c666),_0x29242d=_0xf941f5[_0x19e4fb(0xf2)]['padEnd'](_0x3148bd),_0x4bb2b4=_0xf941f5['cron']?a34_0x4b19e1['cyan'](_0xf941f5[_0x19e4fb(0xe7)]['padEnd'](_0x193217)):'\x20'['repeat'](_0x193217),_0x55185c=hyperlink(_0xf941f5['name'],_0xf941f5[_0x19e4fb(0xbe)]);return _0x19e4fb(0x12c)+_0x5f8b01+'\x20'+_0x389bc1+_0x19e4fb(0xbd)+_0x29242d+'\x20\x20'+_0x4bb2b4+'\x20\x20'+_0x55185c;});await writeOutput(_0x2f8848[_0x4028cb(0x107)]('\x0a'),_0x15cb5f[_0x4028cb(0xc6)],'list');}}return 0x0;}}export class ScheduleShowCommand extends BaseCommand{[a34_0x554f9a(0xf0)]=a34_0x554f9a(0x126);[a34_0x554f9a(0x134)]=a34_0x554f9a(0x11f);[a34_0x554f9a(0xea)](_0x3e4c61){const _0x52072a=a34_0x554f9a,_0x3e7f83=_0x3e4c61[_0x52072a(0xb8)][0x0];if(!_0x3e7f83)return _0x52072a(0xf7);return undefined;}async[a34_0x554f9a(0xd2)](_0x376322){const _0x2a7c1e=a34_0x554f9a,{options:_0x352ac6,args:_0x468906,tdx:_0x5d88ab}=_0x376322,_0x5ec24a=_0x468906[0x0],_0x5276a1=await withSpinner('Getting\x20schedule\x20details...',()=>_0x5d88ab[_0x2a7c1e(0xcc)][_0x2a7c1e(0x119)](_0x5ec24a),{'verbose':_0x352ac6[_0x2a7c1e(0x129)]}),_0x25c3c5=_0x5276a1[_0x2a7c1e(0xeb)],_0x34d5fb={'name':_0x25c3c5[_0x2a7c1e(0xf0)],'cron':_0x25c3c5[_0x2a7c1e(0xe7)],'database':_0x25c3c5[_0x2a7c1e(0xc8)],'type':_0x25c3c5[_0x2a7c1e(0x132)],'timezone':_0x25c3c5[_0x2a7c1e(0xcf)],'user_name':_0x25c3c5[_0x2a7c1e(0xcd)],'created_at':_0x25c3c5[_0x2a7c1e(0xda)],'engine_version':_0x25c3c5[_0x2a7c1e(0xc7)],'executing_user_id':_0x25c3c5[_0x2a7c1e(0xc1)],'query':_0x25c3c5[_0x2a7c1e(0x11c)],'delay':_0x25c3c5['delay'],'priority':_0x25c3c5[_0x2a7c1e(0xe0)],'retry_limit':_0x25c3c5[_0x2a7c1e(0xe8)],..._0x25c3c5[_0x2a7c1e(0xc2)]&&{'result':_0x25c3c5[_0x2a7c1e(0xc2)]}};return await handleSingleObjectOutput(_0x34d5fb,_0x352ac6),0x0;}}export class ScheduleCreateCommand extends BaseCommand{[a34_0x554f9a(0xf0)]=a34_0x554f9a(0x137);['description']='Create\x20a\x20scheduled\x20query';[a34_0x554f9a(0xea)](_0x45b6fb){const _0x23ae9e=a34_0x554f9a,_0x55b81e=_0x45b6fb[_0x23ae9e(0xb8)][0x0];if(!_0x55b81e)return _0x23ae9e(0xc4);const _0x4474bd=_0x45b6fb[_0x23ae9e(0xba)];if(!_0x4474bd[_0x23ae9e(0xc8)])return _0x23ae9e(0xc9);return undefined;}async[a34_0x554f9a(0xd2)](_0x35179f){const _0x581d24=a34_0x554f9a,{options:_0x3c8079,args:_0x360474,tdx:_0x279ec3}=_0x35179f,_0x1b704d=_0x360474[0x0],_0x70a0e4=_0x3c8079,_0x4c1d40=_0x70a0e4['database'],_0x8813a4=_0x70a0e4[_0x581d24(0xb4)],_0x4d404c=_0x70a0e4[_0x581d24(0x132)]||_0x581d24(0x101);let _0x1a64f4;try{_0x1a64f4=readFileSync(_0x8813a4,_0x581d24(0xe2))[_0x581d24(0x122)]();}catch(_0x44f89f){throw new SDKError(ErrorCode[_0x581d24(0xfb)],_0x581d24(0x123)+_0x8813a4,_0x44f89f instanceof Error?_0x44f89f:undefined);}if(!_0x1a64f4)throw new SDKError(ErrorCode[_0x581d24(0xfb)],_0x581d24(0xe4));const _0x3c3370={'database':_0x4c1d40,'query':_0x1a64f4,'type':_0x4d404c};if(_0x70a0e4['cron'])_0x3c3370['cron']=_0x70a0e4['cron'];if(_0x70a0e4[_0x581d24(0xcf)])_0x3c3370['timezone']=_0x70a0e4['timezone'];if(_0x70a0e4[_0x581d24(0x10a)]!==undefined)_0x3c3370[_0x581d24(0x10a)]=Number(_0x70a0e4[_0x581d24(0x10a)]);if(_0x70a0e4[_0x581d24(0xe0)]!==undefined)_0x3c3370[_0x581d24(0xe0)]=Number(_0x70a0e4[_0x581d24(0xe0)]);if(_0x70a0e4[_0x581d24(0xe1)]!==undefined)_0x3c3370[_0x581d24(0xe8)]=Number(_0x70a0e4[_0x581d24(0xe1)]);if(_0x70a0e4[_0x581d24(0x102)])_0x3c3370[_0x581d24(0xc7)]=_0x70a0e4[_0x581d24(0x102)];if(_0x70a0e4['result'])_0x3c3370[_0x581d24(0xc2)]=_0x70a0e4[_0x581d24(0xc2)];if(_0x3c8079[_0x581d24(0x129)]){console['error'](_0x581d24(0x136)+_0x1b704d),console[_0x581d24(0x125)]('\x20\x20Database:\x20'+_0x4c1d40),console[_0x581d24(0x125)]('\x20\x20Type:\x20'+_0x4d404c);if(_0x3c3370[_0x581d24(0xe7)])console[_0x581d24(0x125)](_0x581d24(0xc5)+_0x3c3370[_0x581d24(0xe7)]);if(_0x3c3370['timezone'])console[_0x581d24(0x125)](_0x581d24(0xf8)+_0x3c3370[_0x581d24(0xcf)]);}const _0x2e060c=await withSpinner(_0x581d24(0xf9),()=>_0x279ec3[_0x581d24(0xcc)][_0x581d24(0xfa)](_0x1b704d,_0x3c3370),{'verbose':_0x3c8079[_0x581d24(0x129)]});return console[_0x581d24(0x125)](_0x581d24(0xee)+_0x2e060c[_0x581d24(0xeb)][_0x581d24(0xf0)]),await handleSingleObjectOutput(_0x2e060c[_0x581d24(0xeb)],_0x3c8079),0x0;}}export class ScheduleUpdateCommand extends BaseCommand{[a34_0x554f9a(0xf0)]=a34_0x554f9a(0x100);[a34_0x554f9a(0x134)]=a34_0x554f9a(0x114);[a34_0x554f9a(0xea)](_0x20ab64){const _0x5bb860=a34_0x554f9a,_0x23bb93=_0x20ab64[_0x5bb860(0xb8)][0x0];if(!_0x23bb93)return'Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20update\x20<name>\x20[options]';return undefined;}async['execute'](_0x27fa5d){const _0x19ddea=a34_0x554f9a,{options:_0x4da896,args:_0x263787,tdx:_0x5ca884}=_0x27fa5d,_0x421d2d=_0x263787[0x0],_0xb35646=_0x4da896,_0x91427={};if(_0xb35646['database'])_0x91427[_0x19ddea(0xc8)]=_0xb35646[_0x19ddea(0xc8)];if(_0xb35646[_0x19ddea(0x132)])_0x91427['type']=_0xb35646[_0x19ddea(0x132)];if(_0xb35646['cron'])_0x91427[_0x19ddea(0xe7)]=_0xb35646[_0x19ddea(0xe7)];if(_0xb35646['timezone'])_0x91427[_0x19ddea(0xcf)]=_0xb35646[_0x19ddea(0xcf)];if(_0xb35646[_0x19ddea(0x10a)]!==undefined)_0x91427[_0x19ddea(0x10a)]=Number(_0xb35646['delay']);if(_0xb35646[_0x19ddea(0xe0)]!==undefined)_0x91427[_0x19ddea(0xe0)]=Number(_0xb35646[_0x19ddea(0xe0)]);if(_0xb35646[_0x19ddea(0xe1)]!==undefined)_0x91427['retry_limit']=Number(_0xb35646[_0x19ddea(0xe1)]);if(_0xb35646[_0x19ddea(0x102)])_0x91427[_0x19ddea(0xc7)]=_0xb35646[_0x19ddea(0x102)];if(_0xb35646['result'])_0x91427['result']=_0xb35646['result'];if(_0xb35646[_0x19ddea(0xb4)])try{_0x91427['query']=readFileSync(_0xb35646[_0x19ddea(0xb4)],_0x19ddea(0xe2))[_0x19ddea(0x122)]();}catch(_0xe1ddd2){throw new SDKError(ErrorCode[_0x19ddea(0xfb)],_0x19ddea(0x123)+_0xb35646[_0x19ddea(0xb4)],_0xe1ddd2 instanceof Error?_0xe1ddd2:undefined);}if(Object[_0x19ddea(0x103)](_0x91427)['length']===0x0)throw new SDKError(ErrorCode[_0x19ddea(0xfb)],'At\x20least\x20one\x20option\x20must\x20be\x20provided\x20to\x20update');if(_0x4da896[_0x19ddea(0x129)]){console[_0x19ddea(0x125)](_0x19ddea(0x117)+_0x421d2d);for(const [_0x4121ce,_0x9131f1]of Object[_0x19ddea(0x124)](_0x91427)){_0x4121ce===_0x19ddea(0x11c)?console[_0x19ddea(0x125)]('\x20\x20'+_0x4121ce+':\x20'+_0x9131f1[_0x19ddea(0xae)](0x0,0x32)+_0x19ddea(0x139)):console[_0x19ddea(0x125)]('\x20\x20'+_0x4121ce+':\x20'+_0x9131f1);}}const _0x321c99=await withSpinner(_0x19ddea(0x10f),()=>_0x5ca884[_0x19ddea(0xcc)][_0x19ddea(0x11a)](_0x421d2d,_0x91427),{'verbose':_0x4da896[_0x19ddea(0x129)]});return console['error'](_0x19ddea(0x118)+_0x321c99[_0x19ddea(0xeb)][_0x19ddea(0xf0)]),await handleSingleObjectOutput(_0x321c99['data'],_0x4da896),0x0;}}export class ScheduleDeleteCommand extends BaseCommand{[a34_0x554f9a(0xf0)]=a34_0x554f9a(0xaf);[a34_0x554f9a(0x134)]=a34_0x554f9a(0x13c);[a34_0x554f9a(0xea)](_0x5f0e34){const _0x36cc6d=a34_0x554f9a,_0x2d9f2b=_0x5f0e34[_0x36cc6d(0xb8)][0x0];if(!_0x2d9f2b)return _0x36cc6d(0xb9);return undefined;}async[a34_0x554f9a(0xd2)](_0x415173){const _0x506e38=a34_0x554f9a,{options:_0x247a2a,args:_0x2eb40a,tdx:_0x1448aa}=_0x415173,_0x198fbc=_0x2eb40a[0x0];if(!_0x247a2a[_0x506e38(0x113)]){const _0x231b22=await confirm(_0x506e38(0x12e)+_0x198fbc+'\x22?');if(!_0x231b22)return console['error'](_0x506e38(0xc3)),0x0;}const _0x983c5b=await withSpinner('Deleting\x20schedule...',()=>_0x1448aa['schedules'][_0x506e38(0x106)](_0x198fbc),{'verbose':_0x247a2a[_0x506e38(0x129)]});return console[_0x506e38(0x125)]('Schedule\x20deleted:\x20'+_0x983c5b[_0x506e38(0xeb)]['name']),0x0;}}export class ScheduleRunCommand extends BaseCommand{['name']=a34_0x554f9a(0x110);[a34_0x554f9a(0x134)]='Run\x20a\x20scheduled\x20query\x20immediately';['validate'](_0x3b8f18){const _0x38aacd=a34_0x554f9a,_0x3c4a56=_0x3b8f18[_0x38aacd(0xb8)][0x0];if(!_0x3c4a56)return _0x38aacd(0xe5);return undefined;}async['execute'](_0x2b8c10){const _0x2781be=a34_0x554f9a,{options:_0x281261,args:_0x45c14a,tdx:_0x480a4e}=_0x2b8c10,_0x54c9e8=_0x45c14a[0x0],_0x2e65bf=_0x281261,_0x36f8b3=_0x2e65bf[_0x2781be(0xfc)],_0x23cc70=_0x2e65bf['num']!==undefined?Number(_0x2e65bf[_0x2781be(0xfd)]):undefined;if(_0x281261[_0x2781be(0x129)]){console['error'](_0x2781be(0x12a)+_0x54c9e8);if(_0x36f8b3)console[_0x2781be(0x125)]('\x20\x20Time:\x20'+_0x36f8b3);if(_0x23cc70)console[_0x2781be(0x125)](_0x2781be(0x109)+_0x23cc70);}const _0x4a90c2=await withSpinner(_0x2781be(0x13b),()=>_0x480a4e[_0x2781be(0xcc)][_0x2781be(0xb2)](_0x54c9e8,{'time':_0x36f8b3,'num':_0x23cc70}),{'verbose':_0x281261[_0x2781be(0x129)]}),_0x1ac1e4=_0x4a90c2[_0x2781be(0xeb)][_0x2781be(0xb6)];console[_0x2781be(0x125)]('Schedule\x20run\x20submitted:\x20'+_0x1ac1e4[_0x2781be(0x12d)]+_0x2781be(0xdd)+(_0x1ac1e4['length']!==0x1?'s':'')+'\x20created');for(const _0x44ffad of _0x1ac1e4){console['error'](_0x2781be(0xbf)+_0x44ffad[_0x2781be(0xbc)]);}return await handleSDKOutput(_0x1ac1e4,_0x281261),0x0;}}export class ScheduleHistoryCommand extends BaseCommand{[a34_0x554f9a(0xf0)]=a34_0x554f9a(0x11b);['description']='Show\x20schedule\x20execution\x20history';[a34_0x554f9a(0xea)](_0x424a7b){const _0x2d4b49=_0x424a7b['args'][0x0];if(!_0x2d4b49)return'Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20history\x20<name>\x20[--from\x20<n>]\x20[--to\x20<n>]';return undefined;}async[a34_0x554f9a(0xd2)](_0x45c565){const _0x4d6f4f=a34_0x554f9a,{options:_0x5c48bd,args:_0x44f3c8,tdx:_0x1606ab}=_0x45c565,_0x122f90=_0x44f3c8[0x0],_0x3588c2=_0x5c48bd,_0x4080e0=_0x3588c2['from']!==undefined?Number(_0x3588c2[_0x4d6f4f(0xf5)]):undefined,_0x38c4b7=_0x3588c2['to']!==undefined?Number(_0x3588c2['to']):undefined,_0x555943=await withSpinner('Getting\x20schedule\x20history...',()=>_0x1606ab[_0x4d6f4f(0xcc)]['history'](_0x122f90,{'from':_0x4080e0,'to':_0x38c4b7}),{'verbose':_0x5c48bd[_0x4d6f4f(0x129)]}),_0x6b26dc=_0x555943[_0x4d6f4f(0xeb)];console['error'](_0x4d6f4f(0xf1)+_0x6b26dc['count']+_0x4d6f4f(0xb7)+(_0x6b26dc[_0x4d6f4f(0xdf)]!==0x1?'s':'')+_0x4d6f4f(0xed)+_0x6b26dc['from']+'-'+_0x6b26dc['to']+')');const _0x2fb638=_0x6b26dc[_0x4d6f4f(0xf3)]['map'](_0x1b8549=>({'job_id':_0x1b8549[_0x4d6f4f(0xbc)],'type':_0x1b8549['type'],'status':_0x1b8549[_0x4d6f4f(0x112)],'scheduled_at':_0x1b8549['scheduled_at'],'created_at':_0x1b8549[_0x4d6f4f(0xda)],'start_at':_0x1b8549[_0x4d6f4f(0xe3)],'end_at':_0x1b8549[_0x4d6f4f(0xec)]}));return await handleSDKOutput(_0x2fb638,_0x5c48bd),0x0;}}function a34_0x4b72(){const _0x3226ec=['7212HwvSxn','job_id','\x20\x20→\x20','queryUrl','\x20\x20Job\x20ID:\x20','1234UwMuEZ','executing_user_id','result','Cancelled','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20create\x20<name>\x20-d\x20<db>\x20--file\x20<path>\x20[options]','\x20\x20Cron:\x20','output','engine_version','database','Database\x20is\x20required\x0aUsage:\x20job\x20schedule\x20create\x20<name>\x20-d\x20<db>\x20--file\x20<path>\x20[options]','abs','dim','schedules','user_name','\x20matching\x20\x22','timezone','5151111XVErhv','\x20schedules','execute','table','round','green','tsv','976tiThUl','last_job','134019XrnNAX','created_at','\x20scheduled\x20quer','180CIEjCb','\x20job','soon','count','priority','retryLimit','utf-8','start_at','Query\x20file\x20is\x20empty','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20run\x20<name>\x20[--time\x20<iso8601>]\x20[--num\x20<1-10>]','map','cron','retry_limit','success','validate','data','end_at','\x20(showing\x20','Schedule\x20created:\x20','in\x20','name','Found\x20','nextRun','history','h\x20ago','from','schedule:list','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20show\x20<name>','\x20\x20Timezone:\x20','Creating\x20schedule...','create','INVALID_ARGUMENT','time','num','just\x20now','time_zone','schedule:update','trino','engineVersion','keys','listQueries','ies','delete','join','No\x20scheduled\x20queries\x20found','\x20\x20Num:\x20','delay','507XAxePB','padEnd','jsonl','statusIcon','Updating\x20schedule...','schedule:run','next_run_at','status','yes','Update\x20a\x20scheduled\x20query','format','3600444kKGrqM','Updating\x20schedule:\x20','Schedule\x20updated:\x20','show','update','schedule:history','query','d\x20ago','(unnamed)','Show\x20schedule\x20details','site','Listing\x20scheduled\x20queries...','trim','Failed\x20to\x20read\x20file:\x20','entries','error','schedule:show','max','log','verbose','Running\x20schedule:\x20','json','📅\x20','length','Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20schedule\x20\x22','\x20(use\x20--limit\x20to\x20see\x20more)','1476690YzHBql','limit','type','Searching\x20scheduled\x20queries\x20matching\x20\x22','description','/app/queries/editor?queryId=','Creating\x20schedule:\x20','schedule:create','List\x20scheduled\x20queries','...','toLocaleDateString','Running\x20schedule...','Delete\x20a\x20scheduled\x20query','substring','schedule:delete','updated_at','4146264kTPmzC','run','pagination','file','lastRun','jobs','\x20execution','args','Schedule\x20name\x20is\x20required\x0aUsage:\x20job\x20schedule\x20delete\x20<name>','options'];a34_0x4b72=function(){return _0x3226ec;};return a34_0x4b72();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a35_0x500582=a35_0x5279;(function(_0x5537ac,_0x57c730){const _0x3eb798=a35_0x5279,_0x5f55a7=_0x5537ac();while(!![]){try{const _0x2b7d55=-parseInt(_0x3eb798(0x24f))/0x1+parseInt(_0x3eb798(0x22e))/0x2*(-parseInt(_0x3eb798(0x24e))/0x3)+-parseInt(_0x3eb798(0x235))/0x4*(parseInt(_0x3eb798(0x24a))/0x5)+-parseInt(_0x3eb798(0x22b))/0x6+-parseInt(_0x3eb798(0x208))/0x7+parseInt(_0x3eb798(0x21d))/0x8*(-parseInt(_0x3eb798(0x252))/0x9)+parseInt(_0x3eb798(0x23b))/0xa;if(_0x2b7d55===_0x57c730)break;else _0x5f55a7['push'](_0x5f55a7['shift']());}catch(_0x22202f){_0x5f55a7['push'](_0x5f55a7['shift']());}}}(a35_0x3147,0x25382));import{BaseCommand}from'./command.js';import{SDKError,ErrorCode}from'../sdk/index.js';import{handleSDKOutput,handleQueryOutput,handleSingleObjectOutput}from'../core/command-output.js';import{withSpinner,withProgressSpinner,formatElapsed}from'../utils/spinner.js';import{parseSegmentRef}from'../sdk/segment/segment-ref-parser.js';import{DEFAULT_DISPLAY_LIMIT,resolveLimit}from'../core/constants.js';function a35_0x3147(){const _0xbe9302=['Error:\x20Child\x20segment\x20name\x20or\x20YAML\x20file\x20path\x20is\x20required','Folder\x20name:\x20','Error:\x20YAML\x20file\x20paths\x20must\x20be\x20specified\x20with\x20--path\x20option','SEGMENT_NOT_FOUND','segment','Show\x20segment\x20folder\x20details','parent','\x20\x20-w,\x20--web\x20\x20Open\x20segment\x20in\x20web\x20browser','Examples:','\x20[Job\x20ID:\x20','Error:\x20Path\x20or\x20name\x20is\x20required','Error:\x20Cannot\x20execute\x20query\x20for\x20parent\x20segment\x20with\x20this\x20command.','Usage:\x20tdx\x20segment\x20folder\x20show\x20<parent_name/folder_name>','message','stats','resolveFolderId','Executing\x20segment\x20query...','/e/','Fetching\x20SQL\x20from\x20rule...','Usage:\x20tdx\x20sg\x20view\x20<name>\x20[-w]','getSQLFromServerSegment','green','Cannot\x20get\x20SQL\x20for\x20parent\x20segment\x20with\x20this\x20command.\x20Use:\x20tdx\x20ps\x20sql','Site:\x20','path','\x20\x20tdx\x20segment\x20describe\x20\x22My\x20Audience/Marketing/High\x20Value\x22','964467QMgmfb','Use:\x20tdx\x20sg\x20view\x20<name>\x20\x20#\x20To\x20show\x20folder\x20details','Create\x20segment\x20folder\x20for\x20organization','List\x20segment\x20folders\x20under\x20a\x20parent\x20segment','Resolved:\x20','Resolved\x20type:\x20','toLocaleString','error','type','\x20\x20Segment\x20name:\x20','\x20\x20tdx\x20sg\x20sql\x20--path\x20','Resolved\x20parent\x20ID:\x20','limit','SELECT\x20*\x20FROM\x20(\x0a','cyan','json','url','Failed\x20to\x20resolve\x20YAML\x20file\x20path:\x20','createFolder','Parent\x20ID:\x20','site','1672FAMKbd','Target\x20path:\x20','\x20\x20Full\x20path:\x20','segment:describe','resolvePathToResource','Fetching\x20folder\x20\x27','processedRows','log','Resolved\x20relative\x20path\x20to:\x20','Fetching\x20SQL\x20for\x20segment...','folderPath','getSegmentSQLFromYaml','resolveParentId','Error:\x20Specify\x20either\x20segment\x20name\x20or\x20--path,\x20not\x20both','770136DoiHOD','Use:\x20tdx\x20ps\x20view','segment:desc','2PmlbdU','getSegment','Resolved\x20folder\x20ID:\x20','segmentPath','\x20\x20tdx\x20sg\x20view\x20\x22Marketing\x22\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20View\x20folder\x20details','Folder\x20ID\x20missing\x20from\x20resolved\x20path','parentSegment','144djYNDa','jobId','Usage:\x20tdx\x20segment\x20describe\x20<path>','data','Fetching\x20parent\x20segment\x20details...','SEGMENT_FOLDER_NOT_FOUND','12135180FapgOy','code','red','\x20\x20Or\x20set\x20context:\x20tdx\x20use\x20parent_segment\x20<name>','execute','Resolving\x20parent\x20folder\x20\x27','trim','cause','Cannot\x20get\x20SQL\x20query\x20for\x20a\x20folder.\x20Folders\x20are\x20organizational\x20containers,\x20not\x20queryable\x20segments.','segmentId','Error:\x20Cannot\x20view\x20parent\x20segment\x20details\x20with\x20this\x20command.','SQL\x20query:\x0a','\x27\x20with\x20ID:\x20','getFolder','\x20\x20tdx\x20sg\x20desc\x20segments/my-audience/premium-users.yml','27460HLbxqx','Resolved\x20YAML\x20file:\x20','getSQLFromYamlFile','Show\x20segment\x20or\x20folder\x20details','757899GVRbuJ','293590KzDiJT','name','Error:\x20Cannot\x20open\x20parent\x20segment\x20with\x20this\x20command.','2196bknzKD','Listing\x20folders\x20for\x20parent\x20\x27','Usage:\x20tdx\x20segment\x20folder\x20create\x20<parent_name>\x20<folder_name>\x20[options]','segment:folder:create','elapsedTimeMillis','Error:\x20Folder\x20reference\x20is\x20required','segment:view','format','replace','✔\x20Found\x20','setJobId','Error:\x20','\x20\x20tdx\x20sg\x20view\x20\x22Premium\x20Users\x22\x20-w\x20\x20#\x20Open\x20segment\x20in\x20web\x20browser','Parent\x20name:\x20','Options:','parentId','Creating\x20folder\x20\x27','Resolving\x20\x27','Error:\x20Cannot\x20open\x20folder\x20in\x20web\x20browser.\x20Use\x20a\x20segment\x20name\x20instead.','content','Show\x20folder\x20or\x20child\x20segment\x20details','information_schema','description','Error:\x20Parent\x20segment\x20name\x20and\x20folder\x20name\x20are\x20required','Error:\x20Cannot\x20execute\x20SQL\x20query\x20on\x20a\x20folder.','\x20\x20tdx\x20segment\x20describe\x20\x22My\x20Audience\x22','folder','Get\x20SQL\x20query\x20for\x20child\x20segment','Error:\x20Segment\x20name\x20or\x20--path\x20is\x20required','Execute\x20child\x20segment\x20SQL\x20query\x20and\x20show\x20results','\x20\x20tdx\x20sg\x20sql\x20--path\x20segments/my-audience/premium-users.yml','Resolving\x20path\x20\x27','\x20Opening\x20','✖\x20Query\x20failed\x20[','Segment\x20ID:\x20','getSegmentSQL','in\x20','segmentName','\x20\x20Server-side\x20segment:\x20\x20tdx\x20sg\x20sql\x20<name>','\x20\x20Parent\x20segment:\x20','Error:\x20Folder\x20name\x20is\x20required\x20(use\x20parent_name/folder_name\x20format)','Show\x20child\x20segment\x20schema\x20(column\x20types)','Error:\x20Folder\x20or\x20segment\x20name,\x20or\x20YAML\x20file\x20path\x20is\x20required','Parent\x20segment:\x20','web','Resolving\x20parent\x20segment\x20\x27','Segment\x20ID\x20missing\x20from\x20resolved\x20path','Fetching\x20segment\x20details...','length','verbose','Use:\x20tdx\x20ps\x20show','Resolving\x20folder\x20\x27','Fetching\x20folder\x20details...','\x20\x20tdx\x20sg\x20show\x20segments/my-audience/premium-users.yml','\x20\x20Cause:\x20','segment:folder:list','/app/ps/','folderId','\x20\x20Local\x20YAML\x20file:\x20\x20\x20\x20\x20\x20tdx\x20sg\x20sql\x20--path\x20<file-path>','\x20\x20Folder\x20path:\x20','\x20rows\x20','\x27...','Usage:\x20tdx\x20sg\x20show\x20<name>','INVALID_ARGUMENT','\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20show\x20<path/to/segment.yml>','Error:\x20Cannot\x20show\x20schema\x20for\x20a\x20folder.','No\x20parent\x20segment\x20context\x20set.\x20Set\x20context\x20with:\x20tdx\x20sg\x20use\x20\x22Name\x22\x20or\x20tdx\x20sg\x20pull\x20\x22Name\x22'];a35_0x3147=function(){return _0xbe9302;};return a35_0x3147();}import{executeSchemaQuery}from'../sdk/segment/fields-display.js';import{isYamlFilePath,resolveYamlFilePath}from'../sdk/segment/segment-path-parser.js';import{getConsoleNextUrl}from'../sdk/client/endpoints.js';import{openBrowser}from'../utils/process.js';import a35_0x2c9435 from'chalk';async function resolveSegmentTarget(_0x671a80,_0x195da0,_0x215b03){const _0x1a2191=a35_0x5279;if(isYamlFilePath(_0x671a80))try{const _0x230de4=await resolveYamlFilePath(_0x671a80);return _0x215b03&&(console[_0x1a2191(0x20f)](_0x1a2191(0x24b)+_0x671a80),console[_0x1a2191(0x20f)](_0x1a2191(0x279)+_0x230de4[_0x1a2191(0x234)]),console['error'](_0x1a2191(0x211)+_0x230de4[_0x1a2191(0x277)]),console[_0x1a2191(0x20f)](_0x1a2191(0x1e6)+(_0x230de4[_0x1a2191(0x227)]||'(root)')),console[_0x1a2191(0x20f)](_0x1a2191(0x21f)+_0x230de4['fullPath'])),_0x230de4['fullPath'];}catch(_0x3abc69){throw new SDKError(ErrorCode[_0x1a2191(0x1ea)],_0x1a2191(0x219)+_0x3abc69['message']);}if(!_0x195da0)throw new SDKError(ErrorCode[_0x1a2191(0x1ea)],_0x1a2191(0x1ed));return _0x195da0+'/'+_0x671a80;}export class SegmentDescribeCommand extends BaseCommand{[a35_0x500582(0x250)]=a35_0x500582(0x220);[a35_0x500582(0x268)]=a35_0x500582(0x24d);async[a35_0x500582(0x23f)](_0x52c859){const _0xf49753=a35_0x500582,{options:_0x1eccde,args:_0x1ddf27,tdx:_0x31295b}=_0x52c859,_0x5ca0ea=_0x1ddf27[0x0],_0x1cdf78=!_0x5ca0ea&&!!_0x1eccde['parentSegment'],_0x533a9b=_0x5ca0ea||_0x1eccde[_0xf49753(0x234)];if(!_0x533a9b)return console['error'](_0xf49753(0x1f8)),console[_0xf49753(0x20f)](_0xf49753(0x237)),console[_0xf49753(0x20f)](_0xf49753(0x1f6)),console[_0xf49753(0x20f)](_0xf49753(0x26b)),console['error'](_0xf49753(0x207)),console[_0xf49753(0x20f)]('\x20\x20tdx\x20segment\x20describe\x20\x22High\x20Value\x22\x20\x20\x20\x20#\x20Relative\x20to\x20current\x20context'),console[_0xf49753(0x20f)](_0xf49753(0x23e)),0x1;try{const _0x5b40aa=_0x1eccde[_0xf49753(0x231)];let _0xc83fae=_0x533a9b;!_0x1cdf78&&_0x5b40aa&&!_0x533a9b['includes']('/')&&(_0xc83fae=_0x5b40aa+'/'+_0x533a9b,_0x1eccde[_0xf49753(0x283)]&&console[_0xf49753(0x20f)](_0xf49753(0x225)+_0xc83fae));const _0x45c71e=await withSpinner(_0xf49753(0x271)+_0xc83fae+_0xf49753(0x1e8),()=>_0x31295b[_0xf49753(0x1f2)][_0xf49753(0x221)](_0xc83fae),{'verbose':_0x1eccde[_0xf49753(0x283)]}),_0x484c3c=_0x45c71e[_0xf49753(0x238)];_0x1eccde[_0xf49753(0x283)]&&(console['error'](_0xf49753(0x20d)+_0x484c3c[_0xf49753(0x210)]),console[_0xf49753(0x20f)](_0xf49753(0x21b)+_0x484c3c[_0xf49753(0x261)]),_0x484c3c[_0xf49753(0x1e4)]&&console[_0xf49753(0x20f)]('Folder\x20ID:\x20'+_0x484c3c['folderId']),_0x484c3c[_0xf49753(0x244)]&&console[_0xf49753(0x20f)](_0xf49753(0x274)+_0x484c3c[_0xf49753(0x244)]));if(_0x484c3c[_0xf49753(0x210)]===_0xf49753(0x1f4)){const _0x4784d1=await withSpinner(_0xf49753(0x239),()=>_0x31295b[_0xf49753(0x1f2)]['getParent'](_0x484c3c[_0xf49753(0x261)]),{'verbose':_0x1eccde[_0xf49753(0x283)]});await handleSingleObjectOutput(_0x4784d1[_0xf49753(0x238)],_0x1eccde);}else{if(_0x484c3c[_0xf49753(0x210)]===_0xf49753(0x26c)){if(!_0x484c3c[_0xf49753(0x1e4)])throw new SDKError(ErrorCode[_0xf49753(0x23a)],'Folder\x20ID\x20missing\x20from\x20resolved\x20path');const _0x266fea=await withSpinner(_0xf49753(0x286),()=>_0x31295b['segment'][_0xf49753(0x248)](_0x484c3c[_0xf49753(0x1e4)]),{'verbose':_0x1eccde[_0xf49753(0x283)]});await handleSingleObjectOutput(_0x266fea[_0xf49753(0x238)],_0x1eccde);}else{if(_0x484c3c[_0xf49753(0x210)]===_0xf49753(0x1f2)){if(!_0x484c3c[_0xf49753(0x244)])throw new SDKError(ErrorCode[_0xf49753(0x1f1)],'Segment\x20ID\x20missing\x20from\x20resolved\x20path');const _0x5ccec2=await withSpinner(_0xf49753(0x281),()=>_0x31295b['segment'][_0xf49753(0x22f)](_0x484c3c[_0xf49753(0x261)],_0x484c3c[_0xf49753(0x244)]),{'verbose':_0x1eccde[_0xf49753(0x283)]});await handleSingleObjectOutput(_0x5ccec2[_0xf49753(0x238)],_0x1eccde);}}}return 0x0;}catch(_0x56f1e6){if(_0x56f1e6 instanceof SDKError)return console[_0xf49753(0x20f)](_0xf49753(0x25d)+_0x56f1e6['message']),_0x56f1e6[_0xf49753(0x242)]&&console[_0xf49753(0x20f)](_0xf49753(0x288)+_0x56f1e6['cause']),0x1;throw _0x56f1e6;}}}export class SegmentShowCommand extends BaseCommand{['name']='segment:show';['description']=a35_0x500582(0x26f);async[a35_0x500582(0x23f)](_0x1af566){const _0x4513f4=a35_0x500582,{options:_0x28db20,args:_0x3cb688,tdx:_0x11fc00}=_0x1af566,_0x4f39c9=_0x3cb688[0x0];if(!_0x4f39c9)return console[_0x4513f4(0x20f)](_0x4513f4(0x1ee)),console[_0x4513f4(0x20f)](_0x4513f4(0x1e9)),console[_0x4513f4(0x20f)](_0x4513f4(0x1eb)),console['error']('Examples:'),console[_0x4513f4(0x20f)]('\x20\x20tdx\x20sg\x20show\x20\x22Premium\x20Users\x22'),console[_0x4513f4(0x20f)](_0x4513f4(0x287)),0x1;try{const _0x48d063=_0x28db20['parentSegment'],_0xf7bc83=await resolveSegmentTarget(_0x4f39c9,_0x48d063,_0x28db20[_0x4513f4(0x283)]);_0x28db20[_0x4513f4(0x283)]&&console[_0x4513f4(0x20f)](_0x4513f4(0x21e)+_0xf7bc83);const _0x542eab=await withSpinner(_0x4513f4(0x263)+_0x4f39c9+_0x4513f4(0x1e8),()=>_0x11fc00[_0x4513f4(0x1f2)][_0x4513f4(0x221)](_0xf7bc83),{'verbose':_0x28db20[_0x4513f4(0x283)]}),_0x442d28=_0x542eab[_0x4513f4(0x238)];_0x28db20[_0x4513f4(0x283)]&&(console['error'](_0x4513f4(0x20d)+_0x442d28[_0x4513f4(0x210)]),console['error']('Parent\x20ID:\x20'+_0x442d28[_0x4513f4(0x261)]));if(_0x442d28['type']==='folder')return console[_0x4513f4(0x20f)](_0x4513f4(0x26a)),console['error'](_0x4513f4(0x209)),0x1;if(_0x442d28[_0x4513f4(0x210)]==='parent')return console[_0x4513f4(0x20f)](_0x4513f4(0x1f9)),console[_0x4513f4(0x20f)](_0x4513f4(0x284)),0x1;if(!_0x442d28[_0x4513f4(0x244)])throw new SDKError(ErrorCode[_0x4513f4(0x1f1)],_0x4513f4(0x280));const _0x495fa7=await withSpinner(_0x4513f4(0x226),()=>_0x11fc00['segment'][_0x4513f4(0x275)](_0x442d28[_0x4513f4(0x261)],_0x442d28[_0x4513f4(0x244)]),{'verbose':_0x28db20['verbose']});let _0x3e76c6=_0x495fa7[_0x4513f4(0x238)];const _0x3d2113=resolveLimit(_0x28db20[_0x4513f4(0x214)],DEFAULT_DISPLAY_LIMIT),_0x3a4d2c=/\bLIMIT\s+\d+/i['test'](_0x3e76c6);!_0x3a4d2c&&(_0x3e76c6=_0x3e76c6[_0x4513f4(0x241)]()[_0x4513f4(0x25a)](/;+$/,''),_0x3e76c6=_0x4513f4(0x215)+_0x3e76c6+'\x0a)\x20AS\x20segment_query\x0aLIMIT\x20'+_0x3d2113);_0x28db20[_0x4513f4(0x283)]&&console['error'](_0x4513f4(0x246)+_0x3e76c6);const _0x2cb81c=await withProgressSpinner(_0x4513f4(0x1fe),async _0x5d9c69=>{const _0x5af5b1=_0x4513f4,_0xd914c4=await _0x11fc00['query']['execute'](_0x3e76c6,{'catalog':'td','schema':_0x5af5b1(0x267),'onJobId':_0x565699=>{const _0x2700a5=_0x5af5b1;_0x5d9c69[_0x2700a5(0x25c)](_0x565699);}});return _0xd914c4;},{'verbose':_0x28db20[_0x4513f4(0x283)]}),_0x230e60=_0x2cb81c[_0x4513f4(0x238)],_0x16c259=_0x230e60[_0x4513f4(0x236)]?_0x4513f4(0x1f7)+_0x230e60['jobId']+']':'';return console[_0x4513f4(0x20f)]('✔\x20Query\x20completed:\x20Processed\x20'+_0x230e60[_0x4513f4(0x1fc)][_0x4513f4(0x223)][_0x4513f4(0x20e)]()+_0x4513f4(0x1e7)+(_0x4513f4(0x276)+formatElapsed(_0x230e60[_0x4513f4(0x1fc)][_0x4513f4(0x256)])+_0x16c259)),await handleQueryOutput(_0x230e60,_0x28db20),0x0;}catch(_0x4c43b3){if(_0x4c43b3 instanceof SDKError)return console[_0x4513f4(0x20f)](_0x4513f4(0x273)+_0x4c43b3[_0x4513f4(0x23c)]+']'),console[_0x4513f4(0x20f)]('\x0a'+_0x4c43b3[_0x4513f4(0x1fb)]),0x1;throw _0x4c43b3;}}}export class SegmentFolderListCommand extends BaseCommand{[a35_0x500582(0x250)]=a35_0x500582(0x289);[a35_0x500582(0x268)]=a35_0x500582(0x20b);async[a35_0x500582(0x23f)](_0x5e34df){const _0x548757=a35_0x500582,{options:_0x1043f4,args:_0x4df0f3,tdx:_0x516e5e}=_0x5e34df;if(_0x4df0f3['length']===0x0)return console[_0x548757(0x20f)]('Error:\x20Parent\x20segment\x20name\x20is\x20required'),console[_0x548757(0x20f)]('Usage:\x20tdx\x20segment\x20folder\x20list\x20<parent_name>'),0x1;const _0x43f69e=_0x4df0f3[0x0];try{_0x1043f4[_0x548757(0x283)]&&(console['error'](_0x548757(0x205)+_0x1043f4[_0x548757(0x21c)]),console[_0x548757(0x20f)](_0x548757(0x25f)+_0x43f69e));const _0x56265a=await withSpinner(_0x548757(0x27f)+_0x43f69e+_0x548757(0x1e8),()=>_0x516e5e[_0x548757(0x1f2)][_0x548757(0x229)](_0x43f69e),{'verbose':_0x1043f4[_0x548757(0x283)]}),_0x3a18a5=_0x56265a[_0x548757(0x238)];_0x1043f4[_0x548757(0x283)]&&console['error'](_0x548757(0x213)+_0x3a18a5);const _0x61d116=await withSpinner(_0x548757(0x253)+_0x43f69e+'\x27...',()=>_0x516e5e[_0x548757(0x1f2)]['listFolders'](_0x3a18a5),{'verbose':_0x1043f4[_0x548757(0x283)]}),_0x5b4559=_0x61d116[_0x548757(0x238)];return console[_0x548757(0x20f)](_0x548757(0x25b)+_0x5b4559['length']+'\x20folder'+(_0x5b4559[_0x548757(0x282)]!==0x1?'s':'')),await handleSDKOutput(_0x5b4559,_0x1043f4),0x0;}catch(_0x19ba92){if(_0x19ba92 instanceof SDKError)return console[_0x548757(0x20f)]('Error:\x20'+_0x19ba92['message']),_0x19ba92[_0x548757(0x242)]&&console[_0x548757(0x20f)](_0x548757(0x288)+_0x19ba92[_0x548757(0x242)]),0x1;throw _0x19ba92;}}}export class SegmentFolderShowCommand extends BaseCommand{['name']='segment:folder:show';[a35_0x500582(0x268)]=a35_0x500582(0x1f3);async[a35_0x500582(0x23f)](_0x459f39){const _0x58b4f6=a35_0x500582,{options:_0x2838a8,args:_0x48d8f9,tdx:_0x4642cd}=_0x459f39;if(_0x48d8f9['length']===0x0)return console[_0x58b4f6(0x20f)](_0x58b4f6(0x257)),console[_0x58b4f6(0x20f)](_0x58b4f6(0x1fa)),0x1;try{const {parentId:_0x3064ab,childId:_0x3338ea}=parseSegmentRef(_0x48d8f9[0x0]);_0x2838a8[_0x58b4f6(0x283)]&&(console[_0x58b4f6(0x20f)]('Site:\x20'+_0x2838a8[_0x58b4f6(0x21c)]),console[_0x58b4f6(0x20f)](_0x58b4f6(0x25f)+_0x3064ab),_0x3338ea&&console[_0x58b4f6(0x20f)](_0x58b4f6(0x1ef)+_0x3338ea));if(!_0x3338ea)return console['error'](_0x58b4f6(0x27a)),0x1;const _0x41bc99=await withSpinner(_0x58b4f6(0x27f)+_0x3064ab+_0x58b4f6(0x1e8),()=>_0x4642cd['segment'][_0x58b4f6(0x229)](_0x3064ab),{'verbose':_0x2838a8[_0x58b4f6(0x283)]}),_0xe6f687=_0x41bc99[_0x58b4f6(0x238)];_0x2838a8[_0x58b4f6(0x283)]&&console[_0x58b4f6(0x20f)]('Resolved\x20parent\x20ID:\x20'+_0xe6f687);const _0xb299eb=await withSpinner(_0x58b4f6(0x285)+_0x3338ea+_0x58b4f6(0x1e8),()=>_0x4642cd[_0x58b4f6(0x1f2)][_0x58b4f6(0x1fd)](_0xe6f687,_0x3338ea),{'verbose':_0x2838a8['verbose']}),_0x1ebaa6=_0xb299eb[_0x58b4f6(0x238)];_0x2838a8[_0x58b4f6(0x283)]&&console['error'](_0x58b4f6(0x230)+_0x1ebaa6);const _0x2c2b14=await withSpinner(_0x58b4f6(0x222)+_0x3338ea+_0x58b4f6(0x1e8),()=>_0x4642cd[_0x58b4f6(0x1f2)]['getFolder'](_0x1ebaa6),{'verbose':_0x2838a8[_0x58b4f6(0x283)]});return await handleSDKOutput([_0x2c2b14[_0x58b4f6(0x238)]],_0x2838a8),0x0;}catch(_0x24824f){if(_0x24824f instanceof SDKError)return console[_0x58b4f6(0x20f)]('Error:\x20'+_0x24824f[_0x58b4f6(0x1fb)]),_0x24824f[_0x58b4f6(0x242)]&&console[_0x58b4f6(0x20f)]('\x20\x20Cause:\x20'+_0x24824f[_0x58b4f6(0x242)]),0x1;throw _0x24824f;}}}export class SegmentSQLCommand extends BaseCommand{[a35_0x500582(0x250)]='segment:sql';[a35_0x500582(0x268)]=a35_0x500582(0x26d);async[a35_0x500582(0x23f)](_0x9a28c){const _0x480600=a35_0x500582,{options:_0x469aba,args:_0x46291b}=_0x9a28c,_0x472e69=_0x469aba,_0x6fe391=_0x472e69[_0x480600(0x206)],_0x2870e0=_0x46291b[0x0];if(!_0x2870e0&&!_0x6fe391)return console['error'](a35_0x2c9435[_0x480600(0x23d)](_0x480600(0x26e))),console[_0x480600(0x20f)]('Usage:'),console[_0x480600(0x20f)](_0x480600(0x278)),console[_0x480600(0x20f)](_0x480600(0x1e5)),console['error'](_0x480600(0x1f6)),console[_0x480600(0x20f)]('\x20\x20tdx\x20sg\x20sql\x20\x22Premium\x20Users\x22'),console[_0x480600(0x20f)](_0x480600(0x270)),0x1;if(_0x2870e0&&_0x6fe391)return console[_0x480600(0x20f)](a35_0x2c9435[_0x480600(0x23d)](_0x480600(0x22a))),0x1;try{let _0x41b39b;if(_0x6fe391)_0x41b39b=await this[_0x480600(0x24c)](_0x6fe391,_0x9a28c);else{if(isYamlFilePath(_0x2870e0))return console[_0x480600(0x20f)](a35_0x2c9435[_0x480600(0x23d)](_0x480600(0x1f0))),console[_0x480600(0x20f)](_0x480600(0x212)+_0x2870e0),0x1;else _0x41b39b=await this[_0x480600(0x202)](_0x2870e0,_0x9a28c);}return _0x469aba[_0x480600(0x259)]===_0x480600(0x217)||_0x469aba[_0x480600(0x259)]==='jsonl'?await handleSDKOutput([{'sql':_0x41b39b}],_0x469aba):console[_0x480600(0x224)](_0x41b39b),0x0;}catch(_0x2f07db){if(_0x2f07db instanceof SDKError)return console[_0x480600(0x20f)](_0x480600(0x25d)+_0x2f07db['message']),_0x2f07db[_0x480600(0x242)]&&console[_0x480600(0x20f)](_0x480600(0x288)+_0x2f07db[_0x480600(0x242)]),0x1;throw _0x2f07db;}}async['getSQLFromYamlFile'](_0x48d2ff,_0x59fafe){const _0x3aaed4=a35_0x500582,{options:_0xa6945c,tdx:_0x4ee636}=_0x59fafe;let _0x31df44;try{_0x31df44=await resolveYamlFilePath(_0x48d2ff);}catch(_0x3cf2c3){throw new SDKError(ErrorCode[_0x3aaed4(0x1ea)],_0x3aaed4(0x219)+_0x3cf2c3[_0x3aaed4(0x1fb)]);}_0xa6945c[_0x3aaed4(0x283)]&&console[_0x3aaed4(0x20f)](_0x3aaed4(0x20c)+_0x31df44[_0x3aaed4(0x234)]+'/'+_0x31df44[_0x3aaed4(0x277)]);const _0x45e8ed=await withSpinner(_0x3aaed4(0x200),()=>_0x4ee636[_0x3aaed4(0x1f2)][_0x3aaed4(0x228)](_0x31df44[_0x3aaed4(0x265)],_0x31df44[_0x3aaed4(0x234)],_0x31df44[_0x3aaed4(0x277)]),{'verbose':_0xa6945c[_0x3aaed4(0x283)]});return _0x45e8ed['data'];}async[a35_0x500582(0x202)](_0x111df1,_0x57ff77){const _0x3b195b=a35_0x500582,{options:_0x543a5e,tdx:_0x5662fe}=_0x57ff77,_0x55faf5=_0x543a5e['parentSegment'],_0x4af65f=await resolveSegmentTarget(_0x111df1,_0x55faf5,_0x543a5e[_0x3b195b(0x283)]);_0x543a5e[_0x3b195b(0x283)]&&console['error']('Target\x20path:\x20'+_0x4af65f);const _0x465ba8=await withSpinner('Resolving\x20\x27'+_0x111df1+_0x3b195b(0x1e8),()=>_0x5662fe[_0x3b195b(0x1f2)][_0x3b195b(0x221)](_0x4af65f),{'verbose':_0x543a5e['verbose']}),_0x51db23=_0x465ba8[_0x3b195b(0x238)];_0x543a5e[_0x3b195b(0x283)]&&(console['error'](_0x3b195b(0x20d)+_0x51db23['type']),console['error'](_0x3b195b(0x21b)+_0x51db23[_0x3b195b(0x261)]));if(_0x51db23[_0x3b195b(0x210)]==='folder')throw new SDKError(ErrorCode[_0x3b195b(0x1ea)],_0x3b195b(0x243));if(_0x51db23['type']===_0x3b195b(0x1f4))throw new SDKError(ErrorCode[_0x3b195b(0x1ea)],_0x3b195b(0x204));if(!_0x51db23[_0x3b195b(0x244)])throw new SDKError(ErrorCode[_0x3b195b(0x1f1)],_0x3b195b(0x280));const _0x17989a=await withSpinner(_0x3b195b(0x226),()=>_0x5662fe['segment'][_0x3b195b(0x275)](_0x51db23[_0x3b195b(0x261)],_0x51db23[_0x3b195b(0x244)]),{'verbose':_0x543a5e['verbose']});return _0x17989a[_0x3b195b(0x238)];}}export class SegmentFolderCreateCommand extends BaseCommand{[a35_0x500582(0x250)]=a35_0x500582(0x255);[a35_0x500582(0x268)]=a35_0x500582(0x20a);async[a35_0x500582(0x23f)](_0x58537d){const _0x326166=a35_0x500582,{options:_0x4c250e,args:_0x23af79,tdx:_0x884f1c}=_0x58537d,_0x2b912d=_0x4c250e;if(_0x23af79['length']<0x2)return console[_0x326166(0x20f)](_0x326166(0x269)),console[_0x326166(0x20f)](_0x326166(0x254)),0x1;const _0x1881e2=_0x23af79[0x0],_0x4d2f1d=_0x23af79[0x1];_0x2b912d['verbose']&&(console[_0x326166(0x20f)](_0x326166(0x205)+_0x2b912d[_0x326166(0x21c)]),console[_0x326166(0x20f)](_0x326166(0x27d)+_0x1881e2),console['error'](_0x326166(0x1ef)+_0x4d2f1d));let _0x50c830;if(_0x2b912d['parentFolder']){const _0x493cc8=_0x2b912d['parentFolder'],_0xa79752=await withSpinner(_0x326166(0x27f)+_0x1881e2+'\x27...',()=>_0x884f1c['segment'][_0x326166(0x229)](_0x1881e2),{'verbose':_0x2b912d[_0x326166(0x283)]}),_0x2cbb34=_0xa79752['data'],_0x3265be=await withSpinner(_0x326166(0x240)+_0x493cc8+_0x326166(0x1e8),()=>_0x884f1c[_0x326166(0x1f2)][_0x326166(0x1fd)](_0x2cbb34,_0x493cc8),{'verbose':_0x2b912d[_0x326166(0x283)]});_0x50c830=_0x3265be[_0x326166(0x238)],_0x2b912d['verbose']&&console[_0x326166(0x20f)]('Resolved\x20parent\x20folder\x20ID:\x20'+_0x50c830);}const _0x3f3250={'name':_0x4d2f1d,'description':_0x2b912d[_0x326166(0x268)],'parentFolderId':_0x50c830},_0x5d24b3=await withSpinner(_0x326166(0x262)+_0x4d2f1d+_0x326166(0x1e8),()=>_0x884f1c[_0x326166(0x1f2)][_0x326166(0x21a)](_0x1881e2,_0x3f3250),{'verbose':_0x2b912d['verbose']}),_0x4ed740=_0x5d24b3[_0x326166(0x238)];return console[_0x326166(0x20f)]('✔\x20Created\x20folder\x20\x27'+_0x4ed740[_0x326166(0x250)]+_0x326166(0x247)+_0x4ed740['id']),await handleSDKOutput([_0x4ed740],_0x2b912d),0x0;}}export class SegmentViewCommand extends BaseCommand{['name']=a35_0x500582(0x258);['description']=a35_0x500582(0x266);async[a35_0x500582(0x23f)](_0x1140ce){const _0x199449=a35_0x500582,{options:_0x5c01b2,args:_0x1640cd,tdx:_0xd87fa8}=_0x1140ce,_0x10b694=_0x1640cd[0x0];if(!_0x10b694)return console['error'](_0x199449(0x27c)),console['error'](_0x199449(0x201)),console[_0x199449(0x20f)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20view\x20<path/to/segment.yml>'),console[_0x199449(0x20f)](_0x199449(0x260)),console[_0x199449(0x20f)](_0x199449(0x1f5)),console[_0x199449(0x20f)](_0x199449(0x1f6)),console[_0x199449(0x20f)](_0x199449(0x232)),console[_0x199449(0x20f)]('\x20\x20tdx\x20sg\x20view\x20\x22Premium\x20Users\x22\x20\x20\x20\x20\x20#\x20View\x20child\x20segment\x20details'),console['error'](_0x199449(0x25e)),console['error']('\x20\x20tdx\x20sg\x20view\x20segments/my-audience/premium-users.yml'),0x1;try{const _0x12e05e=_0x5c01b2[_0x199449(0x234)],_0x1e9ad0=await resolveSegmentTarget(_0x10b694,_0x12e05e,_0x5c01b2[_0x199449(0x283)]);_0x5c01b2[_0x199449(0x283)]&&console[_0x199449(0x20f)](_0x199449(0x21e)+_0x1e9ad0);const _0x14315a=await withSpinner(_0x199449(0x263)+_0x10b694+_0x199449(0x1e8),()=>_0xd87fa8['segment'][_0x199449(0x221)](_0x1e9ad0),{'verbose':_0x5c01b2[_0x199449(0x283)]}),_0x14f020=_0x14315a[_0x199449(0x238)];_0x5c01b2[_0x199449(0x283)]&&(console[_0x199449(0x20f)](_0x199449(0x20d)+_0x14f020[_0x199449(0x210)]),console[_0x199449(0x20f)](_0x199449(0x21b)+_0x14f020['parentId']),_0x14f020[_0x199449(0x1e4)]&&console[_0x199449(0x20f)]('Folder\x20ID:\x20'+_0x14f020[_0x199449(0x1e4)]),_0x14f020[_0x199449(0x244)]&&console[_0x199449(0x20f)](_0x199449(0x274)+_0x14f020[_0x199449(0x244)]));if(_0x5c01b2[_0x199449(0x27e)]){if(_0x14f020[_0x199449(0x210)]===_0x199449(0x26c))return console[_0x199449(0x20f)](_0x199449(0x264)),0x1;if(_0x14f020[_0x199449(0x210)]===_0x199449(0x1f4))return console[_0x199449(0x20f)](_0x199449(0x251)),console[_0x199449(0x20f)]('Use:\x20tdx\x20ps\x20view\x20-w'),0x1;if(!_0x14f020[_0x199449(0x244)])throw new SDKError(ErrorCode[_0x199449(0x1f1)],_0x199449(0x280));const _0x4e08e6=getConsoleNextUrl(_0x5c01b2[_0x199449(0x21c)],_0x199449(0x28a)+_0x14f020[_0x199449(0x261)]+_0x199449(0x1ff)+_0x14f020[_0x199449(0x244)]);return console[_0x199449(0x20f)](a35_0x2c9435[_0x199449(0x203)]('✔')+_0x199449(0x272)+a35_0x2c9435[_0x199449(0x216)](_0x4e08e6)),openBrowser(_0x4e08e6),0x0;}if(_0x14f020[_0x199449(0x210)]===_0x199449(0x26c)){if(!_0x14f020['folderId'])throw new SDKError(ErrorCode[_0x199449(0x23a)],_0x199449(0x233));const _0x129a8a=await withSpinner('Fetching\x20folder\x20details...',()=>_0xd87fa8['segment'][_0x199449(0x248)](_0x14f020['folderId']),{'verbose':_0x5c01b2[_0x199449(0x283)]});await handleSingleObjectOutput(_0x129a8a[_0x199449(0x238)],_0x5c01b2);}else{if(_0x14f020[_0x199449(0x210)]==='segment'){if(!_0x14f020[_0x199449(0x244)])throw new SDKError(ErrorCode[_0x199449(0x1f1)],_0x199449(0x280));const _0x2d1f57=await withSpinner(_0x199449(0x281),()=>_0xd87fa8[_0x199449(0x1f2)][_0x199449(0x22f)](_0x14f020[_0x199449(0x261)],_0x14f020[_0x199449(0x244)]),{'verbose':_0x5c01b2['verbose']}),_0x26075b=getConsoleNextUrl(_0x5c01b2[_0x199449(0x21c)],_0x199449(0x28a)+_0x14f020['parentId']+_0x199449(0x1ff)+_0x14f020[_0x199449(0x244)]),_0x49b6e3=_0x2d1f57[_0x199449(0x238)];_0x49b6e3[_0x199449(0x218)]=_0x26075b,await handleSingleObjectOutput(_0x49b6e3,_0x5c01b2);}else return console['error'](_0x199449(0x245)),console[_0x199449(0x20f)](_0x199449(0x22c)),0x1;}return 0x0;}catch(_0x48c9c9){if(_0x48c9c9 instanceof SDKError)return console[_0x199449(0x20f)](_0x199449(0x25d)+_0x48c9c9[_0x199449(0x1fb)]),_0x48c9c9[_0x199449(0x242)]&&console[_0x199449(0x20f)](_0x199449(0x288)+_0x48c9c9[_0x199449(0x242)]),0x1;throw _0x48c9c9;}}}export const SegmentInfoCommand=SegmentViewCommand;function a35_0x5279(_0x16f262,_0x41fb09){_0x16f262=_0x16f262-0x1e4;const _0x314702=a35_0x3147();let _0x5279f8=_0x314702[_0x16f262];return _0x5279f8;}export class SegmentDescCommand extends BaseCommand{[a35_0x500582(0x250)]=a35_0x500582(0x22d);[a35_0x500582(0x268)]=a35_0x500582(0x27b);async[a35_0x500582(0x23f)](_0x3ba57a){const _0x11b17b=a35_0x500582,{options:_0x18cb03,args:_0x9c6330,tdx:_0x2c84a2}=_0x3ba57a,_0x24aee7=_0x9c6330[0x0];if(!_0x24aee7)return console[_0x11b17b(0x20f)](_0x11b17b(0x1ee)),console['error']('Usage:\x20tdx\x20sg\x20desc\x20<name>'),console[_0x11b17b(0x20f)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20desc\x20<path/to/segment.yml>'),console[_0x11b17b(0x20f)](_0x11b17b(0x1f6)),console[_0x11b17b(0x20f)]('\x20\x20tdx\x20sg\x20desc\x20\x22Premium\x20Users\x22'),console[_0x11b17b(0x20f)](_0x11b17b(0x249)),0x1;try{const _0x2fa767=_0x18cb03[_0x11b17b(0x234)],_0x3166e2=await resolveSegmentTarget(_0x24aee7,_0x2fa767,_0x18cb03[_0x11b17b(0x283)]);_0x18cb03[_0x11b17b(0x283)]&&console['error'](_0x11b17b(0x21e)+_0x3166e2);const _0x46d574=await withSpinner(_0x11b17b(0x263)+_0x24aee7+_0x11b17b(0x1e8),()=>_0x2c84a2[_0x11b17b(0x1f2)]['resolvePathToResource'](_0x3166e2),{'verbose':_0x18cb03[_0x11b17b(0x283)]}),_0x2882c1=_0x46d574[_0x11b17b(0x238)];_0x18cb03[_0x11b17b(0x283)]&&(console['error']('Resolved\x20type:\x20'+_0x2882c1[_0x11b17b(0x210)]),console[_0x11b17b(0x20f)]('Parent\x20ID:\x20'+_0x2882c1[_0x11b17b(0x261)]));if(_0x2882c1['type']===_0x11b17b(0x26c))return console[_0x11b17b(0x20f)](_0x11b17b(0x1ec)),console[_0x11b17b(0x20f)]('Folders\x20are\x20organizational\x20containers,\x20not\x20queryable\x20segments.'),0x1;if(_0x2882c1[_0x11b17b(0x210)]===_0x11b17b(0x1f4))return console[_0x11b17b(0x20f)]('Error:\x20Cannot\x20show\x20schema\x20for\x20parent\x20segment\x20with\x20this\x20command.'),console[_0x11b17b(0x20f)]('Use:\x20tdx\x20ps\x20desc'),0x1;if(!_0x2882c1[_0x11b17b(0x244)])throw new SDKError(ErrorCode[_0x11b17b(0x1f1)],_0x11b17b(0x280));const _0x1217ac=await withSpinner(_0x11b17b(0x226),()=>_0x2c84a2[_0x11b17b(0x1f2)][_0x11b17b(0x275)](_0x2882c1['parentId'],_0x2882c1[_0x11b17b(0x244)]),{'verbose':_0x18cb03[_0x11b17b(0x283)]}),_0x26de0b=_0x1217ac['data'],_0x371366=await executeSchemaQuery(_0x26de0b,_0x2c84a2,_0x18cb03);return await handleQueryOutput(_0x371366,_0x18cb03),0x0;}catch(_0x52206d){if(_0x52206d instanceof SDKError)return console[_0x11b17b(0x20f)](_0x11b17b(0x25d)+_0x52206d[_0x11b17b(0x1fb)]),_0x52206d[_0x11b17b(0x242)]&&console[_0x11b17b(0x20f)]('\x20\x20Cause:\x20'+_0x52206d[_0x11b17b(0x242)]),0x1;throw _0x52206d;}}}
|
|
1
|
+
const a35_0x3e5dea=a35_0x42a2;(function(_0x2d8c67,_0x2c25e9){const _0x4e18ff=a35_0x42a2,_0x56ba42=_0x2d8c67();while(!![]){try{const _0x456170=parseInt(_0x4e18ff(0x118))/0x1*(-parseInt(_0x4e18ff(0x12a))/0x2)+parseInt(_0x4e18ff(0xc1))/0x3*(parseInt(_0x4e18ff(0x121))/0x4)+-parseInt(_0x4e18ff(0x10e))/0x5+-parseInt(_0x4e18ff(0x96))/0x6+-parseInt(_0x4e18ff(0x111))/0x7*(-parseInt(_0x4e18ff(0xb5))/0x8)+-parseInt(_0x4e18ff(0xe3))/0x9+parseInt(_0x4e18ff(0x11f))/0xa;if(_0x456170===_0x2c25e9)break;else _0x56ba42['push'](_0x56ba42['shift']());}catch(_0x295650){_0x56ba42['push'](_0x56ba42['shift']());}}}(a35_0x49ff,0x719f6));import{BaseCommand}from'./command.js';import{SDKError,ErrorCode}from'../sdk/index.js';import{handleSDKOutput,handleQueryOutput,handleSingleObjectOutput}from'../core/command-output.js';import{withSpinner,withProgressSpinner,formatElapsed}from'../utils/spinner.js';import{parseSegmentRef}from'../sdk/segment/segment-ref-parser.js';import{DEFAULT_DISPLAY_LIMIT,resolveLimit}from'../core/constants.js';import{executeSchemaQuery}from'../sdk/segment/fields-display.js';import{isYamlFilePath,resolveYamlFilePath}from'../sdk/segment/segment-path-parser.js';import{getConsoleNextUrl}from'../sdk/client/endpoints.js';import{openBrowser}from'../utils/process.js';import a35_0x135643 from'chalk';async function resolveSegmentTarget(_0x42286c,_0x1c5c68,_0x8e1ef7){const _0x3564f5=a35_0x42a2;if(isYamlFilePath(_0x42286c))try{const _0x197ae0=await resolveYamlFilePath(_0x42286c);return _0x8e1ef7&&(console[_0x3564f5(0x122)](_0x3564f5(0xcd)+_0x42286c),console[_0x3564f5(0x122)]('\x20\x20Parent\x20segment:\x20'+_0x197ae0[_0x3564f5(0xd4)]),console[_0x3564f5(0x122)](_0x3564f5(0x11a)+_0x197ae0[_0x3564f5(0x9e)]),console[_0x3564f5(0x122)](_0x3564f5(0xb7)+(_0x197ae0['folderPath']||_0x3564f5(0xfc))),console[_0x3564f5(0x122)](_0x3564f5(0x95)+_0x197ae0['fullPath'])),_0x197ae0[_0x3564f5(0x124)];}catch(_0x398054){throw new SDKError(ErrorCode[_0x3564f5(0xd7)],_0x3564f5(0x12f)+_0x398054[_0x3564f5(0x8e)]);}if(!_0x1c5c68)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'No\x20parent\x20segment\x20context\x20set.\x20Set\x20context\x20with:\x20tdx\x20sg\x20use\x20\x22Name\x22\x20or\x20tdx\x20sg\x20pull\x20\x22Name\x22');return _0x1c5c68+'/'+_0x42286c;}function a35_0x42a2(_0x1665aa,_0x2d589a){_0x1665aa=_0x1665aa-0x8c;const _0x49ff3e=a35_0x49ff();let _0x42a2ff=_0x49ff3e[_0x1665aa];return _0x42a2ff;}export class SegmentDescribeCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]=a35_0x3e5dea(0x100);['description']=a35_0x3e5dea(0x128);async[a35_0x3e5dea(0xe1)](_0x50a47){const _0x4f2149=a35_0x3e5dea,{options:_0x4b6a2f,args:_0x4bf9d2,tdx:_0x50cd5b}=_0x50a47,_0x29943c=_0x4bf9d2[0x0],_0x4b347c=!_0x29943c&&!!_0x4b6a2f[_0x4f2149(0xd4)],_0x18e0d4=_0x29943c||_0x4b6a2f[_0x4f2149(0xd4)];if(!_0x18e0d4)return console['error']('Error:\x20Path\x20or\x20name\x20is\x20required'),console['error'](_0x4f2149(0x125)),console[_0x4f2149(0x122)](_0x4f2149(0xad)),console['error'](_0x4f2149(0x8f)),console[_0x4f2149(0x122)](_0x4f2149(0xc3)),console[_0x4f2149(0x122)](_0x4f2149(0x104)),console['error'](_0x4f2149(0xd3)),0x1;try{const _0x61862=_0x4b6a2f['segmentPath'];let _0x518b91=_0x18e0d4;!_0x4b347c&&_0x61862&&!_0x18e0d4['includes']('/')&&(_0x518b91=_0x61862+'/'+_0x18e0d4,_0x4b6a2f[_0x4f2149(0xe0)]&&console['error'](_0x4f2149(0xbc)+_0x518b91));const _0x1a8fec=await withSpinner('Resolving\x20path\x20\x27'+_0x518b91+'\x27...',()=>_0x50cd5b[_0x4f2149(0xd9)][_0x4f2149(0x9f)](_0x518b91),{'verbose':_0x4b6a2f['verbose']}),_0x3a7719=_0x1a8fec[_0x4f2149(0xea)];_0x4b6a2f[_0x4f2149(0xe0)]&&(console['error'](_0x4f2149(0x9d)+_0x3a7719[_0x4f2149(0x90)]),console[_0x4f2149(0x122)](_0x4f2149(0xff)+_0x3a7719[_0x4f2149(0xcb)]),_0x3a7719[_0x4f2149(0xf1)]&&console[_0x4f2149(0x122)](_0x4f2149(0x8c)+_0x3a7719[_0x4f2149(0xf1)]),_0x3a7719[_0x4f2149(0x109)]&&console[_0x4f2149(0x122)](_0x4f2149(0x91)+_0x3a7719['segmentId']));if(_0x3a7719[_0x4f2149(0x90)]==='parent'){const _0x33cb94=await withSpinner('Fetching\x20parent\x20segment\x20details...',()=>_0x50cd5b[_0x4f2149(0xd9)]['getParent'](_0x3a7719[_0x4f2149(0xcb)]),{'verbose':_0x4b6a2f[_0x4f2149(0xe0)]});await handleSingleObjectOutput(_0x33cb94[_0x4f2149(0xea)],_0x4b6a2f);}else{if(_0x3a7719[_0x4f2149(0x90)]==='folder'){if(!_0x3a7719[_0x4f2149(0xf1)])throw new SDKError(ErrorCode[_0x4f2149(0x9b)],_0x4f2149(0xb2));const _0x1f374f=await withSpinner(_0x4f2149(0xa5),()=>_0x50cd5b[_0x4f2149(0xd9)][_0x4f2149(0x112)](_0x3a7719['folderId']),{'verbose':_0x4b6a2f[_0x4f2149(0xe0)]});await handleSingleObjectOutput(_0x1f374f[_0x4f2149(0xea)],_0x4b6a2f);}else{if(_0x3a7719[_0x4f2149(0x90)]==='segment'){if(!_0x3a7719[_0x4f2149(0x109)])throw new SDKError(ErrorCode[_0x4f2149(0xfd)],'Segment\x20ID\x20missing\x20from\x20resolved\x20path');const _0x3bd4a1=await withSpinner('Fetching\x20segment\x20details...',()=>_0x50cd5b[_0x4f2149(0xd9)]['getSegment'](_0x3a7719[_0x4f2149(0xcb)],_0x3a7719[_0x4f2149(0x109)]),{'verbose':_0x4b6a2f[_0x4f2149(0xe0)]});await handleSingleObjectOutput(_0x3bd4a1[_0x4f2149(0xea)],_0x4b6a2f);}}}return 0x0;}catch(_0xbcf581){if(_0xbcf581 instanceof SDKError)return console[_0x4f2149(0x122)](_0x4f2149(0xd0)+_0xbcf581[_0x4f2149(0x8e)]),_0xbcf581[_0x4f2149(0x107)]&&console[_0x4f2149(0x122)](_0x4f2149(0xce)+_0xbcf581[_0x4f2149(0x107)]),0x1;throw _0xbcf581;}}}export class SegmentShowCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]=a35_0x3e5dea(0xa9);[a35_0x3e5dea(0x129)]=a35_0x3e5dea(0x126);async['execute'](_0x28bf08){const _0x28c164=a35_0x3e5dea,{options:_0x5e360c,args:_0x2c5c6e,tdx:_0x589c78}=_0x28bf08,_0x13d4c6=_0x2c5c6e[0x0];if(!_0x13d4c6)return console['error']('Error:\x20Child\x20segment\x20name\x20or\x20YAML\x20file\x20path\x20is\x20required'),console[_0x28c164(0x122)](_0x28c164(0xdd)),console[_0x28c164(0x122)](_0x28c164(0xf6)),console['error'](_0x28c164(0xad)),console[_0x28c164(0x122)](_0x28c164(0xd5)),console[_0x28c164(0x122)](_0x28c164(0x106)),0x1;try{const _0x23c2b6=_0x5e360c[_0x28c164(0xd4)],_0x17513e=await resolveSegmentTarget(_0x13d4c6,_0x23c2b6,_0x5e360c[_0x28c164(0xe0)]);_0x5e360c['verbose']&&console[_0x28c164(0x122)](_0x28c164(0x123)+_0x17513e);const _0x8f910c=await withSpinner(_0x28c164(0xc8)+_0x13d4c6+'\x27...',()=>_0x589c78[_0x28c164(0xd9)][_0x28c164(0x9f)](_0x17513e),{'verbose':_0x5e360c['verbose']}),_0x55366a=_0x8f910c[_0x28c164(0xea)];_0x5e360c[_0x28c164(0xe0)]&&(console[_0x28c164(0x122)](_0x28c164(0x9d)+_0x55366a[_0x28c164(0x90)]),console[_0x28c164(0x122)](_0x28c164(0xff)+_0x55366a[_0x28c164(0xcb)]));if(_0x55366a[_0x28c164(0x90)]===_0x28c164(0x10a))return console[_0x28c164(0x122)](_0x28c164(0xe5)),console[_0x28c164(0x122)](_0x28c164(0xbe)),0x1;if(_0x55366a[_0x28c164(0x90)]===_0x28c164(0x12e))return console['error'](_0x28c164(0xb0)),console[_0x28c164(0x122)](_0x28c164(0x101)),0x1;if(!_0x55366a[_0x28c164(0x109)])throw new SDKError(ErrorCode[_0x28c164(0xfd)],_0x28c164(0xf0));const _0xd24942=await withSpinner(_0x28c164(0x10f),()=>_0x589c78[_0x28c164(0xd9)]['getSegmentSQL'](_0x55366a['parentId'],_0x55366a[_0x28c164(0x109)]),{'verbose':_0x5e360c[_0x28c164(0xe0)]});let _0x135276=_0xd24942[_0x28c164(0xea)];const _0x312da4=resolveLimit(_0x5e360c[_0x28c164(0x113)],DEFAULT_DISPLAY_LIMIT),_0x10ce16=/\bLIMIT\s+\d+/i[_0x28c164(0xed)](_0x135276);!_0x10ce16&&(_0x135276=_0x135276[_0x28c164(0x119)]()['replace'](/;+$/,''),_0x135276=_0x28c164(0x103)+_0x135276+_0x28c164(0x11e)+_0x312da4);_0x5e360c[_0x28c164(0xe0)]&&console[_0x28c164(0x122)](_0x28c164(0xc9)+_0x135276);const _0x214b63=await withProgressSpinner(_0x28c164(0xfe),async _0x30079e=>{const _0x573661=_0x28c164,_0x472742=await _0x589c78['query'][_0x573661(0xe1)](_0x135276,{'catalog':'td','schema':_0x573661(0x99),'onJobId':_0x2ad46e=>{const _0x3a81fd=_0x573661;_0x30079e[_0x3a81fd(0x10d)](_0x2ad46e);}});return _0x472742;},{'verbose':_0x5e360c[_0x28c164(0xe0)]}),_0x1a3954=_0x214b63[_0x28c164(0xea)],_0x106b4c=_0x1a3954[_0x28c164(0x130)]?_0x28c164(0xe4)+_0x1a3954[_0x28c164(0x130)]+']':'';return console[_0x28c164(0x122)](_0x28c164(0xdb)+_0x1a3954[_0x28c164(0xb8)]['processedRows']['toLocaleString']()+_0x28c164(0xba)+(_0x28c164(0xd6)+formatElapsed(_0x1a3954['stats'][_0x28c164(0x102)])+_0x106b4c)),await handleQueryOutput(_0x1a3954,_0x5e360c),0x0;}catch(_0x1aa3d9){if(_0x1aa3d9 instanceof SDKError)return console[_0x28c164(0x122)]('✖\x20Query\x20failed\x20['+_0x1aa3d9[_0x28c164(0xf3)]+']'),console[_0x28c164(0x122)]('\x0a'+_0x1aa3d9['message']),0x1;throw _0x1aa3d9;}}}export class SegmentFolderListCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]=a35_0x3e5dea(0xf9);[a35_0x3e5dea(0x129)]='List\x20segment\x20folders\x20under\x20a\x20parent\x20segment';async[a35_0x3e5dea(0xe1)](_0x7c2525){const _0x291860=a35_0x3e5dea,{options:_0x54f687,args:_0x437c64,tdx:_0x1d17eb}=_0x7c2525;if(_0x437c64['length']===0x0)return console[_0x291860(0x122)]('Error:\x20Parent\x20segment\x20name\x20is\x20required'),console[_0x291860(0x122)](_0x291860(0x10c)),0x1;const _0x3070fb=_0x437c64[0x0];try{_0x54f687[_0x291860(0xe0)]&&(console[_0x291860(0x122)](_0x291860(0xd8)+_0x54f687[_0x291860(0xa1)]),console[_0x291860(0x122)]('Parent\x20name:\x20'+_0x3070fb));const _0x33e5ed=await withSpinner('Resolving\x20parent\x20segment\x20\x27'+_0x3070fb+_0x291860(0xe9),()=>_0x1d17eb['segment']['resolveParentId'](_0x3070fb),{'verbose':_0x54f687['verbose']}),_0x197608=_0x33e5ed[_0x291860(0xea)];_0x54f687[_0x291860(0xe0)]&&console['error']('Resolved\x20parent\x20ID:\x20'+_0x197608);const _0x1955e9=await withSpinner('Listing\x20folders\x20for\x20parent\x20\x27'+_0x3070fb+'\x27...',()=>_0x1d17eb[_0x291860(0xd9)][_0x291860(0xfa)](_0x197608),{'verbose':_0x54f687[_0x291860(0xe0)]}),_0xd6001=_0x1955e9[_0x291860(0xea)];return console[_0x291860(0x122)](_0x291860(0x93)+_0xd6001[_0x291860(0xaf)]+_0x291860(0x116)+(_0xd6001['length']!==0x1?'s':'')),await handleSDKOutput(_0xd6001,_0x54f687),0x0;}catch(_0x45b8dd){if(_0x45b8dd instanceof SDKError)return console['error'](_0x291860(0xd0)+_0x45b8dd['message']),_0x45b8dd[_0x291860(0x107)]&&console['error']('\x20\x20Cause:\x20'+_0x45b8dd['cause']),0x1;throw _0x45b8dd;}}}function a35_0x49ff(){const _0x9aa8b=['listFolders','resolveParentId','(root)','SEGMENT_NOT_FOUND','Executing\x20segment\x20query...','Parent\x20ID:\x20','segment:describe','Use:\x20tdx\x20ps\x20show','elapsedTimeMillis','SELECT\x20*\x20FROM\x20(\x0a','\x20\x20tdx\x20segment\x20describe\x20\x22High\x20Value\x22\x20\x20\x20\x20#\x20Relative\x20to\x20current\x20context','Get\x20SQL\x20query\x20for\x20child\x20segment','\x20\x20tdx\x20sg\x20show\x20segments/my-audience/premium-users.yml','cause','Usage:\x20tdx\x20segment\x20folder\x20show\x20<parent_name/folder_name>','segmentId','folder','content','Usage:\x20tdx\x20segment\x20folder\x20list\x20<parent_name>','setJobId','4192940RceeGm','Fetching\x20SQL\x20for\x20segment...','Usage:\x20tdx\x20segment\x20folder\x20create\x20<parent_name>\x20<folder_name>\x20[options]','14aZnRmC','getFolder','limit','\x20\x20tdx\x20sg\x20sql\x20--path\x20segments/my-audience/premium-users.yml','Resolved\x20parent\x20ID:\x20','\x20folder','createFolder','85413bVtCJA','trim','\x20\x20Segment\x20name:\x20','url','/app/ps/','Parent\x20name:\x20','\x0a)\x20AS\x20segment_query\x0aLIMIT\x20','21062580NbHcuh','green','438004xvanSh','error','Target\x20path:\x20','fullPath','Usage:\x20tdx\x20segment\x20describe\x20<path>','Execute\x20child\x20segment\x20SQL\x20query\x20and\x20show\x20results','Resolving\x20parent\x20segment\x20\x27','Show\x20segment\x20or\x20folder\x20details','description','2seDgqz','\x20\x20tdx\x20sg\x20view\x20\x22Premium\x20Users\x22\x20-w\x20\x20#\x20Open\x20segment\x20in\x20web\x20browser','Usage:\x20tdx\x20sg\x20desc\x20<name>','/e/','parent','Failed\x20to\x20resolve\x20YAML\x20file\x20path:\x20','jobId','Folder\x20ID:\x20','resolveFolderId','message','\x20\x20tdx\x20segment\x20describe\x20\x22My\x20Audience\x22','type','Segment\x20ID:\x20','Parent\x20segment:\x20','✔\x20Found\x20','\x20\x20Local\x20YAML\x20file:\x20\x20\x20\x20\x20\x20tdx\x20sg\x20sql\x20--path\x20<file-path>','\x20\x20Full\x20path:\x20','5356350nmghEK','Error:\x20Cannot\x20view\x20parent\x20segment\x20details\x20with\x20this\x20command.','Error:\x20Folder\x20or\x20segment\x20name,\x20or\x20YAML\x20file\x20path\x20is\x20required','information_schema','Error:\x20Cannot\x20show\x20schema\x20for\x20parent\x20segment\x20with\x20this\x20command.','SEGMENT_FOLDER_NOT_FOUND','segment:sql','Resolved\x20type:\x20','segmentName','resolvePathToResource','Resolving\x20folder\x20\x27','site','Cannot\x20get\x20SQL\x20query\x20for\x20a\x20folder.\x20Folders\x20are\x20organizational\x20containers,\x20not\x20queryable\x20segments.','Fetching\x20segment\x20details...','\x20Opening\x20','Fetching\x20folder\x20details...','name','\x27\x20with\x20ID:\x20','✔\x20Created\x20folder\x20\x27','segment:show','Error:\x20Cannot\x20show\x20schema\x20for\x20a\x20folder.','format','Error:\x20Parent\x20segment\x20name\x20and\x20folder\x20name\x20are\x20required','Examples:','Use:\x20tdx\x20ps\x20desc','length','Error:\x20Cannot\x20execute\x20query\x20for\x20parent\x20segment\x20with\x20this\x20command.','segment:folder:show','Folder\x20ID\x20missing\x20from\x20resolved\x20path','Create\x20segment\x20folder\x20for\x20organization','segment:desc','1052000wbQImT','getSegment','\x20\x20Folder\x20path:\x20','stats','\x20\x20tdx\x20sg\x20view\x20segments/my-audience/premium-users.yml','\x20rows\x20','getSQLFromYamlFile','Resolved\x20relative\x20path\x20to:\x20','Show\x20folder\x20or\x20child\x20segment\x20details','Use:\x20tdx\x20sg\x20view\x20<name>\x20\x20#\x20To\x20show\x20folder\x20details','getSQLFromServerSegment','Error:\x20Specify\x20either\x20segment\x20name\x20or\x20--path,\x20not\x20both','12kdChtJ','Error:\x20Cannot\x20open\x20parent\x20segment\x20with\x20this\x20command.','\x20\x20tdx\x20segment\x20describe\x20\x22My\x20Audience/Marketing/High\x20Value\x22','\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20view\x20<path/to/segment.yml>','Options:','Use:\x20tdx\x20ps\x20view\x20-w','red','Resolving\x20\x27','SQL\x20query:\x0a','getSegmentSQL','parentId','segment:view','Resolved\x20YAML\x20file:\x20','\x20\x20Cause:\x20','cyan','Error:\x20','\x20\x20tdx\x20sg\x20desc\x20segments/my-audience/premium-users.yml','jsonl','\x20\x20Or\x20set\x20context:\x20tdx\x20use\x20parent_segment\x20<name>','parentSegment','\x20\x20tdx\x20sg\x20show\x20\x22Premium\x20Users\x22','in\x20','INVALID_ARGUMENT','Site:\x20','segment','Show\x20child\x20segment\x20schema\x20(column\x20types)','✔\x20Query\x20completed:\x20Processed\x20','Fetching\x20folder\x20\x27','Usage:\x20tdx\x20sg\x20show\x20<name>','\x20\x20tdx\x20sg\x20sql\x20\x22Premium\x20Users\x22','Resolved:\x20','verbose','execute','Folder\x20name:\x20','4726242dYxstT','\x20[Job\x20ID:\x20','Error:\x20Cannot\x20execute\x20SQL\x20query\x20on\x20a\x20folder.','\x20\x20tdx\x20sg\x20desc\x20\x22Premium\x20Users\x22','Error:\x20YAML\x20file\x20paths\x20must\x20be\x20specified\x20with\x20--path\x20option','Error:\x20Child\x20segment\x20name\x20or\x20YAML\x20file\x20path\x20is\x20required','\x27...','data','Folders\x20are\x20organizational\x20containers,\x20not\x20queryable\x20segments.','\x20\x20Server-side\x20segment:\x20\x20tdx\x20sg\x20sql\x20<name>','test','getSegmentSQLFromYaml','Usage:','Segment\x20ID\x20missing\x20from\x20resolved\x20path','folderId','web','code','parentFolder','Resolved\x20folder\x20ID:\x20','\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20show\x20<path/to/segment.yml>','Error:\x20Segment\x20name\x20or\x20--path\x20is\x20required','\x20\x20tdx\x20sg\x20sql\x20--path\x20','segment:folder:list'];a35_0x49ff=function(){return _0x9aa8b;};return a35_0x49ff();}export class SegmentFolderShowCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]=a35_0x3e5dea(0xb1);[a35_0x3e5dea(0x129)]='Show\x20segment\x20folder\x20details';async[a35_0x3e5dea(0xe1)](_0x1f760a){const _0x17224d=a35_0x3e5dea,{options:_0x2eddfa,args:_0x5e51cf,tdx:_0xdca224}=_0x1f760a;if(_0x5e51cf[_0x17224d(0xaf)]===0x0)return console[_0x17224d(0x122)]('Error:\x20Folder\x20reference\x20is\x20required'),console[_0x17224d(0x122)](_0x17224d(0x108)),0x1;try{const {parentId:_0x3dd6e0,childId:_0x598db0}=parseSegmentRef(_0x5e51cf[0x0]);_0x2eddfa[_0x17224d(0xe0)]&&(console[_0x17224d(0x122)](_0x17224d(0xd8)+_0x2eddfa[_0x17224d(0xa1)]),console[_0x17224d(0x122)](_0x17224d(0x11d)+_0x3dd6e0),_0x598db0&&console[_0x17224d(0x122)](_0x17224d(0xe2)+_0x598db0));if(!_0x598db0)return console[_0x17224d(0x122)]('Error:\x20Folder\x20name\x20is\x20required\x20(use\x20parent_name/folder_name\x20format)'),0x1;const _0x97bddd=await withSpinner(_0x17224d(0x127)+_0x3dd6e0+_0x17224d(0xe9),()=>_0xdca224[_0x17224d(0xd9)]['resolveParentId'](_0x3dd6e0),{'verbose':_0x2eddfa[_0x17224d(0xe0)]}),_0x4cbe91=_0x97bddd['data'];_0x2eddfa[_0x17224d(0xe0)]&&console['error'](_0x17224d(0x115)+_0x4cbe91);const _0x1e0688=await withSpinner(_0x17224d(0xa0)+_0x598db0+_0x17224d(0xe9),()=>_0xdca224[_0x17224d(0xd9)][_0x17224d(0x8d)](_0x4cbe91,_0x598db0),{'verbose':_0x2eddfa[_0x17224d(0xe0)]}),_0x2b56f0=_0x1e0688[_0x17224d(0xea)];_0x2eddfa['verbose']&&console[_0x17224d(0x122)](_0x17224d(0xf5)+_0x2b56f0);const _0x2ac603=await withSpinner(_0x17224d(0xdc)+_0x598db0+'\x27...',()=>_0xdca224[_0x17224d(0xd9)][_0x17224d(0x112)](_0x2b56f0),{'verbose':_0x2eddfa[_0x17224d(0xe0)]});return await handleSDKOutput([_0x2ac603[_0x17224d(0xea)]],_0x2eddfa),0x0;}catch(_0x5374fa){if(_0x5374fa instanceof SDKError)return console[_0x17224d(0x122)](_0x17224d(0xd0)+_0x5374fa[_0x17224d(0x8e)]),_0x5374fa[_0x17224d(0x107)]&&console[_0x17224d(0x122)](_0x17224d(0xce)+_0x5374fa[_0x17224d(0x107)]),0x1;throw _0x5374fa;}}}export class SegmentSQLCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]=a35_0x3e5dea(0x9c);[a35_0x3e5dea(0x129)]=a35_0x3e5dea(0x105);async['execute'](_0x485c86){const _0x25eb62=a35_0x3e5dea,{options:_0x5d56a5,args:_0x1f11dd}=_0x485c86,_0x2a3ba9=_0x5d56a5,_0xcdee49=_0x2a3ba9['path'],_0x485734=_0x1f11dd[0x0];if(!_0x485734&&!_0xcdee49)return console['error'](a35_0x135643[_0x25eb62(0xc7)](_0x25eb62(0xf7))),console[_0x25eb62(0x122)](_0x25eb62(0xef)),console['error'](_0x25eb62(0xec)),console['error'](_0x25eb62(0x94)),console[_0x25eb62(0x122)](_0x25eb62(0xad)),console[_0x25eb62(0x122)](_0x25eb62(0xde)),console['error'](_0x25eb62(0x114)),0x1;if(_0x485734&&_0xcdee49)return console[_0x25eb62(0x122)](a35_0x135643['red'](_0x25eb62(0xc0))),0x1;try{let _0x14f1fc;if(_0xcdee49)_0x14f1fc=await this[_0x25eb62(0xbb)](_0xcdee49,_0x485c86);else{if(isYamlFilePath(_0x485734))return console[_0x25eb62(0x122)](a35_0x135643['red'](_0x25eb62(0xe7))),console[_0x25eb62(0x122)](_0x25eb62(0xf8)+_0x485734),0x1;else _0x14f1fc=await this[_0x25eb62(0xbf)](_0x485734,_0x485c86);}return _0x5d56a5[_0x25eb62(0xab)]==='json'||_0x5d56a5[_0x25eb62(0xab)]===_0x25eb62(0xd2)?await handleSDKOutput([{'sql':_0x14f1fc}],_0x5d56a5):console['log'](_0x14f1fc),0x0;}catch(_0x5147f7){if(_0x5147f7 instanceof SDKError)return console[_0x25eb62(0x122)]('Error:\x20'+_0x5147f7[_0x25eb62(0x8e)]),_0x5147f7[_0x25eb62(0x107)]&&console['error'](_0x25eb62(0xce)+_0x5147f7['cause']),0x1;throw _0x5147f7;}}async[a35_0x3e5dea(0xbb)](_0x422814,_0x2a1c86){const _0x2baf55=a35_0x3e5dea,{options:_0xd04aca,tdx:_0x377aa2}=_0x2a1c86;let _0x48525c;try{_0x48525c=await resolveYamlFilePath(_0x422814);}catch(_0x4b88ec){throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x2baf55(0x12f)+_0x4b88ec[_0x2baf55(0x8e)]);}_0xd04aca[_0x2baf55(0xe0)]&&console[_0x2baf55(0x122)](_0x2baf55(0xdf)+_0x48525c['parentSegment']+'/'+_0x48525c['segmentName']);const _0x57fa99=await withSpinner('Fetching\x20SQL\x20from\x20rule...',()=>_0x377aa2['segment'][_0x2baf55(0xee)](_0x48525c[_0x2baf55(0x10b)],_0x48525c[_0x2baf55(0xd4)],_0x48525c['segmentName']),{'verbose':_0xd04aca['verbose']});return _0x57fa99[_0x2baf55(0xea)];}async['getSQLFromServerSegment'](_0x3892f0,_0x451e2a){const _0x4fc67a=a35_0x3e5dea,{options:_0x5d50a4,tdx:_0x2b9dbc}=_0x451e2a,_0x27fe12=_0x5d50a4[_0x4fc67a(0xd4)],_0x22e9dd=await resolveSegmentTarget(_0x3892f0,_0x27fe12,_0x5d50a4['verbose']);_0x5d50a4[_0x4fc67a(0xe0)]&&console[_0x4fc67a(0x122)](_0x4fc67a(0x123)+_0x22e9dd);const _0x2c61c8=await withSpinner(_0x4fc67a(0xc8)+_0x3892f0+_0x4fc67a(0xe9),()=>_0x2b9dbc[_0x4fc67a(0xd9)][_0x4fc67a(0x9f)](_0x22e9dd),{'verbose':_0x5d50a4['verbose']}),_0x384b48=_0x2c61c8[_0x4fc67a(0xea)];_0x5d50a4['verbose']&&(console['error'](_0x4fc67a(0x9d)+_0x384b48[_0x4fc67a(0x90)]),console['error'](_0x4fc67a(0xff)+_0x384b48[_0x4fc67a(0xcb)]));if(_0x384b48[_0x4fc67a(0x90)]===_0x4fc67a(0x10a))throw new SDKError(ErrorCode[_0x4fc67a(0xd7)],_0x4fc67a(0xa2));if(_0x384b48[_0x4fc67a(0x90)]==='parent')throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Cannot\x20get\x20SQL\x20for\x20parent\x20segment\x20with\x20this\x20command.\x20Use:\x20tdx\x20ps\x20sql');if(!_0x384b48[_0x4fc67a(0x109)])throw new SDKError(ErrorCode[_0x4fc67a(0xfd)],_0x4fc67a(0xf0));const _0x357fbc=await withSpinner(_0x4fc67a(0x10f),()=>_0x2b9dbc[_0x4fc67a(0xd9)][_0x4fc67a(0xca)](_0x384b48[_0x4fc67a(0xcb)],_0x384b48[_0x4fc67a(0x109)]),{'verbose':_0x5d50a4['verbose']});return _0x357fbc[_0x4fc67a(0xea)];}}export class SegmentFolderCreateCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]='segment:folder:create';[a35_0x3e5dea(0x129)]=a35_0x3e5dea(0xb3);async[a35_0x3e5dea(0xe1)](_0x2c4066){const _0x10c7d5=a35_0x3e5dea,{options:_0x3a3419,args:_0x2a9c6a,tdx:_0x33b8e3}=_0x2c4066,_0x5ba638=_0x3a3419;if(_0x2a9c6a[_0x10c7d5(0xaf)]<0x2)return console['error'](_0x10c7d5(0xac)),console['error'](_0x10c7d5(0x110)),0x1;const _0x23fcb4=_0x2a9c6a[0x0],_0x426b17=_0x2a9c6a[0x1];_0x5ba638[_0x10c7d5(0xe0)]&&(console[_0x10c7d5(0x122)]('Site:\x20'+_0x5ba638[_0x10c7d5(0xa1)]),console[_0x10c7d5(0x122)](_0x10c7d5(0x92)+_0x23fcb4),console[_0x10c7d5(0x122)](_0x10c7d5(0xe2)+_0x426b17));let _0x354fd8;if(_0x5ba638[_0x10c7d5(0xf4)]){const _0x841676=_0x5ba638[_0x10c7d5(0xf4)],_0x46b68d=await withSpinner(_0x10c7d5(0x127)+_0x23fcb4+_0x10c7d5(0xe9),()=>_0x33b8e3[_0x10c7d5(0xd9)][_0x10c7d5(0xfb)](_0x23fcb4),{'verbose':_0x5ba638[_0x10c7d5(0xe0)]}),_0x54a4de=_0x46b68d[_0x10c7d5(0xea)],_0x435991=await withSpinner('Resolving\x20parent\x20folder\x20\x27'+_0x841676+_0x10c7d5(0xe9),()=>_0x33b8e3[_0x10c7d5(0xd9)][_0x10c7d5(0x8d)](_0x54a4de,_0x841676),{'verbose':_0x5ba638[_0x10c7d5(0xe0)]});_0x354fd8=_0x435991[_0x10c7d5(0xea)],_0x5ba638[_0x10c7d5(0xe0)]&&console[_0x10c7d5(0x122)]('Resolved\x20parent\x20folder\x20ID:\x20'+_0x354fd8);}const _0x20f1b3={'name':_0x426b17,'description':_0x5ba638[_0x10c7d5(0x129)],'parentFolderId':_0x354fd8},_0x5c2d32=await withSpinner('Creating\x20folder\x20\x27'+_0x426b17+_0x10c7d5(0xe9),()=>_0x33b8e3[_0x10c7d5(0xd9)][_0x10c7d5(0x117)](_0x23fcb4,_0x20f1b3),{'verbose':_0x5ba638[_0x10c7d5(0xe0)]}),_0x26bbb8=_0x5c2d32[_0x10c7d5(0xea)];return console[_0x10c7d5(0x122)](_0x10c7d5(0xa8)+_0x26bbb8[_0x10c7d5(0xa6)]+_0x10c7d5(0xa7)+_0x26bbb8['id']),await handleSDKOutput([_0x26bbb8],_0x5ba638),0x0;}}export class SegmentViewCommand extends BaseCommand{[a35_0x3e5dea(0xa6)]=a35_0x3e5dea(0xcc);[a35_0x3e5dea(0x129)]=a35_0x3e5dea(0xbd);async[a35_0x3e5dea(0xe1)](_0x4ec440){const _0x2cb060=a35_0x3e5dea,{options:_0x47d200,args:_0xc22053,tdx:_0x6601ce}=_0x4ec440,_0x3e2561=_0xc22053[0x0];if(!_0x3e2561)return console[_0x2cb060(0x122)](_0x2cb060(0x98)),console[_0x2cb060(0x122)]('Usage:\x20tdx\x20sg\x20view\x20<name>\x20[-w]'),console[_0x2cb060(0x122)](_0x2cb060(0xc4)),console['error'](_0x2cb060(0xc5)),console[_0x2cb060(0x122)]('\x20\x20-w,\x20--web\x20\x20Open\x20segment\x20in\x20web\x20browser'),console['error']('Examples:'),console['error']('\x20\x20tdx\x20sg\x20view\x20\x22Marketing\x22\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20View\x20folder\x20details'),console[_0x2cb060(0x122)]('\x20\x20tdx\x20sg\x20view\x20\x22Premium\x20Users\x22\x20\x20\x20\x20\x20#\x20View\x20child\x20segment\x20details'),console['error'](_0x2cb060(0x12b)),console['error'](_0x2cb060(0xb9)),0x1;try{const _0x2c6536=_0x47d200[_0x2cb060(0xd4)],_0x263a71=await resolveSegmentTarget(_0x3e2561,_0x2c6536,_0x47d200[_0x2cb060(0xe0)]);_0x47d200[_0x2cb060(0xe0)]&&console[_0x2cb060(0x122)](_0x2cb060(0x123)+_0x263a71);const _0x333d7b=await withSpinner(_0x2cb060(0xc8)+_0x3e2561+'\x27...',()=>_0x6601ce[_0x2cb060(0xd9)][_0x2cb060(0x9f)](_0x263a71),{'verbose':_0x47d200[_0x2cb060(0xe0)]}),_0x34e1c0=_0x333d7b[_0x2cb060(0xea)];_0x47d200['verbose']&&(console[_0x2cb060(0x122)](_0x2cb060(0x9d)+_0x34e1c0[_0x2cb060(0x90)]),console[_0x2cb060(0x122)]('Parent\x20ID:\x20'+_0x34e1c0[_0x2cb060(0xcb)]),_0x34e1c0[_0x2cb060(0xf1)]&&console['error']('Folder\x20ID:\x20'+_0x34e1c0[_0x2cb060(0xf1)]),_0x34e1c0[_0x2cb060(0x109)]&&console[_0x2cb060(0x122)](_0x2cb060(0x91)+_0x34e1c0[_0x2cb060(0x109)]));if(_0x47d200[_0x2cb060(0xf2)]){if(_0x34e1c0[_0x2cb060(0x90)]==='folder')return console['error']('Error:\x20Cannot\x20open\x20folder\x20in\x20web\x20browser.\x20Use\x20a\x20segment\x20name\x20instead.'),0x1;if(_0x34e1c0[_0x2cb060(0x90)]==='parent')return console[_0x2cb060(0x122)](_0x2cb060(0xc2)),console[_0x2cb060(0x122)](_0x2cb060(0xc6)),0x1;if(!_0x34e1c0[_0x2cb060(0x109)])throw new SDKError(ErrorCode[_0x2cb060(0xfd)],_0x2cb060(0xf0));const _0x31410f=getConsoleNextUrl(_0x47d200[_0x2cb060(0xa1)],_0x2cb060(0x11c)+_0x34e1c0[_0x2cb060(0xcb)]+'/e/'+_0x34e1c0[_0x2cb060(0x109)]);return console[_0x2cb060(0x122)](a35_0x135643[_0x2cb060(0x120)]('✔')+_0x2cb060(0xa4)+a35_0x135643[_0x2cb060(0xcf)](_0x31410f)),openBrowser(_0x31410f),0x0;}if(_0x34e1c0[_0x2cb060(0x90)]===_0x2cb060(0x10a)){if(!_0x34e1c0['folderId'])throw new SDKError(ErrorCode['SEGMENT_FOLDER_NOT_FOUND'],_0x2cb060(0xb2));const _0x3bbc57=await withSpinner(_0x2cb060(0xa5),()=>_0x6601ce[_0x2cb060(0xd9)]['getFolder'](_0x34e1c0[_0x2cb060(0xf1)]),{'verbose':_0x47d200[_0x2cb060(0xe0)]});await handleSingleObjectOutput(_0x3bbc57['data'],_0x47d200);}else{if(_0x34e1c0[_0x2cb060(0x90)]===_0x2cb060(0xd9)){if(!_0x34e1c0[_0x2cb060(0x109)])throw new SDKError(ErrorCode[_0x2cb060(0xfd)],_0x2cb060(0xf0));const _0x318892=await withSpinner(_0x2cb060(0xa3),()=>_0x6601ce[_0x2cb060(0xd9)][_0x2cb060(0xb6)](_0x34e1c0[_0x2cb060(0xcb)],_0x34e1c0['segmentId']),{'verbose':_0x47d200['verbose']}),_0x5d6679=getConsoleNextUrl(_0x47d200[_0x2cb060(0xa1)],'/app/ps/'+_0x34e1c0['parentId']+_0x2cb060(0x12d)+_0x34e1c0['segmentId']),_0x30c028=_0x318892[_0x2cb060(0xea)];_0x30c028[_0x2cb060(0x11b)]=_0x5d6679,await handleSingleObjectOutput(_0x30c028,_0x47d200);}else return console[_0x2cb060(0x122)](_0x2cb060(0x97)),console[_0x2cb060(0x122)]('Use:\x20tdx\x20ps\x20view'),0x1;}return 0x0;}catch(_0xcaf88e){if(_0xcaf88e instanceof SDKError)return console[_0x2cb060(0x122)]('Error:\x20'+_0xcaf88e[_0x2cb060(0x8e)]),_0xcaf88e[_0x2cb060(0x107)]&&console[_0x2cb060(0x122)](_0x2cb060(0xce)+_0xcaf88e['cause']),0x1;throw _0xcaf88e;}}}export const SegmentInfoCommand=SegmentViewCommand;export class SegmentDescCommand extends BaseCommand{['name']=a35_0x3e5dea(0xb4);[a35_0x3e5dea(0x129)]=a35_0x3e5dea(0xda);async[a35_0x3e5dea(0xe1)](_0x1df76f){const _0x282e91=a35_0x3e5dea,{options:_0x2a16e2,args:_0x2a446f,tdx:_0x1cfcae}=_0x1df76f,_0x7ec67c=_0x2a446f[0x0];if(!_0x7ec67c)return console[_0x282e91(0x122)](_0x282e91(0xe8)),console[_0x282e91(0x122)](_0x282e91(0x12c)),console[_0x282e91(0x122)]('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20desc\x20<path/to/segment.yml>'),console[_0x282e91(0x122)]('Examples:'),console[_0x282e91(0x122)](_0x282e91(0xe6)),console[_0x282e91(0x122)](_0x282e91(0xd1)),0x1;try{const _0x592504=_0x2a16e2['parentSegment'],_0x182385=await resolveSegmentTarget(_0x7ec67c,_0x592504,_0x2a16e2[_0x282e91(0xe0)]);_0x2a16e2[_0x282e91(0xe0)]&&console[_0x282e91(0x122)]('Target\x20path:\x20'+_0x182385);const _0x1a0477=await withSpinner(_0x282e91(0xc8)+_0x7ec67c+_0x282e91(0xe9),()=>_0x1cfcae[_0x282e91(0xd9)]['resolvePathToResource'](_0x182385),{'verbose':_0x2a16e2[_0x282e91(0xe0)]}),_0x359701=_0x1a0477['data'];_0x2a16e2['verbose']&&(console[_0x282e91(0x122)](_0x282e91(0x9d)+_0x359701[_0x282e91(0x90)]),console['error'](_0x282e91(0xff)+_0x359701['parentId']));if(_0x359701[_0x282e91(0x90)]==='folder')return console[_0x282e91(0x122)](_0x282e91(0xaa)),console[_0x282e91(0x122)](_0x282e91(0xeb)),0x1;if(_0x359701[_0x282e91(0x90)]===_0x282e91(0x12e))return console[_0x282e91(0x122)](_0x282e91(0x9a)),console['error'](_0x282e91(0xae)),0x1;if(!_0x359701[_0x282e91(0x109)])throw new SDKError(ErrorCode['SEGMENT_NOT_FOUND'],_0x282e91(0xf0));const _0x2aa01b=await withSpinner('Fetching\x20SQL\x20for\x20segment...',()=>_0x1cfcae['segment']['getSegmentSQL'](_0x359701['parentId'],_0x359701[_0x282e91(0x109)]),{'verbose':_0x2a16e2[_0x282e91(0xe0)]}),_0x4f78f8=_0x2aa01b[_0x282e91(0xea)],_0x4e9f5c=await executeSchemaQuery(_0x4f78f8,_0x1cfcae,_0x2a16e2);return await handleQueryOutput(_0x4e9f5c,_0x2a16e2),0x0;}catch(_0x58c423){if(_0x58c423 instanceof SDKError)return console[_0x282e91(0x122)](_0x282e91(0xd0)+_0x58c423[_0x282e91(0x8e)]),_0x58c423[_0x282e91(0x107)]&&console['error'](_0x282e91(0xce)+_0x58c423[_0x282e91(0x107)]),0x1;throw _0x58c423;}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a36_0x3ecc2b=a36_0x14a0;(function(_0x2d2895,_0x1bde66){const _0x1a7db5=a36_0x14a0,_0x1ceb5e=_0x2d2895();while(!![]){try{const _0x195ffb=-parseInt(_0x1a7db5(0x171))/0x1+-parseInt(_0x1a7db5(0x179))/0x2*(-parseInt(_0x1a7db5(0x16d))/0x3)+parseInt(_0x1a7db5(0x160))/0x4*(parseInt(_0x1a7db5(0x168))/0x5)+-parseInt(_0x1a7db5(0x170))/0x6+-parseInt(_0x1a7db5(0x183))/0x7+parseInt(_0x1a7db5(0x17e))/0x8*(-parseInt(_0x1a7db5(0x16a))/0x9)+parseInt(_0x1a7db5(0x17c))/0xa*(parseInt(_0x1a7db5(0x178))/0xb);if(_0x195ffb===_0x1bde66)break;else _0x1ceb5e['push'](_0x1ceb5e['shift']());}catch(_0x64b362){_0x1ceb5e['push'](_0x1ceb5e['shift']());}}}(a36_0x4226,0xd96ba));import{BaseCommand}from'./command.js';import{handleSDKOutput}from'../core/command-output.js';function a36_0x4226(){const _0x57476d=['Error:\x20Full\x20path\x20required\x20(parent/segment_name\x20or\x20parent/folder/segment_name)','4420dxrKkR','description','6664VaeSkj','Site:\x20','⚠\x20Deprecation\x20warning:\x20`segment\x20create`\x20is\x20deprecated.','includes','Target\x20path:\x20','2034641mNoeVv','noCountPopulation','parent','ruleFile','Parent:\x20','segments','Segment\x20name:\x20','execute','segment:create','Usage:\x20tdx\x20segment\x20create\x20<parent/segment_name>\x20[options]','createSegment','\x20\x20tdx\x20segment\x20create\x20\x22Premium\x22\x20--rule\x20\x27...\x27\x20\x20#\x20Relative\x20to\x20context','segment','Parent\x20path:\x20','\x20\x20tdx\x20segment\x20create\x20\x22My\x20Audience/Marketing/Premium\x22\x20--rule\x20\x27...\x27','error','folder','resolveFolderId','13548fQGIoD','Create\x20child\x20segment\x20with\x20filtering\x20rules','\x20\x20Use\x20`tdx\x20sg\x20push`\x20with\x20YAML\x20files\x20instead.\x0a','verbose','resolvePathToResource','\x20\x20tdx\x20segment\x20create\x20\x22My\x20Audience/High\x20Value\x22\x20--rule\x20\x27...\x27','Usage:\x20tdx\x20segment\x20create\x20<path>\x20[options]','data','1210xkciPz','segmentPath','8118mMahjz','length','Error:\x20Segment\x20path\x20or\x20name\x20is\x20required','848313PwXLjv','name','kind','9045708JqfApu','154220DiCWWX','\x27...','type','resolveParentId','Resolved\x20folder\x20ID:\x20','Resolving\x20parent\x20segment\x20\x27','site','62018ZAFLkC','2qjADjp','Resolving\x20folder\x20\x27'];a36_0x4226=function(){return _0x57476d;};return a36_0x4226();}import{withSpinner}from'../utils/spinner.js';function a36_0x14a0(_0x3fb05a,_0x2397f3){_0x3fb05a=_0x3fb05a-0x150;const _0x4226bf=a36_0x4226();let _0x14a03b=_0x4226bf[_0x3fb05a];return _0x14a03b;}import{loadJSONFromOptions}from'../utils/json-loader.js';import{parsePath,getParentPath,getBaseName}from'../sdk/segment/segment-path-parser.js';import a36_0x41a530 from'chalk';export class SegmentCreateCommand extends BaseCommand{[a36_0x3ecc2b(0x16e)]=a36_0x3ecc2b(0x156);[a36_0x3ecc2b(0x17d)]=a36_0x3ecc2b(0x161);async[a36_0x3ecc2b(0x155)](_0x3b0f77){const _0x36cf6a=a36_0x3ecc2b;console[_0x36cf6a(0x15d)](a36_0x41a530['yellow'](_0x36cf6a(0x180))),console[_0x36cf6a(0x15d)](a36_0x41a530['yellow'](_0x36cf6a(0x162)));const {options:_0x1ee8e2,args:_0x55393a,tdx:_0x18085a}=_0x3b0f77,_0x3c6748=_0x1ee8e2;if(_0x55393a['length']===0x0)return console[_0x36cf6a(0x15d)](_0x36cf6a(0x16c)),console[_0x36cf6a(0x15d)](_0x36cf6a(0x166)),console['error']('Examples:'),console['error'](_0x36cf6a(0x165)),console[_0x36cf6a(0x15d)](_0x36cf6a(0x15c)),console[_0x36cf6a(0x15d)](_0x36cf6a(0x159)),0x1;const _0x519ac9=_0x55393a[0x0],_0x398fdf=_0x1ee8e2[_0x36cf6a(0x169)];let _0x394197=_0x519ac9;_0x398fdf&&!_0x519ac9[_0x36cf6a(0x181)]('/')&&(_0x394197=_0x398fdf+'/'+_0x519ac9,_0x3c6748[_0x36cf6a(0x163)]&&console[_0x36cf6a(0x15d)]('Resolved\x20relative\x20path\x20to:\x20'+_0x394197));const _0x3ef8e6=parsePath(_0x394197);if(_0x3ef8e6['segments'][_0x36cf6a(0x16b)]<0x2)return console[_0x36cf6a(0x15d)](_0x36cf6a(0x17b)),console[_0x36cf6a(0x15d)](_0x36cf6a(0x157)),0x1;const _0x4db4bb=_0x3ef8e6[_0x36cf6a(0x153)][0x0],_0x4b4659=getBaseName(_0x394197),_0x47a36a=getParentPath(_0x394197);_0x3c6748[_0x36cf6a(0x163)]&&(console[_0x36cf6a(0x15d)](_0x36cf6a(0x17f)+_0x3c6748[_0x36cf6a(0x177)]),console[_0x36cf6a(0x15d)](_0x36cf6a(0x182)+_0x394197),console['error'](_0x36cf6a(0x152)+_0x4db4bb),console[_0x36cf6a(0x15d)](_0x36cf6a(0x154)+_0x4b4659),console[_0x36cf6a(0x15d)](_0x36cf6a(0x15b)+_0x47a36a));const _0x435fb2=await withSpinner(_0x36cf6a(0x176)+_0x4db4bb+_0x36cf6a(0x172),()=>_0x18085a[_0x36cf6a(0x15a)][_0x36cf6a(0x174)](_0x4db4bb),{'verbose':_0x3c6748[_0x36cf6a(0x163)]}),_0x1e98f2=_0x435fb2[_0x36cf6a(0x167)];let _0x38a293;if(_0x3ef8e6[_0x36cf6a(0x153)]['length']>0x2){const _0x311403=await withSpinner('Resolving\x20folder\x20path\x20\x27'+_0x47a36a+'\x27...',()=>_0x18085a[_0x36cf6a(0x15a)][_0x36cf6a(0x164)](_0x47a36a),{'verbose':_0x3c6748['verbose']}),_0x23559f=_0x311403[_0x36cf6a(0x167)];if(_0x23559f['type']!==_0x36cf6a(0x15e)&&_0x23559f[_0x36cf6a(0x173)]!==_0x36cf6a(0x150))return console[_0x36cf6a(0x15d)]('Error:\x20Cannot\x20create\x20segment\x20in\x20a\x20segment.\x20Parent\x20path\x20must\x20be\x20a\x20folder\x20or\x20parent.'),0x1;_0x38a293=_0x23559f['folderId'];}else{if(_0x3c6748[_0x36cf6a(0x15e)]){const _0x454586=await withSpinner(_0x36cf6a(0x17a)+_0x3c6748[_0x36cf6a(0x15e)]+_0x36cf6a(0x172),()=>_0x18085a[_0x36cf6a(0x15a)][_0x36cf6a(0x15f)](_0x1e98f2,_0x3c6748[_0x36cf6a(0x15e)]),{'verbose':_0x3c6748[_0x36cf6a(0x163)]});_0x38a293=_0x454586[_0x36cf6a(0x167)];}}_0x3c6748['verbose']&&_0x38a293&&console['error'](_0x36cf6a(0x175)+_0x38a293);const _0x3b812a=await loadJSONFromOptions(_0x3c6748['rule'],_0x3c6748[_0x36cf6a(0x151)]),_0x4765fd={'name':_0x4b4659,'description':_0x3c6748[_0x36cf6a(0x17d)],'rule':_0x3b812a,'kind':_0x3c6748[_0x36cf6a(0x16f)]!==undefined?parseInt(_0x3c6748['kind'],0xa):undefined,'isVisible':_0x3c6748['invisible']?![]:undefined,'segmentFolderId':_0x38a293,'countPopulation':_0x3c6748[_0x36cf6a(0x184)]?![]:undefined},_0x2599ac=await withSpinner('Creating\x20segment\x20\x27'+_0x4b4659+_0x36cf6a(0x172),()=>_0x18085a[_0x36cf6a(0x15a)][_0x36cf6a(0x158)](_0x1e98f2,_0x4765fd),{'verbose':_0x3c6748[_0x36cf6a(0x163)]}),_0x243d85=_0x2599ac[_0x36cf6a(0x167)];return console[_0x36cf6a(0x15d)]('✔\x20Created\x20segment\x20\x27'+_0x243d85[_0x36cf6a(0x16e)]+'\x27\x20with\x20ID:\x20'+_0x243d85['id']),_0x394197!==_0x519ac9&&console[_0x36cf6a(0x15d)]('\x20\x20\x20Path:\x20'+_0x394197),await handleSDKOutput([_0x243d85],_0x3c6748),0x0;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a37_0x4956d8=a37_0x4ef5;function a37_0x5c18(){const _0x41ff94=['1642YpeKuq','length','5952180MeUQLu','json','verbose','Parent\x20segment:\x20','7855299fpeCjX','1208ISBNjX','segment:fields','error','3681412EcPBPB','Site:\x20','✔\x20Found\x20','Error:\x20Parent\x20segment\x20name\x20is\x20required','\x27...','1029963pQpxzs','7669914iIwGRm','listFields','name','jsonl','24QkGMCf','parentSegment','data','execute','description','Usage:\x20tdx\x20segment\x20fields\x20<parent_name>','segment','6473340rjZkOT'];a37_0x5c18=function(){return _0x41ff94;};return a37_0x5c18();}(function(_0x2072e5,_0x23f954){const _0x41b327=a37_0x4ef5,_0x3df2d0=_0x2072e5();while(!![]){try{const _0x15f20d=parseInt(_0x41b327(0x1c7))/0x1*(-parseInt(_0x41b327(0x1ce))/0x2)+-parseInt(_0x41b327(0x1d6))/0x3+parseInt(_0x41b327(0x1c9))/0x4+parseInt(_0x41b327(0x1c6))/0x5+-parseInt(_0x41b327(0x1d7))/0x6+-parseInt(_0x41b327(0x1d1))/0x7*(-parseInt(_0x41b327(0x1bf))/0x8)+-parseInt(_0x41b327(0x1cd))/0x9;if(_0x15f20d===_0x23f954)break;else _0x3df2d0['push'](_0x3df2d0['shift']());}catch(_0x2e3a54){_0x3df2d0['push'](_0x3df2d0['shift']());}}}(a37_0x5c18,0xd5702));import{BaseCommand}from'./command.js';import{handleSDKOutput}from'../core/command-output.js';import{withSpinner}from'../utils/spinner.js';function a37_0x4ef5(_0x4740c8,_0x5df4de){_0x4740c8=_0x4740c8-0x1bc;const _0x5c1873=a37_0x5c18();let _0x4ef5c4=_0x5c1873[_0x4740c8];return _0x4ef5c4;}import{displayFieldsHumanReadable}from'../sdk/segment/fields-display.js';export class SegmentFieldsCommand extends BaseCommand{[a37_0x4956d8(0x1bd)]=a37_0x4956d8(0x1cf);[a37_0x4956d8(0x1c3)]='List\x20available\x20fields\x20for\x20segmentation';async[a37_0x4956d8(0x1c2)](_0xe0ce6e){const _0xf7a877=a37_0x4956d8,{options:_0x40d32c,args:_0x2f6944,tdx:_0x14fba6}=_0xe0ce6e,_0x17faae=_0x2f6944[0x0]||_0x40d32c[_0xf7a877(0x1c0)];if(!_0x17faae)return console[_0xf7a877(0x1d0)](_0xf7a877(0x1d4)),console['error'](_0xf7a877(0x1c4)),console[_0xf7a877(0x1d0)]('\x20\x20Or\x20set\x20context:\x20tdx\x20use\x20parent_segment\x20<name>'),0x1;_0x40d32c[_0xf7a877(0x1cb)]&&(console[_0xf7a877(0x1d0)](_0xf7a877(0x1d2)+_0x40d32c['site']),console[_0xf7a877(0x1d0)](_0xf7a877(0x1cc)+_0x17faae));const _0x572814=await withSpinner('Listing\x20fields\x20for\x20\x27'+_0x17faae+_0xf7a877(0x1d5),()=>_0x14fba6[_0xf7a877(0x1c5)][_0xf7a877(0x1bc)](_0x17faae),{'verbose':_0x40d32c[_0xf7a877(0x1cb)]}),_0x2dcd91=_0x572814[_0xf7a877(0x1c1)];console[_0xf7a877(0x1d0)](_0xf7a877(0x1d3)+_0x2dcd91[_0xf7a877(0x1c8)]+'\x20field'+(_0x2dcd91[_0xf7a877(0x1c8)]!==0x1?'s':''));if(_0x40d32c[_0xf7a877(0x1ca)]||_0x40d32c[_0xf7a877(0x1be)])return await handleSDKOutput(_0x2dcd91,_0x40d32c),0x0;return displayFieldsHumanReadable(_0x2dcd91,_0x17faae),0x0;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a38_0x1f93d7=a38_0x5c25;(function(_0x5c2a62,_0x320bf3){const _0x1f6592=a38_0x5c25,_0xd4a539=_0x5c2a62();while(!![]){try{const _0x3d5a7a=-parseInt(_0x1f6592(0x1bd))/0x1*(parseInt(_0x1f6592(0x18a))/0x2)+-parseInt(_0x1f6592(0x192))/0x3+-parseInt(_0x1f6592(0x1ad))/0x4+-parseInt(_0x1f6592(0x1c9))/0x5+parseInt(_0x1f6592(0x189))/0x6+-parseInt(_0x1f6592(0x195))/0x7*(parseInt(_0x1f6592(0x184))/0x8)+-parseInt(_0x1f6592(0x1a8))/0x9*(-parseInt(_0x1f6592(0x1a0))/0xa);if(_0x3d5a7a===_0x320bf3)break;else _0xd4a539['push'](_0xd4a539['shift']());}catch(_0x240229){_0xd4a539['push'](_0xd4a539['shift']());}}}(a38_0xb15b,0xb57f4));import{BaseCommand}from'./command.js';import{withProgressSpinner}from'../utils/spinner.js';import{confirmKey,isInteractive}from'../utils/prompt.js';function a38_0x5c25(_0x45122c,_0x4e76fd){_0x45122c=_0x45122c-0x183;const _0xb15b13=a38_0xb15b();let _0x5c256d=_0xb15b13[_0x45122c];return _0x5c256d;}import{saveSessionContext}from'../core/session.js';function a38_0xb15b(){const _0x78233b=['\x20activations','538542DWNisX','113716kAizfQ','Use\x20-y\x20or\x20--yes\x20flag\x20to\x20apply\x20changes\x20without\x20confirmation','green','No\x20segments\x20or\x20journeys\x20found\x20in\x20parent\x20segment\x20\x27','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)','Pull\x20child\x20segments\x20and\x20journeys\x20to\x20YAML\x20files','\x27...','counts','990306CdadNz','length','dim','2621899FIqzsp','dryRun','parent_segment\x20is\x20not\x20set.\x20Use\x20`tdx\x20sg\x20use\x20<parent_name>`\x20to\x20set\x20it.\x0a','site','-\x20no\x20files\x20written','content','✔\x20Pulled\x20','file','segment:pull','\x20\x20Target:\x20','yellow','10RMEEol','✔\x20Context\x20set:\x20','files','repeat','parentSegment','hasChanges','red','type','37645605MGkbcC','Parent\x20segment:\x20','absolutePath','activations','cwd','2614524lTYLag','filter','targetDir','Site:\x20','session','utf-8','Target\x20resource:\x20','resourceName','journeyVersions','\x20journeys','\x20versions)','\x0aError:','description','✔\x20All\x20files\x20are\x20up\x20to\x20date','dirname','cyan','19EfNawB','journeys','diff','relativePath','\x20changed\x20files','verbose','errorCode','\x20with\x20','\x20unchanged\x20files','isNew','data','Write\x20','5452990JlzDvD','Pulling\x20segments\x20from\x20\x27','parentName','parent_segment','segments','\x0aChanges\x20to\x20\x27','\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20pull\x20<parent_name>\x20\x20\x20\x20\x20\x20#\x20Pull\x20all\x20segments\x20from\x20parent','execute','error','Error:\x20','\x0a[Dry\x20run]\x20No\x20files\x20were\x20written','\x20=\x20','8oljKrU','message','Aborted.','helpText'];a38_0xb15b=function(){return _0x78233b;};return a38_0xb15b();}import a38_0xed7c91 from'chalk';import{existsSync,mkdirSync,writeFileSync}from'fs';import a38_0x3a6548 from'path';import{resolveTarget,isSuccessfulResolution}from'../sdk/segment/target-resolution.js';export{buildFolderIdToPathMap as buildFolderPathMap}from'../sdk/segment/resolution-context.js';export class SegmentPullCommand extends BaseCommand{['name']=a38_0x1f93d7(0x19d);[a38_0x1f93d7(0x1b9)]=a38_0x1f93d7(0x18f);async[a38_0x1f93d7(0x1d0)](_0x2a1f66){const _0x529504=a38_0x1f93d7,{options:_0x5c488b,args:_0x4d4d50,tdx:_0x19a0d8}=_0x2a1f66,_0x336395=_0x5c488b,_0x1f50a8=await resolveTarget({'arg':_0x4d4d50[0x0],'contextParent':_0x5c488b[_0x529504(0x1a4)],'cwd':process[_0x529504(0x1ac)]()});if(!isSuccessfulResolution(_0x1f50a8))return _0x1f50a8[_0x529504(0x1c3)]==='no_parent'?(console[_0x529504(0x1d1)](a38_0xed7c91[_0x529504(0x19f)](_0x529504(0x197))),console[_0x529504(0x1d1)](_0x529504(0x18e)),console[_0x529504(0x1d1)](_0x529504(0x1cf)),console['error']('\x20\x20\x20\x20\x20\x20\x20tdx\x20sg\x20pull\x20<file_path>\x20\x20\x20\x20\x20\x20\x20\x20#\x20Pull\x20specific\x20segment\x20file')):(console['error'](a38_0xed7c91[_0x529504(0x1a6)](_0x529504(0x1d2)+_0x1f50a8[_0x529504(0x185)]+'\x0a')),_0x1f50a8[_0x529504(0x187)]&&console[_0x529504(0x1d1)](a38_0xed7c91[_0x529504(0x1bc)](_0x1f50a8['helpText']))),0x1;const _0x52520b=_0x1f50a8[_0x529504(0x1cb)],_0x3ba42f=_0x1f50a8['targetDir'],_0xce99de=_0x1f50a8[_0x529504(0x1a7)]===_0x529504(0x19c)?_0x1f50a8[_0x529504(0x1b4)]:undefined;_0x336395[_0x529504(0x1c2)]&&(console[_0x529504(0x1d1)](_0x529504(0x1b0)+_0x336395[_0x529504(0x198)]),console[_0x529504(0x1d1)](_0x529504(0x1a9)+_0x52520b),_0xce99de&&console['error'](_0x529504(0x1b3)+_0xce99de));const _0x3383ec=await withProgressSpinner(_0x529504(0x1ca)+_0x52520b+_0x529504(0x190),_0x276211=>_0x19a0d8['segment']['pullSegments'](_0x52520b,{'targetDir':_0x3ba42f,'targetResourceName':_0xce99de,'verbose':_0x336395[_0x529504(0x1c2)],'progress':{'update':_0x3f5c58=>{const _0x168599=_0x529504;_0x276211['setPhase'](_0x3f5c58),_0x336395[_0x168599(0x1c2)]&&console[_0x168599(0x1d1)]('\x20\x20'+_0x3f5c58);}}}),{'verbose':_0x336395[_0x529504(0x1c2)]}),_0x3e9864=_0x3383ec[_0x529504(0x1c7)];if(_0x3e9864['counts']['segments']===0x0&&_0x3e9864['counts'][_0x529504(0x1be)]===0x0)return console[_0x529504(0x1d1)](a38_0xed7c91['yellow'](_0x529504(0x18d)+_0x3e9864[_0x529504(0x1cb)]+'\x27')),0x0;const _0x87343c=_0x3e9864[_0x529504(0x1a2)][_0x529504(0x1ae)](_0x5b7bdd=>_0x5b7bdd[_0x529504(0x1c6)]),_0x5c4b19=_0x3e9864[_0x529504(0x1a2)][_0x529504(0x1ae)](_0x17eb7e=>!_0x17eb7e[_0x529504(0x1c6)]&&_0x17eb7e[_0x529504(0x1a5)]),_0x156578=_0x3e9864[_0x529504(0x1a2)][_0x529504(0x1ae)](_0x36cf01=>!_0x36cf01[_0x529504(0x1c6)]&&!_0x36cf01[_0x529504(0x1a5)]);console[_0x529504(0x1d1)]('\x0aPull\x20summary\x20for\x20\x27'+_0x3e9864[_0x529504(0x1cb)]+'\x27:'),console['error']('\x20\x20🎯\x20'+a38_0xed7c91[_0x529504(0x1bc)](_0x3e9864[_0x529504(0x191)][_0x529504(0x1cd)]+'\x20segments')+_0x529504(0x1c4)+a38_0xed7c91[_0x529504(0x1bc)](_0x3e9864[_0x529504(0x191)][_0x529504(0x1ab)]+_0x529504(0x188)));if(_0x3e9864[_0x529504(0x191)][_0x529504(0x1be)]>0x0){const _0x32617d=_0x3e9864[_0x529504(0x191)][_0x529504(0x1b5)]>_0x3e9864[_0x529504(0x191)][_0x529504(0x1be)]?'\x20('+_0x3e9864[_0x529504(0x191)][_0x529504(0x1b5)]+_0x529504(0x1b7):'';console[_0x529504(0x1d1)]('\x20\x20🗺️\x20\x20'+a38_0xed7c91[_0x529504(0x1bc)](_0x3e9864[_0x529504(0x191)][_0x529504(0x1be)]+_0x529504(0x1b6))+a38_0xed7c91[_0x529504(0x194)](_0x32617d));}console[_0x529504(0x1d1)]('\x20\x20'+a38_0xed7c91[_0x529504(0x18c)]('+\x20'+_0x87343c[_0x529504(0x193)]+'\x20new\x20files')),console[_0x529504(0x1d1)]('\x20\x20'+a38_0xed7c91['yellow']('~\x20'+_0x5c4b19[_0x529504(0x193)]+_0x529504(0x1c1))),console[_0x529504(0x1d1)]('\x20\x20'+a38_0xed7c91['dim']('=\x20'+_0x156578[_0x529504(0x193)]+_0x529504(0x1c5))),console['error'](_0x529504(0x19e)+a38_0xed7c91[_0x529504(0x1bc)](_0x3e9864[_0x529504(0x1af)])+'\x0a');if(_0x5c4b19['length']>0x0)for(const _0x2a4075 of _0x5c4b19){console[_0x529504(0x1d1)](_0x529504(0x1ce)+_0x2a4075[_0x529504(0x1c0)]+'\x27:'),console[_0x529504(0x1d1)]('─'[_0x529504(0x1a3)](0x3c)),console[_0x529504(0x1d1)](_0x2a4075[_0x529504(0x1bf)]),console[_0x529504(0x1d1)]('─'[_0x529504(0x1a3)](0x3c));}if(_0x336395[_0x529504(0x196)])return console[_0x529504(0x1d1)](a38_0xed7c91[_0x529504(0x19f)](_0x529504(0x1d3))),0x0;if(_0x87343c['length']===0x0&&_0x5c4b19[_0x529504(0x193)]===0x0)return console['error'](a38_0xed7c91[_0x529504(0x18c)](_0x529504(0x1ba))),saveSessionContext({'parent_segment':_0x3e9864[_0x529504(0x1cb)]},_0x336395[_0x529504(0x1b1)]),console[_0x529504(0x1d1)](a38_0xed7c91['green'](_0x529504(0x1a1)+a38_0xed7c91[_0x529504(0x194)](_0x529504(0x1cc))+_0x529504(0x183)+a38_0xed7c91[_0x529504(0x1bc)](_0x3e9864[_0x529504(0x1cb)]))),0x0;if(!_0x336395['yes']){if(!isInteractive())return console[_0x529504(0x1d1)](a38_0xed7c91[_0x529504(0x1a6)](_0x529504(0x1b8)),'Confirmation\x20required\x20but\x20running\x20in\x20non-interactive\x20mode'),console['error'](a38_0xed7c91[_0x529504(0x194)](_0x529504(0x18b))),0x1;const _0x4d0e8a=await confirmKey(_0x529504(0x1c8)+(_0x87343c['length']+_0x5c4b19[_0x529504(0x193)])+'\x20files?');if(!_0x4d0e8a)return console['error'](a38_0xed7c91[_0x529504(0x19f)](_0x529504(0x186)),_0x529504(0x199)),0x1;}for(const _0x1da02b of _0x3e9864[_0x529504(0x1a2)]){if(_0x1da02b[_0x529504(0x1c6)]||_0x1da02b[_0x529504(0x1a5)]){const _0x38b568=a38_0x3a6548[_0x529504(0x1bb)](_0x1da02b[_0x529504(0x1aa)]);!existsSync(_0x38b568)&&mkdirSync(_0x38b568,{'recursive':!![]}),writeFileSync(_0x1da02b[_0x529504(0x1aa)],_0x1da02b[_0x529504(0x19a)],_0x529504(0x1b2));}}return console['error'](a38_0xed7c91[_0x529504(0x18c)](_0x529504(0x19b)+(_0x87343c[_0x529504(0x193)]+_0x5c4b19[_0x529504(0x193)])+'\x20files\x20to\x20'+_0x3e9864[_0x529504(0x1af)])),saveSessionContext({'parent_segment':_0x3e9864[_0x529504(0x1cb)]},_0x336395[_0x529504(0x1b1)]),console['error'](a38_0xed7c91[_0x529504(0x18c)](_0x529504(0x1a1)+a38_0xed7c91['dim'](_0x529504(0x1cc))+_0x529504(0x183)+a38_0xed7c91['cyan'](_0x3e9864[_0x529504(0x1cb)]))),0x0;}}
|