memorio 4.7.1 → 4.8.0

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.
@@ -0,0 +1,53 @@
1
+ /// MEMORIO SCHEMA TYPES
2
+ /// Ambient declarations for the schema validation system.
3
+
4
+ ///
5
+ // Schema type — describes the expected runtime shape of a value.
6
+ ///
7
+ interface _schemaDef {
8
+ /** Expected runtime type of the value. */
9
+ type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any'
10
+ /** Required property names when type is 'object'. */
11
+ required?: string[]
12
+ /** Nested property schemas (validated recursively). */
13
+ properties?: Record<string, _schemaDef>
14
+ /** Minimum: value for numbers, length for strings. */
15
+ min?: number
16
+ /** Maximum: value for numbers, length for strings. */
17
+ max?: number
18
+ /** Regex pattern a string value must match. */
19
+ pattern?: RegExp
20
+ /** Whitelist of allowed values. */
21
+ enum?: any[]
22
+ /** Custom validator: return true for pass, or a string describing the error. */
23
+ validator?: (value: any) => boolean | string
24
+ }
25
+
26
+ ///
27
+ // Result of a validation check.
28
+ ///
29
+ interface _validationResult {
30
+ /** Whether the value passed all checks. */
31
+ valid: boolean
32
+ /** Array of human-readable error strings (present when valid is false). */
33
+ errors?: string[]
34
+ }
35
+
36
+ ///
37
+ // Schema namespace — the public `memorio.schema`-style helpers live on `memorio`.
38
+ ///
39
+ interface _schemaHelpers {
40
+ /** Registers a schema (or custom validator) for a state path. */
41
+ register: (path: string, schema: _schemaDef | ((value: any) => boolean | string)) => void
42
+ /** Validates a value against a registered schema. */
43
+ validate: (path: string, value: any) => _validationResult
44
+ /** Removes a previously registered schema. */
45
+ unregister: (path: string) => boolean
46
+ /** Lists all registered schema paths. */
47
+ list: () => string[]
48
+ /** Retrieves the schema registered for a path. */
49
+ get: (path: string) => _schemaDef | undefined
50
+ }
51
+
52
+ declare var _schemaDef: _schemaDef
53
+ declare var _validationResult: _validationResult
@@ -0,0 +1,35 @@
1
+ /*!
2
+ memorio
3
+ Copyright (c) 2019 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under MIT License, see
5
+ dario.passariello.ca
6
+ */
7
+
8
+ /**
9
+ * Memorio SQLite module.
10
+ *
11
+ * Backed by the optional `sql.js` package (SQLite compiled to WebAssembly).
12
+ * Lazily loaded in the browser; disabled in non-browser environments.
13
+ */
14
+ interface _sqlite {
15
+ /** Database connection tools (create, get, delete, list, size, export, import). */
16
+ db: any
17
+ /** SQL execution tools (run, select). */
18
+ query: any
19
+ /** CRUD shortcut helpers (set, get). */
20
+ data: any
21
+ /** Lazy-load / configure the sql.js engine (wasm loader, locateFile, etc.). */
22
+ config: (opts: any) => any
23
+ /** Promise that resolves once the sql.js engine has been initialized. */
24
+ ready: Promise<void> | null
25
+ /** True when running outside a supported browser environment. */
26
+ _disabled?: boolean
27
+ /** Human readable reason the module is disabled, when applicable. */
28
+ _warning?: string
29
+ [key: string]: any
30
+ }
31
+
32
+ declare var sqlite: _sqlite
33
+ type sqlite = _sqlite
34
+
35
+ declare var sqlbases: any[]