@ubiquity-os/plugin-sdk 3.8.0 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -27
- package/dist/configuration.d.mts +3 -3
- package/dist/configuration.d.ts +3 -3
- package/dist/configuration.js +12 -2632
- package/dist/configuration.mjs +2 -2632
- package/dist/{context-zLHgu52i.d.ts → context-BE4WjJZf.d.ts} +0 -28
- package/dist/{context-Dwl3aRX-.d.mts → context-Ckj1HMjz.d.mts} +0 -28
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +127 -2857
- package/dist/index.mjs +93 -2823
- package/dist/llm.d.mts +2 -2
- package/dist/llm.d.ts +2 -2
- package/dist/llm.js +11 -0
- package/dist/llm.mjs +11 -0
- package/dist/octokit.d.mts +2 -2
- package/dist/octokit.d.ts +2 -2
- package/dist/octokit.js +2 -164
- package/dist/octokit.mjs +1 -163
- package/package.json +11 -1
package/dist/llm.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChatCompletionMessageParam, ChatCompletionCreateParamsNonStreaming, ChatCompletion, ChatCompletionChunk } from 'openai/resources/chat/completions';
|
|
2
|
-
import { C as Context } from './context-
|
|
2
|
+
import { C as Context } from './context-Ckj1HMjz.mjs';
|
|
3
3
|
import { PluginInput } from './signature.mjs';
|
|
4
4
|
import '@octokit/webhooks';
|
|
5
5
|
import '@ubiquity-os/ubiquity-os-logger';
|
|
@@ -8,7 +8,7 @@ import './octokit.mjs';
|
|
|
8
8
|
import '@octokit/core/types';
|
|
9
9
|
import '@octokit/plugin-paginate-graphql';
|
|
10
10
|
import '@octokit/plugin-paginate-rest';
|
|
11
|
-
import '@octokit/request-error';
|
|
11
|
+
import '@octokit/webhooks/node_modules/@octokit/request-error';
|
|
12
12
|
import '@octokit/core';
|
|
13
13
|
import '@sinclair/typebox';
|
|
14
14
|
|
package/dist/llm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChatCompletionMessageParam, ChatCompletionCreateParamsNonStreaming, ChatCompletion, ChatCompletionChunk } from 'openai/resources/chat/completions';
|
|
2
|
-
import { C as Context } from './context-
|
|
2
|
+
import { C as Context } from './context-BE4WjJZf.js';
|
|
3
3
|
import { PluginInput } from './signature.js';
|
|
4
4
|
import '@octokit/webhooks';
|
|
5
5
|
import '@ubiquity-os/ubiquity-os-logger';
|
|
@@ -8,7 +8,7 @@ import './octokit.js';
|
|
|
8
8
|
import '@octokit/core/types';
|
|
9
9
|
import '@octokit/plugin-paginate-graphql';
|
|
10
10
|
import '@octokit/plugin-paginate-rest';
|
|
11
|
-
import '@octokit/request-error';
|
|
11
|
+
import '@octokit/webhooks/node_modules/@octokit/request-error';
|
|
12
12
|
import '@octokit/core';
|
|
13
13
|
import '@sinclair/typebox';
|
|
14
14
|
|
package/dist/llm.js
CHANGED
|
@@ -122,6 +122,10 @@ async function fetchWithRetry(url, options, maxRetries) {
|
|
|
122
122
|
throw error;
|
|
123
123
|
} catch (error) {
|
|
124
124
|
lastError = error;
|
|
125
|
+
const status = typeof error.status === "number" ? error.status : void 0;
|
|
126
|
+
if (typeof status === "number" && status < 500) {
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
125
129
|
if (attempt >= maxRetries) throw error;
|
|
126
130
|
await sleep(getRetryDelayMs(attempt));
|
|
127
131
|
attempt += 1;
|
|
@@ -197,6 +201,13 @@ function parseEventData(data) {
|
|
|
197
201
|
try {
|
|
198
202
|
return JSON.parse(data);
|
|
199
203
|
} catch (error) {
|
|
204
|
+
if (data.includes("\n")) {
|
|
205
|
+
const collapsed = data.replace(/\n/g, EMPTY_STRING);
|
|
206
|
+
try {
|
|
207
|
+
return JSON.parse(collapsed);
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
200
211
|
const message = error instanceof Error ? error.message : String(error);
|
|
201
212
|
const preview = data.length > 200 ? `${data.slice(0, 200)}...` : data;
|
|
202
213
|
throw new Error(`LLM stream parse error: ${message}. Data: ${preview}`);
|
package/dist/llm.mjs
CHANGED
|
@@ -98,6 +98,10 @@ async function fetchWithRetry(url, options, maxRetries) {
|
|
|
98
98
|
throw error;
|
|
99
99
|
} catch (error) {
|
|
100
100
|
lastError = error;
|
|
101
|
+
const status = typeof error.status === "number" ? error.status : void 0;
|
|
102
|
+
if (typeof status === "number" && status < 500) {
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
101
105
|
if (attempt >= maxRetries) throw error;
|
|
102
106
|
await sleep(getRetryDelayMs(attempt));
|
|
103
107
|
attempt += 1;
|
|
@@ -173,6 +177,13 @@ function parseEventData(data) {
|
|
|
173
177
|
try {
|
|
174
178
|
return JSON.parse(data);
|
|
175
179
|
} catch (error) {
|
|
180
|
+
if (data.includes("\n")) {
|
|
181
|
+
const collapsed = data.replace(/\n/g, EMPTY_STRING);
|
|
182
|
+
try {
|
|
183
|
+
return JSON.parse(collapsed);
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
176
187
|
const message = error instanceof Error ? error.message : String(error);
|
|
177
188
|
const preview = data.length > 200 ? `${data.slice(0, 200)}...` : data;
|
|
178
189
|
throw new Error(`LLM stream parse error: ${message}. Data: ${preview}`);
|
package/dist/octokit.d.mts
CHANGED
|
@@ -3,12 +3,12 @@ import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-grap
|
|
|
3
3
|
import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
|
|
4
4
|
export { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
|
|
5
5
|
import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
|
|
6
|
-
import * as
|
|
6
|
+
import * as _octokit_webhooks_node_modules__octokit_request_error from '@octokit/webhooks/node_modules/@octokit/request-error';
|
|
7
7
|
import { Octokit } from '@octokit/core';
|
|
8
8
|
|
|
9
9
|
declare const customOctokit: typeof Octokit & _octokit_core_types.Constructor<{
|
|
10
10
|
retry: {
|
|
11
|
-
retryRequest: (error:
|
|
11
|
+
retryRequest: (error: _octokit_webhooks_node_modules__octokit_request_error.RequestError, retries: number, retryAfter: number) => _octokit_webhooks_node_modules__octokit_request_error.RequestError;
|
|
12
12
|
};
|
|
13
13
|
} & {
|
|
14
14
|
paginate: _octokit_plugin_paginate_rest.PaginateInterface;
|
package/dist/octokit.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-grap
|
|
|
3
3
|
import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
|
|
4
4
|
export { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
|
|
5
5
|
import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
|
|
6
|
-
import * as
|
|
6
|
+
import * as _octokit_webhooks_node_modules__octokit_request_error from '@octokit/webhooks/node_modules/@octokit/request-error';
|
|
7
7
|
import { Octokit } from '@octokit/core';
|
|
8
8
|
|
|
9
9
|
declare const customOctokit: typeof Octokit & _octokit_core_types.Constructor<{
|
|
10
10
|
retry: {
|
|
11
|
-
retryRequest: (error:
|
|
11
|
+
retryRequest: (error: _octokit_webhooks_node_modules__octokit_request_error.RequestError, retries: number, retryAfter: number) => _octokit_webhooks_node_modules__octokit_request_error.RequestError;
|
|
12
12
|
};
|
|
13
13
|
} & {
|
|
14
14
|
paginate: _octokit_plugin_paginate_rest.PaginateInterface;
|
package/dist/octokit.js
CHANGED
|
@@ -24,169 +24,7 @@ __export(octokit_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(octokit_exports);
|
|
26
26
|
var import_core = require("@octokit/core");
|
|
27
|
-
|
|
28
|
-
// ../../node_modules/@octokit/plugin-paginate-graphql/dist-bundle/index.js
|
|
29
|
-
var generateMessage = (path, cursorValue) => `The cursor at "${path.join(
|
|
30
|
-
","
|
|
31
|
-
)}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`;
|
|
32
|
-
var MissingCursorChange = class extends Error {
|
|
33
|
-
constructor(pageInfo, cursorValue) {
|
|
34
|
-
super(generateMessage(pageInfo.pathInQuery, cursorValue));
|
|
35
|
-
this.pageInfo = pageInfo;
|
|
36
|
-
this.cursorValue = cursorValue;
|
|
37
|
-
if (Error.captureStackTrace) {
|
|
38
|
-
Error.captureStackTrace(this, this.constructor);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
name = "MissingCursorChangeError";
|
|
42
|
-
};
|
|
43
|
-
var MissingPageInfo = class extends Error {
|
|
44
|
-
constructor(response) {
|
|
45
|
-
super(
|
|
46
|
-
`No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify(
|
|
47
|
-
response,
|
|
48
|
-
null,
|
|
49
|
-
2
|
|
50
|
-
)}`
|
|
51
|
-
);
|
|
52
|
-
this.response = response;
|
|
53
|
-
if (Error.captureStackTrace) {
|
|
54
|
-
Error.captureStackTrace(this, this.constructor);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
name = "MissingPageInfo";
|
|
58
|
-
};
|
|
59
|
-
var isObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
|
|
60
|
-
function findPaginatedResourcePath(responseData) {
|
|
61
|
-
const paginatedResourcePath = deepFindPathToProperty(
|
|
62
|
-
responseData,
|
|
63
|
-
"pageInfo"
|
|
64
|
-
);
|
|
65
|
-
if (paginatedResourcePath.length === 0) {
|
|
66
|
-
throw new MissingPageInfo(responseData);
|
|
67
|
-
}
|
|
68
|
-
return paginatedResourcePath;
|
|
69
|
-
}
|
|
70
|
-
var deepFindPathToProperty = (object, searchProp, path = []) => {
|
|
71
|
-
for (const key of Object.keys(object)) {
|
|
72
|
-
const currentPath = [...path, key];
|
|
73
|
-
const currentValue = object[key];
|
|
74
|
-
if (isObject(currentValue)) {
|
|
75
|
-
if (currentValue.hasOwnProperty(searchProp)) {
|
|
76
|
-
return currentPath;
|
|
77
|
-
}
|
|
78
|
-
const result = deepFindPathToProperty(
|
|
79
|
-
currentValue,
|
|
80
|
-
searchProp,
|
|
81
|
-
currentPath
|
|
82
|
-
);
|
|
83
|
-
if (result.length > 0) {
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return [];
|
|
89
|
-
};
|
|
90
|
-
var get = (object, path) => {
|
|
91
|
-
return path.reduce((current, nextProperty) => current[nextProperty], object);
|
|
92
|
-
};
|
|
93
|
-
var set = (object, path, mutator) => {
|
|
94
|
-
const lastProperty = path[path.length - 1];
|
|
95
|
-
const parentPath = [...path].slice(0, -1);
|
|
96
|
-
const parent = get(object, parentPath);
|
|
97
|
-
if (typeof mutator === "function") {
|
|
98
|
-
parent[lastProperty] = mutator(parent[lastProperty]);
|
|
99
|
-
} else {
|
|
100
|
-
parent[lastProperty] = mutator;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
var extractPageInfos = (responseData) => {
|
|
104
|
-
const pageInfoPath = findPaginatedResourcePath(responseData);
|
|
105
|
-
return {
|
|
106
|
-
pathInQuery: pageInfoPath,
|
|
107
|
-
pageInfo: get(responseData, [...pageInfoPath, "pageInfo"])
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
var isForwardSearch = (givenPageInfo) => {
|
|
111
|
-
return givenPageInfo.hasOwnProperty("hasNextPage");
|
|
112
|
-
};
|
|
113
|
-
var getCursorFrom = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.endCursor : pageInfo.startCursor;
|
|
114
|
-
var hasAnotherPage = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.hasNextPage : pageInfo.hasPreviousPage;
|
|
115
|
-
var createIterator = (octokit) => {
|
|
116
|
-
return (query, initialParameters = {}) => {
|
|
117
|
-
let nextPageExists = true;
|
|
118
|
-
let parameters = { ...initialParameters };
|
|
119
|
-
return {
|
|
120
|
-
[Symbol.asyncIterator]: () => ({
|
|
121
|
-
async next() {
|
|
122
|
-
if (!nextPageExists) return { done: true, value: {} };
|
|
123
|
-
const response = await octokit.graphql(
|
|
124
|
-
query,
|
|
125
|
-
parameters
|
|
126
|
-
);
|
|
127
|
-
const pageInfoContext = extractPageInfos(response);
|
|
128
|
-
const nextCursorValue = getCursorFrom(pageInfoContext.pageInfo);
|
|
129
|
-
nextPageExists = hasAnotherPage(pageInfoContext.pageInfo);
|
|
130
|
-
if (nextPageExists && nextCursorValue === parameters.cursor) {
|
|
131
|
-
throw new MissingCursorChange(pageInfoContext, nextCursorValue);
|
|
132
|
-
}
|
|
133
|
-
parameters = {
|
|
134
|
-
...parameters,
|
|
135
|
-
cursor: nextCursorValue
|
|
136
|
-
};
|
|
137
|
-
return { done: false, value: response };
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
var mergeResponses = (response1, response2) => {
|
|
144
|
-
if (Object.keys(response1).length === 0) {
|
|
145
|
-
return Object.assign(response1, response2);
|
|
146
|
-
}
|
|
147
|
-
const path = findPaginatedResourcePath(response1);
|
|
148
|
-
const nodesPath = [...path, "nodes"];
|
|
149
|
-
const newNodes = get(response2, nodesPath);
|
|
150
|
-
if (newNodes) {
|
|
151
|
-
set(response1, nodesPath, (values) => {
|
|
152
|
-
return [...values, ...newNodes];
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
const edgesPath = [...path, "edges"];
|
|
156
|
-
const newEdges = get(response2, edgesPath);
|
|
157
|
-
if (newEdges) {
|
|
158
|
-
set(response1, edgesPath, (values) => {
|
|
159
|
-
return [...values, ...newEdges];
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
const pageInfoPath = [...path, "pageInfo"];
|
|
163
|
-
set(response1, pageInfoPath, get(response2, pageInfoPath));
|
|
164
|
-
return response1;
|
|
165
|
-
};
|
|
166
|
-
var createPaginate = (octokit) => {
|
|
167
|
-
const iterator = createIterator(octokit);
|
|
168
|
-
return async (query, initialParameters = {}) => {
|
|
169
|
-
let mergedResponse = {};
|
|
170
|
-
for await (const response of iterator(
|
|
171
|
-
query,
|
|
172
|
-
initialParameters
|
|
173
|
-
)) {
|
|
174
|
-
mergedResponse = mergeResponses(mergedResponse, response);
|
|
175
|
-
}
|
|
176
|
-
return mergedResponse;
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
function paginateGraphQL(octokit) {
|
|
180
|
-
return {
|
|
181
|
-
graphql: Object.assign(octokit.graphql, {
|
|
182
|
-
paginate: Object.assign(createPaginate(octokit), {
|
|
183
|
-
iterator: createIterator(octokit)
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// src/octokit.ts
|
|
27
|
+
var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
|
|
190
28
|
var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
|
|
191
29
|
var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
|
|
192
30
|
var import_plugin_retry = require("@octokit/plugin-retry");
|
|
@@ -207,7 +45,7 @@ var defaultOptions = {
|
|
|
207
45
|
}
|
|
208
46
|
}
|
|
209
47
|
};
|
|
210
|
-
var customOctokit = import_core.Octokit.plugin(import_plugin_throttling.throttling, import_plugin_retry.retry, import_plugin_paginate_rest.paginateRest, import_plugin_rest_endpoint_methods.restEndpointMethods, paginateGraphQL).defaults((instanceOptions) => {
|
|
48
|
+
var customOctokit = import_core.Octokit.plugin(import_plugin_throttling.throttling, import_plugin_retry.retry, import_plugin_paginate_rest.paginateRest, import_plugin_rest_endpoint_methods.restEndpointMethods, import_plugin_paginate_graphql.paginateGraphQL).defaults((instanceOptions) => {
|
|
211
49
|
return { ...defaultOptions, ...instanceOptions };
|
|
212
50
|
});
|
|
213
51
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/octokit.mjs
CHANGED
|
@@ -1,168 +1,6 @@
|
|
|
1
1
|
// src/octokit.ts
|
|
2
2
|
import { Octokit } from "@octokit/core";
|
|
3
|
-
|
|
4
|
-
// ../../node_modules/@octokit/plugin-paginate-graphql/dist-bundle/index.js
|
|
5
|
-
var generateMessage = (path, cursorValue) => `The cursor at "${path.join(
|
|
6
|
-
","
|
|
7
|
-
)}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`;
|
|
8
|
-
var MissingCursorChange = class extends Error {
|
|
9
|
-
constructor(pageInfo, cursorValue) {
|
|
10
|
-
super(generateMessage(pageInfo.pathInQuery, cursorValue));
|
|
11
|
-
this.pageInfo = pageInfo;
|
|
12
|
-
this.cursorValue = cursorValue;
|
|
13
|
-
if (Error.captureStackTrace) {
|
|
14
|
-
Error.captureStackTrace(this, this.constructor);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
name = "MissingCursorChangeError";
|
|
18
|
-
};
|
|
19
|
-
var MissingPageInfo = class extends Error {
|
|
20
|
-
constructor(response) {
|
|
21
|
-
super(
|
|
22
|
-
`No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify(
|
|
23
|
-
response,
|
|
24
|
-
null,
|
|
25
|
-
2
|
|
26
|
-
)}`
|
|
27
|
-
);
|
|
28
|
-
this.response = response;
|
|
29
|
-
if (Error.captureStackTrace) {
|
|
30
|
-
Error.captureStackTrace(this, this.constructor);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
name = "MissingPageInfo";
|
|
34
|
-
};
|
|
35
|
-
var isObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
|
|
36
|
-
function findPaginatedResourcePath(responseData) {
|
|
37
|
-
const paginatedResourcePath = deepFindPathToProperty(
|
|
38
|
-
responseData,
|
|
39
|
-
"pageInfo"
|
|
40
|
-
);
|
|
41
|
-
if (paginatedResourcePath.length === 0) {
|
|
42
|
-
throw new MissingPageInfo(responseData);
|
|
43
|
-
}
|
|
44
|
-
return paginatedResourcePath;
|
|
45
|
-
}
|
|
46
|
-
var deepFindPathToProperty = (object, searchProp, path = []) => {
|
|
47
|
-
for (const key of Object.keys(object)) {
|
|
48
|
-
const currentPath = [...path, key];
|
|
49
|
-
const currentValue = object[key];
|
|
50
|
-
if (isObject(currentValue)) {
|
|
51
|
-
if (currentValue.hasOwnProperty(searchProp)) {
|
|
52
|
-
return currentPath;
|
|
53
|
-
}
|
|
54
|
-
const result = deepFindPathToProperty(
|
|
55
|
-
currentValue,
|
|
56
|
-
searchProp,
|
|
57
|
-
currentPath
|
|
58
|
-
);
|
|
59
|
-
if (result.length > 0) {
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return [];
|
|
65
|
-
};
|
|
66
|
-
var get = (object, path) => {
|
|
67
|
-
return path.reduce((current, nextProperty) => current[nextProperty], object);
|
|
68
|
-
};
|
|
69
|
-
var set = (object, path, mutator) => {
|
|
70
|
-
const lastProperty = path[path.length - 1];
|
|
71
|
-
const parentPath = [...path].slice(0, -1);
|
|
72
|
-
const parent = get(object, parentPath);
|
|
73
|
-
if (typeof mutator === "function") {
|
|
74
|
-
parent[lastProperty] = mutator(parent[lastProperty]);
|
|
75
|
-
} else {
|
|
76
|
-
parent[lastProperty] = mutator;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var extractPageInfos = (responseData) => {
|
|
80
|
-
const pageInfoPath = findPaginatedResourcePath(responseData);
|
|
81
|
-
return {
|
|
82
|
-
pathInQuery: pageInfoPath,
|
|
83
|
-
pageInfo: get(responseData, [...pageInfoPath, "pageInfo"])
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
var isForwardSearch = (givenPageInfo) => {
|
|
87
|
-
return givenPageInfo.hasOwnProperty("hasNextPage");
|
|
88
|
-
};
|
|
89
|
-
var getCursorFrom = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.endCursor : pageInfo.startCursor;
|
|
90
|
-
var hasAnotherPage = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.hasNextPage : pageInfo.hasPreviousPage;
|
|
91
|
-
var createIterator = (octokit) => {
|
|
92
|
-
return (query, initialParameters = {}) => {
|
|
93
|
-
let nextPageExists = true;
|
|
94
|
-
let parameters = { ...initialParameters };
|
|
95
|
-
return {
|
|
96
|
-
[Symbol.asyncIterator]: () => ({
|
|
97
|
-
async next() {
|
|
98
|
-
if (!nextPageExists) return { done: true, value: {} };
|
|
99
|
-
const response = await octokit.graphql(
|
|
100
|
-
query,
|
|
101
|
-
parameters
|
|
102
|
-
);
|
|
103
|
-
const pageInfoContext = extractPageInfos(response);
|
|
104
|
-
const nextCursorValue = getCursorFrom(pageInfoContext.pageInfo);
|
|
105
|
-
nextPageExists = hasAnotherPage(pageInfoContext.pageInfo);
|
|
106
|
-
if (nextPageExists && nextCursorValue === parameters.cursor) {
|
|
107
|
-
throw new MissingCursorChange(pageInfoContext, nextCursorValue);
|
|
108
|
-
}
|
|
109
|
-
parameters = {
|
|
110
|
-
...parameters,
|
|
111
|
-
cursor: nextCursorValue
|
|
112
|
-
};
|
|
113
|
-
return { done: false, value: response };
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
var mergeResponses = (response1, response2) => {
|
|
120
|
-
if (Object.keys(response1).length === 0) {
|
|
121
|
-
return Object.assign(response1, response2);
|
|
122
|
-
}
|
|
123
|
-
const path = findPaginatedResourcePath(response1);
|
|
124
|
-
const nodesPath = [...path, "nodes"];
|
|
125
|
-
const newNodes = get(response2, nodesPath);
|
|
126
|
-
if (newNodes) {
|
|
127
|
-
set(response1, nodesPath, (values) => {
|
|
128
|
-
return [...values, ...newNodes];
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
const edgesPath = [...path, "edges"];
|
|
132
|
-
const newEdges = get(response2, edgesPath);
|
|
133
|
-
if (newEdges) {
|
|
134
|
-
set(response1, edgesPath, (values) => {
|
|
135
|
-
return [...values, ...newEdges];
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
const pageInfoPath = [...path, "pageInfo"];
|
|
139
|
-
set(response1, pageInfoPath, get(response2, pageInfoPath));
|
|
140
|
-
return response1;
|
|
141
|
-
};
|
|
142
|
-
var createPaginate = (octokit) => {
|
|
143
|
-
const iterator = createIterator(octokit);
|
|
144
|
-
return async (query, initialParameters = {}) => {
|
|
145
|
-
let mergedResponse = {};
|
|
146
|
-
for await (const response of iterator(
|
|
147
|
-
query,
|
|
148
|
-
initialParameters
|
|
149
|
-
)) {
|
|
150
|
-
mergedResponse = mergeResponses(mergedResponse, response);
|
|
151
|
-
}
|
|
152
|
-
return mergedResponse;
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
function paginateGraphQL(octokit) {
|
|
156
|
-
return {
|
|
157
|
-
graphql: Object.assign(octokit.graphql, {
|
|
158
|
-
paginate: Object.assign(createPaginate(octokit), {
|
|
159
|
-
iterator: createIterator(octokit)
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/octokit.ts
|
|
3
|
+
import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
|
|
166
4
|
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
|
167
5
|
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
|
168
6
|
import { retry } from "@octokit/plugin-retry";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubiquity-os/plugin-sdk",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "SDK for plugin support.",
|
|
5
5
|
"author": "Ubiquity DAO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -110,8 +110,11 @@
|
|
|
110
110
|
"open-source"
|
|
111
111
|
],
|
|
112
112
|
"dependencies": {
|
|
113
|
+
"@actions/core": "^1.11.1",
|
|
114
|
+
"@actions/github": "^6.0.0",
|
|
113
115
|
"@octokit/auth-app": "^7.1.1",
|
|
114
116
|
"@octokit/core": "^6.1.3",
|
|
117
|
+
"@octokit/plugin-paginate-graphql": "^6.0.0",
|
|
115
118
|
"@octokit/plugin-paginate-rest": "^11.4.2",
|
|
116
119
|
"@octokit/plugin-request-log": "^5.3.1",
|
|
117
120
|
"@octokit/plugin-rest-endpoint-methods": "^13.2.1",
|
|
@@ -122,6 +125,9 @@
|
|
|
122
125
|
"@octokit/webhooks": "^13.4.1",
|
|
123
126
|
"@octokit/webhooks-types": "^7.6.1",
|
|
124
127
|
"@sinclair/typebox": "^0.33.17",
|
|
128
|
+
"@ubiquity-os/ubiquity-os-logger": "^1.4.0",
|
|
129
|
+
"hono": "^4.10.7",
|
|
130
|
+
"js-yaml": "^4.1.1",
|
|
125
131
|
"libsodium-wrappers": "^0.7.15",
|
|
126
132
|
"openai": "^4.70.2",
|
|
127
133
|
"pino": "^9.7.0",
|
|
@@ -137,13 +143,16 @@
|
|
|
137
143
|
"@cspell/dict-typescript": "^3.1.6",
|
|
138
144
|
"@eslint/js": "^9.17.0",
|
|
139
145
|
"@jest/globals": "^29.7.0",
|
|
146
|
+
"@mswjs/data": "^0.16.2",
|
|
140
147
|
"@swc/core": "^1.10.1",
|
|
141
148
|
"@swc/jest": "^0.2.36",
|
|
142
149
|
"@types/jest": "^29.5.14",
|
|
150
|
+
"@types/js-yaml": "^4.0.9",
|
|
143
151
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
144
152
|
"@types/node": "^22.10.1",
|
|
145
153
|
"@ubiquity-os/eslint-plugin-no-empty-strings": "^1.0.3",
|
|
146
154
|
"cspell": "^8.17.0",
|
|
155
|
+
"dotenv": "^16.4.5",
|
|
147
156
|
"esbuild": "^0.24.0",
|
|
148
157
|
"eslint": "^9.17.0",
|
|
149
158
|
"eslint-config-prettier": "^9.1.2",
|
|
@@ -159,6 +168,7 @@
|
|
|
159
168
|
"msw": "^2.12.2",
|
|
160
169
|
"npm-run-all": "^4.1.5",
|
|
161
170
|
"prettier": "^3.6.2",
|
|
171
|
+
"rimraf": "^6.1.2",
|
|
162
172
|
"ts-node": "^10.9.2",
|
|
163
173
|
"tsup": "^8.5.1",
|
|
164
174
|
"typescript": "^5.9.3",
|