hekireki 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -129,7 +129,7 @@ model Like {
129
129
 
130
130
  ## Generate
131
131
 
132
- ### Zod
132
+ ## Zod
133
133
 
134
134
  ```ts
135
135
  import { z } from 'zod'
@@ -294,9 +294,9 @@ export type Like = v.InferInput<typeof LikeSchema>
294
294
 
295
295
  ```mermaid
296
296
  erDiagram
297
- User ||--o{ Post : "(id) - (userId)"
298
- Post ||--o{ Like : "(id) - (postId)"
299
- User ||--o{ Like : "(id) - (userId)"
297
+ User ||--|{ Post : "(id) - (userId)"
298
+ Post ||--|{ Like : "(id) - (postId)"
299
+ User ||--|{ Like : "(id) - (userId)"
300
300
  User {
301
301
  String id "Unique identifier for the user."
302
302
  String username "Username of the user."
@@ -1,8 +1,7 @@
1
1
  import type { Relation } from "../type";
2
2
  /**
3
3
  * generate relation line
4
- * @function generateRelationLine
5
- * @param relation
6
- * @returns string
4
+ * @param { Relation } relation
5
+ * @returns { string } relation line
7
6
  */
8
7
  export declare function generateRelationLine(relation: Relation): string;
@@ -4,9 +4,8 @@ exports.generateRelationLine = generateRelationLine;
4
4
  const __1 = require("..");
5
5
  /**
6
6
  * generate relation line
7
- * @function generateRelationLine
8
- * @param relation
9
- * @returns string
7
+ * @param { Relation } relation
8
+ * @returns { string } relation line
10
9
  */
11
10
  function generateRelationLine(relation) {
12
11
  const cardinality = __1.CARDINALITY_MAP[relation.type];
@@ -12,38 +12,32 @@ const DEFAULT_CONFIG = {
12
12
  };
13
13
  exports.CARDINALITY_MAP = {
14
14
  // Required Relationships
15
- // Both sides required (one-to-one)
16
15
  "one-to-one": "||--||", // 1 --- 1
17
- // One side singular, the other multiple
18
- "one-to-many": "||--o{", // 1 --- * (also known as one-to-zero-many)
19
- "many-to-one": "}o--||", // * --- 1
20
- // Both sides multiple (many-to-many)
21
- "many-to-many": "}o--o{", // * --- *
22
- // One side required, one side optional (0..1)
16
+ "one-to-many": "||--|{", // 1 --- 0..*
17
+ "many-to-one": "}|--||", // * --- 1
18
+ "many-to-many": "}|--|{", // * --- *
23
19
  "one-to-zero-one": "||--o|", // 1 --- 0..1
24
20
  "zero-one-to-one": "o|--||", // 0..1 --- 1
25
- // Both sides optional singular (0..1 on both sides)
26
21
  "zero-to-one": "o|--o|", // 0..1 --- 0..1
27
22
  "zero-to-zero-one": "o|--o|", // Alias for zero-to-one
28
- // One side optional singular, the other multiple
29
- "zero-to-many": "o|--o{", // 0 --- *
23
+ "zero-to-many": "o|--o{", // 0..1 --- 0..*
30
24
  "zero-one-to-many": "o|--o{", // 0..1 --- *
31
- "many-to-zero-one": "}o--o|", // * --- 0..1
32
- // Optional Relationships (using dotted lines)
33
- "one-to-one-optional": "||..||", // 1..1
34
- "one-to-many-optional": "||..o{", // 1..*
35
- "many-to-one-optional": "}o..||", // *..1
36
- "many-to-many-optional": "}o..o{", // *..*
37
- "one-to-zero-one-optional": "||..o|", // 1..0..1
38
- "zero-one-to-one-optional": "o|..||", // 0..1..1
39
- "zero-to-one-optional": "o|..o|", // 0..1 (both sides optional singular)
40
- "zero-to-many-optional": "o|..o{", // 0..* (optional multiple)
41
- "zero-one-to-many-optional": "o|..o{", // 0..1 --- * (optional)
42
- "many-to-zero-one-optional": "}o..o|", // *..0..1
25
+ "many-to-zero-one": "}|--o|", // * --- 0..1
26
+ // Optional Relationships (dotted lines)
27
+ "one-to-one-optional": "||..||", // 1 --- 1 optional
28
+ "one-to-many-optional": "||..o{", // 1 --- 0..* optional
29
+ "many-to-one-optional": "}|..||", // * --- 1 optional
30
+ "many-to-many-optional": "}|..o{", // * --- 0..* optional
31
+ "one-to-zero-one-optional": "||..o|", // 1 --- 0..1 optional
32
+ "zero-one-to-one-optional": "o|..||", // 0..1 --- 1 optional
33
+ "zero-to-one-optional": "o|..o|", // 0..1 --- 0..1 optional
34
+ "zero-to-many-optional": "o|..o{", // 0..1 --- 0..* optional
35
+ "zero-one-to-many-optional": "o|..o{", // 0..1 --- * optional
36
+ "many-to-zero-one-optional": "}|..o|", // * --- 0..1 optional
43
37
  // Nuanced Patterns (Aliases)
44
- "many-to-zero-many": "}o..o{", // * --- 0..* (equivalent to many-to-many-optional)
45
- "zero-many-to-many": "o{..}o", // 0..* --- * (left side optional multiple, right side required multiple)
46
- "zero-many-to-zero-many": "o{..o{", // both sides optional multiple
38
+ "many-to-zero-many": "}|..o{", // * --- 0..*
39
+ "zero-many-to-many": "o{--|{", // 0..* --- *
40
+ "zero-many-to-zero-many": "o{--o{", // 0..* --- 0..*
47
41
  };
48
42
  // ER diagram header
49
43
  exports.ER_HEADER = ["```mermaid", "erDiagram"];
@@ -1,8 +1,7 @@
1
1
  import type { Model } from "../type";
2
2
  /**
3
3
  * extract relations from model
4
- * @function extractRelations
5
- * @param model
6
- * @returns
4
+ * @param { Model } model
5
+ * @returns { readonly string[] }
7
6
  */
8
7
  export declare function extractRelations(model: Model): readonly string[];
@@ -5,13 +5,12 @@ const generate_relation_line_1 = require("../generator/generate-relation-line");
5
5
  const parse_relation_1 = require("./parse-relation");
6
6
  /**
7
7
  * extract relations from model
8
- * @function extractRelations
9
- * @param model
10
- * @returns
8
+ * @param { Model } model
9
+ * @returns { readonly string[] }
11
10
  */
12
11
  function extractRelations(model) {
13
12
  const relations = [];
14
- // @r annotation
13
+ // @relation annotation
15
14
  if (model.documentation) {
16
15
  const annotationRelations = model.documentation
17
16
  .split("\n")
@@ -1,2 +1,7 @@
1
1
  import type { RelationType } from "../type";
2
+ /**
3
+ * check if the value is a valid relation
4
+ * @param { unknown } value
5
+ * @returns { boolean }
6
+ */
2
7
  export declare function isRelation(value: unknown): value is RelationType;
@@ -27,6 +27,11 @@ const VALID_RELATIONS = new Set([
27
27
  "zero-many-to-many",
28
28
  "zero-many-to-zero-many",
29
29
  ]);
30
+ /**
31
+ * check if the value is a valid relation
32
+ * @param { unknown } value
33
+ * @returns { boolean }
34
+ */
30
35
  function isRelation(value) {
31
36
  return typeof value === "string" && VALID_RELATIONS.has(value);
32
37
  }
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * remove duplicate relations
3
- * @function removeDuplicateRelations
4
- * @param relations
5
- * @returns
3
+ * @param { readonly string[] } relations
4
+ * @returns { readonly string[] }
6
5
  */
7
6
  export declare function removeDuplicateRelations(relations: readonly string[]): readonly string[];
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeDuplicateRelations = removeDuplicateRelations;
4
4
  /**
5
5
  * remove duplicate relations
6
- * @function removeDuplicateRelations
7
- * @param relations
8
- * @returns
6
+ * @param { readonly string[] } relations
7
+ * @returns { readonly string[] }
9
8
  */
10
9
  function removeDuplicateRelations(relations) {
11
10
  return [...new Set(relations)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hekireki",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "license": "MIT",
5
5
  "description": "Hekireki is a tool that generates validation schemas for Zod and Valibot, as well as ER diagrams, from Prisma schemas annotated with comments.",
6
6
  "keywords": [