Skip to content

Commit

Permalink
[core] Reorganizing project packages (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 25, 2024
1 parent 46d54a1 commit 60fa1ed
Show file tree
Hide file tree
Showing 104 changed files with 480 additions and 371 deletions.
3 changes: 1 addition & 2 deletions assets/layouts/layout-default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import { onBeforeMount, ref } from 'vue';
import get from 'lodash.get';
import { DashboardDocument, GroupDocument, WidgetDataSourceDocument, WidgetDisplayDocument, WidgetDocument } from '@fastybird/metadata-library';
import { useDashboards, useGroups, useWidgets, useWidgetDataSources, useWidgetDisplay } from '../models';
import { DashboardDocument, GroupDocument, WidgetDataSourceDocument, WidgetDisplayDocument, WidgetDocument } from '../types';
defineOptions({
name: 'LayoutDefault',
Expand Down
3 changes: 2 additions & 1 deletion assets/models/dashboards/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DashboardDocument, UiModuleRoutes as RoutingKeys, ModulePrefix } from '@fastybird/metadata-library';
import { ModulePrefix } from '@fastybird/metadata-library';
import addFormats from 'ajv-formats';
import Ajv from 'ajv/dist/2020';
import axios from 'axios';
Expand All @@ -19,6 +19,7 @@ import {
IDashboardsLoadRecordActionPayload,
IPlainRelation,
} from '../../models/types';
import { DashboardDocument, RoutingKeys } from '../../types';
import { addRecord, getAllRecords, getRecord, removeRecord, DB_TABLE_DASHBOARDS } from '../../utilities/database';

import {
Expand Down
3 changes: 1 addition & 2 deletions assets/models/dashboards/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonApiRelation, TJsonApiRelationships } from 'jsona/lib/JsonaTypes';
import { _GettersTree } from 'pinia';

import { DashboardDocument } from '@fastybird/metadata-library';

import { ITabResponseData, ITabResponseModel, IEntityMeta, IPlainRelation } from '../../models/types';
import { DashboardDocument } from '../../types';

export interface IDashboardMeta extends IEntityMeta {
entity: 'dashboard';
Expand Down
3 changes: 2 additions & 1 deletion assets/models/groups/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GroupDocument, UiModuleRoutes as RoutingKeys, ModulePrefix } from '@fastybird/metadata-library';
import { ModulePrefix } from '@fastybird/metadata-library';
import addFormats from 'ajv-formats';
import Ajv from 'ajv/dist/2020';
import axios from 'axios';
Expand All @@ -13,6 +13,7 @@ import exchangeDocumentSchema from '../../../resources/schemas/document.group.js
import { ApiError } from '../../errors';
import { JsonApiJsonPropertiesMapper, JsonApiModelPropertiesMapper } from '../../jsonapi';
import { IGroupDatabaseRecord, IGroupMeta, IGroupsInsertDataActionPayload, IGroupsLoadRecordActionPayload, IPlainRelation } from '../../models/types';
import { GroupDocument, RoutingKeys } from '../../types';
import { addRecord, getAllRecords, getRecord, removeRecord, DB_TABLE_GROUPS } from '../../utilities/database';

import {
Expand Down
3 changes: 1 addition & 2 deletions assets/models/groups/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonApiRelation, TJsonApiRelationships } from 'jsona/lib/JsonaTypes';
import { _GettersTree } from 'pinia';

import { GroupDocument } from '@fastybird/metadata-library';

import { IWidgetResponseData, IWidgetResponseModel, IEntityMeta, IPlainRelation } from '../../models/types';
import { GroupDocument } from '../../types';

export interface IGroupMeta extends IEntityMeta {
entity: 'group';
Expand Down
3 changes: 2 additions & 1 deletion assets/models/tabs/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TabDocument, UiModuleRoutes as RoutingKeys, ModulePrefix, ModuleSource } from '@fastybird/metadata-library';
import { ModulePrefix, ModuleSource } from '@fastybird/metadata-library';
import addFormats from 'ajv-formats';
import Ajv from 'ajv/dist/2020';
import axios from 'axios';
Expand All @@ -13,6 +13,7 @@ import exchangeDocumentSchema from '../../../resources/schemas/document.tab.json
import { ApiError } from '../../errors';
import { JsonApiJsonPropertiesMapper, JsonApiModelPropertiesMapper } from '../../jsonapi';
import { ITabDatabaseRecord, ITabMeta, ITabsInsertDataActionPayload, ITabsLoadRecordActionPayload, IPlainRelation } from '../../models/types';
import { RoutingKeys, TabDocument } from '../../types';
import { addRecord, getAllRecords, getRecord, removeRecord, DB_TABLE_TABS } from '../../utilities/database';

import {
Expand Down
3 changes: 1 addition & 2 deletions assets/models/tabs/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonApiRelation, TJsonApiRelationships } from 'jsona/lib/JsonaTypes';
import { _GettersTree } from 'pinia';

import { TabDocument } from '@fastybird/metadata-library';

import {
IDashboardResponseData,
IDashboardResponseModel,
Expand All @@ -11,6 +9,7 @@ import {
IEntityMeta,
IPlainRelation,
} from '../../models/types';
import { TabDocument } from '../../types';

export interface ITabMeta extends IEntityMeta {
entity: 'tab';
Expand Down
3 changes: 2 additions & 1 deletion assets/models/widgets-data-sources/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionRoutes, ExchangeCommand, ModulePrefix, UiModuleRoutes as RoutingKeys, WidgetDataSourceDocument } from '@fastybird/metadata-library';
import { ModulePrefix } from '@fastybird/metadata-library';
import { useWampV1Client } from '@fastybird/vue-wamp-v1';
import addFormats from 'ajv-formats';
import Ajv from 'ajv/dist/2020';
Expand All @@ -14,6 +14,7 @@ import exchangeDocumentSchema from '../../../resources/schemas/document.widget.d
import { ApiError } from '../../errors';
import { JsonApiJsonPropertiesMapper, JsonApiModelPropertiesMapper } from '../../jsonapi';
import { useWidgets } from '../../models';
import { ActionRoutes, ExchangeCommand, RoutingKeys, WidgetDataSourceDocument } from '../../types';
import { addRecord, DB_TABLE_WIDGETS_DATA_SOURCES, getAllRecords, getRecord, removeRecord } from '../../utilities/database';
import { IWidget } from '../widgets/types';

Expand Down
2 changes: 1 addition & 1 deletion assets/models/widgets-data-sources/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { WidgetDataSourceDocument } from '@fastybird/metadata-library';
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonApiRelation, TJsonApiRelationships } from 'jsona/lib/JsonaTypes';
import { _GettersTree } from 'pinia';

import { IWidget, IWidgetResponseData, IPlainRelation, IWidgetResponseModel, IEntityMeta } from '../../models/types';
import { WidgetDataSourceDocument } from '../../types';

export interface IWidgetDataSourceMeta extends IEntityMeta {
type: string;
Expand Down
3 changes: 2 additions & 1 deletion assets/models/widgets-display/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModulePrefix, UiModuleRoutes as RoutingKeys, WidgetDisplayDocument } from '@fastybird/metadata-library';
import { ModulePrefix } from '@fastybird/metadata-library';
import addFormats from 'ajv-formats';
import Ajv from 'ajv/dist/2020';
import axios from 'axios';
Expand All @@ -13,6 +13,7 @@ import exchangeDocumentSchema from '../../../resources/schemas/document.widget.d
import { ApiError } from '../../errors';
import { JsonApiJsonPropertiesMapper, JsonApiModelPropertiesMapper } from '../../jsonapi';
import { useWidgets } from '../../models';
import { RoutingKeys, WidgetDisplayDocument } from '../../types';
import { addRecord, DB_TABLE_WIDGETS_DATA_SOURCES, getAllRecords, getRecord, removeRecord } from '../../utilities/database';
import { IWidget } from '../widgets/types';

Expand Down
2 changes: 1 addition & 1 deletion assets/models/widgets-display/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { WidgetDisplayDocument } from '@fastybird/metadata-library';
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonApiRelation, TJsonApiRelationships } from 'jsona/lib/JsonaTypes';
import { _GettersTree } from 'pinia';

import { IWidget, IWidgetResponseData, IPlainRelation, IWidgetResponseModel, IEntityMeta } from '../../models/types';
import { WidgetDisplayDocument } from '../../types';

export interface IWidgetDisplayMeta extends IEntityMeta {
type: string;
Expand Down
3 changes: 2 additions & 1 deletion assets/models/widgets/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WidgetDocument, UiModuleRoutes as RoutingKeys, ModulePrefix, ModuleSource } from '@fastybird/metadata-library';
import { ModulePrefix, ModuleSource } from '@fastybird/metadata-library';
import addFormats from 'ajv-formats';
import Ajv from 'ajv/dist/2020';
import axios from 'axios';
Expand All @@ -22,6 +22,7 @@ import {
IWidgetDataSourceResponseModel,
IWidgetDisplayResponseModel,
} from '../../models/types';
import { RoutingKeys, WidgetDocument } from '../../types';
import { addRecord, getAllRecords, getRecord, removeRecord, DB_TABLE_WIDGETS } from '../../utilities/database';

import {
Expand Down
3 changes: 1 addition & 2 deletions assets/models/widgets/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { TJsonaModel, TJsonApiBody, TJsonApiData, TJsonApiRelation, TJsonApiRelationships } from 'jsona/lib/JsonaTypes';
import { _GettersTree } from 'pinia';

import { WidgetDocument } from '@fastybird/metadata-library';

import {
IWidgetDataSourceResponseModel,
ITabResponseModel,
Expand All @@ -14,6 +12,7 @@ import {
ITabResponseData,
IWidgetDisplayResponseData,
} from '../../models/types';
import { WidgetDocument } from '../../types';

export interface IWidgetMeta extends IEntityMeta {
type: string;
Expand Down
47 changes: 47 additions & 0 deletions assets/types/exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export enum ActionRoutes {
WIDGET_DATA_SOURCE = 'fb.exchange.action.widget.data-source',
}

export enum RoutingKeys {
// Dashboards
DASHBOARD_DOCUMENT_REPORTED = 'fb.exchange.module.document.reported.dashboard',
DASHBOARD_DOCUMENT_CREATED = 'fb.exchange.module.document.created.dashboard',
DASHBOARD_DOCUMENT_UPDATED = 'fb.exchange.module.document.updated.dashboard',
DASHBOARD_DOCUMENT_DELETED = 'fb.exchange.module.document.deleted.dashboard',

// Tabs
TAB_DOCUMENT_REPORTED = 'fb.exchange.module.document.reported.tab',
TAB_DOCUMENT_CREATED = 'fb.exchange.module.document.created.tab',
TAB_DOCUMENT_UPDATED = 'fb.exchange.module.document.updated.tab',
TAB_DOCUMENT_DELETED = 'fb.exchange.module.document.deleted.tab',

// Groups
GROUP_DOCUMENT_REPORTED = 'fb.exchange.module.document.reported.group',
GROUP_DOCUMENT_CREATED = 'fb.exchange.module.document.created.group',
GROUP_DOCUMENT_UPDATED = 'fb.exchange.module.document.updated.group',
GROUP_DOCUMENT_DELETED = 'fb.exchange.module.document.deleted.group',

// Widgets
WIDGET_DOCUMENT_REPORTED = 'fb.exchange.module.document.reported.widget',
WIDGET_DOCUMENT_CREATED = 'fb.exchange.module.document.created.widget',
WIDGET_DOCUMENT_UPDATED = 'fb.exchange.module.document.updated.widget',
WIDGET_DOCUMENT_DELETED = 'fb.exchange.module.document.deleted.widget',

// Widget's display
WIDGET_DISPLAY_DOCUMENT_REPORTED = 'fb.exchange.module.document.reported.widget.display',
WIDGET_DISPLAY_DOCUMENT_CREATED = 'fb.exchange.module.document.created.widget.display',
WIDGET_DISPLAY_DOCUMENT_UPDATED = 'fb.exchange.module.document.updated.widget.display',
WIDGET_DISPLAY_DOCUMENT_DELETED = 'fb.exchange.module.document.deleted.widget.display',

// Widget's data sources
WIDGET_DATA_SOURCE_DOCUMENT_REPORTED = 'fb.exchange.module.document.reported.widget.data-source',
WIDGET_DATA_SOURCE_DOCUMENT_CREATED = 'fb.exchange.module.document.created.widget.data-source',
WIDGET_DATA_SOURCE_DOCUMENT_UPDATED = 'fb.exchange.module.document.updated.widget.data-source',
WIDGET_DATA_SOURCE_DOCUMENT_DELETED = 'fb.exchange.module.document.deleted.widget.data-source',
}

export enum ExchangeCommand {
SET = 'set',
GET = 'get',
REPORT = 'report',
}
81 changes: 81 additions & 0 deletions assets/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { I18n } from 'vue-i18n';
import { Router } from 'vue-router';
import { Client } from '@fastybird/vue-wamp-v1';

export * from './exchange';

export type InstallFunction = Plugin & { installed?: boolean };

export interface IUiModuleOptions {
Expand Down Expand Up @@ -57,3 +59,82 @@ export enum FormResultTypes {
}

export type FormResultType = FormResultTypes.NONE | FormResultTypes.WORKING | FormResultTypes.ERROR | FormResultTypes.OK;
export interface DashboardDocument {
id: string;
source: string;
identifier: string;
name: string | null;
comment: string | null;
priority: number;
tabs: TabDocument['id'][];
owner: string | null;
createdAt: Date | null;
updatedAt: Date | null;
}

export interface TabDocument {
id: string;
source: string;
identifier: string;
name: string | null;
comment: string | null;
priority: number;
dashboard: DashboardDocument['id'];
widgets: WidgetDocument['id'][];
owner: string | null;
createdAt: Date | null;
updatedAt: Date | null;
}

export interface GroupDocument {
id: string;
source: string;
identifier: string;
name: string | null;
comment: string | null;
priority: number;
widgets: WidgetDocument['id'][];
owner: string | null;
createdAt: Date | null;
updatedAt: Date | null;
}

export interface WidgetDocument {
id: string;
type: string;
source: string;
identifier: string;
name: string | null;
comment: string | null;
display: WidgetDisplayDocument['id'];
data_sources: WidgetDataSourceDocument['id'][];
tabs: TabDocument['id'][];
groups: GroupDocument['id'][];
owner: string | null;
createdAt: Date | null;
updatedAt: Date | null;
}

export interface WidgetDisplayDocument {
id: string;
type: string;
source: string;
identifier: string;
params: object;
widget: WidgetDocument['id'];
owner: string | null;
createdAt: Date | null;
updatedAt: Date | null;
}

export interface WidgetDataSourceDocument {
id: string;
type: string;
source: string;
identifier: string;
params: object;
widget: WidgetDocument['id'];
owner: string | null;
createdAt: Date | null;
updatedAt: Date | null;
}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
"contributte/monolog": "^0.5",
"contributte/translation": "^2.0",
"cweagans/composer-patches": "^1.7",
"fastybird/application-library": "dev-main",
"fastybird/exchange-library": "dev-main",
"fastybird/application": "dev-main",
"fastybird/exchange": "dev-main",
"fastybird/json-api": "^0.19",
"fastybird/metadata-library": "dev-main",
"fastybird/simple-auth": "^0.14",
"fastybird/tools-library": "dev-main",
"fastybird/tools": "dev-main",
"ipub/slim-router": "^0.2",
"nettrine/dbal": "^0.8",
"nettrine/orm": "^0.8",
Expand Down
4 changes: 2 additions & 2 deletions config/example.neon
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ extensions:
fbJsonApi : FastyBird\JsonApi\DI\JsonApiExtension
fbSimpleAuth : FastyBird\SimpleAuth\DI\SimpleAuthExtension
fbWebServer : FastyBird\WebServer\DI\WebServerExtension
fbMetadataLibrary : FastyBird\Library\Metadata\DI\MetadataExtension
fbExchangeLibrary : FastyBird\Library\Exchange\DI\ExchangeExtension
fbTools : FastyBird\Core\Tools\DI\ToolsExtension
fbExchange : FastyBird\Core\Exchange\DI\ExchangeExtension

contributteTranslation:
locales:
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastybird/ui-module",
"version": "1.0.0-dev.23",
"version": "1.0.0-dev.24",
"type": "module",
"description" : "FastyBird IoT module for managing visual components",
"keywords": [
Expand Down Expand Up @@ -58,10 +58,10 @@
"pretty:write": "prettier assets --write"
},
"dependencies": {
"@fastybird/metadata-library": "1.0.0-dev.23",
"@fastybird/metadata-library": "1.0.0-dev.24",
"@fastybird/vue-wamp-v1": "^1.2",
"@fastybird/web-ui-icons": "1.0.0-dev.23",
"@fastybird/web-ui-library": "1.0.0-dev.23",
"@fastybird/web-ui-icons": "1.0.0-dev.24",
"@fastybird/web-ui-library": "1.0.0-dev.24",
"@sentry/vue": "^7.113",
"ajv": "^8.12",
"ajv-formats": "^3.0",
Expand Down Expand Up @@ -118,7 +118,7 @@
"stylelint-config-standard-scss": "^13.1",
"stylelint-order": "^6.0",
"stylelint-prettier": "^5.0",
"typescript": "^5.4",
"typescript": "5.6.2",
"typescript-eslint": "^7.8",
"unocss": "^0.59",
"vite": "^5.2",
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace FastyBird\Module\Ui\Commands;

use FastyBird\Library\Application\Helpers as ApplicationHelpers;
use FastyBird\Core\Tools\Helpers as ToolsHelpers;
use FastyBird\Library\Metadata\Types as MetadataTypes;
use FastyBird\Module\Ui;
use Nette\Localization;
Expand Down Expand Up @@ -104,7 +104,7 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $
[
'source' => MetadataTypes\Sources\Module::UI->value,
'type' => 'install-cmd',
'exception' => ApplicationHelpers\Logger::buildException($ex),
'exception' => ToolsHelpers\Logger::buildException($ex),
],
);

Expand Down
Loading

0 comments on commit 60fa1ed

Please sign in to comment.