rimecms 0.31.4 → 0.31.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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/adapter-sqlite/transform.server.js +1 -1
  3. package/dist/core/collections/upload/util/path.d.ts +2 -1
  4. package/dist/core/collections/upload/util/path.js +3 -3
  5. package/dist/core/constant.d.ts +10 -0
  6. package/dist/core/constant.js +22 -0
  7. package/dist/core/dev/cli/build/templates.js +2 -0
  8. package/dist/core/dev/cli/init/index.server.js +2 -1
  9. package/dist/core/dev/cli/init/templates.d.ts +6 -4
  10. package/dist/core/dev/cli/init/templates.js +20 -9
  11. package/dist/core/dev/constants.d.ts +5 -0
  12. package/dist/core/dev/constants.js +9 -0
  13. package/dist/core/dev/generate/routes/common.server.js +33 -33
  14. package/dist/core/dev/generate/routes/index.server.d.ts +6 -3
  15. package/dist/core/dev/generate/routes/index.server.js +13 -7
  16. package/dist/core/dev/generate/routes/util.server.d.ts +14 -6
  17. package/dist/core/dev/generate/routes/util.server.js +17 -6
  18. package/dist/core/handlers/auth.server.js +16 -8
  19. package/dist/core/handlers/routes.server.d.ts +1 -1
  20. package/dist/core/handlers/routes.server.js +4 -3
  21. package/dist/core/operations/hooks/before-read/populate-url.server.js +2 -1
  22. package/dist/core/plugins/cache/handler.server.js +1 -1
  23. package/dist/panel/components/sections/collection/list/row/Row.svelte +2 -1
  24. package/dist/panel/components/sections/collection/tree/CollectionTreeNode.svelte +2 -1
  25. package/dist/panel/components/sections/document/AuthFooter.svelte +2 -1
  26. package/dist/panel/components/sections/document/Versions.svelte +1 -1
  27. package/dist/panel/components/ui/card-resource/card-resource.svelte +2 -1
  28. package/dist/panel/components/ui/nav/Nav.svelte +1 -1
  29. package/dist/panel/components/ui/nav/NavItem.svelte +3 -2
  30. package/dist/panel/components/ui/nav/UserButton.svelte +3 -3
  31. package/dist/panel/context/documentForm.svelte.js +5 -6
  32. package/dist/panel/navigation.d.ts +7 -2
  33. package/dist/panel/navigation.js +11 -6
  34. package/dist/panel/pages/area/actions.server.js +4 -3
  35. package/dist/panel/pages/area/load.server.js +3 -2
  36. package/dist/panel/pages/auth/forgot-password/ForgotPassword.svelte +2 -1
  37. package/dist/panel/pages/auth/reset-password/ResetPassword.svelte +2 -1
  38. package/dist/panel/pages/auth/sign-in/SignIn.svelte +3 -2
  39. package/dist/panel/pages/auth/sign-in/actions.server.js +2 -2
  40. package/dist/panel/pages/auth/sign-in/load.server.d.ts +1 -1
  41. package/dist/panel/pages/auth/sign-in/load.server.js +2 -2
  42. package/dist/panel/pages/collection/load.server.js +9 -4
  43. package/dist/panel/pages/collection-document/actions.server.js +5 -3
  44. package/dist/panel/pages/collection-document/load.server.js +10 -6
  45. package/dist/panel/pages/dashboard/load.server.js +5 -4
  46. package/dist/panel/pages/live/Live.svelte +3 -7
  47. package/dist/panel/util/url.d.ts +30 -1
  48. package/dist/panel/util/url.js +36 -2
  49. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
- import { panelUrl } from '../../util/url.js';
1
+ import { panelUrlFor } from '../../util/url.js';
2
2
  import { capitalize } from '../../../util/string.js';
3
3
  export const dashboardLoad = async (event) => {
4
4
  const { locale, user, rime } = event.locals;
5
+ const panelSegment = event.params.panel;
5
6
  const entries = [];
6
7
  const normalizedPanelConfig = (c) => {
7
8
  const incomingConfig = c.panel || {};
@@ -21,7 +22,7 @@ export const dashboardLoad = async (event) => {
21
22
  description: panelConfig.description || null,
22
23
  slug: c.slug,
23
24
  canCreate: user && c.access.create(user, {}),
24
- link: panelUrl(c.kebab),
25
+ link: panelUrlFor(panelSegment, c.kebab),
25
26
  titleSingular: c.label.singular,
26
27
  title: c.label.plural,
27
28
  layout: panelConfig.dashboard.layout
@@ -72,11 +73,11 @@ export const dashboardLoad = async (event) => {
72
73
  prototype: 'area',
73
74
  description: (area.panel && area.panel?.description) || null,
74
75
  slug: area.slug,
75
- link: panelUrl(area.kebab),
76
+ link: panelUrlFor(panelSegment, area.kebab),
76
77
  title: area.label || capitalize(area.slug)
77
78
  });
78
79
  }
79
80
  }
80
- const aria = [{ title: 'Dashboard', icon: 'dashboard', url: panelUrl() }];
81
+ const aria = [{ title: 'Dashboard', icon: 'dashboard', url: panelUrlFor(panelSegment) }];
81
82
  return { entries, aria };
82
83
  };
@@ -14,6 +14,7 @@
14
14
  import { setLocaleContext } from '../../context/locale.svelte';
15
15
  import { setTitleContext } from '../../context/title';
16
16
  import { setUserContext } from '../../context/user.svelte';
17
+ import { panelPath } from '../../util/url.js';
17
18
  import type { GenericDoc, User } from '../../../types';
18
19
  import { trycatchFetch } from '../../../util/function';
