@makeplane/plane-node-sdk 0.1.0 → 0.1.2

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.
@@ -1,6 +1,7 @@
1
1
  .gitignore
2
2
  .npmignore
3
3
  README.md
4
+ eslint.config.mjs
4
5
  package.json
5
6
  src/apis/AssetsApi.ts
6
7
  src/apis/CyclesApi.ts
@@ -52,6 +53,7 @@ src/models/IssuePropertyValueAPI.ts
52
53
  src/models/IssuePropertyValueAPIRequest.ts
53
54
  src/models/IssueRequest.ts
54
55
  src/models/IssueSearch.ts
56
+ src/models/IssueSearchItem.ts
55
57
  src/models/IssueTypeAPI.ts
56
58
  src/models/IssueTypeAPIRequest.ts
57
59
  src/models/IssueWorkLogAPI.ts
@@ -115,5 +117,7 @@ src/models/TypeEnum.ts
115
117
  src/models/UserAssetUploadRequest.ts
116
118
  src/models/UserLite.ts
117
119
  src/models/index.ts
120
+ src/oauth/api.ts
121
+ src/oauth/models.ts
118
122
  src/runtime.ts
119
123
  tsconfig.json
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## @makeplane/plane-node-sdk@0.1.0
1
+ ## @makeplane/plane-node-sdk@0.1.2
2
2
 
3
3
  This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
4
4
 
@@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co
36
36
  _published:_
37
37
 
38
38
  ```
39
- npm install @makeplane/plane-node-sdk@0.1.0 --save
39
+ npm install @makeplane/plane-node-sdk@0.1.2 --save
40
40
  ```
41
41
 
42
42
  _unPublished (not recommended):_
@@ -25,12 +25,12 @@ export declare class MembersApi extends runtime.BaseAPI {
25
25
  * Retrieve all users who are members of the specified project.
26
26
  * List project members
27
27
  */
28
- getProjectMembersRaw(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserLite>>;
28
+ getProjectMembersRaw(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<UserLite>>>;
29
29
  /**
30
30
  * Retrieve all users who are members of the specified project.
31
31
  * List project members
32
32
  */
33
- getProjectMembers(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserLite>;
33
+ getProjectMembers(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<UserLite>>;
34
34
  /**
35
35
  * Retrieve all users who are members of the specified workspace.
36
36
  * List workspace members
@@ -127,7 +127,7 @@ var MembersApi = /** @class */ (function (_super) {
127
127
  }, initOverrides)];
128
128
  case 7:
129
129
  response = _g.sent();
130
- return [2 /*return*/, new runtime.JSONApiResponse(response, function (jsonValue) { return (0, index_1.UserLiteFromJSON)(jsonValue); })];
130
+ return [2 /*return*/, new runtime.JSONApiResponse(response, function (jsonValue) { return jsonValue.map(index_1.UserLiteFromJSON); })];
131
131
  }
132
132
  });
133
133
  });
@@ -63,12 +63,12 @@ export declare class WorkItemTypesApi extends runtime.BaseAPI {
63
63
  * List all issue types for a project
64
64
  * List issue types
65
65
  */
66
- listIssueTypesRaw(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<IssueTypeAPI>>;
66
+ listIssueTypesRaw(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<IssueTypeAPI>>>;
67
67
  /**
68
68
  * List all issue types for a project
69
69
  * List issue types
70
70
  */
71
- listIssueTypes(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<IssueTypeAPI>;
71
+ listIssueTypes(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<IssueTypeAPI>>;
72
72
  /**
73
73
  * Retrieve an issue type by id
74
74
  * Retrieve an issue type by id
@@ -285,7 +285,7 @@ var WorkItemTypesApi = /** @class */ (function (_super) {
285
285
  }, initOverrides)];
286
286
  case 7:
287
287
  response = _g.sent();
288
- return [2 /*return*/, new runtime.JSONApiResponse(response, function (jsonValue) { return (0, index_1.IssueTypeAPIFromJSON)(jsonValue); })];
288
+ return [2 /*return*/, new runtime.JSONApiResponse(response, function (jsonValue) { return jsonValue.map(index_1.IssueTypeAPIFromJSON); })];
289
289
  }
290
290
  });
291
291
  });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './runtime';
2
2
  export * from './apis/index';
3
3
  export * from './models/index';
4
+ export * from "./oauth/api";
package/dist/index.js CHANGED
@@ -18,3 +18,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  __exportStar(require("./runtime"), exports);
19
19
  __exportStar(require("./apis/index"), exports);
20
20
  __exportStar(require("./models/index"), exports);
21
+ __exportStar(require("./oauth/api"), exports);
@@ -8,6 +8,7 @@
8
8
  * NOTE: This class is auto generated.
9
9
  * Do not edit the class manually.
10
10
  */
11
+ import type { IssueSearchItem } from './IssueSearchItem';
11
12
  /**
12
13
  * Serializer for work item search result data formatting.
13
14
  *
@@ -18,41 +19,11 @@
18
19
  */
19
20
  export interface IssueSearch {
20
21
  /**
21
- * Issue ID
22
- * @type {string}
22
+ * Array of search result issues
23
+ * @type {Array<IssueSearchItem>}
23
24
  * @memberof IssueSearch
24
25
  */
25
- id: string;
26
- /**
27
- * Issue name
28
- * @type {string}
29
- * @memberof IssueSearch
30
- */
31
- name: string;
32
- /**
33
- * Issue sequence ID
34
- * @type {string}
35
- * @memberof IssueSearch
36
- */
37
- sequenceId: string;
38
- /**
39
- * Project identifier
40
- * @type {string}
41
- * @memberof IssueSearch
42
- */
43
- projectIdentifier: string;
44
- /**
45
- * Project ID
46
- * @type {string}
47
- * @memberof IssueSearch
48
- */
49
- projectId: string;
50
- /**
51
- * Workspace slug
52
- * @type {string}
53
- * @memberof IssueSearch
54
- */
55
- workspaceSlug: string;
26
+ issues: Array<IssueSearchItem>;
56
27
  }
