@docstack/client 0.1.5 → 0.1.8
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/LICENSE +10 -0
- package/README.md +1 -1
- package/lib/core/attribute.d.ts +11 -2
- package/lib/core/class.d.ts +29 -6
- package/lib/core/content-transfer.d.ts +178 -0
- package/lib/core/crypto-engine/index.d.ts +82 -1
- package/lib/core/crypto-engine/utils.d.ts +36 -1
- package/lib/core/datamodel/index.d.ts +16 -0
- package/lib/core/domain.d.ts +1 -1
- package/lib/core/guarded-db.d.ts +53 -0
- package/lib/core/index.d.ts +138 -2
- package/lib/core/job-engine/schedule.d.ts +90 -0
- package/lib/core/job-engine/scheduler.d.ts +206 -0
- package/lib/core/policy-engine/index.d.ts +35 -0
- package/lib/core/query-engine/classes.d.ts +24 -0
- package/lib/core/query-engine/executor.d.ts +11 -0
- package/lib/core/query-engine/index.d.ts +2 -1
- package/lib/core/query-engine/planner.d.ts +19 -0
- package/lib/core/stack.d.ts +690 -7
- package/lib/core/sync/class-filter.d.ts +106 -0
- package/lib/core/sync/filter-identity.d.ts +53 -0
- package/lib/core/sync/index.d.ts +352 -0
- package/lib/core/sync/internal-docs.d.ts +159 -0
- package/lib/core/sync/tenants.d.ts +67 -0
- package/lib/index.d.ts +38 -1
- package/lib/index.js +5865 -664
- package/lib/index.umd.js +5903 -681
- package/lib/plugins/pouchdb.d.ts +43 -3
- package/lib/utils/logger/index.d.ts +28 -4
- package/lib/utils/logger/transport.d.ts +52 -11
- package/package.json +18 -10
- package/lib/core/attribute.js +0 -406
- package/lib/core/attribute.js.map +0 -1
- package/lib/core/class.js +0 -774
- package/lib/core/class.js.map +0 -1
- package/lib/core/crypto-engine/index.js +0 -229
- package/lib/core/crypto-engine/index.js.map +0 -1
- package/lib/core/crypto-engine/utils.js +0 -88
- package/lib/core/crypto-engine/utils.js.map +0 -1
- package/lib/core/datamodel/index.js +0 -1308
- package/lib/core/datamodel/index.js.map +0 -1
- package/lib/core/domain.js +0 -423
- package/lib/core/domain.js.map +0 -1
- package/lib/core/index.js +0 -532
- package/lib/core/index.js.map +0 -1
- package/lib/core/job-engine/index.js +0 -220
- package/lib/core/job-engine/index.js.map +0 -1
- package/lib/core/policy-engine/index.js +0 -232
- package/lib/core/policy-engine/index.js.map +0 -1
- package/lib/core/query-engine/accumulators.js +0 -258
- package/lib/core/query-engine/accumulators.js.map +0 -1
- package/lib/core/query-engine/evaluator.js +0 -179
- package/lib/core/query-engine/evaluator.js.map +0 -1
- package/lib/core/query-engine/executor.js +0 -405
- package/lib/core/query-engine/executor.js.map +0 -1
- package/lib/core/query-engine/index.js +0 -4
- package/lib/core/query-engine/index.js.map +0 -1
- package/lib/core/query-engine/parser.js +0 -515
- package/lib/core/query-engine/parser.js.map +0 -1
- package/lib/core/query-engine/planner.js +0 -330
- package/lib/core/query-engine/planner.js.map +0 -1
- package/lib/core/stack.js +0 -1827
- package/lib/core/stack.js.map +0 -1
- package/lib/core/test-utils/docstack.js +0 -222
- package/lib/core/test-utils/docstack.js.map +0 -1
- package/lib/core/trigger/index.js +0 -81
- package/lib/core/trigger/index.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/plugins/pouchdb.js +0 -412
- package/lib/plugins/pouchdb.js.map +0 -1
- package/lib/utils/crypto/index.js +0 -34
- package/lib/utils/crypto/index.js.map +0 -1
- package/lib/utils/index.js +0 -58
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/logger/index.js +0 -20
- package/lib/utils/logger/index.js.map +0 -1
- package/lib/utils/logger/transport.js +0 -28
- package/lib/utils/logger/transport.js.map +0 -1
- package/lib/workers/dataModel.js +0 -48
- package/lib/workers/dataModel.js.map +0 -1
package/lib/plugins/pouchdb.d.ts
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import type { StackPluginType } from "@docstack/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Raised when a locked stack is asked to write a class carrying encrypted attributes.
|
|
4
|
+
*
|
|
5
|
+
* A stack is locked when encryption is enabled but no document key has been supplied.
|
|
6
|
+
* Writing then would store the encrypted fields as plaintext, so the write is refused.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* await secretClass.addCard({ ssn: "..." });
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* error instanceof StackLockedError; // true - call stack.unlock(key) first
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class StackLockedError extends Error {
|
|
18
|
+
name: string;
|
|
19
|
+
/** The class the refused document belongs to. */
|
|
20
|
+
readonly className: string;
|
|
21
|
+
constructor(className: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the effective `new_edits` flag for a `bulkDocs` call.
|
|
25
|
+
*
|
|
26
|
+
* `pouchdb-core` accepts it either on the request body or on the options object and
|
|
27
|
+
* normalizes the two before handing over to the adapter. {@link StackPlugin} replaces
|
|
28
|
+
* `bulkDocs` outright, so it never sees that normalization and has to repeat it -
|
|
29
|
+
* reading only `options.new_edits` misses every write `pouchdb-replication` makes.
|
|
30
|
+
*
|
|
31
|
+
* @param docs - The `bulkDocs` request: an array of documents or a `{ docs }` envelope.
|
|
32
|
+
* @param options - The `bulkDocs` options object, possibly `null`.
|
|
33
|
+
* @returns The resolved flag; `true` when neither side carries one.
|
|
34
|
+
*/
|
|
35
|
+
export declare const readNewEdits: (docs: unknown, options?: (PouchDB.Core.BulkDocsOptions & {
|
|
36
|
+
new_edits?: boolean;
|
|
37
|
+
}) | null) => boolean;
|
|
2
38
|
/**
|
|
3
39
|
* Plugin Factory method that returns a PouchDB plugin object
|
|
4
40
|
* which performs on documents (before) triggers and validation against
|
|
5
|
-
* their class schema
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
41
|
+
* their class schema.
|
|
42
|
+
*
|
|
43
|
+
* @param pouch - The PouchDB constructor, for adapter-level lookups.
|
|
44
|
+
* @param stack - The stack the wrapped database belongs to.
|
|
45
|
+
* @param pristine - The database's own `bulkDocs`/`bulkGet`, captured before this plugin
|
|
46
|
+
* replaced them. Handed in rather than looked up, because both places it could be looked
|
|
47
|
+
* up are wrong - see {@link StackPluginType} and ADR-0019.
|
|
8
48
|
*/
|
|
9
49
|
export declare const StackPlugin: StackPluginType;
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { LogFields, Logger, LogLevel, Stack } from "@docstack/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Structured logging for a browser-first package.
|
|
4
|
+
*
|
|
5
|
+
* This replaced winston, which was the only reason `@docstack/client` needed Node core
|
|
6
|
+
* modules at all: `fs`, `http`, `https`, `os`, `path`, `util` and `zlib` directly, plus
|
|
7
|
+
* `stream`, `buffer`, `process` and the rest through `logform` and `readable-stream`.
|
|
8
|
+
* Every consumer had to configure a bundler around that - `resolve.fallback` entries, a
|
|
9
|
+
* `ProvidePlugin` for `process` and `Buffer`, and a rule to strip `node:` prefixes - to
|
|
10
|
+
* use a library that never leaves the browser. What was actually used of winston was
|
|
11
|
+
* `createLogger`, `.child()` and three level methods, so the dependency bought nothing
|
|
12
|
+
* the twenty lines below do not.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here is exported from the package; log output is the only observable change.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
export type { LogFields, Logger, LogLevel };
|
|
19
|
+
/**
|
|
20
|
+
* Creates a logger, optionally recording into a stack.
|
|
21
|
+
*
|
|
22
|
+
* @param stack - When given, log records are also written into the stack's database, the
|
|
23
|
+
* way the winston `PouchDBTransport` did, and the stack's `logLevel` option governs how
|
|
24
|
+
* much this logger emits - `"silent"` for none at all.
|
|
25
|
+
* @returns A logger with no accumulated context; call `.child()` to add some.
|
|
26
|
+
*/
|
|
27
|
+
declare const createLogger: (stack?: Stack | null) => Logger;
|
|
28
|
+
export default createLogger;
|
|
@@ -1,11 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Stack } from "@docstack/shared";
|
|
2
|
+
/**
|
|
3
|
+
* The id prefix every log record carries.
|
|
4
|
+
*
|
|
5
|
+
* Records used to be written with `db.post` and a bare `{ log }` payload, which gives a
|
|
6
|
+
* random id and no field any filter can match on - so every record replicated. On one
|
|
7
|
+
* measured remote, 111 of 134 documents were log records, pushed by every client and
|
|
8
|
+
* pulled by every other. See ADR-0023.
|
|
9
|
+
*
|
|
10
|
+
* A prefix rather than a `~class`: a `~class` makes the document `isDocument()` to
|
|
11
|
+
* `StackPlugin`, which then demands a class model for it and rejects the write. The
|
|
12
|
+
* prefix reaches `INTERNAL_DOC_ID_PREFIXES` - where `~lock-` already lives - and touches
|
|
13
|
+
* nothing on the write path.
|
|
14
|
+
*/
|
|
15
|
+
export declare const LOG_RECORD_ID_PREFIX = "~log-";
|
|
16
|
+
/**
|
|
17
|
+
* The ephemeral class log records belong to.
|
|
18
|
+
*
|
|
19
|
+
* Declared by system patch `0.0.15`. Diagnostics written before that patch has applied -
|
|
20
|
+
* during a stack's own startup - cannot be stored and are dropped by the sink's existing
|
|
21
|
+
* catch; they still reach the console.
|
|
22
|
+
*/
|
|
23
|
+
export declare const LOG_RECORD_CLASS = "~Log";
|
|
24
|
+
/** A finished log line: level, message, and whatever context was attached. */
|
|
25
|
+
export type LogRecord = {
|
|
26
|
+
level: "error" | "warn" | "info" | "debug";
|
|
27
|
+
message: string;
|
|
28
|
+
[field: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Writes log records into a stack's own database.
|
|
32
|
+
*
|
|
33
|
+
* Previously a `winston-transport` subclass. The base class contributed a Node stream
|
|
34
|
+
* (and with it `readable-stream`, `buffer` and `process`) in exchange for `super(opts)`
|
|
35
|
+
* and an `emit('logged')` nothing listened to, so it is gone; the useful part, one
|
|
36
|
+
* `db.post` per record, is below.
|
|
37
|
+
*
|
|
38
|
+
* Failures are swallowed deliberately. Logging is not the caller's operation, and a
|
|
39
|
+
* rejected write here - a closed database mid-teardown, most often - must not surface as
|
|
40
|
+
* a failure of whatever was being logged about.
|
|
41
|
+
*
|
|
42
|
+
* @param stack - The stack whose database receives the records.
|
|
43
|
+
* @returns A sink to hand {@link createLogger}.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const sink = createStackSink(stack);
|
|
48
|
+
* sink({ level: "warn", message: "slow query", ms: 1200 });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const createStackSink: (stack: Stack) => (record: LogRecord) => void;
|
|
52
|
+
export default createStackSink;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docstack/client",
|
|
3
3
|
"description": "One does not simply stack documents.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -13,13 +13,18 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib"
|
|
18
|
+
],
|
|
16
19
|
"scripts": {
|
|
17
20
|
"build:types": "npx tsc -build --force ./tsconfig.json",
|
|
18
|
-
"
|
|
21
|
+
"clean": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\"",
|
|
22
|
+
"build": "npm run clean && npm run build:types && rollup --config ./rollup.config.js",
|
|
19
23
|
"build:dev": "webpack --node-env=development",
|
|
20
24
|
"build:prod": "webpack --node-env=production",
|
|
21
25
|
"build:vendor": "rollup --config ./rollup.vendor.js",
|
|
22
26
|
"lint": "eslint ./src --ext .ts,.tsx",
|
|
27
|
+
"pretest": "npm run build && npm run build:vendor",
|
|
23
28
|
"test": "playwright test"
|
|
24
29
|
},
|
|
25
30
|
"repository": {
|
|
@@ -39,25 +44,28 @@
|
|
|
39
44
|
},
|
|
40
45
|
"homepage": "https://onyx.ac/docstack",
|
|
41
46
|
"dependencies": {
|
|
42
|
-
"@docstack/shared": "^0.0
|
|
43
|
-
"jsondiffpatch": "^0.
|
|
44
|
-
"pouchdb-browser": "^9.0.0",
|
|
45
|
-
"pouchdb-find": "^9.0.0",
|
|
47
|
+
"@docstack/shared": "^0.1.0",
|
|
48
|
+
"jsondiffpatch": "^0.7.3",
|
|
46
49
|
"semver": "^7.7.3",
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
50
|
+
"zod": "^4.1.5"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"pouchdb-browser": "^9.0.0",
|
|
54
|
+
"pouchdb-find": "^9.0.0"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
57
|
"@playwright/test": "^1.57.0",
|
|
58
|
+
"pouchdb-browser": "^9.0.0",
|
|
59
|
+
"pouchdb-find": "^9.0.0",
|
|
54
60
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
55
61
|
"@rollup/plugin-json": "^6.1.0",
|
|
56
62
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
57
63
|
"@rollup/plugin-replace": "^5.0.7",
|
|
58
64
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
65
|
+
"@rollup/rollup-linux-x64-gnu": "^4.57.1",
|
|
59
66
|
"@types/semver": "^7.7.1",
|
|
60
67
|
"http-server": "^14.1.1",
|
|
68
|
+
"is-reference": "^1.2.1",
|
|
61
69
|
"rollup": "^4.53.1",
|
|
62
70
|
"rollup-plugin-polyfill-node": "^0.13.0"
|
|
63
71
|
},
|
package/lib/core/attribute.js
DELETED
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { Attribute as Attribute_, ATTRIBUTE_TYPES } from "@docstack/shared";
|
|
4
|
-
/**
|
|
5
|
-
* Represents a single attribute (field) within a Class schema.
|
|
6
|
-
*
|
|
7
|
-
* Attributes define the structure of documents, including their type,
|
|
8
|
-
* validation rules (via Zod), and configuration options like mandatory,
|
|
9
|
-
* default values, primary keys, and foreign key references.
|
|
10
|
-
*
|
|
11
|
-
* Use the static factory method {@link Attribute.create} to instantiate
|
|
12
|
-
* attributes with proper validation and persistence.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* // Create a string attribute
|
|
17
|
-
* const titleAttr = await Attribute.create(taskClass, 'title', 'string', 'Task Title', {
|
|
18
|
-
* mandatory: true,
|
|
19
|
-
* maxLength: 200
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // Create a foreign key reference
|
|
23
|
-
* const assigneeAttr = await Attribute.create(taskClass, 'assigneeId', 'foreign_key', 'Assigned User', {
|
|
24
|
-
* targetClass: 'User'
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @extends Attribute_
|
|
29
|
-
*/
|
|
30
|
-
class Attribute extends Attribute_ {
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new Attribute instance.
|
|
33
|
-
* For most use cases, prefer using {@link Attribute.create} which also persists the attribute.
|
|
34
|
-
*
|
|
35
|
-
* @param classObj - The parent Class for this attribute
|
|
36
|
-
* @param name - The attribute name
|
|
37
|
-
* @param type - The attribute type (e.g., 'string', 'integer', 'boolean', 'enum')
|
|
38
|
-
* @param description - Optional description
|
|
39
|
-
* @param config - Type-specific configuration options
|
|
40
|
-
*/
|
|
41
|
-
constructor(classObj = null, name, type, description, config) {
|
|
42
|
-
super(classObj, name, type, config);
|
|
43
|
-
/** Zod schema for runtime validation of this field. */
|
|
44
|
-
this.field = z.any();
|
|
45
|
-
/**
|
|
46
|
-
* Validates that reference-type attributes have proper domain configuration.
|
|
47
|
-
* Called automatically during {@link Attribute.create}.
|
|
48
|
-
* @throws Error if the reference configuration is invalid
|
|
49
|
-
*/
|
|
50
|
-
this.ensureReferenceConfigIsValid = async () => {
|
|
51
|
-
if (this.model.type !== "reference") {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (!this.class) {
|
|
55
|
-
throw new Error(`Attribute '${this.name}' must belong to a class to validate reference configuration.`);
|
|
56
|
-
}
|
|
57
|
-
const stack = this.class.getStack();
|
|
58
|
-
if (!stack) {
|
|
59
|
-
throw new Error(`Class '${this.class.getName()}' is not attached to a stack.`);
|
|
60
|
-
}
|
|
61
|
-
const config = this.model.config;
|
|
62
|
-
const domainName = config.domain;
|
|
63
|
-
if (typeof domainName !== "string" || domainName.length === 0) {
|
|
64
|
-
throw new Error(`Attribute '${this.name}' of type 'reference' must declare a domain.`);
|
|
65
|
-
}
|
|
66
|
-
if (config.isArray) {
|
|
67
|
-
throw new Error(`Attribute '${this.name}' of type 'reference' cannot be an array.`);
|
|
68
|
-
}
|
|
69
|
-
const domain = await stack.getDomain(domainName);
|
|
70
|
-
if (!domain) {
|
|
71
|
-
throw new Error(`Domain '${domainName}' was not found for attribute '${this.name}'.`);
|
|
72
|
-
}
|
|
73
|
-
const classId = this.class.id;
|
|
74
|
-
switch (domain.relation) {
|
|
75
|
-
case "1:N":
|
|
76
|
-
if (classId !== domain.targetClass.id) {
|
|
77
|
-
throw new Error(`Given classId '${classId}' Reference attributes for domain '${domainName}' can only be added to class '${domain.targetClass}'.`);
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
case "N:1":
|
|
81
|
-
if (classId !== domain.sourceClass.id) {
|
|
82
|
-
throw new Error(`Given classId '${classId}' Reference attributes for domain '${domainName}' can only be added to class '${domain.sourceClass}'.`);
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
case "1:1":
|
|
86
|
-
if (classId !== domain.sourceClass.id && classId !== domain.targetClass.id) {
|
|
87
|
-
throw new Error(`Class '${classId}' is not part of domain '${domainName}'.`);
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
90
|
-
case "N:N":
|
|
91
|
-
throw new Error(`Domain '${domainName}' does not support reference attributes.`);
|
|
92
|
-
default:
|
|
93
|
-
throw new Error(`Unsupported relation '${domain.relation}' for domain '${domainName}'.`);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Builds the Zod validation schema based on attribute type and configuration.
|
|
98
|
-
* Called automatically during construction.
|
|
99
|
-
*/
|
|
100
|
-
this.setField = () => {
|
|
101
|
-
const { name, type, config } = this.model;
|
|
102
|
-
let field;
|
|
103
|
-
switch (type) {
|
|
104
|
-
// ... existing cases for 'string', 'number', 'boolean', 'date' ...
|
|
105
|
-
case 'string':
|
|
106
|
-
field = z.string();
|
|
107
|
-
if (config.maxLength !== undefined) {
|
|
108
|
-
field = field.max(config.maxLength);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
case 'integer':
|
|
112
|
-
field = z.number();
|
|
113
|
-
if (typeof config.min === 'number') {
|
|
114
|
-
field = field.min(config.min);
|
|
115
|
-
}
|
|
116
|
-
if (typeof config.max === 'number') {
|
|
117
|
-
field = field.max(config.max);
|
|
118
|
-
}
|
|
119
|
-
break;
|
|
120
|
-
// case 'date':
|
|
121
|
-
// field = z.date();
|
|
122
|
-
// break;
|
|
123
|
-
case 'decimal':
|
|
124
|
-
field = z.number();
|
|
125
|
-
// min and max validation
|
|
126
|
-
if (typeof config.min === 'number') {
|
|
127
|
-
field = field.min(config.min);
|
|
128
|
-
}
|
|
129
|
-
if (typeof config.max === 'number') {
|
|
130
|
-
field = field.max(config.max);
|
|
131
|
-
}
|
|
132
|
-
// decimal precision validation (with refinement)
|
|
133
|
-
if (typeof config.precision === 'number' && config.precision >= 0) {
|
|
134
|
-
const isPrecise = (value) => {
|
|
135
|
-
if (typeof value !== 'number')
|
|
136
|
-
return true;
|
|
137
|
-
const valueAsString = value.toString();
|
|
138
|
-
const decimalPart = valueAsString.split('.')[1];
|
|
139
|
-
const decimalPlaces = decimalPart ? decimalPart.length : 0;
|
|
140
|
-
return decimalPlaces <= config.precision;
|
|
141
|
-
};
|
|
142
|
-
field = field.refine(isPrecise, `Number cannot have more than ${config.precision} decimals.`);
|
|
143
|
-
}
|
|
144
|
-
break;
|
|
145
|
-
case 'boolean':
|
|
146
|
-
field = z.boolean();
|
|
147
|
-
break;
|
|
148
|
-
case "object":
|
|
149
|
-
field = z.object({});
|
|
150
|
-
break;
|
|
151
|
-
case 'enum':
|
|
152
|
-
if (!config.values || !Array.isArray(config.values) || config.values.length === 0) {
|
|
153
|
-
throw new Error(`Attribute '${name}' of type 'enum' must have a non-empty 'values' array in its config.`);
|
|
154
|
-
}
|
|
155
|
-
const enumValues = config.values.map(v => v.value);
|
|
156
|
-
field = z.enum(enumValues);
|
|
157
|
-
break;
|
|
158
|
-
case 'foreign_key':
|
|
159
|
-
if (!config.targetClass) {
|
|
160
|
-
throw new Error(`Attribute '${name}' of type 'foreign_key' is missing a 'targetClass' in its config.`);
|
|
161
|
-
}
|
|
162
|
-
const foreignClass = config.targetClass;
|
|
163
|
-
const baseSchema = z.string();
|
|
164
|
-
field = baseSchema.refine(async (documentIdOrIds) => {
|
|
165
|
-
var _b;
|
|
166
|
-
const idsToValidate = Array.isArray(documentIdOrIds) ? documentIdOrIds : [documentIdOrIds];
|
|
167
|
-
if (idsToValidate.length === 0) {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
try {
|
|
171
|
-
if (this.class) {
|
|
172
|
-
const stack = this.class.getStack();
|
|
173
|
-
if (stack) {
|
|
174
|
-
const promises = idsToValidate.map(id => stack.db.get(id));
|
|
175
|
-
const fetchResult = await Promise.all(promises);
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
else
|
|
179
|
-
throw new Error("Missing stack connection");
|
|
180
|
-
}
|
|
181
|
-
else
|
|
182
|
-
throw new Error("Missing class parentship");
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
if (error.status === 404) {
|
|
186
|
-
console.error(`Foreign key validation failed: document not found in class '${foreignClass}'. ${(_b = this.class) === null || _b === void 0 ? void 0 : _b.getName()}`, { error });
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
throw error;
|
|
190
|
-
}
|
|
191
|
-
}, {
|
|
192
|
-
message: `One or more documents not found in class '${foreignClass}'.`,
|
|
193
|
-
});
|
|
194
|
-
break;
|
|
195
|
-
case 'reference':
|
|
196
|
-
field = z.string().min(1);
|
|
197
|
-
break;
|
|
198
|
-
default:
|
|
199
|
-
throw new Error(`Unsupported schema type: '${type}' for field '${name}'`);
|
|
200
|
-
}
|
|
201
|
-
// These rules are applied regardless of the type, and in the correct order
|
|
202
|
-
if (config.defaultValue) {
|
|
203
|
-
field = field.default(config.defaultValue);
|
|
204
|
-
}
|
|
205
|
-
if (config.mandatory !== true) {
|
|
206
|
-
field = field.optional();
|
|
207
|
-
}
|
|
208
|
-
if (config.isArray === true) {
|
|
209
|
-
field = z.array(field);
|
|
210
|
-
}
|
|
211
|
-
this.field = field;
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Checks if this attribute is marked as a primary key.
|
|
215
|
-
* @returns `true` if this is a primary key attribute
|
|
216
|
-
*/
|
|
217
|
-
this.isPrimaryKey = () => {
|
|
218
|
-
let model = this.getModel();
|
|
219
|
-
return !!model.config.primaryKey;
|
|
220
|
-
};
|
|
221
|
-
/**
|
|
222
|
-
* Checks if this attribute is mandatory (required).
|
|
223
|
-
* @returns `true` if the attribute is mandatory
|
|
224
|
-
*/
|
|
225
|
-
this.isMandatory = () => {
|
|
226
|
-
return !!this.model.config.mandatory;
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* Returns the AttributeModel for this attribute.
|
|
230
|
-
* @returns The underlying AttributeModel
|
|
231
|
-
*/
|
|
232
|
-
this.getModel = () => {
|
|
233
|
-
return this.model;
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Returns the parent Class for this attribute.
|
|
237
|
-
* @returns The Class instance
|
|
238
|
-
* @throws Error if the attribute has no parent class
|
|
239
|
-
*/
|
|
240
|
-
this.getClass = () => {
|
|
241
|
-
if (this.class)
|
|
242
|
-
return this.class;
|
|
243
|
-
else
|
|
244
|
-
throw Error("Missing class configuration for this attribute");
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Validates a value against this attribute's Zod schema.
|
|
248
|
-
*
|
|
249
|
-
* @param data - The value to validate
|
|
250
|
-
* @returns Zod safe parse result with success status and data/error
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* ```typescript
|
|
254
|
-
* const result = await priceAttr.validate(19.99);
|
|
255
|
-
* if (result.success) {
|
|
256
|
-
* console.log('Valid:', result.data);
|
|
257
|
-
* } else {
|
|
258
|
-
* console.log('Invalid:', result.error);
|
|
259
|
-
* }
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
this.validate = async (data) => {
|
|
263
|
-
return this.field.safeParseAsync(data);
|
|
264
|
-
};
|
|
265
|
-
this.setModel = (model) => {
|
|
266
|
-
let currentModel = this.getModel();
|
|
267
|
-
model = Object.assign(currentModel || {}, model);
|
|
268
|
-
this.model = model;
|
|
269
|
-
this.defaultValue = model.config.defaultValue;
|
|
270
|
-
};
|
|
271
|
-
// TODO: Better define config
|
|
272
|
-
this.getType = (type) => {
|
|
273
|
-
if (this.checkTypeValidity(type)) {
|
|
274
|
-
return type;
|
|
275
|
-
}
|
|
276
|
-
else
|
|
277
|
-
throw Error("Invalid attribute type: " + type);
|
|
278
|
-
// return this?
|
|
279
|
-
};
|
|
280
|
-
/**
|
|
281
|
-
* Returns an empty/default value for this attribute.
|
|
282
|
-
* Uses the Zod schema's default value if configured.
|
|
283
|
-
* @returns Object with attribute name as key and default/null value
|
|
284
|
-
*/
|
|
285
|
-
this.getEmpty = () => {
|
|
286
|
-
const partialDoc = {
|
|
287
|
-
[this.name]: this.field.parse(undefined) || null
|
|
288
|
-
};
|
|
289
|
-
return partialDoc;
|
|
290
|
-
};
|
|
291
|
-
// getType()
|
|
292
|
-
/**
|
|
293
|
-
* Returns the attribute name.
|
|
294
|
-
* @returns The attribute name string
|
|
295
|
-
*/
|
|
296
|
-
this.getName = () => {
|
|
297
|
-
return this.name;
|
|
298
|
-
};
|
|
299
|
-
this.checkTypeValidity = (type) => {
|
|
300
|
-
let validity = false;
|
|
301
|
-
if (ATTRIBUTE_TYPES.includes(type)) {
|
|
302
|
-
validity = true;
|
|
303
|
-
}
|
|
304
|
-
return validity;
|
|
305
|
-
};
|
|
306
|
-
// TODO: change to imported const default configs for types
|
|
307
|
-
// as of now it accepts only string
|
|
308
|
-
// TODO: since config depends on attribute's type,
|
|
309
|
-
// find a way to check if given configs are correct
|
|
310
|
-
// find a way to add default configs base on type
|
|
311
|
-
this.getTypeConf = (type, config) => {
|
|
312
|
-
switch (type) {
|
|
313
|
-
// TODO: add missing cases and change values to imported const
|
|
314
|
-
case "decimal":
|
|
315
|
-
config = Object.assign({ max: null, min: null, precision: null, isArray: false }, config);
|
|
316
|
-
break;
|
|
317
|
-
case "integer":
|
|
318
|
-
config = Object.assign({ max: null, min: null, isArray: false }, config);
|
|
319
|
-
break;
|
|
320
|
-
case "string":
|
|
321
|
-
config = Object.assign({ isArray: false }, config);
|
|
322
|
-
break;
|
|
323
|
-
case "object":
|
|
324
|
-
config = Object.assign({ isArray: false }, config);
|
|
325
|
-
break;
|
|
326
|
-
case "date":
|
|
327
|
-
config = Object.assign({ format: "iso", max: null, min: null, isArray: false }, config);
|
|
328
|
-
break;
|
|
329
|
-
case "boolean":
|
|
330
|
-
config = Object.assign({ defaultValue: false, isArray: false }, config);
|
|
331
|
-
break;
|
|
332
|
-
case "foreign_key":
|
|
333
|
-
config = Object.assign({ targetClass: null, isArray: false }, config);
|
|
334
|
-
break;
|
|
335
|
-
case "enum":
|
|
336
|
-
config = Object.assign({ values: [], isArray: false }, config);
|
|
337
|
-
break;
|
|
338
|
-
case "reference":
|
|
339
|
-
config = Object.assign({ isArray: false }, config);
|
|
340
|
-
break;
|
|
341
|
-
default:
|
|
342
|
-
throw new Error("Unexpected type: " + type);
|
|
343
|
-
// return "^[a-zA-Z0-9_\\s]".concat("{0,"+config.maxLength+"}$");
|
|
344
|
-
}
|
|
345
|
-
return config;
|
|
346
|
-
};
|
|
347
|
-
this.name = name;
|
|
348
|
-
this.description = description;
|
|
349
|
-
this.setModel({
|
|
350
|
-
name: this.name,
|
|
351
|
-
description: this.description,
|
|
352
|
-
type: this.getType(type),
|
|
353
|
-
config: this.getTypeConf(type, config) || {},
|
|
354
|
-
});
|
|
355
|
-
this.setField();
|
|
356
|
-
this.class = classObj;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Creates a new Attribute and persists it to the parent Class.
|
|
360
|
-
* This is the primary factory method for creating attributes.
|
|
361
|
-
*
|
|
362
|
-
* @param classObj - The parent Class to add the attribute to
|
|
363
|
-
* @param name - The attribute name
|
|
364
|
-
* @param type - The attribute type
|
|
365
|
-
* @param description - Optional description
|
|
366
|
-
* @param config - Type-specific configuration
|
|
367
|
-
* @returns The created Attribute instance
|
|
368
|
-
*
|
|
369
|
-
* @example
|
|
370
|
-
* ```typescript
|
|
371
|
-
* const priceAttr = await Attribute.create(productClass, 'price', 'decimal', 'Product price', {
|
|
372
|
-
* min: 0,
|
|
373
|
-
* precision: 2,
|
|
374
|
-
* mandatory: true
|
|
375
|
-
* });
|
|
376
|
-
* ```
|
|
377
|
-
*/
|
|
378
|
-
static async create(classObj, name, type, description, config) {
|
|
379
|
-
const attribute = new _a(classObj, name, type, description, config);
|
|
380
|
-
await attribute.ensureReferenceConfigIsValid();
|
|
381
|
-
await _a.build(attribute);
|
|
382
|
-
return attribute;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
_a = Attribute;
|
|
386
|
-
/**
|
|
387
|
-
* Adds an attribute to its parent class and persists to the database.
|
|
388
|
-
* Used internally by {@link Attribute.create}.
|
|
389
|
-
*
|
|
390
|
-
* @param attributeObj - The Attribute instance to build
|
|
391
|
-
* @returns The Attribute instance
|
|
392
|
-
* @throws Error if the class has no stack connection
|
|
393
|
-
*/
|
|
394
|
-
Attribute.build = async (attributeObj) => {
|
|
395
|
-
let classObj = attributeObj.getClass();
|
|
396
|
-
let stack = classObj.getStack();
|
|
397
|
-
if (stack) {
|
|
398
|
-
await classObj.addAttribute(attributeObj);
|
|
399
|
-
return attributeObj;
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
throw new Error("Missing db configuration");
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
export default Attribute;
|
|
406
|
-
//# sourceMappingURL=attribute.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../src/core/attribute.ts"],"names":[],"mappings":";AAAA,OAAO,CAAmC,MAAM,KAAK,CAAC;AAEtD,OAAO,EAAE,SAAS,IAAI,UAAU,EAAiC,eAAe,EAA+C,MAAM,kBAAkB,CAAC;AAExJ;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,SAAU,SAAQ,UAAU;IAc9B;;;;;;;;;OASG;IACH,YAAY,WAAyB,IAAI,EAAE,IAAY,EAAE,IAA2B,EAAE,WAAoB,EAAE,MAAgC;QACxI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAlBxC,uDAAuD;QACvD,UAAK,GAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QA8BrB;;;;WAIG;QACH,iCAA4B,GAAG,KAAK,IAAI,EAAE;YACtC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAClC,OAAO;YACX,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gB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