@vilio/sample-module 0.0.3 → 0.0.5

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.
@@ -1,7 +1,8 @@
1
1
  export interface SampleConfig {
2
2
  defaultVar: string;
3
3
  }
4
- export declare function getSampleConfig(): Promise<any>;
4
+ export declare function getSampleConfig(): Promise<SampleConfig>;
5
5
  export declare function updateSampleConfig(config: SampleConfig): Promise<{
6
6
  success: boolean;
7
7
  }>;
8
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/actions/settings.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,eAAe,0BAQpC;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY;;GAkB5D"}
@@ -0,0 +1,24 @@
1
+ "use server";
2
+ import { eventBus } from "@vilio/core";
3
+ import { getCurrentSession } from "@vilio/core/server";
4
+ import { getModuleConfig, getVilioPathPrefix, updateModuleConfig, } from "@vilio/modules/server";
5
+ import { revalidatePath } from "next/cache";
6
+ export async function getSampleConfig() {
7
+ const config = await getModuleConfig("sample-module");
8
+ return (config ?? {
9
+ defaultVar: "",
10
+ });
11
+ }
12
+ export async function updateSampleConfig(config) {
13
+ await updateModuleConfig("sample-module", config);
14
+ revalidatePath(`${getVilioPathPrefix()}/sample-module/settings`);
15
+ const { user } = await getCurrentSession();
16
+ await eventBus.publish("activity.create", {
17
+ action: "sample-module.config.updated",
18
+ description: `User updated sample module config`,
19
+ userId: user?.id,
20
+ metadata: config,
21
+ }, "sample-module");
22
+ return { success: true };
23
+ }
24
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/actions/settings.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM5C,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,MAAM,GAAG,MAAM,eAAe,CAAe,eAAe,CAAC,CAAC;IAEpE,OAAO,CACL,MAAM,IAAI;QACR,UAAU,EAAE,EAAE;KACf,CACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAoB;IAC3D,MAAM,kBAAkB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAClD,cAAc,CAAC,GAAG,kBAAkB,EAAE,yBAAyB,CAAC,CAAC;IAEjE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,iBAAiB,EAAE,CAAC;IAE3C,MAAM,QAAQ,CAAC,OAAO,CACpB,iBAAiB,EACjB;QACE,MAAM,EAAE,8BAA8B;QACtC,WAAW,EAAE,mCAAmC;QAChD,MAAM,EAAE,IAAI,EAAE,EAAE;QAChB,QAAQ,EAAE,MAAM;KACjB,EACD,eAAe,CAChB,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { IModule } from "@vilio/modules";
2
2
  declare const module: IModule;
3
3
  export default module;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAO9C,QAAA,MAAM,MAAM,EAAE,OAsCb,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import { i18n } from "@vilio/intl";