57
28
  /**
58
29
  * Check if a given object implements the IssueSearch interface.
@@ -17,21 +17,12 @@ exports.IssueSearchFromJSON = IssueSearchFromJSON;
17
17
  exports.IssueSearchFromJSONTyped = IssueSearchFromJSONTyped;
18
18
  exports.IssueSearchToJSON = IssueSearchToJSON;
19
19
  exports.IssueSearchToJSONTyped = IssueSearchToJSONTyped;
20
+ var IssueSearchItem_1 = require("./IssueSearchItem");
20
21
  /**
21
22
  * Check if a given object implements the IssueSearch interface.
22
23
  */
23
24
  function instanceOfIssueSearch(value) {
24
- if (!('id' in value) || value['id'] === undefined)
25
- return false;
26
- if (!('name' in value) || value['name'] === undefined)
27
- return false;
28
- if (!('sequenceId' in value) || value['sequenceId'] === undefined)
29
- return false;
30
- if (!('projectIdentifier' in value) || value['projectIdentifier'] === undefined)
31
- return false;
32
- if (!('projectId' in value) || value['projectId'] === undefined)
33
- return false;
34
- if (!('workspaceSlug' in value) || value['workspaceSlug'] === undefined)
25
+ if (!('issues' in value) || value['issues'] === undefined)
35
26
  return false;
36
27
  return true;
37
28
  }
@@ -43,12 +34,7 @@ function IssueSearchFromJSONTyped(json, ignoreDiscriminator) {
43
34
  return json;
44
35
  }
45
36
  return {
46
- 'id': json['id'],
47
- 'name': json['name'],
48
- 'sequenceId': json['sequence_id'],
49
- 'projectIdentifier': json['project__identifier'],
50
- 'projectId': json['project_id'],
51
- 'workspaceSlug': json['workspace__slug'],
37
+ 'issues': (json['issues'].map(IssueSearchItem_1.IssueSearchItemFromJSON)),
52
38
  };
53
39
  }
54
40
  function IssueSearchToJSON(json) {
@@ -60,11 +46,6 @@ function IssueSearchToJSONTyped(value, ignoreDiscriminator) {
60
46
  return value;
61
47
  }
62
48
  return {
63
- 'id': value['id'],
64
- 'name': value['name'],
65
- 'sequence_id': value['sequenceId'],
66
- 'project__identifier': value['projectIdentifier'],
67
- 'project_id': value['projectId'],
68
- 'workspace__slug': value['workspaceSlug'],
49
+ 'issues': (value['issues'].map(IssueSearchItem_1.IssueSearchItemToJSON)),
69
50
  };
70
51
  }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The Plane REST API
