@nan0web/core 1.1.1 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nan0web/core",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Core application framework for nan0web with database handling, internationalization, and interface connectivity",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@nan0web/db": "^1.4.3",
35
35
  "@nan0web/i18n": "^1.3.0",
36
36
  "@nan0web/protocol": "^2.0.0",
37
- "@nan0web/types": "^1.4.0"
37
+ "@nan0web/types": "^1.6.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc",
package/src/AppCore.js CHANGED
@@ -55,8 +55,10 @@ export default class AppCore {
55
55
  actions
56
56
  /** @type {object} */
57
57
  meta
58
- /** @type {Record<string, Language>} */
58
+ /** @type {object} */
59
59
  langs
60
+ /** @type {object} */
61
+ element
60
62
  /** @type {(key: string, replacements?: Record<string, string>) => string} */
61
63
  t = (key, replacements = {}) => key
62
64
 
@@ -79,6 +81,7 @@ export default class AppCore {
79
81
  this.actions = resolved.actions
80
82
  this.meta = resolved.meta
81
83
  this.langs = resolved.langs
84
+ this.element = resolved.element || input.element || {}
82
85
  }
83
86
 
84
87
  /**
@@ -132,7 +135,7 @@ export default class AppCore {
132
135
  }
133
136
 
134
137
  static from(input) {
135
- if (input instanceof AppCore) return input
136
- return new AppCore(input)
138
+ if (input instanceof this) return input
139
+ return new this(input)
137
140
  }
138
141
  }
package/src/Model.js CHANGED
@@ -1,47 +1,3 @@
1
- import { resolveDefaults, resolveAliases, resolveValidation } from '@nan0web/types'
1
+ import { Model } from '@nan0web/types'
2
2
 
3
- /**
4
- * Domain Data Model for a Project Configuration
5
- * Implements Model-as-Schema (Project-as-Data)
6
- *
7
- * Ця модель є дзеркалом `project.schema.yaml` та джерелом правди
8
- * для автоматичних інструментів валідації та генерації ТЗ.
9
- *
10
- * @example
11
- * import { Model } from '@nan0web/core'
12
- * const model = new Model({ description: 'My App', tags: ['ui'] })
13
- */
14
- export class Model {
15
- #options = {}
16
- /**
17
- * @param {Partial<Model>} data Data from YAML or Markdown frontmatter
18
- * @param {object} [options] Extended options (db, etc.)
19
- */
20
- constructor(data = {}, options = {}) {
21
- const Model = this.constructor
22
- Object.assign(this, resolveDefaults(Model, resolveAliases(Model, data)))
23
- this.#options = options
24
- }
25
-
26
- /** @returns {import('@nan0web/db').default | undefined} */
27
- get db() {
28
- return this.#options.db
29
- }
30
-
31
- /**
32
- * Environment options dependencies
33
- * @returns {object}
34
- */
35
- get _() {
36
- return this.#options
37
- }
38
-
39
- /**
40
- * Validate instance against static schema metadata.
41
- * @returns {boolean} True if validation passes
42
- * @throws {import('@nan0web/types').ModelError}
43
- */
44
- validate() {
45
- return resolveValidation(this.constructor, this)
46
- }
47
- }
3
+ export { Model }
@@ -64,8 +64,10 @@ export default class AppCore {
64
64
  actions: Record<string, Function>;
65
65
  /** @type {object} */
66
66
  meta: object;
67
- /** @type {Record<string, Language>} */
68
- langs: Record<string, Language>;
67
+ /** @type {object} */
68
+ langs: object;
69
+ /** @type {object} */
70
+ element: object;
69
71
  /** @type {(key: string, replacements?: Record<string, string>) => string} */
70
72
  t: (key: string, replacements?: Record<string, string>) => string;
71
73
  /**
package/types/Model.d.ts CHANGED
@@ -1,32 +1,2 @@
1
- /**
2
- * Domain Data Model for a Project Configuration
3
- * Implements Model-as-Schema (Project-as-Data)
4
- *
5
- * Ця модель є дзеркалом `project.schema.yaml` та джерелом правди
6
- * для автоматичних інструментів валідації та генерації ТЗ.
7
- *
8
- * @example
9
- * import { Model } from '@nan0web/core'
10
- * const model = new Model({ description: 'My App', tags: ['ui'] })
11
- */
12
- export class Model {
13
- /**
14
- * @param {Partial<Model>} data Data from YAML or Markdown frontmatter
15
- * @param {object} [options] Extended options (db, etc.)
16
- */
17
- constructor(data?: Partial<Model>, options?: object);
18
- /** @returns {import('@nan0web/db').default | undefined} */
19
- get db(): import("@nan0web/db").default | undefined;
20
- /**
21
- * Environment options dependencies
22
- * @returns {object}
23
- */
24
- get _(): object;
25
- /**
26
- * Validate instance against static schema metadata.
27
- * @returns {boolean} True if validation passes
28
- * @throws {import('@nan0web/types').ModelError}
29
- */
30
- validate(): boolean;
31
- #private;
32
- }
1
+ export { Model };
2
+ import { Model } from '@nan0web/types';