@skaldapp/shared 1.2.45 → 1.2.47

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/index.d.ts CHANGED
@@ -22,10 +22,9 @@ export type TPage = FromSchema<typeof Page> & {
22
22
  to?: string;
23
23
  };
24
24
  export declare const sharedStore: {
25
- $nodes: TPage[];
26
- isRedirect: ({ branch, id, siblings }: TPage) => unknown;
27
25
  kvNodes: Record<string, TPage>;
28
26
  nodes: TPage[];
27
+ removeHiddens: (pages: TPage[], redirects?: boolean) => TPage[];
29
28
  add: (pId: string) => string | undefined;
30
29
  addChild: (pId: string) => string | undefined;
31
30
  down: (pId: string) => string | undefined;
package/dist/index.js CHANGED
@@ -2,11 +2,19 @@ import useFlatJsonTree from "@skaldapp/flat-json-tree";
2
2
  import AJV from "ajv";
3
3
  import dynamicDefaults from "ajv-keywords/dist/definitions/dynamicDefaults.js";
4
4
  import { generateSlug } from "random-word-slugs";
5
- import { computed, reactive, ref, toRef, watch } from "vue";
5
+ import { reactive, ref, toRef, watch } from "vue";
6
6
  import Credential from "./schemas/credential.js";
7
7
  import Nodes from "./schemas/nodes.js";
8
8
  import Page from "./schemas/page.js";
9
9
  dynamicDefaults.DEFAULTS["uuid"] = () => generateSlug;
10
+ const removeHiddens = (pages, redirects) => pages.filter(({ branch, frontmatter: { hidden }, id, path, siblings }) => path !== undefined &&
11
+ !hidden &&
12
+ (!redirects ||
13
+ !branch
14
+ .slice(0, -1)
15
+ .reverse()
16
+ .find(({ frontmatter: { hidden } }) => !hidden)?.frontmatter["template"] ||
17
+ siblings.find(({ frontmatter: { hidden } }) => !hidden)?.id !== id));
10
18
  const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefaults()], removeAdditional = true, schemas = [Nodes, Page], useDefaults = true, ajv = new AJV({
11
19
  code,
12
20
  coerceTypes,
@@ -14,18 +22,15 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
14
22
  removeAdditional,
15
23
  schemas,
16
24
  useDefaults,
17
- }), immediate = true, isRedirect = ({ branch, id, siblings }) => branch
18
- .slice(0, -1)
19
- .reverse()
20
- .find(({ frontmatter: { hidden } }) => !hidden)?.frontmatter["template"] && siblings.find(({ frontmatter: { hidden } }) => !hidden)?.id === id, properties = {
25
+ }), immediate = true, properties = {
21
26
  $branch: {
22
27
  get() {
23
- return this.branch.filter(({ frontmatter: { hidden } }) => !hidden);
28
+ return removeHiddens(this.branch, true);
24
29
  },
25
30
  },
26
31
  $children: {
27
32
  get() {
28
- return this.children.filter(({ frontmatter: { hidden } }) => !hidden);
33
+ return removeHiddens(this.children, true);
29
34
  },
30
35
  },
31
36
  $index: {
@@ -50,7 +55,7 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
50
55
  },
51
56
  $siblings: {
52
57
  get() {
53
- return this.siblings.filter(({ frontmatter: { hidden } }) => !hidden);
58
+ return removeHiddens(this.siblings, true);
54
59
  },
55
60
  },
56
61
  path: {
@@ -70,14 +75,12 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
70
75
  },
71
76
  },
72
77
  }, tree = ref([]), validate = Object.fromEntries(schemas.map(({ $id }) => [$id, ajv.getSchema($id)])), { kvNodes, nodes, ...flatJsonTree } = useFlatJsonTree(tree);
73
- const $nodes = computed(() => nodes.value.filter((node) => node.path !== undefined && !node.frontmatter["hidden"]));
74
78
  export const sharedStore = reactive({
75
79
  tree,
76
80
  ...flatJsonTree,
77
- $nodes,
78
- isRedirect,
79
81
  kvNodes: kvNodes,
80
82
  nodes: nodes,
83
+ removeHiddens,
81
84
  });
82
85
  watch(toRef(sharedStore, "nodes"), async (value) => {
83
86
  if (!(await validate["nodes"]?.(value)))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://www.schemastore.org/package",
3
3
  "name": "@skaldapp/shared",
4
- "version": "1.2.45",
4
+ "version": "1.2.47",
5
5
  "description": "A TypeScript library providing reactive data structures, JSON schema validation, and tree utilities for Vue-based applications in the skald ecosystem.",
6
6
  "keywords": [
7
7
  "vue",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "prettier": "@skaldapp/configs/prettierrc",
35
35
  "dependencies": {
36
- "@skaldapp/flat-json-tree": "^2.2.31",
36
+ "@skaldapp/flat-json-tree": "^2.2.32",
37
37
  "ajv": "^8.17.1",
38
38
  "ajv-keywords": "^5.1.0",
39
39
  "json-schema-to-ts": "^3.1.1",
@@ -41,7 +41,7 @@
41
41
  "vue": "^3.5.28"
42
42
  },
43
43
  "devDependencies": {
44
- "@skaldapp/configs": "^1.2.58",
44
+ "@skaldapp/configs": "^1.2.59",
45
45
  "@types/node": "^25.2.3",
46
46
  "eslint": "^9.39.2"
47
47
  }