@ubiquity-os/plugin-sdk 3.5.5 → 3.6.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.
- package/README.md +35 -93
- package/dist/configuration.d.mts +2 -2
- package/dist/configuration.d.ts +2 -2
- package/dist/configuration.js +2633 -13
- package/dist/configuration.mjs +2633 -3
- package/dist/{context-DOUnUNNN.d.ts → context-BbEmsEct.d.ts} +2 -0
- package/dist/{context-3Ck9sBZI.d.mts → context-sqbr2o6i.d.mts} +2 -0
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2242 -94
- package/dist/index.mjs +2237 -90
- package/dist/llm.d.mts +23 -0
- package/dist/llm.d.ts +23 -0
- package/dist/llm.js +109 -0
- package/dist/llm.mjs +84 -0
- package/dist/octokit.d.mts +2 -2
- package/dist/octokit.d.ts +2 -2
- package/dist/octokit.js +164 -2
- package/dist/octokit.mjs +163 -1
- package/dist/signature.d.mts +1 -0
- package/dist/signature.d.ts +1 -0
- package/dist/signature.js +1 -0
- package/dist/signature.mjs +1 -0
- package/package.json +51 -40
package/dist/llm.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { C as Context } from './context-sqbr2o6i.mjs';
|
|
2
|
+
import { PluginInput } from './signature.mjs';
|
|
3
|
+
import { ChatCompletionMessageParam, ChatCompletionCreateParamsNonStreaming, ChatCompletion, ChatCompletionChunk } from 'openai/resources/chat/completions';
|
|
4
|
+
import '@octokit/webhooks';
|
|
5
|
+
import '@ubiquity-os/ubiquity-os-logger';
|
|
6
|
+
import '@octokit/plugin-rest-endpoint-methods';
|
|
7
|
+
import './octokit.mjs';
|
|
8
|
+
import '@octokit/core/types';
|
|
9
|
+
import '@octokit/plugin-paginate-graphql';
|
|
10
|
+
import '@octokit/plugin-paginate-rest';
|
|
11
|
+
import '@octokit/request-error';
|
|
12
|
+
import '@octokit/core';
|
|
13
|
+
import '@sinclair/typebox';
|
|
14
|
+
|
|
15
|
+
type LlmCallOptions = {
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
stream?: boolean;
|
|
19
|
+
messages: ChatCompletionMessageParam[];
|
|
20
|
+
} & Partial<Omit<ChatCompletionCreateParamsNonStreaming, "model" | "messages" | "stream">>;
|
|
21
|
+
declare function callLlm(options: LlmCallOptions, input: PluginInput | Context): Promise<ChatCompletion | AsyncIterable<ChatCompletionChunk>>;
|
|
22
|
+
|
|
23
|
+
export { type LlmCallOptions, callLlm };
|
package/dist/llm.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { C as Context } from './context-BbEmsEct.js';
|
|
2
|
+
import { PluginInput } from './signature.js';
|
|
3
|
+
import { ChatCompletionMessageParam, ChatCompletionCreateParamsNonStreaming, ChatCompletion, ChatCompletionChunk } from 'openai/resources/chat/completions';
|
|
4
|
+
import '@octokit/webhooks';
|
|
5
|
+
import '@ubiquity-os/ubiquity-os-logger';
|
|
6
|
+
import '@octokit/plugin-rest-endpoint-methods';
|
|
7
|
+
import './octokit.js';
|
|
8
|
+
import '@octokit/core/types';
|
|
9
|
+
import '@octokit/plugin-paginate-graphql';
|
|
10
|
+
import '@octokit/plugin-paginate-rest';
|
|
11
|
+
import '@octokit/request-error';
|
|
12
|
+
import '@octokit/core';
|
|
13
|
+
import '@sinclair/typebox';
|
|
14
|
+
|
|
15
|
+
type LlmCallOptions = {
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
stream?: boolean;
|
|
19
|
+
messages: ChatCompletionMessageParam[];
|
|
20
|
+
} & Partial<Omit<ChatCompletionCreateParamsNonStreaming, "model" | "messages" | "stream">>;
|
|
21
|
+
declare function callLlm(options: LlmCallOptions, input: PluginInput | Context): Promise<ChatCompletion | AsyncIterable<ChatCompletionChunk>>;
|
|
22
|
+
|
|
23
|
+
export { type LlmCallOptions, callLlm };
|
package/dist/llm.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/llm/index.ts
|
|
21
|
+
var llm_exports = {};
|
|
22
|
+
__export(llm_exports, {
|
|
23
|
+
callLlm: () => callLlm
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(llm_exports);
|
|
26
|
+
function normalizeBaseUrl(baseUrl) {
|
|
27
|
+
return baseUrl.trim().replace(/\/+$/, "");
|
|
28
|
+
}
|
|
29
|
+
function getEnvString(name) {
|
|
30
|
+
if (typeof process === "undefined" || !process?.env) return "";
|
|
31
|
+
return String(process.env[name] ?? "").trim();
|
|
32
|
+
}
|
|
33
|
+
function getAiBaseUrl(options) {
|
|
34
|
+
if (typeof options.baseUrl === "string" && options.baseUrl.trim()) {
|
|
35
|
+
return normalizeBaseUrl(options.baseUrl);
|
|
36
|
+
}
|
|
37
|
+
const envBaseUrl = getEnvString("UBQ_AI_BASE_URL") || getEnvString("UBQ_AI_URL");
|
|
38
|
+
if (envBaseUrl) return normalizeBaseUrl(envBaseUrl);
|
|
39
|
+
return "https://ai.ubq.fi";
|
|
40
|
+
}
|
|
41
|
+
async function callLlm(options, input) {
|
|
42
|
+
const authToken = input?.authToken ?? "";
|
|
43
|
+
const ubiquityKernelToken = input?.ubiquityKernelToken ?? "";
|
|
44
|
+
const payload = input?.payload;
|
|
45
|
+
const owner = payload?.repository?.owner?.login ?? "";
|
|
46
|
+
const repo = payload?.repository?.name ?? "";
|
|
47
|
+
const installationId = payload?.installation?.id;
|
|
48
|
+
if (!authToken) throw new Error("Missing authToken in inputs");
|
|
49
|
+
const requiresKernelToken = authToken.trim().startsWith("gh");
|
|
50
|
+
if (requiresKernelToken && !ubiquityKernelToken) {
|
|
51
|
+
throw new Error("Missing ubiquityKernelToken in inputs (kernel attestation is required for GitHub auth)");
|
|
52
|
+
}
|
|
53
|
+
const url = `${getAiBaseUrl(options)}/v1/chat/completions`;
|
|
54
|
+
const { baseUrl: _baseUrl, model, stream, messages, ...rest } = options;
|
|
55
|
+
const body = JSON.stringify({
|
|
56
|
+
...rest,
|
|
57
|
+
...model ? { model } : {},
|
|
58
|
+
messages,
|
|
59
|
+
stream: stream ?? false
|
|
60
|
+
});
|
|
61
|
+
const headers = {
|
|
62
|
+
Authorization: `Bearer ${authToken}`,
|
|
63
|
+
"Content-Type": "application/json"
|
|
64
|
+
};
|
|
65
|
+
if (owner) headers["X-GitHub-Owner"] = owner;
|
|
66
|
+
if (repo) headers["X-GitHub-Repo"] = repo;
|
|
67
|
+
if (typeof installationId === "number" && Number.isFinite(installationId)) {
|
|
68
|
+
headers["X-GitHub-Installation-Id"] = String(installationId);
|
|
69
|
+
}
|
|
70
|
+
if (ubiquityKernelToken) {
|
|
71
|
+
headers["X-Ubiquity-Kernel-Token"] = ubiquityKernelToken;
|
|
72
|
+
}
|
|
73
|
+
const response = await fetch(url, { method: "POST", headers, body });
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
const err = await response.text();
|
|
76
|
+
throw new Error(`LLM API error: ${response.status} - ${err}`);
|
|
77
|
+
}
|
|
78
|
+
if (options.stream) {
|
|
79
|
+
return parseSseStream(response.body);
|
|
80
|
+
}
|
|
81
|
+
return response.json();
|
|
82
|
+
}
|
|
83
|
+
async function* parseSseStream(body) {
|
|
84
|
+
const reader = body.getReader();
|
|
85
|
+
const decoder = new TextDecoder();
|
|
86
|
+
let buffer = "";
|
|
87
|
+
try {
|
|
88
|
+
while (true) {
|
|
89
|
+
const { value, done } = await reader.read();
|
|
90
|
+
if (done) break;
|
|
91
|
+
buffer += decoder.decode(value, { stream: true });
|
|
92
|
+
const events = buffer.split("\n\n");
|
|
93
|
+
buffer = events.pop() || "";
|
|
94
|
+
for (const event of events) {
|
|
95
|
+
if (event.startsWith("data: ")) {
|
|
96
|
+
const data = event.slice(6);
|
|
97
|
+
if (data === "[DONE]") return;
|
|
98
|
+
yield JSON.parse(data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
reader.releaseLock();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
callLlm
|
|
109
|
+
});
|
package/dist/llm.mjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/llm/index.ts
|
|
2
|
+
function normalizeBaseUrl(baseUrl) {
|
|
3
|
+
return baseUrl.trim().replace(/\/+$/, "");
|
|
4
|
+
}
|
|
5
|
+
function getEnvString(name) {
|
|
6
|
+
if (typeof process === "undefined" || !process?.env) return "";
|
|
7
|
+
return String(process.env[name] ?? "").trim();
|
|
8
|
+
}
|
|
9
|
+
function getAiBaseUrl(options) {
|
|
10
|
+
if (typeof options.baseUrl === "string" && options.baseUrl.trim()) {
|
|
11
|
+
return normalizeBaseUrl(options.baseUrl);
|
|
12
|
+
}
|
|
13
|
+
const envBaseUrl = getEnvString("UBQ_AI_BASE_URL") || getEnvString("UBQ_AI_URL");
|
|
14
|
+
if (envBaseUrl) return normalizeBaseUrl(envBaseUrl);
|
|
15
|
+
return "https://ai.ubq.fi";
|
|
16
|
+
}
|
|
17
|
+
async function callLlm(options, input) {
|
|
18
|
+
const authToken = input?.authToken ?? "";
|
|
19
|
+
const ubiquityKernelToken = input?.ubiquityKernelToken ?? "";
|
|
20
|
+
const payload = input?.payload;
|
|
21
|
+
const owner = payload?.repository?.owner?.login ?? "";
|
|
22
|
+
const repo = payload?.repository?.name ?? "";
|
|
23
|
+
const installationId = payload?.installation?.id;
|
|
24
|
+
if (!authToken) throw new Error("Missing authToken in inputs");
|
|
25
|
+
const requiresKernelToken = authToken.trim().startsWith("gh");
|
|
26
|
+
if (requiresKernelToken && !ubiquityKernelToken) {
|
|
27
|
+
throw new Error("Missing ubiquityKernelToken in inputs (kernel attestation is required for GitHub auth)");
|
|
28
|
+
}
|
|
29
|
+
const url = `${getAiBaseUrl(options)}/v1/chat/completions`;
|
|
30
|
+
const { baseUrl: _baseUrl, model, stream, messages, ...rest } = options;
|
|
31
|
+
const body = JSON.stringify({
|
|
32
|
+
...rest,
|
|
33
|
+
...model ? { model } : {},
|
|
34
|
+
messages,
|
|
35
|
+
stream: stream ?? false
|
|
36
|
+
});
|
|
37
|
+
const headers = {
|
|
38
|
+
Authorization: `Bearer ${authToken}`,
|
|
39
|
+
"Content-Type": "application/json"
|
|
40
|
+
};
|
|
41
|
+
if (owner) headers["X-GitHub-Owner"] = owner;
|
|
42
|
+
if (repo) headers["X-GitHub-Repo"] = repo;
|
|
43
|
+
if (typeof installationId === "number" && Number.isFinite(installationId)) {
|
|
44
|
+
headers["X-GitHub-Installation-Id"] = String(installationId);
|
|
45
|
+
}
|
|
46
|
+
if (ubiquityKernelToken) {
|
|
47
|
+
headers["X-Ubiquity-Kernel-Token"] = ubiquityKernelToken;
|
|
48
|
+
}
|
|
49
|
+
const response = await fetch(url, { method: "POST", headers, body });
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const err = await response.text();
|
|
52
|
+
throw new Error(`LLM API error: ${response.status} - ${err}`);
|
|
53
|
+
}
|
|
54
|
+
if (options.stream) {
|
|
55
|
+
return parseSseStream(response.body);
|
|
56
|
+
}
|
|
57
|
+
return response.json();
|
|
58
|
+
}
|
|
59
|
+
async function* parseSseStream(body) {
|
|
60
|
+
const reader = body.getReader();
|
|
61
|
+
const decoder = new TextDecoder();
|
|
62
|
+
let buffer = "";
|
|
63
|
+
try {
|
|
64
|
+
while (true) {
|
|
65
|
+
const { value, done } = await reader.read();
|
|
66
|
+
if (done) break;
|
|
67
|
+
buffer += decoder.decode(value, { stream: true });
|
|
68
|
+
const events = buffer.split("\n\n");
|
|
69
|
+
buffer = events.pop() || "";
|
|
70
|
+
for (const event of events) {
|
|
71
|
+
if (event.startsWith("data: ")) {
|
|
72
|
+
const data = event.slice(6);
|
|
73
|
+
if (data === "[DONE]") return;
|
|
74
|
+
yield JSON.parse(data);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} finally {
|
|
79
|
+
reader.releaseLock();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
callLlm
|
|
84
|
+
};
|
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_request_error from '@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_request_error.RequestError, retries: number, retryAfter: number) => _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_request_error from '@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_request_error.RequestError, retries: number, retryAfter: number) => _octokit_request_error.RequestError;
|
|
12
12
|
};
|
|
13
13
|
} & {
|
|
14
14
|
paginate: _octokit_plugin_paginate_rest.PaginateInterface;
|
package/dist/octokit.js
CHANGED
|
@@ -24,7 +24,169 @@ __export(octokit_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(octokit_exports);
|
|
26
26
|
var import_core = require("@octokit/core");
|
|
27
|
-
|
|
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
|
|
28
190
|
var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
|
|
29
191
|
var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
|
|
30
192
|
var import_plugin_retry = require("@octokit/plugin-retry");
|
|
@@ -45,7 +207,7 @@ var defaultOptions = {
|
|
|
45
207
|
}
|
|
46
208
|
}
|
|
47
209
|
};
|
|
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,
|
|
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) => {
|
|
49
211
|
return { ...defaultOptions, ...instanceOptions };
|
|
50
212
|
});
|
|
51
213
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/octokit.mjs
CHANGED
|
@@ -1,6 +1,168 @@
|
|
|
1
1
|
// src/octokit.ts
|
|
2
2
|
import { Octokit } from "@octokit/core";
|
|
3
|
-
|
|
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
|
|
4
166
|
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
|
5
167
|
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
|
6
168
|
import { retry } from "@octokit/plugin-retry";
|
package/dist/signature.d.mts
CHANGED
package/dist/signature.d.ts
CHANGED
package/dist/signature.js
CHANGED
|
@@ -79,6 +79,7 @@ async function verifySignature(publicKeyPem, inputs, signature) {
|
|
|
79
79
|
eventPayload: inputs.eventPayload,
|
|
80
80
|
settings: inputs.settings,
|
|
81
81
|
authToken: inputs.authToken,
|
|
82
|
+
ubiquityKernelToken: inputs.ubiquityKernelToken,
|
|
82
83
|
ref: inputs.ref,
|
|
83
84
|
command: inputs.command
|
|
84
85
|
};
|
package/dist/signature.mjs
CHANGED
|
@@ -51,6 +51,7 @@ async function verifySignature(publicKeyPem, inputs, signature) {
|
|
|
51
51
|
eventPayload: inputs.eventPayload,
|
|
52
52
|
settings: inputs.settings,
|
|
53
53
|
authToken: inputs.authToken,
|
|
54
|
+
ubiquityKernelToken: inputs.ubiquityKernelToken,
|
|
54
55
|
ref: inputs.ref,
|
|
55
56
|
command: inputs.command
|
|
56
57
|
};
|