@docstack/client 0.0.2 → 0.0.4

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,9 +1,10 @@
1
1
  import { Class as Class_, TriggerModel } from "@docstack/shared";
2
- import { Stack, ClassModel, AttributeModel, Document } from "@docstack/shared";
2
+ import { ClassModel, AttributeModel, Document } from "@docstack/shared";
3
3
  import Attribute from "./attribute";
4
4
  import { Logger } from 'winston';
5
5
  import { Trigger } from "./trigger/index";
6
6
  import { z } from "zod";
7
+ import ClientStack from "./stack";
7
8
  /**
8
9
  * Represents a data class (schema definition) in the DocStack database.
9
10
  *
@@ -30,7 +31,7 @@ import { z } from "zod";
30
31
  */
31
32
  declare class Class extends Class_ {
32
33
  /** Reference to the parent stack instance. */
33
- stack: Stack | undefined;
34
+ stack: ClientStack | undefined;
34
35
  /** The name of this class (e.g., 'Task', 'User'). */
35
36
  name: string;
36
37
  /** The class type (e.g., 'class', '~self'). */
@@ -57,7 +58,7 @@ declare class Class extends Class_ {
57
58
  triggers: Trigger[];
58
59
  private constructor();
59
60
  build: () => Promise<Class>;
60
- init: (stack: Stack | null, id: string, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => void;
61
+ init: (stack: ClientStack | null, id: string, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => void;
61
62
  /**
62
63
  * Gets a Class instance without persisting it to the database.
63
64
  * Use this for working with existing class models or for testing.
@@ -71,7 +72,7 @@ declare class Class extends Class_ {
71
72
  * @param schema - Initial schema definition
72
73
  * @returns A new Class instance (not persisted)
73
74
  */
74
- static get: (stack: Stack, id: string, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => Class;
75
+ static get: (stack: ClientStack, id: string, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => Class;
75
76
  /**
76
77
  * Creates a new class and persists it to the database.
77
78
  * This is the primary factory method for creating new classes.
@@ -88,7 +89,7 @@ declare class Class extends Class_ {
88
89
  * const userClass = await Class.create(stack, 'User', 'class', 'Application users');
89
90
  * ```
90
91
  */
91
- static create: (stack: Stack, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => Promise<Class>;
92
+ static create: (stack: ClientStack, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => Promise<Class>;
92
93
  /**
93
94
  * Builds a Class instance from an existing ClassModel document.
94
95
  * Hydrates attributes and triggers from the model.
@@ -97,7 +98,7 @@ declare class Class extends Class_ {
97
98
  * @param classModel - The ClassModel document from the database
98
99
  * @returns The hydrated Class instance
99
100
  */
100
- static buildFromModel: (stack: Stack, classModel: ClassModel) => Promise<Class>;
101
+ static buildFromModel: (stack: ClientStack, classModel: ClassModel) => Promise<Class>;
101
102
  /**
102
103
  * Fetches a class by its document ID.
103
104
  *
@@ -106,7 +107,7 @@ declare class Class extends Class_ {
106
107
  * @returns The Class instance
107
108
  * @throws Error if the class is not found
108
109
  */
109
- static fetchById: (stack: Stack, classId: string) => Promise<Class>;
110
+ static fetchById: (stack: ClientStack, classId: string) => Promise<Class>;
110
111
  /**
111
112
  * Fetches a class by its name.
112
113
  * This is the most common way to retrieve an existing class.
@@ -123,7 +124,7 @@ declare class Class extends Class_ {
123
124
  * }
124
125
  * ```
125
126
  */
126
- static fetch: (stack: Stack, className: string) => Promise<Class>;
127
+ static fetch: (stack: ClientStack, className: string) => Promise<Class>;
127
128
  uniqueCheck: (doc: Document) => Promise<boolean>;
128
129
  bulkUniqueCheck: (pKs: string[]) => Promise<boolean>;
129
130
  /**
@@ -137,9 +138,9 @@ declare class Class extends Class_ {
137
138
  }) => Promise<boolean>;
138
139
  setId: (id: string) => void;
139
140
  getName: () => string;
140
- getStack: () => Stack;
141
+ getStack: () => ClientStack;
141
142
  getDescription: () => string;
142
- getType: () => "class" | "~self";
143
+ getType: () => "~self" | "class";
143
144
  getId: () => string;
144
145
  /**
145
146
  * Builds the schema object from the current attributes.
@@ -1,4 +1,5 @@
1
1
  import { Document, Domain as Domain_, DomainModel, Stack, DomainRelationValidation, DomainRelationParams, Class, RelationDocument } from "@docstack/shared";
2
+ import ClientStack from "./stack";
2
3
  import { Logger } from "winston";
3
4
  /**
4
5
  * Represents a relationship definition between two Classes in the DocStack database.
@@ -31,7 +32,7 @@ import { Logger } from "winston";
31
32
  */
32
33
  declare class Domain extends Domain_ {
33
34
  /** Reference to the parent stack instance. */
34
- stack: Stack | undefined;
35
+ stack: ClientStack | undefined;
35
36
  /** The name of this domain (e.g., 'ProjectTasks'). */
36
37
  name: string;
37
38
  /** The domain type (typically 'domain'). */
@@ -53,12 +54,12 @@ declare class Domain extends Domain_ {
53
54
  static logger: Logger;
54
55
  logger: Logger;
55
56
  private constructor();
56
- getStack: () => Stack;
57
+ getStack: () => ClientStack;
57
58
  getName: () => string;
58
59
  setId: (id: string) => void;
59
60
  setModel: (model?: DomainModel) => void;
60
61
  build: () => Promise<Domain>;
61
- init: (stack: Stack | null, id: string | null, name: string, type: DomainModel["~class"], relation: typeof this.relation, sourceClass: Class, targetClass: Class, description?: string) => void;
62
+ init: (stack: ClientStack | null, id: string | null, name: string, type: DomainModel["~class"], relation: typeof this.relation, sourceClass: Class, targetClass: Class, description?: string) => void;
62
63
  /**
63
64
  * Gets a Domain instance without persisting it to the database.
64
65
  * Use this for working with existing domain models or for testing.
@@ -75,7 +76,7 @@ declare class Domain extends Domain_ {
75
76
  * @param schema - Optional schema definition
76
77
  * @returns A new Domain instance (not persisted)
77
78
  */
78
- static get: (stack: Stack, id: string | null, name: string, type: DomainModel["~class"], relation: "1:1" | "1:N" | "N:1" | "N:N", sourceClass: Class, targetClass: Class, description?: string, schema?: DomainModel["schema"]) => Domain;
79
+ static get: (stack: ClientStack, id: string | null, name: string, type: DomainModel["~class"], relation: "1:1" | "1:N" | "N:1" | "N:N", sourceClass: Class, targetClass: Class, description?: string, schema?: DomainModel["schema"]) => Domain;
79
80
  /**
80
81
  * Creates a new domain and persists it to the database.
81
82
  * This is the primary factory method for creating new domains.
@@ -99,7 +100,7 @@ declare class Domain extends Domain_ {
99
100
  * );
100
101
  * ```
101
102
  */
102
- static create: (stack: Stack, id: string | null, name: string, type: DomainModel["~class"], relation: "1:1" | "1:N" | "N:1" | "N:N", sourceClass: Class, targetClass: Class, description?: string, schema?: DomainModel["schema"]) => Promise<Domain>;
103
+ static create: (stack: ClientStack, id: string | null, name: string, type: DomainModel["~class"], relation: "1:1" | "1:N" | "N:1" | "N:N", sourceClass: Class, targetClass: Class, description?: string, schema?: DomainModel["schema"]) => Promise<Domain>;
103
104
  /**
104
105
  * Builds a Domain instance from an existing DomainModel document.
105
106
  * Fetches the source and target classes and hydrates the domain.
@@ -109,7 +110,7 @@ declare class Domain extends Domain_ {
109
110
  * @returns The hydrated Domain instance
110
111
  * @throws Error if source or target class is not found
111
112
  */
112
- static buildFromModel: (stack: Stack, domainModel: DomainModel) => Promise<Domain>;
113
+ static buildFromModel: (stack: ClientStack, domainModel: DomainModel) => Promise<Domain>;
113
114
  /**
114
115
  * Fetches a domain by its name.
115
116
  * This is the most common way to retrieve an existing domain.
@@ -126,7 +127,7 @@ declare class Domain extends Domain_ {
126
127
  * }
127
128
  * ```
128
129
  */
129
- static fetch: (stack: Stack, domainName: string) => Promise<Domain>;
130
+ static fetch: (stack: ClientStack, domainName: string) => Promise<Domain>;
130
131
  /**
131
132
  * Returns the current DomainModel representation of this domain.
132
133
  * @returns The DomainModel document