@ubiquity-os/plugin-sdk 3.12.1 → 3.12.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/configuration.js +4 -4
- package/dist/configuration.mjs +4 -4
- package/dist/index.js +65 -1
- package/dist/index.mjs +65 -1
- package/package.json +1 -1
package/dist/configuration.js
CHANGED
|
@@ -465,7 +465,7 @@ var ConfigurationHandler = class {
|
|
|
465
465
|
return { config: targetRepoConfiguration, imports, errors, rawData };
|
|
466
466
|
}
|
|
467
467
|
_decodeConfiguration(location, config) {
|
|
468
|
-
this._logger.
|
|
468
|
+
this._logger.debug("Decoding configuration", { owner: location.owner, repository: location.repo });
|
|
469
469
|
try {
|
|
470
470
|
const configSchemaWithDefaults = import_value.Value.Default(configSchema, config);
|
|
471
471
|
const errors = import_value.Value.Errors(configSchema, configSchemaWithDefaults);
|
|
@@ -560,7 +560,7 @@ var ConfigurationHandler = class {
|
|
|
560
560
|
...ref ? { ref } : {},
|
|
561
561
|
mediaType: { format: "raw" }
|
|
562
562
|
});
|
|
563
|
-
|
|
563
|
+
this._logger.debug("Configuration file found", { owner, repository, filePath, rateLimitRemaining: headers?.["x-ratelimit-remaining"] });
|
|
564
564
|
return data;
|
|
565
565
|
} catch (err) {
|
|
566
566
|
this._handleDownloadError(err, { owner, repository, filePath });
|
|
@@ -584,11 +584,11 @@ var ConfigurationHandler = class {
|
|
|
584
584
|
* Parse the raw YAML content and returns the loaded YAML, or errors if any.
|
|
585
585
|
*/
|
|
586
586
|
parseYaml(data) {
|
|
587
|
-
this._logger.
|
|
587
|
+
this._logger.debug("Will attempt to parse YAML data");
|
|
588
588
|
try {
|
|
589
589
|
if (data) {
|
|
590
590
|
const parsedData = import_js_yaml.default.load(data);
|
|
591
|
-
|
|
591
|
+
this._logger.debug("Parsed yaml data successfully");
|
|
592
592
|
return { yaml: parsedData ?? null, errors: null };
|
|
593
593
|
}
|
|
594
594
|
} catch (error) {
|
package/dist/configuration.mjs
CHANGED
|
@@ -426,7 +426,7 @@ var ConfigurationHandler = class {
|
|
|
426
426
|
return { config: targetRepoConfiguration, imports, errors, rawData };
|
|
427
427
|
}
|
|
428
428
|
_decodeConfiguration(location, config) {
|
|
429
|
-
this._logger.
|
|
429
|
+
this._logger.debug("Decoding configuration", { owner: location.owner, repository: location.repo });
|
|
430
430
|
try {
|
|
431
431
|
const configSchemaWithDefaults = Value.Default(configSchema, config);
|
|
432
432
|
const errors = Value.Errors(configSchema, configSchemaWithDefaults);
|
|
@@ -521,7 +521,7 @@ var ConfigurationHandler = class {
|
|
|
521
521
|
...ref ? { ref } : {},
|
|
522
522
|
mediaType: { format: "raw" }
|
|
523
523
|
});
|
|
524
|
-
|
|
524
|
+
this._logger.debug("Configuration file found", { owner, repository, filePath, rateLimitRemaining: headers?.["x-ratelimit-remaining"] });
|
|
525
525
|
return data;
|
|
526
526
|
} catch (err) {
|
|
527
527
|
this._handleDownloadError(err, { owner, repository, filePath });
|
|
@@ -545,11 +545,11 @@ var ConfigurationHandler = class {
|
|
|
545
545
|
* Parse the raw YAML content and returns the loaded YAML, or errors if any.
|
|
546
546
|
*/
|
|
547
547
|
parseYaml(data) {
|
|
548
|
-
this._logger.
|
|
548
|
+
this._logger.debug("Will attempt to parse YAML data");
|
|
549
549
|
try {
|
|
550
550
|
if (data) {
|
|
551
551
|
const parsedData = YAML.load(data);
|
|
552
|
-
|
|
552
|
+
this._logger.debug("Parsed yaml data successfully");
|
|
553
553
|
return { yaml: parsedData ?? null, errors: null };
|
|
554
554
|
}
|
|
555
555
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -853,6 +853,70 @@ var import_ubiquity_os_logger4 = require("@ubiquity-os/ubiquity-os-logger");
|
|
|
853
853
|
var import_hono = require("hono");
|
|
854
854
|
var import_adapter2 = require("hono/adapter");
|
|
855
855
|
var import_http_exception = require("hono/http-exception");
|
|
856
|
+
|
|
857
|
+
// src/helpers/runtime-manifest.ts
|
|
858
|
+
var EMPTY_VALUE = String();
|
|
859
|
+
function readRuntimeTimeline() {
|
|
860
|
+
if (typeof globalThis.Deno !== "undefined" && typeof globalThis.Deno?.env?.get === "function") {
|
|
861
|
+
const denoTimeline = globalThis.Deno.env.get("DENO_TIMELINE");
|
|
862
|
+
if (typeof denoTimeline === "string" && denoTimeline.trim()) {
|
|
863
|
+
return denoTimeline.trim();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if (typeof process !== "undefined") {
|
|
867
|
+
const processTimeline = process.env.DENO_TIMELINE;
|
|
868
|
+
if (typeof processTimeline === "string" && processTimeline.trim()) {
|
|
869
|
+
return processTimeline.trim();
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return EMPTY_VALUE;
|
|
873
|
+
}
|
|
874
|
+
function resolveRuntimeRefName(timeline) {
|
|
875
|
+
if (!timeline) {
|
|
876
|
+
return EMPTY_VALUE;
|
|
877
|
+
}
|
|
878
|
+
if (timeline === "production") {
|
|
879
|
+
return "main";
|
|
880
|
+
}
|
|
881
|
+
if (timeline.startsWith("git-branch/")) {
|
|
882
|
+
return timeline.slice("git-branch/".length);
|
|
883
|
+
}
|
|
884
|
+
if (timeline.startsWith("preview/")) {
|
|
885
|
+
return timeline.slice("preview/".length);
|
|
886
|
+
}
|
|
887
|
+
return EMPTY_VALUE;
|
|
888
|
+
}
|
|
889
|
+
function overrideShortName(shortName, refName) {
|
|
890
|
+
if (!shortName || !refName) {
|
|
891
|
+
return shortName;
|
|
892
|
+
}
|
|
893
|
+
const separatorIndex = shortName.lastIndexOf("@");
|
|
894
|
+
const repository = separatorIndex === -1 ? shortName : shortName.slice(0, separatorIndex);
|
|
895
|
+
if (!repository) {
|
|
896
|
+
return shortName;
|
|
897
|
+
}
|
|
898
|
+
return `${repository}@${refName}`;
|
|
899
|
+
}
|
|
900
|
+
function resolveRuntimeManifest(manifest, requestUrl) {
|
|
901
|
+
const timeline = readRuntimeTimeline();
|
|
902
|
+
const refName = resolveRuntimeRefName(timeline);
|
|
903
|
+
if (!refName) {
|
|
904
|
+
return manifest;
|
|
905
|
+
}
|
|
906
|
+
let homepageUrl;
|
|
907
|
+
try {
|
|
908
|
+
homepageUrl = new URL(requestUrl).origin;
|
|
909
|
+
} catch {
|
|
910
|
+
homepageUrl = void 0;
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
...manifest,
|
|
914
|
+
short_name: overrideShortName(manifest.short_name, refName),
|
|
915
|
+
...homepageUrl ? { homepage_url: homepageUrl } : {}
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/server.ts
|
|
856
920
|
async function handleError2(context, pluginOptions, error) {
|
|
857
921
|
console.error(error);
|
|
858
922
|
const loggerError = transformError(context, error);
|
|
@@ -865,7 +929,7 @@ function createPlugin(handler, manifest, options) {
|
|
|
865
929
|
const pluginOptions = getPluginOptions(options);
|
|
866
930
|
const app = new import_hono.Hono();
|
|
867
931
|
app.get("/manifest.json", (ctx) => {
|
|
868
|
-
return ctx.json(manifest);
|
|
932
|
+
return ctx.json(resolveRuntimeManifest(manifest, ctx.req.url));
|
|
869
933
|
});
|
|
870
934
|
app.post("/", async function appPost(ctx) {
|
|
871
935
|
if (ctx.req.header("content-type") !== "application/json") {
|
package/dist/index.mjs
CHANGED
|
@@ -812,6 +812,70 @@ import { Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
|
|
|
812
812
|
import { Hono } from "hono";
|
|
813
813
|
import { env as honoEnv } from "hono/adapter";
|
|
814
814
|
import { HTTPException } from "hono/http-exception";
|
|
815
|
+
|
|
816
|
+
// src/helpers/runtime-manifest.ts
|
|
817
|
+
var EMPTY_VALUE = String();
|
|
818
|
+
function readRuntimeTimeline() {
|
|
819
|
+
if (typeof globalThis.Deno !== "undefined" && typeof globalThis.Deno?.env?.get === "function") {
|
|
820
|
+
const denoTimeline = globalThis.Deno.env.get("DENO_TIMELINE");
|
|
821
|
+
if (typeof denoTimeline === "string" && denoTimeline.trim()) {
|
|
822
|
+
return denoTimeline.trim();
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
if (typeof process !== "undefined") {
|
|
826
|
+
const processTimeline = process.env.DENO_TIMELINE;
|
|
827
|
+
if (typeof processTimeline === "string" && processTimeline.trim()) {
|
|
828
|
+
return processTimeline.trim();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return EMPTY_VALUE;
|
|
832
|
+
}
|
|
833
|
+
function resolveRuntimeRefName(timeline) {
|
|
834
|
+
if (!timeline) {
|
|
835
|
+
return EMPTY_VALUE;
|
|
836
|
+
}
|
|
837
|
+
if (timeline === "production") {
|
|
838
|
+
return "main";
|
|
839
|
+
}
|
|
840
|
+
if (timeline.startsWith("git-branch/")) {
|
|
841
|
+
return timeline.slice("git-branch/".length);
|
|
842
|
+
}
|
|
843
|
+
if (timeline.startsWith("preview/")) {
|
|
844
|
+
return timeline.slice("preview/".length);
|
|
845
|
+
}
|
|
846
|
+
return EMPTY_VALUE;
|
|
847
|
+
}
|
|
848
|
+
function overrideShortName(shortName, refName) {
|
|
849
|
+
if (!shortName || !refName) {
|
|
850
|
+
return shortName;
|
|
851
|
+
}
|
|
852
|
+
const separatorIndex = shortName.lastIndexOf("@");
|
|
853
|
+
const repository = separatorIndex === -1 ? shortName : shortName.slice(0, separatorIndex);
|
|
854
|
+
if (!repository) {
|
|
855
|
+
return shortName;
|
|
856
|
+
}
|
|
857
|
+
return `${repository}@${refName}`;
|
|
858
|
+
}
|
|
859
|
+
function resolveRuntimeManifest(manifest, requestUrl) {
|
|
860
|
+
const timeline = readRuntimeTimeline();
|
|
861
|
+
const refName = resolveRuntimeRefName(timeline);
|
|
862
|
+
if (!refName) {
|
|
863
|
+
return manifest;
|
|
864
|
+
}
|
|
865
|
+
let homepageUrl;
|
|
866
|
+
try {
|
|
867
|
+
homepageUrl = new URL(requestUrl).origin;
|
|
868
|
+
} catch {
|
|
869
|
+
homepageUrl = void 0;
|
|
870
|
+
}
|
|
871
|
+
return {
|
|
872
|
+
...manifest,
|
|
873
|
+
short_name: overrideShortName(manifest.short_name, refName),
|
|
874
|
+
...homepageUrl ? { homepage_url: homepageUrl } : {}
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// src/server.ts
|
|
815
879
|
async function handleError2(context, pluginOptions, error) {
|
|
816
880
|
console.error(error);
|
|
817
881
|
const loggerError = transformError(context, error);
|
|
@@ -824,7 +888,7 @@ function createPlugin(handler, manifest, options) {
|
|
|
824
888
|
const pluginOptions = getPluginOptions(options);
|
|
825
889
|
const app = new Hono();
|
|
826
890
|
app.get("/manifest.json", (ctx) => {
|
|
827
|
-
return ctx.json(manifest);
|
|
891
|
+
return ctx.json(resolveRuntimeManifest(manifest, ctx.req.url));
|
|
828
892
|
});
|
|
829
893
|
app.post("/", async function appPost(ctx) {
|
|
830
894
|
if (ctx.req.header("content-type") !== "application/json") {
|