@nan0web/core 1.1.1 → 1.1.3

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.3",
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",
@@ -25,20 +25,20 @@
25
25
  "author": "ЯRаСлав YaRaSLove <support@yaro.page>",
26
26
  "license": "ISC",
27
27
  "devDependencies": {
28
- "@nan0web/release": "^1.0.2",
29
- "@nan0web/test": "^1.1.3",
30
28
  "husky": "^9.1.7",
31
- "knip": "^5.86.0"
29
+ "knip": "^5.86.0",
30
+ "@nan0web/test": "1.1.3",
31
+ "@nan0web/release": "1.0.3"
32
32
  },
33
33
  "dependencies": {
34
- "@nan0web/db": "^1.4.3",
35
- "@nan0web/i18n": "^1.3.0",
36
- "@nan0web/protocol": "^2.0.0",
37
- "@nan0web/types": "^1.4.0"
34
+ "@nan0web/db": "1.4.6",
35
+ "@nan0web/i18n": "1.5.0",
36
+ "@nan0web/protocol": "2.0.0",
37
+ "@nan0web/types": "1.7.1"
38
38
  },
39
39
  "scripts": {
40
- "build": "tsc",
41
- "clean": "rm -rf .cache/ && rm -rf dist/",
40
+ "build": "rm -rf types && tsc",
41
+ "clean": "rm -rf .cache/ && rm -rf dist/ && rm -rf types/",
42
42
  "clean:modules": "rm -rf node_modules",
43
43
  "precommit": "npm test",
44
44
  "prepush": "npm test",
package/src/AppCore.js CHANGED
@@ -17,7 +17,10 @@ import AppResult from './AppResult.js'
17
17
  * @property {Function} t - Translation function
18
18
  */
19
19
  export default class AppCore {
20
- static DB = DB
20
+ static get DB() {
21
+ return DB
22
+ }
23
+
21
24
  static UI = {
22
25
  title: 'Application Core',
23
26
  description: 'Base application logic and state container',
@@ -55,8 +58,10 @@ export default class AppCore {
55
58
  actions
56
59
  /** @type {object} */
57
60
  meta
58
- /** @type {Record<string, Language>} */
61
+ /** @type {object} */
59
62
  langs
63
+ /** @type {object} */
64
+ element
60
65
  /** @type {(key: string, replacements?: Record<string, string>) => string} */
61
66
  t = (key, replacements = {}) => key
62
67
 
@@ -79,6 +84,7 @@ export default class AppCore {
79
84
  this.actions = resolved.actions
80
85
  this.meta = resolved.meta
81
86
  this.langs = resolved.langs
87
+ this.element = resolved.element || input.element || {}
82
88
  }
83
89
 
84
90
  /**
@@ -132,7 +138,7 @@ export default class AppCore {
132
138
  }
133
139
 
134
140
  static from(input) {
135
- if (input instanceof AppCore) return input
136
- return new AppCore(input)
141
+ if (input instanceof this) return input
142
+ return new this(input)
137
143
  }
138
144
  }
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 }
package/src/index.js CHANGED
@@ -1,12 +1,8 @@
1
- import { ExecutableCommand } from '@nan0web/protocol'
2
- import { ModelError } from '@nan0web/types'
3
- import AppCore from './AppCore.js'
4
- import AppResult from './AppResult.js'
5
- import { Model } from './Model.js'
6
- import { ProjectModel } from './ProjectModel.js'
1
+ export { ExecutableCommand } from '@nan0web/protocol'
2
+ export { ModelError } from '@nan0web/types'
3
+ export { Model } from './Model.js'
4
+ export { ProjectModel } from './ProjectModel.js'
5
+ export { default as AppResult } from './AppResult.js'
6
+ export { default as AppCore, default } from './AppCore.js'
7
7
 
8
8
  /** @typedef {import("./AppCore.js").Language} Language */
9
-
10
- export { AppCore, AppResult, ExecutableCommand, Model, ProjectModel, ModelError }
11
-
12
- export default AppCore
@@ -11,7 +11,7 @@
11
11
  * @property {Function} t - Translation function
12
12
  */
13
13
  export default class AppCore {
14
- static DB: typeof DB;
14
+ static get DB(): typeof DB;
15
15
  static UI: {
16
16
  title: string;
17
17
  description: string;
@@ -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';
package/types/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- export default AppCore;
1
+ export { ExecutableCommand } from "@nan0web/protocol";
2
+ export { ModelError } from "@nan0web/types";
3
+ export { Model } from "./Model.js";
4
+ export { ProjectModel } from "./ProjectModel.js";
5
+ export { default as AppResult } from "./AppResult.js";
2
6
  export type Language = import("./AppCore.js").Language;
3
- import AppCore from './AppCore.js';
4
- import AppResult from './AppResult.js';
5
- import { ExecutableCommand } from '@nan0web/protocol';
6
- import { Model } from './Model.js';
7
- import { ProjectModel } from './ProjectModel.js';
8
- import { ModelError } from '@nan0web/types';
9
- export { AppCore, AppResult, ExecutableCommand, Model, ProjectModel, ModelError };
7
+ export { default as AppCore, default } from "./AppCore.js";