2
+ import localesEn from "../locales/en/global.json" with { type: "json" };
3
+ import localesPl from "../locales/pl/global.json" with { type: "json" };
4
+ import manifest from "../manifest.json";
5
+ import { apiRoutes, privateRoutes } from "./routes";
6
+ const module = {
7
+ manifest,
8
+ translations: {
9
+ en: localesEn,
10
+ pl: localesPl,
11
+ },
12
+ onEnable: async () => { },
13
+ onDisable: async () => {
14
+ console.log("[Module:Sample] onDisable: Dropping all tables physically...");
15
+ // try {
16
+ // const tables = ["sample"];
17
+ // for (const table of tables) {
18
+ // await db.execute(sql.raw(`DROP TABLE IF EXISTS ${table} CASCADE`));
19
+ // }
20
+ // } catch (e) {
21
+ // console.error("[Module:Sample] onDisable Error:", e);
22
+ // }
23
+ },
24
+ routes: {
25
+ private: privateRoutes,
26
+ api: apiRoutes,
27
+ },
28
+ navigation: {
29
+ settings: {
30
+ [i18n("General")]: [
31
+ {
32
+ id: "sample-settings",
33
+ title: i18n("Sample Configuration"),
34
+ url: "/settings/sample",
35
+ icon: "solar:box-bold-duotone",
36
+ },
37
+ ],
38
+ },
39
+ },
40
+ };
41
+ export default module;
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,OAAO,SAAS,MAAM,2BAA2B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxE,OAAO,SAAS,MAAM,2BAA2B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxE,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,MAAM,GAAY;IACtB,QAAQ;IACR,YAAY,EAAE;QACZ,EAAE,EAAE,SAAS;QACb,EAAE,EAAE,SAAS;KACd;IAED,QAAQ,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;IAExB,SAAS,EAAE,KAAK,IAAI,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;QAC5E,QAAQ;QACR,6BAA6B;QAC7B,gCAAgC;QAChC,wEAAwE;QACxE,IAAI;QACJ,gBAAgB;QAChB,0DAA0D;QAC1D,IAAI;IACN,CAAC;IAED,MAAM,EAAE;QACN,OAAO,EAAE,aAAa;QACtB,GAAG,EAAE,SAAS;KACf;IAED,UAAU,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;gBACjB;oBACE,EAAE,EAAE,iBAAiB;oBACrB,KAAK,EAAE,IAAI,CAAC,sBAAsB,CAAC;oBACnC,GAAG,EAAE,kBAAkB;oBACvB,IAAI,EAAE,wBAAwB;iBAC/B;aACF;SACF;KACF;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/routes.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { ApiRouteDefinition, PrivateRouteDefinition } from "@vilio/modules";
2
2
  export declare const privateRoutes: PrivateRouteDefinition[];
3
3
  export declare const apiRoutes: ApiRouteDefinition[];
4
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAIxB,eAAO,MAAM,aAAa,EAAE,sBAAsB,EAMjD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,kBAAkB,EAAO,CAAC"}
package/dist/routes.js ADDED
@@ -0,0 +1,10 @@
1
+ import SampleSettingsPage from "./ui/settings-page";
2
+ export const privateRoutes = [
3
+ {
4
+ path: "/settings/sample", // Będzie widoczne pod /settings/sample
5
+ component: SampleSettingsPage,
6
+ auth: true,
7
+ },
8
+ ];
9
+ export const apiRoutes = [];
10
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAKA,OAAO,kBAAkB,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,aAAa,GAA6B;IACrD;QACE,IAAI,EAAE,kBAAkB,EAAE,uCAAuC;QACjE,SAAS,EAAE,kBAAkB;QAC7B,IAAI,EAAE,IAAI;KACX;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAyB,EAAE,CAAC"}
package/dist/schema.d.ts CHANGED
@@ -110,3 +110,4 @@ export declare const sampleSchema: {
110
110
  dialect: "pg";
111
111
  }>;
112
112
  };
