@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.
Files changed (134) hide show
  1. package/README.md +341 -0
  2. package/dist/cjs/airstore.js +127 -0
  3. package/dist/cjs/airstore.js.map +1 -0
  4. package/dist/cjs/client.js +214 -0
  5. package/dist/cjs/client.js.map +1 -0
  6. package/dist/cjs/errors.js +129 -0
  7. package/dist/cjs/errors.js.map +1 -0
  8. package/dist/cjs/index.js +40 -0
  9. package/dist/cjs/index.js.map +1 -0
  10. package/dist/cjs/resources/connections.js +74 -0
  11. package/dist/cjs/resources/connections.js.map +1 -0
  12. package/dist/cjs/resources/filesystem.js +101 -0
  13. package/dist/cjs/resources/filesystem.js.map +1 -0
  14. package/dist/cjs/resources/index.js +18 -0
  15. package/dist/cjs/resources/index.js.map +1 -0
  16. package/dist/cjs/resources/members.js +63 -0
  17. package/dist/cjs/resources/members.js.map +1 -0
  18. package/dist/cjs/resources/oauth.js +85 -0
  19. package/dist/cjs/resources/oauth.js.map +1 -0
  20. package/dist/cjs/resources/smart-folders.js +102 -0
  21. package/dist/cjs/resources/smart-folders.js.map +1 -0
  22. package/dist/cjs/resources/tokens.js +73 -0
  23. package/dist/cjs/resources/tokens.js.map +1 -0
  24. package/dist/cjs/resources/workspaces.js +75 -0
  25. package/dist/cjs/resources/workspaces.js.map +1 -0
  26. package/dist/cjs/types/connections.js +3 -0
  27. package/dist/cjs/types/connections.js.map +1 -0
  28. package/dist/cjs/types/filesystem.js +3 -0
  29. package/dist/cjs/types/filesystem.js.map +1 -0
  30. package/dist/cjs/types/index.js +25 -0
  31. package/dist/cjs/types/index.js.map +1 -0
  32. package/dist/cjs/types/members.js +3 -0
  33. package/dist/cjs/types/members.js.map +1 -0
  34. package/dist/cjs/types/oauth.js +3 -0
  35. package/dist/cjs/types/oauth.js.map +1 -0
  36. package/dist/cjs/types/shared.js +3 -0
  37. package/dist/cjs/types/shared.js.map +1 -0
  38. package/dist/cjs/types/smart-folders.js +3 -0
  39. package/dist/cjs/types/smart-folders.js.map +1 -0
  40. package/dist/cjs/types/tokens.js +3 -0
  41. package/dist/cjs/types/tokens.js.map +1 -0
  42. package/dist/cjs/types/workspaces.js +3 -0
  43. package/dist/cjs/types/workspaces.js.map +1 -0
  44. package/dist/cjs/version.js +6 -0
  45. package/dist/cjs/version.js.map +1 -0
  46. package/dist/esm/airstore.js +123 -0
  47. package/dist/esm/airstore.js.map +1 -0
  48. package/dist/esm/client.js +209 -0
  49. package/dist/esm/client.js.map +1 -0
  50. package/dist/esm/errors.js +115 -0
  51. package/dist/esm/errors.js.map +1 -0
  52. package/dist/esm/index.js +16 -0
  53. package/dist/esm/index.js.map +1 -0
  54. package/dist/esm/resources/connections.js +70 -0
  55. package/dist/esm/resources/connections.js.map +1 -0
  56. package/dist/esm/resources/filesystem.js +97 -0
  57. package/dist/esm/resources/filesystem.js.map +1 -0
  58. package/dist/esm/resources/index.js +8 -0
  59. package/dist/esm/resources/index.js.map +1 -0
  60. package/dist/esm/resources/members.js +59 -0
  61. package/dist/esm/resources/members.js.map +1 -0
  62. package/dist/esm/resources/oauth.js +81 -0
  63. package/dist/esm/resources/oauth.js.map +1 -0
  64. package/dist/esm/resources/smart-folders.js +98 -0
  65. package/dist/esm/resources/smart-folders.js.map +1 -0
  66. package/dist/esm/resources/tokens.js +69 -0
  67. package/dist/esm/resources/tokens.js.map +1 -0
  68. package/dist/esm/resources/workspaces.js +71 -0
  69. package/dist/esm/resources/workspaces.js.map +1 -0
  70. package/dist/esm/types/connections.js +2 -0
  71. package/dist/esm/types/connections.js.map +1 -0
  72. package/dist/esm/types/filesystem.js +2 -0
  73. package/dist/esm/types/filesystem.js.map +1 -0
  74. package/dist/esm/types/index.js +9 -0
  75. package/dist/esm/types/index.js.map +1 -0
  76. package/dist/esm/types/members.js +2 -0
  77. package/dist/esm/types/members.js.map +1 -0
  78. package/dist/esm/types/oauth.js +2 -0
  79. package/dist/esm/types/oauth.js.map +1 -0
  80. package/dist/esm/types/shared.js +2 -0
  81. package/dist/esm/types/shared.js.map +1 -0
  82. package/dist/esm/types/smart-folders.js +2 -0
  83. package/dist/esm/types/smart-folders.js.map +1 -0
  84. package/dist/esm/types/tokens.js +2 -0
  85. package/dist/esm/types/tokens.js.map +1 -0
  86. package/dist/esm/types/workspaces.js +2 -0
  87. package/dist/esm/types/workspaces.js.map +1 -0
  88. package/dist/esm/version.js +3 -0
  89. package/dist/esm/version.js.map +1 -0
  90. package/dist/types/airstore.d.ts +114 -0
  91. package/dist/types/airstore.d.ts.map +1 -0
  92. package/dist/types/client.d.ts +86 -0
  93. package/dist/types/client.d.ts.map +1 -0
  94. package/dist/types/errors.d.ts +61 -0
  95. package/dist/types/errors.d.ts.map +1 -0
  96. package/dist/types/index.d.ts +21 -0
  97. package/dist/types/index.d.ts.map +1 -0
  98. package/dist/types/resources/connections.d.ts +50 -0
  99. package/dist/types/resources/connections.d.ts.map +1 -0
  100. package/dist/types/resources/filesystem.d.ts +81 -0
  101. package/dist/types/resources/filesystem.d.ts.map +1 -0
  102. package/dist/types/resources/index.d.ts +8 -0
  103. package/dist/types/resources/index.d.ts.map +1 -0
  104. package/dist/types/resources/members.d.ts +49 -0
  105. package/dist/types/resources/members.d.ts.map +1 -0
  106. package/dist/types/resources/oauth.d.ts +57 -0
  107. package/dist/types/resources/oauth.d.ts.map +1 -0
  108. package/dist/types/resources/smart-folders.d.ts +70 -0
  109. package/dist/types/resources/smart-folders.d.ts.map +1 -0
  110. package/dist/types/resources/tokens.d.ts +54 -0
  111. package/dist/types/resources/tokens.d.ts.map +1 -0
  112. package/dist/types/resources/workspaces.d.ts +63 -0
  113. package/dist/types/resources/workspaces.d.ts.map +1 -0
  114. package/dist/types/types/connections.d.ts +41 -0
  115. package/dist/types/types/connections.d.ts.map +1 -0
  116. package/dist/types/types/filesystem.d.ts +39 -0
  117. package/dist/types/types/filesystem.d.ts.map +1 -0
  118. package/dist/types/types/index.d.ts +9 -0
  119. package/dist/types/types/index.d.ts.map +1 -0
  120. package/dist/types/types/members.d.ts +30 -0
  121. package/dist/types/types/members.d.ts.map +1 -0
  122. package/dist/types/types/oauth.d.ts +40 -0
  123. package/dist/types/types/oauth.d.ts.map +1 -0
  124. package/dist/types/types/shared.d.ts +27 -0
  125. package/dist/types/types/shared.d.ts.map +1 -0
  126. package/dist/types/types/smart-folders.d.ts +45 -0
  127. package/dist/types/types/smart-folders.d.ts.map +1 -0
  128. package/dist/types/types/tokens.d.ts +40 -0
  129. package/dist/types/types/tokens.d.ts.map +1 -0
  130. package/dist/types/types/workspaces.d.ts +26 -0
  131. package/dist/types/types/workspaces.d.ts.map +1 -0
  132. package/dist/types/version.d.ts +3 -0
  133. package/dist/types/version.d.ts.map +1 -0
  134. package/package.json +45 -0
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Base error for all Airstore SDK errors.
3
+ */
4
+ export class AirstoreError extends Error {
5
+ cause;
6
+ constructor(message, cause) {
7
+ super(message);
8
+ this.cause = cause;
9
+ this.name = 'AirstoreError';
10
+ }
11
+ }
12
+ /**
13
+ * Error returned by the Airstore API.
14
+ *
15
+ * Contains the HTTP status code, response headers, and optional request ID
16
+ * for debugging. Use the semantic subclasses (AuthenticationError, NotFoundError, etc.)
17
+ * for targeted catch blocks.
18
+ */
19
+ export class APIError extends AirstoreError {
20
+ status;
21
+ headers;
22
+ requestId;
23
+ constructor(status, message, headers, requestId) {
24
+ super(message);
25
+ this.name = 'APIError';
26
+ this.status = status;
27
+ this.headers = headers;
28
+ this.requestId = requestId;
29
+ }
30
+ /**
31
+ * Generate the appropriate APIError subclass for a given HTTP status.
32
+ */
33
+ static generate(status, errorBody, message, headers) {
34
+ const requestId = headers.get('x-request-id') ?? headers.get('X-Request-Id') ?? undefined;
35
+ if (status === 401)
36
+ return new AuthenticationError(message, headers, requestId);
37
+ if (status === 403)
38
+ return new PermissionDeniedError(message, headers, requestId);
39
+ if (status === 404)
40
+ return new NotFoundError(message, headers, requestId);
41
+ if (status === 409)
42
+ return new ConflictError(message, headers, requestId);
43
+ if (status === 422)
44
+ return new UnprocessableEntityError(message, headers, requestId);
45
+ if (status === 429)
46
+ return new RateLimitError(message, headers, requestId);
47
+ if (status >= 500)
48
+ return new InternalServerError(status, message, headers, requestId);
49
+ return new APIError(status, message, headers, requestId);
50
+ }
51
+ }
52
+ /** 401 - Invalid or missing API key. */
53
+ export class AuthenticationError extends APIError {
54
+ constructor(message, headers, requestId) {
55
+ super(401, message, headers, requestId);
56
+ this.name = 'AuthenticationError';
57
+ }
58
+ }
59
+ /** 403 - Token lacks permission for this operation. */
60
+ export class PermissionDeniedError extends APIError {
61
+ constructor(message, headers, requestId) {
62
+ super(403, message, headers, requestId);
63
+ this.name = 'PermissionDeniedError';
64
+ }
65
+ }
66
+ /** 404 - Resource not found. */
67
+ export class NotFoundError extends APIError {
68
+ constructor(message, headers, requestId) {
69
+ super(404, message, headers, requestId);
70
+ this.name = 'NotFoundError';
71
+ }
72
+ }
73
+ /** 409 - Conflicting operation. */
74
+ export class ConflictError extends APIError {
75
+ constructor(message, headers, requestId) {
76
+ super(409, message, headers, requestId);
77
+ this.name = 'ConflictError';
78
+ }
79
+ }
80
+ /** 422 - Validation failed. */
81
+ export class UnprocessableEntityError extends APIError {
82
+ constructor(message, headers, requestId) {
83
+ super(422, message, headers, requestId);
84
+ this.name = 'UnprocessableEntityError';
85
+ }
86
+ }
87
+ /** 429 - Rate limit exceeded. Retry after the period indicated by Retry-After header. */
88
+ export class RateLimitError extends APIError {
89
+ constructor(message, headers, requestId) {
90
+ super(429, message, headers, requestId);
91
+ this.name = 'RateLimitError';
92
+ }
93
+ }
94
+ /** 5xx - Server-side error. Safe to retry with backoff. */
95
+ export class InternalServerError extends APIError {
96
+ constructor(status, message, headers, requestId) {
97
+ super(status, message, headers, requestId);
98
+ this.name = 'InternalServerError';
99
+ }
100
+ }
101
+ /** Network-level connection failure (DNS, TCP, TLS). */
102
+ export class APIConnectionError extends AirstoreError {
103
+ constructor(message, cause) {
104
+ super(message, cause);
105
+ this.name = 'APIConnectionError';
106
+ }
107
+ }
108
+ /** Request timed out. */
109
+ export class APIConnectionTimeoutError extends APIConnectionError {
110
+ constructor(message = 'Request timed out') {
111
+ super(message);
112
+ this.name = 'APIConnectionTimeoutError';
113
+ }
114
+ }
115
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,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;AAED;;;;;;GAMG;AACH,MAAM,OAAO,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,KAA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C,OAAO,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,yBAAyB;AACzB,MAAM,OAAO,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"}
@@ -0,0 +1,16 @@
1
+ /** @module @airstore/sdk */
2
+ // ── Main client ──────────────────────────────────────────────────────────────
3
+ export { Airstore, Airstore as default } from './airstore.js';
4
+ // ── Errors ───────────────────────────────────────────────────────────────────
5
+ export { AirstoreError, APIError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, APIConnectionError, APIConnectionTimeoutError, } from './errors.js';
6
+ // ── Resource classes ─────────────────────────────────────────────────────────
7
+ export { Workspaces } from './resources/workspaces.js';
8
+ export { Connections } from './resources/connections.js';
9
+ export { SmartFolders } from './resources/smart-folders.js';
10
+ export { Tokens } from './resources/tokens.js';
11
+ export { Members } from './resources/members.js';
12
+ export { OAuth } from './resources/oauth.js';
13
+ export { Filesystem } from './resources/filesystem.js';
14
+ // ── Version ──────────────────────────────────────────────────────────────────
15
+ export { VERSION } from './version.js';
16
+ //# 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,OAAO,EAAE,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAG9D,gFAAgF;AAChF,OAAO,EACL,aAAa,EACb,QAAQ,EACR,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,gFAAgF;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAYvD,gFAAgF;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Manage connections (integrations) within a workspace.
3
+ *
4
+ * Connections store OAuth tokens or API keys for external services like
5
+ * Gmail, GitHub, Notion, etc. Pass existing tokens directly to avoid
6
+ * requiring users to re-authenticate.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * await airstore.connections.create("ws_abc", {
11
+ * integrationType: "gmail",
12
+ * accessToken: existingAccessToken,
13
+ * refreshToken: existingRefreshToken,
14
+ * });
15
+ * ```
16
+ */
17
+ export class Connections {
18
+ client;
19
+ constructor(client) {
20
+ this.client = client;
21
+ }
22
+ /**
23
+ * Create a connection by passing existing OAuth credentials or API keys.
24
+ *
25
+ * @param workspaceId - Workspace external ID.
26
+ * @param params - Connection creation parameters.
27
+ * @param options - Per-request overrides.
28
+ * @returns The created connection.
29
+ */
30
+ async create(workspaceId, params, options) {
31
+ const body = {
32
+ integration_type: params.integrationType,
33
+ };
34
+ if (params.accessToken !== undefined)
35
+ body['access_token'] = params.accessToken;
36
+ if (params.refreshToken !== undefined)
37
+ body['refresh_token'] = params.refreshToken;
38
+ if (params.apiKey !== undefined)
39
+ body['api_key'] = params.apiKey;
40
+ if (params.scope !== undefined)
41
+ body['scope'] = params.scope;
42
+ if (params.extra !== undefined)
43
+ body['extra'] = params.extra;
44
+ return this.client.request('POST', `/workspaces/${workspaceId}/connections`, body, undefined, options);
45
+ }
46
+ /**
47
+ * List all connections in a workspace.
48
+ *
49
+ * @param workspaceId - Workspace external ID.
50
+ * @param options - Per-request overrides.
51
+ * @returns Array of connections.
52
+ */
53
+ async list(workspaceId, options) {
54
+ const result = await this.client.request('GET', `/workspaces/${workspaceId}/connections`, undefined, undefined, options);
55
+ return Array.isArray(result) ? result : [];
56
+ }
57
+ /**
58
+ * Delete a connection.
59
+ *
60
+ * @param workspaceId - Workspace external ID.
61
+ * @param connectionId - Connection external ID.
62
+ * @param options - Per-request overrides.
63
+ *
64
+ * @throws {NotFoundError} If the connection doesn't exist.
65
+ */
66
+ async del(workspaceId, connectionId, options) {
67
+ await this.client.request('DELETE', `/workspaces/${workspaceId}/connections/${connectionId}`, undefined, undefined, options);
68
+ }
69
+ }
70
+ //# sourceMappingURL=connections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/resources/connections.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,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"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Read-only access to the workspace virtual filesystem.
3
+ *
4
+ * The filesystem provides a unified view of all connected integrations,
5
+ * smart folders, tools, and user-uploaded files.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const listing = await airstore.fs.list("ws_abc", { path: "/" });
10
+ * const content = await airstore.fs.read("ws_abc", {
11
+ * path: "/Sources/gmail/inbox/email.txt",
12
+ * });
13
+ * ```
14
+ */
15
+ export class Filesystem {
16
+ client;
17
+ constructor(client) {
18
+ this.client = client;
19
+ }
20
+ /**
21
+ * List directory contents.
22
+ *
23
+ * @param workspaceId - Workspace external ID.
24
+ * @param opts - Listing options.
25
+ * @param opts.path - Directory path to list. Defaults to root.
26
+ * @param options - Per-request overrides.
27
+ * @returns Array of files and directories.
28
+ */
29
+ async list(workspaceId, opts = {}, options) {
30
+ const params = {};
31
+ if (opts.path !== undefined)
32
+ params['path'] = opts.path;
33
+ const result = await this.client.request('GET', `/workspaces/${workspaceId}/fs/list`, undefined, params, options);
34
+ return result.entries ?? [];
35
+ }
36
+ /**
37
+ * Read file contents as a string.
38
+ *
39
+ * @param workspaceId - Workspace external ID.
40
+ * @param opts - Read options.
41
+ * @param opts.path - File path to read.
42
+ * @param opts.offset - Byte offset to start reading from.
43
+ * @param opts.length - Number of bytes to read.
44
+ * @param options - Per-request overrides.
45
+ * @returns File contents as a string.
46
+ *
47
+ * @throws {NotFoundError} If the file doesn't exist.
48
+ */
49
+ async read(workspaceId, opts, options) {
50
+ const params = { path: opts.path };
51
+ if (opts.offset !== undefined)
52
+ params['offset'] = String(opts.offset);
53
+ if (opts.length !== undefined)
54
+ params['length'] = String(opts.length);
55
+ const resp = await this.client.rawRequest('GET', `/workspaces/${workspaceId}/fs/read`, { params, ...options });
56
+ return resp.text();
57
+ }
58
+ /**
59
+ * Get a directory tree for efficient prefetching.
60
+ *
61
+ * Returns a flat list of all entries under the given path. Supports
62
+ * pagination via `continuationToken` for large directories.
63
+ *
64
+ * @param workspaceId - Workspace external ID.
65
+ * @param opts - Tree options.
66
+ * @param opts.path - Root path for the tree. Defaults to root.
67
+ * @param opts.maxKeys - Maximum number of entries to return.
68
+ * @param opts.continuationToken - Token from a previous truncated response.
69
+ * @param options - Per-request overrides.
70
+ * @returns Tree listing with entries and pagination info.
71
+ */
72
+ async tree(workspaceId, opts = {}, options) {
73
+ const params = {};
74
+ if (opts.path !== undefined)
75
+ params['path'] = opts.path;
76
+ if (opts.maxKeys !== undefined)
77
+ params['max_keys'] = String(opts.maxKeys);
78
+ if (opts.continuationToken !== undefined) {
79
+ params['continuation_token'] = opts.continuationToken;
80
+ }
81
+ return this.client.request('GET', `/workspaces/${workspaceId}/fs/tree`, undefined, params, options);
82
+ }
83
+ /**
84
+ * Get file or directory metadata.
85
+ *
86
+ * @param workspaceId - Workspace external ID.
87
+ * @param path - Absolute path to stat.
88
+ * @param options - Per-request overrides.
89
+ * @returns File metadata.
90
+ *
91
+ * @throws {NotFoundError} If the path doesn't exist.
92
+ */
93
+ async stat(workspaceId, path, options) {
94
+ return this.client.request('GET', `/workspaces/${workspaceId}/fs/stat`, undefined, { path }, options);
95
+ }
96
+ }
97
+ //# sourceMappingURL=filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../../src/resources/filesystem.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,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,I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E,IAAI,EAAE,EACR,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export { Workspaces } from './workspaces.js';
2
+ export { Connections } from './connections.js';
3
+ export { SmartFolders } from './smart-folders.js';
4
+ export { Tokens } from './tokens.js';
5
+ export { Members } from './members.js';
6
+ export { OAuth } from './oauth.js';
7
+ export { Filesystem } from './filesystem.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Manage workspace members.
3
+ *
4
+ * Members are users with roles (admin, member, viewer) in a workspace.
5
+ * Tokens are always associated with a member.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const member = await airstore.members.create("ws_abc", {
10
+ * email: "agent@internal",
11
+ * name: "Agent",
12
+ * role: "member",
13
+ * });
14
+ * ```
15
+ */
16
+ export class Members {
17
+ client;
18
+ constructor(client) {
19
+ this.client = client;
20
+ }
21
+ /**
22
+ * Add a member to a workspace.
23
+ *
24
+ * @param workspaceId - Workspace external ID.
25
+ * @param params - Member creation parameters.
26
+ * @param options - Per-request overrides.
27
+ * @returns The created member.
28
+ */
29
+ async create(workspaceId, params, options) {
30
+ return this.client.request('POST', `/workspaces/${workspaceId}/members`, {
31
+ email: params.email,
32
+ name: params.name,
33
+ role: params.role ?? 'member',
34
+ }, undefined, options);
35
+ }
36
+ /**
37
+ * List members of a workspace.
38
+ *
39
+ * @param workspaceId - Workspace external ID.
40
+ * @param options - Per-request overrides.
41
+ * @returns Array of members.
42
+ */
43
+ async list(workspaceId, options) {
44
+ return this.client.request('GET', `/workspaces/${workspaceId}/members`, undefined, undefined, options);
45
+ }
46
+ /**
47
+ * Remove a member from a workspace.
48
+ *
49
+ * @param workspaceId - Workspace external ID.
50
+ * @param memberId - Member external ID.
51
+ * @param options - Per-request overrides.
52
+ *
53
+ * @throws {NotFoundError} If the member doesn't exist.
54
+ */
55
+ async del(workspaceId, memberId, options) {
56
+ await this.client.request('DELETE', `/workspaces/${workspaceId}/members/${memberId}`, undefined, undefined, options);
57
+ }
58
+ }
59
+ //# sourceMappingURL=members.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.js","sourceRoot":"","sources":["../../../src/resources/members.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,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"}
@@ -0,0 +1,81 @@
1
+ import { AirstoreError } from '../errors.js';
2
+ /**
3
+ * Manage OAuth sessions for interactive connection setup.
4
+ *
5
+ * Use this when you want users to authorize via browser redirect
6
+ * rather than passing tokens directly.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const session = await airstore.oauth.createSession({
11
+ * integrationType: "gmail",
12
+ * returnTo: "https://myapp.com/callback",
13
+ * });
14
+ * console.log(session.authorize_url); // redirect user here
15
+ * const completed = await airstore.oauth.poll(session.session_id);
16
+ * ```
17
+ */
18
+ export class OAuth {
19
+ client;
20
+ constructor(client) {
21
+ this.client = client;
22
+ }
23
+ /**
24
+ * Create an OAuth session to initiate the authorization flow.
25
+ *
26
+ * Returns a session with an `authorize_url` that the user should be
27
+ * redirected to. Once they complete authorization, poll the session
28
+ * for the resulting connection ID.
29
+ *
30
+ * @param params - Session creation parameters.
31
+ * @param options - Per-request overrides.
32
+ * @returns The session with authorize_url to redirect the user to.
33
+ */
34
+ async createSession(params, options) {
35
+ const body = {
36
+ integration_type: params.integrationType,
37
+ };
38
+ if (params.returnTo !== undefined)
39
+ body['return_to'] = params.returnTo;
40
+ return this.client.request('POST', '/oauth/sessions', body, undefined, options);
41
+ }
42
+ /**
43
+ * Get the current status of an OAuth session.
44
+ *
45
+ * @param sessionId - Session ID from createSession.
46
+ * @param options - Per-request overrides.
47
+ * @returns The session status.
48
+ */
49
+ async getSession(sessionId, options) {
50
+ return this.client.request('GET', `/oauth/sessions/${sessionId}`, undefined, undefined, options);
51
+ }
52
+ /**
53
+ * Poll an OAuth session until completion or timeout.
54
+ *
55
+ * Repeatedly checks session status at the specified interval until
56
+ * the session completes, errors, or the timeout is reached.
57
+ *
58
+ * @param sessionId - Session ID from createSession.
59
+ * @param pollOpts - Polling configuration (timeout, interval).
60
+ * @param options - Per-request overrides.
61
+ * @returns The completed session status with connection_id.
62
+ *
63
+ * @throws {AirstoreError} If the session errors or times out.
64
+ */
65
+ async poll(sessionId, pollOpts, options) {
66
+ const timeout = pollOpts?.timeout ?? 300_000;
67
+ const interval = pollOpts?.interval ?? 2_000;
68
+ const deadline = Date.now() + timeout;
69
+ while (Date.now() < deadline) {
70
+ const status = await this.getSession(sessionId, options);
71
+ if (status.status === 'complete')
72
+ return status;
73
+ if (status.status === 'error') {
74
+ throw new AirstoreError(`OAuth session failed: ${status.error ?? 'unknown error'}`);
75
+ }
76
+ await new Promise((resolve) => setTimeout(resolve, interval));
77
+ }
78
+ throw new AirstoreError(`OAuth session timed out after ${timeout}ms`);
79
+ }
80
+ }
81
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/resources/oauth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,KAAK;IACa;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;;;;;OAUG;IACH,KAAK,CAAC,aAAa,CACjB,MAAgC,EAChC,OAAwB;QAExB,MAAM,IAAI,GAA4B;YACpC,gBAAgB,EAAE,MAAM,CAAC,eAAe;SACzC,CAAC;QACF,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAEvE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,iBAAiB,EACjB,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CACd,SAAiB,EACjB,OAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,mBAAmB,SAAS,EAAE,EAC9B,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,IAAI,CACR,SAAiB,EACjB,QAA2B,EAC3B,OAAwB;QAExB,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,IAAI,OAAO,CAAC;QAC7C,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ,IAAI,KAAK,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;QAEtC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAEzD,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO,MAAM,CAAC;YAChD,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAC9B,MAAM,IAAI,aAAa,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,aAAa,CAAC,iCAAiC,OAAO,IAAI,CAAC,CAAC;IACxE,CAAC;CACF"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Manage smart folders (filesystem queries) within a workspace.
3
+ *
4
+ * Smart folders use LLM inference to automatically organize and filter
5
+ * data from connected integrations into virtual folders or files.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * await airstore.smartFolders.create("ws_abc", {
10
+ * integration: "gmail",
11
+ * name: "Recent Emails",
12
+ * guidance: "Last 7 days of emails",
13
+ * });
14
+ * ```
15
+ */
16
+ export class SmartFolders {
17
+ client;
18
+ constructor(client) {
19
+ this.client = client;
20
+ }
21
+ /**
22
+ * Create a new smart folder.
23
+ *
24
+ * @param workspaceId - Workspace external ID.
25
+ * @param params - Smart folder creation parameters.
26
+ * @param options - Per-request overrides.
27
+ * @returns The created smart folder.
28
+ */
29
+ async create(workspaceId, params, options) {
30
+ const body = {
31
+ integration: params.integration,
32
+ name: params.name,
33
+ output_format: params.outputFormat ?? 'folder',
34
+ };
35
+ if (params.guidance !== undefined)
36
+ body['guidance'] = params.guidance;
37
+ if (params.fileExt !== undefined)
38
+ body['file_ext'] = params.fileExt;
39
+ return this.client.request('POST', `/workspaces/${workspaceId}/fs/queries`, body, undefined, options);
40
+ }
41
+ /**
42
+ * List all smart folders in a workspace.
43
+ *
44
+ * @param workspaceId - Workspace external ID.
45
+ * @param options - Per-request overrides.
46
+ * @returns Array of smart folders.
47
+ */
48
+ async list(workspaceId, options) {
49
+ // API may return { queries: [...] } or a direct array depending on version
50
+ const result = await this.client.request('GET', `/workspaces/${workspaceId}/fs/queries/list`, undefined, undefined, options);
51
+ if (Array.isArray(result))
52
+ return result;
53
+ return result.queries ?? [];
54
+ }
55
+ /**
56
+ * Retrieve a smart folder by its virtual filesystem path.
57
+ *
58
+ * @param workspaceId - Workspace external ID.
59
+ * @param queryPath - Virtual path of the smart folder.
60
+ * @param options - Per-request overrides.
61
+ * @returns The smart folder.
62
+ *
63
+ * @throws {NotFoundError} If the smart folder doesn't exist.
64
+ */
65
+ async retrieve(workspaceId, queryPath, options) {
66
+ return this.client.request('GET', `/workspaces/${workspaceId}/fs/queries`, undefined, { path: queryPath }, options);
67
+ }
68
+ /**
69
+ * Update an existing smart folder.
70
+ *
71
+ * @param workspaceId - Workspace external ID.
72
+ * @param queryId - Smart folder external ID.
73
+ * @param params - Fields to update.
74
+ * @param options - Per-request overrides.
75
+ * @returns The updated smart folder.
76
+ */
77
+ async update(workspaceId, queryId, params, options) {
78
+ const body = {};
79
+ if (params.name !== undefined)
80
+ body['name'] = params.name;
81
+ if (params.guidance !== undefined)
82
+ body['guidance'] = params.guidance;
83
+ return this.client.request('PUT', `/workspaces/${workspaceId}/fs/queries/${queryId}`, body, undefined, options);
84
+ }
85
+ /**
86
+ * Delete a smart folder.
87
+ *
88
+ * @param workspaceId - Workspace external ID.
89
+ * @param queryId - Smart folder external ID.
90
+ * @param options - Per-request overrides.
91
+ *
92
+ * @throws {NotFoundError} If the smart folder doesn't exist.
93
+ */
94
+ async del(workspaceId, queryId, options) {
95
+ await this.client.request('DELETE', `/workspaces/${workspaceId}/fs/queries/${queryId}`, undefined, undefined, options);
96
+ }
97
+ }
98
+ //# 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,MAAM,OAAO,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,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAEpE,OAAO,IAAI,CAAC,MAAM,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,CACP,WAAmB,EACnB,OAAe,EACf,OAAwB;QAExB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACvB,QAAQ,EACR,eAAe,WAAW,eAAe,OAAO,EAAE,EAClD,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Manage workspace-scoped authentication tokens.
3
+ *
4
+ * Tokens are used for CLI mounting (`airstore start --token <token>`)
5
+ * and per-workspace programmatic access.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const token = await airstore.tokens.create("ws_abc", {
10
+ * email: "agent@internal",
11
+ * name: "vm-mount",
12
+ * });
13
+ * // token.token -> pass to: airstore start --token <this>
14
+ * ```
15
+ */
16
+ export class Tokens {
17
+ client;
18
+ constructor(client) {
19
+ this.client = client;
20
+ }
21
+ /**
22
+ * Create a workspace-scoped token.
23
+ *
24
+ * Either `memberId` or `email` must be provided. If `email` is given
25
+ * and no member with that email exists, one is auto-created.
26
+ *
27
+ * @param workspaceId - Workspace external ID.
28
+ * @param params - Token creation parameters.
29
+ * @param options - Per-request overrides.
30
+ * @returns The created token with raw value (shown once — store it safely).
31
+ */
32
+ async create(workspaceId, params, options) {
33
+ const body = {};
34
+ if (params.memberId !== undefined)
35
+ body['member_id'] = params.memberId;
36
+ if (params.email !== undefined)
37
+ body['email'] = params.email;
38
+ if (params.name !== undefined)
39
+ body['name'] = params.name;
40
+ if (params.expiresIn !== undefined)
41
+ body['expires_in'] = params.expiresIn;
42
+ return this.client.request('POST', `/workspaces/${workspaceId}/tokens`, body, undefined, options);
43
+ }
44
+ /**
45
+ * List tokens in a workspace.
46
+ *
47
+ * Raw token values are never returned — only metadata.
48
+ *
49
+ * @param workspaceId - Workspace external ID.
50
+ * @param options - Per-request overrides.
51
+ * @returns Array of token metadata.
52
+ */
53
+ async list(workspaceId, options) {
54
+ return this.client.request('GET', `/workspaces/${workspaceId}/tokens`, undefined, undefined, options);
55
+ }
56
+ /**
57
+ * Revoke (delete) a token. Once revoked, the token can no longer be used.
58
+ *
59
+ * @param workspaceId - Workspace external ID.
60
+ * @param tokenId - Token external ID.
61
+ * @param options - Per-request overrides.
62
+ *
63
+ * @throws {NotFoundError} If the token doesn't exist.
64
+ */
65
+ async revoke(workspaceId, tokenId, options) {
66
+ await this.client.request('DELETE', `/workspaces/${workspaceId}/tokens/${tokenId}`, undefined, undefined, options);
67
+ }
68
+ }
69
+ //# sourceMappingURL=tokens.js.map