19
20
  import { snapshot } from '../../../util/state';
@@ -240,13 +241,8 @@
240
241
  const slug = data.slug;
241
242
  const id = data.doc.id;
242
243
 
243
- // Start with the base URI for the panel
244
- let panelUri = `/panel/${toKebabCase(slug)}`;
245
-
246
- // Add the item ID to the URI if we're updating a collection doc
247
- if (id) {
248
- panelUri += `/${id}`;
249
- }
244
+ // Start with the base URI for the panel, adding the item ID if present
245
+ const panelUri = id ? panelPath(toKebabCase(slug), id) : panelPath(toKebabCase(slug));
250
246
  return goto(panelUri);
251
247
  }
252
248
 
@@ -1,6 +1,35 @@
1
1
  /**
2
- * Build a panel url for given segments
2
+ * Build a panel url for given segments. Reads the current panel segment off
3
+ * the live matched route (page.params.panel, resolved by the [panel=panel]
4
+ * matcher) rather than from a public env var — the segment can be configured
5
+ * via RIME_PANEL_ROUTE to hide the panel from admin-path scanners, and that
6
+ * would be defeated by shipping it into every page's public env bundle.
7
+ *
8
+ * Only call this from actual component rendering (.svelte files, or a
9
+ * .svelte.ts context set up during component init) — page.params is bound to
10
+ * the current request via component context and SvelteKit throws if it's read
11
+ * anywhere else, including a +page.server.ts/+layout.server.ts load function
12
+ * or a form action, even though those also run server-side. Every load/action
13
+ * function in this codebase already receives an `event` with `event.params.panel`
14
+ * populated the same way — use panelUrlFor(event.params.panel, ...) there instead.
3
15
  * @example
4
16
  * panelUrl('some-collection') // -> http://localhost:5713/panel/some-collection
5
17
  */
6
18
  export declare function panelUrl(...args: string[]): string;
19
+ /**
20
+ * Same as panelUrl(), but takes the panel segment explicitly instead of
21
+ * reading it off page.params — for any caller that isn't component rendering:
22
+ * every +page.server.ts/+layout.server.ts load function and form action
23
+ * (pass event.params.panel), plus the one hook-level caller that runs before
24
+ * resolve() (buildNavigation(), which gets it forwarded from routes.server.ts).
25
+ */
26
+ export declare function panelUrlFor(panelSegment: string | undefined, ...args: string[]): string;
27
+ /**
28
+ * Same as panelUrl(), but returns a same-origin-relative path instead of an
29
+ * absolute URL — for goto()/form-action targets where PUBLIC_RIME_URL isn't
30
+ * guaranteed to match the actual origin the page was served from (a reverse
31
+ * proxy, differing dev host, etc). Everywhere else (real cross-page <a href>
32
+ * links, window.location.href, emailed reset links) stays absolute, matching
33
+ * apiUrl()'s existing convention.
34
+ */
35
+ export declare function panelPath(...args: string[]): string;
@@ -1,9 +1,43 @@
1
+ import { page } from '$app/state';
1
2
  import { env } from '$env/dynamic/public';
2
3
  /**
3
- * Build a panel url for given segments
4
+ * Build a panel url for given segments. Reads the current panel segment off
5
+ * the live matched route (page.params.panel, resolved by the [panel=panel]
6
+ * matcher) rather than from a public env var — the segment can be configured
7
+ * via RIME_PANEL_ROUTE to hide the panel from admin-path scanners, and that
8
+ * would be defeated by shipping it into every page's public env bundle.
9
+ *
10
+ * Only call this from actual component rendering (.svelte files, or a
11
+ * .svelte.ts context set up during component init) — page.params is bound to
12
+ * the current request via component context and SvelteKit throws if it's read
13
+ * anywhere else, including a +page.server.ts/+layout.server.ts load function
14
+ * or a form action, even though those also run server-side. Every load/action
15
+ * function in this codebase already receives an `event` with `event.params.panel`
16
+ * populated the same way — use panelUrlFor(event.params.panel, ...) there instead.
4
17
  * @example
5
18
  * panelUrl('some-collection') // -> http://localhost:5713/panel/some-collection
6
19
  */
7
20
  export function panelUrl(...args) {
8
- return `${env.PUBLIC_RIME_URL}/panel/${args.join('/')}`;
21
+ return panelUrlFor(page.params.panel, ...args);
22
+ }
23
+ /**
24
+ * Same as panelUrl(), but takes the panel segment explicitly instead of
25
+ * reading it off page.params — for any caller that isn't component rendering:
26
+ * every +page.server.ts/+layout.server.ts load function and form action
27
+ * (pass event.params.panel), plus the one hook-level caller that runs before
28
+ * resolve() (buildNavigation(), which gets it forwarded from routes.server.ts).
29
+ */
30
+ export function panelUrlFor(panelSegment, ...args) {
31
+ return `${env.PUBLIC_RIME_URL}/${panelSegment}/${args.join('/')}`;
32
+ }
33
+ /**
34
+ * Same as panelUrl(), but returns a same-origin-relative path instead of an
35
+ * absolute URL — for goto()/form-action targets where PUBLIC_RIME_URL isn't
36
+ * guaranteed to match the actual origin the page was served from (a reverse
37
+ * proxy, differing dev host, etc). Everywhere else (real cross-page <a href>
38
+ * links, window.location.href, emailed reset links) stays absolute, matching
39
+ * apiUrl()'s existing convention.
40
+ */
41
+ export function panelPath(...args) {
42
+ return `/${page.params.panel}/${args.join('/')}`;
9
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "0.31.4",
3
+ "version": "0.31.5",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "packageManager": "bun@1.3.0",
6
6
  "scripts": {