113
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAStB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAExB,CAAC"}
package/dist/schema.js ADDED
@@ -0,0 +1,15 @@
1
+ import { userTable } from "@vilio/core";
2
+ import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
3
+ export const sampleTable = pgTable("sample", {
4
+ id: text("id")
5
+ .primaryKey()
6
+ .$defaultFn(() => crypto.randomUUID()),
7
+ userId: text("user_id")
8
+ .references(() => userTable.id, { onDelete: "cascade" })
9
+ .notNull(),
10
+ createdAt: timestamp("created_at").defaultNow().notNull(),
11
+ });
12
+ export const sampleSchema = {
13
+ sampleTable,
14
+ };
15
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAQ,MAAM,qBAAqB,CAAC;AAErE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE;IAC3C,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;SACX,UAAU,EAAE;SACZ,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAExC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;SACpB,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;SACvD,OAAO,EAAE;IACZ,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE;CAC1D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW;CACZ,CAAC"}
@@ -1,2 +1,2 @@
1
- import * as React from "react";
2
- export default function SampleSettingsPage(): React.JSX.Element;
1
+ export default function SampleSettingsPage(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=settings-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-page.d.ts","sourceRoot":"","sources":["../../src/ui/settings-page.tsx"],"names":[],"mappings":"AAqBA,MAAM,CAAC,OAAO,UAAU,kBAAkB,4CA0DzC"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useTranslation } from "@vilio/intl";
4
+ import { Button } from "@vilio/ui/components/button";
5
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@vilio/ui/components/card";
6
+ import { Input } from "@vilio/ui/components/input";
7
+ import { Label } from "@vilio/ui/components/label";
8
+ import { useEffect, useState } from "react";
9
+ import { toast } from "sonner";
10
+ import { getSampleConfig, updateSampleConfig, } from "../actions/settings";
11
+ export default function SampleSettingsPage() {
12
+ const { t } = useTranslation();
13
+ const [config, setConfig] = useState({
14
+ defaultVar: "",
15
+ });
16
+ const [loading, setLoading] = useState(true);
17
+ useEffect(() => {
18
+ getSampleConfig().then((data) => {
19
+ setConfig(data);
20
+ setLoading(false);
21
+ });
22
+ }, []);
23
+ const handleSave = async (e) => {
24
+ e.preventDefault();
25
+ try {
26
+ await updateSampleConfig(config);
27
+ toast.success(t("Settings saved successfully"));
28
+ }
29
+ catch {
30
+ toast.error(t("Failed to save settings"));
31
+ }
32
+ };
33
+ if (loading)
34
+ return _jsx("div", { children: t("Loading Sample Settings...") });
35
+ return (_jsx("div", { className: "container mx-auto py-10 max-w-2xl", children: _jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: t("Sample Settings") }), _jsx(CardDescription, { children: t("Configure your Sample Configuration.") })] }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSave, className: "space-y-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "defaultVar", children: t("Default Var") }), _jsx(Input, { id: "defaultVar", value: config.defaultVar, onChange: (e) => setConfig({ ...config, defaultVar: e.target.value }), placeholder: "" })] }), _jsx(Button, { type: "submit", className: "w-full", children: t("Save Configuration") })] }) })] }) }));
36
+ }
37
+ //# sourceMappingURL=settings-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-page.js","sourceRoot":"","sources":["../../src/ui/settings-page.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EACL,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EACL,eAAe,EAEf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACxC,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC;IAE/B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAe;QACjD,UAAU,EAAE,EAAE;KACf,CAAC,CAAC;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9B,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,KAAK,EAAE,CAAkB,EAAE,EAAE;QAC9C,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,OAAO;QAAE,OAAO,wBAAM,CAAC,CAAC,4BAA4B,CAAC,GAAO,CAAC;IAEjE,OAAO,CACL,cAAK,SAAS,EAAC,mCAAmC,YAChD,MAAC,IAAI,eACH,MAAC,UAAU,eACT,KAAC,SAAS,cAAE,CAAC,CAAC,iBAAiB,CAAC,GAAa,EAC7C,KAAC,eAAe,cACb,CAAC,CAAC,sCAAsC,CAAC,GAC1B,IACP,EACb,KAAC,WAAW,cACV,gBAAM,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAC,WAAW,aAC/C,eAAK,SAAS,EAAC,WAAW,aACxB,KAAC,KAAK,IAAC,OAAO,EAAC,YAAY,YAAE,CAAC,CAAC,aAAa,CAAC,GAAS,EACtD,KAAC,KAAK,IACJ,EAAE,EAAC,YAAY,EACf,KAAK,EAAE,MAAM,CAAC,UAAU,EACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACd,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAEtD,WAAW,EAAC,EAAE,GACd,IACE,EAEN,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,YACrC,CAAC,CAAC,oBAAoB,CAAC,GACjB,IACJ,GACK,IACT,GACH,CACP,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "@vilio/sample-module",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Sample module for Vilio framework",
5
- "type": "module",
5
+ "main": "./dist/index.js",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.cjs"
12
- }
8
+ ".": "./dist/index.js"
13
9
  },
