@ubiquity-os/plugin-sdk 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/index.mjs +5 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -5,9 +5,9 @@ import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
|
|
|
5
5
|
import { customOctokit } from './octokit.mjs';
|
|
6
6
|
import { Manifest } from './manifest.mjs';
|
|
7
7
|
import { TAnySchema } from '@sinclair/typebox';
|
|
8
|
+
import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
|
|
8
9
|
import '@octokit/core/dist-types/types';
|
|
9
10
|
import '@octokit/plugin-paginate-graphql';
|
|
10
|
-
import '@octokit/plugin-rest-endpoint-methods';
|
|
11
11
|
import '@octokit/plugin-paginate-rest';
|
|
12
12
|
import '@octokit/request-error';
|
|
13
13
|
import '@octokit/core';
|
|
@@ -48,8 +48,11 @@ interface CommentOptions {
|
|
|
48
48
|
raw?: boolean;
|
|
49
49
|
updateComment?: boolean;
|
|
50
50
|
}
|
|
51
|
+
type WithIssueNumber<T> = T & {
|
|
52
|
+
issueNumber: number;
|
|
53
|
+
};
|
|
51
54
|
type PostComment = {
|
|
52
|
-
(context: Context, message: LogReturn | Error, options?: CommentOptions): Promise<
|
|
55
|
+
(context: Context, message: LogReturn | Error, options?: CommentOptions): Promise<WithIssueNumber<RestEndpointMethodTypes["issues"]["updateComment"]["response"]["data"] | RestEndpointMethodTypes["issues"]["createComment"]["response"]["data"]> | null>;
|
|
53
56
|
lastCommentId?: number;
|
|
54
57
|
};
|
|
55
58
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
|
|
|
5
5
|
import { customOctokit } from './octokit.js';
|
|
6
6
|
import { Manifest } from './manifest.js';
|
|
7
7
|
import { TAnySchema } from '@sinclair/typebox';
|
|
8
|
+
import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
|
|
8
9
|
import '@octokit/core/dist-types/types';
|
|
9
10
|
import '@octokit/plugin-paginate-graphql';
|
|
10
|
-
import '@octokit/plugin-rest-endpoint-methods';
|
|
11
11
|
import '@octokit/plugin-paginate-rest';
|
|
12
12
|
import '@octokit/request-error';
|
|
13
13
|
import '@octokit/core';
|
|
@@ -48,8 +48,11 @@ interface CommentOptions {
|
|
|
48
48
|
raw?: boolean;
|
|
49
49
|
updateComment?: boolean;
|
|
50
50
|
}
|
|
51
|
+
type WithIssueNumber<T> = T & {
|
|
52
|
+
issueNumber: number;
|
|
53
|
+
};
|
|
51
54
|
type PostComment = {
|
|
52
|
-
(context: Context, message: LogReturn | Error, options?: CommentOptions): Promise<
|
|
55
|
+
(context: Context, message: LogReturn | Error, options?: CommentOptions): Promise<WithIssueNumber<RestEndpointMethodTypes["issues"]["updateComment"]["response"]["data"] | RestEndpointMethodTypes["issues"]["createComment"]["response"]["data"]> | null>;
|
|
53
56
|
lastCommentId?: number;
|
|
54
57
|
};
|
|
55
58
|
/**
|
package/dist/index.js
CHANGED
|
@@ -127,17 +127,18 @@ var postComment = async function(context2, message, options = { updateComment: t
|
|
|
127
127
|
issueNumber = context2.payload.discussion.number;
|
|
128
128
|
} else {
|
|
129
129
|
context2.logger.info("Cannot post comment because issue is not found in the payload.");
|
|
130
|
-
return;
|
|
130
|
+
return null;
|
|
131
131
|
}
|
|
132
132
|
if ("repository" in context2.payload && context2.payload.repository?.owner?.login) {
|
|
133
133
|
const body = await createStructuredMetadataWithMessage(context2, message, options);
|
|
134
134
|
if (options.updateComment && postComment.lastCommentId) {
|
|
135
|
-
await context2.octokit.rest.issues.updateComment({
|
|
135
|
+
const commentData = await context2.octokit.rest.issues.updateComment({
|
|
136
136
|
owner: context2.payload.repository.owner.login,
|
|
137
137
|
repo: context2.payload.repository.name,
|
|
138
138
|
comment_id: postComment.lastCommentId,
|
|
139
139
|
body
|
|
140
140
|
});
|
|
141
|
+
return { ...commentData.data, issueNumber };
|
|
141
142
|
} else {
|
|
142
143
|
const commentData = await context2.octokit.rest.issues.createComment({
|
|
143
144
|
owner: context2.payload.repository.owner.login,
|
|
@@ -146,10 +147,12 @@ var postComment = async function(context2, message, options = { updateComment: t
|
|
|
146
147
|
body
|
|
147
148
|
});
|
|
148
149
|
postComment.lastCommentId = commentData.data.id;
|
|
150
|
+
return { ...commentData.data, issueNumber };
|
|
149
151
|
}
|
|
150
152
|
} else {
|
|
151
153
|
context2.logger.info("Cannot post comment because repository is not found in the payload.", { payload: context2.payload });
|
|
152
154
|
}
|
|
155
|
+
return null;
|
|
153
156
|
};
|
|
154
157
|
async function createStructuredMetadataWithMessage(context2, message, options) {
|
|
155
158
|
let logMessage;
|
package/dist/index.mjs
CHANGED
|
@@ -89,17 +89,18 @@ var postComment = async function(context2, message, options = { updateComment: t
|
|
|
89
89
|
issueNumber = context2.payload.discussion.number;
|
|
90
90
|
} else {
|
|
91
91
|
context2.logger.info("Cannot post comment because issue is not found in the payload.");
|
|
92
|
-
return;
|
|
92
|
+
return null;
|
|
93
93
|
}
|
|
94
94
|
if ("repository" in context2.payload && context2.payload.repository?.owner?.login) {
|
|
95
95
|
const body = await createStructuredMetadataWithMessage(context2, message, options);
|
|
96
96
|
if (options.updateComment && postComment.lastCommentId) {
|
|
97
|
-
await context2.octokit.rest.issues.updateComment({
|
|
97
|
+
const commentData = await context2.octokit.rest.issues.updateComment({
|
|
98
98
|
owner: context2.payload.repository.owner.login,
|
|
99
99
|
repo: context2.payload.repository.name,
|
|
100
100
|
comment_id: postComment.lastCommentId,
|
|
101
101
|
body
|
|
102
102
|
});
|
|
103
|
+
return { ...commentData.data, issueNumber };
|
|
103
104
|
} else {
|
|
104
105
|
const commentData = await context2.octokit.rest.issues.createComment({
|
|
105
106
|
owner: context2.payload.repository.owner.login,
|
|
@@ -108,10 +109,12 @@ var postComment = async function(context2, message, options = { updateComment: t
|
|
|
108
109
|
body
|
|
109
110
|
});
|
|
110
111
|
postComment.lastCommentId = commentData.data.id;
|
|
112
|
+
return { ...commentData.data, issueNumber };
|
|
111
113
|
}
|
|
112
114
|
} else {
|
|
113
115
|
context2.logger.info("Cannot post comment because repository is not found in the payload.", { payload: context2.payload });
|
|
114
116
|
}
|
|
117
|
+
return null;
|
|
115
118
|
};
|
|
116
119
|
async function createStructuredMetadataWithMessage(context2, message, options) {
|
|
117
120
|
let logMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubiquity-os/plugin-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "SDK for plugin support.",
|
|
5
5
|
"author": "Ubiquity DAO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@octokit/rest": "^21.0.2",
|
|
88
88
|
"@octokit/types": "^13.6.1",
|
|
89
89
|
"@octokit/webhooks": "^13.3.0",
|
|
90
|
-
"@ubiquity-os/ubiquity-os-logger": "^1.
|
|
90
|
+
"@ubiquity-os/ubiquity-os-logger": "^1.4.0",
|
|
91
91
|
"dotenv": "^16.4.5",
|
|
92
92
|
"hono": "^4.6.9"
|
|
93
93
|
},
|