@tangle-network/sandbox 0.9.1-develop.20260624210934.e2730e8 → 0.9.2-develop.20260625093856.35d47c0
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/agent/index.js +1026 -1
- package/dist/auth/index.js +273 -1
- package/dist/client-BBZ7YLmq.js +2193 -0
- package/dist/collaboration/index.js +2 -1
- package/dist/collaboration-BxlfZ2Uh.js +201 -1
- package/dist/core.js +4 -1
- package/dist/errors-DZsfJUuc.js +262 -1
- package/dist/index.js +1180 -1
- package/dist/intelligence/index.js +225 -1
- package/dist/openai/index.js +1760 -1
- package/dist/sandbox-joKtQ5y3.js +4457 -0
- package/dist/session-gateway/index.js +667 -1
- package/dist/tangle/index.js +2 -1
- package/dist/tangle-DM0o66lW.js +831 -0
- package/package.json +4 -4
- package/dist/client-DFXGfX9s.js +0 -1
- package/dist/sandbox-CPwJYUuQ.js +0 -1
- package/dist/tangle-KvorROxa.js +0 -1
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "../collaboration-BxlfZ2Uh.js";
|
|
2
|
+
export { CollaborationClient, CollaborationFileBridge, buildCollaborationDocumentId, normalizeCollaborationPath, parseCollaborationDocumentId };
|
|
@@ -1 +1,201 @@
|
|
|
1
|
-
const a0_0x4da695=a0_0x2fc9;(function(_0x398254,_0x16c19f){const _0x4e0891=a0_0x2fc9,_0x50e9e1=_0x398254();while(!![]){try{const _0x5a50c1=-parseInt(_0x4e0891(0x10f))/0x1+-parseInt(_0x4e0891(0x167))/0x2*(-parseInt(_0x4e0891(0x153))/0x3)+parseInt(_0x4e0891(0x114))/0x4*(-parseInt(_0x4e0891(0x162))/0x5)+parseInt(_0x4e0891(0x169))/0x6*(-parseInt(_0x4e0891(0x14c))/0x7)+-parseInt(_0x4e0891(0x11f))/0x8+parseInt(_0x4e0891(0x116))/0x9+-parseInt(_0x4e0891(0x146))/0xa*(-parseInt(_0x4e0891(0x143))/0xb);if(_0x5a50c1===_0x16c19f)break;else _0x50e9e1['push'](_0x50e9e1['shift']());}catch(_0x4d7922){_0x50e9e1['push'](_0x50e9e1['shift']());}}}(a0_0x360c,0x2099e));import{f as a0_0x2f352d,r as a0_0x2b2912,u as a0_0x4ddaed}from'\x2e\x2f\x65\x72\x72\x6f\x72\x73\x2d\x44\x5a\x73\x66\x4a\x55\x75\x63\x2e\x6a\x73';function a0_0x360c(){const _0x1ba324=['\x44\x32\x39\x59\x41\x33\x6e\x57\x79\x77\x6e\x4c\x73\x77\x71','\x6d\x5a\x7a\x35\x79\x4b\x6a\x6e\x77\x77\x4f','\x75\x75\x58\x7a\x42\x68\x69','\x6d\x4a\x47\x31\x6d\x5a\x69\x33\x45\x4b\x7a\x78\x75\x77\x7a\x57','\x42\x4d\x76\x34\x44\x66\x62\x48\x44\x67\x47','\x7a\x67\x76\x5a\x44\x68\x6a\x56\x45\x77\x76\x4b','\x44\x78\x62\x4b\x79\x78\x72\x4c\x7a\x61','\x7a\x67\x76\x49\x42\x33\x76\x55\x79\x32\x76\x6e\x43\x57','\x73\x67\x72\x65\x42\x33\x4b','\x41\x76\x76\x6f\x7a\x4e\x61','\x44\x33\x6a\x50\x44\x67\x75','\x43\x32\x66\x32\x7a\x76\x6e\x55\x79\x78\x62\x5a\x41\x67\x39\x30','\x6d\x74\x61\x35\x6f\x64\x69\x34\x6d\x65\x39\x79\x44\x32\x7a\x36\x41\x71','\x76\x75\x50\x78\x71\x78\x61','\x43\x32\x76\x30','\x79\x32\x39\x4b\x7a\x71','\x43\x33\x76\x49\x43\x32\x6e\x59\x41\x77\x6a\x4c','\x44\x32\x39\x59\x41\x33\x6e\x57\x79\x77\x6e\x4c\x73\x77\x71\x47\x41\x78\x6d\x47\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x77\x71','\x43\x4d\x76\x5a\x42\x32\x58\x32\x7a\x75\x48\x4c\x79\x77\x72\x4c\x43\x4e\x6d','\x79\x78\x62\x57\x42\x67\x4c\x4a\x79\x78\x72\x50\x42\x32\x34\x56\x41\x4e\x6e\x56\x42\x47','\x42\x32\x35\x67\x41\x77\x58\x4c\x72\x67\x76\x53\x7a\x78\x72\x4c\x7a\x61','\x6c\x32\x66\x57\x41\x73\x39\x4a\x42\x32\x58\x53\x79\x77\x6a\x56\x43\x4d\x66\x30\x41\x77\x39\x55\x6c\x33\x72\x56\x41\x32\x76\x55','\x43\x33\x72\x59\x41\x77\x35\x4e\x41\x77\x7a\x35','\x79\x4d\x4c\x55\x7a\x61','\x42\x33\x6a\x50\x7a\x32\x4c\x55','\x71\x4b\x7a\x66\x73\x33\x61','\x42\x67\x76\x55\x7a\x33\x72\x4f','\x79\x4d\x39\x31\x42\x4d\x72\x71\x79\x78\x72\x4f','\x43\x4d\x76\x53\x79\x78\x72\x50\x44\x4d\x76\x71\x79\x78\x72\x4f\x69\x67\x4c\x5a\x69\x68\x6a\x4c\x43\x78\x76\x50\x43\x4d\x76\x4b','\x71\x77\x6a\x56\x43\x4e\x72\x66\x43\x4e\x6a\x56\x43\x47','\x79\x77\x6a\x56\x43\x4e\x71','\x7a\x67\x76\x53\x7a\x78\x72\x4c\x7a\x61','\x7a\x4e\x76\x55\x79\x33\x72\x50\x42\x32\x34','\x7a\x67\x76\x5a\x44\x68\x6a\x56\x45\x71','\x79\x4d\x66\x5a\x7a\x76\x76\x59\x42\x61','\x77\x78\x6a\x65\x73\x32\x75','\x43\x4d\x76\x4d\x43\x4d\x76\x5a\x41\x66\x72\x56\x41\x32\x76\x55','\x42\x77\x76\x30\x41\x67\x39\x4b','\x44\x77\x35\x5a\x44\x77\x6a\x5a\x79\x33\x6a\x50\x79\x4d\x76\x65\x42\x32\x6e\x31\x42\x77\x76\x55\x44\x61','\x44\x67\x4c\x54\x7a\x77\x39\x31\x44\x65\x31\x5a','\x42\x4d\x66\x54\x7a\x71','\x6f\x4d\x7a\x50\x42\x67\x75\x36','\x75\x4c\x4c\x6a\x71\x4e\x4f','\x43\x32\x4c\x4e\x42\x4d\x66\x53','\x44\x68\x4c\x57\x7a\x71','\x43\x4d\x76\x53\x79\x78\x72\x50\x44\x4d\x76\x71\x79\x78\x72\x4f','\x42\x33\x62\x30\x41\x77\x39\x55\x43\x57','\x41\x65\x31\x49\x79\x77\x79','\x6d\x74\x66\x49\x73\x77\x35\x57\x79\x4b\x75','\x42\x32\x35\x67\x41\x77\x58\x4c\x75\x4d\x76\x55\x79\x77\x31\x4c\x7a\x61','\x6c\x32\x66\x57\x41\x73\x39\x4a\x42\x32\x58\x53\x79\x77\x6a\x56\x43\x4d\x66\x30\x41\x77\x39\x55\x6c\x32\x6a\x56\x42\x33\x72\x5a\x44\x68\x6a\x48\x43\x61','\x6d\x4a\x79\x35\x6f\x74\x71\x33\x6d\x68\x66\x58\x43\x68\x50\x52\x41\x71','\x41\x67\x66\x55\x7a\x67\x58\x4c\x72\x4d\x4c\x53\x7a\x75\x76\x32\x7a\x77\x35\x30','\x43\x4d\x76\x55\x79\x77\x31\x4c\x7a\x61','\x41\x77\x35\x4a\x42\x68\x76\x4b\x7a\x78\x6d','\x44\x77\x35\x5a\x44\x77\x6a\x5a\x79\x33\x6a\x50\x79\x4d\x76\x67\x41\x77\x58\x4c\x72\x78\x7a\x4c\x42\x4e\x72\x5a','\x43\x4d\x76\x57\x42\x67\x66\x4a\x7a\x75\x6e\x56\x42\x4e\x72\x4c\x42\x4e\x71','\x6d\x4a\x66\x50\x74\x32\x39\x58\x76\x78\x4f','\x7a\x4d\x76\x30\x79\x32\x47','\x44\x32\x39\x59\x41\x33\x6e\x57\x79\x77\x6e\x4c\x73\x77\x71\x47\x42\x78\x76\x5a\x44\x63\x62\x55\x42\x33\x71\x47\x79\x32\x39\x55\x44\x67\x66\x50\x42\x49\x62\x57\x79\x78\x72\x4f\x69\x68\x6e\x4c\x43\x67\x66\x59\x79\x78\x72\x56\x43\x4e\x6d\x47\x42\x33\x69\x47\x42\x4e\x76\x53\x42\x63\x62\x49\x45\x78\x72\x4c\x43\x57','\x43\x32\x58\x50\x79\x32\x75','\x43\x33\x72\x48\x44\x68\x76\x5a','\x43\x33\x76\x49\x43\x32\x6e\x59\x41\x77\x6a\x4c\x76\x67\x39\x67\x41\x77\x58\x4c\x72\x78\x7a\x4c\x42\x4e\x72\x5a','\x6d\x4e\x57\x57\x46\x64\x72\x38\x6d\x78\x57\x31\x46\x64\x6e\x38\x6e\x47','\x6e\x64\x71\x35\x6e\x33\x7a\x32\x45\x4b\x4c\x31\x41\x71','\x79\x4c\x6a\x4c\x77\x4b\x6d','\x73\x77\x4c\x59\x41\x31\x43','\x75\x65\x39\x74\x76\x61','\x41\x67\x76\x48\x7a\x67\x76\x59\x43\x57','\x45\x78\x44\x6e\x45\x4c\x4f','\x44\x32\x39\x59\x41\x33\x6e\x57\x79\x77\x6e\x4c\x6f\x47','\x7a\x4d\x76\x30\x79\x32\x48\x6a\x42\x78\x62\x53','\x41\x77\x35\x4b\x7a\x78\x48\x70\x7a\x47','\x7a\x32\x76\x30\x71\x32\x39\x55\x44\x67\x76\x55\x44\x61','\x75\x75\x58\x70\x42\x4b\x75','\x43\x4d\x76\x53\x79\x78\x72\x50\x44\x4d\x76\x71\x79\x78\x72\x4f\x69\x67\x31\x31\x43\x33\x71\x47\x42\x4d\x39\x30\x69\x67\x6a\x4c\x69\x67\x76\x54\x43\x68\x72\x35','\x43\x4d\x76\x53\x79\x78\x72\x50\x44\x4d\x76\x71\x79\x78\x72\x4f\x69\x67\x31\x31\x43\x33\x71\x47\x42\x4d\x39\x30\x69\x67\x6e\x56\x42\x4e\x72\x48\x41\x77\x34\x47\x69\x49\x34\x55\x69\x47','\x43\x4d\x76\x57\x42\x67\x66\x4a\x7a\x71','\x43\x4d\x76\x58\x44\x77\x76\x5a\x44\x65\x50\x5a\x42\x32\x34','\x6e\x64\x61\x35\x6e\x64\x76\x63\x72\x65\x35\x36\x75\x30\x71','\x79\x77\x72\x48\x43\x68\x72\x4c\x43\x47','\x72\x4d\x66\x50\x42\x67\x76\x4b\x69\x68\x72\x56\x69\x67\x6e\x56\x42\x4d\x35\x4c\x79\x33\x71\x47\x44\x67\x38\x47\x79\x32\x39\x53\x42\x67\x66\x49\x42\x33\x6a\x48\x44\x67\x4c\x56\x42\x49\x62\x62\x75\x65\x4b\x36\x69\x61','\x41\x4e\x6e\x56\x42\x47','\x71\x32\x39\x55\x44\x67\x76\x55\x44\x63\x31\x75\x45\x78\x62\x4c','\x6d\x4a\x47\x32\x45\x67\x39\x62\x41\x67\x76\x36','\x79\x4d\x39\x56\x44\x68\x6e\x30\x43\x4d\x66\x57','\x6d\x4a\x61\x57\x6e\x64\x62\x4d\x74\x75\x72\x32\x73\x32\x4b','\x43\x68\x6e\x52\x72\x4c\x69','\x41\x4d\x39\x50\x42\x47','\x43\x67\x76\x55\x7a\x67\x4c\x55\x7a\x31\x44\x59\x41\x78\x72\x4c\x76\x67\x4c\x54\x7a\x78\x69','\x42\x67\x66\x5a\x44\x66\x44\x59\x41\x78\x72\x30\x7a\x77\x35\x64\x42\x32\x35\x30\x7a\x77\x35\x30','\x76\x78\x76\x36\x73\x4c\x6d','\x42\x33\x66\x32\x76\x68\x79','\x6d\x74\x79\x58\x6e\x64\x79\x33\x74\x4b\x48\x75\x42\x33\x62\x6d','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x71','\x43\x33\x62\x53\x41\x78\x71','\x79\x32\x39\x55\x44\x67\x76\x55\x44\x61'];a0_0x360c=function(){return _0x1ba324;};return a0_0x360c();}const DEFAULT_TIMEOUT_MS=0x7530;function normalizeBaseUrl(_0x48c4d0){const _0x21f7bd=a0_0x2fc9;return _0x48c4d0[_0x21f7bd(0x160)](/\/+$/,'');}var CollaborationClient=class{[a0_0x4da695(0x135)];[a0_0x4da695(0x13a)];['\x66\x65\x74\x63\x68\x49\x6d\x70\x6c'];[a0_0x4da695(0x157)];constructor(_0x4d15c9){const _0x2424c9=a0_0x4da695;this[_0x2424c9(0x135)]=normalizeBaseUrl(_0x4d15c9[_0x2424c9(0x135)]),this[_0x2424c9(0x13a)]=_0x4d15c9[_0x2424c9(0x13a)]??DEFAULT_TIMEOUT_MS,this['\x66\x65\x74\x63\x68\x49\x6d\x70\x6c']=_0x4d15c9[_0x2424c9(0x14d)]??globalThis[_0x2424c9(0x14d)][_0x2424c9(0x12a)](globalThis),this[_0x2424c9(0x157)]=_0x4d15c9['\x68\x65\x61\x64\x65\x72\x73'];}async[a0_0x4da695(0x168)](_0x1b4227){const _0x150775=a0_0x4da695,_0x3c3e1b={'\x68\x4d\x62\x61\x66':_0x150775(0x145)};return this['\x72\x65\x71\x75\x65\x73\x74\x4a\x73\x6f\x6e'](_0x3c3e1b[_0x150775(0x142)],{'\x6d\x65\x74\x68\x6f\x64':_0x150775(0x156),'\x62\x6f\x64\x79':JSON[_0x150775(0x129)](_0x1b4227)});}async[a0_0x4da695(0x137)](_0x11090f){const _0x19764e=a0_0x4da695;return this[_0x19764e(0x161)](_0x19764e(0x128),{'\x6d\x65\x74\x68\x6f\x64':_0x19764e(0x156),'\x62\x6f\x64\x79':JSON[_0x19764e(0x129)](_0x11090f)});}async[a0_0x4da695(0x11e)](_0x3948d0){const _0x93cfbb=a0_0x4da695;return this[_0x93cfbb(0x161)]('\x2f\x61\x70\x69\x2f\x63\x6f\x6c\x6c\x61\x62\x6f\x72\x61\x74\x69\x6f\x6e\x2f\x73\x6e\x61\x70\x73\x68\x6f\x74',{'\x6d\x65\x74\x68\x6f\x64':_0x93cfbb(0x156),'\x62\x6f\x64\x79':JSON[_0x93cfbb(0x129)](_0x3948d0)});}async[a0_0x4da695(0x161)](_0x9bfe99,_0x11ae1b){const _0x3d9228=a0_0x4da695,_0x513bba={'\x4c\x45\x49\x57\x41':function(_0x2ddd5d,_0x2303e1,_0x48d910){return _0x2ddd5d(_0x2303e1,_0x48d910);},'\x69\x55\x4e\x66\x70':function(_0x2e3f3e,_0x32499b){return _0x2e3f3e instanceof _0x32499b;},'\x65\x59\x5a\x4a\x50':function(_0x41ebb5,_0x5c7d42){return _0x41ebb5 in _0x5c7d42;},'\x51\x4c\x59\x6c\x72':_0x3d9228(0x122),'\x51\x4c\x4f\x6e\x45':function(_0xc6d29b,_0x32bb2d){return _0xc6d29b(_0x32bb2d);}},_0x6bc492=new AbortController(),_0x4e3dc9=_0x513bba['\x4c\x45\x49\x57\x41'](setTimeout,()=>_0x6bc492[_0x3d9228(0x131)](),this[_0x3d9228(0x13a)]);try{const _0x44409d=new Headers(await this[_0x3d9228(0x125)]());if(!_0x44409d['\x68\x61\x73']('\x43\x6f\x6e\x74\x65\x6e\x74\x2d\x54\x79\x70\x65'))_0x44409d[_0x3d9228(0x121)](_0x3d9228(0x166),_0x3d9228(0x126));const _0x32744e=await this[_0x3d9228(0x15a)](''+this[_0x3d9228(0x135)]+_0x9bfe99,{..._0x11ae1b,'\x68\x65\x61\x64\x65\x72\x73':_0x44409d,'\x73\x69\x67\x6e\x61\x6c':_0x11ae1b[_0x3d9228(0x13e)]??_0x6bc492['\x73\x69\x67\x6e\x61\x6c']});if(!_0x32744e['\x6f\x6b']){const _0xf0c006=await _0x32744e['\x74\x65\x78\x74']();throw a0_0x2f352d(_0x32744e[_0x3d9228(0x150)],_0xf0c006,{'\x6d\x65\x74\x68\x6f\x64':_0x11ae1b[_0x3d9228(0x138)],'\x70\x61\x74\x68':_0x9bfe99},_0x32744e[_0x3d9228(0x157)]);}return _0x32744e[_0x3d9228(0x165)]();}catch(_0xfda266){if(_0x513bba[_0x3d9228(0x11c)](_0xfda266,Error)&&_0xfda266[_0x3d9228(0x13b)]===_0x3d9228(0x130))throw new a0_0x4ddaed(this[_0x3d9228(0x13a)]);if(_0xfda266 instanceof Error&&_0x513bba['\x65\x59\x5a\x4a\x50'](_0x513bba[_0x3d9228(0x115)],_0xfda266))throw _0xfda266;throw new a0_0x2b2912(_0x3d9228(0x164)+(_0xfda266 instanceof Error?_0xfda266[_0x3d9228(0x110)]:_0x513bba[_0x3d9228(0x15d)](String,_0xfda266)),_0xfda266 instanceof Error?_0xfda266:void 0x0);}finally{clearTimeout(_0x4e3dc9);}}async[a0_0x4da695(0x125)](){const _0x30a770=a0_0x4da695,_0x2c59fa={'\x52\x59\x49\x42\x7a':_0x30a770(0x133)};if(typeof this[_0x30a770(0x157)]===_0x2c59fa[_0x30a770(0x13d)])return this['\x68\x65\x61\x64\x65\x72\x73']();return this['\x68\x65\x61\x64\x65\x72\x73'];}};const DOCUMENT_PREFIX=a0_0x4da695(0x159),FILE_SEGMENT=a0_0x4da695(0x13c);function assertValidWorkspaceId(_0x32a3ff){const _0x449293=a0_0x4da695,_0x34df03={'\x6d\x57\x6c\x67\x61':_0x449293(0x124)};if(!_0x32a3ff)throw new Error(_0x34df03['\x6d\x57\x6c\x67\x61']);if(_0x32a3ff[_0x449293(0x149)]('\x2f')||_0x32a3ff['\x69\x6e\x63\x6c\x75\x64\x65\x73']('\x5c')||_0x32a3ff[_0x449293(0x149)]('\x00'))throw new Error(_0x449293(0x14e));}function normalizeCollaborationPath(_0x2505ce){const _0x3346e5=a0_0x4da695,_0x33bbef={'\x55\x75\x7a\x4a\x53':_0x3346e5(0x12f),'\x6f\x71\x76\x54\x76':function(_0x4a5997,_0x186dbd){return _0x4a5997===_0x186dbd;},'\x62\x52\x65\x5a\x43':_0x3346e5(0x15f),'\x59\x5a\x6f\x67\x41':'\x72\x65\x6c\x61\x74\x69\x76\x65\x50\x61\x74\x68\x20\x6d\x75\x73\x74\x20\x6e\x6f\x74\x20\x63\x6f\x6e\x74\x61\x69\x6e\x20\x6e\x75\x6c\x6c\x20\x62\x79\x74\x65\x73'};if(!_0x2505ce)throw new Error(_0x33bbef[_0x3346e5(0x10d)]);const _0x3a6118=_0x2505ce[_0x3346e5(0x160)](/\\/g,'\x2f')[_0x3346e5(0x111)]('\x2f')['\x66\x69\x6c\x74\x65\x72'](_0x4c1790=>_0x4c1790['\x6c\x65\x6e\x67\x74\x68']>0x0&&_0x4c1790!=='\x2e');if(_0x3a6118[_0x3346e5(0x12d)]===0x0)throw new Error(_0x3346e5(0x15e));for(const _0x4d1b93 of _0x3a6118){if(_0x33bbef[_0x3346e5(0x10e)](_0x4d1b93,'\x2e\x2e'))throw new Error(_0x33bbef[_0x3346e5(0x154)]);if(_0x4d1b93[_0x3346e5(0x149)]('\x00'))throw new Error(_0x33bbef['\x59\x5a\x6f\x67\x41']);}return _0x3a6118[_0x3346e5(0x16b)]('\x2f');}function buildCollaborationDocumentId(_0x5d9f27){const _0x479906=a0_0x4da695;assertValidWorkspaceId(_0x5d9f27['\x77\x6f\x72\x6b\x73\x70\x61\x63\x65\x49\x64']);const _0x336a94=normalizeCollaborationPath(_0x5d9f27[_0x479906(0x140)]);return''+DOCUMENT_PREFIX+_0x5d9f27[_0x479906(0x113)]+FILE_SEGMENT+_0x336a94;}function parseCollaborationDocumentId(_0xf69e0c){const _0x24f48b=a0_0x4da695,_0x15e83c={'\x49\x69\x72\x6b\x57':function(_0xab5aef,_0x4028d0){return _0xab5aef===_0x4028d0;},'\x4e\x6e\x76\x46\x69':function(_0x968048,_0x23d552){return _0x968048(_0x23d552);}};if(!_0xf69e0c['\x73\x74\x61\x72\x74\x73\x57\x69\x74\x68'](DOCUMENT_PREFIX))return null;const _0x4c91f2=_0xf69e0c[_0x24f48b(0x15b)](FILE_SEGMENT,0xa);if(_0x15e83c[_0x24f48b(0x155)](_0x4c91f2,-0x1))return null;const _0x54df4e=_0xf69e0c[_0x24f48b(0x14f)](0xa,_0x4c91f2),_0x114ecc=_0xf69e0c[_0x24f48b(0x14f)](_0x4c91f2+0x6);try{return _0x15e83c['\x4e\x6e\x76\x46\x69'](assertValidWorkspaceId,_0x54df4e),{'\x77\x6f\x72\x6b\x73\x70\x61\x63\x65\x49\x64':_0x54df4e,'\x72\x65\x6c\x61\x74\x69\x76\x65\x50\x61\x74\x68':normalizeCollaborationPath(_0x114ecc)};}catch{return null;}}const DEFAULT_DEBOUNCE_MS=0x1f4,FILE_ORIGIN='\x62\x72\x69\x64\x67\x65\x3a\x66\x69\x6c\x65';var CollaborationFileBridge=class{['\x64\x65\x62\x6f\x75\x6e\x63\x65\x4d\x73'];[a0_0x4da695(0x141)];['\x61\x64\x61\x70\x74\x65\x72']=null;[a0_0x4da695(0x139)]=null;[a0_0x4da695(0x14a)]=null;[a0_0x4da695(0x16c)]=null;[a0_0x4da695(0x118)]=![];['\x62\x6f\x75\x6e\x64\x50\x61\x74\x68'];['\x6c\x61\x73\x74\x57\x72\x69\x74\x74\x65\x6e\x43\x6f\x6e\x74\x65\x6e\x74']=null;constructor(_0x31a9cb){const _0x282d6a=a0_0x4da695;this[_0x282d6a(0x141)]=_0x31a9cb,this[_0x282d6a(0x12e)]=_0x31a9cb[_0x282d6a(0x140)],this[_0x282d6a(0x11a)]=_0x31a9cb['\x64\x65\x62\x6f\x75\x6e\x63\x65\x4d\x73']??DEFAULT_DEBOUNCE_MS;}['\x62\x69\x6e\x64'](_0x281077){const _0x2e6622=a0_0x4da695,_0x13a8bc={'\x42\x46\x45\x4b\x70':function(_0x8fa2c5,_0x204d2b){return _0x8fa2c5===_0x204d2b;},'\x79\x77\x4d\x7a\x5a':function(_0x1536e6,_0x43b5ae){return _0x1536e6===_0x43b5ae;}};this[_0x2e6622(0x134)](),this['\x64\x65\x73\x74\x72\x6f\x79\x65\x64']=![],this[_0x2e6622(0x163)]=_0x281077,this[_0x2e6622(0x12e)]=this[_0x2e6622(0x141)][_0x2e6622(0x140)],this[_0x2e6622(0x139)]=_0x281077[_0x2e6622(0x123)](_0x581c58=>{const _0x931bed=_0x2e6622;if(_0x13a8bc[_0x931bed(0x12c)](_0x581c58[_0x931bed(0x12b)],FILE_ORIGIN))return;if(this['\x6c\x61\x73\x74\x57\x72\x69\x74\x74\x65\x6e\x43\x6f\x6e\x74\x65\x6e\x74']!==null&&_0x13a8bc[_0x931bed(0x158)](_0x581c58['\x63\x6f\x6e\x74\x65\x6e\x74'],this[_0x931bed(0x16d)]))return;this['\x73\x63\x68\x65\x64\x75\x6c\x65\x57\x72\x69\x74\x65'](_0x581c58['\x63\x6f\x6e\x74\x65\x6e\x74']);}),this[_0x2e6622(0x14a)]=this[_0x2e6622(0x141)][_0x2e6622(0x151)](this[_0x2e6622(0x12e)],_0x6d99ff=>{const _0x3c5925=_0x2e6622;this[_0x3c5925(0x147)](_0x6d99ff);});}async['\x66\x6c\x75\x73\x68'](){const _0x57b937=a0_0x4da695;if(!this[_0x57b937(0x163)])return;this[_0x57b937(0x16c)]&&(clearTimeout(this['\x70\x65\x6e\x64\x69\x6e\x67\x57\x72\x69\x74\x65\x54\x69\x6d\x65\x72']),this[_0x57b937(0x16c)]=null);const _0x8baad8=this[_0x57b937(0x163)][_0x57b937(0x15c)]();await this[_0x57b937(0x11d)](_0x8baad8);}['\x67\x65\x74\x50\x61\x74\x68'](){const _0x1eacc1=a0_0x4da695;return this[_0x1eacc1(0x12e)];}['\x64\x65\x73\x74\x72\x6f\x79'](){const _0x534d7c=a0_0x4da695;this[_0x534d7c(0x118)]=!![],this['\x70\x65\x6e\x64\x69\x6e\x67\x57\x72\x69\x74\x65\x54\x69\x6d\x65\x72']&&(clearTimeout(this[_0x534d7c(0x16c)]),this[_0x534d7c(0x16c)]=null),this[_0x534d7c(0x139)]?.(),this[_0x534d7c(0x139)]=null,this['\x75\x6e\x73\x75\x62\x73\x63\x72\x69\x62\x65\x46\x69\x6c\x65\x45\x76\x65\x6e\x74\x73']?.(),this[_0x534d7c(0x14a)]=null,this[_0x534d7c(0x163)]=null;}['\x73\x63\x68\x65\x64\x75\x6c\x65\x57\x72\x69\x74\x65'](_0x526b70){const _0x2d7e32=a0_0x4da695;if(this['\x70\x65\x6e\x64\x69\x6e\x67\x57\x72\x69\x74\x65\x54\x69\x6d\x65\x72'])clearTimeout(this['\x70\x65\x6e\x64\x69\x6e\x67\x57\x72\x69\x74\x65\x54\x69\x6d\x65\x72']);this['\x70\x65\x6e\x64\x69\x6e\x67\x57\x72\x69\x74\x65\x54\x69\x6d\x65\x72']=setTimeout(()=>{this['\x70\x65\x6e\x64\x69\x6e\x67\x57\x72\x69\x74\x65\x54\x69\x6d\x65\x72']=null,this['\x77\x72\x69\x74\x65'](_0x526b70);},this[_0x2d7e32(0x11a)]);}async[a0_0x4da695(0x11d)](_0x1ea369){const _0x40a25e=a0_0x4da695;if(this[_0x40a25e(0x118)])return;this[_0x40a25e(0x16d)]=_0x1ea369,await this[_0x40a25e(0x141)]['\x77\x72\x69\x74\x65\x46\x69\x6c\x65'](this[_0x40a25e(0x12e)],_0x1ea369);}[a0_0x4da695(0x147)](_0x23f12a){const _0x1b5b64=a0_0x4da695,_0x40b814={'\x59\x72\x44\x4b\x65':_0x1b5b64(0x152),'\x55\x4a\x57\x41\x70':_0x1b5b64(0x119),'\x48\x64\x44\x6f\x79':'\x73\x74\x72\x69\x6e\x67','\x70\x73\x6b\x46\x52':function(_0x1f4b58,_0xd4796){return _0x1f4b58===_0xd4796;}},_0x3411a9=_0x40b814[_0x1b5b64(0x136)][_0x1b5b64(0x111)]('\x7c');let _0x4ccecb=0x0;while(!![]){switch(_0x3411a9[_0x4ccecb++]){case'\x30':if(_0x23f12a[_0x1b5b64(0x13f)]===_0x1b5b64(0x148)&&_0x23f12a[_0x1b5b64(0x117)]){this[_0x1b5b64(0x12e)]=_0x23f12a[_0x1b5b64(0x117)],this[_0x1b5b64(0x141)][_0x1b5b64(0x144)]?.(_0x23f12a);return;}continue;case'\x31':if(_0x23f12a[_0x1b5b64(0x13f)]!==_0x40b814[_0x1b5b64(0x120)]||typeof _0x23f12a[_0x1b5b64(0x112)]!==_0x40b814[_0x1b5b64(0x11b)])return;continue;case'\x32':if(!this[_0x1b5b64(0x163)]||this[_0x1b5b64(0x118)])return;continue;case'\x33':if(this[_0x1b5b64(0x16d)]!==null&&_0x23f12a[_0x1b5b64(0x112)]===this[_0x1b5b64(0x16d)])return;continue;case'\x34':if(_0x40b814[_0x1b5b64(0x16a)](_0x23f12a[_0x1b5b64(0x13f)],_0x1b5b64(0x132))){this[_0x1b5b64(0x141)][_0x1b5b64(0x127)]?.(_0x23f12a);return;}continue;case'\x35':if(_0x23f12a['\x63\x6f\x6e\x74\x65\x6e\x74']===this['\x61\x64\x61\x70\x74\x65\x72']['\x67\x65\x74\x43\x6f\x6e\x74\x65\x6e\x74']())return;continue;case'\x36':this['\x61\x64\x61\x70\x74\x65\x72'][_0x1b5b64(0x14b)](_0x23f12a[_0x1b5b64(0x112)],{'\x6f\x72\x69\x67\x69\x6e':FILE_ORIGIN,'\x76\x65\x72\x73\x69\x6f\x6e':_0x23f12a['\x76\x65\x72\x73\x69\x6f\x6e']});continue;}break;}}};function a0_0x2fc9(_0x265cc7,_0xf034a9){_0x265cc7=_0x265cc7-0x10d;const _0x360cf9=a0_0x360c();let _0x2fc932=_0x360cf9[_0x265cc7];if(a0_0x2fc9['\x4e\x73\x65\x4b\x72\x51']===undefined){var _0x40ab8b=function(_0x3179a1){const _0x29a69b='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';let _0x2dd2cb='',_0x352d06='';for(let _0x54c770=0x0,_0x447854,_0x4d8a23,_0x527c30=0x0;_0x4d8a23=_0x3179a1['\x63\x68\x61\x72\x41\x74'](_0x527c30++);~_0x4d8a23&&(_0x447854=_0x54c770%0x4?_0x447854*0x40+_0x4d8a23:_0x4d8a23,_0x54c770++%0x4)?_0x2dd2cb+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0xff&_0x447854>>(-0x2*_0x54c770&0x6)):0x0){_0x4d8a23=_0x29a69b['\x69\x6e\x64\x65\x78\x4f\x66'](_0x4d8a23);}for(let _0x152d69=0x0,_0x15a02b=_0x2dd2cb['\x6c\x65\x6e\x67\x74\x68'];_0x152d69<_0x15a02b;_0x152d69++){_0x352d06+='\x25'+('\x30\x30'+_0x2dd2cb['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x152d69)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x10))['\x73\x6c\x69\x63\x65'](-0x2);}return decodeURIComponent(_0x352d06);};a0_0x2fc9['\x75\x6a\x54\x57\x7a\x46']=_0x40ab8b,a0_0x2fc9['\x46\x6e\x6b\x75\x64\x61']={},a0_0x2fc9['\x4e\x73\x65\x4b\x72\x51']=!![];}const _0x495523=_0x360cf9[0x0],_0x459d3d=_0x265cc7+_0x495523,_0x3b03b7=a0_0x2fc9['\x46\x6e\x6b\x75\x64\x61'][_0x459d3d];return!_0x3b03b7?(_0x2fc932=a0_0x2fc9['\x75\x6a\x54\x57\x7a\x46'](_0x2fc932),a0_0x2fc9['\x46\x6e\x6b\x75\x64\x61'][_0x459d3d]=_0x2fc932):_0x2fc932=_0x3b03b7,_0x2fc932;}export{CollaborationClient as a,parseCollaborationDocumentId as i,buildCollaborationDocumentId as n,normalizeCollaborationPath as r,CollaborationFileBridge as t};
|
|
1
|
+
import { f as parseErrorResponse, r as NetworkError, u as TimeoutError } from "./errors-DZsfJUuc.js";
|
|
2
|
+
//#region src/collaboration/client.ts
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 3e4;
|
|
4
|
+
function normalizeBaseUrl(url) {
|
|
5
|
+
return url.replace(/\/+$/, "");
|
|
6
|
+
}
|
|
7
|
+
var CollaborationClient = class {
|
|
8
|
+
baseUrl;
|
|
9
|
+
timeoutMs;
|
|
10
|
+
fetchImpl;
|
|
11
|
+
headers;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.baseUrl = normalizeBaseUrl(config.baseUrl);
|
|
14
|
+
this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
15
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
16
|
+
this.headers = config.headers;
|
|
17
|
+
}
|
|
18
|
+
async bootstrap(request) {
|
|
19
|
+
return this.requestJson("/api/collaboration/bootstrap", {
|
|
20
|
+
method: "POST",
|
|
21
|
+
body: JSON.stringify(request)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async refreshToken(request) {
|
|
25
|
+
return this.requestJson("/api/collaboration/token", {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: JSON.stringify(request)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async saveSnapshot(request) {
|
|
31
|
+
return this.requestJson("/api/collaboration/snapshot", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify(request)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async requestJson(path, init) {
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
39
|
+
try {
|
|
40
|
+
const headers = new Headers(await this.resolveHeaders());
|
|
41
|
+
if (!headers.has("Content-Type")) headers.set("Content-Type", "application/json");
|
|
42
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
43
|
+
...init,
|
|
44
|
+
headers,
|
|
45
|
+
signal: init.signal ?? controller.signal
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
const body = await response.text();
|
|
49
|
+
throw parseErrorResponse(response.status, body, {
|
|
50
|
+
method: init.method,
|
|
51
|
+
path
|
|
52
|
+
}, response.headers);
|
|
53
|
+
}
|
|
54
|
+
return response.json();
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof Error && error.name === "AbortError") throw new TimeoutError(this.timeoutMs);
|
|
57
|
+
if (error instanceof Error && "code" in error) throw error;
|
|
58
|
+
throw new NetworkError(`Failed to connect to collaboration API: ${error instanceof Error ? error.message : String(error)}`, error instanceof Error ? error : void 0);
|
|
59
|
+
} finally {
|
|
60
|
+
clearTimeout(timeoutId);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async resolveHeaders() {
|
|
64
|
+
if (typeof this.headers === "function") return this.headers();
|
|
65
|
+
return this.headers;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/collaboration/document-id.ts
|
|
70
|
+
const DOCUMENT_PREFIX = "workspace:";
|
|
71
|
+
const FILE_SEGMENT = ":file:";
|
|
72
|
+
function assertValidWorkspaceId(workspaceId) {
|
|
73
|
+
if (!workspaceId) throw new Error("workspaceId is required");
|
|
74
|
+
if (workspaceId.includes("/") || workspaceId.includes("\\") || workspaceId.includes("\0")) throw new Error("workspaceId must not contain path separators or null bytes");
|
|
75
|
+
}
|
|
76
|
+
function normalizeCollaborationPath(path) {
|
|
77
|
+
if (!path) throw new Error("relativePath is required");
|
|
78
|
+
const normalized = path.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0 && segment !== ".");
|
|
79
|
+
if (normalized.length === 0) throw new Error("relativePath must not be empty");
|
|
80
|
+
for (const segment of normalized) {
|
|
81
|
+
if (segment === "..") throw new Error("relativePath must not contain \"..\"");
|
|
82
|
+
if (segment.includes("\0")) throw new Error("relativePath must not contain null bytes");
|
|
83
|
+
}
|
|
84
|
+
return normalized.join("/");
|
|
85
|
+
}
|
|
86
|
+
function buildCollaborationDocumentId(ref) {
|
|
87
|
+
assertValidWorkspaceId(ref.workspaceId);
|
|
88
|
+
const relativePath = normalizeCollaborationPath(ref.relativePath);
|
|
89
|
+
return `${DOCUMENT_PREFIX}${ref.workspaceId}${FILE_SEGMENT}${relativePath}`;
|
|
90
|
+
}
|
|
91
|
+
function parseCollaborationDocumentId(documentId) {
|
|
92
|
+
if (!documentId.startsWith(DOCUMENT_PREFIX)) return null;
|
|
93
|
+
const separatorIndex = documentId.indexOf(FILE_SEGMENT, 10);
|
|
94
|
+
if (separatorIndex === -1) return null;
|
|
95
|
+
const workspaceId = documentId.slice(10, separatorIndex);
|
|
96
|
+
const relativePath = documentId.slice(separatorIndex + 6);
|
|
97
|
+
try {
|
|
98
|
+
assertValidWorkspaceId(workspaceId);
|
|
99
|
+
return {
|
|
100
|
+
workspaceId,
|
|
101
|
+
relativePath: normalizeCollaborationPath(relativePath)
|
|
102
|
+
};
|
|
103
|
+
} catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/collaboration/file-bridge.ts
|
|
109
|
+
const DEFAULT_DEBOUNCE_MS = 500;
|
|
110
|
+
const FILE_ORIGIN = "bridge:file";
|
|
111
|
+
/**
|
|
112
|
+
* Headless bridge between a collaborative document adapter and the sandbox
|
|
113
|
+
* filesystem. Keeps this package free of direct Yjs assumptions.
|
|
114
|
+
*/
|
|
115
|
+
var CollaborationFileBridge = class {
|
|
116
|
+
debounceMs;
|
|
117
|
+
options;
|
|
118
|
+
adapter = null;
|
|
119
|
+
unsubscribeDocument = null;
|
|
120
|
+
unsubscribeFileEvents = null;
|
|
121
|
+
pendingWriteTimer = null;
|
|
122
|
+
destroyed = false;
|
|
123
|
+
boundPath;
|
|
124
|
+
lastWrittenContent = null;
|
|
125
|
+
constructor(options) {
|
|
126
|
+
this.options = options;
|
|
127
|
+
this.boundPath = options.relativePath;
|
|
128
|
+
this.debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
129
|
+
}
|
|
130
|
+
bind(adapter) {
|
|
131
|
+
this.destroy();
|
|
132
|
+
this.destroyed = false;
|
|
133
|
+
this.adapter = adapter;
|
|
134
|
+
this.boundPath = this.options.relativePath;
|
|
135
|
+
this.unsubscribeDocument = adapter.subscribe((change) => {
|
|
136
|
+
if (change.origin === FILE_ORIGIN) return;
|
|
137
|
+
if (this.lastWrittenContent !== null && change.content === this.lastWrittenContent) return;
|
|
138
|
+
this.scheduleWrite(change.content);
|
|
139
|
+
});
|
|
140
|
+
this.unsubscribeFileEvents = this.options.subscribeToFileEvents(this.boundPath, (event) => {
|
|
141
|
+
this.handleFileEvent(event);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async flush() {
|
|
145
|
+
if (!this.adapter) return;
|
|
146
|
+
if (this.pendingWriteTimer) {
|
|
147
|
+
clearTimeout(this.pendingWriteTimer);
|
|
148
|
+
this.pendingWriteTimer = null;
|
|
149
|
+
}
|
|
150
|
+
const content = this.adapter.getContent();
|
|
151
|
+
await this.write(content);
|
|
152
|
+
}
|
|
153
|
+
getPath() {
|
|
154
|
+
return this.boundPath;
|
|
155
|
+
}
|
|
156
|
+
destroy() {
|
|
157
|
+
this.destroyed = true;
|
|
158
|
+
if (this.pendingWriteTimer) {
|
|
159
|
+
clearTimeout(this.pendingWriteTimer);
|
|
160
|
+
this.pendingWriteTimer = null;
|
|
161
|
+
}
|
|
162
|
+
this.unsubscribeDocument?.();
|
|
163
|
+
this.unsubscribeDocument = null;
|
|
164
|
+
this.unsubscribeFileEvents?.();
|
|
165
|
+
this.unsubscribeFileEvents = null;
|
|
166
|
+
this.adapter = null;
|
|
167
|
+
}
|
|
168
|
+
scheduleWrite(content) {
|
|
169
|
+
if (this.pendingWriteTimer) clearTimeout(this.pendingWriteTimer);
|
|
170
|
+
this.pendingWriteTimer = setTimeout(() => {
|
|
171
|
+
this.pendingWriteTimer = null;
|
|
172
|
+
this.write(content);
|
|
173
|
+
}, this.debounceMs);
|
|
174
|
+
}
|
|
175
|
+
async write(content) {
|
|
176
|
+
if (this.destroyed) return;
|
|
177
|
+
this.lastWrittenContent = content;
|
|
178
|
+
await this.options.writeFile(this.boundPath, content);
|
|
179
|
+
}
|
|
180
|
+
handleFileEvent(event) {
|
|
181
|
+
if (!this.adapter || this.destroyed) return;
|
|
182
|
+
if (event.type === "renamed" && event.nextPath) {
|
|
183
|
+
this.boundPath = event.nextPath;
|
|
184
|
+
this.options.onFileRenamed?.(event);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (event.type === "deleted") {
|
|
188
|
+
this.options.onFileDeleted?.(event);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (event.type !== "updated" || typeof event.content !== "string") return;
|
|
192
|
+
if (event.content === this.adapter.getContent()) return;
|
|
193
|
+
if (this.lastWrittenContent !== null && event.content === this.lastWrittenContent) return;
|
|
194
|
+
this.adapter.replaceContent(event.content, {
|
|
195
|
+
origin: FILE_ORIGIN,
|
|
196
|
+
version: event.version
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
export { CollaborationClient as a, parseCollaborationDocumentId as i, buildCollaborationDocumentId as n, normalizeCollaborationPath as r, CollaborationFileBridge as t };
|
package/dist/core.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { t as SandboxInstance } from "./sandbox-joKtQ5y3.js";
|
|
2
|
+
import { a as PartialFailureError, c as ServerError, d as ValidationError, i as NotFoundError, l as StateError, n as CapabilityError, o as QuotaError, r as NetworkError, s as SandboxError, t as AuthError, u as TimeoutError } from "./errors-DZsfJUuc.js";
|
|
3
|
+
import { n as SandboxClient } from "./client-BBZ7YLmq.js";
|
|
4
|
+
export { AuthError, CapabilityError, NetworkError, NotFoundError, PartialFailureError, QuotaError, SandboxClient as Sandbox, SandboxClient, SandboxError, SandboxInstance, ServerError, StateError, TimeoutError, ValidationError };
|
package/dist/errors-DZsfJUuc.js
CHANGED
|
@@ -1 +1,262 @@
|
|
|
1
|
-
const a0_0x2bc80f=a0_0x3877;(function(_0x3b4dd9,_0x546056){const _0x390c66=a0_0x3877,_0x460bf2=_0x3b4dd9();while(!![]){try{const _0x35ba34=-parseInt(_0x390c66(0xbb))/0x1+parseInt(_0x390c66(0xb6))/0x2*(parseInt(_0x390c66(0xee))/0x3)+parseInt(_0x390c66(0xed))/0x4*(parseInt(_0x390c66(0x81))/0x5)+parseInt(_0x390c66(0xf0))/0x6*(-parseInt(_0x390c66(0x76))/0x7)+parseInt(_0x390c66(0xbf))/0x8*(-parseInt(_0x390c66(0x7c))/0x9)+-parseInt(_0x390c66(0xdc))/0xa+parseInt(_0x390c66(0x9a))/0xb;if(_0x35ba34===_0x546056)break;else _0x460bf2['push'](_0x460bf2['shift']());}catch(_0x4cda15){_0x460bf2['push'](_0x460bf2['shift']());}}}(a0_0x18bf,0xf2807));var SandboxError=class extends Error{[a0_0x2bc80f(0xe9)];[a0_0x2bc80f(0xe2)];['\x6f\x72\x69\x67\x69\x6e'];[a0_0x2bc80f(0xb7)];[a0_0x2bc80f(0xba)];[a0_0x2bc80f(0xc8)];[a0_0x2bc80f(0xc9)];constructor(_0x111ba3,_0x489a8e,_0x33e974,_0x46c65f){const _0x18ab0c=a0_0x2bc80f,_0x1670cd=_0x18ab0c(0x87)[_0x18ab0c(0xe5)]('\x7c');let _0x45e42d=0x0;while(!![]){switch(_0x1670cd[_0x45e42d++]){case'\x30':this[_0x18ab0c(0xe9)]=_0x33e974;continue;case'\x31':this[_0x18ab0c(0xe2)]=_0x489a8e;continue;case'\x32':this[_0x18ab0c(0x80)]=_0x46c65f?.[_0x18ab0c(0x80)];continue;case'\x33':this[_0x18ab0c(0xb7)]=_0x46c65f?.[_0x18ab0c(0xb7)];continue;case'\x34':this['\x73\x69\x64\x65\x63\x61\x72\x56\x65\x72\x73\x69\x6f\x6e']=_0x46c65f?.['\x73\x69\x64\x65\x63\x61\x72\x56\x65\x72\x73\x69\x6f\x6e'];continue;case'\x35':this[_0x18ab0c(0xa0)]='\x53\x61\x6e\x64\x62\x6f\x78\x45\x72\x72\x6f\x72';continue;case'\x36':super(_0x111ba3);continue;case'\x37':this[_0x18ab0c(0xba)]=_0x46c65f?.[_0x18ab0c(0xba)];continue;case'\x38':this[_0x18ab0c(0xc9)]=_0x46c65f?.[_0x18ab0c(0xc9)];continue;}break;}}},AuthError=class extends SandboxError{constructor(_0x48d628=a0_0x2bc80f(0xe6),_0x2aad07){const _0x4436fe=a0_0x2bc80f,_0x56f7f4={'\x42\x47\x54\x4d\x47':'\x41\x75\x74\x68\x45\x72\x72\x6f\x72'};super(_0x48d628,'\x41\x55\x54\x48\x5f\x45\x52\x52\x4f\x52',0x191,_0x2aad07),this[_0x4436fe(0xa0)]=_0x56f7f4[_0x4436fe(0xb9)];}},NotFoundError=class extends SandboxError{['\x72\x65\x73\x6f\x75\x72\x63\x65\x54\x79\x70\x65'];['\x72\x65\x73\x6f\x75\x72\x63\x65\x49\x64'];constructor(_0x32153a,_0x3fa55c,_0x247441){const _0x308781=a0_0x2bc80f,_0x2c6343={'\x47\x75\x61\x41\x68':'\x4e\x4f\x54\x5f\x46\x4f\x55\x4e\x44','\x47\x53\x76\x6a\x4a':'\x4e\x6f\x74\x46\x6f\x75\x6e\x64\x45\x72\x72\x6f\x72'};super(_0x32153a+_0x308781(0xdf)+_0x3fa55c,_0x2c6343[_0x308781(0xbc)],0x194,_0x247441),this[_0x308781(0xa0)]=_0x2c6343[_0x308781(0x99)],this[_0x308781(0x78)]=_0x32153a,this['\x72\x65\x73\x6f\x75\x72\x63\x65\x49\x64']=_0x3fa55c;}},QuotaError=class extends SandboxError{[a0_0x2bc80f(0xde)];[a0_0x2bc80f(0xd2)];[a0_0x2bc80f(0x88)];[a0_0x2bc80f(0xba)];constructor(_0x2be261,_0x260495,_0x5cf8dd,_0x1f8268,_0x336097,_0x3e9908=0x1ad){const _0x5f4fc4=a0_0x2bc80f;super(_0x260495??_0x5f4fc4(0xaa)+_0x2be261,'\x51\x55\x4f\x54\x41\x5f\x45\x58\x43\x45\x45\x44\x45\x44',_0x3e9908,_0x336097),this[_0x5f4fc4(0xa0)]=_0x5f4fc4(0xc3),this[_0x5f4fc4(0xde)]=_0x2be261,this[_0x5f4fc4(0xd2)]=_0x5cf8dd,this['\x6c\x69\x6d\x69\x74']=_0x1f8268,this[_0x5f4fc4(0xba)]=_0x336097?.[_0x5f4fc4(0xba)];}},CapabilityError=class extends SandboxError{[a0_0x2bc80f(0xd4)];constructor(_0x53134,_0x785109=a0_0x2bc80f(0x97),_0x123845=0x190,_0x4fed6f,_0xc67571){const _0x3acfa1=a0_0x2bc80f,_0x36ffb0={'\x63\x77\x68\x71\x4c':_0x3acfa1(0xc6)};super(_0x53134,_0x785109,_0x123845,_0x4fed6f),this['\x6e\x61\x6d\x65']=_0x36ffb0[_0x3acfa1(0xcf)],this[_0x3acfa1(0xd4)]=_0xc67571;}},PartialFailureError=class extends SandboxError{[a0_0x2bc80f(0xc0)];constructor(_0x507867,_0x519aae=a0_0x2bc80f(0x7f),_0x7d591b=0x1f6,_0x302b9d,_0x580846){const _0x2ed7be=a0_0x2bc80f,_0x2d4b7b={'\x70\x45\x44\x4b\x4d':_0x2ed7be(0xa8)};super(_0x507867,_0x519aae,_0x7d591b,_0x302b9d),this[_0x2ed7be(0xa0)]=_0x2d4b7b[_0x2ed7be(0x8f)],this[_0x2ed7be(0xc0)]=_0x580846;}},ValidationError=class extends SandboxError{[a0_0x2bc80f(0xe3)];constructor(_0x1aee64,_0x13a612,_0x1ef922){const _0x484106=a0_0x2bc80f,_0x47954f={'\x63\x50\x47\x72\x7a':_0x484106(0x98)};super(_0x1aee64,_0x47954f['\x63\x50\x47\x72\x7a'],0x190,_0x1ef922),this[_0x484106(0xa0)]=_0x484106(0xd9),this[_0x484106(0xe3)]=_0x13a612;}},StateError=class extends SandboxError{[a0_0x2bc80f(0xd1)];[a0_0x2bc80f(0xe1)];constructor(_0x29295d,_0x47393f,_0x1e2584,_0x9d2c42){const _0x5c70ae=a0_0x2bc80f,_0x503d70={'\x43\x76\x7a\x5a\x53':'\x49\x4e\x56\x41\x4c\x49\x44\x5f\x53\x54\x41\x54\x45'};super(_0x29295d,_0x503d70[_0x5c70ae(0xe0)],0x199,_0x9d2c42),this[_0x5c70ae(0xa0)]=_0x5c70ae(0xa1),this[_0x5c70ae(0xd1)]=_0x47393f,this['\x72\x65\x71\x75\x69\x72\x65\x64\x53\x74\x61\x74\x65']=_0x1e2584;}},TimeoutError=class extends SandboxError{[a0_0x2bc80f(0xb1)];constructor(_0xf7ee18,_0x5320f7,_0x10a40e){const _0x57c140=a0_0x2bc80f;super(_0x5320f7??_0x57c140(0xc5)+_0xf7ee18+'\x6d\x73',_0x57c140(0x7a),0x198,_0x10a40e),this[_0x57c140(0xa0)]=_0x57c140(0xec),this[_0x57c140(0xb1)]=_0xf7ee18;}},NetworkError=class extends SandboxError{[a0_0x2bc80f(0x85)];constructor(_0x5e9062,_0x578f45,_0xd73eff){const _0x151443=a0_0x2bc80f,_0x3e9c9b={'\x52\x46\x62\x78\x79':function(_0x4e1b79,_0x9d49e1){return _0x4e1b79 instanceof _0x9d49e1;}},_0x3cc7a7=_0x3e9c9b[_0x151443(0x86)](_0x578f45,Error)?_0x578f45:void 0x0,_0x46a36b=_0x578f45 instanceof Error?_0xd73eff:_0x578f45??_0xd73eff;super(_0x5e9062,'\x4e\x45\x54\x57\x4f\x52\x4b\x5f\x45\x52\x52\x4f\x52',void 0x0,_0x46a36b),this[_0x151443(0xa0)]=_0x151443(0xea),this[_0x151443(0x85)]=_0x3cc7a7;}},ServerError=class extends SandboxError{constructor(_0xd087f9,_0x5df43e=0x1f4,_0xd6d742){const _0x237a3e=a0_0x2bc80f;super(_0xd087f9,_0x237a3e(0xd7),_0x5df43e,_0xd6d742),this[_0x237a3e(0xa0)]=_0x237a3e(0xb3);}};function parseRetryAfterMs(_0x1e7d9c,_0x235e48){const _0x2c78c5=a0_0x2bc80f,_0x340173={'\x42\x48\x61\x6a\x61':_0x2c78c5(0x8d),'\x73\x55\x73\x57\x6b':function(_0x533464,_0x5f509c){return _0x533464-_0x5f509c;}};if(typeof _0x235e48[_0x2c78c5(0xba)]===_0x340173[_0x2c78c5(0xeb)]&&Number['\x69\x73\x46\x69\x6e\x69\x74\x65'](_0x235e48[_0x2c78c5(0xba)]))return Math[_0x2c78c5(0x9d)](0x0,_0x235e48[_0x2c78c5(0xba)]);if(!_0x1e7d9c)return void 0x0;const _0x3725a1=_0x1e7d9c[_0x2c78c5(0xda)]();if(!_0x3725a1)return void 0x0;const _0x75c5d2=Number(_0x3725a1);if(Number['\x69\x73\x46\x69\x6e\x69\x74\x65'](_0x75c5d2))return Math['\x6d\x61\x78'](0x0,_0x75c5d2)*0x3e8;const _0x6303fc=Date['\x70\x61\x72\x73\x65'](_0x3725a1);if(!Number['\x69\x73\x4e\x61\x4e'](_0x6303fc))return Math[_0x2c78c5(0x9d)](0x0,_0x340173[_0x2c78c5(0xe7)](_0x6303fc,Date['\x6e\x6f\x77']()));}function inferOrigin(_0x395ce4,_0x3f8aa6){const _0x3a6afd=a0_0x2bc80f,_0x3f1868={'\x64\x66\x75\x51\x47':_0x3a6afd(0x7d),'\x66\x53\x46\x4a\x4a':_0x3a6afd(0x95),'\x70\x59\x56\x6f\x4f':_0x3a6afd(0xb8)},_0xb318be=_0x3f8aa6?.[_0x3a6afd(0xc2)]??_0x395ce4?.['\x67\x65\x74']('\x78\x2d\x74\x61\x6e\x67\x6c\x65\x2d\x72\x65\x71\x75\x65\x73\x74\x2d\x70\x61\x74\x68')??void 0x0;if(!_0x395ce4)return _0x3f8aa6?.[_0x3a6afd(0xc2)]?_0x3a6afd(0x8b):void 0x0;if(_0x395ce4[_0x3a6afd(0x8a)](_0x3a6afd(0x92))||_0x395ce4[_0x3a6afd(0x8a)]('\x78\x2d\x73\x69\x64\x65\x63\x61\x72\x2d\x69\x6d\x61\x67\x65')||_0x395ce4[_0x3a6afd(0x8a)](_0x3a6afd(0xbe)))return _0x3f1868[_0x3a6afd(0xd8)];if(_0x395ce4['\x68\x61\x73'](_0x3a6afd(0xa5)))return _0x3f1868[_0x3a6afd(0x8c)];if(_0xb318be?.[_0x3a6afd(0xbd)](_0x3a6afd(0xcb)))return _0x3a6afd(0x8b);if(_0xb318be){if(_0xb318be[_0x3a6afd(0xbd)](_0x3a6afd(0x89))||_0xb318be[_0x3a6afd(0xbd)](_0x3a6afd(0xb2))||_0xb318be[_0x3a6afd(0xbd)](_0x3f1868['\x70\x59\x56\x6f\x4f']))return'\x63\x6f\x6e\x74\x72\x6f\x6c\x2d\x70\x6c\x61\x6e\x65';return _0x3a6afd(0xc7);}return _0x3a6afd(0xe8);}function isQuotaCode(_0x4c0af7){const _0x3e9bdd=a0_0x2bc80f,_0x2c458a={'\x61\x70\x55\x61\x73':function(_0x355905,_0x30dade){return _0x355905===_0x30dade;}};return _0x4c0af7==='\x51\x55\x4f\x54\x41\x5f\x45\x58\x43\x45\x45\x44\x45\x44'||_0x2c458a[_0x3e9bdd(0xb0)](_0x4c0af7?.[_0x3e9bdd(0x90)]('\x5f\x51\x55\x4f\x54\x41\x5f\x45\x58\x43\x45\x45\x44\x45\x44'),!![]);}function isCapabilityCode(_0x29cbc4){const _0x5e8225=a0_0x2bc80f,_0x2a7326={'\x56\x67\x74\x43\x47':function(_0x5a718c,_0x3fc837){return _0x5a718c===_0x3fc837;},'\x55\x78\x6c\x65\x78':_0x5e8225(0xd3),'\x61\x47\x42\x6d\x70':_0x5e8225(0xca)};return _0x2a7326[_0x5e8225(0xd6)](_0x29cbc4,_0x2a7326[_0x5e8225(0xd5)])||_0x29cbc4===_0x5e8225(0x97)||_0x2a7326[_0x5e8225(0xd6)](_0x29cbc4,_0x2a7326['\x61\x47\x42\x6d\x70'])||_0x29cbc4===_0x5e8225(0x7e)||_0x29cbc4===_0x5e8225(0x7b);}function isPartialFailureCode(_0x272b50){const _0x503b89=a0_0x2bc80f,_0x58e99e={'\x74\x59\x45\x67\x67':function(_0x403f92,_0x46caa0){return _0x403f92===_0x46caa0;},'\x75\x73\x53\x70\x43':_0x503b89(0x7f),'\x56\x47\x69\x6d\x46':_0x503b89(0x94)};return _0x58e99e['\x74\x59\x45\x67\x67'](_0x272b50,_0x58e99e[_0x503b89(0xac)])||_0x58e99e[_0x503b89(0x93)](_0x272b50,_0x503b89(0xdb))||_0x58e99e[_0x503b89(0x93)](_0x272b50,_0x58e99e[_0x503b89(0xc4)])||_0x272b50===_0x503b89(0xa2);}function asString(_0x4189ae){const _0x7a2052=a0_0x2bc80f,_0x2ac73c={'\x62\x56\x65\x69\x55':function(_0x433e4e,_0x1ea83c){return _0x433e4e>_0x1ea83c;}};return typeof _0x4189ae===_0x7a2052(0x82)&&_0x2ac73c[_0x7a2052(0x9e)](_0x4189ae[_0x7a2052(0xda)]()[_0x7a2052(0xf2)],0x0)?_0x4189ae:void 0x0;}function isFailureDetail(_0x4e57e1){const _0x3c6a74=a0_0x2bc80f,_0x2ccf30={'\x66\x59\x6a\x4d\x49':_0x3c6a74(0x9f)};return typeof _0x4e57e1===_0x2ccf30[_0x3c6a74(0xf1)]&&_0x4e57e1!==null&&!Array['\x69\x73\x41\x72\x72\x61\x79'](_0x4e57e1);}function readCapability(_0x2b07d7,_0x102286){const _0x45f6ab=a0_0x2bc80f,_0x3750da={'\x42\x78\x7a\x53\x6b':function(_0x1fbf51,_0x7a926c){return _0x1fbf51(_0x7a926c);},'\x61\x65\x42\x4f\x75':function(_0x37ec9e,_0x4025f2){return _0x37ec9e(_0x4025f2);}},_0xbad534=typeof _0x102286===_0x45f6ab(0x9f)&&_0x102286!==null?_0x3750da[_0x45f6ab(0xab)](asString,_0x102286['\x63\x61\x70\x61\x62\x69\x6c\x69\x74\x79']):void 0x0;return _0x3750da['\x61\x65\x42\x4f\x75'](asString,_0x2b07d7[_0x45f6ab(0xd4)])??_0xbad534;}function a0_0x18bf(){const _0x318748=['\x72\x4b\x58\x66\x72\x76\x72\x46\x75\x65\x66\x73\x76\x65\x4c\x62\x74\x66\x39\x67\x71\x75\x4c\x6d\x76\x76\x6a\x66','\x6d\x74\x79\x35\x6d\x74\x6d\x59\x6d\x64\x62\x51\x41\x33\x50\x6d\x72\x75\x71','\x44\x67\x76\x5a\x44\x61','\x43\x78\x76\x56\x44\x67\x66\x75\x45\x78\x62\x4c','\x69\x67\x35\x56\x44\x63\x62\x4d\x42\x33\x76\x55\x7a\x64\x4f\x47','\x71\x33\x7a\x36\x77\x4c\x6d','\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x77\x72\x74\x44\x67\x66\x30\x7a\x71','\x79\x32\x39\x4b\x7a\x71','\x7a\x4d\x4c\x4c\x42\x67\x72\x5a','\x7a\x32\x76\x30','\x43\x33\x62\x53\x41\x78\x71','\x71\x78\x76\x30\x41\x67\x76\x55\x44\x67\x4c\x4a\x79\x78\x72\x50\x42\x32\x34\x47\x7a\x4d\x66\x50\x42\x67\x76\x4b','\x43\x31\x76\x5a\x76\x32\x53','\x44\x77\x35\x52\x42\x4d\x39\x33\x42\x47','\x43\x33\x72\x48\x44\x68\x76\x5a','\x74\x4d\x76\x30\x44\x32\x39\x59\x41\x30\x76\x59\x43\x4d\x39\x59','\x71\x4b\x48\x48\x41\x4d\x65','\x76\x67\x4c\x54\x7a\x77\x39\x31\x44\x65\x76\x59\x43\x4d\x39\x59','\x6e\x67\x50\x73\x73\x4d\x44\x68\x42\x47','\x6d\x74\x65\x58\x6f\x77\x50\x4e\x45\x4b\x54\x6a\x75\x71','\x7a\x30\x66\x57\x44\x4d\x65','\x6d\x74\x48\x7a\x74\x4c\x62\x73\x45\x65\x65','\x7a\x4c\x4c\x51\x74\x75\x4b','\x42\x67\x76\x55\x7a\x33\x72\x4f','\x6d\x5a\x61\x58\x6e\x74\x6d\x32\x6f\x76\x48\x64\x76\x78\x6e\x69\x74\x61','\x71\x30\x7a\x4d\x72\x65\x47','\x43\x4d\x76\x5a\x42\x33\x76\x59\x79\x32\x76\x75\x45\x78\x62\x4c','\x43\x4d\x76\x5a\x44\x77\x58\x30\x43\x57','\x76\x65\x4c\x6e\x72\x75\x39\x76\x76\x61','\x75\x30\x48\x62\x75\x4b\x76\x65\x78\x31\x44\x70\x75\x4b\x54\x74\x75\x65\x66\x64\x72\x76\x39\x76\x74\x4c\x6e\x76\x75\x66\x62\x70\x75\x4c\x72\x66\x72\x61','\x6f\x75\x4c\x79\x41\x32\x4c\x5a\x75\x61','\x43\x32\x4c\x4b\x7a\x77\x6e\x48\x43\x47','\x72\x4b\x58\x66\x72\x76\x72\x46\x75\x30\x48\x62\x75\x4b\x76\x65\x78\x31\x44\x70\x75\x4b\x54\x74\x75\x65\x66\x64\x72\x76\x39\x76\x74\x4c\x6e\x76\x75\x66\x62\x70\x75\x4c\x72\x66\x72\x61','\x75\x65\x66\x73\x76\x65\x4c\x62\x74\x66\x39\x67\x71\x75\x4c\x6d\x76\x76\x6a\x66','\x42\x33\x6a\x50\x7a\x32\x4c\x55','\x6e\x4a\x61\x35\x6f\x64\x47\x31\x6e\x75\x44\x77\x71\x4c\x66\x30\x72\x61','\x43\x33\x72\x59\x41\x77\x35\x4e','\x7a\x78\x6a\x59\x42\x33\x69','\x43\x4d\x66\x30\x7a\x76\x39\x53\x41\x77\x31\x50\x44\x61','\x79\x32\x66\x31\x43\x32\x75','\x75\x4b\x7a\x49\x45\x68\x4b','\x6e\x4e\x57\x31\x46\x64\x66\x38\x6d\x68\x57\x59\x46\x64\x6e\x38\x6e\x33\x57\x30\x46\x64\x47','\x42\x67\x4c\x54\x41\x78\x71','\x6c\x33\x62\x59\x42\x32\x50\x4c\x79\x33\x72\x5a','\x41\x67\x66\x5a','\x43\x32\x66\x55\x7a\x67\x6a\x56\x45\x63\x31\x48\x43\x67\x4b','\x7a\x4c\x6e\x67\x73\x4b\x4f','\x42\x4e\x76\x54\x79\x4d\x76\x59','\x43\x67\x39\x67\x77\x65\x6d','\x43\x65\x76\x65\x73\x30\x30','\x7a\x77\x35\x4b\x43\x31\x44\x50\x44\x67\x47','\x41\x78\x6e\x62\x43\x4e\x6a\x48\x45\x71','\x45\x63\x31\x5a\x41\x77\x72\x4c\x79\x32\x66\x59\x6c\x78\x7a\x4c\x43\x4e\x6e\x50\x42\x32\x34','\x44\x66\x4c\x66\x7a\x32\x43','\x72\x4b\x58\x66\x72\x76\x72\x46\x72\x65\x4c\x74\x75\x65\x66\x75\x71\x30\x48\x46\x75\x65\x66\x73\x76\x65\x4c\x62\x74\x66\x39\x67\x71\x75\x4c\x6d\x76\x76\x6a\x66','\x79\x32\x39\x55\x44\x68\x6a\x56\x42\x63\x31\x57\x42\x67\x66\x55\x7a\x71','\x44\x65\x76\x34\x72\x67\x38','\x71\x30\x66\x71\x71\x75\x6a\x6a\x74\x65\x4c\x75\x77\x76\x39\x76\x74\x4c\x6e\x76\x75\x66\x62\x70\x75\x4c\x72\x66\x72\x61','\x76\x4b\x66\x6d\x73\x75\x72\x62\x76\x65\x4c\x70\x74\x4c\x39\x66\x75\x4c\x6a\x70\x75\x47','\x72\x31\x6e\x32\x41\x4b\x4f','\x6d\x5a\x61\x32\x6e\x5a\x43\x35\x6e\x4a\x7a\x65\x45\x4b\x31\x4c\x71\x30\x57','\x76\x75\x35\x6c\x74\x4b\x39\x78\x74\x4c\x39\x66\x75\x4c\x6a\x70\x75\x47','\x45\x63\x31\x5a\x41\x77\x72\x4c\x79\x32\x66\x59\x6c\x77\x4c\x54\x79\x77\x44\x4c','\x42\x77\x66\x34','\x79\x4c\x7a\x4c\x41\x76\x75','\x42\x32\x6a\x51\x7a\x77\x6e\x30','\x42\x4d\x66\x54\x7a\x71','\x75\x33\x72\x48\x44\x67\x76\x66\x43\x4e\x6a\x56\x43\x47','\x72\x4b\x58\x66\x72\x76\x72\x46\x72\x65\x76\x71\x75\x4b\x39\x77\x73\x76\x6e\x6a\x74\x30\x35\x46\x72\x4b\x66\x6a\x74\x65\x76\x65','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x71','\x79\x4c\x6e\x6b\x73\x75\x6d','\x45\x63\x31\x56\x43\x4d\x6e\x4f\x7a\x78\x6e\x30\x43\x4d\x66\x30\x42\x33\x69\x54\x44\x4d\x76\x59\x43\x32\x4c\x56\x42\x47','\x75\x4b\x76\x72\x76\x75\x76\x74\x76\x61','\x45\x4c\x7a\x4c\x75\x33\x4b','\x75\x67\x66\x59\x44\x67\x4c\x48\x42\x65\x7a\x48\x41\x77\x58\x31\x43\x4d\x76\x66\x43\x4e\x6a\x56\x43\x47','\x42\x77\x76\x30\x41\x67\x39\x4b','\x75\x78\x76\x56\x44\x67\x65\x47\x7a\x78\x48\x4a\x7a\x77\x76\x4b\x7a\x77\x71\x36\x69\x61','\x71\x4e\x48\x36\x75\x32\x53','\x44\x78\x6e\x74\x43\x65\x6d','\x74\x4b\x39\x75\x78\x30\x4c\x6e\x75\x65\x58\x66\x74\x75\x76\x6f\x76\x65\x76\x65','\x73\x30\x50\x36\x43\x75\x38','\x71\x4e\x4c\x33\x43\x66\x4b','\x79\x78\x62\x76\x79\x78\x6d','\x44\x67\x4c\x54\x7a\x77\x39\x31\x44\x65\x31\x5a','\x6c\x33\x6e\x50\x7a\x67\x76\x4a\x79\x78\x6a\x5a','\x75\x32\x76\x59\x44\x4d\x76\x59\x72\x78\x6a\x59\x42\x33\x69','\x72\x4d\x72\x6d\x41\x4d\x47','\x73\x65\x54\x72\x73\x75\x79','\x6f\x64\x43\x35\x6d\x4e\x76\x74\x76\x75\x4c\x30\x7a\x61','\x7a\x77\x35\x4b\x43\x67\x39\x50\x42\x4e\x71','\x6c\x32\x4c\x55\x43\x33\x72\x48\x42\x4d\x6e\x4c\x43\x57','\x71\x4b\x44\x75\x74\x75\x43','\x43\x4d\x76\x30\x43\x4e\x4c\x62\x7a\x4e\x72\x4c\x43\x4b\x31\x5a','\x6e\x4a\x65\x30\x6e\x74\x65\x34\x73\x4e\x4c\x49\x43\x75\x7a\x32','\x72\x33\x76\x48\x71\x77\x47','\x43\x33\x72\x48\x43\x4e\x72\x5a\x76\x32\x4c\x30\x41\x61','\x45\x63\x31\x5a\x41\x77\x72\x4c\x79\x32\x66\x59\x6c\x77\x4c\x54\x79\x77\x44\x4c\x6c\x78\x72\x48\x7a\x57','\x6f\x64\x71\x31\x6e\x74\x79\x33\x6d\x4b\x7a\x51\x76\x68\x76\x7a\x72\x47','\x7a\x4d\x66\x50\x42\x68\x76\x59\x7a\x78\x6d','\x7a\x67\x76\x30\x79\x77\x4c\x53\x43\x57','\x43\x67\x66\x30\x41\x61','\x75\x78\x76\x56\x44\x67\x66\x66\x43\x4e\x6a\x56\x43\x47','\x76\x4b\x44\x50\x42\x75\x79','\x75\x4d\x76\x58\x44\x77\x76\x5a\x44\x63\x62\x30\x41\x77\x31\x4c\x7a\x63\x62\x56\x44\x78\x71\x47\x79\x77\x7a\x30\x7a\x78\x69\x47','\x71\x32\x66\x57\x79\x77\x6a\x50\x42\x67\x4c\x30\x45\x75\x76\x59\x43\x4d\x39\x59','\x43\x4e\x76\x55\x44\x67\x4c\x54\x7a\x71','\x43\x32\x4c\x4b\x7a\x77\x6e\x48\x43\x4c\x7a\x4c\x43\x4e\x6e\x50\x42\x32\x34','\x79\x32\x39\x55\x44\x67\x66\x50\x42\x4d\x76\x59\x73\x77\x31\x48\x7a\x32\x75','\x76\x75\x35\x74\x76\x76\x62\x71\x74\x31\x6a\x75\x72\x75\x72\x46\x71\x30\x66\x71\x71\x75\x6a\x6a\x74\x65\x4c\x75\x77\x71','\x6c\x33\x79\x58\x6c\x57','\x75\x4d\x76\x5a\x42\x33\x76\x59\x79\x32\x75','\x77\x4c\x72\x6a\x45\x4b\x71','\x72\x68\x50\x54\x76\x32\x75','\x79\x33\x44\x4f\x43\x75\x57','\x7a\x4d\x4c\x53\x44\x67\x76\x59','\x79\x33\x76\x59\x43\x4d\x76\x55\x44\x66\x6e\x30\x79\x78\x72\x4c','\x79\x33\x76\x59\x43\x4d\x76\x55\x44\x61','\x71\x30\x66\x71\x71\x75\x6a\x6a\x74\x65\x4c\x75\x77\x76\x39\x6f\x74\x31\x72\x46\x72\x75\x35\x62\x71\x4b\x58\x66\x72\x61','\x79\x32\x66\x57\x79\x77\x6a\x50\x42\x67\x4c\x30\x45\x71','\x76\x78\x48\x53\x7a\x78\x47','\x76\x4d\x44\x30\x71\x30\x43','\x75\x30\x76\x73\x76\x4b\x76\x73\x78\x30\x76\x73\x75\x4b\x39\x73','\x7a\x67\x7a\x31\x75\x75\x43','\x76\x4d\x66\x53\x41\x77\x72\x48\x44\x67\x4c\x56\x42\x4b\x76\x59\x43\x4d\x39\x59','\x44\x68\x6a\x50\x42\x71'];a0_0x18bf=function(){return _0x318748;};return a0_0x18bf();}function readFailures(_0x4d348e,_0x545c41){const _0x2424f0=a0_0x2bc80f,_0x4b3ce1={'\x7a\x56\x65\x53\x79':function(_0x526d6b,_0x48a6e3){return _0x526d6b>_0x48a6e3;},'\x74\x45\x78\x44\x6f':function(_0x3f7349,_0x1acb43){return _0x3f7349!==_0x1acb43;}};if(Array[_0x2424f0(0x91)](_0x4d348e[_0x2424f0(0xc0)]))return _0x4d348e[_0x2424f0(0xc0)]['\x66\x69\x6c\x74\x65\x72'](isFailureDetail);if(Array[_0x2424f0(0x91)](_0x4d348e[_0x2424f0(0x79)])){const _0x269b99=_0x4d348e[_0x2424f0(0x79)][_0x2424f0(0xd0)](_0x1dd812=>typeof _0x1dd812===_0x2424f0(0x9f)&&_0x1dd812!==null&&_0x1dd812['\x6f\x6b']===![]);if(_0x4b3ce1[_0x2424f0(0xa7)](_0x269b99[_0x2424f0(0xf2)],0x0))return _0x269b99[_0x2424f0(0xd0)](isFailureDetail);}if(typeof _0x545c41===_0x2424f0(0x9f)&&_0x4b3ce1[_0x2424f0(0x96)](_0x545c41,null)&&Array[_0x2424f0(0x91)](_0x545c41[_0x2424f0(0xc0)]))return _0x545c41['\x66\x61\x69\x6c\x75\x72\x65\x73'][_0x2424f0(0xd0)](isFailureDetail);}function parseErrorResponse(_0x5997d4,_0x51b9e2,_0x2ac5aa,_0x4910af){const _0x3ab22f=a0_0x2bc80f,_0x4de7f5={'\x46\x64\x4c\x6a\x68':'\x6f\x62\x6a\x65\x63\x74','\x70\x6f\x46\x58\x43':'\x55\x6e\x6b\x6e\x6f\x77\x6e\x20\x65\x72\x72\x6f\x72','\x4b\x4a\x7a\x71\x4f':function(_0x180893,_0x5138ef){return _0x180893===_0x5138ef;},'\x44\x7a\x6d\x57\x65':_0x3ab22f(0x82),'\x67\x41\x70\x76\x61':function(_0x433cb0,_0x137da6){return _0x433cb0>_0x137da6;},'\x5a\x54\x49\x7a\x44':function(_0x1240ae,_0x56b9af,_0x40c11a){return _0x1240ae(_0x56b9af,_0x40c11a);},'\x62\x53\x4a\x49\x43':'\x78\x2d\x73\x69\x64\x65\x63\x61\x72\x2d\x76\x65\x72\x73\x69\x6f\x6e','\x43\x46\x66\x44\x48':_0x3ab22f(0xbe),'\x48\x4b\x51\x49\x46':_0x3ab22f(0xe8),'\x73\x64\x56\x70\x48':function(_0x5c165c,_0xf78040){return _0x5c165c||_0xf78040;},'\x42\x79\x77\x70\x59':_0x3ab22f(0xad),'\x74\x54\x4b\x79\x5a':function(_0x4afa9a,_0x444107){return _0x4afa9a>=_0x444107;}};let _0x456b4d;try{_0x456b4d=JSON['\x70\x61\x72\x73\x65'](_0x51b9e2);}catch{_0x456b4d={'\x6d\x65\x73\x73\x61\x67\x65':_0x51b9e2};}const _0x14bd56=_0x456b4d[_0x3ab22f(0x83)],_0x70783d=typeof _0x14bd56==='\x6f\x62\x6a\x65\x63\x74'&&_0x14bd56!==null?_0x14bd56[_0x3ab22f(0xa3)]:void 0x0,_0x27861e=typeof _0x14bd56===_0x4de7f5[_0x3ab22f(0xb4)]&&_0x14bd56!==null?_0x14bd56[_0x3ab22f(0xe2)]:void 0x0,_0xdc3efd=_0x456b4d['\x6d\x65\x73\x73\x61\x67\x65']||_0x70783d||(typeof _0x14bd56===_0x3ab22f(0x82)?_0x14bd56:void 0x0)||_0x51b9e2||_0x4de7f5[_0x3ab22f(0x8e)],_0x1b4432=_0x4de7f5[_0x3ab22f(0xae)](typeof _0x456b4d[_0x3ab22f(0xc1)],_0x4de7f5[_0x3ab22f(0xce)])&&_0x4de7f5[_0x3ab22f(0xef)](_0x456b4d['\x64\x65\x74\x61\x69\x6c\x73']['\x74\x72\x69\x6d']()['\x6c\x65\x6e\x67\x74\x68'],0x0)?_0x456b4d[_0x3ab22f(0xc1)]['\x74\x72\x69\x6d']():void 0x0,_0x3dad73=!!_0x1b4432&&_0x1b4432!==_0xdc3efd&&(_0x4de7f5[_0x3ab22f(0xae)](_0xdc3efd,_0x4de7f5[_0x3ab22f(0x8e)])||/^failed\b/i[_0x3ab22f(0xdd)](_0xdc3efd)||/^provision failed\b/i[_0x3ab22f(0xdd)](_0xdc3efd)||/^deprovision failed\b/i[_0x3ab22f(0xdd)](_0xdc3efd)),_0x1884c3=_0x456b4d[_0x3ab22f(0xe2)]||_0x27861e,_0x34edc2=''+(_0x2ac5aa?(_0x2ac5aa[_0x3ab22f(0xa9)]??_0x3ab22f(0xa6))+'\x20'+(_0x2ac5aa['\x70\x61\x74\x68']??'')+'\x3a\x20':'')+(_0x3dad73?_0xdc3efd+'\x3a\x20'+_0x1b4432:_0xdc3efd),_0x142d3d={'\x6f\x72\x69\x67\x69\x6e':_0x4de7f5[_0x3ab22f(0xcd)](inferOrigin,_0x4910af,_0x2ac5aa),'\x65\x6e\x64\x70\x6f\x69\x6e\x74':_0x2ac5aa?.['\x70\x61\x74\x68']??_0x4910af?.['\x67\x65\x74']('\x78\x2d\x74\x61\x6e\x67\x6c\x65\x2d\x72\x65\x71\x75\x65\x73\x74\x2d\x70\x61\x74\x68')??void 0x0,'\x72\x65\x74\x72\x79\x41\x66\x74\x65\x72\x4d\x73':parseRetryAfterMs(_0x4910af?.[_0x3ab22f(0xe4)]('\x72\x65\x74\x72\x79\x2d\x61\x66\x74\x65\x72')??void 0x0,_0x456b4d),'\x73\x69\x64\x65\x63\x61\x72\x56\x65\x72\x73\x69\x6f\x6e':_0x4910af?.[_0x3ab22f(0xe4)](_0x4de7f5[_0x3ab22f(0xa4)])??void 0x0,'\x63\x6f\x6e\x74\x61\x69\x6e\x65\x72\x49\x6d\x61\x67\x65':_0x4910af?.['\x67\x65\x74'](_0x3ab22f(0x9c))??_0x4910af?.[_0x3ab22f(0xe4)](_0x4de7f5[_0x3ab22f(0x77)])??void 0x0};if(isQuotaCode(_0x1884c3))return new QuotaError(_0x456b4d[_0x3ab22f(0xde)]||'\x72\x61\x74\x65\x5f\x6c\x69\x6d\x69\x74',_0x34edc2,_0x456b4d[_0x3ab22f(0xd2)],_0x456b4d[_0x3ab22f(0x88)],_0x142d3d,_0x5997d4);if(isCapabilityCode(_0x1884c3))return new CapabilityError(_0x34edc2,_0x1884c3,_0x5997d4,_0x142d3d,_0x4de7f5['\x5a\x54\x49\x7a\x44'](readCapability,_0x456b4d,_0x14bd56));if(isPartialFailureCode(_0x1884c3))return new PartialFailureError(_0x34edc2,_0x1884c3,_0x5997d4,_0x142d3d,readFailures(_0x456b4d,_0x14bd56));switch(_0x5997d4){case 0x190:return new ValidationError(_0x34edc2,_0x456b4d[_0x3ab22f(0xe3)],_0x142d3d);case 0x191:return new AuthError(_0x34edc2,_0x142d3d);case 0x194:return new NotFoundError(_0x456b4d[_0x3ab22f(0x78)]||_0x3ab22f(0xcc),_0x456b4d['\x72\x65\x73\x6f\x75\x72\x63\x65\x49\x64']||_0x4de7f5['\x48\x4b\x51\x49\x46'],_0x142d3d);case 0x198:return new TimeoutError(_0x456b4d[_0x3ab22f(0xb1)]||0x7530,_0x34edc2,_0x142d3d);case 0x199:return new StateError(_0x34edc2,_0x456b4d['\x63\x75\x72\x72\x65\x6e\x74\x53\x74\x61\x74\x65']||_0x4de7f5[_0x3ab22f(0xb5)],_0x456b4d[_0x3ab22f(0xe1)],_0x142d3d);case 0x1ad:return new QuotaError(_0x456b4d[_0x3ab22f(0xde)]||_0x3ab22f(0x84),_0x34edc2,_0x456b4d['\x63\x75\x72\x72\x65\x6e\x74'],_0x456b4d['\x6c\x69\x6d\x69\x74'],_0x142d3d);case 0x1f5:return new SandboxError(_0x34edc2,_0x4de7f5['\x73\x64\x56\x70\x48'](_0x1884c3,_0x4de7f5[_0x3ab22f(0xaf)]),_0x5997d4,_0x142d3d);default:if(_0x4de7f5['\x74\x54\x4b\x79\x5a'](_0x5997d4,0x1f4))return new ServerError(_0x34edc2,_0x5997d4,_0x142d3d);return new SandboxError(_0x34edc2,_0x1884c3||_0x3ab22f(0x9b),_0x5997d4,_0x142d3d);}}function a0_0x3877(_0x196248,_0x131b60){_0x196248=_0x196248-0x76;const _0x18bf42=a0_0x18bf();let _0x387796=_0x18bf42[_0x196248];if(a0_0x3877['\x6e\x78\x75\x53\x51\x59']===undefined){var _0x377839=function(_0x2fb6ef){const _0x2eb4b5='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';let _0x18e805='',_0x57dd92='';for(let _0x4f7a90=0x0,_0x3bdfd2,_0x10e6e7,_0x1261fb=0x0;_0x10e6e7=_0x2fb6ef['\x63\x68\x61\x72\x41\x74'](_0x1261fb++);~_0x10e6e7&&(_0x3bdfd2=_0x4f7a90%0x4?_0x3bdfd2*0x40+_0x10e6e7:_0x10e6e7,_0x4f7a90++%0x4)?_0x18e805+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0xff&_0x3bdfd2>>(-0x2*_0x4f7a90&0x6)):0x0){_0x10e6e7=_0x2eb4b5['\x69\x6e\x64\x65\x78\x4f\x66'](_0x10e6e7);}for(let _0x19f5a4=0x0,_0x1c7f14=_0x18e805['\x6c\x65\x6e\x67\x74\x68'];_0x19f5a4<_0x1c7f14;_0x19f5a4++){_0x57dd92+='\x25'+('\x30\x30'+_0x18e805['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x19f5a4)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x10))['\x73\x6c\x69\x63\x65'](-0x2);}return decodeURIComponent(_0x57dd92);};a0_0x3877['\x74\x67\x77\x61\x6c\x73']=_0x377839,a0_0x3877['\x65\x74\x61\x72\x72\x73']={},a0_0x3877['\x6e\x78\x75\x53\x51\x59']=!![];}const _0x337575=_0x18bf42[0x0],_0x49b89b=_0x196248+_0x337575,_0x1a3347=a0_0x3877['\x65\x74\x61\x72\x72\x73'][_0x49b89b];return!_0x1a3347?(_0x387796=a0_0x3877['\x74\x67\x77\x61\x6c\x73'](_0x387796),a0_0x3877['\x65\x74\x61\x72\x72\x73'][_0x49b89b]=_0x387796):_0x387796=_0x1a3347,_0x387796;}export{PartialFailureError as a,ServerError as c,ValidationError as d,parseErrorResponse as f,NotFoundError as i,StateError as l,CapabilityError as n,QuotaError as o,NetworkError as r,SandboxError as s,AuthError as t,TimeoutError as u};
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sandbox SDK Errors
|
|
4
|
+
*
|
|
5
|
+
* Error classes for the Sandbox client SDK.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base error class for all Sandbox SDK errors.
|
|
9
|
+
*/
|
|
10
|
+
var SandboxError = class extends Error {
|
|
11
|
+
/** HTTP status code if applicable */
|
|
12
|
+
status;
|
|
13
|
+
/** Error code for programmatic handling */
|
|
14
|
+
code;
|
|
15
|
+
/** Best-effort origin of the failing request */
|
|
16
|
+
origin;
|
|
17
|
+
/** Request path or endpoint when known */
|
|
18
|
+
endpoint;
|
|
19
|
+
/** Retry-after duration in ms when surfaced by the upstream */
|
|
20
|
+
retryAfterMs;
|
|
21
|
+
/** Sidecar version when the runtime emitted it */
|
|
22
|
+
sidecarVersion;
|
|
23
|
+
/** Sidecar image/tag/sha when the runtime emitted it */
|
|
24
|
+
containerImage;
|
|
25
|
+
constructor(message, code, status, metadata) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "SandboxError";
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.status = status;
|
|
30
|
+
this.origin = metadata?.origin;
|
|
31
|
+
this.endpoint = metadata?.endpoint;
|
|
32
|
+
this.retryAfterMs = metadata?.retryAfterMs;
|
|
33
|
+
this.sidecarVersion = metadata?.sidecarVersion;
|
|
34
|
+
this.containerImage = metadata?.containerImage;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Authentication failed or API key is invalid.
|
|
39
|
+
*/
|
|
40
|
+
var AuthError = class extends SandboxError {
|
|
41
|
+
constructor(message = "Authentication failed", metadata) {
|
|
42
|
+
super(message, "AUTH_ERROR", 401, metadata);
|
|
43
|
+
this.name = "AuthError";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The requested resource was not found.
|
|
48
|
+
*/
|
|
49
|
+
var NotFoundError = class extends SandboxError {
|
|
50
|
+
/** The resource type that was not found */
|
|
51
|
+
resourceType;
|
|
52
|
+
/** The resource ID that was not found */
|
|
53
|
+
resourceId;
|
|
54
|
+
constructor(resourceType, resourceId, metadata) {
|
|
55
|
+
super(`${resourceType} not found: ${resourceId}`, "NOT_FOUND", 404, metadata);
|
|
56
|
+
this.name = "NotFoundError";
|
|
57
|
+
this.resourceType = resourceType;
|
|
58
|
+
this.resourceId = resourceId;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Account quota or rate limit exceeded.
|
|
63
|
+
*/
|
|
64
|
+
var QuotaError = class extends SandboxError {
|
|
65
|
+
/** The type of quota that was exceeded */
|
|
66
|
+
quotaType;
|
|
67
|
+
/** Current usage */
|
|
68
|
+
current;
|
|
69
|
+
/** Maximum allowed */
|
|
70
|
+
limit;
|
|
71
|
+
/** Suggested retry-after duration in ms */
|
|
72
|
+
retryAfterMs;
|
|
73
|
+
constructor(quotaType, message, current, limit, metadata, status = 429) {
|
|
74
|
+
super(message ?? `Quota exceeded: ${quotaType}`, "QUOTA_EXCEEDED", status, metadata);
|
|
75
|
+
this.name = "QuotaError";
|
|
76
|
+
this.quotaType = quotaType;
|
|
77
|
+
this.current = current;
|
|
78
|
+
this.limit = limit;
|
|
79
|
+
this.retryAfterMs = metadata?.retryAfterMs;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* The requested capability is unavailable for the account, driver, or sandbox.
|
|
84
|
+
*/
|
|
85
|
+
var CapabilityError = class extends SandboxError {
|
|
86
|
+
/** Capability or feature that was rejected when known */
|
|
87
|
+
capability;
|
|
88
|
+
constructor(message, code = "CAPABILITY_UNSUPPORTED", status = 400, metadata, capability) {
|
|
89
|
+
super(message, code, status, metadata);
|
|
90
|
+
this.name = "CapabilityError";
|
|
91
|
+
this.capability = capability;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A multi-resource operation failed for one or more branches.
|
|
96
|
+
*/
|
|
97
|
+
var PartialFailureError = class extends SandboxError {
|
|
98
|
+
/** Per-resource failures returned by the API when available */
|
|
99
|
+
failures;
|
|
100
|
+
constructor(message, code = "PARTIAL_FAILURE", status = 502, metadata, failures) {
|
|
101
|
+
super(message, code, status, metadata);
|
|
102
|
+
this.name = "PartialFailureError";
|
|
103
|
+
this.failures = failures;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The request was invalid or malformed.
|
|
108
|
+
*/
|
|
109
|
+
var ValidationError = class extends SandboxError {
|
|
110
|
+
/** Field-level validation errors */
|
|
111
|
+
fields;
|
|
112
|
+
constructor(message, fields, metadata) {
|
|
113
|
+
super(message, "VALIDATION_ERROR", 400, metadata);
|
|
114
|
+
this.name = "ValidationError";
|
|
115
|
+
this.fields = fields;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The sandbox is not in a valid state for the requested operation.
|
|
120
|
+
*/
|
|
121
|
+
var StateError = class extends SandboxError {
|
|
122
|
+
/** Current state of the sandbox */
|
|
123
|
+
currentState;
|
|
124
|
+
/** Required state for the operation */
|
|
125
|
+
requiredState;
|
|
126
|
+
constructor(message, currentState, requiredState, metadata) {
|
|
127
|
+
super(message, "INVALID_STATE", 409, metadata);
|
|
128
|
+
this.name = "StateError";
|
|
129
|
+
this.currentState = currentState;
|
|
130
|
+
this.requiredState = requiredState;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* The request timed out.
|
|
135
|
+
*/
|
|
136
|
+
var TimeoutError = class extends SandboxError {
|
|
137
|
+
/** Timeout duration in milliseconds */
|
|
138
|
+
timeoutMs;
|
|
139
|
+
constructor(timeoutMs, message, metadata) {
|
|
140
|
+
super(message ?? `Request timed out after ${timeoutMs}ms`, "TIMEOUT", 408, metadata);
|
|
141
|
+
this.name = "TimeoutError";
|
|
142
|
+
this.timeoutMs = timeoutMs;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* A network or connection error occurred.
|
|
147
|
+
*/
|
|
148
|
+
var NetworkError = class extends SandboxError {
|
|
149
|
+
/** The underlying error */
|
|
150
|
+
cause;
|
|
151
|
+
constructor(message, causeOrMetadata, metadata) {
|
|
152
|
+
const cause = causeOrMetadata instanceof Error ? causeOrMetadata : void 0;
|
|
153
|
+
const resolvedMetadata = causeOrMetadata instanceof Error ? metadata : causeOrMetadata ?? metadata;
|
|
154
|
+
super(message, "NETWORK_ERROR", void 0, resolvedMetadata);
|
|
155
|
+
this.name = "NetworkError";
|
|
156
|
+
this.cause = cause;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* The server returned an unexpected error.
|
|
161
|
+
*/
|
|
162
|
+
var ServerError = class extends SandboxError {
|
|
163
|
+
constructor(message, status = 500, metadata) {
|
|
164
|
+
super(message, "SERVER_ERROR", status, metadata);
|
|
165
|
+
this.name = "ServerError";
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
function parseRetryAfterMs(rawValue, data) {
|
|
169
|
+
if (typeof data.retryAfterMs === "number" && Number.isFinite(data.retryAfterMs)) return Math.max(0, data.retryAfterMs);
|
|
170
|
+
if (!rawValue) return void 0;
|
|
171
|
+
const trimmed = rawValue.trim();
|
|
172
|
+
if (!trimmed) return void 0;
|
|
173
|
+
const seconds = Number(trimmed);
|
|
174
|
+
if (Number.isFinite(seconds)) return Math.max(0, seconds) * 1e3;
|
|
175
|
+
const targetTs = Date.parse(trimmed);
|
|
176
|
+
if (!Number.isNaN(targetTs)) return Math.max(0, targetTs - Date.now());
|
|
177
|
+
}
|
|
178
|
+
function inferOrigin(headers, context) {
|
|
179
|
+
const derivedPath = context?.path ?? headers?.get("x-tangle-request-path") ?? void 0;
|
|
180
|
+
if (!headers) return context?.path ? "sandbox-api" : void 0;
|
|
181
|
+
if (headers.has("x-sidecar-version") || headers.has("x-sidecar-image") || headers.has("x-sidecar-image-tag")) return "sidecar";
|
|
182
|
+
if (headers.has("x-orchestrator-version")) return "control-plane";
|
|
183
|
+
if (derivedPath?.startsWith("/v1/")) return "sandbox-api";
|
|
184
|
+
if (derivedPath) {
|
|
185
|
+
if (derivedPath.startsWith("/projects") || derivedPath.startsWith("/sidecars") || derivedPath.startsWith("/instances")) return "control-plane";
|
|
186
|
+
return "runtime";
|
|
187
|
+
}
|
|
188
|
+
return "unknown";
|
|
189
|
+
}
|
|
190
|
+
function isQuotaCode(code) {
|
|
191
|
+
return code === "QUOTA_EXCEEDED" || code?.endsWith("_QUOTA_EXCEEDED") === true;
|
|
192
|
+
}
|
|
193
|
+
function isCapabilityCode(code) {
|
|
194
|
+
return code === "CAPABILITY_NOT_ENABLED" || code === "CAPABILITY_UNSUPPORTED" || code === "UNSUPPORTED_CAPABILITY" || code === "FLEET_SHARED_WORKSPACE_UNSUPPORTED" || code === "SHARED_WORKSPACE_UNSUPPORTED";
|
|
195
|
+
}
|
|
196
|
+
function isPartialFailureCode(code) {
|
|
197
|
+
return code === "PARTIAL_FAILURE" || code === "FLEET_PARTIAL_FAILURE" || code === "FLEET_DISPATCH_PARTIAL_FAILURE" || code === "FLEET_DEPROVISION_FAILED";
|
|
198
|
+
}
|
|
199
|
+
function asString(value) {
|
|
200
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
201
|
+
}
|
|
202
|
+
function isFailureDetail(value) {
|
|
203
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
204
|
+
}
|
|
205
|
+
function readCapability(data, errorObj) {
|
|
206
|
+
const nested = typeof errorObj === "object" && errorObj !== null ? asString(errorObj.capability) : void 0;
|
|
207
|
+
return asString(data.capability) ?? nested;
|
|
208
|
+
}
|
|
209
|
+
function readFailures(data, errorObj) {
|
|
210
|
+
if (Array.isArray(data.failures)) return data.failures.filter(isFailureDetail);
|
|
211
|
+
if (Array.isArray(data.results)) {
|
|
212
|
+
const failures = data.results.filter((result) => typeof result === "object" && result !== null && result.ok === false);
|
|
213
|
+
if (failures.length > 0) return failures.filter(isFailureDetail);
|
|
214
|
+
}
|
|
215
|
+
if (typeof errorObj === "object" && errorObj !== null && Array.isArray(errorObj.failures)) return errorObj.failures.filter(isFailureDetail);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Parse an error response from the API.
|
|
219
|
+
* @param status - HTTP status code
|
|
220
|
+
* @param body - Response body text
|
|
221
|
+
* @param context - Optional request context for better error messages
|
|
222
|
+
*/
|
|
223
|
+
function parseErrorResponse(status, body, context, headers) {
|
|
224
|
+
let data;
|
|
225
|
+
try {
|
|
226
|
+
data = JSON.parse(body);
|
|
227
|
+
} catch {
|
|
228
|
+
data = { message: body };
|
|
229
|
+
}
|
|
230
|
+
const errorObj = data.error;
|
|
231
|
+
const nestedMessage = typeof errorObj === "object" && errorObj !== null ? errorObj.message : void 0;
|
|
232
|
+
const nestedCode = typeof errorObj === "object" && errorObj !== null ? errorObj.code : void 0;
|
|
233
|
+
const baseMessage = data.message || nestedMessage || (typeof errorObj === "string" ? errorObj : void 0) || body || "Unknown error";
|
|
234
|
+
const details = typeof data.details === "string" && data.details.trim().length > 0 ? data.details.trim() : void 0;
|
|
235
|
+
const shouldAppendDetails = !!details && details !== baseMessage && (baseMessage === "Unknown error" || /^failed\b/i.test(baseMessage) || /^provision failed\b/i.test(baseMessage) || /^deprovision failed\b/i.test(baseMessage));
|
|
236
|
+
const code = data.code || nestedCode;
|
|
237
|
+
const message = `${context ? `${context.method ?? "REQUEST"} ${context.path ?? ""}: ` : ""}${shouldAppendDetails ? `${baseMessage}: ${details}` : baseMessage}`;
|
|
238
|
+
const metadata = {
|
|
239
|
+
origin: inferOrigin(headers, context),
|
|
240
|
+
endpoint: context?.path ?? headers?.get("x-tangle-request-path") ?? void 0,
|
|
241
|
+
retryAfterMs: parseRetryAfterMs(headers?.get("retry-after") ?? void 0, data),
|
|
242
|
+
sidecarVersion: headers?.get("x-sidecar-version") ?? void 0,
|
|
243
|
+
containerImage: headers?.get("x-sidecar-image") ?? headers?.get("x-sidecar-image-tag") ?? void 0
|
|
244
|
+
};
|
|
245
|
+
if (isQuotaCode(code)) return new QuotaError(data.quotaType || "rate_limit", message, data.current, data.limit, metadata, status);
|
|
246
|
+
if (isCapabilityCode(code)) return new CapabilityError(message, code, status, metadata, readCapability(data, errorObj));
|
|
247
|
+
if (isPartialFailureCode(code)) return new PartialFailureError(message, code, status, metadata, readFailures(data, errorObj));
|
|
248
|
+
switch (status) {
|
|
249
|
+
case 400: return new ValidationError(message, data.fields, metadata);
|
|
250
|
+
case 401: return new AuthError(message, metadata);
|
|
251
|
+
case 404: return new NotFoundError(data.resourceType || "Resource", data.resourceId || "unknown", metadata);
|
|
252
|
+
case 408: return new TimeoutError(data.timeoutMs || 3e4, message, metadata);
|
|
253
|
+
case 409: return new StateError(message, data.currentState || "unknown", data.requiredState, metadata);
|
|
254
|
+
case 429: return new QuotaError(data.quotaType || "rate_limit", message, data.current, data.limit, metadata);
|
|
255
|
+
case 501: return new SandboxError(message, code || "NOT_IMPLEMENTED", status, metadata);
|
|
256
|
+
default:
|
|
257
|
+
if (status >= 500) return new ServerError(message, status, metadata);
|
|
258
|
+
return new SandboxError(message, code || "UNKNOWN_ERROR", status, metadata);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
export { PartialFailureError as a, ServerError as c, ValidationError as d, parseErrorResponse as f, NotFoundError as i, StateError as l, CapabilityError as n, QuotaError as o, NetworkError as r, SandboxError as s, AuthError as t, TimeoutError as u };
|