14
10
  "files": [
15
11
  "dist",
@@ -19,15 +15,13 @@
19
15
  "scripts": {
20
16
  "release": "npm publish --access public --no-git-checks",
21
17
  "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"
18
+ "dev": "tsc --watch",
19
+ "build": "tsc"
26
20
  },
27
21
  "dependencies": {
28
22
  "@hookform/resolvers": "^3.10.0",
29
- "@vilio/ui": "^0.0.4",
30
- "@vilio/modules": "^0.0.4",
23
+ "@vilio/ui": "^0.0.6",
24
+ "@vilio/modules": "^0.0.6",
31
25
  "lucide-react": "^0.475.0",
32
26
  "react-hook-form": "^7.54.2",
33
27
  "drizzle-orm": "1.0.0-beta.6-4414a19",
@@ -35,19 +29,17 @@
35
29
  "zod": "^3.24.1"
36
30
  },
37
31
  "devDependencies": {
38
- "@vilio/core": "^0.0.4",
32
+ "@vilio/core": "^0.0.9",
39
33
  "@types/react": "^19",
40
- "next": "16.1.1",
34
+ "next": "16.1.6",
41
35
  "react": "^19.0.0",
42
- "typescript": "^5.3.3",
43
- "unbuild": "^3.6.1"
36
+ "typescript": "5.9.2"
44
37
  },
45
38
  "peerDependencies": {
46
- "@vilio/core": "^0.0.4",
47
- "@vilio/intl": "^0.0.4",
48
- "@vilio/ui": "^0.0.4",
49
- "next": ">=13.0.0",
39
+ "@vilio/core": "^0.0.9",
40
+ "@vilio/intl": "^0.0.7",
41
+ "@vilio/ui": "^0.0.6",
42
+ "next": "16.1.6",
50
43
  "react": "^19.0.0"
51
- },
52
- "main": "./dist/index.mjs"
44
+ }
53
45
  }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- "use server";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getSampleConfig = getSampleConfig;
