@docstack/client 0.0.1
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 +214 -0
- package/lib/core/attribute.d.ts +174 -0
- package/lib/core/attribute.js +296 -0
- package/lib/core/attribute.js.map +1 -0
- package/lib/core/class.d.ts +340 -0
- package/lib/core/class.js +540 -0
- package/lib/core/class.js.map +1 -0
- package/lib/core/crypto-engine/index.d.ts +121 -0
- package/lib/core/crypto-engine/index.js +130 -0
- package/lib/core/crypto-engine/index.js.map +1 -0
- package/lib/core/crypto-engine/utils.d.ts +20 -0
- package/lib/core/crypto-engine/utils.js +76 -0
- package/lib/core/crypto-engine/utils.js.map +1 -0
- package/lib/core/datamodel/index.d.ts +3 -0
- package/lib/core/datamodel/index.js +1186 -0
- package/lib/core/datamodel/index.js.map +1 -0
- package/lib/core/domain.d.ts +200 -0
- package/lib/core/domain.js +285 -0
- package/lib/core/domain.js.map +1 -0
- package/lib/core/index.d.ts +176 -0
- package/lib/core/index.js +379 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/job-engine/index.d.ts +110 -0
- package/lib/core/job-engine/index.js +116 -0
- package/lib/core/job-engine/index.js.map +1 -0
- package/lib/core/policy-engine/index.d.ts +97 -0
- package/lib/core/policy-engine/index.js +150 -0
- package/lib/core/policy-engine/index.js.map +1 -0
- package/lib/core/query-engine/accumulators.d.ts +9 -0
- package/lib/core/query-engine/accumulators.js +258 -0
- package/lib/core/query-engine/accumulators.js.map +1 -0
- package/lib/core/query-engine/evaluator.d.ts +37 -0
- package/lib/core/query-engine/evaluator.js +179 -0
- package/lib/core/query-engine/evaluator.js.map +1 -0
- package/lib/core/query-engine/executor.d.ts +14 -0
- package/lib/core/query-engine/executor.js +405 -0
- package/lib/core/query-engine/executor.js.map +1 -0
- package/lib/core/query-engine/index.d.ts +4 -0
- package/lib/core/query-engine/index.js +4 -0
- package/lib/core/query-engine/index.js.map +1 -0
- package/lib/core/query-engine/parser.d.ts +10 -0
- package/lib/core/query-engine/parser.js +515 -0
- package/lib/core/query-engine/parser.js.map +1 -0
- package/lib/core/query-engine/planner.d.ts +27 -0
- package/lib/core/query-engine/planner.js +330 -0
- package/lib/core/query-engine/planner.js.map +1 -0
- package/lib/core/stack.d.ts +497 -0
- package/lib/core/stack.js +1507 -0
- package/lib/core/stack.js.map +1 -0
- package/lib/core/test-utils/docstack.d.ts +29 -0
- package/lib/core/test-utils/docstack.js +222 -0
- package/lib/core/test-utils/docstack.js.map +1 -0
- package/lib/core/trigger/index.d.ts +31 -0
- package/lib/core/trigger/index.js +81 -0
- package/lib/core/trigger/index.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +8237 -0
- package/lib/index.js.map +1 -0
- package/lib/plugins/pouchdb.d.ts +9 -0
- package/lib/plugins/pouchdb.js +403 -0
- package/lib/plugins/pouchdb.js.map +1 -0
- package/lib/utils/crypto/index.d.ts +3 -0
- package/lib/utils/crypto/index.js +34 -0
- package/lib/utils/crypto/index.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +58 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/logger/index.d.ts +4 -0
- package/lib/utils/logger/index.js +20 -0
- package/lib/utils/logger/index.js.map +1 -0
- package/lib/utils/logger/transport.d.ts +11 -0
- package/lib/utils/logger/transport.js +28 -0
- package/lib/utils/logger/transport.js.map +1 -0
- package/lib/workers/dataModel.d.ts +1 -0
- package/lib/workers/dataModel.js +48 -0
- package/lib/workers/dataModel.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../src/core/attribute.ts"],"names":[],"mappings":";AAAA,OAAO,CAAc,MAAM,KAAK,CAAC;AAEjC,OAAO,EAAE,SAAS,IAAI,UAAU,EAAiC,eAAe,EAA+C,MAAM,kBAAkB,CAAC;AAExJ,MAAM,SAAU,SAAQ,UAAU;IAQ9B,YAAY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AAW,EAAE,MAAM,CAAC,CAAC;QAC3E,MAAM,SAAS,CAAC,4BAA4B,EAAE,CAAC;QAC/C,MAAM,EAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAChC,OAAO,SAAS,CAAC;IACrB,CAAC;;;AAwBM,eAAK,GAAG,KAAK,EAAE,YAAuB,EAAE,EAAE;IAC7C,IAAI,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IACvC,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAChC,IAAI,KAAK,EAAE,CAAC;QACR,MAAM,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC1C,OAAO,YAAY,CAAC;IACxB,CAAC;SAAM,CAAC;QACJ,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;AACL,CAAC,AATW,CASX;AAmFL,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { Class as Class_, TriggerModel } from "@docstack/shared";
|
|
2
|
+
import { Stack, ClassModel, AttributeModel, Document } from "@docstack/shared";
|
|
3
|
+
import Attribute from "./attribute.js";
|
|
4
|
+
import { Logger } from 'winston';
|
|
5
|
+
import { Trigger } from "./trigger/index.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Represents a data class (schema definition) in the DocStack database.
|
|
9
|
+
*
|
|
10
|
+
* A Class defines the structure of documents, including their attributes,
|
|
11
|
+
* validation rules (via Zod), and triggers that execute during document operations.
|
|
12
|
+
*
|
|
13
|
+
* Use the static factory methods ({@link Class.create}, {@link Class.fetch}) to
|
|
14
|
+
* instantiate classes - the constructor is private.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Create a new class with schema
|
|
19
|
+
* const taskClass = await Class.create(stack, 'Task', 'class', 'User Tasks');
|
|
20
|
+
*
|
|
21
|
+
* // Add attributes to define the schema
|
|
22
|
+
* await Attribute.create(taskClass, 'title', 'string', 'Task Title', { mandatory: true });
|
|
23
|
+
* await Attribute.create(taskClass, 'isComplete', 'boolean', 'Done?', { defaultValue: false });
|
|
24
|
+
*
|
|
25
|
+
* // Create documents (cards) of this class
|
|
26
|
+
* const task = await taskClass.add({ title: 'My Task', isComplete: false });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @extends Class_
|
|
30
|
+
*/
|
|
31
|
+
declare class Class extends Class_ {
|
|
32
|
+
/** Reference to the parent stack instance. */
|
|
33
|
+
stack: Stack | undefined;
|
|
34
|
+
/** The name of this class (e.g., 'Task', 'User'). */
|
|
35
|
+
name: string;
|
|
36
|
+
/** The class type (e.g., 'class', '~self'). */
|
|
37
|
+
type: ClassModel["~class"];
|
|
38
|
+
/** Optional description of the class purpose. */
|
|
39
|
+
description?: string;
|
|
40
|
+
/** Map of attribute names to Attribute instances defining the schema. */
|
|
41
|
+
attributes: {
|
|
42
|
+
[name: string]: Attribute;
|
|
43
|
+
};
|
|
44
|
+
/** The raw schema definition from the ClassModel. */
|
|
45
|
+
schema: ClassModel["schema"];
|
|
46
|
+
/** Zod schema for runtime validation of document data. */
|
|
47
|
+
schemaZOD: z.ZodObject;
|
|
48
|
+
/** The unique identifier for this class (e.g., 'Task', 'Class-123'). */
|
|
49
|
+
id?: string;
|
|
50
|
+
/** The underlying ClassModel document. */
|
|
51
|
+
model: ClassModel;
|
|
52
|
+
/** Current state indicating if the class is processing an operation. */
|
|
53
|
+
state: "busy" | "idle";
|
|
54
|
+
static logger: Logger;
|
|
55
|
+
logger: Logger;
|
|
56
|
+
/** Array of triggers that execute before/after document operations. */
|
|
57
|
+
triggers: Trigger[];
|
|
58
|
+
private constructor();
|
|
59
|
+
build: () => Promise<Class>;
|
|
60
|
+
init: (stack: Stack | null, id: string, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Gets a Class instance without persisting it to the database.
|
|
63
|
+
* Use this for working with existing class models or for testing.
|
|
64
|
+
* Sets up a document change listener for real-time updates.
|
|
65
|
+
*
|
|
66
|
+
* @param stack - The parent stack instance
|
|
67
|
+
* @param id - The class ID
|
|
68
|
+
* @param name - The class name
|
|
69
|
+
* @param type - The class type
|
|
70
|
+
* @param description - Optional description
|
|
71
|
+
* @param schema - Initial schema definition
|
|
72
|
+
* @returns A new Class instance (not persisted)
|
|
73
|
+
*/
|
|
74
|
+
static get: (stack: Stack, id: string, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => Class;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new class and persists it to the database.
|
|
77
|
+
* This is the primary factory method for creating new classes.
|
|
78
|
+
*
|
|
79
|
+
* @param stack - The parent stack instance
|
|
80
|
+
* @param name - The name for the new class
|
|
81
|
+
* @param type - The class type (typically 'class')
|
|
82
|
+
* @param description - Optional description of the class
|
|
83
|
+
* @param schema - Initial schema definition
|
|
84
|
+
* @returns The persisted Class instance
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const userClass = await Class.create(stack, 'User', 'class', 'Application users');
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
static create: (stack: Stack, name: string, type: ClassModel["~class"], description?: string, schema?: ClassModel["schema"]) => Promise<Class>;
|
|
92
|
+
/**
|
|
93
|
+
* Builds a Class instance from an existing ClassModel document.
|
|
94
|
+
* Hydrates attributes and triggers from the model.
|
|
95
|
+
*
|
|
96
|
+
* @param stack - The parent stack instance
|
|
97
|
+
* @param classModel - The ClassModel document from the database
|
|
98
|
+
* @returns The hydrated Class instance
|
|
99
|
+
*/
|
|
100
|
+
static buildFromModel: (stack: Stack, classModel: ClassModel) => Promise<Class>;
|
|
101
|
+
/**
|
|
102
|
+
* Fetches a class by its document ID.
|
|
103
|
+
*
|
|
104
|
+
* @param stack - The parent stack instance
|
|
105
|
+
* @param classId - The class document ID
|
|
106
|
+
* @returns The Class instance
|
|
107
|
+
* @throws Error if the class is not found
|
|
108
|
+
*/
|
|
109
|
+
static fetchById: (stack: Stack, classId: string) => Promise<Class>;
|
|
110
|
+
/**
|
|
111
|
+
* Fetches a class by its name.
|
|
112
|
+
* This is the most common way to retrieve an existing class.
|
|
113
|
+
*
|
|
114
|
+
* @param stack - The parent stack instance
|
|
115
|
+
* @param className - The class name to fetch
|
|
116
|
+
* @returns The Class instance, or `null` if not found
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const taskClass = await Class.fetch(stack, 'Task');
|
|
121
|
+
* if (taskClass) {
|
|
122
|
+
* const tasks = await taskClass.getCards();
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
static fetch: (stack: Stack, className: string) => Promise<Class>;
|
|
127
|
+
uniqueCheck: (doc: Document) => Promise<boolean>;
|
|
128
|
+
bulkUniqueCheck: (pKs: string[]) => Promise<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Validates document data against the class schema using Zod.
|
|
131
|
+
*
|
|
132
|
+
* @param data - The document data to validate
|
|
133
|
+
* @returns `true` if validation passes, `false` otherwise
|
|
134
|
+
*/
|
|
135
|
+
validate: (data: {
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
}) => Promise<boolean>;
|
|
138
|
+
setId: (id: string) => void;
|
|
139
|
+
getName: () => string;
|
|
140
|
+
getStack: () => Stack;
|
|
141
|
+
getDescription: () => string;
|
|
142
|
+
getType: () => "class" | "~self";
|
|
143
|
+
getId: () => string;
|
|
144
|
+
/**
|
|
145
|
+
* Builds the schema object from the current attributes.
|
|
146
|
+
* @returns The schema definition object
|
|
147
|
+
*/
|
|
148
|
+
buildSchema: () => {
|
|
149
|
+
[name: string]: AttributeModel;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Returns the current ClassModel representation of this class.
|
|
153
|
+
* @returns The ClassModel document
|
|
154
|
+
*/
|
|
155
|
+
getModel: () => ClassModel;
|
|
156
|
+
/**
|
|
157
|
+
* It hydrates attributes and triggers from given model
|
|
158
|
+
* @param model
|
|
159
|
+
*/
|
|
160
|
+
setModel: (model?: ClassModel) => void;
|
|
161
|
+
/**
|
|
162
|
+
* Returns the primary key attribute names for this class.
|
|
163
|
+
* @returns Array of attribute names marked as primary keys
|
|
164
|
+
*/
|
|
165
|
+
getPrimaryKeys: () => string[];
|
|
166
|
+
getAttributes: (...names: string[]) => {
|
|
167
|
+
[name: string]: Attribute;
|
|
168
|
+
};
|
|
169
|
+
hasAllAttributes: (...names: string[]) => boolean;
|
|
170
|
+
hasAnyAttributes: (...names: string[]) => boolean;
|
|
171
|
+
getEncryptedAttributes: () => Attribute[];
|
|
172
|
+
hasAttribute: (name: string) => boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Adds a new attribute to the class schema.
|
|
175
|
+
* Persists the change to the database.
|
|
176
|
+
*
|
|
177
|
+
* @param attribute - The Attribute instance or AttributeModel to add
|
|
178
|
+
* @returns This Class instance for chaining
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* await taskClass.addAttribute(new Attribute(taskClass, 'dueDate', 'date', 'Due Date'));
|
|
183
|
+
* // Or use Attribute.create() for a simpler API
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
addAttribute: (attribute: Attribute | AttributeModel) => Promise<Class>;
|
|
187
|
+
/**
|
|
188
|
+
* Modifies an existing attribute in the class schema.
|
|
189
|
+
*
|
|
190
|
+
* @param name - The name of the attribute to modify
|
|
191
|
+
* @param attribute - The new Attribute or AttributeModel definition
|
|
192
|
+
* @returns This Class instance for chaining
|
|
193
|
+
*/
|
|
194
|
+
modifyAttribute: (name: string, attribute: Attribute | AttributeModel) => Promise<Class>;
|
|
195
|
+
/**
|
|
196
|
+
* Removes an attribute from the class schema.
|
|
197
|
+
*
|
|
198
|
+
* @param name - The name of the attribute to remove
|
|
199
|
+
* @returns This Class instance for chaining
|
|
200
|
+
*/
|
|
201
|
+
removeAttribute: (name: string) => Promise<Class>;
|
|
202
|
+
/**
|
|
203
|
+
* Creates a new document (card) of this class type.
|
|
204
|
+
*
|
|
205
|
+
* @param params - The document data
|
|
206
|
+
* @returns The created document, or `null` if stack is not defined
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const task = await taskClass.addCard({
|
|
211
|
+
* title: 'My Task',
|
|
212
|
+
* isComplete: false
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
addCard: (params: {
|
|
217
|
+
[key: string]: any;
|
|
218
|
+
}) => Promise<Document>;
|
|
219
|
+
/**
|
|
220
|
+
* Creates multiple documents (cards) of this class type in a batch.
|
|
221
|
+
*
|
|
222
|
+
* @param paramsArray - Array of document data objects
|
|
223
|
+
* @returns Array of created documents
|
|
224
|
+
*/
|
|
225
|
+
addCards: (paramsArray: {
|
|
226
|
+
[key: string]: any;
|
|
227
|
+
}[]) => Promise<Document[]>;
|
|
228
|
+
getByPrimaryKeys: (params: {
|
|
229
|
+
[key: string]: any;
|
|
230
|
+
}) => Promise<Document | null>;
|
|
231
|
+
/**
|
|
232
|
+
* Creates one or more documents of this class type.
|
|
233
|
+
* Convenience method that handles both single and batch creation.
|
|
234
|
+
*
|
|
235
|
+
* @param params - Document data (single object for one doc, or multiple for batch)
|
|
236
|
+
* @returns Single document when one param passed, array when multiple
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* // Single document
|
|
241
|
+
* const task = await taskClass.add({ title: 'Task 1' });
|
|
242
|
+
*
|
|
243
|
+
* // Multiple documents
|
|
244
|
+
* const tasks = await taskClass.add(
|
|
245
|
+
* { title: 'Task 1' },
|
|
246
|
+
* { title: 'Task 2' }
|
|
247
|
+
* );
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
add(params: {
|
|
251
|
+
[key: string]: any;
|
|
252
|
+
}): Promise<Document | null>;
|
|
253
|
+
add(...paramsArray: {
|
|
254
|
+
[key: string]: any;
|
|
255
|
+
}[]): Promise<Document[]>;
|
|
256
|
+
addOrUpdateCard: (params: {
|
|
257
|
+
[key: string]: any;
|
|
258
|
+
}, cardId?: string) => Promise<Document>;
|
|
259
|
+
/**
|
|
260
|
+
* Updates an existing document (card) of this class.
|
|
261
|
+
*
|
|
262
|
+
* @param cardId - The document ID to update
|
|
263
|
+
* @param params - The updated document data
|
|
264
|
+
* @returns The updated document, or `null` if stack is not defined
|
|
265
|
+
*/
|
|
266
|
+
updateCard: (cardId: string, params: {
|
|
267
|
+
[key: string]: any;
|
|
268
|
+
}) => Promise<Document>;
|
|
269
|
+
/**
|
|
270
|
+
* Soft-deletes a document by setting its `active` flag to `false`.
|
|
271
|
+
*
|
|
272
|
+
* @param cardId - The document ID to delete
|
|
273
|
+
* @returns `true` if successful, `false` otherwise
|
|
274
|
+
*/
|
|
275
|
+
deleteCard: (cardId: string) => Promise<boolean>;
|
|
276
|
+
/**
|
|
277
|
+
* Retrieves documents (cards) of this class type.
|
|
278
|
+
*
|
|
279
|
+
* @param selector - Optional PouchDB/Mango selector for filtering
|
|
280
|
+
* @param fields - Optional list of fields to return
|
|
281
|
+
* @param skip - Number of documents to skip
|
|
282
|
+
* @param limit - Maximum number of documents to return
|
|
283
|
+
* @returns Array of matching documents
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* // Get all tasks
|
|
288
|
+
* const allTasks = await taskClass.getCards();
|
|
289
|
+
*
|
|
290
|
+
* // Get incomplete tasks
|
|
291
|
+
* const incomplete = await taskClass.getCards({ isComplete: { $eq: false } });
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
getCards: (selector?: {
|
|
295
|
+
[key: string]: any;
|
|
296
|
+
}, fields?: string[], skip?: number, limit?: number) => Promise<Document[]>;
|
|
297
|
+
/**
|
|
298
|
+
* Retrieves one or more documents by their IDs.
|
|
299
|
+
*
|
|
300
|
+
* @param cardId - Single ID or multiple IDs to fetch
|
|
301
|
+
* @returns Single document (or null) when one ID passed, array when multiple
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* // Get single document
|
|
306
|
+
* const task = await taskClass.get('Task-123');
|
|
307
|
+
*
|
|
308
|
+
* // Get multiple documents
|
|
309
|
+
* const tasks = await taskClass.get('Task-1', 'Task-2', 'Task-3');
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
get(cardId: string): Promise<Document | null>;
|
|
313
|
+
get(...cardId: string[]): Promise<Document[]>;
|
|
314
|
+
/**
|
|
315
|
+
* Adds a trigger to this class.
|
|
316
|
+
* Triggers execute before or after document operations.
|
|
317
|
+
*
|
|
318
|
+
* @param name - The trigger name
|
|
319
|
+
* @param model - The trigger model containing the execution logic
|
|
320
|
+
* @returns This Class instance for chaining
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* await taskClass.addTrigger('generate-slug', {
|
|
325
|
+
* name: 'generate-slug',
|
|
326
|
+
* order: 'before',
|
|
327
|
+
* run: `document.slug = document.title.toLowerCase().replace(/\\s+/g, '-'); return document;`
|
|
328
|
+
* });
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
addTrigger: (name: string, model: TriggerModel) => Promise<this>;
|
|
332
|
+
/**
|
|
333
|
+
* Removes a trigger from this class by name.
|
|
334
|
+
*
|
|
335
|
+
* @param name - The name of the trigger to remove
|
|
336
|
+
* @returns This Class instance for chaining
|
|
337
|
+
*/
|
|
338
|
+
removeTrigger: (name: string) => Promise<this>;
|
|
339
|
+
}
|
|
340
|
+
export default Class;
|