@airstore/sdk 0.1.0
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/README.md +341 -0
- package/dist/cjs/airstore.js +127 -0
- package/dist/cjs/airstore.js.map +1 -0
- package/dist/cjs/client.js +214 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.js +129 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/resources/connections.js +74 -0
- package/dist/cjs/resources/connections.js.map +1 -0
- package/dist/cjs/resources/filesystem.js +101 -0
- package/dist/cjs/resources/filesystem.js.map +1 -0
- package/dist/cjs/resources/index.js +18 -0
- package/dist/cjs/resources/index.js.map +1 -0
- package/dist/cjs/resources/members.js +63 -0
- package/dist/cjs/resources/members.js.map +1 -0
- package/dist/cjs/resources/oauth.js +85 -0
- package/dist/cjs/resources/oauth.js.map +1 -0
- package/dist/cjs/resources/smart-folders.js +102 -0
- package/dist/cjs/resources/smart-folders.js.map +1 -0
- package/dist/cjs/resources/tokens.js +73 -0
- package/dist/cjs/resources/tokens.js.map +1 -0
- package/dist/cjs/resources/workspaces.js +75 -0
- package/dist/cjs/resources/workspaces.js.map +1 -0
- package/dist/cjs/types/connections.js +3 -0
- package/dist/cjs/types/connections.js.map +1 -0
- package/dist/cjs/types/filesystem.js +3 -0
- package/dist/cjs/types/filesystem.js.map +1 -0
- package/dist/cjs/types/index.js +25 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/members.js +3 -0
- package/dist/cjs/types/members.js.map +1 -0
- package/dist/cjs/types/oauth.js +3 -0
- package/dist/cjs/types/oauth.js.map +1 -0
- package/dist/cjs/types/shared.js +3 -0
- package/dist/cjs/types/shared.js.map +1 -0
- package/dist/cjs/types/smart-folders.js +3 -0
- package/dist/cjs/types/smart-folders.js.map +1 -0
- package/dist/cjs/types/tokens.js +3 -0
- package/dist/cjs/types/tokens.js.map +1 -0
- package/dist/cjs/types/workspaces.js +3 -0
- package/dist/cjs/types/workspaces.js.map +1 -0
- package/dist/cjs/version.js +6 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/airstore.js +123 -0
- package/dist/esm/airstore.js.map +1 -0
- package/dist/esm/client.js +209 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +115 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/resources/connections.js +70 -0
- package/dist/esm/resources/connections.js.map +1 -0
- package/dist/esm/resources/filesystem.js +97 -0
- package/dist/esm/resources/filesystem.js.map +1 -0
- package/dist/esm/resources/index.js +8 -0
- package/dist/esm/resources/index.js.map +1 -0
- package/dist/esm/resources/members.js +59 -0
- package/dist/esm/resources/members.js.map +1 -0
- package/dist/esm/resources/oauth.js +81 -0
- package/dist/esm/resources/oauth.js.map +1 -0
- package/dist/esm/resources/smart-folders.js +98 -0
- package/dist/esm/resources/smart-folders.js.map +1 -0
- package/dist/esm/resources/tokens.js +69 -0
- package/dist/esm/resources/tokens.js.map +1 -0
- package/dist/esm/resources/workspaces.js +71 -0
- package/dist/esm/resources/workspaces.js.map +1 -0
- package/dist/esm/types/connections.js +2 -0
- package/dist/esm/types/connections.js.map +1 -0
- package/dist/esm/types/filesystem.js +2 -0
- package/dist/esm/types/filesystem.js.map +1 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/members.js +2 -0
- package/dist/esm/types/members.js.map +1 -0
- package/dist/esm/types/oauth.js +2 -0
- package/dist/esm/types/oauth.js.map +1 -0
- package/dist/esm/types/shared.js +2 -0
- package/dist/esm/types/shared.js.map +1 -0
- package/dist/esm/types/smart-folders.js +2 -0
- package/dist/esm/types/smart-folders.js.map +1 -0
- package/dist/esm/types/tokens.js +2 -0
- package/dist/esm/types/tokens.js.map +1 -0
- package/dist/esm/types/workspaces.js +2 -0
- package/dist/esm/types/workspaces.js.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/airstore.d.ts +114 -0
- package/dist/types/airstore.d.ts.map +1 -0
- package/dist/types/client.d.ts +86 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.ts +61 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/resources/connections.d.ts +50 -0
- package/dist/types/resources/connections.d.ts.map +1 -0
- package/dist/types/resources/filesystem.d.ts +81 -0
- package/dist/types/resources/filesystem.d.ts.map +1 -0
- package/dist/types/resources/index.d.ts +8 -0
- package/dist/types/resources/index.d.ts.map +1 -0
- package/dist/types/resources/members.d.ts +49 -0
- package/dist/types/resources/members.d.ts.map +1 -0
- package/dist/types/resources/oauth.d.ts +57 -0
- package/dist/types/resources/oauth.d.ts.map +1 -0
- package/dist/types/resources/smart-folders.d.ts +70 -0
- package/dist/types/resources/smart-folders.d.ts.map +1 -0
- package/dist/types/resources/tokens.d.ts +54 -0
- package/dist/types/resources/tokens.d.ts.map +1 -0
- package/dist/types/resources/workspaces.d.ts +63 -0
- package/dist/types/resources/workspaces.d.ts.map +1 -0
- package/dist/types/types/connections.d.ts +41 -0
- package/dist/types/types/connections.d.ts.map +1 -0
- package/dist/types/types/filesystem.d.ts +39 -0
- package/dist/types/types/filesystem.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +9 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/members.d.ts +30 -0
- package/dist/types/types/members.d.ts.map +1 -0
- package/dist/types/types/oauth.d.ts +40 -0
- package/dist/types/types/oauth.d.ts.map +1 -0
- package/dist/types/types/shared.d.ts +27 -0
- package/dist/types/types/shared.d.ts.map +1 -0
- package/dist/types/types/smart-folders.d.ts +45 -0
- package/dist/types/types/smart-folders.d.ts.map +1 -0
- package/dist/types/types/tokens.d.ts +40 -0
- package/dist/types/types/tokens.d.ts.map +1 -0
- package/dist/types/types/workspaces.d.ts +26 -0
- package/dist/types/types/workspaces.d.ts.map +1 -0
- package/dist/types/version.d.ts +3 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.APIError = exports.AirstoreError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base error for all Airstore SDK errors.
|
|
6
|
+
*/
|
|
7
|
+
class AirstoreError extends Error {
|
|
8
|
+
cause;
|
|
9
|
+
constructor(message, cause) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.name = 'AirstoreError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AirstoreError = AirstoreError;
|
|
16
|
+
/**
|
|
17
|
+
* Error returned by the Airstore API.
|
|
18
|
+
*
|
|
19
|
+
* Contains the HTTP status code, response headers, and optional request ID
|
|
20
|
+
* for debugging. Use the semantic subclasses (AuthenticationError, NotFoundError, etc.)
|
|
21
|
+
* for targeted catch blocks.
|
|
22
|
+
*/
|
|
23
|
+
class APIError extends AirstoreError {
|
|
24
|
+
status;
|
|
25
|
+
headers;
|
|
26
|
+
requestId;
|
|
27
|
+
constructor(status, message, headers, requestId) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = 'APIError';
|
|
30
|
+
this.status = status;
|
|
31
|
+
this.headers = headers;
|
|
32
|
+
this.requestId = requestId;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate the appropriate APIError subclass for a given HTTP status.
|
|
36
|
+
*/
|
|
37
|
+
static generate(status, errorBody, message, headers) {
|
|
38
|
+
const requestId = headers.get('x-request-id') ?? headers.get('X-Request-Id') ?? undefined;
|
|
39
|
+
if (status === 401)
|
|
40
|
+
return new AuthenticationError(message, headers, requestId);
|
|
41
|
+
if (status === 403)
|
|
42
|
+
return new PermissionDeniedError(message, headers, requestId);
|
|
43
|
+
if (status === 404)
|
|
44
|
+
return new NotFoundError(message, headers, requestId);
|
|
45
|
+
if (status === 409)
|
|
46
|
+
return new ConflictError(message, headers, requestId);
|
|
47
|
+
if (status === 422)
|
|
48
|
+
return new UnprocessableEntityError(message, headers, requestId);
|
|
49
|
+
if (status === 429)
|
|
50
|
+
return new RateLimitError(message, headers, requestId);
|
|
51
|
+
if (status >= 500)
|
|
52
|
+
return new InternalServerError(status, message, headers, requestId);
|
|
53
|
+
return new APIError(status, message, headers, requestId);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.APIError = APIError;
|
|
57
|
+
/** 401 - Invalid or missing API key. */
|
|
58
|
+
class AuthenticationError extends APIError {
|
|
59
|
+
constructor(message, headers, requestId) {
|
|
60
|
+
super(401, message, headers, requestId);
|
|
61
|
+
this.name = 'AuthenticationError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.AuthenticationError = AuthenticationError;
|
|
65
|
+
/** 403 - Token lacks permission for this operation. */
|
|
66
|
+
class PermissionDeniedError extends APIError {
|
|
67
|
+
constructor(message, headers, requestId) {
|
|
68
|
+
super(403, message, headers, requestId);
|
|
69
|
+
this.name = 'PermissionDeniedError';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.PermissionDeniedError = PermissionDeniedError;
|
|
73
|
+
/** 404 - Resource not found. */
|
|
74
|
+
class NotFoundError extends APIError {
|
|
75
|
+
constructor(message, headers, requestId) {
|
|
76
|
+
super(404, message, headers, requestId);
|
|
77
|
+
this.name = 'NotFoundError';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.NotFoundError = NotFoundError;
|
|
81
|
+
/** 409 - Conflicting operation. */
|
|
82
|
+
class ConflictError extends APIError {
|
|
83
|
+
constructor(message, headers, requestId) {
|
|
84
|
+
super(409, message, headers, requestId);
|
|
85
|
+
this.name = 'ConflictError';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.ConflictError = ConflictError;
|
|
89
|
+
/** 422 - Validation failed. */
|
|
90
|
+
class UnprocessableEntityError extends APIError {
|
|
91
|
+
constructor(message, headers, requestId) {
|
|
92
|
+
super(422, message, headers, requestId);
|
|
93
|
+
this.name = 'UnprocessableEntityError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
97
|
+
/** 429 - Rate limit exceeded. Retry after the period indicated by Retry-After header. */
|
|
98
|
+
class RateLimitError extends APIError {
|
|
99
|
+
constructor(message, headers, requestId) {
|
|
100
|
+
super(429, message, headers, requestId);
|
|
101
|
+
this.name = 'RateLimitError';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.RateLimitError = RateLimitError;
|
|
105
|
+
/** 5xx - Server-side error. Safe to retry with backoff. */
|
|
106
|
+
class InternalServerError extends APIError {
|
|
107
|
+
constructor(status, message, headers, requestId) {
|
|
108
|
+
super(status, message, headers, requestId);
|
|
109
|
+
this.name = 'InternalServerError';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.InternalServerError = InternalServerError;
|
|
113
|
+
/** Network-level connection failure (DNS, TCP, TLS). */
|
|
114
|
+
class APIConnectionError extends AirstoreError {
|
|
115
|
+
constructor(message, cause) {
|
|
116
|
+
super(message, cause);
|
|
117
|
+
this.name = 'APIConnectionError';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.APIConnectionError = APIConnectionError;
|
|
121
|
+
/** Request timed out. */
|
|
122
|
+
class APIConnectionTimeoutError extends APIConnectionError {
|
|
123
|
+
constructor(message = 'Request timed out') {
|
|
124
|
+
super(message);
|
|
125
|
+
this.name = 'APIConnectionTimeoutError';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.APIConnectionTimeoutError = APIConnectionTimeoutError;
|
|
129
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACO;IAA7C,YAAY,OAAe,EAAkB,KAAe;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,UAAK,GAAL,KAAK,CAAU;QAE1D,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC;AAED;;;;;;GAMG;AACH,MAAa,QAAS,SAAQ,aAAa;IAChC,MAAM,CAAS;IACf,OAAO,CAAU;IACjB,SAAS,CAAqB;IAEvC,YACE,MAAc,EACd,OAAe,EACf,OAAgB,EAChB,SAA6B;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CACb,MAAc,EACd,SAAkB,EAClB,OAAe,EACf,OAAgB;QAEhB,MAAM,SAAS,GACb,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,SAAS,CAAC;QAE1E,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAChF,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAClF,IAAI,MAAM,KAA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AI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED,yBAAyB;AACzB,MAAa,yBAA0B,SAAQ,kBAAkB;IAC/D,YAAY,UAAkB,mBAAmB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AALD,8DAKC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @module @airstore/sdk */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.VERSION = exports.Filesystem = exports.OAuth = exports.Members = exports.Tokens = exports.SmartFolders = exports.Connections = exports.Workspaces = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.APIError = exports.AirstoreError = exports.default = exports.Airstore = void 0;
|
|
5
|
+
// ── Main client ──────────────────────────────────────────────────────────────
|
|
6
|
+
var airstore_js_1 = require("./airstore.js");
|
|
7
|
+
Object.defineProperty(exports, "Airstore", { enumerable: true, get: function () { return airstore_js_1.Airstore; } });
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return airstore_js_1.Airstore; } });
|
|
9
|
+
// ── Errors ───────────────────────────────────────────────────────────────────
|
|
10
|
+
var errors_js_1 = require("./errors.js");
|
|
11
|
+
Object.defineProperty(exports, "AirstoreError", { enumerable: true, get: function () { return errors_js_1.AirstoreError; } });
|
|
12
|
+
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return errors_js_1.APIError; } });
|
|
13
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_js_1.AuthenticationError; } });
|
|
14
|
+
Object.defineProperty(exports, "PermissionDeniedError", { enumerable: true, get: function () { return errors_js_1.PermissionDeniedError; } });
|
|
15
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_js_1.NotFoundError; } });
|
|
16
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return errors_js_1.ConflictError; } });
|
|
17
|
+
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return errors_js_1.UnprocessableEntityError; } });
|
|
18
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_1.RateLimitError; } });
|
|
19
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return errors_js_1.InternalServerError; } });
|
|
20
|
+
Object.defineProperty(exports, "APIConnectionError", { enumerable: true, get: function () { return errors_js_1.APIConnectionError; } });
|
|
21
|
+
Object.defineProperty(exports, "APIConnectionTimeoutError", { enumerable: true, get: function () { return errors_js_1.APIConnectionTimeoutError; } });
|
|
22
|
+
// ── Resource classes ─────────────────────────────────────────────────────────
|
|
23
|
+
var workspaces_js_1 = require("./resources/workspaces.js");
|
|
24
|
+
Object.defineProperty(exports, "Workspaces", { enumerable: true, get: function () { return workspaces_js_1.Workspaces; } });
|
|
25
|
+
var connections_js_1 = require("./resources/connections.js");
|
|
26
|
+
Object.defineProperty(exports, "Connections", { enumerable: true, get: function () { return connections_js_1.Connections; } });
|
|
27
|
+
var smart_folders_js_1 = require("./resources/smart-folders.js");
|
|
28
|
+
Object.defineProperty(exports, "SmartFolders", { enumerable: true, get: function () { return smart_folders_js_1.SmartFolders; } });
|
|
29
|
+
var tokens_js_1 = require("./resources/tokens.js");
|
|
30
|
+
Object.defineProperty(exports, "Tokens", { enumerable: true, get: function () { return tokens_js_1.Tokens; } });
|
|
31
|
+
var members_js_1 = require("./resources/members.js");
|
|
32
|
+
Object.defineProperty(exports, "Members", { enumerable: true, get: function () { return members_js_1.Members; } });
|
|
33
|
+
var oauth_js_1 = require("./resources/oauth.js");
|
|
34
|
+
Object.defineProperty(exports, "OAuth", { enumerable: true, get: function () { return oauth_js_1.OAuth; } });
|
|
35
|
+
var filesystem_js_1 = require("./resources/filesystem.js");
|
|
36
|
+
Object.defineProperty(exports, "Filesystem", { enumerable: true, get: function () { return filesystem_js_1.Filesystem; } });
|
|
37
|
+
// ── Version ──────────────────────────────────────────────────────────────────
|
|
38
|
+
var version_js_1 = require("./version.js");
|
|
39
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_js_1.VERSION; } });
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,gFAAgF;AAChF,6CAA8D;AAArD,uGAAA,QAAQ,OAAA;AAAE,sGAAA,QAAQ,OAAW;AAGtC,gFAAgF;AAChF,yCAYqB;AAXnB,0GAAA,aAAa,OAAA;AACb,qGAAA,QAAQ,OAAA;AACR,gHAAA,mBAAmB,OAAA;AACnB,kHAAA,qBAAqB,OAAA;AACrB,0GAAA,aAAa,OAAA;AACb,0GAAA,aAAa,OAAA;AACb,qHAAA,wBAAwB,OAAA;AACxB,2GAAA,cAAc,OAAA;AACd,gHAAA,mBAAmB,OAAA;AACnB,+GAAA,kBAAkB,OAAA;AAClB,sHAAA,yBAAyB,OAAA;AAG3B,gFAAgF;AAChF,2DAAuD;AAA9C,2GAAA,UAAU,OAAA;AACnB,6DAAyD;AAAhD,6GAAA,WAAW,OAAA;AACpB,iEAA4D;AAAnD,gHAAA,YAAY,OAAA;AACrB,mDAA+C;AAAtC,mGAAA,MAAM,OAAA;AACf,qDAAiD;AAAxC,qGAAA,OAAO,OAAA;AAChB,iDAA6C;AAApC,iGAAA,KAAK,OAAA;AACd,2DAAuD;AAA9C,2GAAA,UAAU,OAAA;AAYnB,gFAAgF;AAChF,2CAAuC;AAA9B,qGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Connections = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Manage connections (integrations) within a workspace.
|
|
6
|
+
*
|
|
7
|
+
* Connections store OAuth tokens or API keys for external services like
|
|
8
|
+
* Gmail, GitHub, Notion, etc. Pass existing tokens directly to avoid
|
|
9
|
+
* requiring users to re-authenticate.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* await airstore.connections.create("ws_abc", {
|
|
14
|
+
* integrationType: "gmail",
|
|
15
|
+
* accessToken: existingAccessToken,
|
|
16
|
+
* refreshToken: existingRefreshToken,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
class Connections {
|
|
21
|
+
client;
|
|
22
|
+
constructor(client) {
|
|
23
|
+
this.client = client;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a connection by passing existing OAuth credentials or API keys.
|
|
27
|
+
*
|
|
28
|
+
* @param workspaceId - Workspace external ID.
|
|
29
|
+
* @param params - Connection creation parameters.
|
|
30
|
+
* @param options - Per-request overrides.
|
|
31
|
+
* @returns The created connection.
|
|
32
|
+
*/
|
|
33
|
+
async create(workspaceId, params, options) {
|
|
34
|
+
const body = {
|
|
35
|
+
integration_type: params.integrationType,
|
|
36
|
+
};
|
|
37
|
+
if (params.accessToken !== undefined)
|
|
38
|
+
body['access_token'] = params.accessToken;
|
|
39
|
+
if (params.refreshToken !== undefined)
|
|
40
|
+
body['refresh_token'] = params.refreshToken;
|
|
41
|
+
if (params.apiKey !== undefined)
|
|
42
|
+
body['api_key'] = params.apiKey;
|
|
43
|
+
if (params.scope !== undefined)
|
|
44
|
+
body['scope'] = params.scope;
|
|
45
|
+
if (params.extra !== undefined)
|
|
46
|
+
body['extra'] = params.extra;
|
|
47
|
+
return this.client.request('POST', `/workspaces/${workspaceId}/connections`, body, undefined, options);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* List all connections in a workspace.
|
|
51
|
+
*
|
|
52
|
+
* @param workspaceId - Workspace external ID.
|
|
53
|
+
* @param options - Per-request overrides.
|
|
54
|
+
* @returns Array of connections.
|
|
55
|
+
*/
|
|
56
|
+
async list(workspaceId, options) {
|
|
57
|
+
const result = await this.client.request('GET', `/workspaces/${workspaceId}/connections`, undefined, undefined, options);
|
|
58
|
+
return Array.isArray(result) ? result : [];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Delete a connection.
|
|
62
|
+
*
|
|
63
|
+
* @param workspaceId - Workspace external ID.
|
|
64
|
+
* @param connectionId - Connection external ID.
|
|
65
|
+
* @param options - Per-request overrides.
|
|
66
|
+
*
|
|
67
|
+
* @throws {NotFoundError} If the connection doesn't exist.
|
|
68
|
+
*/
|
|
69
|
+
async del(workspaceId, connectionId, options) {
|
|
70
|
+
await this.client.request('DELETE', `/workspaces/${workspaceId}/connections/${connectionId}`, undefined, undefined, options);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Connections = Connections;
|
|
74
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/resources/connections.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAa,WAAW;IACO;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACV,WAAmB,EACnB,MAA8B,EAC9B,OAAwB;QAExB,MAAM,IAAI,GAA4B;YACpC,gBAAgB,EAAE,MAAM,CAAC,eAAe;SACzC,CAAC;QACF,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC;QAChF,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS;YAAE,IAAI,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC;QACnF,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QACjE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAC7D,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAE7D,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,eAAe,WAAW,cAAc,EACxC,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,OAAwB;QACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACtC,KAAK,EACL,eAAe,WAAW,cAAc,EACxC,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;QACF,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,GAAG,CACP,WAAmB,EACnB,YAAoB,EACpB,OAAwB;QAExB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACvB,QAAQ,EACR,eAAe,WAAW,gBAAgB,YAAY,EAAE,EACxD,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AA1ED,kCA0EC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Filesystem = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Read-only access to the workspace virtual filesystem.
|
|
6
|
+
*
|
|
7
|
+
* The filesystem provides a unified view of all connected integrations,
|
|
8
|
+
* smart folders, tools, and user-uploaded files.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const listing = await airstore.fs.list("ws_abc", { path: "/" });
|
|
13
|
+
* const content = await airstore.fs.read("ws_abc", {
|
|
14
|
+
* path: "/Sources/gmail/inbox/email.txt",
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
class Filesystem {
|
|
19
|
+
client;
|
|
20
|
+
constructor(client) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List directory contents.
|
|
25
|
+
*
|
|
26
|
+
* @param workspaceId - Workspace external ID.
|
|
27
|
+
* @param opts - Listing options.
|
|
28
|
+
* @param opts.path - Directory path to list. Defaults to root.
|
|
29
|
+
* @param options - Per-request overrides.
|
|
30
|
+
* @returns Array of files and directories.
|
|
31
|
+
*/
|
|
32
|
+
async list(workspaceId, opts = {}, options) {
|
|
33
|
+
const params = {};
|
|
34
|
+
if (opts.path !== undefined)
|
|
35
|
+
params['path'] = opts.path;
|
|
36
|
+
const result = await this.client.request('GET', `/workspaces/${workspaceId}/fs/list`, undefined, params, options);
|
|
37
|
+
return result.entries ?? [];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read file contents as a string.
|
|
41
|
+
*
|
|
42
|
+
* @param workspaceId - Workspace external ID.
|
|
43
|
+
* @param opts - Read options.
|
|
44
|
+
* @param opts.path - File path to read.
|
|
45
|
+
* @param opts.offset - Byte offset to start reading from.
|
|
46
|
+
* @param opts.length - Number of bytes to read.
|
|
47
|
+
* @param options - Per-request overrides.
|
|
48
|
+
* @returns File contents as a string.
|
|
49
|
+
*
|
|
50
|
+
* @throws {NotFoundError} If the file doesn't exist.
|
|
51
|
+
*/
|
|
52
|
+
async read(workspaceId, opts, options) {
|
|
53
|
+
const params = { path: opts.path };
|
|
54
|
+
if (opts.offset !== undefined)
|
|
55
|
+
params['offset'] = String(opts.offset);
|
|
56
|
+
if (opts.length !== undefined)
|
|
57
|
+
params['length'] = String(opts.length);
|
|
58
|
+
const resp = await this.client.rawRequest('GET', `/workspaces/${workspaceId}/fs/read`, { params, ...options });
|
|
59
|
+
return resp.text();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get a directory tree for efficient prefetching.
|
|
63
|
+
*
|
|
64
|
+
* Returns a flat list of all entries under the given path. Supports
|
|
65
|
+
* pagination via `continuationToken` for large directories.
|
|
66
|
+
*
|
|
67
|
+
* @param workspaceId - Workspace external ID.
|
|
68
|
+
* @param opts - Tree options.
|
|
69
|
+
* @param opts.path - Root path for the tree. Defaults to root.
|
|
70
|
+
* @param opts.maxKeys - Maximum number of entries to return.
|
|
71
|
+
* @param opts.continuationToken - Token from a previous truncated response.
|
|
72
|
+
* @param options - Per-request overrides.
|
|
73
|
+
* @returns Tree listing with entries and pagination info.
|
|
74
|
+
*/
|
|
75
|
+
async tree(workspaceId, opts = {}, options) {
|
|
76
|
+
const params = {};
|
|
77
|
+
if (opts.path !== undefined)
|
|
78
|
+
params['path'] = opts.path;
|
|
79
|
+
if (opts.maxKeys !== undefined)
|
|
80
|
+
params['max_keys'] = String(opts.maxKeys);
|
|
81
|
+
if (opts.continuationToken !== undefined) {
|
|
82
|
+
params['continuation_token'] = opts.continuationToken;
|
|
83
|
+
}
|
|
84
|
+
return this.client.request('GET', `/workspaces/${workspaceId}/fs/tree`, undefined, params, options);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get file or directory metadata.
|
|
88
|
+
*
|
|
89
|
+
* @param workspaceId - Workspace external ID.
|
|
90
|
+
* @param path - Absolute path to stat.
|
|
91
|
+
* @param options - Per-request overrides.
|
|
92
|
+
* @returns File metadata.
|
|
93
|
+
*
|
|
94
|
+
* @throws {NotFoundError} If the path doesn't exist.
|
|
95
|
+
*/
|
|
96
|
+
async stat(workspaceId, path, options) {
|
|
97
|
+
return this.client.request('GET', `/workspaces/${workspaceId}/fs/stat`, undefined, { path }, options);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.Filesystem = Filesystem;
|
|
101
|
+
//# sourceMappingURL=filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../../src/resources/filesystem.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAU;IACQ;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CACR,WAAmB,EACnB,OAA0B,EAAE,EAC5B,OAAwB;QAExB,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QAExD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACtC,KAAK,EACL,eAAe,WAAW,UAAU,EACpC,SAAS,EACT,MAAM,EACN,OAAO,CACR,CAAC;QACF,OAAQ,MAA2B,CAAC,OAAO,IAAI,EAAE,CAAC;IACpD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,IAAI,CACR,WAAmB,EACnB,IAAwD,EACxD,OAAwB;QAExB,MAAM,MAAM,GAA2B,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3D,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEtE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CACvC,KAAK,EACL,eAAe,WAAW,UAAU,EACpC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CACvB,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,IAAI,CACR,WAAmB,EACnB,OAAwE,EAAE,EAC1E,OAAwB;QAExB,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QACxD,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACxD,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,eAAe,WAAW,UAAU,EACpC,SAAS,EACT,MAAM,EACN,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI,CACR,WAAmB,EACnB,IAAY,EACZ,OAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,eAAe,WAAW,UAAU,EACpC,SAAS,EACT,EAAE,IAAI,EAAE,EACR,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAtHD,gCAsHC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Filesystem = exports.OAuth = exports.Members = exports.Tokens = exports.SmartFolders = exports.Connections = exports.Workspaces = void 0;
|
|
4
|
+
var workspaces_js_1 = require("./workspaces.js");
|
|
5
|
+
Object.defineProperty(exports, "Workspaces", { enumerable: true, get: function () { return workspaces_js_1.Workspaces; } });
|
|
6
|
+
var connections_js_1 = require("./connections.js");
|
|
7
|
+
Object.defineProperty(exports, "Connections", { enumerable: true, get: function () { return connections_js_1.Connections; } });
|
|
8
|
+
var smart_folders_js_1 = require("./smart-folders.js");
|
|
9
|
+
Object.defineProperty(exports, "SmartFolders", { enumerable: true, get: function () { return smart_folders_js_1.SmartFolders; } });
|
|
10
|
+
var tokens_js_1 = require("./tokens.js");
|
|
11
|
+
Object.defineProperty(exports, "Tokens", { enumerable: true, get: function () { return tokens_js_1.Tokens; } });
|
|
12
|
+
var members_js_1 = require("./members.js");
|
|
13
|
+
Object.defineProperty(exports, "Members", { enumerable: true, get: function () { return members_js_1.Members; } });
|
|
14
|
+
var oauth_js_1 = require("./oauth.js");
|
|
15
|
+
Object.defineProperty(exports, "OAuth", { enumerable: true, get: function () { return oauth_js_1.OAuth; } });
|
|
16
|
+
var filesystem_js_1 = require("./filesystem.js");
|
|
17
|
+
Object.defineProperty(exports, "Filesystem", { enumerable: true, get: function () { return filesystem_js_1.Filesystem; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AACpB,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,2CAAuC;AAA9B,qGAAA,OAAO,OAAA;AAChB,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AACd,iDAA6C;AAApC,2GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Members = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Manage workspace members.
|
|
6
|
+
*
|
|
7
|
+
* Members are users with roles (admin, member, viewer) in a workspace.
|
|
8
|
+
* Tokens are always associated with a member.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const member = await airstore.members.create("ws_abc", {
|
|
13
|
+
* email: "agent@internal",
|
|
14
|
+
* name: "Agent",
|
|
15
|
+
* role: "member",
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class Members {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Add a member to a workspace.
|
|
26
|
+
*
|
|
27
|
+
* @param workspaceId - Workspace external ID.
|
|
28
|
+
* @param params - Member creation parameters.
|
|
29
|
+
* @param options - Per-request overrides.
|
|
30
|
+
* @returns The created member.
|
|
31
|
+
*/
|
|
32
|
+
async create(workspaceId, params, options) {
|
|
33
|
+
return this.client.request('POST', `/workspaces/${workspaceId}/members`, {
|
|
34
|
+
email: params.email,
|
|
35
|
+
name: params.name,
|
|
36
|
+
role: params.role ?? 'member',
|
|
37
|
+
}, undefined, options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* List members of a workspace.
|
|
41
|
+
*
|
|
42
|
+
* @param workspaceId - Workspace external ID.
|
|
43
|
+
* @param options - Per-request overrides.
|
|
44
|
+
* @returns Array of members.
|
|
45
|
+
*/
|
|
46
|
+
async list(workspaceId, options) {
|
|
47
|
+
return this.client.request('GET', `/workspaces/${workspaceId}/members`, undefined, undefined, options);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Remove a member from a workspace.
|
|
51
|
+
*
|
|
52
|
+
* @param workspaceId - Workspace external ID.
|
|
53
|
+
* @param memberId - Member external ID.
|
|
54
|
+
* @param options - Per-request overrides.
|
|
55
|
+
*
|
|
56
|
+
* @throws {NotFoundError} If the member doesn't exist.
|
|
57
|
+
*/
|
|
58
|
+
async del(workspaceId, memberId, options) {
|
|
59
|
+
await this.client.request('DELETE', `/workspaces/${workspaceId}/members/${memberId}`, undefined, undefined, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.Members = Members;
|
|
63
|
+
//# sourceMappingURL=members.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../../src/resources/members.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;GAcG;AACH,MAAa,OAAO;IACW;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACV,WAAmB,EACnB,MAA0B,EAC1B,OAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,eAAe,WAAW,UAAU,EACpC;YACE,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,QAAQ;SAC9B,EACD,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,eAAe,WAAW,UAAU,EACpC,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,GAAG,CACP,WAAmB,EACnB,QAAgB,EAChB,OAAwB;QAExB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACvB,QAAQ,EACR,eAAe,WAAW,YAAY,QAAQ,EAAE,EAChD,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AApED,0BAoEC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuth = void 0;
|
|
4
|
+
const errors_js_1 = require("../errors.js");
|
|
5
|
+
/**
|
|
6
|
+
* Manage OAuth sessions for interactive connection setup.
|
|
7
|
+
*
|
|
8
|
+
* Use this when you want users to authorize via browser redirect
|
|
9
|
+
* rather than passing tokens directly.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const session = await airstore.oauth.createSession({
|
|
14
|
+
* integrationType: "gmail",
|
|
15
|
+
* returnTo: "https://myapp.com/callback",
|
|
16
|
+
* });
|
|
17
|
+
* console.log(session.authorize_url); // redirect user here
|
|
18
|
+
* const completed = await airstore.oauth.poll(session.session_id);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
class OAuth {
|
|
22
|
+
client;
|
|
23
|
+
constructor(client) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create an OAuth session to initiate the authorization flow.
|
|
28
|
+
*
|
|
29
|
+
* Returns a session with an `authorize_url` that the user should be
|
|
30
|
+
* redirected to. Once they complete authorization, poll the session
|
|
31
|
+
* for the resulting connection ID.
|
|
32
|
+
*
|
|
33
|
+
* @param params - Session creation parameters.
|
|
34
|
+
* @param options - Per-request overrides.
|
|
35
|
+
* @returns The session with authorize_url to redirect the user to.
|
|
36
|
+
*/
|
|
37
|
+
async createSession(params, options) {
|
|
38
|
+
const body = {
|
|
39
|
+
integration_type: params.integrationType,
|
|
40
|
+
};
|
|
41
|
+
if (params.returnTo !== undefined)
|
|
42
|
+
body['return_to'] = params.returnTo;
|
|
43
|
+
return this.client.request('POST', '/oauth/sessions', body, undefined, options);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the current status of an OAuth session.
|
|
47
|
+
*
|
|
48
|
+
* @param sessionId - Session ID from createSession.
|
|
49
|
+
* @param options - Per-request overrides.
|
|
50
|
+
* @returns The session status.
|
|
51
|
+
*/
|
|
52
|
+
async getSession(sessionId, options) {
|
|
53
|
+
return this.client.request('GET', `/oauth/sessions/${sessionId}`, undefined, undefined, options);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Poll an OAuth session until completion or timeout.
|
|
57
|
+
*
|
|
58
|
+
* Repeatedly checks session status at the specified interval until
|
|
59
|
+
* the session completes, errors, or the timeout is reached.
|
|
60
|
+
*
|
|
61
|
+
* @param sessionId - Session ID from createSession.
|
|
62
|
+
* @param pollOpts - Polling configuration (timeout, interval).
|
|
63
|
+
* @param options - Per-request overrides.
|
|
64
|
+
* @returns The completed session status with connection_id.
|
|
65
|
+
*
|
|
66
|
+
* @throws {AirstoreError} If the session errors or times out.
|
|
67
|
+
*/
|
|
68
|
+
async poll(sessionId, pollOpts, options) {
|
|
69
|
+
const timeout = pollOpts?.timeout ?? 300_000;
|
|
70
|
+
const interval = pollOpts?.interval ?? 2_000;
|
|
71
|
+
const deadline = Date.now() + timeout;
|
|
72
|
+
while (Date.now() < deadline) {
|
|
73
|
+
const status = await this.getSession(sessionId, options);
|
|
74
|
+
if (status.status === 'complete')
|
|
75
|
+
return status;
|
|
76
|
+
if (status.status === 'error') {
|
|
77
|
+
throw new errors_js_1.AirstoreError(`OAuth session failed: ${status.error ?? 'unknown error'}`);
|
|
78
|
+
}
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
80
|
+
}
|
|
81
|
+
throw new errors_js_1.AirstoreError(`OAuth session timed out after ${timeout}ms`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.OAuth = OAuth;
|
|
85
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/resources/oauth.ts"],"names":[],"mappings":";;;AAOA,4CAA6C;AAE7C;;;;;;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AAC;gBAC9B,MAAM,IAAI,yBAAa,CACrB,yBAAyB,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,CAC3D,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,IAAI,yBAAa,CAAC,iCAAiC,OAAO,IAAI,CAAC,CAAC;IACxE,CAAC;CACF;AAzFD,sBAyFC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SmartFolders = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Manage smart folders (filesystem queries) within a workspace.
|
|
6
|
+
*
|
|
7
|
+
* Smart folders use LLM inference to automatically organize and filter
|
|
8
|
+
* data from connected integrations into virtual folders or files.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* await airstore.smartFolders.create("ws_abc", {
|
|
13
|
+
* integration: "gmail",
|
|
14
|
+
* name: "Recent Emails",
|
|
15
|
+
* guidance: "Last 7 days of emails",
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class SmartFolders {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a new smart folder.
|
|
26
|
+
*
|
|
27
|
+
* @param workspaceId - Workspace external ID.
|
|
28
|
+
* @param params - Smart folder creation parameters.
|
|
29
|
+
* @param options - Per-request overrides.
|
|
30
|
+
* @returns The created smart folder.
|
|
31
|
+
*/
|
|
32
|
+
async create(workspaceId, params, options) {
|
|
33
|
+
const body = {
|
|
34
|
+
integration: params.integration,
|
|
35
|
+
name: params.name,
|
|
36
|
+
output_format: params.outputFormat ?? 'folder',
|
|
37
|
+
};
|
|
38
|
+
if (params.guidance !== undefined)
|
|
39
|
+
body['guidance'] = params.guidance;
|
|
40
|
+
if (params.fileExt !== undefined)
|
|
41
|
+
body['file_ext'] = params.fileExt;
|
|
42
|
+
return this.client.request('POST', `/workspaces/${workspaceId}/fs/queries`, body, undefined, options);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* List all smart folders in a workspace.
|
|
46
|
+
*
|
|
47
|
+
* @param workspaceId - Workspace external ID.
|
|
48
|
+
* @param options - Per-request overrides.
|
|
49
|
+
* @returns Array of smart folders.
|
|
50
|
+
*/
|
|
51
|
+
async list(workspaceId, options) {
|
|
52
|
+
// API may return { queries: [...] } or a direct array depending on version
|
|
53
|
+
const result = await this.client.request('GET', `/workspaces/${workspaceId}/fs/queries/list`, undefined, undefined, options);
|
|
54
|
+
if (Array.isArray(result))
|
|
55
|
+
return result;
|
|
56
|
+
return result.queries ?? [];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve a smart folder by its virtual filesystem path.
|
|
60
|
+
*
|
|
61
|
+
* @param workspaceId - Workspace external ID.
|
|
62
|
+
* @param queryPath - Virtual path of the smart folder.
|
|
63
|
+
* @param options - Per-request overrides.
|
|
64
|
+
* @returns The smart folder.
|
|
65
|
+
*
|
|
66
|
+
* @throws {NotFoundError} If the smart folder doesn't exist.
|
|
67
|
+
*/
|
|
68
|
+
async retrieve(workspaceId, queryPath, options) {
|
|
69
|
+
return this.client.request('GET', `/workspaces/${workspaceId}/fs/queries`, undefined, { path: queryPath }, options);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Update an existing smart folder.
|
|
73
|
+
*
|
|
74
|
+
* @param workspaceId - Workspace external ID.
|
|
75
|
+
* @param queryId - Smart folder external ID.
|
|
76
|
+
* @param params - Fields to update.
|
|
77
|
+
* @param options - Per-request overrides.
|
|
78
|
+
* @returns The updated smart folder.
|
|
79
|
+
*/
|
|
80
|
+
async update(workspaceId, queryId, params, options) {
|
|
81
|
+
const body = {};
|
|
82
|
+
if (params.name !== undefined)
|
|
83
|
+
body['name'] = params.name;
|
|
84
|
+
if (params.guidance !== undefined)
|
|
85
|
+
body['guidance'] = params.guidance;
|
|
86
|
+
return this.client.request('PUT', `/workspaces/${workspaceId}/fs/queries/${queryId}`, body, undefined, options);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Delete a smart folder.
|
|
90
|
+
*
|
|
91
|
+
* @param workspaceId - Workspace external ID.
|
|
92
|
+
* @param queryId - Smart folder external ID.
|
|
93
|
+
* @param options - Per-request overrides.
|
|
94
|
+
*
|
|
95
|
+
* @throws {NotFoundError} If the smart folder doesn't exist.
|
|
96
|
+
*/
|
|
97
|
+
async del(workspaceId, queryId, options) {
|
|
98
|
+
await this.client.request('DELETE', `/workspaces/${workspaceId}/fs/queries/${queryId}`, undefined, undefined, options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.SmartFolders = SmartFolders;
|
|
102
|
+
//# sourceMappingURL=smart-folders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-folders.js","sourceRoot":"","sources":["../../../src/resources/smart-folders.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;GAcG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACV,WAAmB,EACnB,MAA+B,EAC/B,OAAwB;QAExB,MAAM,IAAI,GAA4B;YACpC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,aAAa,EAAE,MAAM,CAAC,YAAY,IAAI,QAAQ;SAC/C,CAAC;QACF,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QACtE,IAAI,MAAM,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