@carlonicora/nextjs-jsonapi 6.32.0 → 6.32.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/dist/{BlockNoteEditor-HQTBH527.mjs → BlockNoteEditor-KRNC6EAX.mjs} +4 -4
- package/dist/{BlockNoteEditor-YONN45A3.js → BlockNoteEditor-VXSVY6OY.js} +24 -24
- package/dist/{BlockNoteEditor-YONN45A3.js.map → BlockNoteEditor-VXSVY6OY.js.map} +1 -1
- package/dist/{BlockNoteViewer-BNZEXGVT.mjs → BlockNoteViewer-NVSR67X5.mjs} +2 -2
- package/dist/{BlockNoteViewer-YONLBNXW.js → BlockNoteViewer-RQBYHBQL.js} +3 -3
- package/dist/{BlockNoteViewer-YONLBNXW.js.map → BlockNoteViewer-RQBYHBQL.js.map} +1 -1
- package/dist/billing/index.js +465 -465
- package/dist/billing/index.mjs +3 -3
- package/dist/{chunk-HNK2O6YE.mjs → chunk-4JVLLBRS.mjs} +4 -16
- package/dist/chunk-4JVLLBRS.mjs.map +1 -0
- package/dist/{chunk-6DNGLY5Y.mjs → chunk-4SXHRANW.mjs} +55 -42
- package/dist/chunk-4SXHRANW.mjs.map +1 -0
- package/dist/{chunk-NQL2NDKH.js → chunk-5H25LM2Z.js} +10 -10
- package/dist/chunk-5H25LM2Z.js.map +1 -0
- package/dist/{chunk-FDKAVSZ6.mjs → chunk-AEBZ67JJ.mjs} +8 -8
- package/dist/chunk-AEBZ67JJ.mjs.map +1 -0
- package/dist/{chunk-JL6XL5NK.mjs → chunk-AMQFKCAX.mjs} +2 -2
- package/dist/{chunk-J37GJKCB.js → chunk-GPVLFNLB.js} +1242 -1229
- package/dist/chunk-GPVLFNLB.js.map +1 -0
- package/dist/{chunk-5XP5G45B.js → chunk-NPGX2GJD.js} +4 -16
- package/dist/chunk-NPGX2GJD.js.map +1 -0
- package/dist/{chunk-Q5SMFSE4.js → chunk-PNCO3HMJ.js} +3 -3
- package/dist/{chunk-Q5SMFSE4.js.map → chunk-PNCO3HMJ.js.map} +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/components/index.js +4 -4
- package/dist/components/index.mjs +3 -3
- package/dist/contexts/index.js +4 -4
- package/dist/contexts/index.mjs +3 -3
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/email-automations/index.js +105 -105
- package/dist/email-automations/index.mjs +3 -3
- package/dist/features/analytics/index.js +114 -114
- package/dist/features/analytics/index.mjs +3 -3
- package/dist/features/analytics/server.js +4 -4
- package/dist/features/analytics/server.mjs +2 -2
- package/dist/features/auth/components/forms/RefreshUser.d.ts.map +1 -1
- package/dist/features/auth/config.d.ts +0 -9
- package/dist/features/auth/config.d.ts.map +1 -1
- package/dist/features/auth/data/auth.service.d.ts.map +1 -1
- package/dist/features/auth/data/two-factor.service.d.ts.map +1 -1
- package/dist/features/auth/utils/AuthCookies.d.ts +0 -9
- package/dist/features/auth/utils/AuthCookies.d.ts.map +1 -1
- package/dist/features/blog/index.js +129 -129
- package/dist/features/blog/index.mjs +3 -3
- package/dist/features/blog/server.js +7 -7
- package/dist/features/blog/server.mjs +1 -1
- package/dist/features/help/index.js +37 -37
- package/dist/features/help/index.mjs +3 -3
- package/dist/features/tokenusage/index.js +114 -114
- package/dist/features/tokenusage/index.mjs +3 -3
- package/dist/features/user/contexts/CurrentUserContext.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/dist/server/ServerSession.d.ts.map +1 -1
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/shadcnui/ui/calendar.d.ts +1 -1
- package/dist/shadcnui/ui/calendar.d.ts.map +1 -1
- package/messages/en.json +11 -0
- package/messages/it.json +11 -0
- package/package.json +1 -1
- package/src/features/auth/components/forms/RefreshUser.tsx +0 -3
- package/src/features/auth/config.ts +0 -9
- package/src/features/auth/data/auth.service.ts +0 -8
- package/src/features/auth/data/two-factor.service.ts +0 -4
- package/src/features/auth/utils/AuthCookies.ts +1 -23
- package/src/features/user/contexts/CurrentUserContext.tsx +0 -4
- package/src/features/user/contexts/__tests__/CurrentUserContext.spec.tsx +2 -0
- package/src/server/ServerSession.ts +10 -26
- package/src/server/__tests__/ServerSession.hasPermissionToModule.spec.ts +78 -0
- package/src/shadcnui/ui/__tests__/calendar.spec.tsx +222 -0
- package/src/shadcnui/ui/calendar.tsx +28 -1
- package/dist/chunk-5XP5G45B.js.map +0 -1
- package/dist/chunk-6DNGLY5Y.mjs.map +0 -1
- package/dist/chunk-FDKAVSZ6.mjs.map +0 -1
- package/dist/chunk-HNK2O6YE.mjs.map +0 -1
- package/dist/chunk-J37GJKCB.js.map +0 -1
- package/dist/chunk-NQL2NDKH.js.map +0 -1
- /package/dist/{BlockNoteEditor-HQTBH527.mjs.map → BlockNoteEditor-KRNC6EAX.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-BNZEXGVT.mjs.map → BlockNoteViewer-NVSR67X5.mjs.map} +0 -0
- /package/dist/{chunk-JL6XL5NK.mjs.map → chunk-AMQFKCAX.mjs.map} +0 -0
|
@@ -4,7 +4,8 @@ var _chunkG4JR3SFVjs = require('./chunk-G4JR3SFV.js');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
var _chunkNPGX2GJDjs = require('./chunk-NPGX2GJD.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
@@ -30,7 +31,8 @@ _chunk7QVYU63Ejs.__name.call(void 0, updateCacheTag, "updateCacheTag");
|
|
|
30
31
|
var _headers = require('next/headers');
|
|
31
32
|
var _navigation = require('next/navigation');
|
|
32
33
|
var _server = require('next/server');
|
|
33
|
-
var
|
|
34
|
+
var _react = require('react');
|
|
35
|
+
var getCachedFullUser = _react.cache.call(void 0, async () => _chunkNPGX2GJDjs.UserService.findFullUser());
|
|
34
36
|
var ServerSession = class {
|
|
35
37
|
static {
|
|
36
38
|
_chunk7QVYU63Ejs.__name.call(void 0, this, "ServerSession");
|
|
@@ -40,7 +42,7 @@ var ServerSession = class {
|
|
|
40
42
|
const headerStore = await _headers.headers.call(void 0, );
|
|
41
43
|
const token = _optionalChain([cookieStore, 'access', _ => _.get, 'call', _2 => _2("token"), 'optionalAccess', _3 => _3.value]) || void 0;
|
|
42
44
|
const roles = _optionalChain([cookieStore, 'access', _4 => _4.get, 'call', _5 => _5("roles"), 'optionalAccess', _6 => _6.value]);
|
|
43
|
-
const viewportCookie = _optionalChain([cookieStore, 'access', _7 => _7.get, 'call', _8 => _8(
|
|
45
|
+
const viewportCookie = _optionalChain([cookieStore, 'access', _7 => _7.get, 'call', _8 => _8(_chunkNPGX2GJDjs.VIEWPORT_COOKIE_NAME), 'optionalAccess', _9 => _9.value]);
|
|
44
46
|
return {
|
|
45
47
|
isLogged: !!token,
|
|
46
48
|
isAdministrator: !!roles && roles.includes(_chunkG4JR3SFVjs.getRoleId.call(void 0, ).Administrator),
|
|
@@ -85,16 +87,14 @@ var ServerSession = class {
|
|
|
85
87
|
const features = _optionalChain([cookieStore, 'access', _25 => _25.get, 'call', _26 => _26("features"), 'optionalAccess', _27 => _27.value]);
|
|
86
88
|
if (features && !features.includes(params.module.feature)) return false;
|
|
87
89
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const selectedModule = modules.find((module) => module.id === params.module.moduleId);
|
|
92
|
-
return _chunk5XP5G45Bjs.checkPermissionsFromServer.call(void 0, {
|
|
90
|
+
const user = await getCachedFullUser();
|
|
91
|
+
const selectedModule = user.modules.find((module) => module.id === params.module.moduleId);
|
|
92
|
+
return _chunkNPGX2GJDjs.checkPermissionsFromServer.call(void 0, {
|
|
93
93
|
module: params.module,
|
|
94
94
|
action: params.action,
|
|
95
95
|
data: params.data,
|
|
96
96
|
userId: await this.userId(),
|
|
97
|
-
selectedModule
|
|
97
|
+
selectedModule: selectedModule ? { id: selectedModule.id, permissions: selectedModule.permissions } : void 0
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
};
|
|
@@ -139,4 +139,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, readBuildId, "readBuildId");
|
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.updateCacheTag = updateCacheTag; exports.ServerSession = ServerSession; exports.buildOfflineManifest = buildOfflineManifest;
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-5H25LM2Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-5H25LM2Z.js","../src/server/cache.ts","../src/server/ServerSession.ts","../src/offline/server/build-offline-manifest.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACVA,mCAAyC;AAkBzC,MAAA,SAAsB,kBAAA,CAAmB,GAAA,EAAa,QAAA,EAAwB,KAAA,EAAsB;AAClG,EAAA,kCAAA,GAAc,EAAK,OAAO,CAAA;AAC5B;AAFsB,qCAAA,kBAAA,EAAA,oBAAA,CAAA;AAUtB,MAAA,SAAsB,mBAAA,CAAoB,IAAA,EAAgB,QAAA,EAAwB,KAAA,EAAsB;AACtG,EAAA,IAAA,CAAA,MAAW,IAAA,GAAO,IAAA,EAAM;AACtB,IAAA,kCAAA,GAAc,EAAK,OAAO,CAAA;AAAA,EAC5B;AACF;AAJsB,qCAAA,mBAAA,EAAA,qBAAA,CAAA;AAYtB,MAAA,SAAsB,cAAA,CAAe,GAAA,EAA4B;AAC/D,EAAA,8BAAA,GAAa,CAAA;AACf;AAFsB,qCAAA,cAAA,EAAA,gBAAA,CAAA;ADdtB;AACA;AE7BA,uCAA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;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-5H25LM2Z.js","sourcesContent":[null,"// Server-only utilities (NOT server actions - these cannot be called from client components)\n\nimport { revalidateTag, updateTag } from \"next/cache\";\n\nimport type { CacheProfile } from \"./cacheProfiles\";\n\nexport { CACHE_PROFILES, type CacheProfile } from \"./cacheProfiles\";\n\n/**\n * Revalidate a cache tag to invalidate cached data.\n * Next.js 16+ requires a profile parameter.\n *\n * With `\"max\"` the tagged entries are marked stale and served stale-while-revalidate\n * (a one-year window): the next request still gets the old data while fresh data loads\n * in the background. It is not an immediate invalidation. A Server Action that must\n * read its own write uses `updateCacheTag` instead.\n *\n * @param tag - The cache tag to invalidate\n * @param profile - The cache profile whose `expire` bounds how long stale data may be served (defaults to \"max\")\n */\nexport async function invalidateCacheTag(tag: string, profile: CacheProfile = \"max\"): Promise<void> {\n revalidateTag(tag, profile);\n}\n\n/**\n * Revalidate multiple cache tags.\n *\n * @param tags - Array of cache tags to invalidate\n * @param profile - The cache profile, see `invalidateCacheTag` (defaults to \"max\", stale-while-revalidate)\n */\nexport async function invalidateCacheTags(tags: string[], profile: CacheProfile = \"max\"): Promise<void> {\n for (const tag of tags) {\n revalidateTag(tag, profile);\n }\n}\n\n/**\n * Expire a cache tag immediately, so the same request reads fresh data (read-your-own-writes).\n * Wraps `updateTag`, which works in Server Actions only. Route Handlers use `invalidateCacheTag`.\n *\n * @param tag - The cache tag to expire\n */\nexport async function updateCacheTag(tag: string): Promise<void> {\n updateTag(tag);\n}\n","import { cookies, headers } from \"next/headers\";\nimport { redirect } from \"next/navigation\";\nimport { userAgent } from \"next/server\";\nimport { cache } from \"react\";\nimport { UserService } from \"../features/user/data/user.service\";\nimport { Action, checkPermissionsFromServer, ModuleWithPermissions } from \"../permissions\";\nimport { getRoleId } from \"../roles/config\";\nimport { VIEWPORT_COOKIE_NAME } from \"../utils/use-mobile\";\n\n// The user's modules come from the api once per request. They no longer travel in a\n// cookie: a non-admin user's scoped permissions push it past the browser's 4096-byte limit.\n// No `cache` option on the request: it carries the user's token.\nconst getCachedFullUser = cache(async () => UserService.findFullUser());\n\nexport interface SessionSnapshot {\n isLogged: boolean;\n isAdministrator: boolean;\n token?: string;\n sidebarOpen: boolean;\n isMobile: boolean;\n /** The request's raw `Accept-Language` header; the date locale is resolved from it on the client. */\n acceptLanguage?: string;\n}\n\nexport class ServerSession {\n static async read(): Promise<SessionSnapshot> {\n const cookieStore = await cookies();\n const headerStore = await headers();\n\n const token = cookieStore.get(\"token\")?.value || undefined;\n const roles = cookieStore.get(\"roles\")?.value;\n const viewportCookie = cookieStore.get(VIEWPORT_COOKIE_NAME)?.value;\n\n return {\n isLogged: !!token,\n isAdministrator: !!roles && roles.includes(getRoleId().Administrator),\n token,\n sidebarOpen: cookieStore.get(\"sidebar_state\")?.value !== \"false\",\n isMobile: viewportCookie ? viewportCookie === \"1\" : userAgent({ headers: headerStore }).device.type === \"mobile\",\n acceptLanguage: headerStore.get(\"accept-language\") ?? undefined,\n };\n }\n\n static async isLogged() {\n const cookieStore = await cookies();\n const token = cookieStore.get(\"token\");\n\n if (!token || !token.value) return false;\n return true;\n }\n\n static async companyId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"companyId\")?.value ?? \"\";\n }\n\n static async userId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"userId\")?.value ?? \"\";\n }\n\n static async checkPermission<M extends ModuleWithPermissions>(params: { module: M; action: Action; data?: any }) {\n if (!(await this.hasPermissionToModule(params))) redirect(`/401`);\n }\n\n static async hasRole(roleId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const roles = cookieStore.get(\"roles\")?.value;\n\n if (!roles || !roles.includes(roleId)) return false;\n\n return true;\n }\n\n static async hasFeature(featureId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const features = cookieStore.get(\"features\")?.value;\n\n if (!features || !features.includes(featureId)) return false;\n\n return true;\n }\n\n static async hasPermissionToModule<M extends ModuleWithPermissions>(params: {\n module: M;\n action: Action;\n data?: any;\n }): Promise<boolean> {\n const cookieStore = await cookies();\n\n if (params.module.feature) {\n const features = cookieStore.get(\"features\")?.value;\n\n if (features && !features.includes(params.module.feature)) return false;\n }\n\n const user = await getCachedFullUser();\n const selectedModule = user.modules.find((module) => module.id === params.module.moduleId);\n\n return checkPermissionsFromServer({\n module: params.module,\n action: params.action,\n data: params.data,\n userId: await this.userId(),\n selectedModule: selectedModule ? { id: selectedModule.id, permissions: selectedModule.permissions } : undefined,\n });\n }\n}\n","import { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport type OfflineManifest = { buildId: string; assets: string[] };\n\nasync function listFiles(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) files.push(...(await listFiles(full)));\n else if (entry.isFile()) files.push(full);\n }\n return files;\n}\n\n/**\n * Describes the running build for the service worker's offline shell precache\n * (`/offline-manifest.json`): the build id from `<distDir>/BUILD_ID` and every\n * file under `<distDir>/static`, as the `/_next/static/...` URL Next serves it at.\n * `next dev` writes no BUILD_ID (its folder is `.next/dev`): the id is then `dev-` plus a hash\n * of the asset list. Dev chunk names do NOT carry content hashes (an edit rewrites a chunk under\n * the same name), so the id changes only when files appear or disappear; the service worker\n * therefore serves `/_next/static/` network first for a `dev-` build (pwa/sw.js).\n * `distDir` must be the value the app's next.config uses. `extraAssets` are further same-origin\n * URLs the shell needs with no network (the SQLite files the device worker loads).\n */\nexport async function buildOfflineManifest(params: {\n distDir: string;\n extraAssets?: string[];\n}): Promise<OfflineManifest> {\n const staticDir = path.join(params.distDir, \"static\");\n const files = await listFiles(staticDir);\n const assets = files\n .map((file) => `/_next/static/${path.relative(staticDir, file).split(path.sep).join(\"/\")}`)\n .concat(params.extraAssets ?? [])\n .sort();\n const buildId = await readBuildId(params.distDir, assets);\n return { buildId, assets };\n}\n\nasync function readBuildId(distDir: string, assets: string[]): Promise<string> {\n try {\n return (await readFile(path.join(distDir, \"BUILD_ID\"), \"utf8\")).trim();\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n return `dev-${createHash(\"sha256\").update(assets.join(\"\\n\")).digest(\"hex\").slice(0, 16)}`;\n }\n}\n"]}
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
getRoleId
|
|
3
3
|
} from "./chunk-PW42LRSL.mjs";
|
|
4
4
|
import {
|
|
5
|
+
UserService,
|
|
5
6
|
VIEWPORT_COOKIE_NAME,
|
|
6
7
|
checkPermissionsFromServer
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4JVLLBRS.mjs";
|
|
8
9
|
import {
|
|
9
10
|
__name
|
|
10
11
|
} from "./chunk-PAWJFY3S.mjs";
|
|
@@ -30,7 +31,8 @@ __name(updateCacheTag, "updateCacheTag");
|
|
|
30
31
|
import { cookies, headers } from "next/headers";
|
|
31
32
|
import { redirect } from "next/navigation";
|
|
32
33
|
import { userAgent } from "next/server";
|
|
33
|
-
import {
|
|
34
|
+
import { cache } from "react";
|
|
35
|
+
var getCachedFullUser = cache(async () => UserService.findFullUser());
|
|
34
36
|
var ServerSession = class {
|
|
35
37
|
static {
|
|
36
38
|
__name(this, "ServerSession");
|
|
@@ -85,16 +87,14 @@ var ServerSession = class {
|
|
|
85
87
|
const features = cookieStore.get("features")?.value;
|
|
86
88
|
if (features && !features.includes(params.module.feature)) return false;
|
|
87
89
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
const modules = JSON.parse(ungzip(Buffer.from(rawModules, "base64"), { toText: true }));
|
|
91
|
-
const selectedModule = modules.find((module) => module.id === params.module.moduleId);
|
|
90
|
+
const user = await getCachedFullUser();
|
|
91
|
+
const selectedModule = user.modules.find((module) => module.id === params.module.moduleId);
|
|
92
92
|
return checkPermissionsFromServer({
|
|
93
93
|
module: params.module,
|
|
94
94
|
action: params.action,
|
|
95
95
|
data: params.data,
|
|
96
96
|
userId: await this.userId(),
|
|
97
|
-
selectedModule
|
|
97
|
+
selectedModule: selectedModule ? { id: selectedModule.id, permissions: selectedModule.permissions } : void 0
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
};
|
|
@@ -139,4 +139,4 @@ export {
|
|
|
139
139
|
ServerSession,
|
|
140
140
|
buildOfflineManifest
|
|
141
141
|
};
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-AEBZ67JJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/cache.ts","../src/server/ServerSession.ts","../src/offline/server/build-offline-manifest.ts"],"sourcesContent":["// Server-only utilities (NOT server actions - these cannot be called from client components)\n\nimport { revalidateTag, updateTag } from \"next/cache\";\n\nimport type { CacheProfile } from \"./cacheProfiles\";\n\nexport { CACHE_PROFILES, type CacheProfile } from \"./cacheProfiles\";\n\n/**\n * Revalidate a cache tag to invalidate cached data.\n * Next.js 16+ requires a profile parameter.\n *\n * With `\"max\"` the tagged entries are marked stale and served stale-while-revalidate\n * (a one-year window): the next request still gets the old data while fresh data loads\n * in the background. It is not an immediate invalidation. A Server Action that must\n * read its own write uses `updateCacheTag` instead.\n *\n * @param tag - The cache tag to invalidate\n * @param profile - The cache profile whose `expire` bounds how long stale data may be served (defaults to \"max\")\n */\nexport async function invalidateCacheTag(tag: string, profile: CacheProfile = \"max\"): Promise<void> {\n revalidateTag(tag, profile);\n}\n\n/**\n * Revalidate multiple cache tags.\n *\n * @param tags - Array of cache tags to invalidate\n * @param profile - The cache profile, see `invalidateCacheTag` (defaults to \"max\", stale-while-revalidate)\n */\nexport async function invalidateCacheTags(tags: string[], profile: CacheProfile = \"max\"): Promise<void> {\n for (const tag of tags) {\n revalidateTag(tag, profile);\n }\n}\n\n/**\n * Expire a cache tag immediately, so the same request reads fresh data (read-your-own-writes).\n * Wraps `updateTag`, which works in Server Actions only. Route Handlers use `invalidateCacheTag`.\n *\n * @param tag - The cache tag to expire\n */\nexport async function updateCacheTag(tag: string): Promise<void> {\n updateTag(tag);\n}\n","import { cookies, headers } from \"next/headers\";\nimport { redirect } from \"next/navigation\";\nimport { userAgent } from \"next/server\";\nimport { cache } from \"react\";\nimport { UserService } from \"../features/user/data/user.service\";\nimport { Action, checkPermissionsFromServer, ModuleWithPermissions } from \"../permissions\";\nimport { getRoleId } from \"../roles/config\";\nimport { VIEWPORT_COOKIE_NAME } from \"../utils/use-mobile\";\n\n// The user's modules come from the api once per request. They no longer travel in a\n// cookie: a non-admin user's scoped permissions push it past the browser's 4096-byte limit.\n// No `cache` option on the request: it carries the user's token.\nconst getCachedFullUser = cache(async () => UserService.findFullUser());\n\nexport interface SessionSnapshot {\n isLogged: boolean;\n isAdministrator: boolean;\n token?: string;\n sidebarOpen: boolean;\n isMobile: boolean;\n /** The request's raw `Accept-Language` header; the date locale is resolved from it on the client. */\n acceptLanguage?: string;\n}\n\nexport class ServerSession {\n static async read(): Promise<SessionSnapshot> {\n const cookieStore = await cookies();\n const headerStore = await headers();\n\n const token = cookieStore.get(\"token\")?.value || undefined;\n const roles = cookieStore.get(\"roles\")?.value;\n const viewportCookie = cookieStore.get(VIEWPORT_COOKIE_NAME)?.value;\n\n return {\n isLogged: !!token,\n isAdministrator: !!roles && roles.includes(getRoleId().Administrator),\n token,\n sidebarOpen: cookieStore.get(\"sidebar_state\")?.value !== \"false\",\n isMobile: viewportCookie ? viewportCookie === \"1\" : userAgent({ headers: headerStore }).device.type === \"mobile\",\n acceptLanguage: headerStore.get(\"accept-language\") ?? undefined,\n };\n }\n\n static async isLogged() {\n const cookieStore = await cookies();\n const token = cookieStore.get(\"token\");\n\n if (!token || !token.value) return false;\n return true;\n }\n\n static async companyId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"companyId\")?.value ?? \"\";\n }\n\n static async userId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"userId\")?.value ?? \"\";\n }\n\n static async checkPermission<M extends ModuleWithPermissions>(params: { module: M; action: Action; data?: any }) {\n if (!(await this.hasPermissionToModule(params))) redirect(`/401`);\n }\n\n static async hasRole(roleId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const roles = cookieStore.get(\"roles\")?.value;\n\n if (!roles || !roles.includes(roleId)) return false;\n\n return true;\n }\n\n static async hasFeature(featureId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const features = cookieStore.get(\"features\")?.value;\n\n if (!features || !features.includes(featureId)) return false;\n\n return true;\n }\n\n static async hasPermissionToModule<M extends ModuleWithPermissions>(params: {\n module: M;\n action: Action;\n data?: any;\n }): Promise<boolean> {\n const cookieStore = await cookies();\n\n if (params.module.feature) {\n const features = cookieStore.get(\"features\")?.value;\n\n if (features && !features.includes(params.module.feature)) return false;\n }\n\n const user = await getCachedFullUser();\n const selectedModule = user.modules.find((module) => module.id === params.module.moduleId);\n\n return checkPermissionsFromServer({\n module: params.module,\n action: params.action,\n data: params.data,\n userId: await this.userId(),\n selectedModule: selectedModule ? { id: selectedModule.id, permissions: selectedModule.permissions } : undefined,\n });\n }\n}\n","import { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport type OfflineManifest = { buildId: string; assets: string[] };\n\nasync function listFiles(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) files.push(...(await listFiles(full)));\n else if (entry.isFile()) files.push(full);\n }\n return files;\n}\n\n/**\n * Describes the running build for the service worker's offline shell precache\n * (`/offline-manifest.json`): the build id from `<distDir>/BUILD_ID` and every\n * file under `<distDir>/static`, as the `/_next/static/...` URL Next serves it at.\n * `next dev` writes no BUILD_ID (its folder is `.next/dev`): the id is then `dev-` plus a hash\n * of the asset list. Dev chunk names do NOT carry content hashes (an edit rewrites a chunk under\n * the same name), so the id changes only when files appear or disappear; the service worker\n * therefore serves `/_next/static/` network first for a `dev-` build (pwa/sw.js).\n * `distDir` must be the value the app's next.config uses. `extraAssets` are further same-origin\n * URLs the shell needs with no network (the SQLite files the device worker loads).\n */\nexport async function buildOfflineManifest(params: {\n distDir: string;\n extraAssets?: string[];\n}): Promise<OfflineManifest> {\n const staticDir = path.join(params.distDir, \"static\");\n const files = await listFiles(staticDir);\n const assets = files\n .map((file) => `/_next/static/${path.relative(staticDir, file).split(path.sep).join(\"/\")}`)\n .concat(params.extraAssets ?? [])\n .sort();\n const buildId = await readBuildId(params.distDir, assets);\n return { buildId, assets };\n}\n\nasync function readBuildId(distDir: string, assets: string[]): Promise<string> {\n try {\n return (await readFile(path.join(distDir, \"BUILD_ID\"), \"utf8\")).trim();\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n return `dev-${createHash(\"sha256\").update(assets.join(\"\\n\")).digest(\"hex\").slice(0, 16)}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA,SAAS,eAAe,iBAAiB;AAkBzC,eAAsB,mBAAmB,KAAa,UAAwB,OAAsB;AAClG,gBAAc,KAAK,OAAO;AAC5B;AAFsB;AAUtB,eAAsB,oBAAoB,MAAgB,UAAwB,OAAsB;AACtG,aAAW,OAAO,MAAM;AACtB,kBAAc,KAAK,OAAO;AAAA,EAC5B;AACF;AAJsB;AAYtB,eAAsB,eAAe,KAA4B;AAC/D,YAAU,GAAG;AACf;AAFsB;;;AC1CtB,SAAS,SAAS,eAAe;AACjC,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AAStB,IAAM,oBAAoB,MAAM,YAAY,YAAY,aAAa,CAAC;AAY/D,IAAM,gBAAN,MAAoB;AAAA,EAxB3B,OAwB2B;AAAA;AAAA;AAAA,EACzB,aAAa,OAAiC;AAC5C,UAAM,cAAc,MAAM,QAAQ;AAClC,UAAM,cAAc,MAAM,QAAQ;AAElC,UAAM,QAAQ,YAAY,IAAI,OAAO,GAAG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AS,WAAW,IAAI,EAAE,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,EACzF,OAAO,OAAO,eAAe,CAAC,CAAC,EAC/B,KAAK;AACR,QAAM,UAAU,MAAM,YAAY,OAAO,SAAS,MAAM;AACxD,SAAO,EAAE,SAAS,OAAO;AAC3B;AAZsB;AActB,eAAe,YAAY,SAAiB,QAAmC;AAC7E,MAAI;AACF,YAAQ,MAAM,SAAS,KAAK,KAAK,SAAS,UAAU,GAAG,MAAM,GAAG,KAAK;AAAA,EACvE,SAAS,OAAO;AACd,QAAK,MAAgC,SAAS,SAAU,OAAM;AAC9D,WAAO,OAAO,WAAW,QAAQ,EAAE,OAAO,OAAO,KAAK,IAAI,CAAC,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC;AAAA,EACzF;AACF;AAPe;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AbstractService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4JVLLBRS.mjs";
|
|
4
4
|
import {
|
|
5
5
|
EndpointCreator,
|
|
6
6
|
Modules
|
|
@@ -351,4 +351,4 @@ export {
|
|
|
351
351
|
ACTION_TYPES,
|
|
352
352
|
RbacService
|
|
353
353
|
};
|
|
354
|
-
//# sourceMappingURL=chunk-
|
|
354
|
+
//# sourceMappingURL=chunk-AMQFKCAX.mjs.map
|