8
- exports.updateSampleConfig = updateSampleConfig;
9
- var _core = require("@vilio/core");
10
- var _server = require("@vilio/core/server");
11
- var _server2 = require("@vilio/modules/server");
12
- var _cache = require("next/cache");
13
- async function getSampleConfig() {
14
- const config = await (0, _server2.getModuleConfig)("sample-module");
15
- return config ?? {
16
- defaultVar: ""
17
- };
18
- }
19
- async function updateSampleConfig(config) {
20
- await (0, _server2.updateModuleConfig)("sample-module", config);
21
- (0, _cache.revalidatePath)(`${(0, _server2.getVilioPathPrefix)()}/sample-module/settings`);
22
- const {
23
- user
24
- } = await (0, _server.getCurrentSession)();
25
- await _core.eventBus.publish("activity.create", {
26
- action: "sample-module.config.updated",
27
- description: `User updated sample module config`,
28
- userId: user?.id,
29
- metadata: config
30
- }, "sample-module");
31
- return {
32
- success: true
33
- };
34
- }
@@ -1,31 +0,0 @@
1
- "use server";
2
- import { eventBus } from "@vilio/core";
3
- import { getCurrentSession } from "@vilio/core/server";
4
- import {
5
- getModuleConfig,
6
- getVilioPathPrefix,
7
- updateModuleConfig
8
- } from "@vilio/modules/server";
9
- import { revalidatePath } from "next/cache";
10
- export async function getSampleConfig() {
11
- const config = await getModuleConfig("sample-module");
12
- return config ?? {
13
- defaultVar: ""
14
- };
15
- }
16
- export async function updateSampleConfig(config) {
17
- await updateModuleConfig("sample-module", config);
18
- revalidatePath(`${getVilioPathPrefix()}/sample-module/settings`);
19
- const { user } = await getCurrentSession();
20
- await eventBus.publish(
21
- "activity.create",
22
- {
23
- action: "sample-module.config.updated",
24
- description: `User updated sample module config`,
25
- userId: user?.id,
26
- metadata: config
27
- },
28
- "sample-module"
29
- );
30
- return { success: true };
31
- }
package/dist/index.cjs DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _intl = require("@vilio/intl");
8
- var _global = _interopRequireDefault(require("../locales/en/global.json"));
9
- var _global2 = _interopRequireDefault(require("../locales/pl/global.json"));
10
- var _manifest = _interopRequireDefault(require("../manifest.json"));
11
- var _routes = require("./routes.cjs");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- const _module = {
14
- manifest: _manifest.default,
15
- translations: {
16
- en: _global.default,
17
- pl: _global2.default
18
- },
19
- onEnable: async () => {},
20
- onDisable: async () => {
21
- console.log("[Module:Sample] onDisable: Dropping all tables physically...");
22
- },
23
- routes: {
24
- private: _routes.privateRoutes,
25
- api: _routes.apiRoutes
26
- },
27
- navigation: {
28
- admin: {
29
- [(0, _intl.i18n)("General")]: [{
30
- id: "sample-settings",
31
- title: (0, _intl.i18n)("Sample Configuration"),
32
- url: "/sample/settings",
33
- icon: "solar:box-bold-duotone"
34
- }]
35
- }
36
- }
37
- };
38
- module.exports = _module;
package/dist/index.mjs DELETED
@@ -1,34 +0,0 @@
1
- import { i18n } from "@vilio/intl";
2
- import localesEn from "../locales/en/global.json" with { type: "json" };
3
- import localesPl from "../locales/pl/global.json" with { type: "json" };
4
- import manifest from "../manifest.json";
5
- import { apiRoutes, privateRoutes } from "./routes.mjs";
6
- const module = {
7
- manifest,
8
- translations: {
9
- en: localesEn,
10
- pl: localesPl
11
- },
12
- onEnable: async () => {
13
- },
14
- onDisable: async () => {
15
- console.log("[Module:Sample] onDisable: Dropping all tables physically...");
16
- },
17
- routes: {
18
- private: privateRoutes,
19
- api: apiRoutes
20
- },
21
- navigation: {
22
- admin: {
23
- [i18n("General")]: [
24
- {
25
- id: "sample-settings",
26
- title: i18n("Sample Configuration"),
27
- url: "/sample/settings",
28
- icon: "solar:box-bold-duotone"
29
- }
30
- ]
31
- }
32
- }
33
- };
34
- export default module;
package/dist/intl.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import type messages from "../locales/en/global.json";
2
-
3
- type JsonDataType = typeof messages;
4
-
5
- // declare global {
6
- // interface IntlMessages extends JsonDataType {}
7
- // }
8
-
9
- declare module "@vilio/intl" {
10
- export interface IntlMessages extends JsonDataType { }
11
- }
12
-
13
- export { };
package/dist/routes.cjs DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.privateRoutes = exports.apiRoutes = void 0;
7
- var _settingsPage = _interopRequireDefault(require("./ui/settings-page.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const privateRoutes = exports.privateRoutes = [{
10
- path: "/sample/settings",
11
- // Będzie widoczne pod /sample/settings
12
- component: _settingsPage.default,
13
- auth: true
14
- }];
15
- const apiRoutes = exports.apiRoutes = [];
package/dist/routes.mjs DELETED
@@ -1,10 +0,0 @@
1
- import SampleSettingsPage from "./ui/settings-page.mjs";
2
- export const privateRoutes = [
3
- {
4
- path: "/sample/settings",
5
- // Będzie widoczne pod /sample/settings
6
- component: SampleSettingsPage,
7
- auth: true
8
- }
9
- ];
10
- export const apiRoutes = [];
package/dist/schema.cjs DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sampleTable = exports.sampleSchema = void 0;
7
- var _core = require("@vilio/core");
8
- var _pgCore = require("drizzle-orm/pg-core");
9
- const sampleTable = exports.sampleTable = (0, _pgCore.pgTable)("sample", {
10
- id: (0, _pgCore.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
11
- userId: (0, _pgCore.text)("user_id").references(() => _core.userTable.id, {
12
- onDelete: "cascade"
13
- }).notNull(),
14
- createdAt: (0, _pgCore.timestamp)("created_at").defaultNow().notNull()
15
- });
16
- const sampleSchema = exports.sampleSchema = {
17
- sampleTable
18
- };
package/dist/schema.mjs DELETED
@@ -1,10 +0,0 @@
1
- import { userTable } from "@vilio/core";
2
- import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
3
- export const sampleTable = pgTable("sample", {
4
- id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
5
- userId: text("user_id").references(() => userTable.id, { onDelete: "cascade" }).notNull(),
6
- createdAt: timestamp("created_at").defaultNow().notNull()
7
- });
8
- export const sampleSchema = {
9
- sampleTable
10
- };
@@ -1,64 +0,0 @@
1
- "use strict";
2
- "use client";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- module.exports = SampleSettingsPage;
8
- var _intl = require("@vilio/intl");
9
- var _button = require("@vilio/ui/components/button");
10
- var _card = require("@vilio/ui/components/card");
11
- var _input = require("@vilio/ui/components/input");
12
- var _label = require("@vilio/ui/components/label");
13
- var _react = _interopRequireWildcard(require("react"));
14
- var React = _react;
15
- var _sonner = require("sonner");
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 SampleSettingsPage() {
20
- const {
21
- t
22
- } = (0, _intl.useTranslation)();
23
- const [config, setConfig] = (0, _react.useState)({
24
- defaultVar: ""
25
- });
26
- const [loading, setLoading] = (0, _react.useState)(true);
27
- (0, _react.useEffect)(() => {
28
- (0, _settings.getSampleConfig)().then(data => {
29
- setConfig(data);
30
- setLoading(false);
31
- });
32
- }, []);
33
- const handleSave = async e => {
34
- e.preventDefault();
35
- try {
36
- await (0, _settings.updateSampleConfig)(config);
37
- _sonner.toast.success(t("Settings saved successfully"));
38
- } catch {
39
- _sonner.toast.error(t("Failed to save settings"));
40
- }
41
- };
42
- if (loading) return /* @__PURE__ */React.createElement("div", null, t("Loading Sample Settings..."));
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(_card.CardTitle, null, t("Sample Settings")), /* @__PURE__ */React.createElement(_card.CardDescription, null, t("Configure your Sample Configuration."))), /* @__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: "defaultVar"
52
- }, t("Default Var")), /* @__PURE__ */React.createElement(_input.Input, {
53
- id: "defaultVar",
54
- value: config.defaultVar,
55
- onChange: e => setConfig({
56
- ...config,
57
- defaultVar: e.target.value
58
- }),
59
- placeholder: ""
60
- })), /* @__PURE__ */React.createElement(_button.Button, {
61
- type: "submit",
62
- className: "w-full"
63
- }, t("Save Configuration"))))));
64
- }
@@ -1,51 +0,0 @@
1
- "use client";
2
- import { useTranslation } from "@vilio/intl";
3
- import { Button } from "@vilio/ui/components/button";
4
- import {
5
- Card,
6
- CardContent,
7
- CardDescription,
8
- CardHeader,
9
- CardTitle
10
- } from "@vilio/ui/components/card";
11
- import { Input } from "@vilio/ui/components/input";
12
- import { Label } from "@vilio/ui/components/label";
13
- import * as React from "react";
14
- import { useEffect, useState } from "react";
15
- import { toast } from "sonner";
16
- import {
17
- getSampleConfig,
18
- updateSampleConfig
19
- } from "../actions/settings.mjs";
20
- export default function SampleSettingsPage() {
21
- const { t } = useTranslation();
22
- const [config, setConfig] = useState({
23
- defaultVar: ""
24
- });
25
- const [loading, setLoading] = useState(true);
26
- useEffect(() => {
27
- getSampleConfig().then((data) => {
28
- setConfig(data);
29
- setLoading(false);
30
- });
31
- }, []);
32
- const handleSave = async (e) => {
33
- e.preventDefault();
34
- try {
35
- await updateSampleConfig(config);
36
- toast.success(t("Settings saved successfully"));
37
- } catch {
38
- toast.error(t("Failed to save settings"));
39
- }
40
- };
41
- if (loading) return /* @__PURE__ */ React.createElement("div", null, t("Loading Sample Settings..."));
42
- 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(CardTitle, null, t("Sample Settings")), /* @__PURE__ */ React.createElement(CardDescription, null, t("Configure your Sample Configuration."))), /* @__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: "defaultVar" }, t("Default Var")), /* @__PURE__ */ React.createElement(
43
- Input,
44
- {
45
- id: "defaultVar",
46
- value: config.defaultVar,
47
- onChange: (e) => setConfig({ ...config, defaultVar: e.target.value }),
48
- placeholder: ""
49
- }
50
- )), /* @__PURE__ */ React.createElement(Button, { type: "submit", className: "w-full" }, t("Save Configuration"))))));
51
- }