3
+ * The Plane REST API Visit our quick start guide and full API documentation at [developers.plane.so](https://developers.plane.so/api-reference/introduction).
4
+ *
5
+ * The version of the API Spec: 0.0.1
6
+ * Contact: support@plane.so
7
+ *
8
+ * NOTE: This class is auto generated.
9
+ * Do not edit the class manually.
10
+ */
11
+ /**
12
+ * Individual issue component for search results.
13
+ *
14
+ * Provides standardized search result structure including work item identifiers,
15
+ * project context, and workspace information for search API responses.
16
+ * @export
17
+ * @interface IssueSearchItem
18
+ */
19
+ export interface IssueSearchItem {
20
+ /**
21
+ * Issue ID
22
+ * @type {string}
23
+ * @memberof IssueSearchItem
24
+ */
25
+ id: string;
26
+ /**
27
+ * Issue name
28
+ * @type {string}
29
+ * @memberof IssueSearchItem
30
+ */
31
+ name: string;
32
+ /**
33
+ * Issue sequence ID
34
+ * @type {string}
35
+ * @memberof IssueSearchItem
36
+ */
37
+ sequenceId: string;
38
+ /**
39
+ * Project identifier
40
+ * @type {string}
41
+ * @memberof IssueSearchItem
42
+ */
43
+ projectIdentifier: string;
44
+ /**
45
+ * Project ID
46
+ * @type {string}
47
+ * @memberof IssueSearchItem
48
+ */
49
+ projectId: string;
50
+ /**
51
+ * Workspace slug
52
+ * @type {string}
53
+ * @memberof IssueSearchItem
54
+ */
55
+ workspaceSlug: string;
56
+ }
57
+ /**
58
+ * Check if a given object implements the IssueSearchItem interface.
59
+ */
60
+ export declare function instanceOfIssueSearchItem(value: object): value is IssueSearchItem;
61
+ export declare function IssueSearchItemFromJSON(json: any): IssueSearchItem;
62
+ export declare function IssueSearchItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): IssueSearchItem;
63
+ export declare function IssueSearchItemToJSON(json: any): IssueSearchItem;
64
+ export declare function IssueSearchItemToJSONTyped(value?: IssueSearchItem | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * The Plane REST API
6
+ * The Plane REST API Visit our quick start guide and full API documentation at [developers.plane.so](https://developers.plane.so/api-reference/introduction).
7
+ *
8
+ * The version of the API Spec: 0.0.1
9
+ * Contact: support@plane.so
10
+ *
11
+ * NOTE: This class is auto generated.
12
+ * Do not edit the class manually.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.instanceOfIssueSearchItem = instanceOfIssueSearchItem;
16
+ exports.IssueSearchItemFromJSON = IssueSearchItemFromJSON;
17
+ exports.IssueSearchItemFromJSONTyped = IssueSearchItemFromJSONTyped;
18
+ exports.IssueSearchItemToJSON = IssueSearchItemToJSON;
19
+ exports.IssueSearchItemToJSONTyped = IssueSearchItemToJSONTyped;
20
+ /**
21
+ * Check if a given object implements the IssueSearchItem interface.
22
+ */
23
+ function instanceOfIssueSearchItem(value) {
24
+ if (!('id' in value) || value['id'] === undefined)
25
+ return false;
26
+ if (!('name' in value) || value['name'] === undefined)
27
+ return false;
28
+ if (!('sequenceId' in value) || value['sequenceId'] === undefined)
29
+ return false;
30
+ if (!('projectIdentifier' in value) || value['projectIdentifier'] === undefined)
31
+ return false;
32
+ if (!('projectId' in value) || value['projectId'] === undefined)
33
+ return false;
34
+ if (!('workspaceSlug' in value) || value['workspaceSlug'] === undefined)
35
+ return false;
36
+ return true;
37
+ }
38
+ function IssueSearchItemFromJSON(json) {
39
+ return IssueSearchItemFromJSONTyped(json, false);
40
+ }
41
+ function IssueSearchItemFromJSONTyped(json, ignoreDiscriminator) {
42
+ if (json == null) {
43
+ return json;
44
+ }
45
+ return {
46
+ 'id': json['id'],
47
+ 'name': json['name'],
48
+ 'sequenceId': json['sequence_id'],
49
+ 'projectIdentifier': json['project__identifier'],
50
+ 'projectId': json['project_id'],
51
+ 'workspaceSlug': json['workspace__slug'],
52
+ };
53
+ }
54
+ function IssueSearchItemToJSON(json) {
55
+ return IssueSearchItemToJSONTyped(json, false);
56
+ }
57
+ function IssueSearchItemToJSONTyped(value, ignoreDiscriminator) {
58
+ if (ignoreDiscriminator === void 0) { ignoreDiscriminator = false; }
59
+ if (value == null) {
60
+ return value;
61
+ }
62
+ return {
63
+ 'id': value['id'],
64
+ 'name': value['name'],
65
+ 'sequence_id': value['sequenceId'],
66
+ 'project__identifier': value['projectIdentifier'],
67
+ 'project_id': value['projectId'],
68
+ 'workspace__slug': value['workspaceSlug'],
69
+ };
70
+ }
@@ -60,12 +60,6 @@ export interface State {
60
60
  * @memberof State
61
61
  */
62
62
  color: string;
63
- /**
64
- *
65
- * @type {string}
66
- * @memberof State
67
- */
68
- readonly slug?: string;
69
63
  /**
70
64
  *
71
65
  * @type {number}
@@ -134,4 +128,4 @@ export declare function instanceOfState(value: object): value is State;
134
128
  export declare function StateFromJSON(json: any): State;
135
129
  export declare function StateFromJSONTyped(json: any, ignoreDiscriminator: boolean): State;
136
130
  export declare function StateToJSON(json: any): State;
137
- export declare function StateToJSONTyped(value?: Omit<State, 'id' | 'created_at' | 'updated_at' | 'deleted_at' | 'slug' | 'created_by' | 'updated_by' | 'project' | 'workspace'> | null, ignoreDiscriminator?: boolean): any;
131
+ export declare function StateToJSONTyped(value?: Omit<State, 'id' | 'created_at' | 'updated_at' | 'deleted_at' | 'created_by' | 'updated_by' | 'project' | 'workspace'> | null, ignoreDiscriminator?: boolean): any;
@@ -43,7 +43,6 @@ function StateFromJSONTyped(json, ignoreDiscriminator) {
43
43
  'name': json['name'],
44
44
  'description': json['description'] == null ? undefined : json['description'],
45
45
  'color': json['color'],
46
- 'slug': json['slug'] == null ? undefined : json['slug'],
47
46
  'sequence': json['sequence'] == null ? undefined : json['sequence'],
48
47
  'group': json['group'] == null ? undefined : (0, GroupEnum_1.GroupEnumFromJSON)(json['group']),
49
48
  'isTriage': json['is_triage'] == null ? undefined : json['is_triage'],
@@ -29,6 +29,7 @@ export * from './IssuePropertyValueAPI';
29
29
  export * from './IssuePropertyValueAPIRequest';
30
30
  export * from './IssueRequest';
31
31
  export * from './IssueSearch';
32
+ export * from './IssueSearchItem';
32
33
  export * from './IssueTypeAPI';
33
34
  export * from './IssueTypeAPIRequest';
34
35
  export * from './IssueWorkLogAPI';
@@ -46,6 +46,7 @@ __exportStar(require("./IssuePropertyValueAPI"), exports);
46
46
  __exportStar(require("./IssuePropertyValueAPIRequest"), exports);
47
47
  __exportStar(require("./IssueRequest"), exports);
48
48
  __exportStar(require("./IssueSearch"), exports);
49
+ __exportStar(require("./IssueSearchItem"), exports);
49
50
  __exportStar(require("./IssueTypeAPI"), exports);
50
51
  __exportStar(require("./IssueTypeAPIRequest"), exports);
51
52
  __exportStar(require("./IssueWorkLogAPI"), exports);
@@ -0,0 +1,54 @@
1
+ import * as runtime from "../runtime";
2
+ import { PlaneOAuthTokenResponse, PlaneOAuthAppInstallation } from "./models";
3
+ /**
4
+ * OAuth API helper class
5
+ */
6
+ export declare class OAuthApi extends runtime.BaseAPI {
7
+ private clientId;
8
+ private clientSecret;
9
+ private redirectUri;
10
+ private baseUrl;
11
+ constructor(configuration: runtime.Configuration, oauthConfig: {
12
+ clientId: string;
13
+ clientSecret: string;
14
+ redirectUri: string;
15
+ });
16
+ /**
17
+ * Get the authorization URL for the OAuth flow
18
+ * @param responseType - The response type (default: "code")
19
+ * @param state - Optional state parameter for security
20
+ * @returns The authorization URL
21
+ */
22
+ getAuthorizationUrl(responseType?: string, state?: string): string;
23
+ /**
24
+ * Exchange authorization code for access token
25
+ * @param code - The authorization code
26
+ * @param grantType - The grant type (default: "authorization_code")
27
+ * @returns Promise resolving to token response
28
+ */
29
+ exchangeCodeForToken(code: string, grantType?: string): Promise<PlaneOAuthTokenResponse>;
30
+ /**
31
+ * Get a new access token using a refresh token
32
+ * @param refreshToken - The refresh token
33
+ * @returns Promise resolving to token response
34
+ */
35
+ getRefreshToken(refreshToken: string): Promise<PlaneOAuthTokenResponse>;
36
+ /**
37
+ * Get a new access token using client credentials for bot/app installations
38
+ * @param appInstallationId - The app installation ID
39
+ * @returns Promise resolving to token response
40
+ */
41
+ getBotToken(appInstallationId: string): Promise<PlaneOAuthTokenResponse>;
42
+ /**
43
+ * Get an app installation by ID using the bot token
44
+ * @param token - The bot token from getBotToken method
45
+ * @param appInstallationId - The app installation ID
46
+ * @returns Promise resolving to app installation
47
+ */
48
+ getAppInstallations(token: string, appInstallationId?: string): Promise<PlaneOAuthAppInstallation[]>;
49
+ /**
50
+ * Generate basic auth token from client_id and client_secret
51
+ * @returns Base64 encoded basic auth token
52
+ */
53
+ private getBasicAuthToken;
54
+ }
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
28
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.OAuthApi = void 0;
55
+ var runtime = require("../runtime");
56
+ /**
57
+ * OAuth API helper class
58
+ */
59
+ var OAuthApi = /** @class */ (function (_super) {
60
+ __extends(OAuthApi, _super);
61
+ function OAuthApi(configuration, oauthConfig) {
62
+ var _this = _super.call(this, configuration) || this;
63
+ _this.clientId = oauthConfig.clientId;
64
+ _this.clientSecret = oauthConfig.clientSecret;
65
+ _this.redirectUri = oauthConfig.redirectUri;
66
+ _this.baseUrl = configuration.basePath || "https://api.plane.so";
67
+ return _this;
68
+ }
69
+ /**
70
+ * Get the authorization URL for the OAuth flow
71
+ * @param responseType - The response type (default: "code")
72
+ * @param state - Optional state parameter for security
73
+ * @returns The authorization URL
74
+ */
75
+ OAuthApi.prototype.getAuthorizationUrl = function (responseType, state) {
76
+ if (responseType === void 0) { responseType = "code"; }
77
+ var params = new URLSearchParams({
78
+ client_id: this.clientId,
79
+ response_type: responseType,
80
+ redirect_uri: this.redirectUri,
81
+ });
82
+ if (state) {
83
+ params.append("state", state);
84
+ }
85
+ return "".concat(this.baseUrl, "/auth/o/authorize-app/?").concat(params.toString());
86
+ };
87
+ /**
88
+ * Exchange authorization code for access token
89
+ * @param code - The authorization code
90
+ * @param grantType - The grant type (default: "authorization_code")
91
+ * @returns Promise resolving to token response
92
+ */
93
+ OAuthApi.prototype.exchangeCodeForToken = function (code_1) {
94
+ return __awaiter(this, arguments, void 0, function (code, grantType) {
95
+ var data, headers, response;
96
+ if (grantType === void 0) { grantType = "authorization_code"; }
97
+ return __generator(this, function (_a) {
98
+ switch (_a.label) {
99
+ case 0:
100
+ data = new URLSearchParams({
101
+ grant_type: grantType,
102
+ code: code,
103
+ client_id: this.clientId,
104
+ client_secret: this.clientSecret,
105
+ redirect_uri: this.redirectUri,
106
+ });
107
+ headers = {
108
+ "Cache-Control": "no-cache",
109
+ "Content-Type": "application/x-www-form-urlencoded",
110
+ };
111
+ return [4 /*yield*/, this.request({
112
+ path: "/auth/o/token/",
113
+ method: "POST",
114
+ headers: headers,
115
+ body: data,
116
+ })];
117
+ case 1:
118
+ response = _a.sent();
119
+ return [4 /*yield*/, response.json()];
120
+ case 2: return [2 /*return*/, _a.sent()];
121
+ }
122
+ });
123
+ });
124
+ };
125
+ /**
126
+ * Get a new access token using a refresh token
127
+ * @param refreshToken - The refresh token
128
+ * @returns Promise resolving to token response
129
+ */
130
+ OAuthApi.prototype.getRefreshToken = function (refreshToken) {
131
+ return __awaiter(this, void 0, void 0, function () {
132
+ var data, headers, response;
133
+ return __generator(this, function (_a) {
134
+ switch (_a.label) {
135
+ case 0:
136
+ data = new URLSearchParams({
137
+ grant_type: "refresh_token",
138
+ refresh_token: refreshToken,
139
+ client_id: this.clientId,
140
+ client_secret: this.clientSecret,
141
+ });
142
+ headers = {
143
+ "Cache-Control": "no-cache",
144
+ "Content-Type": "application/x-www-form-urlencoded",
145
+ };
146
+ return [4 /*yield*/, this.request({
147
+ path: "/auth/o/token/",
148
+ method: "POST",
149
+ headers: headers,
150
+ body: data,
151
+ })];
152
+ case 1:
153
+ response = _a.sent();
154
+ return [4 /*yield*/, response.json()];
155
+ case 2: return [2 /*return*/, _a.sent()];
156
+ }
157
+ });
158
+ });
159
+ };
160
+ /**
161
+ * Get a new access token using client credentials for bot/app installations
162
+ * @param appInstallationId - The app installation ID
163
+ * @returns Promise resolving to token response
164
+ */
165
+ OAuthApi.prototype.getBotToken = function (appInstallationId) {
166
+ return __awaiter(this, void 0, void 0, function () {
167
+ var data, headers, response;
168
+ return __generator(this, function (_a) {
169
+ switch (_a.label) {
170
+ case 0:
171
+ data = new URLSearchParams({
172
+ grant_type: "client_credentials",
173
+ app_installation_id: appInstallationId,
174
+ });
175
+ headers = {
176
+ "Cache-Control": "no-cache",
177
+ "Content-Type": "application/x-www-form-urlencoded",
178
+ Authorization: "Basic ".concat(this.getBasicAuthToken()),
179
+ };
180
+ return [4 /*yield*/, this.request({
181
+ path: "/auth/o/token/",
182
+ method: "POST",
183
+ headers: headers,
184
+ body: data,
185
+ })];
186
+ case 1:
187
+ response = _a.sent();
188
+ return [4 /*yield*/, response.json()];
189
+ case 2: return [2 /*return*/, _a.sent()];
190
+ }
191
+ });
192
+ });
193
+ };
194
+ /**
195
+ * Get an app installation by ID using the bot token
196
+ * @param token - The bot token from getBotToken method
197
+ * @param appInstallationId - The app installation ID
198
+ * @returns Promise resolving to app installation
199
+ */
200
+ OAuthApi.prototype.getAppInstallations = function (token, appInstallationId) {
201
+ return __awaiter(this, void 0, void 0, function () {
202
+ var headers, path, response, data;
203
+ return __generator(this, function (_a) {
204
+ switch (_a.label) {
205
+ case 0:
206
+ headers = {
207
+ Authorization: "Bearer ".concat(token),
208
+ };
209
+ path = "/auth/o/app-installation/";
210
+ if (appInstallationId) {
211
+ path += "?id=".concat(appInstallationId);
212
+ }
213
+ return [4 /*yield*/, this.request({
214
+ path: path,
215
+ method: "GET",
216
+ headers: headers,
217
+ })];
218
+ case 1:
219
+ response = _a.sent();
220
+ return [4 /*yield*/, response.json()];
221
+ case 2:
222
+ data = _a.sent();
223
+ if (!data || data.length === 0) {
224
+ throw new runtime.ResponseError(response, "App installation not found");
225
+ }
226
+ return [2 /*return*/, data];
227
+ }
228
+ });
229
+ });
230
+ };
231
+ /**
232
+ * Generate basic auth token from client_id and client_secret
233
+ * @returns Base64 encoded basic auth token
234
+ */
235
+ OAuthApi.prototype.getBasicAuthToken = function () {
236
+ var credentials = "".concat(this.clientId, ":").concat(this.clientSecret);
237
+ return btoa(credentials);
238
+ };
239
+ return OAuthApi;
240
+ }(runtime.BaseAPI));
241
+ exports.OAuthApi = OAuthApi;
@@ -0,0 +1,28 @@
1
+ export interface PlaneOAuthTokenResponse {
2
+ access_token: string;
3
+ expires_in?: number;
4
+ token_type: string;
5
+ scope?: string;
6
+ refresh_token?: string;
7
+ }
8
+ export interface WorkspaceDetail {
9
+ name: string;
10
+ slug: string;
11
+ id: string;
12
+ logo_url?: string;
13
+ }
14
+ export interface PlaneOAuthAppInstallation {
15
+ id: string;
16
+ workspace_detail: WorkspaceDetail;
17
+ created_at: string;
18
+ updated_at: string;
19
+ deleted_at?: string;
20
+ status: string;
21
+ created_by?: string;
22
+ updated_by?: string;
23
+ workspace: string;
24
+ application: string;
25
+ installed_by: string;
26
+ app_bot: string;
27
+ webhook?: string;
28
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/runtime.js CHANGED
@@ -148,7 +148,7 @@ var Configuration = /** @class */ (function () {
148
148
  Object.defineProperty(Configuration.prototype, "accessToken", {
149
149
  get: function () {
150
150
  var _this = this;
151
- var accessToken = this.configuration.accessToken;
151
+ var accessToken = "Bearer ".concat(this.configuration.accessToken);
152
152
  if (accessToken) {
153
153
  return typeof accessToken === 'function' ? accessToken : function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
154
154
  return [2 /*return*/, accessToken];
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@makeplane/plane-node-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Node SDK for Plane",
5
5
  "author": "Plane <support@plane.so>",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/makeplane/plane-node-sdk.git"
9
9
  },
10
+ "engines": {
11
+ "node": ">=18.0.0"
12
+ },
10
13
  "main": "./dist/index.js",
11
14
  "typings": "./dist/index.d.ts",
12
15
  "scripts": {
@@ -42,7 +42,7 @@ export class MembersApi extends runtime.BaseAPI {
42
42
  * Retrieve all users who are members of the specified project.
43
43
  * List project members
44
44
  */
45
- async getProjectMembersRaw(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserLite>> {
45
+ async getProjectMembersRaw(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<UserLite>>> {
46
46
  if (requestParameters['projectId'] == null) {
47
47
  throw new runtime.RequiredError(
48
48
  'projectId',
@@ -82,14 +82,14 @@ export class MembersApi extends runtime.BaseAPI {
82
82
  query: queryParameters,
83
83
  }, initOverrides);
84
84
 
85
- return new runtime.JSONApiResponse(response, (jsonValue) => UserLiteFromJSON(jsonValue));
85
+ return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserLiteFromJSON));
86
86
  }
87
87
 
88
88
  /**
89
89
  * Retrieve all users who are members of the specified project.
90
90
  * List project members
91
91
  */
92
- async getProjectMembers(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserLite> {
92
+ async getProjectMembers(requestParameters: GetProjectMembersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<UserLite>> {
93
93
  const response = await this.getProjectMembersRaw(requestParameters, initOverrides);
94
94
  return await response.value();
95
95
  }
@@ -194,7 +194,7 @@ export class WorkItemTypesApi extends runtime.BaseAPI {
194
194
  * List all issue types for a project
195
195
  * List issue types
196
196
  */
197
- async listIssueTypesRaw(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<IssueTypeAPI>> {
197
+ async listIssueTypesRaw(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<IssueTypeAPI>>> {
198
198
  if (requestParameters['projectId'] == null) {
199
199
  throw new runtime.RequiredError(
200
200
  'projectId',
@@ -234,14 +234,14 @@ export class WorkItemTypesApi extends runtime.BaseAPI {
234
234
  query: queryParameters,
235
235
  }, initOverrides);
236
236
 
237
- return new runtime.JSONApiResponse(response, (jsonValue) => IssueTypeAPIFromJSON(jsonValue));
237
+ return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(IssueTypeAPIFromJSON));
238
238
  }
239
239
 
240
240
  /**
241
241
  * List all issue types for a project
242
242
  * List issue types
243
243
  */
244
- async listIssueTypes(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<IssueTypeAPI> {
244
+ async listIssueTypes(requestParameters: ListIssueTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<IssueTypeAPI>> {
245
245
  const response = await this.listIssueTypesRaw(requestParameters, initOverrides);
246
246
  return await response.value();
247
247
  }
package/src/index.ts CHANGED
@@ -3,3 +3,4 @@
3
3
  export * from './runtime';
4
4
  export * from './apis/index';
5
5
  export * from './models/index';
6
+ export * from "./oauth/api";
@@ -12,6 +12,14 @@
12
12
  */
13
13
 
14
14
  import { mapValues } from '../runtime';
15
+ import type { IssueSearchItem } from './IssueSearchItem';
16
+ import {
17
+ IssueSearchItemFromJSON,
18
+ IssueSearchItemFromJSONTyped,
19
+ IssueSearchItemToJSON,
20
+ IssueSearchItemToJSONTyped,
21
+ } from './IssueSearchItem';
22
+
15
23
  /**
16
24
  * Serializer for work item search result data formatting.
17
25
  *
@@ -22,53 +30,18 @@ import { mapValues } from '../runtime';
22
30
  */
23
31
  export interface IssueSearch {
24
32
  /**
25
- * Issue ID
26
- * @type {string}
27
- * @memberof IssueSearch
28
- */
29
- id: string;
30
- /**
31
- * Issue name
32
- * @type {string}
33
- * @memberof IssueSearch
34
- */
35
- name: string;
36
- /**
37
- * Issue sequence ID
38
- * @type {string}
39
- * @memberof IssueSearch
40
- */
41
- sequenceId: string;
42
- /**
43
- * Project identifier
44
- * @type {string}
45
- * @memberof IssueSearch
46
- */
47
- projectIdentifier: string;
48
- /**
49
- * Project ID
50
- * @type {string}
51
- * @memberof IssueSearch
52
- */
53
- projectId: string;
54
- /**
55
- * Workspace slug
56
- * @type {string}
33
+ * Array of search result issues
34
+ * @type {Array<IssueSearchItem>}
57
35
  * @memberof IssueSearch
58
36
  */
59
- workspaceSlug: string;
37
+ issues: Array<IssueSearchItem>;
60
38
  }
61
39
 
62
40
  /**
63
41
  * Check if a given object implements the IssueSearch interface.
64
42
  */
65
43
  export function instanceOfIssueSearch(value: object): value is IssueSearch {
66
- if (!('id' in value) || value['id'] === undefined) return false;
67
- if (!('name' in value) || value['name'] === undefined) return false;
68
- if (!('sequenceId' in value) || value['sequenceId'] === undefined) return false;
69
- if (!('projectIdentifier' in value) || value['projectIdentifier'] === undefined) return false;
70
- if (!('projectId' in value) || value['projectId'] === undefined) return false;
71
- if (!('workspaceSlug' in value) || value['workspaceSlug'] === undefined) return false;
44
+ if (!('issues' in value) || value['issues'] === undefined) return false;
72
45
  return true;
73
46
  }
74
47
 
@@ -82,12 +55,7 @@ export function IssueSearchFromJSONTyped(json: any, ignoreDiscriminator: boolean
82
55
  }
83
56
  return {
84
57
 
85
- 'id': json['id'],
86
- 'name': json['name'],
87
- 'sequenceId': json['sequence_id'],
88
- 'projectIdentifier': json['project__identifier'],
89
- 'projectId': json['project_id'],
90
- 'workspaceSlug': json['workspace__slug'],
58
+ 'issues': ((json['issues'] as Array<any>).map(IssueSearchItemFromJSON)),
91
59
  };
92
60
  }
93
61
 
@@ -102,12 +70,7 @@ export function IssueSearchToJSONTyped(value?: IssueSearch | null, ignoreDiscrim
102
70
 
103
71
  return {
104
72
 
105
- 'id': value['id'],
106
- 'name': value['name'],
107
- 'sequence_id': value['sequenceId'],
108
- 'project__identifier': value['projectIdentifier'],
109
- 'project_id': value['projectId'],
110
- 'workspace__slug': value['workspaceSlug'],
73
+ 'issues': ((value['issues'] as Array<any>).map(IssueSearchItemToJSON)),
111
74
  };
112
75
  }
113
76
 
@@ -0,0 +1,113 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * The Plane REST API
5
+ * The Plane REST API Visit our quick start guide and full API documentation at [developers.plane.so](https://developers.plane.so/api-reference/introduction).
6
+ *
7
+ * The version of the API Spec: 0.0.1
8
+ * Contact: support@plane.so
9
+ *
10
+ * NOTE: This class is auto generated.
11
+ * Do not edit the class manually.
12
+ */
13
+
14
+ import { mapValues } from '../runtime';
15
+ /**
16
+ * Individual issue component for search results.
17
+ *
18
+ * Provides standardized search result structure including work item identifiers,
19
+ * project context, and workspace information for search API responses.
20
+ * @export
21
+ * @interface IssueSearchItem
22
+ */
23
+ export interface IssueSearchItem {
24
+ /**
25
+ * Issue ID
26
+ * @type {string}
27
+ * @memberof IssueSearchItem
28
+ */
29
+ id: string;
30
+ /**
31
+ * Issue name
32
+ * @type {string}
33
+ * @memberof IssueSearchItem
34
+ */
35
+ name: string;
36
+ /**
37
+ * Issue sequence ID
38
+ * @type {string}
39
+ * @memberof IssueSearchItem
40
+ */
41
+ sequenceId: string;
42
+ /**
43
+ * Project identifier
44
+ * @type {string}
45
+ * @memberof IssueSearchItem
46
+ */
47
+ projectIdentifier: string;
48
+ /**
49
+ * Project ID
50
+ * @type {string}
51
+ * @memberof IssueSearchItem
52
+ */
53
+ projectId: string;
54
+ /**
55
+ * Workspace slug
56
+ * @type {string}
57
+ * @memberof IssueSearchItem
58
+ */
59
+ workspaceSlug: string;
60
+ }
61
+
62
+ /**
63
+ * Check if a given object implements the IssueSearchItem interface.
64
+ */
65
+ export function instanceOfIssueSearchItem(value: object): value is IssueSearchItem {
66
+ if (!('id' in value) || value['id'] === undefined) return false;
67
+ if (!('name' in value) || value['name'] === undefined) return false;
68
+ if (!('sequenceId' in value) || value['sequenceId'] === undefined) return false;
69
+ if (!('projectIdentifier' in value) || value['projectIdentifier'] === undefined) return false;
70
+ if (!('projectId' in value) || value['projectId'] === undefined) return false;
71
+ if (!('workspaceSlug' in value) || value['workspaceSlug'] === undefined) return false;
72
+ return true;
73
+ }
74
+
75
+ export function IssueSearchItemFromJSON(json: any): IssueSearchItem {
76
+ return IssueSearchItemFromJSONTyped(json, false);
77
+ }
78
+
79
+ export function IssueSearchItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): IssueSearchItem {
80
+ if (json == null) {
81
+ return json;
82
+ }
83
+ return {
84
+
85
+ 'id': json['id'],
86
+ 'name': json['name'],
87
+ 'sequenceId': json['sequence_id'],
88
+ 'projectIdentifier': json['project__identifier'],
89
+ 'projectId': json['project_id'],
90
+ 'workspaceSlug': json['workspace__slug'],
91
+ };
92
+ }
93
+
94
+ export function IssueSearchItemToJSON(json: any): IssueSearchItem {
95
+ return IssueSearchItemToJSONTyped(json, false);
96
+ }
97
+
98
+ export function IssueSearchItemToJSONTyped(value?: IssueSearchItem | null, ignoreDiscriminator: boolean = false): any {
99
+ if (value == null) {
100
+ return value;
101
+ }
102
+
103
+ return {
104
+
105
+ 'id': value['id'],
106
+ 'name': value['name'],
107
+ 'sequence_id': value['sequenceId'],
108
+ 'project__identifier': value['projectIdentifier'],
109
+ 'project_id': value['projectId'],
110
+ 'workspace__slug': value['workspaceSlug'],
111
+ };
112
+ }
113
+
@@ -71,12 +71,6 @@ export interface State {
71
71
  * @memberof State
72
72
  */
73
73
  color: string;
74
- /**
75
- *
76
- * @type {string}
77
- * @memberof State
78
- */
79
- readonly slug?: string;
80
74
  /**
81
75
  *
82
76
  * @type {number}
@@ -167,7 +161,6 @@ export function StateFromJSONTyped(json: any, ignoreDiscriminator: boolean): Sta
167
161
  'name': json['name'],
168
162
  'description': json['description'] == null ? undefined : json['description'],
169
163
  'color': json['color'],
170
- 'slug': json['slug'] == null ? undefined : json['slug'],
171
164
  'sequence': json['sequence'] == null ? undefined : json['sequence'],
172
165
  'group': json['group'] == null ? undefined : GroupEnumFromJSON(json['group']),
173
166
  'isTriage': json['is_triage'] == null ? undefined : json['is_triage'],
@@ -185,7 +178,7 @@ export function StateToJSON(json: any): State {
185
178
  return StateToJSONTyped(json, false);
186
179
  }
187
180
 
188
- export function StateToJSONTyped(value?: Omit<State, 'id'|'created_at'|'updated_at'|'deleted_at'|'slug'|'created_by'|'updated_by'|'project'|'workspace'> | null, ignoreDiscriminator: boolean = false): any {
181
+ export function StateToJSONTyped(value?: Omit<State, 'id'|'created_at'|'updated_at'|'deleted_at'|'created_by'|'updated_by'|'project'|'workspace'> | null, ignoreDiscriminator: boolean = false): any {
189
182
  if (value == null) {
190
183
  return value;
191
184
  }
@@ -31,6 +31,7 @@ export * from './IssuePropertyValueAPI';
31
31
  export * from './IssuePropertyValueAPIRequest';
32
32
  export * from './IssueRequest';
33
33
  export * from './IssueSearch';
34
+ export * from './IssueSearchItem';
34
35
  export * from './IssueTypeAPI';
35
36
  export * from './IssueTypeAPIRequest';
36
37
  export * from './IssueWorkLogAPI';
@@ -0,0 +1,181 @@
1
+ import * as runtime from "../runtime";
2
+ import { PlaneOAuthTokenResponse, PlaneOAuthAppInstallation } from "./models";
3
+
4
+ /**
5
+ * OAuth API helper class
6
+ */
7
+ export class OAuthApi extends runtime.BaseAPI {
8
+ private clientId: string;
9
+ private clientSecret: string;
10
+ private redirectUri: string;
11
+ private baseUrl: string;
12
+
13
+ constructor(
14
+ configuration: runtime.Configuration,
15
+ oauthConfig: {
16
+ clientId: string;
17
+ clientSecret: string;
18
+ redirectUri: string;
19
+ }
20
+ ) {
21
+ super(configuration);
22
+ this.clientId = oauthConfig.clientId;
23
+ this.clientSecret = oauthConfig.clientSecret;
24
+ this.redirectUri = oauthConfig.redirectUri;
25
+ this.baseUrl = configuration.basePath || "https://api.plane.so";
26
+ }
27
+
28
+ /**
29
+ * Get the authorization URL for the OAuth flow
30
+ * @param responseType - The response type (default: "code")
31
+ * @param state - Optional state parameter for security
32
+ * @returns The authorization URL
33
+ */
34
+ getAuthorizationUrl(responseType: string = "code", state?: string): string {
35
+ const params = new URLSearchParams({
36
+ client_id: this.clientId,
37
+ response_type: responseType,
38
+ redirect_uri: this.redirectUri,
39
+ });
40
+
41
+ if (state) {
42
+ params.append("state", state);
43
+ }
44
+
45
+ return `${this.baseUrl}/auth/o/authorize-app/?${params.toString()}`;
46
+ }
47
+
48
+ /**
49
+ * Exchange authorization code for access token
50
+ * @param code - The authorization code
51
+ * @param grantType - The grant type (default: "authorization_code")
52
+ * @returns Promise resolving to token response
53
+ */
54
+ async exchangeCodeForToken(
55
+ code: string,
56
+ grantType: string = "authorization_code"
57
+ ): Promise<PlaneOAuthTokenResponse> {
58
+ const data = new URLSearchParams({
59
+ grant_type: grantType,
60
+ code: code,
61
+ client_id: this.clientId,
62
+ client_secret: this.clientSecret,
63
+ redirect_uri: this.redirectUri,
64
+ });
65
+
66
+ const headers: runtime.HTTPHeaders = {
67
+ "Cache-Control": "no-cache",
68
+ "Content-Type": "application/x-www-form-urlencoded",
69
+ };
70
+
71
+ const response = await this.request({
72
+ path: `/auth/o/token/`,
73
+ method: "POST",
74
+ headers: headers,
75
+ body: data,
76
+ });
77
+
78
+ return await response.json();
79
+ }
80
+
81
+ /**
82
+ * Get a new access token using a refresh token
83
+ * @param refreshToken - The refresh token
84
+ * @returns Promise resolving to token response
85
+ */
86
+ async getRefreshToken(
87
+ refreshToken: string
88
+ ): Promise<PlaneOAuthTokenResponse> {
89
+ const data = new URLSearchParams({
90
+ grant_type: "refresh_token",
91
+ refresh_token: refreshToken,
92
+ client_id: this.clientId,
93
+ client_secret: this.clientSecret,
94
+ });
95
+
96
+ const headers: runtime.HTTPHeaders = {
97
+ "Cache-Control": "no-cache",
98
+ "Content-Type": "application/x-www-form-urlencoded",
99
+ };
100
+
101
+ const response = await this.request({
102
+ path: `/auth/o/token/`,
103
+ method: "POST",
104
+ headers: headers,
105
+ body: data,
106
+ });
107
+
108
+ return await response.json();
109
+ }
110
+
111
+ /**
112
+ * Get a new access token using client credentials for bot/app installations
113
+ * @param appInstallationId - The app installation ID
114
+ * @returns Promise resolving to token response
115
+ */
116
+ async getBotToken(
117
+ appInstallationId: string
118
+ ): Promise<PlaneOAuthTokenResponse> {
119
+ const data = new URLSearchParams({
120
+ grant_type: "client_credentials",
121
+ app_installation_id: appInstallationId,
122
+ });
123
+
124
+ const headers: runtime.HTTPHeaders = {
125
+ "Cache-Control": "no-cache",
126
+ "Content-Type": "application/x-www-form-urlencoded",
127
+ Authorization: `Basic ${this.getBasicAuthToken()}`,
128
+ };
129
+
130
+ const response = await this.request({
131
+ path: `/auth/o/token/`,
132
+ method: "POST",
133
+ headers: headers,
134
+ body: data,
135
+ });
136
+
137
+ return await response.json();
138
+ }
139
+
140
+ /**
141
+ * Get an app installation by ID using the bot token
142
+ * @param token - The bot token from getBotToken method
143
+ * @param appInstallationId - The app installation ID
144
+ * @returns Promise resolving to app installation
145
+ */
146
+ async getAppInstallations(
147
+ token: string,
148
+ appInstallationId?: string
149
+ ): Promise<PlaneOAuthAppInstallation[]> {
150
+ const headers: runtime.HTTPHeaders = {
151
+ Authorization: `Bearer ${token}`,
152
+ };
153
+
154
+ let path = `/auth/o/app-installation/`;
155
+ if (appInstallationId) {
156
+ path += `?id=${appInstallationId}`;
157
+ }
158
+
159
+ const response = await this.request({
160
+ path: path,
161
+ method: "GET",
162
+ headers: headers,
163
+ });
164
+
165
+ const data = await response.json();
166
+ if (!data || data.length === 0) {
167
+ throw new runtime.ResponseError(response, "App installation not found");
168
+ }
169
+
170
+ return data;
171
+ }
172
+
173
+ /**
174
+ * Generate basic auth token from client_id and client_secret
175
+ * @returns Base64 encoded basic auth token
176
+ */
177
+ private getBasicAuthToken(): string {
178
+ const credentials = `${this.clientId}:${this.clientSecret}`;
179
+ return btoa(credentials);
180
+ }
181
+ }
@@ -0,0 +1,30 @@
1
+ export interface PlaneOAuthTokenResponse {
2
+ access_token: string;
3
+ expires_in?: number;
4
+ token_type: string;
5
+ scope?: string;
6
+ refresh_token?: string;
7
+ }
8
+
9
+ export interface WorkspaceDetail {
10
+ name: string;
11
+ slug: string;
12
+ id: string;
13
+ logo_url?: string;
14
+ }
15
+
16
+ export interface PlaneOAuthAppInstallation {
17
+ id: string;
18
+ workspace_detail: WorkspaceDetail;
19
+ created_at: string;
20
+ updated_at: string;
21
+ deleted_at?: string;
22
+ status: string;
23
+ created_by?: string;
24
+ updated_by?: string;
25
+ workspace: string;
26
+ application: string;
27
+ installed_by: string;
28
+ app_bot: string;
29
+ webhook?: string;
30
+ }
package/src/runtime.ts CHANGED
@@ -67,7 +67,7 @@ export class Configuration {
67
67
  }
68
68
 
69
69
  get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
70
- const accessToken = this.configuration.accessToken;
70
+ const accessToken = `Bearer ${this.configuration.accessToken}`;
71
71
  if (accessToken) {
72
72
  return typeof accessToken === 'function' ? accessToken : async () => accessToken;
73
73
  }