@arch-cadre/vercel-blob-module 0.0.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.
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ "use server";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getBlobConfig = getBlobConfig;
8
+ exports.updateBlobConfig = updateBlobConfig;
9
+ var _server = require("@arch-cadre/modules/server");
10
+ var _cache = require("next/cache");
11
+ async function getBlobConfig() {
12
+ const config = await (0, _server.getModuleConfig)("vercel-blob");
13
+ return config || {
14
+ clientId: ""
15
+ };
16
+ }
17
+ async function updateBlobConfig(config) {
18
+ await (0, _server.updateModuleConfig)("vercel-blob", config);
19
+ (0, _cache.revalidatePath)(`${(0, _server.getKryoPathPrefix)()}/vercel-blob/settings`);
20
+ return {
21
+ success: true
22
+ };
23
+ }
@@ -0,0 +1,7 @@
1
+ export interface BlobConfig {
2
+ clientId: string;
3
+ }
4
+ export declare function getBlobConfig(): Promise<any>;
5
+ export declare function updateBlobConfig(config: BlobConfig): Promise<{
6
+ success: boolean;
7
+ }>;
@@ -0,0 +1,16 @@
1
+ "use server";
2
+ import {
3
+ getKryoPathPrefix,
4
+ getModuleConfig,
5
+ updateModuleConfig
6
+ } from "@arch-cadre/modules/server";
7
+ import { revalidatePath } from "next/cache";
8
+ export async function getBlobConfig() {
9
+ const config = await getModuleConfig("vercel-blob");
10
+ return config || { clientId: "" };
11
+ }
12
+ export async function updateBlobConfig(config) {
13
+ await updateModuleConfig("vercel-blob", config);
14
+ revalidatePath(`${getKryoPathPrefix()}/vercel-blob/settings`);
15
+ return { success: true };
16
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _server = require("@arch-cadre/core/server");
8
+ var _intl = require("@arch-cadre/intl");
9
+ var _manifest = _interopRequireDefault(require("../manifest.json"));
10
+ var _settings = require("./actions/settings.cjs");
11
+ var _vercel = require("./providers/vercel.cjs");
12
+ var _routes = require("./routes.cjs");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const vercelBlobModule = {
15
+ manifest: _manifest.default,
16
+ routes: {
17
+ private: _routes.privateRoutes
18
+ },
19
+ navigation: {
20
+ admin: {
21
+ [(0, _intl.i18n)("System")]: [{
22
+ id: "vercel-blob-settings",
23
+ title: (0, _intl.i18n)("Vercel Blob Storage"),
24
+ url: "/vercel-blob/settings",
25
+ icon: "solar:folder-with-files-bold-duotone"
26
+ }]
27
+ }
28
+ },
29
+ onEnable: async () => {
30
+ _server.filesystemService.registerProvider(new _vercel.VercelBlobProvider());
31
+ const config = await (0, _settings.getBlobConfig)();
32
+ if (process.env.BLOB_READ_WRITE_TOKEN || config.clientId) {
33
+ _server.filesystemService.setDefaultProvider("vercel-blob");
34
+ }
35
+ },
36
+ onDisable: async () => {
37
+ _server.filesystemService.setDefaultProvider("local");
38
+ _server.filesystemService.unregisterProvider("vercel-blob");
39
+ },
40
+ init: async () => {
41
+ _server.filesystemService.registerProvider(new _vercel.VercelBlobProvider());
42
+ const config = await (0, _settings.getBlobConfig)();
43
+ if (process.env.BLOB_READ_WRITE_TOKEN || config.clientId) {
44
+ _server.filesystemService.setDefaultProvider("vercel-blob");
45
+ }
46
+ }
47
+ };
48
+ module.exports = vercelBlobModule;
@@ -0,0 +1,3 @@
1
+ import type { IModule } from "@arch-cadre/modules";
2
+ declare const vercelBlobModule: IModule;
3
+ export default vercelBlobModule;
package/dist/index.mjs ADDED
@@ -0,0 +1,43 @@
1
+ import { filesystemService } from "@arch-cadre/core/server";
2
+ import { i18n } from "@arch-cadre/intl";
3
+ import manifest from "../manifest.json";
4
+ import { getBlobConfig } from "./actions/settings.mjs";
5
+ import { VercelBlobProvider } from "./providers/vercel.mjs";
6
+ import { privateRoutes } from "./routes.mjs";
7
+ const vercelBlobModule = {
8
+ manifest,
9
+ routes: {
10
+ private: privateRoutes
11
+ },
12
+ navigation: {
13
+ admin: {
14
+ [i18n("System")]: [
15
+ {
16
+ id: "vercel-blob-settings",
17
+ title: i18n("Vercel Blob Storage"),
18
+ url: "/vercel-blob/settings",
19
+ icon: "solar:folder-with-files-bold-duotone"
20
+ }
21
+ ]
22
+ }
23
+ },
24
+ onEnable: async () => {
25
+ filesystemService.registerProvider(new VercelBlobProvider());
26
+ const config = await getBlobConfig();
27
+ if (process.env.BLOB_READ_WRITE_TOKEN || config.clientId) {
28
+ filesystemService.setDefaultProvider("vercel-blob");
29
+ }
30
+ },
31
+ onDisable: async () => {
32
+ filesystemService.setDefaultProvider("local");
33
+ filesystemService.unregisterProvider("vercel-blob");
34
+ },
35
+ init: async () => {
36
+ filesystemService.registerProvider(new VercelBlobProvider());
37
+ const config = await getBlobConfig();
38
+ if (process.env.BLOB_READ_WRITE_TOKEN || config.clientId) {
39
+ filesystemService.setDefaultProvider("vercel-blob");
40
+ }
41
+ }
42
+ };
43
+ export default vercelBlobModule;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ "use client";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ module.exports = BlobSettingsPage;
8
+ var _intl = require("@arch-cadre/intl");
9
+ var _ui = require("@arch-cadre/ui");
10
+ var _button = require("@arch-cadre/ui/components/button");
11
+ var _card = require("@arch-cadre/ui/components/card");
12
+ var _input = require("@arch-cadre/ui/components/input");
13
+ var _label = require("@arch-cadre/ui/components/label");
14
+ var _react = _interopRequireWildcard(require("react"));
15
+ var React = _react;
16
+ var _settings = require("../actions/settings.cjs");
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ function BlobSettingsPage() {
20
+ const {
21
+ t
22
+ } = (0, _intl.useTranslation)();
23
+ const [config, setConfig] = (0, _react.useState)({
24
+ clientId: ""
25
+ });
26
+ const [loading, setLoading] = (0, _react.useState)(true);
27
+ (0, _react.useEffect)(() => {
28
+ (0, _settings.getBlobConfig)().then(data => {
29
+ setConfig(data);
30
+ setLoading(false);
31
+ });
32
+ }, []);
33
+ const handleSave = async e => {
34
+ e.preventDefault();
35
+ try {
36
+ await (0, _settings.updateBlobConfig)(config);
37
+ _ui.toast.success(t("Settings saved successfully"));
38
+ } catch (_error) {
39
+ _ui.toast.error(t("Failed to save settings. Please check your configuration and try again."));
40
+ }
41
+ };
42
+ if (loading) return /* @__PURE__ */React.createElement("div", null, t("Vercel Blob loading..."));
43
+ return /* @__PURE__ */React.createElement("div", {
44
+ className: "container mx-auto py-10 max-w-2xl"
45
+ }, /* @__PURE__ */React.createElement(_card.Card, null, /* @__PURE__ */React.createElement(_card.CardHeader, null, /* @__PURE__ */React.createElement("div", null, t("Vercel Blob")), /* @__PURE__ */React.createElement("div", null, t("")), /* @__PURE__ */React.createElement(_card.CardTitle, null, t("Vercel Blob Settings")), /* @__PURE__ */React.createElement(_card.CardDescription, null, t("Configure your Vercel Blob credentials. You can find these in the Vercel Dashboard."))), /* @__PURE__ */React.createElement(_card.CardContent, null, /* @__PURE__ */React.createElement("form", {
46
+ onSubmit: handleSave,
47
+ className: "space-y-4"
48
+ }, /* @__PURE__ */React.createElement("div", {
49
+ className: "space-y-2"
50
+ }, /* @__PURE__ */React.createElement(_label.Label, {
51
+ htmlFor: "clientId"
52
+ }, t("Client ID")), /* @__PURE__ */React.createElement(_input.Input, {
53
+ id: "clientId",
54
+ value: config.clientId,
55
+ onChange: e => setConfig({
56
+ ...config,
57
+ clientId: e.target.value
58
+ }),
59
+ placeholder: "vercel_blob_rw_********************************"
60
+ })), /* @__PURE__ */React.createElement(_button.Button, {
61
+ type: "submit",
62
+ className: "w-full"
63
+ }, t("Save Configuration"))))));
64
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ export default function BlobSettingsPage(): React.JSX.Element;
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { useTranslation } from "@arch-cadre/intl";
3
+ import { toast } from "@arch-cadre/ui";
4
+ import { Button } from "@arch-cadre/ui/components/button";
5
+ import {
6
+ Card,
7
+ CardContent,
8
+ CardDescription,
9
+ CardHeader,
10
+ CardTitle
11
+ } from "@arch-cadre/ui/components/card";
12
+ import { Input } from "@arch-cadre/ui/components/input";
13
+ import { Label } from "@arch-cadre/ui/components/label";
14
+ import * as React from "react";
15
+ import { useEffect, useState } from "react";
16
+ import {
17
+ getBlobConfig,
18
+ updateBlobConfig
19
+ } from "../actions/settings.mjs";
20
+ export default function BlobSettingsPage() {
21
+ const { t } = useTranslation();
22
+ const [config, setConfig] = useState({
23
+ clientId: ""
24
+ });
25
+ const [loading, setLoading] = useState(true);
26
+ useEffect(() => {
27
+ getBlobConfig().then((data) => {
28
+ setConfig(data);
29
+ setLoading(false);
30
+ });
31
+ }, []);
32
+ const handleSave = async (e) => {
33
+ e.preventDefault();
34
+ try {
35
+ await updateBlobConfig(config);
36
+ toast.success(t("Settings saved successfully"));
37
+ } catch (_error) {
38
+ toast.error(
39
+ t(
40
+ "Failed to save settings. Please check your configuration and try again."
41
+ )
42
+ );
43
+ }
44
+ };
45
+ if (loading) return /* @__PURE__ */ React.createElement("div", null, t("Vercel Blob loading..."));
46
+ return /* @__PURE__ */ React.createElement("div", { className: "container mx-auto py-10 max-w-2xl" }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardHeader, null, /* @__PURE__ */ React.createElement("div", null, t("Vercel Blob")), /* @__PURE__ */ React.createElement("div", null, t("")), /* @__PURE__ */ React.createElement(CardTitle, null, t("Vercel Blob Settings")), /* @__PURE__ */ React.createElement(CardDescription, null, t(
47
+ "Configure your Vercel Blob credentials. You can find these in the Vercel Dashboard."
48
+ ))), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement("form", { onSubmit: handleSave, className: "space-y-4" }, /* @__PURE__ */ React.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React.createElement(Label, { htmlFor: "clientId" }, t("Client ID")), /* @__PURE__ */ React.createElement(
49
+ Input,
50
+ {
51
+ id: "clientId",
52
+ value: config.clientId,
53
+ onChange: (e) => setConfig({ ...config, clientId: e.target.value }),
54
+ placeholder: "vercel_blob_rw_********************************"
55
+ }
56
+ )), /* @__PURE__ */ React.createElement(Button, { type: "submit", className: "w-full" }, t("Save Configuration"))))));
57
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VercelBlobProvider = void 0;
7
+ var _blob = require("@vercel/blob");
8
+ var _settings = require("../actions/settings.cjs");
9
+ class VercelBlobProvider {
10
+ id = "vercel-blob";
11
+ name = "Vercel Blob";
12
+ async upload(file) {
13
+ const config = await (0, _settings.getBlobConfig)();
14
+ if (!config.clientId) {
15
+ return {
16
+ error: "Vercel Blob token is not configured"
17
+ };
18
+ }
19
+ try {
20
+ const blob = await (0, _blob.put)(file.name, file, {
21
+ access: "public",
22
+ addRandomSuffix: true,
23
+ token: config.clientId
24
+ });
25
+ return {
26
+ name: file.name,
27
+ url: blob.url,
28
+ type: file.type,
29
+ size: file.size,
30
+ service: "vercel-blob",
31
+ serviceId: blob.pathname
32
+ };
33
+ } catch (error) {
34
+ console.error("[VercelBlob] Upload error:", error);
35
+ return {
36
+ error: error.message || "Failed to upload to Vercel Blob"
37
+ };
38
+ }
39
+ }
40
+ }
41
+ exports.VercelBlobProvider = VercelBlobProvider;
@@ -0,0 +1,6 @@
1
+ import type { IStorageProvider, StorageResult } from "@arch-cadre/core/server";
2
+ export declare class VercelBlobProvider implements IStorageProvider {
3
+ id: string;
4
+ name: string;
5
+ upload(file: File): Promise<StorageResult>;
6
+ }
@@ -0,0 +1,30 @@
1
+ import { put } from "@vercel/blob";
2
+ import { getBlobConfig } from "../actions/settings.mjs";
3
+ export class VercelBlobProvider {
4
+ id = "vercel-blob";
5
+ name = "Vercel Blob";
6
+ async upload(file) {
7
+ const config = await getBlobConfig();
8
+ if (!config.clientId) {
9
+ return { error: "Vercel Blob token is not configured" };
10
+ }
11
+ try {
12
+ const blob = await put(file.name, file, {
13
+ access: "public",
14
+ addRandomSuffix: true,
15
+ token: config.clientId
16
+ });
17
+ return {
18
+ name: file.name,
19
+ url: blob.url,
20
+ type: file.type,
21
+ size: file.size,
22
+ service: "vercel-blob",
23
+ serviceId: blob.pathname
24
+ };
25
+ } catch (error) {
26
+ console.error("[VercelBlob] Upload error:", error);
27
+ return { error: error.message || "Failed to upload to Vercel Blob" };
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.privateRoutes = void 0;
7
+ var _settingsPage = _interopRequireDefault(require("./pages/settings-page.cjs"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const privateRoutes = exports.privateRoutes = [{
10
+ path: "/vercel-blob/settings",
11
+ // Będzie widoczne pod /module/vercel-blob/settings
12
+ component: _settingsPage.default,
13
+ auth: true,
14
+ roles: ["admin"]
15
+ // Tylko użytkownicy z rolą "admin" mogą uzyskać dostęp
16
+ // 'permissions': ['system:vercel-blob-settings'], // Tylko użytkownicy z tą konkretną uprawnieniem mogą uzyskać dostęp
17
+ }];
@@ -0,0 +1,2 @@
1
+ import type { PrivateRouteDefinition } from "@arch-cadre/modules";
2
+ export declare const privateRoutes: PrivateRouteDefinition[];
@@ -0,0 +1,12 @@
1
+ import BlobSettingsPage from "./pages/settings-page.mjs";
2
+ export const privateRoutes = [
3
+ {
4
+ path: "/vercel-blob/settings",
5
+ // Będzie widoczne pod /module/vercel-blob/settings
6
+ component: BlobSettingsPage,
7
+ auth: true,
8
+ roles: ["admin"]
9
+ // Tylko użytkownicy z rolą "admin" mogą uzyskać dostęp
10
+ // 'permissions': ['system:vercel-blob-settings'], // Tylko użytkownicy z tą konkretną uprawnieniem mogą uzyskać dostęp
11
+ }
12
+ ];
@@ -0,0 +1 @@
1
+ {}
package/manifest.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "vercel-blob-module",
3
+ "name": "Vercel Blob Module",
4
+ "version": "0.0.1",
5
+ "description": "Vercel Blob integration to kryo-framework",
6
+ "enabled": true,
7
+ "system": true,
8
+ "dependencies": [],
9
+ "extends": [],
10
+ "isNpm": true
11
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@arch-cadre/vercel-blob-module",
3
+ "version": "0.0.1",
4
+ "description": "Activity module for Kryo framework",
5
+ "type": "module",
6
+ "exports": {
7
+ "./package.json": "./package.json",
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.cjs"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "locales",
17
+ "manifest.json"
18
+ ],
19
+ "scripts": {
20
+ "release": "npm publish --access public --no-git-checks",
21
+ "clean": "rm -rf ./dist",
22
+ "switch:dev": "node scripts/switchToSrc.js",
23
+ "switch:prod": "node scripts/switchToDist.js",
24
+ "dev": "unbuild --stub",
25
+ "build": "unbuild"
26
+ },
27
+ "dependencies": {
28
+ "@vercel/blob": "^2.2.0",
29
+ "@arch-cadre/ui": "^0.0.15",
30
+ "@arch-cadre/modules": "^0.0.15",
31
+ "drizzle-orm": "1.0.0-beta.15-859cf75",
32
+ "pg": "^8.16.3",
33
+ "zod": "^3.24.1"
34
+ },
35
+ "devDependencies": {
36
+ "@arch-cadre/core": "^0.0.15",
37
+ "@types/react": "^19",
38
+ "@types/pg": "^8.16.0",
39
+ "next": "16.1.1",
40
+ "react": "^19.0.0",
41
+ "typescript": "^5.3.3",
42
+ "unbuild": "^3.6.1"
43
+ },
44
+ "peerDependencies": {
45
+ "@arch-cadre/core": "^0.0.15",
46
+ "@arch-cadre/intl": "^0.0.15",
47
+ "@arch-cadre/ui": "^0.0.15",
48
+ "next": ">=13.0.0",
49
+ "react": "^19.0.0"
50
+ },
51
+ "main": "./dist/index.mjs"
52
+ }