@treasuredata/tdx 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +2 -2
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/cdp-api-client.js +1 -1
- package/dist/client/engage-api-client.js +1 -1
- package/dist/client/http-client.js +1 -1
- package/dist/client/llm-api-client.js +1 -1
- package/dist/client/rate-limiter.js +1 -1
- package/dist/client/td-api-client.js +1 -1
- package/dist/client/trino-api-client.js +1 -1
- package/dist/client/workflow-client.js +1 -1
- package/dist/commands/activations.js +1 -1
- package/dist/commands/api-command.js +1 -1
- package/dist/commands/auth-command.js +1 -1
- package/dist/commands/chat-command.js +1 -1
- package/dist/commands/claude-command.d.ts.map +1 -1
- package/dist/commands/claude-command.js +1 -1
- package/dist/commands/claude-command.js.map +1 -1
- package/dist/commands/command.js +1 -1
- package/dist/commands/context-command.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/describe.js +1 -1
- package/dist/commands/engage-command.js +1 -1
- package/dist/commands/job-command.js +1 -1
- package/dist/commands/llm-command.js +1 -1
- package/dist/commands/llm-proxy.js +1 -1
- package/dist/commands/parent-segment-command.js +1 -1
- package/dist/commands/profiles-command.js +1 -1
- package/dist/commands/query-command.js +1 -1
- package/dist/commands/segment-command.js +1 -1
- package/dist/commands/segment-create-command.js +1 -1
- package/dist/commands/segment-fields-command.js +1 -1
- package/dist/commands/segment-pwd-command.js +1 -1
- package/dist/commands/segment-update-command.js +1 -1
- package/dist/commands/segment-use-command.js +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/tables.js +1 -1
- package/dist/commands/use-command.js +1 -1
- package/dist/commands/workflow-command.js +1 -1
- package/dist/core/auth.js +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/credential-cache.js +1 -1
- package/dist/core/global-context.js +1 -1
- package/dist/core/keychain.js +1 -1
- package/dist/core/profile.js +1 -1
- package/dist/core/project-config.js +1 -1
- package/dist/core/session.js +1 -1
- package/dist/index.js +1 -1
- package/dist/proxy/anthropic-adapter.js +1 -1
- package/dist/proxy/server.js +1 -1
- package/dist/proxy/session-cache.js +1 -1
- package/dist/sdk/api.js +1 -1
- package/dist/sdk/engage.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/job.js +1 -1
- package/dist/sdk/llm.js +1 -1
- package/dist/sdk/query.js +1 -1
- package/dist/sdk/segment.js +1 -1
- package/dist/sdk/workflow.js +1 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/agent-ref-parser.js +1 -1
- package/dist/utils/chat-cache.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/command-output.js +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/file-permissions.js +1 -1
- package/dist/utils/format-detector.js +1 -1
- package/dist/utils/formatters.js +1 -1
- package/dist/utils/json-loader.js +1 -1
- package/dist/utils/llm-backup-utils.js +1 -1
- package/dist/utils/model-aliases.js +1 -1
- package/dist/utils/option-validation.js +1 -1
- package/dist/utils/port.js +1 -1
- package/dist/utils/process.js +1 -1
- package/dist/utils/prompt.js +1 -1
- package/dist/utils/segment-path-parser.js +1 -1
- package/dist/utils/segment-ref-parser.js +1 -1
- package/dist/utils/spinner.js +1 -1
- package/dist/utils/sql-parser.js +1 -1
- package/dist/utils/sse-parser.js +1 -1
- package/dist/utils/string-utils.js +1 -1
- package/dist/utils/table-ref-parser.js +1 -1
- package/dist/utils/tdx-logger.js +1 -1
- package/dist/utils/tree-formatter.js +1 -1
- package/dist/utils/version-check.js +1 -1
- package/dist/utils/workflow-utils.js +1 -1
- package/package.json +6 -5
package/dist/sdk/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a48_0x1983(){const _0x5b8473=['80802NJlwRZ','string','9268810RPynzn','1100568BvybqW','request','logger','startsWith','Error:\x20','328qvtIwT','trino','Content-Type','context','application/json','data','apiKey','793975QhbWZV','2271312Ljhmpl','stringify','12189JWcBMy','status','site','message','GET','95JUprUO','87219rsjAWY','632mfXusI','Failed\x20to\x20read\x20request\x20body\x20from\x20file:\x20','readBodyFromFile','Endpoint\x20must\x20start\x20with\x20/:\x20'];a48_0x1983=function(){return _0x5b8473;};return a48_0x1983();}const a48_0x34ac13=a48_0x6bb1;(function(_0x4331dd,_0x2ecd8a){const _0x34250e=a48_0x6bb1,_0x156ae5=_0x4331dd();while(!![]){try{const _0x1ff1df=-parseInt(_0x34250e(0x175))/0x1+parseInt(_0x34250e(0x16e))/0x2*(parseInt(_0x34250e(0x178))/0x3)+parseInt(_0x34250e(0x176))/0x4+-parseInt(_0x34250e(0x17d))/0x5*(parseInt(_0x34250e(0x183))/0x6)+parseInt(_0x34250e(0x186))/0x7+parseInt(_0x34250e(0x17f))/0x8*(-parseInt(_0x34250e(0x17e))/0x9)+parseInt(_0x34250e(0x185))/0xa;if(_0x1ff1df===_0x2ecd8a)break;else _0x156ae5['push'](_0x156ae5['shift']());}catch(_0x1be06a){_0x156ae5['push'](_0x156ae5['shift']());}}}(a48_0x1983,0x7ac2c));function a48_0x6bb1(_0x50aea4,_0x58a908){const _0x1983bf=a48_0x1983();return a48_0x6bb1=function(_0x6bb17a,_0x4914ba){_0x6bb17a=_0x6bb17a-0x16a;let _0x400f7a=_0x1983bf[_0x6bb17a];return _0x400f7a;},a48_0x6bb1(_0x50aea4,_0x58a908);}import{HTTPClient}from'../client/http-client.js';import{getEndpoint}from'../types/index.js';import{getAuthHeaders,getTrinoHeaders,toHeaderRecord}from'../core/auth.js';import{readFileSync}from'fs';export class RawAPI{[a48_0x34ac13(0x171)];constructor(_0x1a1d87){const _0x12a8b4=a48_0x34ac13;this[_0x12a8b4(0x171)]=_0x1a1d87;}async[a48_0x34ac13(0x16a)](_0x5c7196,_0x13edd8={}){const _0xa34b57=a48_0x34ac13,{method:method=_0xa34b57(0x17c),body:_0x1a7dcc,headers:_0x2ce5b8={},apiType:apiType='td',includeHeaders:includeHeaders=![]}=_0x13edd8;if(!_0x5c7196[_0xa34b57(0x16c)]('/'))throw new Error(_0xa34b57(0x182)+_0x5c7196);const _0xa091d=getEndpoint(this[_0xa34b57(0x171)]['site'],apiType);let _0x120a51;if(apiType===_0xa34b57(0x16f)){const _0x5505e4=getTrinoHeaders(this['context'][_0xa34b57(0x17a)],this[_0xa34b57(0x171)][_0xa34b57(0x174)]);_0x120a51={..._0x5505e4,..._0x2ce5b8};}else{const _0x437a7a=getAuthHeaders(this[_0xa34b57(0x171)]['site'],this['context'][_0xa34b57(0x174)]);_0x120a51={...toHeaderRecord(_0x437a7a),..._0x2ce5b8};}const _0x1446f9=_0x120a51;let _0x3d6048;_0x1a7dcc!==undefined&&(_0x3d6048=typeof _0x1a7dcc===_0xa34b57(0x184)?_0x1a7dcc:JSON[_0xa34b57(0x177)](_0x1a7dcc),!_0x1446f9[_0xa34b57(0x170)]&&(_0x1446f9[_0xa34b57(0x170)]=_0xa34b57(0x172)));const _0x33de29=new HTTPClient(_0xa091d,_0x1446f9,this['context'][_0xa34b57(0x16b)]),_0x179340=await _0x33de29[_0xa34b57(0x16a)](method,_0x5c7196,{'body':_0x3d6048,'includeHeaders':!![]});return includeHeaders?{'data':_0x179340[_0xa34b57(0x173)],'status':_0x179340[_0xa34b57(0x179)],'headers':_0x179340['headers']}:{'data':_0x179340[_0xa34b57(0x173)],'status':_0x179340[_0xa34b57(0x179)]};}static[a48_0x34ac13(0x181)](_0x2bf3c7){const _0x5c3479=a48_0x34ac13;try{return readFileSync(_0x2bf3c7,'utf-8');}catch(_0x26b089){throw new Error(_0x5c3479(0x180)+_0x2bf3c7+'.\x20'+(_0x5c3479(0x16d)+(_0x26b089 instanceof Error?_0x26b089[_0x5c3479(0x17b)]:String(_0x26b089))));}}}
|
package/dist/sdk/engage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a49_0x3cc0c1=a49_0x83b7;(function(_0xd9c0de,_0x2c34bf){const _0x5cb1ac=a49_0x83b7,_0x508386=_0xd9c0de();while(!![]){try{const _0x344a76=parseInt(_0x5cb1ac(0x1b3))/0x1*(parseInt(_0x5cb1ac(0x176))/0x2)+parseInt(_0x5cb1ac(0x175))/0x3+parseInt(_0x5cb1ac(0x1ab))/0x4*(-parseInt(_0x5cb1ac(0x1ad))/0x5)+parseInt(_0x5cb1ac(0x191))/0x6*(-parseInt(_0x5cb1ac(0x1a3))/0x7)+-parseInt(_0x5cb1ac(0x1a4))/0x8*(-parseInt(_0x5cb1ac(0x190))/0x9)+-parseInt(_0x5cb1ac(0x1ac))/0xa+parseInt(_0x5cb1ac(0x173))/0xb*(-parseInt(_0x5cb1ac(0x17d))/0xc);if(_0x344a76===_0x2c34bf)break;else _0x508386['push'](_0x508386['shift']());}catch(_0x5ec82c){_0x508386['push'](_0x508386['shift']());}}}(a49_0x2224,0x4cad1));import{EngageApiClient}from'../client/engage-api-client.js';function a49_0x83b7(_0x3a0f04,_0x1e6793){const _0x2224d5=a49_0x2224();return a49_0x83b7=function(_0x83b77a,_0x29bfc2){_0x83b77a=_0x83b77a-0x172;let _0x4329a4=_0x2224d5[_0x83b77a];return _0x4329a4;},a49_0x83b7(_0x3a0f04,_0x1e6793);}function a49_0x2224(){const _0x3e1117=['Use\x20\x22tdx\x20engage\x20campaign\x20list\x22\x20to\x20see\x20available\x20campaigns.','test','getWorkspace','resolveTemplateId','3608132mGTlxo','createCampaign','1672680kaKkaC','60zoNVbg','audienceId','updateWorkspace','Use\x20--workspace-id\x20to\x20narrow\x20the\x20search,\x20or\x20use\x20the\x20campaign\x20UUID\x20directly.','workspaceId','subjectTemplate','Multiple\x20campaigns\x20found\x20with\x20name\x20\x22','24dfsIGu','resumeCampaign','enableUtmTracking','Campaign\x20not\x20found\x20with\x20ID:\x20','length','client','\x22:\x20','getCampaign','name','listCampaigns','launchCampaign','audienceName','segmentName','pauseCampaign','deleteCampaign','workspaceConfig','deleteTemplate','Use\x20--workspace-id\x20to\x20narrow\x20the\x20search,\x20or\x20use\x20the\x20template\x20UUID\x20directly.','getTemplate','2570031iuKtUj','246306fEuife','getWorkspaceFull','description','Email\x20template\x20not\x20found:\x20','Workspace\x20not\x20found:\x20','normalizeWorkspace','Multiple\x20workspaces\x20found\x20with\x20name\x20\x22','editorType','listWorkspaces','INVALID_ARGUMENT','isArray','limit','Workspace\x20not\x20found\x20with\x20ID:\x20','listTemplates','attributes','map','duplicateCampaign','normalizeCampaign','70KuizBT','16JToxUh','join','createdAt','Use\x20the\x20workspace\x20UUID\x20directly\x20to\x20select\x20a\x20specific\x20workspace.','updateCampaign','data','deleteWorkspace','20tCPYfY','336890PNCETT','177290sefEvB','resolveWorkspaceId','status','Email\x20template\x20not\x20found\x20with\x20ID:\x20','Use\x20\x22tdx\x20engage\x20workspace\x20list\x22\x20to\x20see\x20available\x20workspaces.','Use\x20\x22tdx\x20engage\x20template\x20list\x22\x20to\x20see\x20available\x20templates.','15430VKEHMw','applicableParentSegments','createWorkspace','updateTemplate','isUUID','resolveCampaignId','createTemplate','campaignType','normalizeTemplate','NOT_FOUND','launchedAt','code','getCampaignFull','updatedAt','filter'];a49_0x2224=function(){return _0x3e1117;};return a49_0x2224();}import{SDKError,ErrorCode}from'./errors.js';export class EngageSDK{[a49_0x3cc0c1(0x182)];constructor(_0x3f60c4){const _0x27328f=a49_0x3cc0c1;this[_0x27328f(0x182)]=new EngageApiClient(_0x3f60c4);}[a49_0x3cc0c1(0x1b7)](_0x196593){const _0x45e860=a49_0x3cc0c1;return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i[_0x45e860(0x1c3)](_0x196593);}[a49_0x3cc0c1(0x1a2)](_0x2eb8ff){const _0x584105=a49_0x3cc0c1;return{'id':_0x2eb8ff['id'],'name':_0x2eb8ff['attributes'][_0x584105(0x185)],'campaignType':_0x2eb8ff['attributes'][_0x584105(0x1ba)],'status':_0x2eb8ff['attributes'][_0x584105(0x1af)],'description':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x193)],'workspaceId':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x17a)],'audienceId':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x177)],'audienceName':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x188)],'segmentId':_0x2eb8ff[_0x584105(0x19f)]['segmentId'],'segmentName':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x189)],'enableUtmTracking':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x17f)],'createdAt':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x1a6)],'updatedAt':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x1c0)],'launchedAt':_0x2eb8ff[_0x584105(0x19f)][_0x584105(0x1bd)]};}['normalizeTemplate'](_0x52130f){const _0x2f8f67=a49_0x3cc0c1;return{'id':_0x52130f['id'],'name':_0x52130f[_0x2f8f67(0x19f)][_0x2f8f67(0x185)],'subjectTemplate':_0x52130f[_0x2f8f67(0x19f)][_0x2f8f67(0x17b)],'workspaceId':_0x52130f[_0x2f8f67(0x19f)][_0x2f8f67(0x17a)],'editorType':_0x52130f[_0x2f8f67(0x19f)][_0x2f8f67(0x198)],'createdAt':_0x52130f[_0x2f8f67(0x19f)]['createdAt'],'updatedAt':_0x52130f[_0x2f8f67(0x19f)][_0x2f8f67(0x1c0)]};}['normalizeWorkspace'](_0x50e7f5){const _0x4ae2c8=a49_0x3cc0c1;return{'id':_0x50e7f5['id'],'name':_0x50e7f5[_0x4ae2c8(0x19f)]['name'],'description':_0x50e7f5[_0x4ae2c8(0x19f)][_0x4ae2c8(0x193)],'ownerName':_0x50e7f5[_0x4ae2c8(0x19f)]['ownerUser'][_0x4ae2c8(0x185)],'domainCount':_0x50e7f5['attributes']['workspaceConfig']['applicableDomains'][_0x4ae2c8(0x181)],'segmentCount':_0x50e7f5[_0x4ae2c8(0x19f)][_0x4ae2c8(0x18c)][_0x4ae2c8(0x1b4)]['length'],'createdAt':_0x50e7f5['attributes'][_0x4ae2c8(0x1a6)],'updatedAt':_0x50e7f5[_0x4ae2c8(0x19f)][_0x4ae2c8(0x1c0)]};}async[a49_0x3cc0c1(0x1b8)](_0x53c7bf,_0x45928a){const _0x5ec090=a49_0x3cc0c1;if(this[_0x5ec090(0x1b7)](_0x53c7bf))try{return await this['client']['getCampaign'](_0x53c7bf),_0x53c7bf;}catch(_0x771e2e){if(_0x771e2e instanceof SDKError&&_0x771e2e[_0x5ec090(0x1be)]===ErrorCode[_0x5ec090(0x1bc)])throw new SDKError(ErrorCode['NOT_FOUND'],_0x5ec090(0x180)+_0x53c7bf,_0x771e2e,{'helpText':_0x5ec090(0x1c2)});throw _0x771e2e;}const _0x15b665=await this[_0x5ec090(0x182)][_0x5ec090(0x186)]({'workspaceId':_0x45928a}),_0x11f5b1=Array[_0x5ec090(0x19b)](_0x15b665[_0x5ec090(0x1a9)])?_0x15b665[_0x5ec090(0x1a9)]:[_0x15b665[_0x5ec090(0x1a9)]],_0x298683=_0x11f5b1[_0x5ec090(0x1c1)](_0x3218fa=>_0x3218fa[_0x5ec090(0x19f)][_0x5ec090(0x185)]===_0x53c7bf);if(_0x298683[_0x5ec090(0x181)]===0x0)throw new SDKError(ErrorCode[_0x5ec090(0x1bc)],'Campaign\x20not\x20found:\x20'+_0x53c7bf,undefined,{'helpText':_0x5ec090(0x1c2)});if(_0x298683[_0x5ec090(0x181)]>0x1){const _0x2a3693=_0x298683[_0x5ec090(0x1a0)](_0xab8d56=>_0xab8d56['id'])[_0x5ec090(0x1a5)](',\x20');throw new SDKError(ErrorCode[_0x5ec090(0x19a)],_0x5ec090(0x17c)+_0x53c7bf+_0x5ec090(0x183)+_0x2a3693,undefined,{'helpText':_0x5ec090(0x179)});}return _0x298683[0x0]['id'];}async[a49_0x3cc0c1(0x172)](_0x1c1612,_0x4cc09e){const _0x4b8fce=a49_0x3cc0c1;if(this[_0x4b8fce(0x1b7)](_0x1c1612))try{return await this[_0x4b8fce(0x182)][_0x4b8fce(0x18f)](_0x1c1612),_0x1c1612;}catch(_0x1ce30e){if(_0x1ce30e instanceof SDKError&&_0x1ce30e[_0x4b8fce(0x1be)]===ErrorCode['NOT_FOUND'])throw new SDKError(ErrorCode[_0x4b8fce(0x1bc)],_0x4b8fce(0x1b0)+_0x1c1612,_0x1ce30e,{'helpText':_0x4b8fce(0x1b2)});throw _0x1ce30e;}const _0x1b2022=await this['client'][_0x4b8fce(0x19e)]({'workspaceId':_0x4cc09e}),_0x133030=Array[_0x4b8fce(0x19b)](_0x1b2022['data'])?_0x1b2022[_0x4b8fce(0x1a9)]:[_0x1b2022[_0x4b8fce(0x1a9)]],_0x22c518=_0x133030[_0x4b8fce(0x1c1)](_0x59dd76=>_0x59dd76[_0x4b8fce(0x19f)][_0x4b8fce(0x185)]===_0x1c1612);if(_0x22c518[_0x4b8fce(0x181)]===0x0)throw new SDKError(ErrorCode[_0x4b8fce(0x1bc)],_0x4b8fce(0x194)+_0x1c1612,undefined,{'helpText':'Use\x20\x22tdx\x20engage\x20template\x20list\x22\x20to\x20see\x20available\x20templates.'});if(_0x22c518[_0x4b8fce(0x181)]>0x1){const _0x44562d=_0x22c518[_0x4b8fce(0x1a0)](_0x1a2e9a=>_0x1a2e9a['id'])[_0x4b8fce(0x1a5)](',\x20');throw new SDKError(ErrorCode[_0x4b8fce(0x19a)],'Multiple\x20templates\x20found\x20with\x20name\x20\x22'+_0x1c1612+'\x22:\x20'+_0x44562d,undefined,{'helpText':_0x4b8fce(0x18e)});}return _0x22c518[0x0]['id'];}async['resolveWorkspaceId'](_0x55671f){const _0x3e2056=a49_0x3cc0c1;if(this['isUUID'](_0x55671f))try{return await this[_0x3e2056(0x182)]['getWorkspace'](_0x55671f),_0x55671f;}catch(_0x3a2f82){if(_0x3a2f82 instanceof SDKError&&_0x3a2f82['code']===ErrorCode[_0x3e2056(0x1bc)])throw new SDKError(ErrorCode[_0x3e2056(0x1bc)],_0x3e2056(0x19d)+_0x55671f,_0x3a2f82,{'helpText':_0x3e2056(0x1b1)});throw _0x3a2f82;}const _0x1bab97=await this[_0x3e2056(0x182)]['listWorkspaces']({'name':_0x55671f}),_0x4d1778=Array['isArray'](_0x1bab97['data'])?_0x1bab97[_0x3e2056(0x1a9)]:[_0x1bab97[_0x3e2056(0x1a9)]],_0xaabf40=_0x4d1778[_0x3e2056(0x1c1)](_0x3d70a4=>_0x3d70a4[_0x3e2056(0x19f)][_0x3e2056(0x185)]===_0x55671f);if(_0xaabf40[_0x3e2056(0x181)]===0x0)throw new SDKError(ErrorCode[_0x3e2056(0x1bc)],_0x3e2056(0x195)+_0x55671f,undefined,{'helpText':'Use\x20\x22tdx\x20engage\x20workspace\x20list\x22\x20to\x20see\x20available\x20workspaces.'});if(_0xaabf40[_0x3e2056(0x181)]>0x1){const _0x126db3=_0xaabf40['map'](_0x2dd14b=>_0x2dd14b['id'])[_0x3e2056(0x1a5)](',\x20');throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x3e2056(0x197)+_0x55671f+_0x3e2056(0x183)+_0x126db3,undefined,{'helpText':_0x3e2056(0x1a7)});}return _0xaabf40[0x0]['id'];}async[a49_0x3cc0c1(0x186)](_0x34d6b9){const _0x2e67cb=a49_0x3cc0c1,_0x291a97=await this['client']['listCampaigns']({'campaignType':_0x34d6b9?.['type'],'status':_0x34d6b9?.['status'],'workspaceId':_0x34d6b9?.['workspaceId'],'limit':_0x34d6b9?.[_0x2e67cb(0x19c)]}),_0x365a27=Array[_0x2e67cb(0x19b)](_0x291a97[_0x2e67cb(0x1a9)])?_0x291a97[_0x2e67cb(0x1a9)]:[_0x291a97[_0x2e67cb(0x1a9)]];return _0x365a27['map'](_0x334d3b=>this[_0x2e67cb(0x1a2)](_0x334d3b));}async['getCampaign'](_0x17d360,_0x40753d){const _0xff0fad=a49_0x3cc0c1,_0xb54b3e=await this[_0xff0fad(0x1b8)](_0x17d360,_0x40753d),_0x55794e=await this[_0xff0fad(0x182)][_0xff0fad(0x184)](_0xb54b3e);return this[_0xff0fad(0x1a2)](_0x55794e[_0xff0fad(0x1a9)]);}async[a49_0x3cc0c1(0x1bf)](_0x5afe8e,_0x5913cc){const _0x595cae=a49_0x3cc0c1,_0x2cb153=await this[_0x595cae(0x1b8)](_0x5afe8e,_0x5913cc),_0x5a7a6b=await this[_0x595cae(0x182)][_0x595cae(0x184)](_0x2cb153);return _0x5a7a6b[_0x595cae(0x1a9)];}async[a49_0x3cc0c1(0x174)](_0x29ae27){const _0x2ed14f=a49_0x3cc0c1,_0x7dca32=await this[_0x2ed14f(0x182)][_0x2ed14f(0x174)](_0x29ae27);return this['normalizeCampaign'](_0x7dca32['data']);}async['updateCampaign'](_0x2263d5,_0x1fd818,_0x512e64){const _0x1b719d=a49_0x3cc0c1,_0x1418df=await this[_0x1b719d(0x1b8)](_0x2263d5,_0x512e64),_0x2b970a=await this[_0x1b719d(0x182)][_0x1b719d(0x1a8)](_0x1418df,_0x1fd818);return this['normalizeCampaign'](_0x2b970a['data']);}async[a49_0x3cc0c1(0x18b)](_0x465408,_0x1bc165){const _0x5bc913=a49_0x3cc0c1,_0x5e8d22=await this['resolveCampaignId'](_0x465408,_0x1bc165);await this['client'][_0x5bc913(0x18b)](_0x5e8d22);}async['launchCampaign'](_0x4f9407,_0x3fe7af){const _0x4ed5ba=a49_0x3cc0c1,_0x1b78af=await this[_0x4ed5ba(0x1b8)](_0x4f9407,_0x3fe7af);await this[_0x4ed5ba(0x182)][_0x4ed5ba(0x187)](_0x1b78af);}async[a49_0x3cc0c1(0x18a)](_0x9f1104,_0xdec3cb){const _0x16aa68=a49_0x3cc0c1,_0x2a8e60=await this[_0x16aa68(0x1b8)](_0x9f1104,_0xdec3cb);await this[_0x16aa68(0x182)][_0x16aa68(0x18a)](_0x2a8e60);}async[a49_0x3cc0c1(0x17e)](_0x25e8b,_0x5d2127){const _0x54f6dd=a49_0x3cc0c1,_0x4edcd0=await this['resolveCampaignId'](_0x25e8b,_0x5d2127);await this[_0x54f6dd(0x182)][_0x54f6dd(0x17e)](_0x4edcd0);}async['duplicateCampaign'](_0x42ce98,_0x553989){const _0x1460d0=a49_0x3cc0c1,_0x66b47f=await this['resolveCampaignId'](_0x42ce98,_0x553989),_0x3e0cf8=await this[_0x1460d0(0x182)][_0x1460d0(0x1a1)](_0x66b47f);return this[_0x1460d0(0x1a2)](_0x3e0cf8[_0x1460d0(0x1a9)]);}async['listTemplates'](_0x149175){const _0x3d46bb=a49_0x3cc0c1,_0x5b45aa=await this['client'][_0x3d46bb(0x19e)]({'workspaceId':_0x149175?.[_0x3d46bb(0x17a)],'limit':_0x149175?.[_0x3d46bb(0x19c)]}),_0x1fe3cc=Array[_0x3d46bb(0x19b)](_0x5b45aa[_0x3d46bb(0x1a9)])?_0x5b45aa[_0x3d46bb(0x1a9)]:[_0x5b45aa[_0x3d46bb(0x1a9)]];return _0x1fe3cc[_0x3d46bb(0x1a0)](_0x68771b=>this[_0x3d46bb(0x1bb)](_0x68771b));}async['getTemplate'](_0x5768ca,_0x1d9a02){const _0x5b3127=a49_0x3cc0c1,_0x198213=await this[_0x5b3127(0x172)](_0x5768ca,_0x1d9a02),_0x3dd13d=await this[_0x5b3127(0x182)][_0x5b3127(0x18f)](_0x198213);return this[_0x5b3127(0x1bb)](_0x3dd13d[_0x5b3127(0x1a9)]);}async['getTemplateFull'](_0x1d324e,_0x5efc26){const _0x298310=a49_0x3cc0c1,_0x29343c=await this[_0x298310(0x172)](_0x1d324e,_0x5efc26),_0x1a1579=await this[_0x298310(0x182)][_0x298310(0x18f)](_0x29343c);return _0x1a1579[_0x298310(0x1a9)];}async[a49_0x3cc0c1(0x1b9)](_0x4ef6a5){const _0x593d62=a49_0x3cc0c1,_0x477103=await this[_0x593d62(0x182)][_0x593d62(0x1b9)](_0x4ef6a5);return this[_0x593d62(0x1bb)](_0x477103[_0x593d62(0x1a9)]);}async[a49_0x3cc0c1(0x1b6)](_0x13926b,_0x57fd75,_0x3f59cd){const _0x20dcb0=a49_0x3cc0c1,_0x58e54d=await this[_0x20dcb0(0x172)](_0x13926b,_0x3f59cd),_0x1d13dc=await this['client'][_0x20dcb0(0x1b6)](_0x58e54d,_0x57fd75);return this[_0x20dcb0(0x1bb)](_0x1d13dc[_0x20dcb0(0x1a9)]);}async['deleteTemplate'](_0x6b06a,_0x40fc13){const _0x529e9b=a49_0x3cc0c1,_0x21fdd2=await this[_0x529e9b(0x172)](_0x6b06a,_0x40fc13);await this[_0x529e9b(0x182)][_0x529e9b(0x18d)](_0x21fdd2);}async[a49_0x3cc0c1(0x199)](_0xf22b68){const _0x92c133=a49_0x3cc0c1,_0x484f81=await this[_0x92c133(0x182)][_0x92c133(0x199)]({'name':_0xf22b68?.[_0x92c133(0x185)],'limit':_0xf22b68?.[_0x92c133(0x19c)]}),_0x2b9ae1=Array[_0x92c133(0x19b)](_0x484f81[_0x92c133(0x1a9)])?_0x484f81[_0x92c133(0x1a9)]:[_0x484f81[_0x92c133(0x1a9)]];return _0x2b9ae1['map'](_0x132de3=>this[_0x92c133(0x196)](_0x132de3));}async[a49_0x3cc0c1(0x1c4)](_0x50b317){const _0x1de23c=a49_0x3cc0c1,_0x5c0e2f=await this['resolveWorkspaceId'](_0x50b317),_0x52a329=await this['client'][_0x1de23c(0x1c4)](_0x5c0e2f);return this[_0x1de23c(0x196)](_0x52a329[_0x1de23c(0x1a9)]);}async[a49_0x3cc0c1(0x192)](_0x5e284d){const _0xb624fd=a49_0x3cc0c1,_0x26f829=await this[_0xb624fd(0x1ae)](_0x5e284d),_0x12c82c=await this[_0xb624fd(0x182)]['getWorkspace'](_0x26f829);return _0x12c82c[_0xb624fd(0x1a9)];}async[a49_0x3cc0c1(0x1b5)](_0x3d4781){const _0x579ae3=a49_0x3cc0c1,_0x3f6649=await this[_0x579ae3(0x182)][_0x579ae3(0x1b5)](_0x3d4781);return this['normalizeWorkspace'](_0x3f6649[_0x579ae3(0x1a9)]);}async[a49_0x3cc0c1(0x178)](_0x24c797,_0x8e3282){const _0x266744=a49_0x3cc0c1,_0x1d877b=await this[_0x266744(0x1ae)](_0x24c797),_0x15f905=await this[_0x266744(0x182)][_0x266744(0x178)](_0x1d877b,_0x8e3282);return this['normalizeWorkspace'](_0x15f905['data']);}async[a49_0x3cc0c1(0x1aa)](_0x202ae2){const _0x3e78f3=a49_0x3cc0c1,_0x43240c=await this['resolveWorkspaceId'](_0x202ae2);await this['client'][_0x3e78f3(0x1aa)](_0x43240c);}}
|
|
1
|
+
const a49_0xe74303=a49_0x52c2;(function(_0x77cd71,_0x22af3d){const _0x4868b4=a49_0x52c2,_0x464bfe=_0x77cd71();while(!![]){try{const _0x5bfc36=-parseInt(_0x4868b4(0x13a))/0x1+-parseInt(_0x4868b4(0x155))/0x2*(-parseInt(_0x4868b4(0x16f))/0x3)+-parseInt(_0x4868b4(0x168))/0x4+-parseInt(_0x4868b4(0x165))/0x5*(-parseInt(_0x4868b4(0x164))/0x6)+parseInt(_0x4868b4(0x154))/0x7+parseInt(_0x4868b4(0x17f))/0x8+-parseInt(_0x4868b4(0x137))/0x9;if(_0x5bfc36===_0x22af3d)break;else _0x464bfe['push'](_0x464bfe['shift']());}catch(_0x2884f9){_0x464bfe['push'](_0x464bfe['shift']());}}}(a49_0x3980,0x7aba4));function a49_0x52c2(_0x18a634,_0x39bceb){const _0x398066=a49_0x3980();return a49_0x52c2=function(_0x52c29c,_0x435b96){_0x52c29c=_0x52c29c-0x136;let _0x3078d0=_0x398066[_0x52c29c];return _0x3078d0;},a49_0x52c2(_0x18a634,_0x39bceb);}function a49_0x3980(){const _0x2d46e4=['name','\x22:\x20','NOT_FOUND','getWorkspace','resolveWorkspaceId','pauseCampaign','Use\x20--workspace-id\x20to\x20narrow\x20the\x20search,\x20or\x20use\x20the\x20campaign\x20UUID\x20directly.','9369999yThMWS','updateCampaign','launchedAt','168634ruUglK','Campaign\x20not\x20found\x20with\x20ID:\x20','description','attributes','listTemplates','status','normalizeTemplate','Use\x20the\x20workspace\x20UUID\x20directly\x20to\x20select\x20a\x20specific\x20workspace.','normalizeCampaign','listCampaigns','limit','getCampaignFull','applicableParentSegments','Email\x20template\x20not\x20found:\x20','join','INVALID_ARGUMENT','enableUtmTracking','Use\x20--workspace-id\x20to\x20narrow\x20the\x20search,\x20or\x20use\x20the\x20template\x20UUID\x20directly.','createdAt','audienceId','filter','resumeCampaign','resolveTemplateId','Multiple\x20templates\x20found\x20with\x20name\x20\x22','Email\x20template\x20not\x20found\x20with\x20ID:\x20','getTemplateFull','4872924yRtAPD','2SYYiRl','deleteCampaign','createTemplate','normalizeWorkspace','getTemplate','data','createCampaign','type','Multiple\x20campaigns\x20found\x20with\x20name\x20\x22','Use\x20\x22tdx\x20engage\x20campaign\x20list\x22\x20to\x20see\x20available\x20campaigns.','updateWorkspace','updatedAt','getWorkspaceFull','client','campaignType','12jyiCbh','1929205bMuCmr','deleteTemplate','test','3776908AIvwBE','editorType','listWorkspaces','createWorkspace','code','applicableDomains','subjectTemplate','2246829cZJldf','duplicateCampaign','workspaceId','length','launchCampaign','Use\x20\x22tdx\x20engage\x20template\x20list\x22\x20to\x20see\x20available\x20templates.','Use\x20\x22tdx\x20engage\x20workspace\x20list\x22\x20to\x20see\x20available\x20workspaces.','audienceName','segmentId','isArray','getCampaign','map','resolveCampaignId','isUUID','workspaceConfig','deleteWorkspace','3519256VTfgoR','Workspace\x20not\x20found:\x20','ownerUser'];a49_0x3980=function(){return _0x2d46e4;};return a49_0x3980();}import{EngageApiClient}from'../client/engage-api-client.js';import{SDKError,ErrorCode}from'./errors.js';export class EngageSDK{['client'];constructor(_0x3405b3){const _0x50cfb2=a49_0x52c2;this[_0x50cfb2(0x162)]=new EngageApiClient(_0x3405b3);}[a49_0xe74303(0x17c)](_0x1f358e){const _0x37db30=a49_0xe74303;return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i[_0x37db30(0x167)](_0x1f358e);}[a49_0xe74303(0x142)](_0x220843){const _0x536437=a49_0xe74303;return{'id':_0x220843['id'],'name':_0x220843[_0x536437(0x13d)][_0x536437(0x182)],'campaignType':_0x220843[_0x536437(0x13d)][_0x536437(0x163)],'status':_0x220843[_0x536437(0x13d)][_0x536437(0x13f)],'description':_0x220843[_0x536437(0x13d)][_0x536437(0x13c)],'workspaceId':_0x220843[_0x536437(0x13d)][_0x536437(0x171)],'audienceId':_0x220843[_0x536437(0x13d)][_0x536437(0x14d)],'audienceName':_0x220843[_0x536437(0x13d)][_0x536437(0x176)],'segmentId':_0x220843[_0x536437(0x13d)][_0x536437(0x177)],'segmentName':_0x220843[_0x536437(0x13d)]['segmentName'],'enableUtmTracking':_0x220843['attributes'][_0x536437(0x14a)],'createdAt':_0x220843[_0x536437(0x13d)][_0x536437(0x14c)],'updatedAt':_0x220843[_0x536437(0x13d)][_0x536437(0x160)],'launchedAt':_0x220843[_0x536437(0x13d)][_0x536437(0x139)]};}[a49_0xe74303(0x140)](_0x433219){const _0x2704ea=a49_0xe74303;return{'id':_0x433219['id'],'name':_0x433219[_0x2704ea(0x13d)][_0x2704ea(0x182)],'subjectTemplate':_0x433219[_0x2704ea(0x13d)][_0x2704ea(0x16e)],'workspaceId':_0x433219[_0x2704ea(0x13d)][_0x2704ea(0x171)],'editorType':_0x433219[_0x2704ea(0x13d)][_0x2704ea(0x169)],'createdAt':_0x433219[_0x2704ea(0x13d)][_0x2704ea(0x14c)],'updatedAt':_0x433219['attributes'][_0x2704ea(0x160)]};}[a49_0xe74303(0x158)](_0xd37930){const _0x305fc1=a49_0xe74303;return{'id':_0xd37930['id'],'name':_0xd37930[_0x305fc1(0x13d)][_0x305fc1(0x182)],'description':_0xd37930[_0x305fc1(0x13d)][_0x305fc1(0x13c)],'ownerName':_0xd37930[_0x305fc1(0x13d)][_0x305fc1(0x181)][_0x305fc1(0x182)],'domainCount':_0xd37930[_0x305fc1(0x13d)]['workspaceConfig'][_0x305fc1(0x16d)][_0x305fc1(0x172)],'segmentCount':_0xd37930['attributes'][_0x305fc1(0x17d)][_0x305fc1(0x146)][_0x305fc1(0x172)],'createdAt':_0xd37930[_0x305fc1(0x13d)][_0x305fc1(0x14c)],'updatedAt':_0xd37930[_0x305fc1(0x13d)][_0x305fc1(0x160)]};}async[a49_0xe74303(0x17b)](_0x6fbf41,_0x22d70a){const _0x8b6532=a49_0xe74303;if(this['isUUID'](_0x6fbf41))try{return await this['client'][_0x8b6532(0x179)](_0x6fbf41),_0x6fbf41;}catch(_0x4e0556){if(_0x4e0556 instanceof SDKError&&_0x4e0556[_0x8b6532(0x16c)]===ErrorCode[_0x8b6532(0x184)])throw new SDKError(ErrorCode['NOT_FOUND'],_0x8b6532(0x13b)+_0x6fbf41,_0x4e0556,{'helpText':_0x8b6532(0x15e)});throw _0x4e0556;}const _0x8b3353=await this[_0x8b6532(0x162)]['listCampaigns']({'workspaceId':_0x22d70a}),_0x2d2ef6=Array[_0x8b6532(0x178)](_0x8b3353[_0x8b6532(0x15a)])?_0x8b3353[_0x8b6532(0x15a)]:[_0x8b3353[_0x8b6532(0x15a)]],_0x1ebbe1=_0x2d2ef6[_0x8b6532(0x14e)](_0x445173=>_0x445173[_0x8b6532(0x13d)][_0x8b6532(0x182)]===_0x6fbf41);if(_0x1ebbe1[_0x8b6532(0x172)]===0x0)throw new SDKError(ErrorCode['NOT_FOUND'],'Campaign\x20not\x20found:\x20'+_0x6fbf41,undefined,{'helpText':_0x8b6532(0x15e)});if(_0x1ebbe1[_0x8b6532(0x172)]>0x1){const _0x2429aa=_0x1ebbe1[_0x8b6532(0x17a)](_0xddd71f=>_0xddd71f['id'])['join'](',\x20');throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x8b6532(0x15d)+_0x6fbf41+_0x8b6532(0x183)+_0x2429aa,undefined,{'helpText':_0x8b6532(0x136)});}return _0x1ebbe1[0x0]['id'];}async['resolveTemplateId'](_0x35513b,_0x19d350){const _0xdf524d=a49_0xe74303;if(this[_0xdf524d(0x17c)](_0x35513b))try{return await this[_0xdf524d(0x162)][_0xdf524d(0x159)](_0x35513b),_0x35513b;}catch(_0xffe364){if(_0xffe364 instanceof SDKError&&_0xffe364[_0xdf524d(0x16c)]===ErrorCode[_0xdf524d(0x184)])throw new SDKError(ErrorCode[_0xdf524d(0x184)],_0xdf524d(0x152)+_0x35513b,_0xffe364,{'helpText':_0xdf524d(0x174)});throw _0xffe364;}const _0x3aa93f=await this['client']['listTemplates']({'workspaceId':_0x19d350}),_0x519746=Array['isArray'](_0x3aa93f[_0xdf524d(0x15a)])?_0x3aa93f[_0xdf524d(0x15a)]:[_0x3aa93f[_0xdf524d(0x15a)]],_0x11f91f=_0x519746['filter'](_0x23c2fa=>_0x23c2fa[_0xdf524d(0x13d)][_0xdf524d(0x182)]===_0x35513b);if(_0x11f91f['length']===0x0)throw new SDKError(ErrorCode['NOT_FOUND'],_0xdf524d(0x147)+_0x35513b,undefined,{'helpText':_0xdf524d(0x174)});if(_0x11f91f[_0xdf524d(0x172)]>0x1){const _0x50c74a=_0x11f91f[_0xdf524d(0x17a)](_0x48e815=>_0x48e815['id'])[_0xdf524d(0x148)](',\x20');throw new SDKError(ErrorCode[_0xdf524d(0x149)],_0xdf524d(0x151)+_0x35513b+_0xdf524d(0x183)+_0x50c74a,undefined,{'helpText':_0xdf524d(0x14b)});}return _0x11f91f[0x0]['id'];}async[a49_0xe74303(0x186)](_0x4dcbd8){const _0x5962fd=a49_0xe74303;if(this[_0x5962fd(0x17c)](_0x4dcbd8))try{return await this[_0x5962fd(0x162)][_0x5962fd(0x185)](_0x4dcbd8),_0x4dcbd8;}catch(_0x45b0ce){if(_0x45b0ce instanceof SDKError&&_0x45b0ce['code']===ErrorCode[_0x5962fd(0x184)])throw new SDKError(ErrorCode[_0x5962fd(0x184)],'Workspace\x20not\x20found\x20with\x20ID:\x20'+_0x4dcbd8,_0x45b0ce,{'helpText':_0x5962fd(0x175)});throw _0x45b0ce;}const _0x35c8da=await this[_0x5962fd(0x162)][_0x5962fd(0x16a)]({'name':_0x4dcbd8}),_0x39aaa8=Array[_0x5962fd(0x178)](_0x35c8da[_0x5962fd(0x15a)])?_0x35c8da[_0x5962fd(0x15a)]:[_0x35c8da[_0x5962fd(0x15a)]],_0x330eaa=_0x39aaa8[_0x5962fd(0x14e)](_0x527e1a=>_0x527e1a[_0x5962fd(0x13d)][_0x5962fd(0x182)]===_0x4dcbd8);if(_0x330eaa['length']===0x0)throw new SDKError(ErrorCode['NOT_FOUND'],_0x5962fd(0x180)+_0x4dcbd8,undefined,{'helpText':'Use\x20\x22tdx\x20engage\x20workspace\x20list\x22\x20to\x20see\x20available\x20workspaces.'});if(_0x330eaa[_0x5962fd(0x172)]>0x1){const _0x4ca823=_0x330eaa['map'](_0x3c43e0=>_0x3c43e0['id'])['join'](',\x20');throw new SDKError(ErrorCode[_0x5962fd(0x149)],'Multiple\x20workspaces\x20found\x20with\x20name\x20\x22'+_0x4dcbd8+'\x22:\x20'+_0x4ca823,undefined,{'helpText':_0x5962fd(0x141)});}return _0x330eaa[0x0]['id'];}async[a49_0xe74303(0x143)](_0x1e9d87){const _0x481652=a49_0xe74303,_0x772426=await this[_0x481652(0x162)][_0x481652(0x143)]({'campaignType':_0x1e9d87?.[_0x481652(0x15c)],'status':_0x1e9d87?.[_0x481652(0x13f)],'workspaceId':_0x1e9d87?.['workspaceId'],'limit':_0x1e9d87?.[_0x481652(0x144)]}),_0x1d068b=Array[_0x481652(0x178)](_0x772426[_0x481652(0x15a)])?_0x772426[_0x481652(0x15a)]:[_0x772426[_0x481652(0x15a)]];return _0x1d068b['map'](_0x10de22=>this[_0x481652(0x142)](_0x10de22));}async[a49_0xe74303(0x179)](_0x44ec52,_0xb73f79){const _0x5143da=a49_0xe74303,_0x338fcd=await this[_0x5143da(0x17b)](_0x44ec52,_0xb73f79),_0x46c052=await this[_0x5143da(0x162)][_0x5143da(0x179)](_0x338fcd);return this['normalizeCampaign'](_0x46c052[_0x5143da(0x15a)]);}async[a49_0xe74303(0x145)](_0x29c069,_0x3907bb){const _0x9d3d7=a49_0xe74303,_0x314148=await this[_0x9d3d7(0x17b)](_0x29c069,_0x3907bb),_0xf4bbc2=await this['client'][_0x9d3d7(0x179)](_0x314148);return _0xf4bbc2[_0x9d3d7(0x15a)];}async[a49_0xe74303(0x15b)](_0x36b64b){const _0x401c21=a49_0xe74303,_0x3df666=await this[_0x401c21(0x162)][_0x401c21(0x15b)](_0x36b64b);return this[_0x401c21(0x142)](_0x3df666['data']);}async['updateCampaign'](_0x4407de,_0x3b11c3,_0x2bcc26){const _0x5f0a0c=a49_0xe74303,_0x2569c1=await this[_0x5f0a0c(0x17b)](_0x4407de,_0x2bcc26),_0x54e869=await this['client'][_0x5f0a0c(0x138)](_0x2569c1,_0x3b11c3);return this[_0x5f0a0c(0x142)](_0x54e869['data']);}async[a49_0xe74303(0x156)](_0x18229b,_0x1a20ec){const _0x2ab85b=a49_0xe74303,_0x3f2de7=await this[_0x2ab85b(0x17b)](_0x18229b,_0x1a20ec);await this[_0x2ab85b(0x162)]['deleteCampaign'](_0x3f2de7);}async[a49_0xe74303(0x173)](_0x4c811f,_0x47f787){const _0x47c29d=a49_0xe74303,_0x2ddc10=await this[_0x47c29d(0x17b)](_0x4c811f,_0x47f787);await this[_0x47c29d(0x162)]['launchCampaign'](_0x2ddc10);}async[a49_0xe74303(0x187)](_0x5214f1,_0x1ed80c){const _0x515ab4=a49_0xe74303,_0x33b46f=await this[_0x515ab4(0x17b)](_0x5214f1,_0x1ed80c);await this[_0x515ab4(0x162)]['pauseCampaign'](_0x33b46f);}async[a49_0xe74303(0x14f)](_0x4c5996,_0x241def){const _0x43082d=a49_0xe74303,_0x3de2a5=await this['resolveCampaignId'](_0x4c5996,_0x241def);await this[_0x43082d(0x162)][_0x43082d(0x14f)](_0x3de2a5);}async['duplicateCampaign'](_0x5945e7,_0x28b586){const _0x3fba95=a49_0xe74303,_0x12b927=await this['resolveCampaignId'](_0x5945e7,_0x28b586),_0x581346=await this[_0x3fba95(0x162)][_0x3fba95(0x170)](_0x12b927);return this[_0x3fba95(0x142)](_0x581346[_0x3fba95(0x15a)]);}async[a49_0xe74303(0x13e)](_0x5c3529){const _0x2d4927=a49_0xe74303,_0x46a8a9=await this[_0x2d4927(0x162)][_0x2d4927(0x13e)]({'workspaceId':_0x5c3529?.['workspaceId'],'limit':_0x5c3529?.[_0x2d4927(0x144)]}),_0x30e43a=Array[_0x2d4927(0x178)](_0x46a8a9[_0x2d4927(0x15a)])?_0x46a8a9[_0x2d4927(0x15a)]:[_0x46a8a9['data']];return _0x30e43a['map'](_0x52a8d2=>this[_0x2d4927(0x140)](_0x52a8d2));}async[a49_0xe74303(0x159)](_0x96f24,_0x5032f8){const _0x2b315e=a49_0xe74303,_0xe6a35c=await this[_0x2b315e(0x150)](_0x96f24,_0x5032f8),_0x4a63e3=await this[_0x2b315e(0x162)][_0x2b315e(0x159)](_0xe6a35c);return this[_0x2b315e(0x140)](_0x4a63e3[_0x2b315e(0x15a)]);}async[a49_0xe74303(0x153)](_0x4e9eb1,_0x4bb96c){const _0x232998=a49_0xe74303,_0xd32cfc=await this[_0x232998(0x150)](_0x4e9eb1,_0x4bb96c),_0x51993c=await this[_0x232998(0x162)][_0x232998(0x159)](_0xd32cfc);return _0x51993c[_0x232998(0x15a)];}async[a49_0xe74303(0x157)](_0x4f209b){const _0x39508c=a49_0xe74303,_0x3db891=await this[_0x39508c(0x162)]['createTemplate'](_0x4f209b);return this[_0x39508c(0x140)](_0x3db891['data']);}async['updateTemplate'](_0x4704e,_0x1948f4,_0x5255c6){const _0x44de47=a49_0xe74303,_0x4e8a9b=await this[_0x44de47(0x150)](_0x4704e,_0x5255c6),_0x415a7b=await this[_0x44de47(0x162)]['updateTemplate'](_0x4e8a9b,_0x1948f4);return this[_0x44de47(0x140)](_0x415a7b[_0x44de47(0x15a)]);}async[a49_0xe74303(0x166)](_0x394a6a,_0x34ac0e){const _0x39f128=a49_0xe74303,_0x11146b=await this[_0x39f128(0x150)](_0x394a6a,_0x34ac0e);await this[_0x39f128(0x162)][_0x39f128(0x166)](_0x11146b);}async[a49_0xe74303(0x16a)](_0x342a97){const _0x5caff5=a49_0xe74303,_0x49dc76=await this[_0x5caff5(0x162)][_0x5caff5(0x16a)]({'name':_0x342a97?.[_0x5caff5(0x182)],'limit':_0x342a97?.[_0x5caff5(0x144)]}),_0x537e5b=Array[_0x5caff5(0x178)](_0x49dc76[_0x5caff5(0x15a)])?_0x49dc76[_0x5caff5(0x15a)]:[_0x49dc76[_0x5caff5(0x15a)]];return _0x537e5b['map'](_0x25cf25=>this[_0x5caff5(0x158)](_0x25cf25));}async[a49_0xe74303(0x185)](_0x83a86c){const _0x7a6523=a49_0xe74303,_0x163f66=await this['resolveWorkspaceId'](_0x83a86c),_0x492dd0=await this[_0x7a6523(0x162)][_0x7a6523(0x185)](_0x163f66);return this[_0x7a6523(0x158)](_0x492dd0[_0x7a6523(0x15a)]);}async[a49_0xe74303(0x161)](_0x26a0d3){const _0x3b8e2c=a49_0xe74303,_0x316f9c=await this['resolveWorkspaceId'](_0x26a0d3),_0x251846=await this['client'][_0x3b8e2c(0x185)](_0x316f9c);return _0x251846['data'];}async[a49_0xe74303(0x16b)](_0x2faaba){const _0x217253=a49_0xe74303,_0x1a4a2f=await this[_0x217253(0x162)]['createWorkspace'](_0x2faaba);return this[_0x217253(0x158)](_0x1a4a2f[_0x217253(0x15a)]);}async[a49_0xe74303(0x15f)](_0x6c3f30,_0x32e8e0){const _0x25b52d=a49_0xe74303,_0x581420=await this[_0x25b52d(0x186)](_0x6c3f30),_0x2643ac=await this[_0x25b52d(0x162)][_0x25b52d(0x15f)](_0x581420,_0x32e8e0);return this[_0x25b52d(0x158)](_0x2643ac[_0x25b52d(0x15a)]);}async[a49_0xe74303(0x17e)](_0x1168e0){const _0x47df87=a49_0xe74303,_0x2e0c7f=await this['resolveWorkspaceId'](_0x1168e0);await this[_0x47df87(0x162)]['deleteWorkspace'](_0x2e0c7f);}}
|
package/dist/sdk/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a50_0x29c2(){const _0x277c1d=['replace','includes','61019HzNtRy','code','DATABASE_NOT_FOUND','TABLE_NOT_FOUND','LLM_MALFORMED_MESSAGE','142hFTbbp','CANCELLED','stack','TRINO_INSUFFICIENT_RESOURCES','ALREADY_EXISTS','NOT_FOUND','INSTALLATION_FAILED','1180YPINVa','some','HTTP_REQUEST_FAILURE','1562802sJYhmK','UNAVAILABLE','TIMEOUT','1483232OkOpVL','isRetryable','INVALID_ARGUMENT','1479678EVnyNb','TRINO_USER_CANCELLED','TRINO_NOT_FOUND','SDKError','INTERNAL','UNAUTHENTICATED','MISSING_ARGUMENT','AGENT_NOT_FOUND','TRINO_INTERNAL_ERROR','1390420eZazLB','4839490mqitfb','LLM_CHAT_CREATION_FAILURE','LLM_STREAM_ERROR','WORKFLOW_PROJECT_NOT_FOUND','PERMISSION_DENIED','9JFdnzI','helpText','LLM_PROJECT_NOT_FOUND','168HWEuTy','name','USER_ERROR','\x0aCaused\x20by:\x20','TRINO_SYNTAX_ERROR','TRINO_INVALID_ARGUMENT','COMMAND_NOT_FOUND','INTERNAL_ERROR','category','LLM_EMPTY_MESSAGE','cause','CHAT_NOT_FOUND','message'];a50_0x29c2=function(){return _0x277c1d;};return a50_0x29c2();}const a50_0x21eb3f=a50_0x52ae;(function(_0x599413,_0x53031a){const _0x233502=a50_0x52ae,_0x4379bf=_0x599413();while(!![]){try{const _0x21f8f8=-parseInt(_0x233502(0x1d8))/0x1*(parseInt(_0x233502(0x1d1))/0x2)+-parseInt(_0x233502(0x1e1))/0x3+-parseInt(_0x233502(0x1de))/0x4+parseInt(_0x233502(0x1b4))/0x5+parseInt(_0x233502(0x1db))/0x6+-parseInt(_0x233502(0x1cc))/0x7*(-parseInt(_0x233502(0x1bd))/0x8)+parseInt(_0x233502(0x1ba))/0x9*(parseInt(_0x233502(0x1b5))/0xa);if(_0x21f8f8===_0x53031a)break;else _0x4379bf['push'](_0x4379bf['shift']());}catch(_0x2c73ea){_0x4379bf['push'](_0x4379bf['shift']());}}}(a50_0x29c2,0x3eecf));export var ErrorCategory;(function(_0x2d71de){const _0x5365f5=a50_0x52ae;_0x2d71de['USER_ERROR']=_0x5365f5(0x1bf),_0x2d71de[_0x5365f5(0x1c4)]=_0x5365f5(0x1c4);}(ErrorCategory||(ErrorCategory={})));export var ErrorCode;(function(_0x5532b6){const _0xc394d1=a50_0x52ae;_0x5532b6['MISSING_ARGUMENT']=_0xc394d1(0x1b1),_0x5532b6[_0xc394d1(0x1e0)]='INVALID_ARGUMENT',_0x5532b6[_0xc394d1(0x1d6)]=_0xc394d1(0x1d6),_0x5532b6[_0xc394d1(0x1ce)]=_0xc394d1(0x1ce),_0x5532b6[_0xc394d1(0x1cf)]='TABLE_NOT_FOUND',_0x5532b6[_0xc394d1(0x1bc)]=_0xc394d1(0x1bc),_0x5532b6[_0xc394d1(0x1b2)]=_0xc394d1(0x1b2),_0x5532b6[_0xc394d1(0x1b8)]=_0xc394d1(0x1b8),_0x5532b6['CHAT_NOT_FOUND']=_0xc394d1(0x1c8),_0x5532b6['LLM_EMPTY_MESSAGE']=_0xc394d1(0x1c6),_0x5532b6[_0xc394d1(0x1c3)]='COMMAND_NOT_FOUND',_0x5532b6[_0xc394d1(0x1d7)]='INSTALLATION_FAILED',_0x5532b6[_0xc394d1(0x1b9)]=_0xc394d1(0x1b9),_0x5532b6[_0xc394d1(0x1b0)]=_0xc394d1(0x1b0),_0x5532b6[_0xc394d1(0x1d5)]='ALREADY_EXISTS',_0x5532b6[_0xc394d1(0x1d2)]='CANCELLED',_0x5532b6[_0xc394d1(0x1c1)]=_0xc394d1(0x1c1),_0x5532b6['TRINO_NOT_FOUND']=_0xc394d1(0x1e3),_0x5532b6[_0xc394d1(0x1c2)]=_0xc394d1(0x1c2),_0x5532b6[_0xc394d1(0x1e2)]='TRINO_USER_CANCELLED',_0x5532b6[_0xc394d1(0x1dc)]=_0xc394d1(0x1dc),_0x5532b6[_0xc394d1(0x1dd)]=_0xc394d1(0x1dd),_0x5532b6[_0xc394d1(0x1da)]=_0xc394d1(0x1da),_0x5532b6[_0xc394d1(0x1e5)]='INTERNAL',_0x5532b6['RATE_LIMITED']='RATE_LIMITED',_0x5532b6[_0xc394d1(0x1b3)]='TRINO_INTERNAL_ERROR',_0x5532b6[_0xc394d1(0x1d4)]=_0xc394d1(0x1d4),_0x5532b6['LLM_MALFORMED_MESSAGE']=_0xc394d1(0x1d0),_0x5532b6[_0xc394d1(0x1b7)]=_0xc394d1(0x1b7),_0x5532b6[_0xc394d1(0x1b6)]=_0xc394d1(0x1b6);}(ErrorCode||(ErrorCode={})));const ERROR_CODE_CATEGORY={[ErrorCode[a50_0x21eb3f(0x1b1)]]:ErrorCategory['USER_ERROR'],[ErrorCode['INVALID_ARGUMENT']]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1d6)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a50_0x21eb3f(0x1ce)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a50_0x21eb3f(0x1cf)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a50_0x21eb3f(0x1bc)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1b2)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1b8)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1c8)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1c6)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1c3)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1d7)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1b9)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode['UNAUTHENTICATED']]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1d5)]]:ErrorCategory['USER_ERROR'],[ErrorCode['CANCELLED']]:ErrorCategory['USER_ERROR'],[ErrorCode[a50_0x21eb3f(0x1c1)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a50_0x21eb3f(0x1e3)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode['TRINO_INVALID_ARGUMENT']]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1e2)]]:ErrorCategory[a50_0x21eb3f(0x1bf)],[ErrorCode[a50_0x21eb3f(0x1dc)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a50_0x21eb3f(0x1dd)]]:ErrorCategory[a50_0x21eb3f(0x1c4)],[ErrorCode[a50_0x21eb3f(0x1da)]]:ErrorCategory[a50_0x21eb3f(0x1c4)],[ErrorCode['INTERNAL']]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode['RATE_LIMITED']]:ErrorCategory[a50_0x21eb3f(0x1c4)],[ErrorCode[a50_0x21eb3f(0x1b3)]]:ErrorCategory[a50_0x21eb3f(0x1c4)],[ErrorCode[a50_0x21eb3f(0x1d4)]]:ErrorCategory[a50_0x21eb3f(0x1c4)],[ErrorCode[a50_0x21eb3f(0x1d0)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a50_0x21eb3f(0x1b7)]]:ErrorCategory[a50_0x21eb3f(0x1c4)],[ErrorCode[a50_0x21eb3f(0x1b6)]]:ErrorCategory[a50_0x21eb3f(0x1c4)]};export function getErrorCategory(_0x3df35c){return ERROR_CODE_CATEGORY[_0x3df35c];}export function isRetryableError(_0x1c0d8a){const _0x3dc7b9=a50_0x21eb3f;return getErrorCategory(_0x1c0d8a)===ErrorCategory[_0x3dc7b9(0x1c4)];}function a50_0x52ae(_0x1ec262,_0x4e54e3){const _0x29c264=a50_0x29c2();return a50_0x52ae=function(_0x52ae6d,_0x43f5b3){_0x52ae6d=_0x52ae6d-0x1b0;let _0x1ed855=_0x29c264[_0x52ae6d];return _0x1ed855;},a50_0x52ae(_0x1ec262,_0x4e54e3);}export class SDKError extends Error{[a50_0x21eb3f(0x1cd)];[a50_0x21eb3f(0x1bb)];['cause'];constructor(_0x3e2de5,_0x4c0cef,_0x23678a,_0x526539){const _0x2a6c3a=a50_0x21eb3f;super('['+_0x3e2de5+']\x20'+_0x4c0cef),this[_0x2a6c3a(0x1be)]=_0x2a6c3a(0x1e4),this[_0x2a6c3a(0x1cd)]=_0x3e2de5,this[_0x2a6c3a(0x1bb)]=_0x526539?.[_0x2a6c3a(0x1bb)],this[_0x2a6c3a(0x1c7)]=_0x23678a,_0x23678a instanceof Error&&(this[_0x2a6c3a(0x1d3)]=this[_0x2a6c3a(0x1d3)]+_0x2a6c3a(0x1c0)+_0x23678a[_0x2a6c3a(0x1d3)]);}get[a50_0x21eb3f(0x1c5)](){const _0x18a7ca=a50_0x21eb3f;return getErrorCategory(this[_0x18a7ca(0x1cd)]);}[a50_0x21eb3f(0x1df)](){return isRetryableError(this['code']);}get['originalMessage'](){const _0x22060e=a50_0x21eb3f;return this[_0x22060e(0x1c9)][_0x22060e(0x1ca)](/^\[.*?\]\s*/,'');}}export function errorContains(_0x341664,..._0x1073e1){const _0x436337=a50_0x21eb3f,_0x137400=_0x341664?.['message']||'',_0x6d4564=_0x341664?.[_0x436337(0x1c7)],_0xca7a3a=_0x6d4564?.[_0x436337(0x1c9)]||'';return _0x1073e1[_0x436337(0x1d9)](_0x5087da=>_0x137400[_0x436337(0x1cb)](_0x5087da)||_0xca7a3a['includes'](_0x5087da));}
|
package/dist/sdk/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a51_0x45580b=a51_0x3e2d;(function(_0x6931fe,_0x206854){const _0x4fff14=a51_0x3e2d,_0x1c8d81=_0x6931fe();while(!![]){try{const _0x1f0a3b=-parseInt(_0x4fff14(0x13f))/0x1*(-parseInt(_0x4fff14(0x138))/0x2)+-parseInt(_0x4fff14(0x147))/0x3+-parseInt(_0x4fff14(0x14a))/0x4+parseInt(_0x4fff14(0x13b))/0x5+-parseInt(_0x4fff14(0x145))/0x6+-parseInt(_0x4fff14(0x137))/0x7*(parseInt(_0x4fff14(0x14e))/0x8)+-parseInt(_0x4fff14(0x14d))/0x9*(-parseInt(_0x4fff14(0x142))/0xa);if(_0x1f0a3b===_0x206854)break;else _0x1c8d81['push'](_0x1c8d81['shift']());}catch(_0x208ed7){_0x1c8d81['push'](_0x1c8d81['shift']());}}}(a51_0x1816,0x87ed0));import{loadUserConfigOnce,getAPIKey}from'../core/config.js';import{SegmentSDK}from'./segment.js';import{WorkflowSDK}from'./workflow.js';import{LLMSDK}from'./llm.js';import{JobSDK}from'./job.js';function a51_0x3e2d(_0xe93102,_0x386bc5){const _0x18161c=a51_0x1816();return a51_0x3e2d=function(_0x3e2d09,_0x588469){_0x3e2d09=_0x3e2d09-0x137;let _0x12bc45=_0x18161c[_0x3e2d09];return _0x12bc45;},a51_0x3e2d(_0xe93102,_0x386bc5);}import{RawAPI}from'./api.js';import{QuerySDK}from'./query.js';import{EngageSDK}from'./engage.js';import{LogLevel,TDXLogger}from'../utils/tdx-logger.js';export*from'./errors.js';export*from'./segment.js';export*from'./workflow.js';export*from'./llm.js';export*from'./job.js';export*from'./api.js';export*from'./query.js';function a51_0x1816(){const _0x1460eb=['query','27ImYOyr','400qVsWNw','109767EMBouV','262WRZrja','site','context','2136960wObTup','logger','create','segment','7097qTpYiI','jobs','llm','2923030LCnoJx','api','us01','756024tbxBhd','init','1832406zcEVRk','engage','workflow','625600UtKiix','logLevel'];a51_0x1816=function(){return _0x1460eb;};return a51_0x1816();}export*from'./engage.js';export{LogLevel}from'../utils/tdx-logger.js';export class TDX{['context'];[a51_0x45580b(0x14c)];[a51_0x45580b(0x13e)];[a51_0x45580b(0x149)];['llm'];[a51_0x45580b(0x140)];[a51_0x45580b(0x148)];[a51_0x45580b(0x143)];static[a51_0x45580b(0x13d)](_0x121e97={}){const _0x1c3ff7=a51_0x45580b,_0x508351=_0x121e97[_0x1c3ff7(0x139)]||_0x1c3ff7(0x144),_0x52787a=_0x121e97[_0x1c3ff7(0x14b)]??LogLevel['INFO'];let _0xc05ba5=_0x121e97['apiKey'];!_0xc05ba5&&(loadUserConfigOnce(),_0xc05ba5=getAPIKey(_0x508351));const _0x5f5832=new TDXLogger(_0x52787a,!![]);return _0x5f5832[_0x1c3ff7(0x146)]()['catch'](()=>{}),new TDX({'site':_0x508351,'apiKey':_0xc05ba5,'logLevel':_0x52787a,'logger':_0x5f5832});}constructor(_0x48aa28){const _0x4acee8=a51_0x45580b;this[_0x4acee8(0x13a)]=_0x48aa28,this[_0x4acee8(0x14c)]=new QuerySDK(_0x48aa28),this['segment']=new SegmentSDK(_0x48aa28),this[_0x4acee8(0x149)]=new WorkflowSDK(_0x48aa28),this[_0x4acee8(0x141)]=new LLMSDK(_0x48aa28),this[_0x4acee8(0x140)]=new JobSDK(_0x48aa28),this[_0x4acee8(0x148)]=new EngageSDK(_0x48aa28),this[_0x4acee8(0x143)]=new RawAPI(_0x48aa28);}get[a51_0x45580b(0x13c)](){const _0x3827a3=a51_0x45580b;return this[_0x3827a3(0x13a)][_0x3827a3(0x13c)];}}
|
package/dist/sdk/job.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a52_0x4b1b(){const _0x45146c=['test','4246600qUdDCV','2065704uDwKGc','client','38952rwdUAw','1698mXYBtu','created_at','updated_at','replace','1233nzjySk','logger','submit','listJobs','showJob','map','kill','start_at','end_at','result','submitHiveJob','2534876PTfRPe','submitPrestoJob','17227WmUdbO','3758436hcBmRP','list','822361EOrFGS','getJobResult','getUserInfo'];a52_0x4b1b=function(){return _0x45146c;};return a52_0x4b1b();}function a52_0x1d06(_0xbe74e2,_0x7edd3){const _0x4b1b0d=a52_0x4b1b();return a52_0x1d06=function(_0x1d069e,_0x58f2a5){_0x1d069e=_0x1d069e-0x1d0;let _0x236183=_0x4b1b0d[_0x1d069e];return _0x236183;},a52_0x1d06(_0xbe74e2,_0x7edd3);}const a52_0x3bb49b=a52_0x1d06;(function(_0x1afec7,_0x498928){const _0x1ef884=a52_0x1d06,_0x41865e=_0x1afec7();while(!![]){try{const _0x37e5ae=-parseInt(_0x1ef884(0x1de))/0x1+parseInt(_0x1ef884(0x1d9))/0x2+parseInt(_0x1ef884(0x1e3))/0x3+-parseInt(_0x1ef884(0x1dc))/0x4+-parseInt(_0x1ef884(0x1e2))/0x5+-parseInt(_0x1ef884(0x1e6))/0x6*(-parseInt(_0x1ef884(0x1db))/0x7)+parseInt(_0x1ef884(0x1e5))/0x8*(parseInt(_0x1ef884(0x1ea))/0x9);if(_0x37e5ae===_0x498928)break;else _0x41865e['push'](_0x41865e['shift']());}catch(_0x3ee00b){_0x41865e['push'](_0x41865e['shift']());}}}(a52_0x4b1b,0xace88));import{TDApiClient}from'../client/td-api-client.js';function normalizeTimestamp(_0x30375b){const _0x474d53=a52_0x1d06;if(!_0x30375b)return undefined;if(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/[_0x474d53(0x1e1)](_0x30375b))return _0x30375b;return _0x30375b[_0x474d53(0x1e9)]('\x20UTC','Z')[_0x474d53(0x1e9)]('\x20','T');}export class JobSDK{[a52_0x3bb49b(0x1e4)];constructor(_0x456fe7){const _0xaad98=a52_0x3bb49b;this[_0xaad98(0x1e4)]=new TDApiClient(_0x456fe7,_0x456fe7[_0xaad98(0x1eb)]);}async[a52_0x3bb49b(0x1dd)](_0x317ba7){const _0x50f96d=a52_0x3bb49b,_0x9fff50=await this[_0x50f96d(0x1e4)][_0x50f96d(0x1d1)](_0x317ba7);return _0x9fff50[_0x50f96d(0x1d3)](_0xe3c83a=>({..._0xe3c83a,'created_at':normalizeTimestamp(_0xe3c83a[_0x50f96d(0x1e7)]),'updated_at':normalizeTimestamp(_0xe3c83a['updated_at']),'start_at':normalizeTimestamp(_0xe3c83a['start_at']),'end_at':normalizeTimestamp(_0xe3c83a[_0x50f96d(0x1d6)])}));}async['show'](_0x4728a8){const _0x5391fe=a52_0x3bb49b,_0x3e9c60=await this[_0x5391fe(0x1e4)][_0x5391fe(0x1d2)](_0x4728a8);return{..._0x3e9c60,'created_at':normalizeTimestamp(_0x3e9c60[_0x5391fe(0x1e7)]),'updated_at':normalizeTimestamp(_0x3e9c60[_0x5391fe(0x1e8)]),'start_at':normalizeTimestamp(_0x3e9c60[_0x5391fe(0x1d5)]),'end_at':normalizeTimestamp(_0x3e9c60[_0x5391fe(0x1d6)])};}async[a52_0x3bb49b(0x1d4)](_0x169736){const _0xc3edc8=a52_0x3bb49b;await this[_0xc3edc8(0x1e4)]['cancelJob'](_0x169736);}async[a52_0x3bb49b(0x1d0)](_0x2aaa56,_0x58224d,_0x478026='trino'){const _0x147cb7=a52_0x3bb49b;return _0x478026==='hive'?await this[_0x147cb7(0x1e4)][_0x147cb7(0x1d8)](_0x2aaa56,_0x58224d):await this['client'][_0x147cb7(0x1da)](_0x2aaa56,_0x58224d);}async[a52_0x3bb49b(0x1d7)](_0x294963){const _0x40e5b3=a52_0x3bb49b;return await this[_0x40e5b3(0x1e4)][_0x40e5b3(0x1df)](_0x294963);}async[a52_0x3bb49b(0x1e0)](){const _0xb10e=a52_0x3bb49b;return await this[_0xb10e(0x1e4)][_0xb10e(0x1e0)]();}}
|
package/dist/sdk/llm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a53_0x5f0156=a53_0x9751;(function(_0x3a5ea8,_0x10f125){const _0xb1cbd3=a53_0x9751,_0x59dac0=_0x3a5ea8();while(!![]){try{const _0x11f064=-parseInt(_0xb1cbd3(0xc6))/0x1+parseInt(_0xb1cbd3(0xa3))/0x2*(parseInt(_0xb1cbd3(0xfc))/0x3)+-parseInt(_0xb1cbd3(0xdd))/0x4*(-parseInt(_0xb1cbd3(0x80))/0x5)+parseInt(_0xb1cbd3(0xce))/0x6*(parseInt(_0xb1cbd3(0xef))/0x7)+parseInt(_0xb1cbd3(0xf9))/0x8*(parseInt(_0xb1cbd3(0xba))/0x9)+-parseInt(_0xb1cbd3(0x88))/0xa*(-parseInt(_0xb1cbd3(0xa1))/0xb)+-parseInt(_0xb1cbd3(0x86))/0xc*(parseInt(_0xb1cbd3(0xfa))/0xd);if(_0x11f064===_0x10f125)break;else _0x59dac0['push'](_0x59dac0['shift']());}catch(_0x11b1f5){_0x59dac0['push'](_0x59dac0['shift']());}}}(a53_0x51df,0xcd5a6));function a53_0x51df(){const _0x2d7c57=['size','UNAUTHENTICATED','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','actions','agents.json','conflict','writeFileSync','currentProjectId','project.json','listPrompts','parse','getProject','filter','set','serviceType','agentId','Agent\x20not\x20found:\x20','_reasoning_','1.0','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','utf-8','projects','listIntegrations','330385zGwECB','tdx_','1068OdGBJE','logger','find','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','deleteProject','dryRun','LLM_PROJECT_NOT_FOUND','isProjectId','getChatInfo','getBackupMetadata','test','agent','push','event','medium','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','signal','getAgent','slackMessageMode','attributes','has','listAgents','variables','624600wMCMmY','AGENT_NOT_FOUND','INTERNAL','listProjects','chatId','integrations.json','startChat','modelType','getOrCreateDefaultProject','createAgentFull','displayName','join','1648122WcSKpm','Unable\x20to\x20create\x20project\x20after\x20','setCurrentProject','chatIgnoreManagedActions','NOT_FOUND','stringify','description','backupProject','192ZcpiLH','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','prompts.json','maxToolIterations','restoreProject','projectName','Multiple\x20projects\x20found\x20with\x20name\x20\x27','chatWelcomeMessage','metadata','high','\x27.\x20This\x20should\x20not\x20happen.','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','Project\x20not\x20found\x20with\x20ID:\x20','continueChat','minimal','2876dhPDYl','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','createKnowledgeBase','tables','existsSync','webhookCorsOrigins','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','getDefaultProjectName','deleteAgent','listKnowledgeBases','Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.','\x20in\x20project\x20','chat','availableModelNames','outputs','updateAgent','promptId','exportedFrom','44611hxLvIv','context','chats','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','mkdirSync','client','length','listAgentsFull','listChats','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','80hWkfnE','4979KiTrEt','name','6339oCZGJu','claude-4.5-sonnet','createPrompt','Output\x20directory\x20already\x20exists:\x20','INVALID_ARGUMENT','getUserSettings','tdDatabaseName','version','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','get','ALREADY_EXISTS','systemPrompt','toISOString','Multiple\x20agents\x20found\x20with\x20name\x20\x27','\x20attempts\x20due\x20to\x20name\x20conflicts.','Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.','knowledgebases.json','template','getCurrentProject','createIntegration','Project\x20not\x20found:\x20','temperature','loadJsonFile','none','status','createAgent','createProject','site','low','map','6410kyFYQy','Unsupported\x20backup\x20version:\x20','tdx_default_','tools','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','readFileSync','66132ktgzUN','agents','550EJAcqf','resolveProjectId'];a53_0x51df=function(){return _0x2d7c57;};return a53_0x51df();}function a53_0x9751(_0x544b32,_0x584e82){const _0x51dfcc=a53_0x51df();return a53_0x9751=function(_0x9751f3,_0x5debdf){_0x9751f3=_0x9751f3-0x6d;let _0x9eb6ac=_0x51dfcc[_0x9751f3];return _0x9eb6ac;},a53_0x9751(_0x544b32,_0x584e82);}import{LLMApiClient}from'../client/llm-api-client.js';import*as a53_0x142488 from'node:fs';import*as a53_0x3cd23c from'node:path';import{HTTPClientError}from'../client/http-client.js';import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'../utils/llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'./errors.js';import{getSanitizedUsername,generateRandomHex}from'../utils/string-utils.js';import{readCachedLLMProject,writeCachedLLMProject}from'../core/config.js';export class LLMSDK{[a53_0x5f0156(0x91)];['client'];[a53_0x5f0156(0xf0)];constructor(_0x5133d2){const _0x5ed6a7=a53_0x5f0156;this[_0x5ed6a7(0xf4)]=new LLMApiClient(_0x5133d2,_0x5133d2[_0x5ed6a7(0xa4)]),this[_0x5ed6a7(0xf0)]=_0x5133d2;}[a53_0x5f0156(0xe4)](){const _0xe602ff=a53_0x5f0156,_0x3329e7=getSanitizedUsername();return _0xe602ff(0x82)+_0x3329e7;}[a53_0x5f0156(0xaa)](_0x2e6f1d){const _0x482e10=a53_0x5f0156;return/^[a-zA-Z0-9]{8,}$/[_0x482e10(0xad)](_0x2e6f1d);}async[a53_0x5f0156(0xc8)](_0x3f9aeb){const _0x35632e=a53_0x5f0156;if(this[_0x35632e(0xaa)](_0x3f9aeb)){const _0xf8d41a=await this[_0x35632e(0xf4)][_0x35632e(0xbd)](),_0x563869=_0xf8d41a['find'](_0x5bb26e=>_0x5bb26e['id']===_0x3f9aeb);if(!_0x563869)throw new SDKError(ErrorCode[_0x35632e(0xa9)],_0x35632e(0xda)+_0x3f9aeb,undefined,{'helpText':_0x35632e(0x104)});this[_0x35632e(0x91)]=_0x3f9aeb;}else this['currentProjectId']=await this['resolveProjectId'](_0x3f9aeb);}[a53_0x5f0156(0x74)](){const _0x5b1acf=a53_0x5f0156;return this[_0x5b1acf(0x91)];}async['models'](){const _0x3f6153=a53_0x5f0156,_0x4cdec2=await this[_0x3f6153(0xf4)][_0x3f6153(0x101)](),_0x24f131=[];for(const _0x5b6d6c of _0x4cdec2[_0x3f6153(0xea)]){const _0x58c9e0=_0x4cdec2['availableModels'][_0x5b6d6c];_0x58c9e0&&_0x24f131[_0x3f6153(0xaf)]({'name':_0x5b6d6c,'displayName':_0x58c9e0[_0x3f6153(0xc4)]});}return _0x24f131;}async[a53_0x5f0156(0x7c)](_0x3d7c5e){const _0x27304b=a53_0x5f0156;return await this[_0x27304b(0xf4)][_0x27304b(0x7c)](_0x3d7c5e);}async[a53_0x5f0156(0xa7)](_0x321a81){const _0x125f6d=a53_0x5f0156;let _0x4b1022;if(this[_0x125f6d(0xaa)](_0x321a81)){const _0x2b29d5=await this[_0x125f6d(0xf4)][_0x125f6d(0xbd)](),_0x3117d8=_0x2b29d5[_0x125f6d(0xa5)](_0xaacda5=>_0xaacda5['id']===_0x321a81);if(!_0x3117d8)throw new SDKError(ErrorCode[_0x125f6d(0xa9)],'Project\x20not\x20found\x20with\x20ID:\x20'+_0x321a81,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});_0x4b1022=_0x321a81;}else _0x4b1022=await this['resolveProjectId'](_0x321a81);await this[_0x125f6d(0xf4)]['deleteProject'](_0x4b1022);}async[a53_0x5f0156(0x9f)](_0x36b297=0x32){const _0x17bc7d=a53_0x5f0156;return await this[_0x17bc7d(0xf4)][_0x17bc7d(0xbd)](_0x36b297);}async[a53_0x5f0156(0xc2)](_0x3e87c7){const _0x814f4c=a53_0x5f0156,_0x34113d=_0x3e87c7||this[_0x814f4c(0xe4)](),_0x580266=await this[_0x814f4c(0xf4)][_0x814f4c(0xbd)]();if(!_0x3e87c7){const _0x22c5f1=readCachedLLMProject();if(_0x22c5f1){const _0x1d1718=_0x580266[_0x814f4c(0xa5)](_0x21c893=>_0x21c893[_0x814f4c(0xb6)][_0x814f4c(0xfb)]===_0x22c5f1);if(_0x1d1718)return _0x1d1718;}}const _0x5b843a=_0x580266[_0x814f4c(0xa5)](_0x4f5dee=>_0x4f5dee[_0x814f4c(0xb6)][_0x814f4c(0xfb)]===_0x34113d);if(_0x5b843a)return!_0x3e87c7&&writeCachedLLMProject(_0x34113d),_0x5b843a;const _0x510a8e=await this[_0x814f4c(0xf4)][_0x814f4c(0x7c)]({'name':_0x34113d,'description':_0x814f4c(0xf8)+getSanitizedUsername()+')'});return!_0x3e87c7&&writeCachedLLMProject(_0x34113d),_0x510a8e;}async[a53_0x5f0156(0x89)](_0x460d3d){const _0x38a667=a53_0x5f0156,_0x26eec5=await this[_0x38a667(0xf4)][_0x38a667(0xbd)](),_0x493c69=_0x26eec5[_0x38a667(0x96)](_0x48bb24=>_0x48bb24[_0x38a667(0xb6)][_0x38a667(0xfb)]===_0x460d3d);if(_0x493c69['length']===0x0)throw new SDKError(ErrorCode[_0x38a667(0xa9)],_0x38a667(0x76)+_0x460d3d,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});if(_0x493c69['length']>0x1)throw new SDKError(ErrorCode[_0x38a667(0xbc)],_0x38a667(0xd4)+_0x460d3d+_0x38a667(0xd8));return _0x493c69[0x0]['id'];}async['getOrCreateDefaultAgent'](_0x4f8c2f=a53_0x5f0156(0xfd),_0x5d3148=0x0,_0x418242){const _0x1c8deb=a53_0x5f0156,_0x70fedf=0xa;let _0x516025=0x0,_0x37f414;while(_0x516025<_0x70fedf){try{const _0x189107=await this['getOrCreateDefaultProject'](_0x37f414),_0x16af10=_0x189107['id'],_0x5c69f6=[_0x1c8deb(0x79),_0x1c8deb(0xdc),_0x1c8deb(0x7e),_0x1c8deb(0xb1),_0x1c8deb(0xd7)],_0x45c9ef=_0x5d3148===0x0?_0x1c8deb(0xa2)+_0x4f8c2f:_0x1c8deb(0xa2)+_0x4f8c2f+_0x1c8deb(0x9b)+_0x5c69f6[_0x5d3148],_0x2e9e98=await this[_0x1c8deb(0xf4)][_0x1c8deb(0xb8)](_0x16af10),_0x4c46c7=_0x2e9e98[_0x1c8deb(0xa5)](_0x568010=>_0x568010[_0x1c8deb(0xb6)][_0x1c8deb(0xfb)]===_0x45c9ef);if(_0x4c46c7)return _0x4c46c7;const _0x4e4ca9=_0x5d3148>0x0?0x1:_0x418242;return await this[_0x1c8deb(0xf4)][_0x1c8deb(0x7b)]({'name':_0x45c9ef,'projectId':_0x16af10,'modelType':_0x4f8c2f,'systemPrompt':'','temperature':_0x4e4ca9,'reasoningEffort':_0x5d3148>0x0?_0x5d3148:undefined});}catch(_0x2697fe){if(_0x2697fe instanceof HTTPClientError){const _0x4b708a=_0x2697fe[_0x1c8deb(0x7a)];if(_0x4b708a>=0x190&&_0x4b708a<0x1f4){if(_0x4b708a===0x191)throw new SDKError(ErrorCode[_0x1c8deb(0x8b)],_0x1c8deb(0xf2),_0x2697fe);else{if(_0x4b708a===0x193)throw new SDKError(ErrorCode['PERMISSION_DENIED'],_0x1c8deb(0xe7),_0x2697fe);}throw _0x2697fe;}}if(errorContains(_0x2697fe,'already\x20exists','duplicate',_0x1c8deb(0x8f))){_0x516025++;if(_0x516025>=_0x70fedf)throw new SDKError(ErrorCode[_0x1c8deb(0x106)],_0x1c8deb(0xc7)+_0x70fedf+_0x1c8deb(0x70),_0x2697fe);const _0x101677=this[_0x1c8deb(0xe4)]();_0x37f414=_0x101677+'_'+generateRandomHex();continue;}throw _0x2697fe;}}throw new SDKError(ErrorCode[_0x1c8deb(0xbc)],_0x1c8deb(0xde));}async['resolveAgentId'](_0x4792ce,_0x20f792){const _0x4ef12f=a53_0x5f0156,_0x3e3ab3=_0x20f792||this[_0x4ef12f(0x91)],_0x74a805=await this['client']['listAgents'](_0x3e3ab3),_0x16c01f=_0x74a805[_0x4ef12f(0x96)](_0x134ad0=>_0x134ad0[_0x4ef12f(0xb6)]['name']===_0x4792ce);if(_0x16c01f[_0x4ef12f(0xf5)]===0x0){const _0x376567=_0x3e3ab3?_0x4ef12f(0xe8)+_0x3e3ab3:'';throw new SDKError(ErrorCode[_0x4ef12f(0xbb)],_0x4ef12f(0x9a)+_0x4792ce+_0x376567,undefined,{'helpText':_0x3e3ab3?'Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.':_0x4ef12f(0x71)});}if(_0x16c01f[_0x4ef12f(0xf5)]>0x1)throw new SDKError(ErrorCode[_0x4ef12f(0xbc)],_0x4ef12f(0x6f)+_0x4792ce+_0x4ef12f(0xd8));return _0x16c01f[0x0]['id'];}async[a53_0x5f0156(0x87)](_0x1355b6){const _0x44f3a8=a53_0x5f0156,_0x5460b7=_0x1355b6||this[_0x44f3a8(0x91)];return await this[_0x44f3a8(0xf4)]['listAgents'](_0x5460b7);}async[a53_0x5f0156(0xae)](_0x394285){const _0x21b8ce=a53_0x5f0156;return await this[_0x21b8ce(0xf4)][_0x21b8ce(0xb4)](_0x394285);}async[a53_0x5f0156(0x7b)](_0x4d8618){const _0xe16fc3=a53_0x5f0156;return await this['client'][_0xe16fc3(0x7b)](_0x4d8618);}async[a53_0x5f0156(0xec)](_0x4ae363,_0x16354c){const _0xab3408=a53_0x5f0156;return await this[_0xab3408(0xf4)][_0xab3408(0xec)](_0x4ae363,_0x16354c);}async['deleteAgent'](_0x43a54c){const _0x288fc7=a53_0x5f0156;await this[_0x288fc7(0xf4)][_0x288fc7(0xe5)](_0x43a54c);}async[a53_0x5f0156(0xc0)](_0x54fc5c){const _0x5be166=a53_0x5f0156;return await this[_0x5be166(0xf4)][_0x5be166(0xc0)]({'agentId':_0x54fc5c});}async*[a53_0x5f0156(0xe9)](_0x12a9b2,_0x2d4d67){const _0x51157e=a53_0x5f0156;let _0x13222c=_0x2d4d67?.[_0x51157e(0xbe)];const _0x20a584=_0x2d4d67?.[_0x51157e(0x99)];if(!_0x13222c){if(!_0x20a584)throw new Error(_0x51157e(0xb2));const _0x41be41=await this[_0x51157e(0xf4)][_0x51157e(0xc0)]({'agentId':_0x20a584});_0x13222c=_0x41be41['id'],yield{'type':_0x51157e(0xd6),'data':{'chatId':_0x13222c,'agentId':_0x20a584}};}for await(const _0x8e302b of this['client'][_0x51157e(0xdb)](_0x13222c,_0x12a9b2,_0x2d4d67?.[_0x51157e(0xb3)])){yield{'type':_0x51157e(0xb0),'data':_0x8e302b};}}async[a53_0x5f0156(0xf1)](_0x13d6f0=0x32){const _0x4ba85c=a53_0x5f0156;return await this[_0x4ba85c(0xf4)][_0x4ba85c(0xf7)](_0x13d6f0);}async['history'](_0x1fa0fd){const _0x2b979f=a53_0x5f0156;return await this[_0x2b979f(0xf4)]['getChatHistory'](_0x1fa0fd);}async['chatInfo'](_0x34497b){const _0x47abb4=a53_0x5f0156;return await this[_0x47abb4(0xf4)][_0x47abb4(0xab)](_0x34497b);}async[a53_0x5f0156(0xcd)](_0x3c0b3e,_0x4209fd,_0x57d744){const _0xd12b21=a53_0x5f0156,_0x30fecd=_0x57d744?.['dryRun']??![];let _0x2372d6,_0x4e3890;this['isProjectId'](_0x3c0b3e)?(_0x2372d6=_0x3c0b3e,_0x4e3890=await this[_0xd12b21(0xf4)][_0xd12b21(0x95)](_0x2372d6)):(_0x2372d6=await this[_0xd12b21(0x89)](_0x3c0b3e),_0x4e3890=await this[_0xd12b21(0xf4)][_0xd12b21(0x95)](_0x2372d6));const _0x3a59fd=_0x4e3890[_0xd12b21(0xb6)]['name'],_0x3504bf=_0x4209fd||_0x3a59fd+'.llm';if(a53_0x142488[_0xd12b21(0xe1)](_0x3504bf)&&!_0x30fecd)throw new SDKError(ErrorCode['ALREADY_EXISTS'],_0xd12b21(0xff)+_0x3504bf,undefined,{'helpText':_0xd12b21(0x9d)});const _0x4e4c2c=await this['client'][_0xd12b21(0xf6)](_0x2372d6),_0x324c5d=await this[_0xd12b21(0xf4)][_0xd12b21(0xe6)](_0x2372d6),_0x412bce=await this[_0xd12b21(0xf4)][_0xd12b21(0x93)](_0x2372d6),_0x273a6d=await this[_0xd12b21(0xf4)][_0xd12b21(0xa0)](_0x2372d6);if(!_0x30fecd){a53_0x142488[_0xd12b21(0xf3)](_0x3504bf,{'recursive':!![]});const _0x3e1a28={'version':_0xd12b21(0x9c),'exportedAt':new Date()[_0xd12b21(0x6e)](),'exportedFrom':{'site':this[_0xd12b21(0xf0)][_0xd12b21(0x7d)],'projectId':_0x2372d6,'projectName':_0x3a59fd},'project':_0x4e3890};a53_0x142488[_0xd12b21(0x90)](a53_0x3cd23c[_0xd12b21(0xc5)](_0x3504bf,_0xd12b21(0x92)),JSON[_0xd12b21(0xcb)](_0x3e1a28,null,0x2)),a53_0x142488['writeFileSync'](a53_0x3cd23c['join'](_0x3504bf,_0xd12b21(0x8e)),JSON['stringify'](_0x4e4c2c,null,0x2)),a53_0x142488[_0xd12b21(0x90)](a53_0x3cd23c['join'](_0x3504bf,_0xd12b21(0x72)),JSON[_0xd12b21(0xcb)](_0x324c5d,null,0x2)),a53_0x142488[_0xd12b21(0x90)](a53_0x3cd23c['join'](_0x3504bf,_0xd12b21(0xd0)),JSON[_0xd12b21(0xcb)](_0x412bce,null,0x2)),a53_0x142488[_0xd12b21(0x90)](a53_0x3cd23c[_0xd12b21(0xc5)](_0x3504bf,_0xd12b21(0xbf)),JSON[_0xd12b21(0xcb)](_0x273a6d,null,0x2));}return{'projectName':_0x3a59fd,'outputDir':_0x3504bf,'counts':{'agents':_0x4e4c2c[_0xd12b21(0xf5)],'knowledgeBases':_0x324c5d[_0xd12b21(0xf5)],'prompts':_0x412bce[_0xd12b21(0xf5)],'integrations':_0x273a6d['length']}};}async[a53_0x5f0156(0xd2)](_0x4cbe18,_0x4d6773){const _0x2bbe8e=a53_0x5f0156,_0x7b7abe=_0x4d6773?.[_0x2bbe8e(0xa8)]??![],_0x1d4aa2=this[_0x2bbe8e(0xac)](_0x4cbe18),_0x217645=_0x1d4aa2[_0x2bbe8e(0xee)][_0x2bbe8e(0x7d)],_0x532bbe=this['context'][_0x2bbe8e(0x7d)],_0x2ec07e=_0x217645!==_0x532bbe?_0x217645:undefined,_0x4183e8=this[_0x2bbe8e(0x78)](a53_0x3cd23c[_0x2bbe8e(0xc5)](_0x4cbe18,_0x2bbe8e(0x8e)),[]),_0x197c96=this[_0x2bbe8e(0x78)](a53_0x3cd23c[_0x2bbe8e(0xc5)](_0x4cbe18,_0x2bbe8e(0x72)),[]),_0x57d8ce=this[_0x2bbe8e(0x78)](a53_0x3cd23c[_0x2bbe8e(0xc5)](_0x4cbe18,'prompts.json'),[]),_0x12930a=this[_0x2bbe8e(0x78)](a53_0x3cd23c[_0x2bbe8e(0xc5)](_0x4cbe18,_0x2bbe8e(0xbf)),[]),_0x45fb62=_0x4d6773?.['name']||_0x1d4aa2[_0x2bbe8e(0xee)][_0x2bbe8e(0xd3)];if(_0x7b7abe){const _0x14d6c9=new Map(),_0x4b2195=[..._0x4183e8],_0x373733=_0x4183e8[_0x2bbe8e(0xf5)]+0x1;let _0xed42d8=0x0;while(_0x4b2195[_0x2bbe8e(0xf5)]>0x0&&_0xed42d8<_0x373733){_0xed42d8++;const _0x595d8c=[];for(const _0x2d76df of _0x4b2195){canCreateAgent(_0x2d76df,_0x14d6c9)?_0x14d6c9['set'](_0x2d76df['id'],'dry-run-'+_0x2d76df['id']):_0x595d8c['push'](_0x2d76df);}if(_0x595d8c[_0x2bbe8e(0xf5)]===_0x4b2195[_0x2bbe8e(0xf5)])throw new SDKError(ErrorCode[_0x2bbe8e(0xbc)],_0x2bbe8e(0xa6),undefined,{'helpText':_0x2bbe8e(0x8c)});_0x4b2195[_0x2bbe8e(0xf5)]=0x0,_0x4b2195['push'](..._0x595d8c);}const _0x1b0830=_0x57d8ce[_0x2bbe8e(0x96)](_0x21fa6a=>_0x14d6c9[_0x2bbe8e(0xb7)](_0x21fa6a[_0x2bbe8e(0xb6)][_0x2bbe8e(0x99)]))[_0x2bbe8e(0xf5)];return{'projectName':_0x45fb62,'projectId':'(dry-run)','counts':{'agents':_0x4183e8[_0x2bbe8e(0xf5)],'knowledgeBases':_0x197c96['length'],'prompts':_0x1b0830,'integrations':_0x12930a[_0x2bbe8e(0xf5)]},'sourceSite':_0x2ec07e};}const _0x4c3d3e=await this[_0x2bbe8e(0xf4)][_0x2bbe8e(0x7c)]({'name':_0x45fb62,'description':_0x1d4aa2['project'][_0x2bbe8e(0xb6)][_0x2bbe8e(0xcc)]}),_0x19d463=_0x4c3d3e['id'],_0x4da477=new Map(),_0x4346d0=new Map(),_0x4e6d08=new Map();for(const _0x18e61f of _0x197c96){const _0xdf10d=await this['client'][_0x2bbe8e(0xdf)]({'projectId':_0x19d463,'name':_0x18e61f[_0x2bbe8e(0xb6)][_0x2bbe8e(0xfb)],'tdDatabaseName':_0x18e61f['attributes'][_0x2bbe8e(0x102)],'tables':_0x18e61f[_0x2bbe8e(0xb6)][_0x2bbe8e(0xe0)]});_0x4da477[_0x2bbe8e(0x97)](_0x18e61f['id'],_0xdf10d['id']);}const _0xb44b1b=[..._0x4183e8],_0x33a575=_0x4183e8[_0x2bbe8e(0xf5)]+0x1;let _0x2795cb=0x0;while(_0xb44b1b['length']>0x0&&_0x2795cb<_0x33a575){_0x2795cb++;const _0x32ccc0=[];for(const _0x4043f5 of _0xb44b1b){if(canCreateAgent(_0x4043f5,_0x4346d0)){const _0xdbc762=remapToolIds(_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0x83)],_0x4da477,_0x4346d0),_0x100f38=remapVariableIds(_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0xb9)],_0x4da477),_0xd11391=await this[_0x2bbe8e(0xf4)][_0x2bbe8e(0xc3)]({'name':_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0xfb)],'projectId':_0x19d463,'systemPrompt':_0x4043f5[_0x2bbe8e(0xb6)]['systemPrompt'],'starterMessage':_0x4043f5['attributes']['starterMessage'],'modelType':_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0xc1)],'maxToolIterations':_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0xd1)],'temperature':_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0x77)],'reasoningEffort':_0x4043f5[_0x2bbe8e(0xb6)]['reasoningEffort'],'outputs':_0x4043f5[_0x2bbe8e(0xb6)][_0x2bbe8e(0xeb)],'tools':_0xdbc762,'variables':_0x100f38});_0x4346d0['set'](_0x4043f5['id'],_0xd11391['id']);}else _0x32ccc0[_0x2bbe8e(0xaf)](_0x4043f5);}if(_0x32ccc0[_0x2bbe8e(0xf5)]===_0xb44b1b[_0x2bbe8e(0xf5)])throw new SDKError(ErrorCode['INTERNAL'],'Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.',undefined,{'helpText':_0x2bbe8e(0x8c)});_0xb44b1b[_0x2bbe8e(0xf5)]=0x0,_0xb44b1b['push'](..._0x32ccc0);}for(const _0x462ca9 of _0x57d8ce){const _0x217514=_0x4346d0['get'](_0x462ca9[_0x2bbe8e(0xb6)][_0x2bbe8e(0x99)]);if(!_0x217514)continue;const _0xd68b30=await this[_0x2bbe8e(0xf4)][_0x2bbe8e(0xfe)]({'projectId':_0x19d463,'agentId':_0x217514,'name':_0x462ca9[_0x2bbe8e(0xb6)][_0x2bbe8e(0xfb)],'systemPrompt':_0x462ca9['attributes'][_0x2bbe8e(0x6d)],'template':_0x462ca9[_0x2bbe8e(0xb6)][_0x2bbe8e(0x73)],'jsonSchemaHint':_0x462ca9[_0x2bbe8e(0xb6)]['jsonSchemaHint']});_0x4e6d08[_0x2bbe8e(0x97)](_0x462ca9['id'],_0xd68b30['id']);}for(const _0x4cddaa of _0x12930a){const _0x5b71b7=_0x4cddaa[_0x2bbe8e(0xb6)][_0x2bbe8e(0x8d)][_0x2bbe8e(0x7f)](_0x4c6b9a=>({..._0x4c6b9a,'promptId':_0x4e6d08[_0x2bbe8e(0x105)](_0x4c6b9a[_0x2bbe8e(0xed)])||_0x4c6b9a[_0x2bbe8e(0xed)]}));await this['client'][_0x2bbe8e(0x75)]({'projectId':_0x19d463,'serviceType':_0x4cddaa['attributes'][_0x2bbe8e(0x98)],'actions':_0x5b71b7,'slackMessageMode':_0x4cddaa['attributes'][_0x2bbe8e(0xb5)],'chatIgnoreManagedActions':_0x4cddaa['attributes'][_0x2bbe8e(0xc9)],'chatWelcomeMessage':_0x4cddaa[_0x2bbe8e(0xb6)][_0x2bbe8e(0xd5)],'webhookCorsOrigins':_0x4cddaa[_0x2bbe8e(0xb6)][_0x2bbe8e(0xe2)]});}return{'projectName':_0x45fb62,'projectId':_0x19d463,'counts':{'agents':_0x4346d0['size'],'knowledgeBases':_0x4da477['size'],'prompts':_0x4e6d08[_0x2bbe8e(0x8a)],'integrations':_0x12930a[_0x2bbe8e(0xf5)]},'sourceSite':_0x2ec07e};}[a53_0x5f0156(0x78)](_0x3d9a57,_0x9398fe){const _0x5596f8=a53_0x5f0156;if(!a53_0x142488[_0x5596f8(0xe1)](_0x3d9a57))return _0x9398fe;return JSON[_0x5596f8(0x94)](a53_0x142488[_0x5596f8(0x85)](_0x3d9a57,_0x5596f8(0x9e)));}[a53_0x5f0156(0xac)](_0x499528){const _0x28c053=a53_0x5f0156;if(!a53_0x142488[_0x28c053(0xe1)](_0x499528))throw new SDKError(ErrorCode[_0x28c053(0xca)],'Backup\x20folder\x20not\x20found:\x20'+_0x499528,undefined,{'helpText':_0x28c053(0xcf)});const _0x330a94=a53_0x3cd23c[_0x28c053(0xc5)](_0x499528,_0x28c053(0x92));if(!a53_0x142488[_0x28c053(0xe1)](_0x330a94))throw new SDKError(ErrorCode[_0x28c053(0x100)],_0x28c053(0xe3)+_0x499528,undefined,{'helpText':_0x28c053(0x84)});const _0x447876=JSON[_0x28c053(0x94)](a53_0x142488['readFileSync'](_0x330a94,_0x28c053(0x9e)));if(!isSupportedBackupVersion(_0x447876[_0x28c053(0x103)]))throw new SDKError(ErrorCode[_0x28c053(0x100)],_0x28c053(0x81)+_0x447876[_0x28c053(0x103)],undefined,{'helpText':_0x28c053(0xd9)});return _0x447876;}}
|
|
1
|
+
const a53_0x205647=a53_0x3bf4;function a53_0x3bf4(_0x170864,_0x2e582e){const _0x166d7c=a53_0x166d();return a53_0x3bf4=function(_0x3bf405,_0xed0a39){_0x3bf405=_0x3bf405-0x1ec;let _0x5b988f=_0x166d7c[_0x3bf405];return _0x5b988f;},a53_0x3bf4(_0x170864,_0x2e582e);}(function(_0x3fc8e1,_0x575408){const _0x1ed6ee=a53_0x3bf4,_0x2602bc=_0x3fc8e1();while(!![]){try{const _0x4de868=-parseInt(_0x1ed6ee(0x249))/0x1*(parseInt(_0x1ed6ee(0x25b))/0x2)+-parseInt(_0x1ed6ee(0x268))/0x3+-parseInt(_0x1ed6ee(0x207))/0x4*(parseInt(_0x1ed6ee(0x235))/0x5)+parseInt(_0x1ed6ee(0x25f))/0x6*(parseInt(_0x1ed6ee(0x224))/0x7)+parseInt(_0x1ed6ee(0x1fe))/0x8+parseInt(_0x1ed6ee(0x259))/0x9*(parseInt(_0x1ed6ee(0x21b))/0xa)+parseInt(_0x1ed6ee(0x23c))/0xb*(parseInt(_0x1ed6ee(0x238))/0xc);if(_0x4de868===_0x575408)break;else _0x2602bc['push'](_0x2602bc['shift']());}catch(_0xb4d4cf){_0x2602bc['push'](_0x2602bc['shift']());}}}(a53_0x166d,0x6cb26));import{LLMApiClient}from'../client/llm-api-client.js';import*as a53_0x4475f5 from'node:fs';import*as a53_0xcda03f from'node:path';import{HTTPClientError}from'../client/http-client.js';import{canCreateAgent,remapToolIds,remapVariableIds,isSupportedBackupVersion}from'../utils/llm-backup-utils.js';import{SDKError,ErrorCode,errorContains}from'./errors.js';function a53_0x166d(){const _0x260518=['project.json','dry-run-','createKnowledgeBase','test','availableModels','toISOString','join','conflict','webhookCorsOrigins','1.0','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','deleteAgent','chats','Multiple\x20agents\x20found\x20with\x20name\x20\x27','length','promptId','version','getAgent','Ensure\x20this\x20is\x20a\x20valid\x20LLM\x20project\x20backup\x20folder.','description','attributes','projectName','filter','createProject','Invalid\x20backup:\x20project.json\x20not\x20found\x20in\x20','site','serviceType','projects','updateAgent','size','listKnowledgeBases','96520RnEhyq','getUserSettings','deleteProject','integrations.json','readFileSync','high','starterMessage','isProjectId','restoreProject','2520780RLEGTL','Project\x20not\x20found:\x20','createAgent','prompts.json','exportedFrom','tools','agent','jsonSchemaHint','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','tdx_default_','get','slackMessageMode','getOrCreateDefaultAgent','ALREADY_EXISTS','resolveProjectId','Multiple\x20projects\x20found\x20with\x20name\x20\x27','tables','models','Ensure\x20the\x20backup\x20folder\x20path\x20is\x20correct.','30icylWZ','reasoningEffort','getChatInfo','project','INVALID_ARGUMENT','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','The\x20backup\x20contains\x20agents\x20with\x20circular\x20dependencies.','chatInfo','has','91cmdyly','getDefaultProjectName','outputs','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','map','find','maxToolIterations','setCurrentProject','actions','chatWelcomeMessage','Backup\x20folder\x20not\x20found:\x20','already\x20exists','Unable\x20to\x20create\x20project\x20after\x20','loadJsonFile','client','status','stringify','5WOPhJw','getOrCreateDefaultProject','startChat','24sCZLMv','tdx_','agentId','.llm','5347133OGhajv','agents.json','Use\x20a\x20different\x20output\x20path\x20or\x20remove\x20the\x20existing\x20directory.','parse','listChats','systemPrompt','chatIgnoreManagedActions','Output\x20directory\x20already\x20exists:\x20','(dry-run)','name','writeFileSync','chatId','logger','2hcBlLN','\x27.\x20This\x20should\x20not\x20happen.','Project\x20not\x20found\x20with\x20ID:\x20','INTERNAL','dryRun','Circular\x20dependency\x20detected\x20in\x20agents.\x20Cannot\x20restore.','knowledgebases.json','temperature','This\x20backup\x20was\x20created\x20with\x20a\x20newer\x20version\x20of\x20tdx.','listProjects','LLM_PROJECT_NOT_FOUND','metadata','createPrompt','low','context','template','140985sDQLbn','set','402074DmrswJ','existsSync','createIntegration','getProject','390546lBgVNb','\x20attempts\x20due\x20to\x20name\x20conflicts.','getBackupMetadata','currentProjectId','Agent\x20not\x20found:\x20','utf-8','AGENT_NOT_FOUND','none','listIntegrations','1199874VrqQOZ','continueChat','push','listAgents'];a53_0x166d=function(){return _0x260518;};return a53_0x166d();}import{getSanitizedUsername,generateRandomHex}from'../utils/string-utils.js';import{readCachedLLMProject,writeCachedLLMProject}from'../core/config.js';export class LLMSDK{['currentProjectId'];[a53_0x205647(0x232)];[a53_0x205647(0x257)];constructor(_0x207015){const _0x5f261a=a53_0x205647;this[_0x5f261a(0x232)]=new LLMApiClient(_0x207015,_0x207015[_0x5f261a(0x248)]),this['context']=_0x207015;}[a53_0x205647(0x225)](){const _0x4f085a=a53_0x205647,_0x4fb1f9=getSanitizedUsername();return _0x4f085a(0x211)+_0x4fb1f9;}[a53_0x205647(0x205)](_0x4921c9){const _0x5376c3=a53_0x205647;return/^[a-zA-Z0-9]{8,}$/[_0x5376c3(0x26f)](_0x4921c9);}async[a53_0x205647(0x22b)](_0x4f158e){const _0x52fa27=a53_0x205647;if(this[_0x52fa27(0x205)](_0x4f158e)){const _0x5211d8=await this[_0x52fa27(0x232)][_0x52fa27(0x252)](),_0x224fbb=_0x5211d8['find'](_0x30423a=>_0x30423a['id']===_0x4f158e);if(!_0x224fbb)throw new SDKError(ErrorCode[_0x52fa27(0x253)],'Project\x20not\x20found\x20with\x20ID:\x20'+_0x4f158e,undefined,{'helpText':_0x52fa27(0x220)});this[_0x52fa27(0x262)]=_0x4f158e;}else this[_0x52fa27(0x262)]=await this[_0x52fa27(0x216)](_0x4f158e);}['getCurrentProject'](){const _0x1d73ab=a53_0x205647;return this[_0x1d73ab(0x262)];}async[a53_0x205647(0x219)](){const _0x32bb1a=a53_0x205647,_0xa750b1=await this[_0x32bb1a(0x232)][_0x32bb1a(0x1ff)](),_0x4ffc7f=[];for(const _0x13a586 of _0xa750b1['availableModelNames']){const _0x34f231=_0xa750b1[_0x32bb1a(0x270)][_0x13a586];_0x34f231&&_0x4ffc7f[_0x32bb1a(0x26a)]({'name':_0x13a586,'displayName':_0x34f231['displayName']});}return _0x4ffc7f;}async[a53_0x205647(0x1f6)](_0x4cfe9d){const _0x4b02f6=a53_0x205647;return await this[_0x4b02f6(0x232)][_0x4b02f6(0x1f6)](_0x4cfe9d);}async[a53_0x205647(0x200)](_0x582960){const _0x4e9064=a53_0x205647;let _0x17ae03;if(this[_0x4e9064(0x205)](_0x582960)){const _0x3ed29c=await this[_0x4e9064(0x232)]['listProjects'](),_0x1b61cb=_0x3ed29c['find'](_0x974ddc=>_0x974ddc['id']===_0x582960);if(!_0x1b61cb)throw new SDKError(ErrorCode['LLM_PROJECT_NOT_FOUND'],_0x4e9064(0x24b)+_0x582960,undefined,{'helpText':_0x4e9064(0x220)});_0x17ae03=_0x582960;}else _0x17ae03=await this[_0x4e9064(0x216)](_0x582960);await this[_0x4e9064(0x232)][_0x4e9064(0x200)](_0x17ae03);}async[a53_0x205647(0x1fa)](_0x5564d4=0x32){const _0x1f5644=a53_0x205647;return await this[_0x1f5644(0x232)][_0x1f5644(0x252)](_0x5564d4);}async[a53_0x205647(0x236)](_0x2e996b){const _0x42f2d5=a53_0x205647,_0x7e4571=_0x2e996b||this[_0x42f2d5(0x225)](),_0x57f62a=await this[_0x42f2d5(0x232)]['listProjects']();if(!_0x2e996b){const _0x1e5707=readCachedLLMProject();if(_0x1e5707){const _0x5555f1=_0x57f62a[_0x42f2d5(0x229)](_0x393394=>_0x393394['attributes'][_0x42f2d5(0x245)]===_0x1e5707);if(_0x5555f1)return _0x5555f1;}}const _0x24ca58=_0x57f62a[_0x42f2d5(0x229)](_0x3fe678=>_0x3fe678[_0x42f2d5(0x1f3)][_0x42f2d5(0x245)]===_0x7e4571);if(_0x24ca58)return!_0x2e996b&&writeCachedLLMProject(_0x7e4571),_0x24ca58;const _0x43be7d=await this['client'][_0x42f2d5(0x1f6)]({'name':_0x7e4571,'description':_0x42f2d5(0x210)+getSanitizedUsername()+')'});return!_0x2e996b&&writeCachedLLMProject(_0x7e4571),_0x43be7d;}async[a53_0x205647(0x216)](_0x476e2f){const _0x48c804=a53_0x205647,_0x175903=await this[_0x48c804(0x232)][_0x48c804(0x252)](),_0x13728c=_0x175903[_0x48c804(0x1f5)](_0x2c20e4=>_0x2c20e4['attributes']['name']===_0x476e2f);if(_0x13728c[_0x48c804(0x1ed)]===0x0)throw new SDKError(ErrorCode['LLM_PROJECT_NOT_FOUND'],_0x48c804(0x208)+_0x476e2f,undefined,{'helpText':_0x48c804(0x220)});if(_0x13728c[_0x48c804(0x1ed)]>0x1)throw new SDKError(ErrorCode[_0x48c804(0x24c)],_0x48c804(0x217)+_0x476e2f+_0x48c804(0x24a));return _0x13728c[0x0]['id'];}async[a53_0x205647(0x214)](_0x129790='claude-4.5-sonnet',_0x206260=0x0,_0x595f83){const _0x113767=a53_0x205647,_0x4af748=0xa;let _0x10c512=0x0,_0x2c99a2;while(_0x10c512<_0x4af748){try{const _0x4b70b2=await this[_0x113767(0x236)](_0x2c99a2),_0x45e75c=_0x4b70b2['id'],_0x2a0dff=[_0x113767(0x266),'minimal',_0x113767(0x256),'medium',_0x113767(0x203)],_0x55b85c=_0x206260===0x0?_0x113767(0x239)+_0x129790:_0x113767(0x239)+_0x129790+'_reasoning_'+_0x2a0dff[_0x206260],_0x307a0a=await this[_0x113767(0x232)][_0x113767(0x26b)](_0x45e75c),_0x4fba3b=_0x307a0a[_0x113767(0x229)](_0x231218=>_0x231218[_0x113767(0x1f3)][_0x113767(0x245)]===_0x55b85c);if(_0x4fba3b)return _0x4fba3b;const _0x23e6e9=_0x206260>0x0?0x1:_0x595f83;return await this[_0x113767(0x232)][_0x113767(0x209)]({'name':_0x55b85c,'projectId':_0x45e75c,'modelType':_0x129790,'systemPrompt':'','temperature':_0x23e6e9,'reasoningEffort':_0x206260>0x0?_0x206260:undefined});}catch(_0x29dfa1){if(_0x29dfa1 instanceof HTTPClientError){const _0x20d7f3=_0x29dfa1[_0x113767(0x233)];if(_0x20d7f3>=0x190&&_0x20d7f3<0x1f4){if(_0x20d7f3===0x191)throw new SDKError(ErrorCode['UNAUTHENTICATED'],_0x113767(0x276),_0x29dfa1);else{if(_0x20d7f3===0x193)throw new SDKError(ErrorCode['PERMISSION_DENIED'],'Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.',_0x29dfa1);}throw _0x29dfa1;}}if(errorContains(_0x29dfa1,_0x113767(0x22f),'duplicate',_0x113767(0x273))){_0x10c512++;if(_0x10c512>=_0x4af748)throw new SDKError(ErrorCode[_0x113767(0x215)],_0x113767(0x230)+_0x4af748+_0x113767(0x260),_0x29dfa1);const _0x144b28=this[_0x113767(0x225)]();_0x2c99a2=_0x144b28+'_'+generateRandomHex();continue;}throw _0x29dfa1;}}throw new SDKError(ErrorCode[_0x113767(0x24c)],_0x113767(0x20f));}async['resolveAgentId'](_0x3162a6,_0x429742){const _0x52682f=a53_0x205647,_0x397532=_0x429742||this[_0x52682f(0x262)],_0x5035d9=await this[_0x52682f(0x232)][_0x52682f(0x26b)](_0x397532),_0x3bbd1c=_0x5035d9['filter'](_0x59dbbd=>_0x59dbbd[_0x52682f(0x1f3)][_0x52682f(0x245)]===_0x3162a6);if(_0x3bbd1c['length']===0x0){const _0x3813cb=_0x397532?'\x20in\x20project\x20'+_0x397532:'';throw new SDKError(ErrorCode[_0x52682f(0x265)],_0x52682f(0x263)+_0x3162a6+_0x3813cb,undefined,{'helpText':_0x397532?_0x52682f(0x227):'Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.'});}if(_0x3bbd1c[_0x52682f(0x1ed)]>0x1)throw new SDKError(ErrorCode['INTERNAL'],_0x52682f(0x1ec)+_0x3162a6+_0x52682f(0x24a));return _0x3bbd1c[0x0]['id'];}async['agents'](_0x21f46f){const _0x20befd=a53_0x205647,_0x390af2=_0x21f46f||this[_0x20befd(0x262)];return await this[_0x20befd(0x232)][_0x20befd(0x26b)](_0x390af2);}async[a53_0x205647(0x20d)](_0x880db1){const _0x2a595d=a53_0x205647;return await this[_0x2a595d(0x232)][_0x2a595d(0x1f0)](_0x880db1);}async['createAgent'](_0x1e24dc){const _0xea9e98=a53_0x205647;return await this[_0xea9e98(0x232)][_0xea9e98(0x209)](_0x1e24dc);}async[a53_0x205647(0x1fb)](_0xc777d5,_0x1edd21){const _0x59979c=a53_0x205647;return await this[_0x59979c(0x232)][_0x59979c(0x1fb)](_0xc777d5,_0x1edd21);}async[a53_0x205647(0x277)](_0x3b883e){const _0x2c02f3=a53_0x205647;await this['client'][_0x2c02f3(0x277)](_0x3b883e);}async[a53_0x205647(0x237)](_0x3d20d0){const _0x42d4ff=a53_0x205647;return await this[_0x42d4ff(0x232)]['startChat']({'agentId':_0x3d20d0});}async*['chat'](_0x6db436,_0x501784){const _0x469d26=a53_0x205647;let _0x5b20a3=_0x501784?.[_0x469d26(0x247)];const _0x30bee4=_0x501784?.[_0x469d26(0x23a)];if(!_0x5b20a3){if(!_0x30bee4)throw new Error('agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat');const _0x543695=await this['client']['startChat']({'agentId':_0x30bee4});_0x5b20a3=_0x543695['id'],yield{'type':_0x469d26(0x254),'data':{'chatId':_0x5b20a3,'agentId':_0x30bee4}};}for await(const _0x10ed31 of this[_0x469d26(0x232)][_0x469d26(0x269)](_0x5b20a3,_0x6db436,_0x501784?.['signal'])){yield{'type':'event','data':_0x10ed31};}}async[a53_0x205647(0x278)](_0x856237=0x32){const _0x443fc5=a53_0x205647;return await this['client'][_0x443fc5(0x240)](_0x856237);}async['history'](_0x3c5062){return await this['client']['getChatHistory'](_0x3c5062);}async[a53_0x205647(0x222)](_0x310c71){const _0x11b93e=a53_0x205647;return await this[_0x11b93e(0x232)][_0x11b93e(0x21d)](_0x310c71);}async['backupProject'](_0x325cc7,_0x5c4ae8,_0x3f6c82){const _0x1b03b1=a53_0x205647,_0x24f8a2=_0x3f6c82?.[_0x1b03b1(0x24d)]??![];let _0x19e092,_0x5b59c6;this[_0x1b03b1(0x205)](_0x325cc7)?(_0x19e092=_0x325cc7,_0x5b59c6=await this[_0x1b03b1(0x232)][_0x1b03b1(0x25e)](_0x19e092)):(_0x19e092=await this['resolveProjectId'](_0x325cc7),_0x5b59c6=await this[_0x1b03b1(0x232)][_0x1b03b1(0x25e)](_0x19e092));const _0x182eed=_0x5b59c6[_0x1b03b1(0x1f3)]['name'],_0x5276f8=_0x5c4ae8||_0x182eed+_0x1b03b1(0x23b);if(a53_0x4475f5[_0x1b03b1(0x25c)](_0x5276f8)&&!_0x24f8a2)throw new SDKError(ErrorCode[_0x1b03b1(0x215)],_0x1b03b1(0x243)+_0x5276f8,undefined,{'helpText':_0x1b03b1(0x23e)});const _0x422149=await this['client']['listAgentsFull'](_0x19e092),_0x84fd07=await this[_0x1b03b1(0x232)][_0x1b03b1(0x1fd)](_0x19e092),_0x12171b=await this['client']['listPrompts'](_0x19e092),_0x1aef44=await this['client'][_0x1b03b1(0x267)](_0x19e092);if(!_0x24f8a2){a53_0x4475f5['mkdirSync'](_0x5276f8,{'recursive':!![]});const _0x3f566c={'version':_0x1b03b1(0x275),'exportedAt':new Date()[_0x1b03b1(0x271)](),'exportedFrom':{'site':this[_0x1b03b1(0x257)]['site'],'projectId':_0x19e092,'projectName':_0x182eed},'project':_0x5b59c6};a53_0x4475f5[_0x1b03b1(0x246)](a53_0xcda03f[_0x1b03b1(0x272)](_0x5276f8,_0x1b03b1(0x26c)),JSON[_0x1b03b1(0x234)](_0x3f566c,null,0x2)),a53_0x4475f5[_0x1b03b1(0x246)](a53_0xcda03f[_0x1b03b1(0x272)](_0x5276f8,_0x1b03b1(0x23d)),JSON['stringify'](_0x422149,null,0x2)),a53_0x4475f5[_0x1b03b1(0x246)](a53_0xcda03f['join'](_0x5276f8,_0x1b03b1(0x24f)),JSON['stringify'](_0x84fd07,null,0x2)),a53_0x4475f5[_0x1b03b1(0x246)](a53_0xcda03f['join'](_0x5276f8,_0x1b03b1(0x20a)),JSON[_0x1b03b1(0x234)](_0x12171b,null,0x2)),a53_0x4475f5[_0x1b03b1(0x246)](a53_0xcda03f[_0x1b03b1(0x272)](_0x5276f8,_0x1b03b1(0x201)),JSON[_0x1b03b1(0x234)](_0x1aef44,null,0x2));}return{'projectName':_0x182eed,'outputDir':_0x5276f8,'counts':{'agents':_0x422149[_0x1b03b1(0x1ed)],'knowledgeBases':_0x84fd07['length'],'prompts':_0x12171b[_0x1b03b1(0x1ed)],'integrations':_0x1aef44[_0x1b03b1(0x1ed)]}};}async[a53_0x205647(0x206)](_0x5d6528,_0x3bb870){const _0x388512=a53_0x205647,_0xef49a9=_0x3bb870?.[_0x388512(0x24d)]??![],_0x418e2c=this[_0x388512(0x261)](_0x5d6528),_0x5f4cac=_0x418e2c[_0x388512(0x20b)][_0x388512(0x1f8)],_0x11e767=this[_0x388512(0x257)]['site'],_0x4a45dc=_0x5f4cac!==_0x11e767?_0x5f4cac:undefined,_0x1b6143=this[_0x388512(0x231)](a53_0xcda03f[_0x388512(0x272)](_0x5d6528,_0x388512(0x23d)),[]),_0x5175ba=this[_0x388512(0x231)](a53_0xcda03f[_0x388512(0x272)](_0x5d6528,_0x388512(0x24f)),[]),_0x302db6=this[_0x388512(0x231)](a53_0xcda03f['join'](_0x5d6528,_0x388512(0x20a)),[]),_0x1a5eb9=this['loadJsonFile'](a53_0xcda03f[_0x388512(0x272)](_0x5d6528,_0x388512(0x201)),[]),_0x5f9038=_0x3bb870?.['name']||_0x418e2c[_0x388512(0x20b)][_0x388512(0x1f4)];if(_0xef49a9){const _0x2eb7b4=new Map(),_0x21ae22=[..._0x1b6143],_0x407208=_0x1b6143[_0x388512(0x1ed)]+0x1;let _0x5b5185=0x0;while(_0x21ae22[_0x388512(0x1ed)]>0x0&&_0x5b5185<_0x407208){_0x5b5185++;const _0x2648c8=[];for(const _0x28cba2 of _0x21ae22){canCreateAgent(_0x28cba2,_0x2eb7b4)?_0x2eb7b4['set'](_0x28cba2['id'],_0x388512(0x26d)+_0x28cba2['id']):_0x2648c8[_0x388512(0x26a)](_0x28cba2);}if(_0x2648c8[_0x388512(0x1ed)]===_0x21ae22[_0x388512(0x1ed)])throw new SDKError(ErrorCode[_0x388512(0x24c)],_0x388512(0x24e),undefined,{'helpText':_0x388512(0x221)});_0x21ae22[_0x388512(0x1ed)]=0x0,_0x21ae22[_0x388512(0x26a)](..._0x2648c8);}const _0x14a807=_0x302db6['filter'](_0x5ce9ca=>_0x2eb7b4[_0x388512(0x223)](_0x5ce9ca['attributes'][_0x388512(0x23a)]))[_0x388512(0x1ed)];return{'projectName':_0x5f9038,'projectId':_0x388512(0x244),'counts':{'agents':_0x1b6143['length'],'knowledgeBases':_0x5175ba[_0x388512(0x1ed)],'prompts':_0x14a807,'integrations':_0x1a5eb9['length']},'sourceSite':_0x4a45dc};}const _0x1df72c=await this[_0x388512(0x232)][_0x388512(0x1f6)]({'name':_0x5f9038,'description':_0x418e2c[_0x388512(0x21e)]['attributes'][_0x388512(0x1f2)]}),_0x2b5bd8=_0x1df72c['id'],_0x152f7f=new Map(),_0x56586a=new Map(),_0x43097e=new Map();for(const _0xee2544 of _0x5175ba){const _0x66195b=await this['client'][_0x388512(0x26e)]({'projectId':_0x2b5bd8,'name':_0xee2544[_0x388512(0x1f3)][_0x388512(0x245)],'tdDatabaseName':_0xee2544['attributes']['tdDatabaseName'],'tables':_0xee2544[_0x388512(0x1f3)][_0x388512(0x218)]});_0x152f7f[_0x388512(0x25a)](_0xee2544['id'],_0x66195b['id']);}const _0x328e31=[..._0x1b6143],_0x56ff92=_0x1b6143[_0x388512(0x1ed)]+0x1;let _0x4a1a36=0x0;while(_0x328e31['length']>0x0&&_0x4a1a36<_0x56ff92){_0x4a1a36++;const _0x3161eb=[];for(const _0x50f75f of _0x328e31){if(canCreateAgent(_0x50f75f,_0x56586a)){const _0xcdf332=remapToolIds(_0x50f75f['attributes'][_0x388512(0x20c)],_0x152f7f,_0x56586a),_0x2edd78=remapVariableIds(_0x50f75f[_0x388512(0x1f3)]['variables'],_0x152f7f),_0x12bea9=await this[_0x388512(0x232)]['createAgentFull']({'name':_0x50f75f[_0x388512(0x1f3)][_0x388512(0x245)],'projectId':_0x2b5bd8,'systemPrompt':_0x50f75f['attributes'][_0x388512(0x241)],'starterMessage':_0x50f75f[_0x388512(0x1f3)][_0x388512(0x204)],'modelType':_0x50f75f[_0x388512(0x1f3)]['modelType'],'maxToolIterations':_0x50f75f[_0x388512(0x1f3)][_0x388512(0x22a)],'temperature':_0x50f75f[_0x388512(0x1f3)][_0x388512(0x250)],'reasoningEffort':_0x50f75f['attributes'][_0x388512(0x21c)],'outputs':_0x50f75f['attributes'][_0x388512(0x226)],'tools':_0xcdf332,'variables':_0x2edd78});_0x56586a[_0x388512(0x25a)](_0x50f75f['id'],_0x12bea9['id']);}else _0x3161eb[_0x388512(0x26a)](_0x50f75f);}if(_0x3161eb['length']===_0x328e31['length'])throw new SDKError(ErrorCode['INTERNAL'],_0x388512(0x24e),undefined,{'helpText':_0x388512(0x221)});_0x328e31['length']=0x0,_0x328e31[_0x388512(0x26a)](..._0x3161eb);}for(const _0x2bc41c of _0x302db6){const _0x22598a=_0x56586a[_0x388512(0x212)](_0x2bc41c[_0x388512(0x1f3)][_0x388512(0x23a)]);if(!_0x22598a)continue;const _0x22113a=await this[_0x388512(0x232)][_0x388512(0x255)]({'projectId':_0x2b5bd8,'agentId':_0x22598a,'name':_0x2bc41c[_0x388512(0x1f3)][_0x388512(0x245)],'systemPrompt':_0x2bc41c[_0x388512(0x1f3)][_0x388512(0x241)],'template':_0x2bc41c[_0x388512(0x1f3)][_0x388512(0x258)],'jsonSchemaHint':_0x2bc41c['attributes'][_0x388512(0x20e)]});_0x43097e[_0x388512(0x25a)](_0x2bc41c['id'],_0x22113a['id']);}for(const _0x23f5d9 of _0x1a5eb9){const _0x27eb3f=_0x23f5d9['attributes'][_0x388512(0x22c)][_0x388512(0x228)](_0xcbc55f=>({..._0xcbc55f,'promptId':_0x43097e[_0x388512(0x212)](_0xcbc55f[_0x388512(0x1ee)])||_0xcbc55f['promptId']}));await this['client'][_0x388512(0x25d)]({'projectId':_0x2b5bd8,'serviceType':_0x23f5d9[_0x388512(0x1f3)][_0x388512(0x1f9)],'actions':_0x27eb3f,'slackMessageMode':_0x23f5d9['attributes'][_0x388512(0x213)],'chatIgnoreManagedActions':_0x23f5d9['attributes'][_0x388512(0x242)],'chatWelcomeMessage':_0x23f5d9[_0x388512(0x1f3)][_0x388512(0x22d)],'webhookCorsOrigins':_0x23f5d9['attributes'][_0x388512(0x274)]});}return{'projectName':_0x5f9038,'projectId':_0x2b5bd8,'counts':{'agents':_0x56586a['size'],'knowledgeBases':_0x152f7f[_0x388512(0x1fc)],'prompts':_0x43097e[_0x388512(0x1fc)],'integrations':_0x1a5eb9['length']},'sourceSite':_0x4a45dc};}['loadJsonFile'](_0x377ce8,_0x5a764a){const _0x317607=a53_0x205647;if(!a53_0x4475f5[_0x317607(0x25c)](_0x377ce8))return _0x5a764a;return JSON[_0x317607(0x23f)](a53_0x4475f5[_0x317607(0x202)](_0x377ce8,_0x317607(0x264)));}['getBackupMetadata'](_0x9d5444){const _0x7c3a8d=a53_0x205647;if(!a53_0x4475f5['existsSync'](_0x9d5444))throw new SDKError(ErrorCode['NOT_FOUND'],_0x7c3a8d(0x22e)+_0x9d5444,undefined,{'helpText':_0x7c3a8d(0x21a)});const _0x34e400=a53_0xcda03f[_0x7c3a8d(0x272)](_0x9d5444,_0x7c3a8d(0x26c));if(!a53_0x4475f5[_0x7c3a8d(0x25c)](_0x34e400))throw new SDKError(ErrorCode[_0x7c3a8d(0x21f)],_0x7c3a8d(0x1f7)+_0x9d5444,undefined,{'helpText':_0x7c3a8d(0x1f1)});const _0x4989a2=JSON[_0x7c3a8d(0x23f)](a53_0x4475f5[_0x7c3a8d(0x202)](_0x34e400,'utf-8'));if(!isSupportedBackupVersion(_0x4989a2[_0x7c3a8d(0x1ef)]))throw new SDKError(ErrorCode[_0x7c3a8d(0x21f)],'Unsupported\x20backup\x20version:\x20'+_0x4989a2['version'],undefined,{'helpText':_0x7c3a8d(0x251)});return _0x4989a2;}}
|
package/dist/sdk/query.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a54_0x257200=a54_0x17d2;function a54_0x17d2(_0x51b19b,_0x5830e8){const _0x4c90f1=a54_0x4c90();return a54_0x17d2=function(_0x17d23a,_0x3e3bf8){_0x17d23a=_0x17d23a-0x1a0;let _0x3e16d6=_0x4c90f1[_0x17d23a];return _0x3e16d6;},a54_0x17d2(_0x51b19b,_0x5830e8);}(function(_0xf902f5,_0x414c9b){const _0x2334e8=a54_0x17d2,_0x51c6ba=_0xf902f5();while(!![]){try{const _0x1ab3b3=parseInt(_0x2334e8(0x1d6))/0x1*(parseInt(_0x2334e8(0x1bf))/0x2)+parseInt(_0x2334e8(0x1cf))/0x3+parseInt(_0x2334e8(0x1ac))/0x4*(parseInt(_0x2334e8(0x1ae))/0x5)+-parseInt(_0x2334e8(0x1c7))/0x6+parseInt(_0x2334e8(0x1cc))/0x7*(parseInt(_0x2334e8(0x1d4))/0x8)+parseInt(_0x2334e8(0x1ba))/0x9+-parseInt(_0x2334e8(0x1af))/0xa*(parseInt(_0x2334e8(0x1d5))/0xb);if(_0x1ab3b3===_0x414c9b)break;else _0x51c6ba['push'](_0x51c6ba['shift']());}catch(_0x212774){_0x51c6ba['push'](_0x51c6ba['shift']());}}}(a54_0x4c90,0xd780e));import{TrinoApiClient}from'../client/trino-api-client.js';function a54_0x4c90(){const _0x176adc=['\x20ESCAPE\x20\x27\x5c\x27','SQL\x20query\x20is\x20required','Provide\x20SQL\x20via\x20argument\x20or\x20use\x20--file\x20option.','Database\x20name\x20is\x20required','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20the\x20pattern\x20to\x20list\x20all\x20databases.','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20to\x20search\x20all\x20databases.','Usage:\x20tdx\x20show\x20<database.table>','slice','\x0aORDER\x20BY\x20table_name\x0aLIMIT\x20','trinoApiClient','INVALID_ARGUMENT','80OajcLT','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','225805GBVOhx','20pdukHH','listDatabases','\x0a\x20\x20AND\x20schema_name\x20LIKE\x20','\x0a\x20\x20AND\x20table_name\x20LIKE\x20','Table\x20name\x20is\x20required','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20ordinal_position\x0a\x20\x20\x20\x20','\x0aORDER\x20BY\x20database_name,\x20table_name\x0aLIMIT\x20','validateDatabase','trim','logger','12896370dugXrd','Use\x20--limit\x20<number>\x20to\x20specify\x20row\x20limit\x20(must\x20be\x20positive).','listTables','\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20','validateTable','535114WIABKN','\x0aORDER\x20BY\x20database_name\x0aLIMIT\x20','describeTable','\x20LIMIT\x20','\x0a\x20\x20\x20\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22user_*\x22)\x20or\x20omit\x20to\x20list\x20all\x20tables.','execute','5820vUCLHo','executeQuery','Usage:\x20tdx\x20describe\x20<database.table>','Provide\x20a\x20valid\x20database\x20name\x20or\x20omit\x20to\x20list\x20tables\x20from\x20all\x20databases.','length','8947981eITNRM','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20schema_name\x20=\x20','Database\x20name\x20cannot\x20be\x20empty\x20or\x20whitespace-only','5171301DqkakV','data','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','\x0a\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20column_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20data_type,\x0a\x20\x20\x20\x20\x20\x20\x20\x20is_nullable\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.columns\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','MISSING_ARGUMENT','8CyoRCw','27443031AYTwMu','2MwxtHN','isInteger','\x0a\x20\x20\x20\x20\x20\x20SELECT\x20schema_name\x20AS\x20database_name\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20'];a54_0x4c90=function(){return _0x176adc;};return a54_0x4c90();}import{escapeStringLiteral,buildLikePattern}from'../utils/string-utils.js';import{SDKError,ErrorCode}from'./errors.js';import{DEFAULT_LISTING_LIMIT}from'../utils/constants.js';export class QuerySDK{[a54_0x257200(0x1aa)];constructor(_0x259561){const _0x3e8a66=a54_0x257200;this[_0x3e8a66(0x1aa)]=new TrinoApiClient(_0x259561,_0x259561[_0x3e8a66(0x1b9)]);}async[a54_0x257200(0x1c6)](_0x45ad54,_0xaf168d){const _0xf4fa08=a54_0x257200;if(!_0x45ad54||_0x45ad54['trim']()[_0xf4fa08(0x1cb)]===0x0)throw new SDKError(ErrorCode[_0xf4fa08(0x1d3)],_0xf4fa08(0x1a2),undefined,{'helpText':_0xf4fa08(0x1a3)});return await this['trinoApiClient'][_0xf4fa08(0x1c8)](_0x45ad54,_0xaf168d);}async[a54_0x257200(0x1b0)](_0x313b8a,_0x340b3a=DEFAULT_LISTING_LIMIT){const _0x20ba32=a54_0x257200;if(_0x313b8a!==undefined&&_0x313b8a[_0x20ba32(0x1b8)]()[_0x20ba32(0x1cb)]===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x20ba32(0x1ad),undefined,{'helpText':_0x20ba32(0x1a5)});if(_0x340b3a<=0x0)throw new SDKError(ErrorCode[_0x20ba32(0x1ab)],'Limit\x20must\x20be\x20a\x20positive\x20number',undefined,{'helpText':_0x20ba32(0x1b4)});let _0x15a221=_0x20ba32(0x1a0);_0x313b8a&&(_0x15a221+=_0x20ba32(0x1b1)+buildLikePattern(_0x313b8a)+_0x20ba32(0x1a1));_0x15a221+=_0x20ba32(0x1c0)+_0x340b3a;const _0x2323d7=await this[_0x20ba32(0x1aa)][_0x20ba32(0x1c8)](_0x15a221[_0x20ba32(0x1b8)]());return _0x2323d7[_0x20ba32(0x1d0)];}async[a54_0x257200(0x1bc)](_0x2e87db,_0x1deeb8,_0x15e3c3,_0x103b29=DEFAULT_LISTING_LIMIT){const _0x57e62b=a54_0x257200;if(_0x2e87db!==undefined&&_0x2e87db[_0x57e62b(0x1b8)]()[_0x57e62b(0x1cb)]===0x0)throw new SDKError(ErrorCode[_0x57e62b(0x1ab)],_0x57e62b(0x1ce),undefined,{'helpText':_0x57e62b(0x1ca)});if(_0x1deeb8!==undefined&&_0x1deeb8[_0x57e62b(0x1b8)]()[_0x57e62b(0x1cb)]===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only',undefined,{'helpText':_0x57e62b(0x1c5)});if(_0x15e3c3!==undefined&&_0x15e3c3[_0x57e62b(0x1b8)]()[_0x57e62b(0x1cb)]===0x0)throw new SDKError(ErrorCode[_0x57e62b(0x1ab)],'Database\x20pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only',undefined,{'helpText':_0x57e62b(0x1a6)});if(_0x103b29<=0x0)throw new SDKError(ErrorCode[_0x57e62b(0x1ab)],'Limit\x20must\x20be\x20a\x20positive\x20number',undefined,{'helpText':_0x57e62b(0x1b4)});let _0x161adf;_0x2e87db?(_0x161adf=_0x57e62b(0x1c4)+escapeStringLiteral(_0x2e87db)+'\x0a\x20\x20\x20\x20\x20\x20',_0x1deeb8&&(_0x161adf+='\x0a\x20\x20AND\x20table_name\x20LIKE\x20'+buildLikePattern(_0x1deeb8)+_0x57e62b(0x1a1)),_0x161adf+=_0x57e62b(0x1a9)+_0x103b29):(_0x161adf='\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_schema\x20AS\x20database_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20',_0x15e3c3&&(_0x161adf+='\x0a\x20\x20AND\x20table_schema\x20LIKE\x20'+buildLikePattern(_0x15e3c3)+_0x57e62b(0x1a1)),_0x1deeb8&&(_0x161adf+=_0x57e62b(0x1b2)+buildLikePattern(_0x1deeb8)+_0x57e62b(0x1a1)),_0x161adf+=_0x57e62b(0x1b6)+_0x103b29);const _0x1bbe55=await this[_0x57e62b(0x1aa)][_0x57e62b(0x1c8)](_0x161adf[_0x57e62b(0x1b8)]());return _0x1bbe55[_0x57e62b(0x1d0)];}async[a54_0x257200(0x1b7)](_0x5883d6){const _0x7047b8=a54_0x257200,_0x361821=(_0x7047b8(0x1cd)+escapeStringLiteral(_0x5883d6)+_0x7047b8(0x1c3))[_0x7047b8(0x1b8)](),_0x5b1b35=await this[_0x7047b8(0x1aa)][_0x7047b8(0x1c8)](_0x361821);return _0x5b1b35[_0x7047b8(0x1d0)]['length']>0x0;}async[a54_0x257200(0x1be)](_0x5595d9,_0x30fc96){const _0x48a378=a54_0x257200,_0x522c9a=(_0x48a378(0x1d1)+escapeStringLiteral(_0x5595d9)+_0x48a378(0x1bd)+escapeStringLiteral(_0x30fc96)+'\x0a\x20\x20\x20\x20')['trim'](),_0x28e226=await this[_0x48a378(0x1aa)][_0x48a378(0x1c8)](_0x522c9a);return _0x28e226[_0x48a378(0x1d0)][_0x48a378(0x1cb)]>0x0;}async[a54_0x257200(0x1c1)](_0x2f6b7c,_0x530a16){const _0x23ed9b=a54_0x257200;if(!_0x2f6b7c||_0x2f6b7c[_0x23ed9b(0x1b8)]()[_0x23ed9b(0x1cb)]===0x0)throw new SDKError(ErrorCode[_0x23ed9b(0x1d3)],_0x23ed9b(0x1a4),undefined,{'helpText':'Usage:\x20tdx\x20describe\x20<database.table>'});if(!_0x530a16||_0x530a16['trim']()[_0x23ed9b(0x1cb)]===0x0)throw new SDKError(ErrorCode[_0x23ed9b(0x1d3)],_0x23ed9b(0x1b3),undefined,{'helpText':_0x23ed9b(0x1c9)});const _0x1f042c=(_0x23ed9b(0x1d2)+escapeStringLiteral(_0x2f6b7c)+_0x23ed9b(0x1bd)+escapeStringLiteral(_0x530a16)+_0x23ed9b(0x1b5))['trim'](),_0x3b4b54=await this[_0x23ed9b(0x1aa)][_0x23ed9b(0x1c8)](_0x1f042c);return _0x3b4b54[_0x23ed9b(0x1d0)];}async['showTable'](_0x11741a,_0x2333a2,_0x479c47=0x28,_0xb4fd7a){const _0x31fb88=a54_0x257200;if(!_0x11741a||_0x11741a[_0x31fb88(0x1b8)]()['length']===0x0)throw new SDKError(ErrorCode[_0x31fb88(0x1d3)],_0x31fb88(0x1a4),undefined,{'helpText':'Usage:\x20tdx\x20show\x20<database.table>'});if(!_0x2333a2||_0x2333a2[_0x31fb88(0x1b8)]()['length']===0x0)throw new SDKError(ErrorCode[_0x31fb88(0x1d3)],_0x31fb88(0x1b3),undefined,{'helpText':_0x31fb88(0x1a7)});if(!Number[_0x31fb88(0x1d7)](_0x479c47)||_0x479c47<=0x0)throw new SDKError(ErrorCode[_0x31fb88(0x1ab)],'Limit\x20must\x20be\x20a\x20positive\x20integer',undefined,{'helpText':_0x31fb88(0x1bb)});const _0x370036=escapeStringLiteral(_0x11741a)[_0x31fb88(0x1a8)](0x1,-0x1)+'.'+escapeStringLiteral(_0x2333a2)[_0x31fb88(0x1a8)](0x1,-0x1),_0x518ee4='SELECT\x20*\x20FROM\x20'+_0x370036+_0x31fb88(0x1c2)+_0x479c47,_0xe74f8=await this['trinoApiClient'][_0x31fb88(0x1c8)](_0x518ee4,{'catalog':_0xb4fd7a,'schema':_0x11741a});return _0xe74f8;}}
|
package/dist/sdk/segment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a55_0x1fcb1b=a55_0x4b66;(function(_0x193105,_0x5c0be4){const _0x48297c=a55_0x4b66,_0x2ca780=_0x193105();while(!![]){try{const _0x11723f=parseInt(_0x48297c(0x1bf))/0x1*(-parseInt(_0x48297c(0x1dd))/0x2)+-parseInt(_0x48297c(0x1a5))/0x3+parseInt(_0x48297c(0x1ce))/0x4*(parseInt(_0x48297c(0x1ac))/0x5)+parseInt(_0x48297c(0x1e5))/0x6*(-parseInt(_0x48297c(0x1cb))/0x7)+parseInt(_0x48297c(0x19c))/0x8+parseInt(_0x48297c(0x1b0))/0x9+parseInt(_0x48297c(0x19e))/0xa*(parseInt(_0x48297c(0x198))/0xb);if(_0x11723f===_0x5c0be4)break;else _0x2ca780['push'](_0x2ca780['shift']());}catch(_0x2f7089){_0x2ca780['push'](_0x2ca780['shift']());}}}(a55_0x2921,0xc1f8c));function a55_0x2921(){const _0x16c609=['Folder\x20\x27','updateSegmentById','Path\x20cannot\x20be\x20empty','getSegmentSQL','createSegmentFolder','Segment\x20\x27','258070RNWXSA','detectResourceType','listParentSegments','logger','segment','listRecursive','test','\x27\x20not\x20found','33714MjSaEi','find','\x20in\x20parent\x20','getParentSegmentFull','then','getParent','Path\x20must\x20be\x20absolute\x20(cannot\x20start\x20with\x20.\x20or\x20..)','listSegments','some','updateSegment','resolveParentId','listParents','parentColumn','3064831KIyzQA','\x27\x20not\x20found\x20in\x20','createSegment','description','5754936ImbNCR','Maximum\x20recursion\x20depth\x20(','30wVYzdZ','filter','attributes','length','rootFolderId','parent\x20segment','listFolders','4713372UOEPjr','attribute','resolveParentIdOrName','INVALID_ARGUMENT','resolvePathToResource','getParentSegment','population','154115zXkNJm','push','ambiguous','parent','3817836oBkWpO','listUnified','all','updateParent','isArray','parentTableName','behaviors','catch','parentDatabaseName','getFolder','detectResourceTypeInFolder','updateParentSegment','segmentFolderId','listSegmentFolders','createdAt','3SWiFkM','folder','behavior','isAbsolute','getParentFull','traversePath','listActivations','NOT_FOUND','getParentSQL','type','resolveSegmentId','Resource\x20\x27','35gdewQj','client','name','104LpLdTn','parentFolderId','join','resolveFolderId','createParentSegment','Folder\x20not\x20found:\x20','segments','Parent\x20segment\x20not\x20found:\x20','getSegment'];a55_0x2921=function(){return _0x16c609;};return a55_0x2921();}function a55_0x4b66(_0x500043,_0x16bb56){const _0x29219a=a55_0x2921();return a55_0x4b66=function(_0x4b669a,_0x105e27){_0x4b669a=_0x4b669a-0x190;let _0xaa2b7=_0x29219a[_0x4b669a];return _0xaa2b7;},a55_0x4b66(_0x500043,_0x16bb56);}import{CDPApiClient}from'../client/cdp-api-client.js';import{SDKError,ErrorCode}from'./errors.js';import{parsePath}from'../utils/segment-path-parser.js';export class SegmentSDK{[a55_0x1fcb1b(0x1cc)];constructor(_0x4b42d5){const _0x352f06=a55_0x1fcb1b;this[_0x352f06(0x1cc)]=new CDPApiClient(_0x4b42d5,_0x4b42d5[_0x352f06(0x1e0)]);}async[a55_0x1fcb1b(0x196)](){const _0x4ed625=a55_0x1fcb1b;return await this[_0x4ed625(0x1cc)][_0x4ed625(0x1df)]();}async[a55_0x1fcb1b(0x190)](_0x2f406e){const _0x198b0d=a55_0x1fcb1b;return await this[_0x198b0d(0x1cc)][_0x198b0d(0x1aa)](_0x2f406e);}async[a55_0x1fcb1b(0x192)](_0x155c80){const _0x5409a7=a55_0x1fcb1b;return await this[_0x5409a7(0x1cc)][_0x5409a7(0x192)](_0x155c80);}async[a55_0x1fcb1b(0x1d6)](_0x1b4655,_0x4c3c39){const _0xadd11c=a55_0x1fcb1b;return await this['client'][_0xadd11c(0x1d6)](_0x1b4655,_0x4c3c39);}async[a55_0x1fcb1b(0x1a4)](_0xaf4887){const _0x1f67d7=a55_0x1fcb1b;return await this[_0x1f67d7(0x1cc)][_0x1f67d7(0x1bd)](_0xaf4887);}async[a55_0x1fcb1b(0x1b9)](_0x266234){const _0x4d7563=a55_0x1fcb1b;return await this[_0x4d7563(0x1cc)]['getSegmentFolder'](_0x266234);}async[a55_0x1fcb1b(0x1c5)](_0x412e31,_0x50ab9b){const _0x6df68e=a55_0x1fcb1b;return await this['client'][_0x6df68e(0x1c5)](_0x412e31,_0x50ab9b);}async[a55_0x1fcb1b(0x1c7)](_0x1650b7){return await this['client']['getParentSegmentSQL'](_0x1650b7);}async['getSegmentSQL'](_0x126040,_0x55881e){const _0x3d96c3=a55_0x1fcb1b;return await this[_0x3d96c3(0x1cc)][_0x3d96c3(0x1da)](_0x126040,_0x55881e);}async[a55_0x1fcb1b(0x195)](_0x21ae21){const _0xdfd818=a55_0x1fcb1b,_0x723d7=await this[_0xdfd818(0x196)](),_0xe00589=_0x723d7[_0xdfd818(0x1e6)](_0x3af3b3=>_0x3af3b3[_0xdfd818(0x1a0)][_0xdfd818(0x1cd)]===_0x21ae21);if(!_0xe00589)throw new SDKError(ErrorCode[_0xdfd818(0x1c6)],_0xdfd818(0x1d5)+_0x21ae21);return _0xe00589['id'];}async[a55_0x1fcb1b(0x1c9)](_0x14f17a,_0x3bb1bb){const _0xd1eff4=a55_0x1fcb1b,_0x1b48ac=await this[_0xd1eff4(0x192)](_0x14f17a),_0x4d8ed2=_0x1b48ac[_0xd1eff4(0x1e6)](_0x15bb0e=>_0x15bb0e[_0xd1eff4(0x1cd)]===_0x3bb1bb);if(!_0x4d8ed2)throw new SDKError(ErrorCode[_0xd1eff4(0x1c6)],'Child\x20segment\x20not\x20found:\x20'+_0x3bb1bb+_0xd1eff4(0x1e7)+_0x14f17a);return _0x4d8ed2['id'];}async[a55_0x1fcb1b(0x1d1)](_0x13559c,_0x1fab47){const _0x4d5822=a55_0x1fcb1b,_0x4e5151=await this[_0x4d5822(0x1a4)](_0x13559c),_0x1b2711=_0x4e5151[_0x4d5822(0x1e6)](_0x35047d=>_0x35047d[_0x4d5822(0x1cd)]===_0x1fab47);if(!_0x1b2711)throw new SDKError(ErrorCode[_0x4d5822(0x1c6)],_0x4d5822(0x1d3)+_0x1fab47+'\x20in\x20parent\x20'+_0x13559c);return _0x1b2711['id'];}async['listFields'](_0x4158d9){const _0x5e7b8b=a55_0x1fcb1b,_0x130d54=await this['resolveParentIdOrName'](_0x4158d9),_0x5b2e0f=await this[_0x5e7b8b(0x1cc)][_0x5e7b8b(0x1e8)](_0x130d54),_0x49882f=[];if(_0x5b2e0f[_0x5e7b8b(0x1a0)]&&Array[_0x5e7b8b(0x1b4)](_0x5b2e0f[_0x5e7b8b(0x1a0)]))for(const _0x241e5d of _0x5b2e0f[_0x5e7b8b(0x1a0)]){const _0x3902a4=_0x241e5d;_0x3902a4[_0x5e7b8b(0x1cd)]&&_0x3902a4[_0x5e7b8b(0x1c8)]&&_0x49882f[_0x5e7b8b(0x1ad)]({'name':_0x3902a4['name'],'type':_0x3902a4['type'],'source':_0x5e7b8b(0x1a6),'parentDatabaseName':_0x3902a4[_0x5e7b8b(0x1b8)],'parentTableName':_0x3902a4[_0x5e7b8b(0x1b5)],'parentColumn':_0x3902a4['parentColumn']});}if(_0x5b2e0f['behaviors']&&Array[_0x5e7b8b(0x1b4)](_0x5b2e0f[_0x5e7b8b(0x1b6)]))for(const _0x76a29c of _0x5b2e0f['behaviors']){const _0x31525c=_0x76a29c,_0x1778e4=_0x31525c[_0x5e7b8b(0x1cd)];if(_0x1778e4&&_0x31525c['schema']&&Array['isArray'](_0x31525c['schema']))for(const _0x150737 of _0x31525c['schema']){_0x150737['name']&&_0x150737[_0x5e7b8b(0x1c8)]&&_0x49882f[_0x5e7b8b(0x1ad)]({'name':_0x1778e4+'.'+_0x150737[_0x5e7b8b(0x1cd)],'type':_0x150737[_0x5e7b8b(0x1c8)],'source':_0x5e7b8b(0x1c1),'behaviorName':_0x1778e4,'parentDatabaseName':_0x31525c[_0x5e7b8b(0x1b8)],'parentTableName':_0x31525c[_0x5e7b8b(0x1b5)],'parentColumn':_0x150737[_0x5e7b8b(0x197)]});}}return _0x49882f;}async['createParent'](_0x358105){const _0x210138=a55_0x1fcb1b;return await this[_0x210138(0x1cc)][_0x210138(0x1d2)](_0x358105);}async[a55_0x1fcb1b(0x1b3)](_0x5682ed,_0x487c7c){const _0x79755a=a55_0x1fcb1b,_0x1c10b7=await this[_0x79755a(0x1a7)](_0x5682ed);return await this[_0x79755a(0x1cc)][_0x79755a(0x1bb)](_0x1c10b7,_0x487c7c);}async['getParentFull'](_0x3f5bc3){const _0x51c703=a55_0x1fcb1b,_0x31d13f=await this['resolveParentIdOrName'](_0x3f5bc3);return await this[_0x51c703(0x1cc)][_0x51c703(0x1e8)](_0x31d13f);}async['createSegment'](_0x31c17a,_0xcf9188){const _0x5e077e=a55_0x1fcb1b;return await this[_0x5e077e(0x1cc)][_0x5e077e(0x19a)](_0x31c17a,_0xcf9188);}async[a55_0x1fcb1b(0x1d8)](_0x271e5c,_0x274cad,_0x50ca20){const _0x10cfdb=a55_0x1fcb1b;return await this[_0x10cfdb(0x1cc)][_0x10cfdb(0x194)](_0x271e5c,_0x274cad,_0x50ca20);}async['createFolder'](_0x864b77,_0x45c6b3){const _0x69652f=a55_0x1fcb1b,_0x285e9f=await this[_0x69652f(0x1a7)](_0x864b77);return await this[_0x69652f(0x1cc)][_0x69652f(0x1db)](_0x285e9f,_0x45c6b3);}async[a55_0x1fcb1b(0x1a7)](_0x5b0663){const _0x38e99d=a55_0x1fcb1b;if(/^\d+$/[_0x38e99d(0x1e3)](_0x5b0663))return _0x5b0663;return await this[_0x38e99d(0x195)](_0x5b0663);}async[a55_0x1fcb1b(0x1de)](_0x16d86a,_0x881515){const _0x533546=a55_0x1fcb1b,[_0x314b62,_0x5c6264]=await Promise[_0x533546(0x1b2)]([this[_0x533546(0x1d1)](_0x16d86a,_0x881515)[_0x533546(0x1e9)](()=>!![])[_0x533546(0x1b7)](()=>![]),this['resolveSegmentId'](_0x16d86a,_0x881515)[_0x533546(0x1e9)](()=>!![])[_0x533546(0x1b7)](()=>![])]);if(_0x314b62&&_0x5c6264)return _0x533546(0x1ae);else{if(_0x314b62)return _0x533546(0x1c0);else{if(_0x5c6264)return _0x533546(0x1e1);}}throw new SDKError(ErrorCode[_0x533546(0x1c6)],_0x533546(0x1ca)+_0x881515+'\x27\x20not\x20found\x20in\x20parent\x20segment');}async[a55_0x1fcb1b(0x1ba)](_0x8d623a,_0x3d7e12,_0x1b90ed){const _0x198703=a55_0x1fcb1b,[_0x19a6e2,_0x125552]=await Promise[_0x198703(0x1b2)]([this['listFolders'](_0x8d623a),this['listSegments'](_0x8d623a)]),_0x5039bf=_0x1b90ed?_0x19a6e2[_0x198703(0x19f)](_0x34ba21=>_0x34ba21[_0x198703(0x1cf)]===_0x1b90ed):_0x19a6e2[_0x198703(0x19f)](_0x55ca50=>!_0x55ca50['parentFolderId']),_0xa6f6af=_0x1b90ed?_0x125552[_0x198703(0x19f)](_0x1fde84=>_0x1fde84[_0x198703(0x1bc)]===_0x1b90ed):_0x125552[_0x198703(0x19f)](_0x26e191=>!_0x26e191[_0x198703(0x1bc)]),_0x3547d5=_0x5039bf[_0x198703(0x193)](_0xc05243=>_0xc05243[_0x198703(0x1cd)]===_0x3d7e12),_0x2964cb=_0xa6f6af[_0x198703(0x193)](_0xede0c3=>_0xede0c3['name']===_0x3d7e12);if(_0x3547d5&&_0x2964cb)return _0x198703(0x1ae);else{if(_0x3547d5)return _0x198703(0x1c0);else{if(_0x2964cb)return'segment';}}throw new SDKError(ErrorCode[_0x198703(0x1c6)],'Resource\x20\x27'+_0x3d7e12+_0x198703(0x199)+(_0x1b90ed?_0x198703(0x1c0):_0x198703(0x1a3)));}async[a55_0x1fcb1b(0x1c4)](_0x4c2584){const _0x4bfb31=a55_0x1fcb1b;if(_0x4c2584[_0x4bfb31(0x1a1)]===0x0)throw new SDKError(ErrorCode[_0x4bfb31(0x1a8)],_0x4bfb31(0x1d9));const _0x3098cb=_0x4c2584[0x0],_0x21086c=await this[_0x4bfb31(0x195)](_0x3098cb);if(_0x4c2584[_0x4bfb31(0x1a1)]===0x1)return{'parentId':_0x21086c,'parentName':_0x3098cb,'type':_0x4bfb31(0x1af),'fullPath':_0x3098cb};const _0x463952=await this[_0x4bfb31(0x1c3)](_0x21086c),_0x5cdcde=_0x463952[_0x4bfb31(0x1a2)],_0x3a0ff7=[];let _0x2b4f8c=_0x5cdcde;for(let _0x15829b=0x1;_0x15829b<_0x4c2584['length']-0x1;_0x15829b++){const _0x2e726c=_0x4c2584[_0x15829b],_0x656151=await this[_0x4bfb31(0x1a4)](_0x21086c),_0x54c4e0=_0x2b4f8c?_0x656151[_0x4bfb31(0x1e6)](_0x4c021e=>_0x4c021e[_0x4bfb31(0x1cd)]===_0x2e726c&&_0x4c021e[_0x4bfb31(0x1cf)]===_0x2b4f8c):_0x656151['find'](_0x602768=>_0x602768[_0x4bfb31(0x1cd)]===_0x2e726c&&!_0x602768['parentFolderId']);if(!_0x54c4e0)throw new SDKError(ErrorCode[_0x4bfb31(0x1c6)],_0x4bfb31(0x1d7)+_0x2e726c+'\x27\x20not\x20found\x20in\x20path');_0x3a0ff7[_0x4bfb31(0x1ad)](_0x2e726c),_0x2b4f8c=_0x54c4e0['id'];}const _0x3f3211=_0x4c2584[_0x4c2584['length']-0x1],_0x595188=await this[_0x4bfb31(0x1ba)](_0x21086c,_0x3f3211,_0x2b4f8c);if(_0x595188==='ambiguous')return{'parentId':_0x21086c,'parentName':_0x3098cb,'folderId':_0x2b4f8c,'folderPath':_0x3a0ff7[_0x4bfb31(0x1a1)]>0x0?_0x3a0ff7:undefined,'type':_0x4bfb31(0x1c0),'fullPath':_0x4c2584[_0x4bfb31(0x1d0)]('/')};else{if(_0x595188===_0x4bfb31(0x1c0)){const _0x16ae9b=await this[_0x4bfb31(0x1a4)](_0x21086c),_0x4459fa=_0x2b4f8c?_0x16ae9b['find'](_0x568d46=>_0x568d46[_0x4bfb31(0x1cd)]===_0x3f3211&&_0x568d46['parentFolderId']===_0x2b4f8c):_0x16ae9b[_0x4bfb31(0x1e6)](_0x4fb467=>_0x4fb467[_0x4bfb31(0x1cd)]===_0x3f3211&&!_0x4fb467['parentFolderId']);if(!_0x4459fa)throw new SDKError(ErrorCode[_0x4bfb31(0x1c6)],_0x4bfb31(0x1d7)+_0x3f3211+'\x27\x20not\x20found');return _0x3a0ff7[_0x4bfb31(0x1ad)](_0x3f3211),{'parentId':_0x21086c,'parentName':_0x3098cb,'folderId':_0x4459fa['id'],'folderPath':_0x3a0ff7,'type':_0x4bfb31(0x1c0),'fullPath':_0x4c2584[_0x4bfb31(0x1d0)]('/')};}else{const _0x3cb22f=await this[_0x4bfb31(0x192)](_0x21086c),_0x39f3ce=_0x2b4f8c?_0x3cb22f[_0x4bfb31(0x1e6)](_0x351451=>_0x351451['name']===_0x3f3211&&_0x351451['segmentFolderId']===_0x2b4f8c):_0x3cb22f[_0x4bfb31(0x1e6)](_0x10a6e2=>_0x10a6e2[_0x4bfb31(0x1cd)]===_0x3f3211&&!_0x10a6e2[_0x4bfb31(0x1bc)]);if(!_0x39f3ce)throw new SDKError(ErrorCode[_0x4bfb31(0x1c6)],_0x4bfb31(0x1dc)+_0x3f3211+_0x4bfb31(0x1e4));return{'parentId':_0x21086c,'parentName':_0x3098cb,'folderId':_0x2b4f8c,'folderPath':_0x3a0ff7['length']>0x0?_0x3a0ff7:undefined,'segmentId':_0x39f3ce['id'],'segmentName':_0x3f3211,'type':_0x4bfb31(0x1e1),'fullPath':_0x4c2584['join']('/')};}}}async[a55_0x1fcb1b(0x1a9)](_0x5a25cf){const _0x3f144=a55_0x1fcb1b,_0x45bad2=parsePath(_0x5a25cf);if(!_0x45bad2[_0x3f144(0x1c2)])throw new SDKError(ErrorCode[_0x3f144(0x1a8)],_0x3f144(0x191));return await this[_0x3f144(0x1c4)](_0x45bad2[_0x3f144(0x1d4)]);}async[a55_0x1fcb1b(0x1b1)](_0xdded2a,_0x3b93d4){const _0x164f7f=a55_0x1fcb1b,[_0x5d73f0,_0x5607d8]=await Promise[_0x164f7f(0x1b2)]([this[_0x164f7f(0x1a4)](_0xdded2a),this[_0x164f7f(0x192)](_0xdded2a)]);if(_0x3b93d4){const _0xfe9656=_0x5d73f0[_0x164f7f(0x19f)](_0x289551=>_0x289551[_0x164f7f(0x1cf)]===_0x3b93d4),_0x3ce0a7=_0x5607d8['filter'](_0xd2eabb=>_0xd2eabb[_0x164f7f(0x1bc)]===_0x3b93d4);return{'folders':_0xfe9656,'segments':_0x3ce0a7};}const _0x48195f=await this['getParentFull'](_0xdded2a),_0xcd5c9f=_0x48195f[_0x164f7f(0x1a2)];if(_0xcd5c9f){const _0x3e32fe=_0x5d73f0[_0x164f7f(0x19f)](_0x15aa5a=>_0x15aa5a[_0x164f7f(0x1cf)]===_0xcd5c9f),_0x126028=_0x5607d8[_0x164f7f(0x19f)](_0x13c272=>_0x13c272['segmentFolderId']===_0xcd5c9f);return{'folders':_0x3e32fe,'segments':_0x126028};}const _0x3e44bc=_0x5d73f0[_0x164f7f(0x19f)](_0x12d57d=>!_0x12d57d['parentFolderId']),_0x15ed70=_0x5607d8[_0x164f7f(0x19f)](_0x18946d=>!_0x18946d['segmentFolderId']);return{'folders':_0x3e44bc,'segments':_0x15ed70};}async[a55_0x1fcb1b(0x1e2)](_0x145b22,_0x237889,_0x596591=0x0,_0x3c0d08=0xa){const _0x3a14c1=a55_0x1fcb1b;if(_0x596591>=_0x3c0d08)throw new SDKError(ErrorCode[_0x3a14c1(0x1a8)],_0x3a14c1(0x19d)+_0x3c0d08+')\x20exceeded');const {folders:_0x41910e,segments:_0x7f7f6}=await this['listUnified'](_0x145b22,_0x237889),_0x5ac6d5=[];for(const _0x572250 of _0x41910e){const _0x23ba4d=await this[_0x3a14c1(0x1e2)](_0x145b22,_0x572250['id'],_0x596591+0x1,_0x3c0d08);_0x5ac6d5[_0x3a14c1(0x1ad)]({'type':_0x3a14c1(0x1c0),'id':_0x572250['id'],'name':_0x572250['name'],'children':_0x23ba4d[_0x3a14c1(0x1a1)]>0x0?_0x23ba4d:undefined,'metadata':{'description':_0x572250[_0x3a14c1(0x19b)]||undefined,'folderCount':_0x23ba4d['filter'](_0x1872fa=>_0x1872fa[_0x3a14c1(0x1c8)]==='folder')[_0x3a14c1(0x1a1)],'segmentCount':_0x23ba4d['filter'](_0x13a603=>_0x13a603['type']==='segment')['length'],'createdAt':_0x572250[_0x3a14c1(0x1be)],'updatedAt':_0x572250['updatedAt']}});}for(const _0x5bd1a1 of _0x7f7f6){_0x5ac6d5[_0x3a14c1(0x1ad)]({'type':'segment','id':_0x5bd1a1['id'],'name':_0x5bd1a1[_0x3a14c1(0x1cd)],'population':_0x5bd1a1[_0x3a14c1(0x1ab)],'metadata':{'description':_0x5bd1a1[_0x3a14c1(0x19b)],'createdAt':_0x5bd1a1[_0x3a14c1(0x1be)],'updatedAt':_0x5bd1a1['updatedAt']}});}return _0x5ac6d5;}}
|
|
1
|
+
function a55_0x1e3a(){const _0x38915b=['listRecursive','createSegment','parentFolderId','name','listSegmentFolders','312wGBMPt','test','Maximum\x20recursion\x20depth\x20(','resolveParentIdOrName','createParent','behaviors','description','client','createParentSegment','getParentSQL','\x20in\x20parent\x20','getSegmentSQL','logger','Parent\x20segment\x20not\x20found:\x20','listFolders','168iTCMFE','join','resolveSegmentId','parent','INVALID_ARGUMENT','rootFolderId','listFields','attributes','getParentSegmentFull','segmentFolderId','\x27\x20not\x20found\x20in\x20','2832731nQaIoo','createdAt','\x27\x20not\x20found\x20in\x20parent\x20segment','type','isArray','listActivations','updateSegmentById','ambiguous','2996640jYIwzy','segments','getSegment','Folder\x20\x27','then','getSegmentFolder','schema','160534DBQLbH','20Vafdew','attribute',')\x20exceeded','some','Child\x20segment\x20not\x20found:\x20','getParentSegmentSQL','parentDatabaseName','detectResourceTypeInFolder','listParents','\x27\x20not\x20found','catch','find','Path\x20cannot\x20be\x20empty','21mIjWPT','population','resolveParentId','getParent','behavior','createFolder','getParentFull','parentColumn','14zcwwRw','detectResourceType','listSegments','segment','Folder\x20not\x20found:\x20','listUnified','4993029TBmEvx','Resource\x20\x27','folder','NOT_FOUND','listParentSegments','resolveFolderId','parentTableName','traversePath','updatedAt','Path\x20must\x20be\x20absolute\x20(cannot\x20start\x20with\x20.\x20or\x20..)','121898VlvSOX','updateSegment','length','all','2590960wIHdaI','filter','\x27\x20not\x20found\x20in\x20path','push','575536RMiAcu','Segment\x20\x27'];a55_0x1e3a=function(){return _0x38915b;};return a55_0x1e3a();}function a55_0x3538(_0x29fa3f,_0x3dd75e){const _0x1e3acc=a55_0x1e3a();return a55_0x3538=function(_0x353801,_0x2d1142){_0x353801=_0x353801-0x140;let _0x2488fa=_0x1e3acc[_0x353801];return _0x2488fa;},a55_0x3538(_0x29fa3f,_0x3dd75e);}const a55_0x41d2ec=a55_0x3538;(function(_0x17c51c,_0x30fc4a){const _0x5a129b=a55_0x3538,_0x3f0a12=_0x17c51c();while(!![]){try{const _0x221bdd=-parseInt(_0x5a129b(0x166))/0x1*(parseInt(_0x5a129b(0x17c))/0x2)+parseInt(_0x5a129b(0x174))/0x3*(-parseInt(_0x5a129b(0x194))/0x4)+parseInt(_0x5a129b(0x190))/0x5+parseInt(_0x5a129b(0x15f))/0x6+-parseInt(_0x5a129b(0x18c))/0x7*(parseInt(_0x5a129b(0x19b))/0x8)+parseInt(_0x5a129b(0x182))/0x9*(-parseInt(_0x5a129b(0x167))/0xa)+parseInt(_0x5a129b(0x157))/0xb*(parseInt(_0x5a129b(0x14c))/0xc);if(_0x221bdd===_0x30fc4a)break;else _0x3f0a12['push'](_0x3f0a12['shift']());}catch(_0x4f62a0){_0x3f0a12['push'](_0x3f0a12['shift']());}}}(a55_0x1e3a,0xabb3c));import{CDPApiClient}from'../client/cdp-api-client.js';import{SDKError,ErrorCode}from'./errors.js';import{parsePath}from'../utils/segment-path-parser.js';export class SegmentSDK{['client'];constructor(_0x17e2e8){const _0x3f421d=a55_0x3538;this[_0x3f421d(0x144)]=new CDPApiClient(_0x17e2e8,_0x17e2e8[_0x3f421d(0x149)]);}async['listParents'](){const _0x1cb2d2=a55_0x3538;return await this[_0x1cb2d2(0x144)][_0x1cb2d2(0x186)]();}async[a55_0x41d2ec(0x177)](_0x4506c2){const _0x14e5b8=a55_0x41d2ec;return await this[_0x14e5b8(0x144)]['getParentSegment'](_0x4506c2);}async[a55_0x41d2ec(0x17e)](_0x481241){const _0x31dc94=a55_0x41d2ec;return await this[_0x31dc94(0x144)][_0x31dc94(0x17e)](_0x481241);}async[a55_0x41d2ec(0x161)](_0x53ae2c,_0x1351db){const _0x1f5254=a55_0x41d2ec;return await this[_0x1f5254(0x144)][_0x1f5254(0x161)](_0x53ae2c,_0x1351db);}async[a55_0x41d2ec(0x14b)](_0x14bab6){const _0x719513=a55_0x41d2ec;return await this['client'][_0x719513(0x19a)](_0x14bab6);}async['getFolder'](_0x278cbe){const _0x1ae228=a55_0x41d2ec;return await this['client'][_0x1ae228(0x164)](_0x278cbe);}async[a55_0x41d2ec(0x15c)](_0x206bdd,_0x398320){const _0x457780=a55_0x41d2ec;return await this[_0x457780(0x144)][_0x457780(0x15c)](_0x206bdd,_0x398320);}async[a55_0x41d2ec(0x146)](_0x1201a4){const _0x4d8ca2=a55_0x41d2ec;return await this[_0x4d8ca2(0x144)][_0x4d8ca2(0x16c)](_0x1201a4);}async[a55_0x41d2ec(0x148)](_0x52cb01,_0x5b2582){const _0x9f6940=a55_0x41d2ec;return await this[_0x9f6940(0x144)][_0x9f6940(0x148)](_0x52cb01,_0x5b2582);}async['resolveParentId'](_0x14cf9f){const _0x2f2823=a55_0x41d2ec,_0x17054a=await this[_0x2f2823(0x16f)](),_0x3e65b3=_0x17054a[_0x2f2823(0x172)](_0x2f299d=>_0x2f299d['attributes'][_0x2f2823(0x199)]===_0x14cf9f);if(!_0x3e65b3)throw new SDKError(ErrorCode[_0x2f2823(0x185)],_0x2f2823(0x14a)+_0x14cf9f);return _0x3e65b3['id'];}async[a55_0x41d2ec(0x14e)](_0x55db5c,_0x2e3517){const _0x1d80b7=a55_0x41d2ec,_0x53feaa=await this[_0x1d80b7(0x17e)](_0x55db5c),_0x4285b5=_0x53feaa[_0x1d80b7(0x172)](_0x3d6819=>_0x3d6819[_0x1d80b7(0x199)]===_0x2e3517);if(!_0x4285b5)throw new SDKError(ErrorCode[_0x1d80b7(0x185)],_0x1d80b7(0x16b)+_0x2e3517+_0x1d80b7(0x147)+_0x55db5c);return _0x4285b5['id'];}async[a55_0x41d2ec(0x187)](_0x11d0ca,_0x4d5823){const _0x5e663d=a55_0x41d2ec,_0x2b6521=await this[_0x5e663d(0x14b)](_0x11d0ca),_0x53e592=_0x2b6521[_0x5e663d(0x172)](_0x3f7f9e=>_0x3f7f9e['name']===_0x4d5823);if(!_0x53e592)throw new SDKError(ErrorCode[_0x5e663d(0x185)],_0x5e663d(0x180)+_0x4d5823+'\x20in\x20parent\x20'+_0x11d0ca);return _0x53e592['id'];}async[a55_0x41d2ec(0x152)](_0x49685d){const _0x20c27c=a55_0x41d2ec,_0x3c8ff6=await this[_0x20c27c(0x140)](_0x49685d),_0xdcd259=await this[_0x20c27c(0x144)][_0x20c27c(0x154)](_0x3c8ff6),_0x204b9d=[];if(_0xdcd259[_0x20c27c(0x153)]&&Array[_0x20c27c(0x15b)](_0xdcd259[_0x20c27c(0x153)]))for(const _0x171ce6 of _0xdcd259[_0x20c27c(0x153)]){const _0x3fcbf3=_0x171ce6;_0x3fcbf3[_0x20c27c(0x199)]&&_0x3fcbf3[_0x20c27c(0x15a)]&&_0x204b9d['push']({'name':_0x3fcbf3[_0x20c27c(0x199)],'type':_0x3fcbf3[_0x20c27c(0x15a)],'source':_0x20c27c(0x168),'parentDatabaseName':_0x3fcbf3[_0x20c27c(0x16d)],'parentTableName':_0x3fcbf3[_0x20c27c(0x188)],'parentColumn':_0x3fcbf3[_0x20c27c(0x17b)]});}if(_0xdcd259[_0x20c27c(0x142)]&&Array['isArray'](_0xdcd259[_0x20c27c(0x142)]))for(const _0x30291b of _0xdcd259[_0x20c27c(0x142)]){const _0x21edfb=_0x30291b,_0x371ec7=_0x21edfb[_0x20c27c(0x199)];if(_0x371ec7&&_0x21edfb[_0x20c27c(0x165)]&&Array[_0x20c27c(0x15b)](_0x21edfb[_0x20c27c(0x165)]))for(const _0x196666 of _0x21edfb['schema']){_0x196666[_0x20c27c(0x199)]&&_0x196666[_0x20c27c(0x15a)]&&_0x204b9d[_0x20c27c(0x193)]({'name':_0x371ec7+'.'+_0x196666[_0x20c27c(0x199)],'type':_0x196666[_0x20c27c(0x15a)],'source':_0x20c27c(0x178),'behaviorName':_0x371ec7,'parentDatabaseName':_0x21edfb[_0x20c27c(0x16d)],'parentTableName':_0x21edfb[_0x20c27c(0x188)],'parentColumn':_0x196666[_0x20c27c(0x17b)]});}}return _0x204b9d;}async[a55_0x41d2ec(0x141)](_0x25dab0){const _0x30b894=a55_0x41d2ec;return await this[_0x30b894(0x144)][_0x30b894(0x145)](_0x25dab0);}async['updateParent'](_0x24360c,_0x41bad1){const _0x2bfa94=a55_0x41d2ec,_0x1cd951=await this[_0x2bfa94(0x140)](_0x24360c);return await this[_0x2bfa94(0x144)]['updateParentSegment'](_0x1cd951,_0x41bad1);}async[a55_0x41d2ec(0x17a)](_0x431731){const _0x5671f6=a55_0x41d2ec,_0x3aed48=await this[_0x5671f6(0x140)](_0x431731);return await this['client']['getParentSegmentFull'](_0x3aed48);}async['createSegment'](_0x4661ab,_0x5ceb5c){const _0x46256f=a55_0x41d2ec;return await this[_0x46256f(0x144)][_0x46256f(0x197)](_0x4661ab,_0x5ceb5c);}async[a55_0x41d2ec(0x15d)](_0xa4d441,_0x246218,_0x7f6df1){const _0x146f5d=a55_0x41d2ec;return await this[_0x146f5d(0x144)][_0x146f5d(0x18d)](_0xa4d441,_0x246218,_0x7f6df1);}async[a55_0x41d2ec(0x179)](_0x380edb,_0x3481bc){const _0x5b8103=a55_0x41d2ec,_0xa1cbc1=await this[_0x5b8103(0x140)](_0x380edb);return await this[_0x5b8103(0x144)]['createSegmentFolder'](_0xa1cbc1,_0x3481bc);}async['resolveParentIdOrName'](_0x199295){const _0x40e4a0=a55_0x41d2ec;if(/^\d+$/[_0x40e4a0(0x19c)](_0x199295))return _0x199295;return await this[_0x40e4a0(0x176)](_0x199295);}async[a55_0x41d2ec(0x17d)](_0x5a2fa5,_0xc59eb3){const _0x11cedc=a55_0x41d2ec,[_0xbd6de6,_0x282de0]=await Promise['all']([this[_0x11cedc(0x187)](_0x5a2fa5,_0xc59eb3)[_0x11cedc(0x163)](()=>!![])['catch'](()=>![]),this[_0x11cedc(0x14e)](_0x5a2fa5,_0xc59eb3)['then'](()=>!![])[_0x11cedc(0x171)](()=>![])]);if(_0xbd6de6&&_0x282de0)return _0x11cedc(0x15e);else{if(_0xbd6de6)return _0x11cedc(0x184);else{if(_0x282de0)return _0x11cedc(0x17f);}}throw new SDKError(ErrorCode[_0x11cedc(0x185)],_0x11cedc(0x183)+_0xc59eb3+_0x11cedc(0x159));}async[a55_0x41d2ec(0x16e)](_0x528c1d,_0x25315e,_0x49b952){const _0x56cec7=a55_0x41d2ec,[_0xe93769,_0x53bad1]=await Promise[_0x56cec7(0x18f)]([this['listFolders'](_0x528c1d),this[_0x56cec7(0x17e)](_0x528c1d)]),_0x5042d7=_0x49b952?_0xe93769[_0x56cec7(0x191)](_0x29749e=>_0x29749e[_0x56cec7(0x198)]===_0x49b952):_0xe93769[_0x56cec7(0x191)](_0x4c972e=>!_0x4c972e[_0x56cec7(0x198)]),_0x34565b=_0x49b952?_0x53bad1['filter'](_0x10390a=>_0x10390a[_0x56cec7(0x155)]===_0x49b952):_0x53bad1[_0x56cec7(0x191)](_0x29d372=>!_0x29d372['segmentFolderId']),_0x375522=_0x5042d7['some'](_0x3c4695=>_0x3c4695[_0x56cec7(0x199)]===_0x25315e),_0x3ec7e5=_0x34565b[_0x56cec7(0x16a)](_0x2c6e28=>_0x2c6e28[_0x56cec7(0x199)]===_0x25315e);if(_0x375522&&_0x3ec7e5)return _0x56cec7(0x15e);else{if(_0x375522)return _0x56cec7(0x184);else{if(_0x3ec7e5)return _0x56cec7(0x17f);}}throw new SDKError(ErrorCode[_0x56cec7(0x185)],_0x56cec7(0x183)+_0x25315e+_0x56cec7(0x156)+(_0x49b952?'folder':'parent\x20segment'));}async[a55_0x41d2ec(0x189)](_0x3e86bf){const _0x2812f1=a55_0x41d2ec;if(_0x3e86bf[_0x2812f1(0x18e)]===0x0)throw new SDKError(ErrorCode[_0x2812f1(0x150)],_0x2812f1(0x173));const _0x2397a8=_0x3e86bf[0x0],_0x225339=await this[_0x2812f1(0x176)](_0x2397a8);if(_0x3e86bf[_0x2812f1(0x18e)]===0x1)return{'parentId':_0x225339,'parentName':_0x2397a8,'type':_0x2812f1(0x14f),'fullPath':_0x2397a8};const _0x5f4712=await this[_0x2812f1(0x17a)](_0x225339),_0x41086b=_0x5f4712[_0x2812f1(0x151)],_0x4bf1ab=[];let _0x27e059=_0x41086b;for(let _0xf194b9=0x1;_0xf194b9<_0x3e86bf['length']-0x1;_0xf194b9++){const _0x3b82e7=_0x3e86bf[_0xf194b9],_0x58107c=await this[_0x2812f1(0x14b)](_0x225339),_0x466e76=_0x27e059?_0x58107c[_0x2812f1(0x172)](_0x2502b4=>_0x2502b4[_0x2812f1(0x199)]===_0x3b82e7&&_0x2502b4[_0x2812f1(0x198)]===_0x27e059):_0x58107c['find'](_0x44d4bd=>_0x44d4bd['name']===_0x3b82e7&&!_0x44d4bd[_0x2812f1(0x198)]);if(!_0x466e76)throw new SDKError(ErrorCode[_0x2812f1(0x185)],_0x2812f1(0x162)+_0x3b82e7+_0x2812f1(0x192));_0x4bf1ab[_0x2812f1(0x193)](_0x3b82e7),_0x27e059=_0x466e76['id'];}const _0x550d90=_0x3e86bf[_0x3e86bf[_0x2812f1(0x18e)]-0x1],_0x10dc2f=await this['detectResourceTypeInFolder'](_0x225339,_0x550d90,_0x27e059);if(_0x10dc2f===_0x2812f1(0x15e))return{'parentId':_0x225339,'parentName':_0x2397a8,'folderId':_0x27e059,'folderPath':_0x4bf1ab[_0x2812f1(0x18e)]>0x0?_0x4bf1ab:undefined,'type':_0x2812f1(0x184),'fullPath':_0x3e86bf[_0x2812f1(0x14d)]('/')};else{if(_0x10dc2f===_0x2812f1(0x184)){const _0x2abcdd=await this[_0x2812f1(0x14b)](_0x225339),_0x1bca90=_0x27e059?_0x2abcdd[_0x2812f1(0x172)](_0x35fcbd=>_0x35fcbd['name']===_0x550d90&&_0x35fcbd[_0x2812f1(0x198)]===_0x27e059):_0x2abcdd[_0x2812f1(0x172)](_0x555104=>_0x555104[_0x2812f1(0x199)]===_0x550d90&&!_0x555104['parentFolderId']);if(!_0x1bca90)throw new SDKError(ErrorCode[_0x2812f1(0x185)],'Folder\x20\x27'+_0x550d90+_0x2812f1(0x170));return _0x4bf1ab['push'](_0x550d90),{'parentId':_0x225339,'parentName':_0x2397a8,'folderId':_0x1bca90['id'],'folderPath':_0x4bf1ab,'type':_0x2812f1(0x184),'fullPath':_0x3e86bf['join']('/')};}else{const _0x1540fc=await this[_0x2812f1(0x17e)](_0x225339),_0x4829cc=_0x27e059?_0x1540fc[_0x2812f1(0x172)](_0x523aba=>_0x523aba[_0x2812f1(0x199)]===_0x550d90&&_0x523aba[_0x2812f1(0x155)]===_0x27e059):_0x1540fc[_0x2812f1(0x172)](_0x208bfe=>_0x208bfe['name']===_0x550d90&&!_0x208bfe[_0x2812f1(0x155)]);if(!_0x4829cc)throw new SDKError(ErrorCode['NOT_FOUND'],_0x2812f1(0x195)+_0x550d90+_0x2812f1(0x170));return{'parentId':_0x225339,'parentName':_0x2397a8,'folderId':_0x27e059,'folderPath':_0x4bf1ab[_0x2812f1(0x18e)]>0x0?_0x4bf1ab:undefined,'segmentId':_0x4829cc['id'],'segmentName':_0x550d90,'type':'segment','fullPath':_0x3e86bf[_0x2812f1(0x14d)]('/')};}}}async['resolvePathToResource'](_0x2769d4){const _0x1a2c51=a55_0x41d2ec,_0x14fefd=parsePath(_0x2769d4);if(!_0x14fefd['isAbsolute'])throw new SDKError(ErrorCode[_0x1a2c51(0x150)],_0x1a2c51(0x18b));return await this[_0x1a2c51(0x189)](_0x14fefd[_0x1a2c51(0x160)]);}async[a55_0x41d2ec(0x181)](_0x244ac1,_0x192e6f){const _0x28e4a0=a55_0x41d2ec,[_0x634d31,_0x4ce2a5]=await Promise['all']([this[_0x28e4a0(0x14b)](_0x244ac1),this[_0x28e4a0(0x17e)](_0x244ac1)]);if(_0x192e6f){const _0x293778=_0x634d31['filter'](_0x2f627c=>_0x2f627c[_0x28e4a0(0x198)]===_0x192e6f),_0x50cba6=_0x4ce2a5[_0x28e4a0(0x191)](_0x1b5381=>_0x1b5381[_0x28e4a0(0x155)]===_0x192e6f);return{'folders':_0x293778,'segments':_0x50cba6};}const _0x5759cb=await this[_0x28e4a0(0x17a)](_0x244ac1),_0x1e39eb=_0x5759cb['rootFolderId'];if(_0x1e39eb){const _0x3edf31=_0x634d31['filter'](_0x12d08d=>_0x12d08d['parentFolderId']===_0x1e39eb),_0x37b2b4=_0x4ce2a5[_0x28e4a0(0x191)](_0x85b276=>_0x85b276[_0x28e4a0(0x155)]===_0x1e39eb);return{'folders':_0x3edf31,'segments':_0x37b2b4};}const _0x57078e=_0x634d31[_0x28e4a0(0x191)](_0x3b5e65=>!_0x3b5e65['parentFolderId']),_0x26e268=_0x4ce2a5[_0x28e4a0(0x191)](_0x3e990d=>!_0x3e990d[_0x28e4a0(0x155)]);return{'folders':_0x57078e,'segments':_0x26e268};}async[a55_0x41d2ec(0x196)](_0x3e53c5,_0x3819f8,_0x120416=0x0,_0x4fe4f2=0xa){const _0x2af191=a55_0x41d2ec;if(_0x120416>=_0x4fe4f2)throw new SDKError(ErrorCode[_0x2af191(0x150)],_0x2af191(0x19d)+_0x4fe4f2+_0x2af191(0x169));const {folders:_0x7c8980,segments:_0x4c1085}=await this[_0x2af191(0x181)](_0x3e53c5,_0x3819f8),_0x1cdb4c=[];for(const _0x5489fc of _0x7c8980){const _0x4fc865=await this[_0x2af191(0x196)](_0x3e53c5,_0x5489fc['id'],_0x120416+0x1,_0x4fe4f2);_0x1cdb4c[_0x2af191(0x193)]({'type':_0x2af191(0x184),'id':_0x5489fc['id'],'name':_0x5489fc[_0x2af191(0x199)],'children':_0x4fc865['length']>0x0?_0x4fc865:undefined,'metadata':{'description':_0x5489fc[_0x2af191(0x143)]||undefined,'folderCount':_0x4fc865['filter'](_0x5f2b77=>_0x5f2b77['type']===_0x2af191(0x184))[_0x2af191(0x18e)],'segmentCount':_0x4fc865[_0x2af191(0x191)](_0x1e5250=>_0x1e5250[_0x2af191(0x15a)]===_0x2af191(0x17f))['length'],'createdAt':_0x5489fc[_0x2af191(0x158)],'updatedAt':_0x5489fc[_0x2af191(0x18a)]}});}for(const _0xb2dcd6 of _0x4c1085){_0x1cdb4c[_0x2af191(0x193)]({'type':'segment','id':_0xb2dcd6['id'],'name':_0xb2dcd6[_0x2af191(0x199)],'population':_0xb2dcd6[_0x2af191(0x175)],'metadata':{'description':_0xb2dcd6['description'],'createdAt':_0xb2dcd6[_0x2af191(0x158)],'updatedAt':_0xb2dcd6[_0x2af191(0x18a)]}});}return _0x1cdb4c;}}
|
package/dist/sdk/workflow.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a56_0x1afff0=a56_0x1b34;(function(_0x4dece7,_0x1d8207){const _0x915943=a56_0x1b34,_0xadb515=_0x4dece7();while(!![]){try{const _0x2e7a06=parseInt(_0x915943(0x171))/0x1*(parseInt(_0x915943(0x129))/0x2)+parseInt(_0x915943(0x114))/0x3+-parseInt(_0x915943(0x175))/0x4*(parseInt(_0x915943(0x119))/0x5)+parseInt(_0x915943(0x17a))/0x6*(-parseInt(_0x915943(0x156))/0x7)+-parseInt(_0x915943(0x11a))/0x8+parseInt(_0x915943(0x161))/0x9*(-parseInt(_0x915943(0x177))/0xa)+parseInt(_0x915943(0x145))/0xb;if(_0x2e7a06===_0x1d8207)break;else _0xadb515['push'](_0xadb515['shift']());}catch(_0x145072){_0xadb515['push'](_0xadb515['shift']());}}}(a56_0x552a,0x53cb8));import{WorkflowApiClient}from'../client/workflow-client.js';import{shouldIncludeInArchive,WORKFLOW_FILE_EXTENSION}from'../utils/workflow-utils.js';function a56_0x1b34(_0x3a39a5,_0x3cf6c0){const _0x552a0b=a56_0x552a();return a56_0x1b34=function(_0x1b3421,_0x4660cd){_0x1b3421=_0x1b3421-0x111;let _0x3f193b=_0x552a0b[_0x1b3421];return _0x3f193b;},a56_0x1b34(_0x3a39a5,_0x3cf6c0);}export class WorkflowSDK{static [a56_0x1afff0(0x14e)]=/^\d+$/;[a56_0x1afff0(0x179)];constructor(_0xeb452e){const _0x8523fb=a56_0x1afff0;this[_0x8523fb(0x179)]=new WorkflowApiClient(_0xeb452e,_0xeb452e['logger']);}async[a56_0x1afff0(0x165)](_0x948e2f){const _0x4051d4=a56_0x1afff0;if(WorkflowSDK[_0x4051d4(0x14e)]['test'](_0x948e2f))return{'id':_0x948e2f,'name':_0x948e2f};const _0x32a3a7=await this[_0x4051d4(0x179)]['listProjects']({'name_pattern':_0x948e2f}),_0x2a8f2b=_0x32a3a7[_0x4051d4(0x13b)][_0x4051d4(0x13e)](_0x484ba4=>_0x484ba4[_0x4051d4(0x152)]===_0x948e2f);if(!_0x2a8f2b)throw new Error(_0x4051d4(0x15c)+_0x948e2f);return{'id':_0x2a8f2b['id'],'name':_0x2a8f2b[_0x4051d4(0x152)]};}async['projects'](_0x1468cb,_0x552fd3){const _0x5152c0=a56_0x1afff0,_0x29b422=await this[_0x5152c0(0x179)][_0x5152c0(0x112)]({'name_pattern':_0x1468cb,..._0x552fd3});return _0x29b422[_0x5152c0(0x13b)]['map'](_0x18451f=>({..._0x18451f,'project_id':_0x18451f['id'],'project_name':_0x18451f[_0x5152c0(0x152)]}));}async[a56_0x1afff0(0x136)](_0x359f3a,_0x54ce30){const _0x281d6c=a56_0x1afff0,_0x49eee2=await this[_0x281d6c(0x179)][_0x281d6c(0x12d)]({'project_name':_0x359f3a,..._0x54ce30});return _0x49eee2[_0x281d6c(0x13b)][_0x281d6c(0x144)](_0x393a9c=>({'project_id':_0x393a9c['project']?.['id'],'project_name':_0x393a9c[_0x281d6c(0x132)]?.[_0x281d6c(0x152)],'workflow_id':_0x393a9c['id'],'workflow_name':_0x393a9c['name'],'revision':_0x393a9c[_0x281d6c(0x172)],'timezone':_0x393a9c['timezone'],'config':_0x393a9c['config'],'id':_0x393a9c['id'],'name':_0x393a9c[_0x281d6c(0x152)],'project':_0x393a9c[_0x281d6c(0x132)]}));}async[a56_0x1afff0(0x134)](_0x12dd39){const _0x59a6aa=a56_0x1afff0;let _0x270e32;if(_0x12dd39?.[_0x59a6aa(0x142)]){let _0x184820,_0x586f2b=![];while(!_0x586f2b){const _0x99c8bb=await this['client'][_0x59a6aa(0x112)]({'limit':0x64,'last_id':_0x184820}),_0x3c62db=_0x99c8bb[_0x59a6aa(0x13b)][_0x59a6aa(0x13e)](_0x3214d3=>_0x3214d3[_0x59a6aa(0x152)]===_0x12dd39[_0x59a6aa(0x142)]);if(_0x3c62db){_0x270e32=_0x3c62db['id'],_0x586f2b=!![];break;}if(!_0x99c8bb[_0x59a6aa(0x146)]||_0x99c8bb['data'][_0x59a6aa(0x16f)]===0x0)break;_0x184820=_0x99c8bb['lastId'];}if(!_0x270e32)throw new Error('Project\x20not\x20found:\x20'+_0x12dd39[_0x59a6aa(0x142)]);}const _0x355159=await this['client']['listSessions']({'project_id':_0x270e32,'project_name':_0x12dd39?.[_0x59a6aa(0x142)],'workflow_name':_0x12dd39?.[_0x59a6aa(0x12f)],'status':_0x12dd39?.[_0x59a6aa(0x11f)],'from_time':_0x12dd39?.['fromTime'],'to_time':_0x12dd39?.['toTime'],'limit':_0x12dd39?.[_0x59a6aa(0x141)],'last_id':_0x12dd39?.[_0x59a6aa(0x15e)]});return _0x355159[_0x59a6aa(0x13b)]['map'](_0x4cb8d6=>({'project_id':_0x4cb8d6['project']?.['id'],'project_name':_0x4cb8d6[_0x59a6aa(0x132)]?.['name'],'workflow_id':_0x4cb8d6[_0x59a6aa(0x17b)]?.['id'],'workflow_name':_0x4cb8d6[_0x59a6aa(0x17b)]?.[_0x59a6aa(0x152)],'session_id':_0x4cb8d6['id'],'sessionUuid':_0x4cb8d6[_0x59a6aa(0x138)],'sessionTime':_0x4cb8d6[_0x59a6aa(0x16e)],'lastAttempt':_0x4cb8d6[_0x59a6aa(0x15b)],'id':_0x4cb8d6['id'],'project':_0x4cb8d6['project'],'workflow':_0x4cb8d6[_0x59a6aa(0x17b)]}));}async[a56_0x1afff0(0x135)](_0x5acbf1){const _0x4fd0a8=a56_0x1afff0,_0x517d04=await this[_0x4fd0a8(0x179)][_0x4fd0a8(0x16c)]({'project_name':_0x5acbf1?.[_0x4fd0a8(0x142)],'workflow_name':_0x5acbf1?.[_0x4fd0a8(0x12f)],'include_retried':_0x5acbf1?.[_0x4fd0a8(0x125)],'limit':_0x5acbf1?.[_0x4fd0a8(0x141)],'last_id':_0x5acbf1?.[_0x4fd0a8(0x15e)]});return _0x517d04[_0x4fd0a8(0x13b)]['map'](_0x377327=>({'project_id':_0x377327['project']?.['id'],'project_name':_0x377327[_0x4fd0a8(0x132)]?.[_0x4fd0a8(0x152)],'workflow_id':_0x377327[_0x4fd0a8(0x17b)]?.['id'],'workflow_name':_0x377327[_0x4fd0a8(0x17b)]?.[_0x4fd0a8(0x152)],'session_id':_0x377327['sessionId'],'sessionUuid':_0x377327[_0x4fd0a8(0x138)],'sessionTime':_0x377327[_0x4fd0a8(0x16e)],'attempt_id':_0x377327['id'],'attempt_index':_0x377327[_0x4fd0a8(0x16d)],'retryAttemptName':_0x377327['retryAttemptName'],'done':_0x377327[_0x4fd0a8(0x14b)],'success':_0x377327[_0x4fd0a8(0x121)],'cancelRequested':_0x377327[_0x4fd0a8(0x169)],'params':_0x377327[_0x4fd0a8(0x162)],'createdAt':_0x377327['createdAt'],'finishedAt':_0x377327[_0x4fd0a8(0x13a)],'id':_0x377327['id'],'index':_0x377327[_0x4fd0a8(0x16d)],'project':_0x377327[_0x4fd0a8(0x132)],'workflow':_0x377327[_0x4fd0a8(0x17b)]}));}async[a56_0x1afff0(0x15a)](_0x20c2ab){const _0x14746e=a56_0x1afff0,_0x5f04e1=await this[_0x14746e(0x179)][_0x14746e(0x166)](_0x20c2ab);return _0x5f04e1;}async[a56_0x1afff0(0x12c)](_0xb5b017,_0x1a9527=![]){const _0x569467=a56_0x1afff0,_0x275e83=await this[_0x569467(0x179)][_0x569467(0x133)](_0xb5b017,_0x1a9527);return _0x275e83['map'](_0x3bec1f=>({'task_id':_0x3bec1f['id'],'task_name':_0x3bec1f['fullName'],'parentId':_0x3bec1f[_0x569467(0x120)],'config':_0x3bec1f[_0x569467(0x143)],'upstreams':_0x3bec1f[_0x569467(0x157)],'state':_0x3bec1f[_0x569467(0x123)],'exportParams':_0x3bec1f['exportParams'],'storeParams':_0x3bec1f[_0x569467(0x11b)],'stateParams':_0x3bec1f['stateParams'],'updatedAt':_0x3bec1f[_0x569467(0x131)],'retryAt':_0x3bec1f['retryAt'],'startedAt':_0x3bec1f[_0x569467(0x15f)],'error':_0x3bec1f[_0x569467(0x122)],'isGroup':_0x3bec1f[_0x569467(0x153)],'id':_0x3bec1f['id'],'fullName':_0x3bec1f[_0x569467(0x126)]}));}async[a56_0x1afff0(0x176)](_0x2852dc,_0x498fb1){const _0x4c53f2=a56_0x1afff0;return await this[_0x4c53f2(0x179)]['listLogFiles'](_0x2852dc,_0x498fb1);}async[a56_0x1afff0(0x14c)](_0x522166,_0x4522d5){const _0x5c4313=a56_0x1afff0,_0x3d1ce4=await import(_0x5c4313(0x14d)),{promisify:_0x171b98}=await import('util'),_0xb7983a=_0x171b98(_0x3d1ce4[_0x5c4313(0x11d)]),_0x21fcf0=await this[_0x5c4313(0x179)][_0x5c4313(0x163)](_0x522166,_0x4522d5);if(_0x21fcf0[_0x5c4313(0x16f)]===0x0)return'';const _0x4ee455=[];for(const _0x20de59 of _0x21fcf0){if(!_0x20de59[_0x5c4313(0x16b)])continue;const _0x9bfd2f=await fetch(_0x20de59[_0x5c4313(0x16b)]);if(!_0x9bfd2f['ok'])throw new Error('Failed\x20to\x20download\x20log\x20file:\x20'+_0x9bfd2f['status']);const _0x26ba70=Buffer[_0x5c4313(0x12a)](await _0x9bfd2f[_0x5c4313(0x140)]()),_0xb4dc1e=await _0xb7983a(_0x26ba70);_0x4ee455[_0x5c4313(0x14a)](_0xb4dc1e['toString'](_0x5c4313(0x174)));}return _0x4ee455[_0x5c4313(0x13d)]('\x0a');}async[a56_0x1afff0(0x127)](_0x592507,_0x17c231){const _0x3dd4b5=a56_0x1afff0,_0x2bc09b=await this[_0x3dd4b5(0x179)][_0x3dd4b5(0x11e)](_0x592507,_0x17c231);return _0x2bc09b[_0x3dd4b5(0x11c)];}async[a56_0x1afff0(0x150)](_0xdef1eb,_0x3ec743){const _0x2bb23a=a56_0x1afff0,_0x3ece98=await this[_0x2bb23a(0x179)][_0x2bb23a(0x150)](_0xdef1eb,{'from_task':_0x3ec743?.['fromTask'],'retry_params':_0x3ec743?.[_0x2bb23a(0x12b)]});return{'attemptId':_0x3ece98['id'],'sessionId':_0x3ece98[_0x2bb23a(0x164)]};}async[a56_0x1afff0(0x155)](_0x478a91,_0x100916){const _0x5c6390=a56_0x1afff0,_0x1de715=await this['client'][_0x5c6390(0x155)](_0x478a91,{'resume_from':_0x100916?.[_0x5c6390(0x115)],'retry_params':_0x100916?.[_0x5c6390(0x12b)],'force':_0x100916?.['force']});return{'attemptId':_0x1de715['id'],'sessionId':_0x1de715['sessionId']};}async['run'](_0x153d53,_0x12e209={},_0xb7e85c){const _0x1d0112=a56_0x1afff0,_0x548363=_0x153d53['indexOf']('.');let _0xd798a9,_0x10c681;if(_0x548363===-0x1)throw new Error(_0x1d0112(0x15d));_0xd798a9=_0x153d53['substring'](0x0,_0x548363),_0x10c681=_0x153d53[_0x1d0112(0x149)](_0x548363+0x1);if(!_0xd798a9||!_0x10c681)throw new Error('Invalid\x20workflow\x20format:\x20'+_0x153d53+_0x1d0112(0x148));const _0x400c37=_0xb7e85c?.[_0x1d0112(0x16e)]||new Date()[_0x1d0112(0x147)]();return await this['client']['startAttempt']({'projectName':_0xd798a9,'workflowName':_0x10c681,'sessionTime':_0x400c37,'params':_0x12e209});}async['download'](_0x41cb3a,_0x211974,_0x12c679){const _0x5a754f=a56_0x1afff0,{promises:_0x463b2b}=await import('fs'),_0x4bcead=await import(_0x5a754f(0x13f)),_0x19a152=await import('os'),_0x2319fd=await import('tar'),{id:_0x20c5db,name:_0x2c888d}=await this[_0x5a754f(0x165)](_0x41cb3a),_0x1aa36d=_0x19a152['tmpdir'](),_0x1207a8=_0x4bcead[_0x5a754f(0x13d)](_0x1aa36d,_0x5a754f(0x14f)+_0x20c5db+'-'+Date['now']()+_0x5a754f(0x113));try{await this[_0x5a754f(0x179)][_0x5a754f(0x168)](_0x20c5db,_0x1207a8,_0x12c679?.[_0x5a754f(0x172)]);const _0x14e7e5=_0x4bcead[_0x5a754f(0x13d)](_0x211974,_0x2c888d);await _0x463b2b[_0x5a754f(0x178)](_0x14e7e5,{'recursive':!![]}),await _0x2319fd['extract']({'file':_0x1207a8,'cwd':_0x14e7e5,'gzip':!![]});const _0x6b60ac=async _0x561c7c=>{const _0x35724a=_0x5a754f;let _0x5ba957=0x0;const _0x2d9865=await _0x463b2b['readdir'](_0x561c7c,{'withFileTypes':!![]});for(const _0x1b0880 of _0x2d9865){const _0x2f529b=_0x4bcead[_0x35724a(0x13d)](_0x561c7c,_0x1b0880[_0x35724a(0x152)]);if(_0x1b0880['isFile']())_0x5ba957++;else _0x1b0880[_0x35724a(0x160)]()&&(_0x5ba957+=await _0x6b60ac(_0x2f529b));}return _0x5ba957;},_0x3b03e4=await _0x6b60ac(_0x14e7e5);return{'projectName':_0x2c888d,'revision':_0x12c679?.[_0x5a754f(0x172)]||_0x5a754f(0x130),'filesExtracted':_0x3b03e4};}finally{try{await _0x463b2b[_0x5a754f(0x16a)](_0x1207a8);}catch{}}}async[a56_0x1afff0(0x14a)](_0x36d3f2,_0x1bbcfb){const _0x202d28=a56_0x1afff0,{promises:_0x2d5ce4}=await import('fs'),_0x3e4065=await import(_0x202d28(0x13f)),_0x7f7641=await import(_0x202d28(0x118)),_0x5e4f96=_0x1bbcfb?.[_0x202d28(0x142)]||_0x3e4065[_0x202d28(0x117)](_0x36d3f2),_0x52d6a7=_0x1bbcfb?.['revision']||new Date()['toISOString']()[_0x202d28(0x13c)](/[:.]/g,'-');try{await _0x2d5ce4[_0x202d28(0x124)](_0x36d3f2);}catch{throw new Error(_0x202d28(0x137)+_0x36d3f2);}if(!_0x1bbcfb?.[_0x202d28(0x159)]){const _0x5a0440=await _0x2d5ce4['readdir'](_0x36d3f2),_0x225c30=_0x5a0440[_0x202d28(0x128)](_0x363959=>_0x363959[_0x202d28(0x170)](WORKFLOW_FILE_EXTENSION));if(_0x225c30[_0x202d28(0x16f)]===0x0)throw new Error('No\x20'+WORKFLOW_FILE_EXTENSION+_0x202d28(0x111));for(const _0x1bfae7 of _0x225c30){const _0x410c15=_0x3e4065[_0x202d28(0x13d)](_0x36d3f2,_0x1bfae7);try{await _0x2d5ce4[_0x202d28(0x124)](_0x410c15);}catch{throw new Error(_0x202d28(0x173)+_0x1bfae7);}}}const _0x45048a=async(_0x39e6c9,_0x442a1d='')=>{const _0x2042c4=_0x202d28,_0x87ec1=await _0x2d5ce4[_0x2042c4(0x154)](_0x39e6c9,{'withFileTypes':!![]}),_0x42e051=[];for(const _0x934a5d of _0x87ec1){const _0x4e5bdd=_0x3e4065['join'](_0x442a1d,_0x934a5d[_0x2042c4(0x152)]),_0x6c2876=_0x3e4065[_0x2042c4(0x13d)](_0x39e6c9,_0x934a5d[_0x2042c4(0x152)]);if(!shouldIncludeInArchive(_0x934a5d[_0x2042c4(0x152)]))continue;_0x934a5d[_0x2042c4(0x160)]()?_0x42e051[_0x2042c4(0x14a)](...await _0x45048a(_0x6c2876,_0x4e5bdd)):_0x42e051[_0x2042c4(0x14a)](_0x4e5bdd);}return _0x42e051;},_0x5f19d7=await _0x45048a(_0x36d3f2),_0x2d6dc9=await import('os'),_0x3edb53=_0x2d6dc9[_0x202d28(0x158)](),_0x3e8289=_0x3e4065[_0x202d28(0x13d)](_0x3edb53,'tdx-workflow-push-'+Date[_0x202d28(0x12e)]()+_0x202d28(0x113));try{await _0x7f7641[_0x202d28(0x116)]({'file':_0x3e8289,'gzip':!![],'cwd':_0x36d3f2,'portable':!![]},_0x5f19d7);const _0x505030=await this[_0x202d28(0x179)][_0x202d28(0x139)](_0x5e4f96,_0x52d6a7,_0x3e8289,{'scheduleFrom':_0x1bbcfb?.[_0x202d28(0x167)],'clearSchedule':_0x1bbcfb?.['clearSchedule'],'clearScheduleAll':_0x1bbcfb?.['clearScheduleAll']});return{'projectId':_0x505030['id'],'projectName':_0x505030['name'],'revision':_0x505030['revision']};}finally{try{await _0x2d5ce4[_0x202d28(0x16a)](_0x3e8289);}catch{}}}async[a56_0x1afff0(0x151)](_0x29f391){const _0x1a9ee2=a56_0x1afff0,{id:_0x2d97d5}=await this['resolveProjectId'](_0x29f391),_0x5dd534=await this[_0x1a9ee2(0x179)]['deleteProject'](_0x2d97d5);return{'projectId':_0x5dd534['id'],'projectName':_0x5dd534['name']};}}function a56_0x552a(){const _0xd6c64=['finishedAt','data','replace','join','find','path','arrayBuffer','limit','projectName','config','map','10426900KZCnxE','lastId','toISOString','.\x20Expected\x20\x22project.workflow\x22','substring','push','done','logs','zlib','NUMERIC_ID_PATTERN','tdx-workflow-','retrySession','delete','name','isGroup','readdir','retryAttempt','7RYnsdj','upstreams','tmpdir','skipValidation','attempt','lastAttempt','Project\x20not\x20found:\x20','Workflow\x20must\x20be\x20specified\x20as\x20\x22project.workflow\x22\x20format','last_id','startedAt','isDirectory','9zSaQIH','params','listLogFiles','sessionId','resolveProjectId','getAttempt','scheduleFrom','downloadProjectArchive','cancelRequested','unlink','direct','listAttempts','index','sessionTime','length','endsWith','23emLoiZ','revision','Cannot\x20read\x20workflow\x20file:\x20','utf-8','4MWaDrH','logFiles','6407870coOXkd','mkdir','client','1083828UNzOtH','workflow','\x20workflow\x20files\x20found\x20in\x20project\x20directory','listProjects','.tar.gz','2054070GhaWpl','resumeFrom','create','basename','tar','1753685gFTOYr','5367800sEEyIC','storeParams','message','gunzip','killAttempt','status','parentId','success','error','state','access','includeRetried','fullName','kill','filter','48154oMSEtc','from','retryParams','tasks','listWorkflows','now','workflowName','latest','updatedAt','project','getAttemptTasks','sessions','attempts','workflows','Project\x20directory\x20not\x20found:\x20','sessionUuid','uploadProjectArchive'];a56_0x552a=function(){return _0xd6c64;};return a56_0x552a();}
|
|
1
|
+
const a56_0x2d397b=a56_0x4b3d;function a56_0x4b3d(_0xcb84ee,_0x47717a){const _0x2d0431=a56_0x2d04();return a56_0x4b3d=function(_0x4b3dad,_0x55bb8e){_0x4b3dad=_0x4b3dad-0x18a;let _0x34adf8=_0x2d0431[_0x4b3dad];return _0x34adf8;},a56_0x4b3d(_0xcb84ee,_0x47717a);}(function(_0x163b04,_0xfd32c1){const _0x5da5a1=a56_0x4b3d,_0x29390c=_0x163b04();while(!![]){try{const _0x25649d=-parseInt(_0x5da5a1(0x1e8))/0x1+-parseInt(_0x5da5a1(0x1bd))/0x2*(-parseInt(_0x5da5a1(0x1c7))/0x3)+-parseInt(_0x5da5a1(0x1f9))/0x4*(-parseInt(_0x5da5a1(0x1f6))/0x5)+-parseInt(_0x5da5a1(0x1c3))/0x6+-parseInt(_0x5da5a1(0x1ed))/0x7+-parseInt(_0x5da5a1(0x1f4))/0x8*(parseInt(_0x5da5a1(0x1c9))/0x9)+parseInt(_0x5da5a1(0x1b3))/0xa;if(_0x25649d===_0xfd32c1)break;else _0x29390c['push'](_0x29390c['shift']());}catch(_0x4dee0b){_0x29390c['push'](_0x29390c['shift']());}}}(a56_0x2d04,0x9afc9));import{WorkflowApiClient}from'../client/workflow-client.js';import{shouldIncludeInArchive,WORKFLOW_FILE_EXTENSION}from'../utils/workflow-utils.js';function a56_0x2d04(){const _0x264230=['33272utZIHD','listLogFiles','880ZshSNh','clearSchedule','Failed\x20to\x20download\x20log\x20file:\x20','25392fFuFkL','state','push','toString','path','tdx-workflow-','isDirectory','sessions','length','finishedAt','sessionUuid','sessionId','from','toTime','parentId','scheduleFrom','lastId','cancelRequested','workflow','updatedAt','getAttemptTasks','downloadProjectArchive','kill','logFiles','index','done','map','lastAttempt','uploadProjectArchive','listAttempts','sessionTime','retryAt','substring','createdAt','tasks','Invalid\x20workflow\x20format:\x20','startAttempt','logs','attempts','tar','gunzip','projects','replace','latest','26903800Nnbevm','workflows','config','resumeFrom','revision','force','project','now','test','skipValidation','482PnzXGz','Project\x20directory\x20not\x20found:\x20','No\x20','.tar.gz','readdir','tmpdir','6203670VxfIoA','unlink','Cannot\x20read\x20workflow\x20file:\x20','clearScheduleAll','2589DIEhNd','projectName','2745vrrWGA','last_id','timezone','arrayBuffer','filter','retrySession','message','client','indexOf','toISOString','find','.\x20Expected\x20\x22project.workflow\x22','status','isFile','tdx-workflow-push-','fullName','direct','isGroup','retryParams','create','delete','upstreams','retryAttempt','listProjects','params','includeRetried','storeParams','workflowName','download','startedAt','data','512352cNebEc','error','extract','getAttempt','join','3961958WsVdEy','Project\x20not\x20found:\x20','name','NUMERIC_ID_PATTERN','resolveProjectId','Workflow\x20must\x20be\x20specified\x20as\x20\x22project.workflow\x22\x20format','limit'];a56_0x2d04=function(){return _0x264230;};return a56_0x2d04();}export class WorkflowSDK{static [a56_0x2d397b(0x1f0)]=/^\d+$/;[a56_0x2d397b(0x1d0)];constructor(_0x5e54a0){const _0x533686=a56_0x2d397b;this[_0x533686(0x1d0)]=new WorkflowApiClient(_0x5e54a0,_0x5e54a0['logger']);}async['resolveProjectId'](_0xb01e0e){const _0x1375f9=a56_0x2d397b;if(WorkflowSDK[_0x1375f9(0x1f0)][_0x1375f9(0x1bb)](_0xb01e0e))return{'id':_0xb01e0e,'name':_0xb01e0e};const _0x1bbbcb=await this[_0x1375f9(0x1d0)][_0x1375f9(0x1e0)]({'name_pattern':_0xb01e0e}),_0x1c3fcf=_0x1bbbcb[_0x1375f9(0x1e7)][_0x1375f9(0x1d3)](_0x21c7a4=>_0x21c7a4[_0x1375f9(0x1ef)]===_0xb01e0e);if(!_0x1c3fcf)throw new Error(_0x1375f9(0x1ee)+_0xb01e0e);return{'id':_0x1c3fcf['id'],'name':_0x1c3fcf[_0x1375f9(0x1ef)]};}async[a56_0x2d397b(0x1b0)](_0x34cd99,_0x5886ef){const _0x2e4c4e=a56_0x2d397b,_0x179f64=await this[_0x2e4c4e(0x1d0)][_0x2e4c4e(0x1e0)]({'name_pattern':_0x34cd99,..._0x5886ef});return _0x179f64[_0x2e4c4e(0x1e7)][_0x2e4c4e(0x1a1)](_0x4e235e=>({..._0x4e235e,'project_id':_0x4e235e['id'],'project_name':_0x4e235e[_0x2e4c4e(0x1ef)]}));}async[a56_0x2d397b(0x1b4)](_0x9137ef,_0x418d8a){const _0x282db5=a56_0x2d397b,_0x5aa083=await this[_0x282db5(0x1d0)]['listWorkflows']({'project_name':_0x9137ef,..._0x418d8a});return _0x5aa083[_0x282db5(0x1e7)][_0x282db5(0x1a1)](_0x564ba3=>({'project_id':_0x564ba3[_0x282db5(0x1b9)]?.['id'],'project_name':_0x564ba3['project']?.[_0x282db5(0x1ef)],'workflow_id':_0x564ba3['id'],'workflow_name':_0x564ba3[_0x282db5(0x1ef)],'revision':_0x564ba3[_0x282db5(0x1b7)],'timezone':_0x564ba3[_0x282db5(0x1cb)],'config':_0x564ba3[_0x282db5(0x1b5)],'id':_0x564ba3['id'],'name':_0x564ba3[_0x282db5(0x1ef)],'project':_0x564ba3[_0x282db5(0x1b9)]}));}async[a56_0x2d397b(0x18e)](_0x1153ce){const _0x380adc=a56_0x2d397b;let _0x4df240;if(_0x1153ce?.[_0x380adc(0x1c8)]){let _0xc8ef39,_0x173f77=![];while(!_0x173f77){const _0x15b993=await this[_0x380adc(0x1d0)][_0x380adc(0x1e0)]({'limit':0x64,'last_id':_0xc8ef39}),_0x4f9840=_0x15b993['data'][_0x380adc(0x1d3)](_0x48c302=>_0x48c302[_0x380adc(0x1ef)]===_0x1153ce[_0x380adc(0x1c8)]);if(_0x4f9840){_0x4df240=_0x4f9840['id'],_0x173f77=!![];break;}if(!_0x15b993[_0x380adc(0x197)]||_0x15b993[_0x380adc(0x1e7)][_0x380adc(0x18f)]===0x0)break;_0xc8ef39=_0x15b993[_0x380adc(0x197)];}if(!_0x4df240)throw new Error('Project\x20not\x20found:\x20'+_0x1153ce[_0x380adc(0x1c8)]);}const _0x37fb43=await this[_0x380adc(0x1d0)]['listSessions']({'project_id':_0x4df240,'project_name':_0x1153ce?.['projectName'],'workflow_name':_0x1153ce?.[_0x380adc(0x1e4)],'status':_0x1153ce?.[_0x380adc(0x1d5)],'from_time':_0x1153ce?.['fromTime'],'to_time':_0x1153ce?.[_0x380adc(0x194)],'limit':_0x1153ce?.[_0x380adc(0x1f3)],'last_id':_0x1153ce?.[_0x380adc(0x1ca)]});return _0x37fb43[_0x380adc(0x1e7)][_0x380adc(0x1a1)](_0x366c6e=>({'project_id':_0x366c6e[_0x380adc(0x1b9)]?.['id'],'project_name':_0x366c6e[_0x380adc(0x1b9)]?.[_0x380adc(0x1ef)],'workflow_id':_0x366c6e['workflow']?.['id'],'workflow_name':_0x366c6e[_0x380adc(0x199)]?.[_0x380adc(0x1ef)],'session_id':_0x366c6e['id'],'sessionUuid':_0x366c6e[_0x380adc(0x191)],'sessionTime':_0x366c6e[_0x380adc(0x1a5)],'lastAttempt':_0x366c6e[_0x380adc(0x1a2)],'id':_0x366c6e['id'],'project':_0x366c6e[_0x380adc(0x1b9)],'workflow':_0x366c6e[_0x380adc(0x199)]}));}async[a56_0x2d397b(0x1ad)](_0x5002c7){const _0x24931d=a56_0x2d397b,_0x457948=await this[_0x24931d(0x1d0)][_0x24931d(0x1a4)]({'project_name':_0x5002c7?.[_0x24931d(0x1c8)],'workflow_name':_0x5002c7?.[_0x24931d(0x1e4)],'include_retried':_0x5002c7?.[_0x24931d(0x1e2)],'limit':_0x5002c7?.[_0x24931d(0x1f3)],'last_id':_0x5002c7?.[_0x24931d(0x1ca)]});return _0x457948[_0x24931d(0x1e7)][_0x24931d(0x1a1)](_0x4e7f67=>({'project_id':_0x4e7f67[_0x24931d(0x1b9)]?.['id'],'project_name':_0x4e7f67['project']?.['name'],'workflow_id':_0x4e7f67['workflow']?.['id'],'workflow_name':_0x4e7f67[_0x24931d(0x199)]?.['name'],'session_id':_0x4e7f67[_0x24931d(0x192)],'sessionUuid':_0x4e7f67[_0x24931d(0x191)],'sessionTime':_0x4e7f67[_0x24931d(0x1a5)],'attempt_id':_0x4e7f67['id'],'attempt_index':_0x4e7f67[_0x24931d(0x19f)],'retryAttemptName':_0x4e7f67['retryAttemptName'],'done':_0x4e7f67[_0x24931d(0x1a0)],'success':_0x4e7f67['success'],'cancelRequested':_0x4e7f67[_0x24931d(0x198)],'params':_0x4e7f67[_0x24931d(0x1e1)],'createdAt':_0x4e7f67[_0x24931d(0x1a8)],'finishedAt':_0x4e7f67[_0x24931d(0x190)],'id':_0x4e7f67['id'],'index':_0x4e7f67[_0x24931d(0x19f)],'project':_0x4e7f67[_0x24931d(0x1b9)],'workflow':_0x4e7f67['workflow']}));}async['attempt'](_0xcf4c7a){const _0x1a4253=a56_0x2d397b,_0x3dc4c1=await this[_0x1a4253(0x1d0)][_0x1a4253(0x1eb)](_0xcf4c7a);return _0x3dc4c1;}async[a56_0x2d397b(0x1a9)](_0x17d2e8,_0x3f3d4c=![]){const _0xe672e4=a56_0x2d397b,_0x141b04=await this[_0xe672e4(0x1d0)][_0xe672e4(0x19b)](_0x17d2e8,_0x3f3d4c);return _0x141b04[_0xe672e4(0x1a1)](_0x530df7=>({'task_id':_0x530df7['id'],'task_name':_0x530df7[_0xe672e4(0x1d8)],'parentId':_0x530df7[_0xe672e4(0x195)],'config':_0x530df7[_0xe672e4(0x1b5)],'upstreams':_0x530df7[_0xe672e4(0x1de)],'state':_0x530df7[_0xe672e4(0x1fa)],'exportParams':_0x530df7['exportParams'],'storeParams':_0x530df7[_0xe672e4(0x1e3)],'stateParams':_0x530df7['stateParams'],'updatedAt':_0x530df7[_0xe672e4(0x19a)],'retryAt':_0x530df7[_0xe672e4(0x1a6)],'startedAt':_0x530df7[_0xe672e4(0x1e6)],'error':_0x530df7[_0xe672e4(0x1e9)],'isGroup':_0x530df7[_0xe672e4(0x1da)],'id':_0x530df7['id'],'fullName':_0x530df7[_0xe672e4(0x1d8)]}));}async[a56_0x2d397b(0x19e)](_0x2f521a,_0x17a617){const _0x40d815=a56_0x2d397b;return await this[_0x40d815(0x1d0)]['listLogFiles'](_0x2f521a,_0x17a617);}async[a56_0x2d397b(0x1ac)](_0x4575fa,_0x4804d2){const _0x2cb2c3=a56_0x2d397b,_0x18c616=await import('zlib'),{promisify:_0xbf83e5}=await import('util'),_0x1e35a5=_0xbf83e5(_0x18c616[_0x2cb2c3(0x1af)]),_0xb2ac76=await this[_0x2cb2c3(0x1d0)][_0x2cb2c3(0x1f5)](_0x4575fa,_0x4804d2);if(_0xb2ac76['length']===0x0)return'';const _0x3eb5bc=[];for(const _0x2106a4 of _0xb2ac76){if(!_0x2106a4[_0x2cb2c3(0x1d9)])continue;const _0x42eee4=await fetch(_0x2106a4[_0x2cb2c3(0x1d9)]);if(!_0x42eee4['ok'])throw new Error(_0x2cb2c3(0x1f8)+_0x42eee4[_0x2cb2c3(0x1d5)]);const _0x55c4ce=Buffer[_0x2cb2c3(0x193)](await _0x42eee4[_0x2cb2c3(0x1cc)]()),_0xdf9e5f=await _0x1e35a5(_0x55c4ce);_0x3eb5bc[_0x2cb2c3(0x1fb)](_0xdf9e5f[_0x2cb2c3(0x18a)]('utf-8'));}return _0x3eb5bc[_0x2cb2c3(0x1ec)]('\x0a');}async[a56_0x2d397b(0x19d)](_0x45ae72,_0x2ab238){const _0x12e59f=a56_0x2d397b,_0x1fc3d6=await this[_0x12e59f(0x1d0)]['killAttempt'](_0x45ae72,_0x2ab238);return _0x1fc3d6[_0x12e59f(0x1cf)];}async[a56_0x2d397b(0x1ce)](_0x239941,_0x3a5025){const _0x2518c3=a56_0x2d397b,_0x510d89=await this['client'][_0x2518c3(0x1ce)](_0x239941,{'from_task':_0x3a5025?.['fromTask'],'retry_params':_0x3a5025?.[_0x2518c3(0x1db)]});return{'attemptId':_0x510d89['id'],'sessionId':_0x510d89[_0x2518c3(0x192)]};}async['retryAttempt'](_0x15995b,_0x2446c4){const _0x3d1990=a56_0x2d397b,_0x20b54d=await this[_0x3d1990(0x1d0)][_0x3d1990(0x1df)](_0x15995b,{'resume_from':_0x2446c4?.[_0x3d1990(0x1b6)],'retry_params':_0x2446c4?.[_0x3d1990(0x1db)],'force':_0x2446c4?.[_0x3d1990(0x1b8)]});return{'attemptId':_0x20b54d['id'],'sessionId':_0x20b54d[_0x3d1990(0x192)]};}async['run'](_0x3ed843,_0x3ee783={},_0x50bc2c){const _0x20b458=a56_0x2d397b,_0x406c6a=_0x3ed843[_0x20b458(0x1d1)]('.');let _0x5bc393,_0x56ad53;if(_0x406c6a===-0x1)throw new Error(_0x20b458(0x1f2));_0x5bc393=_0x3ed843[_0x20b458(0x1a7)](0x0,_0x406c6a),_0x56ad53=_0x3ed843[_0x20b458(0x1a7)](_0x406c6a+0x1);if(!_0x5bc393||!_0x56ad53)throw new Error(_0x20b458(0x1aa)+_0x3ed843+_0x20b458(0x1d4));const _0x2456b1=_0x50bc2c?.[_0x20b458(0x1a5)]||new Date()[_0x20b458(0x1d2)]();return await this[_0x20b458(0x1d0)][_0x20b458(0x1ab)]({'projectName':_0x5bc393,'workflowName':_0x56ad53,'sessionTime':_0x2456b1,'params':_0x3ee783});}async[a56_0x2d397b(0x1e5)](_0x128136,_0x552985,_0x1ba36c){const _0x55762b=a56_0x2d397b,{promises:_0x35aeed}=await import('fs'),_0x147c04=await import(_0x55762b(0x18b)),_0x45cc98=await import('os'),_0x20e705=await import(_0x55762b(0x1ae)),{id:_0x2a1d7e,name:_0x2c2b09}=await this[_0x55762b(0x1f1)](_0x128136),_0x4f3fc1=_0x45cc98['tmpdir'](),_0x504ea2=_0x147c04['join'](_0x4f3fc1,_0x55762b(0x18c)+_0x2a1d7e+'-'+Date['now']()+'.tar.gz');try{await this['client'][_0x55762b(0x19c)](_0x2a1d7e,_0x504ea2,_0x1ba36c?.[_0x55762b(0x1b7)]);const _0x11bbbe=_0x147c04[_0x55762b(0x1ec)](_0x552985,_0x2c2b09);await _0x35aeed['mkdir'](_0x11bbbe,{'recursive':!![]}),await _0x20e705[_0x55762b(0x1ea)]({'file':_0x504ea2,'cwd':_0x11bbbe,'gzip':!![]});const _0x865c66=async _0x15a7d1=>{const _0x335d25=_0x55762b;let _0x4d7003=0x0;const _0x4ac0d0=await _0x35aeed[_0x335d25(0x1c1)](_0x15a7d1,{'withFileTypes':!![]});for(const _0x37e0ec of _0x4ac0d0){const _0x14410c=_0x147c04['join'](_0x15a7d1,_0x37e0ec[_0x335d25(0x1ef)]);if(_0x37e0ec[_0x335d25(0x1d6)]())_0x4d7003++;else _0x37e0ec['isDirectory']()&&(_0x4d7003+=await _0x865c66(_0x14410c));}return _0x4d7003;},_0x54d655=await _0x865c66(_0x11bbbe);return{'projectName':_0x2c2b09,'revision':_0x1ba36c?.[_0x55762b(0x1b7)]||_0x55762b(0x1b2),'filesExtracted':_0x54d655};}finally{try{await _0x35aeed[_0x55762b(0x1c4)](_0x504ea2);}catch{}}}async[a56_0x2d397b(0x1fb)](_0x351c94,_0x41c498){const _0x5f5570=a56_0x2d397b,{promises:_0x179cdc}=await import('fs'),_0x3c82b6=await import(_0x5f5570(0x18b)),_0x4165f8=await import('tar'),_0x50d421=_0x41c498?.[_0x5f5570(0x1c8)]||_0x3c82b6['basename'](_0x351c94),_0x181aa7=_0x41c498?.[_0x5f5570(0x1b7)]||new Date()[_0x5f5570(0x1d2)]()[_0x5f5570(0x1b1)](/[:.]/g,'-');try{await _0x179cdc['access'](_0x351c94);}catch{throw new Error(_0x5f5570(0x1be)+_0x351c94);}if(!_0x41c498?.[_0x5f5570(0x1bc)]){const _0x3eef0f=await _0x179cdc['readdir'](_0x351c94),_0x5efebf=_0x3eef0f[_0x5f5570(0x1cd)](_0x54c954=>_0x54c954['endsWith'](WORKFLOW_FILE_EXTENSION));if(_0x5efebf['length']===0x0)throw new Error(_0x5f5570(0x1bf)+WORKFLOW_FILE_EXTENSION+'\x20workflow\x20files\x20found\x20in\x20project\x20directory');for(const _0xada041 of _0x5efebf){const _0x1ba37c=_0x3c82b6['join'](_0x351c94,_0xada041);try{await _0x179cdc['access'](_0x1ba37c);}catch{throw new Error(_0x5f5570(0x1c5)+_0xada041);}}}const _0x4af72d=async(_0x2548a4,_0x54c61d='')=>{const _0x4fc7df=_0x5f5570,_0x40dd3b=await _0x179cdc[_0x4fc7df(0x1c1)](_0x2548a4,{'withFileTypes':!![]}),_0x284ba3=[];for(const _0x40aee5 of _0x40dd3b){const _0x598e68=_0x3c82b6[_0x4fc7df(0x1ec)](_0x54c61d,_0x40aee5[_0x4fc7df(0x1ef)]),_0x5cd698=_0x3c82b6[_0x4fc7df(0x1ec)](_0x2548a4,_0x40aee5['name']);if(!shouldIncludeInArchive(_0x40aee5[_0x4fc7df(0x1ef)]))continue;_0x40aee5[_0x4fc7df(0x18d)]()?_0x284ba3[_0x4fc7df(0x1fb)](...await _0x4af72d(_0x5cd698,_0x598e68)):_0x284ba3['push'](_0x598e68);}return _0x284ba3;},_0x50c02f=await _0x4af72d(_0x351c94),_0x500f3c=await import('os'),_0x1bd772=_0x500f3c[_0x5f5570(0x1c2)](),_0x9b4077=_0x3c82b6['join'](_0x1bd772,_0x5f5570(0x1d7)+Date[_0x5f5570(0x1ba)]()+_0x5f5570(0x1c0));try{await _0x4165f8[_0x5f5570(0x1dc)]({'file':_0x9b4077,'gzip':!![],'cwd':_0x351c94,'portable':!![]},_0x50c02f);const _0x1922f7=await this[_0x5f5570(0x1d0)][_0x5f5570(0x1a3)](_0x50d421,_0x181aa7,_0x9b4077,{'scheduleFrom':_0x41c498?.[_0x5f5570(0x196)],'clearSchedule':_0x41c498?.[_0x5f5570(0x1f7)],'clearScheduleAll':_0x41c498?.[_0x5f5570(0x1c6)]});return{'projectId':_0x1922f7['id'],'projectName':_0x1922f7[_0x5f5570(0x1ef)],'revision':_0x1922f7[_0x5f5570(0x1b7)]};}finally{try{await _0x179cdc['unlink'](_0x9b4077);}catch{}}}async[a56_0x2d397b(0x1dd)](_0x2c8cf2){const _0x3abcf5=a56_0x2d397b,{id:_0x2f6329}=await this[_0x3abcf5(0x1f1)](_0x2c8cf2),_0x79c0ab=await this[_0x3abcf5(0x1d0)]['deleteProject'](_0x2f6329);return{'projectId':_0x79c0ab['id'],'projectName':_0x79c0ab['name']};}}
|