Skip to content

Commit

Permalink
Move ask / onAsk to kuzzle-plugin-commons (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauNeko authored Mar 22, 2024
1 parent de00fb7 commit 698e591
Show file tree
Hide file tree
Showing 13 changed files with 1,188 additions and 1,915 deletions.
3 changes: 2 additions & 1 deletion lib/modules/asset/AssetHistoryService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { onAsk } from "kuzzle-plugin-commons";
import { mCreateRequest } from "kuzzle-sdk";

import { DeviceManagerPlugin, InternalCollection } from "../plugin";
import { onAsk, BaseService } from "../shared";
import { BaseService } from "../shared";

import { AskAssetHistoryAdd } from "./types/AssetEvents";
import {
Expand Down
9 changes: 4 additions & 5 deletions lib/modules/asset/AssetService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BadRequestError, KuzzleRequest, User } from "kuzzle";
import { ask, onAsk } from "kuzzle-plugin-commons";
import {
BaseRequest,
DocumentSearchResult,
Expand All @@ -23,18 +24,17 @@ import {
InternalCollection,
} from "../plugin";
import {
BaseService,
EmbeddedMeasure,
Metadata,
ask,
SearchParams,
flattenObject,
lock,
onAsk,
BaseService,
SearchParams,
} from "../shared";

import { AssetHistoryService } from "./AssetHistoryService";
import { AssetSerializer } from "./model/AssetSerializer";
import { ApiAssetMigrateTenantResult } from "./types/AssetApi";
import { AssetContent } from "./types/AssetContent";
import {
AskAssetRefreshModel,
Expand All @@ -45,7 +45,6 @@ import {
AssetHistoryContent,
AssetHistoryEventMetadata,
} from "./types/AssetHistoryContent";
import { ApiAssetMigrateTenantResult } from "./types/AssetApi";

export class AssetService extends BaseService {
private assetHistoryService: AssetHistoryService;
Expand Down
7 changes: 4 additions & 3 deletions lib/modules/decoder/PayloadService.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { BadRequestError, KuzzleRequest } from "kuzzle";
import { ask, onAsk } from "kuzzle-plugin-commons";
import { JSONObject, KDocument } from "kuzzle-sdk";
import { v4 as uuidv4 } from "uuid";

import { DeviceManagerPlugin, InternalCollection } from "../plugin";
import { DeviceContent, DeviceSerializer } from "../device";
import { AskMeasureIngest, DecodedMeasurement } from "../measure";
import { BaseService, ask, onAsk } from "../shared";
import { DeviceManagerPlugin, InternalCollection } from "../plugin";
import { BaseService } from "../shared";

import { DecodedPayload } from "./DecodedPayload";
import { Decoder } from "./Decoder";
import { AskPayloadReceiveFormated } from "./types/PayloadEvents";
import { DecodingState } from "./DecodingState";
import { SkipError } from "./SkipError";
import { AskPayloadReceiveFormated } from "./types/PayloadEvents";

export class PayloadService extends BaseService {
constructor(plugin: DeviceManagerPlugin) {
Expand Down
38 changes: 16 additions & 22 deletions lib/modules/device/DeviceService.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
import { BadRequestError, KuzzleRequest } from "kuzzle";
import { ask, onAsk } from "kuzzle-plugin-commons";
import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";

import {
AskAssetHistoryAdd,
AssetContent,
AssetHistoryEventLink,
AssetHistoryEventUnlink,
} from "./../asset";
import { InternalCollection, DeviceManagerPlugin } from "../plugin";
import {
Metadata,
lock,
ask,
onAsk,
BaseService,
SearchParams,
} from "../shared";
import { DecodedMeasurement } from "../measure";
import {
AskModelAssetGet,
AskModelDeviceGet,
AssetModelContent,
DeviceModelContent,
} from "../model";
import { DecodedMeasurement } from "../measure";
import { DeviceManagerPlugin, InternalCollection } from "../plugin";
import { BaseService, Metadata, SearchParams, lock } from "../shared";
import {
AskAssetHistoryAdd,
AssetContent,
AssetHistoryEventLink,
AssetHistoryEventUnlink,
} from "./../asset";

import { DeviceContent } from "./types/DeviceContent";
import { AskPayloadReceiveFormated } from "../decoder/types/PayloadEvents";
import { DeviceSerializer } from "./model/DeviceSerializer";
import { ApiDeviceLinkAssetRequest } from "./types/DeviceApi";
import { DeviceContent } from "./types/DeviceContent";
import {
AskDeviceUnlinkAsset,
AskDeviceAttachEngine,
AskDeviceDetachEngine,
AskDeviceLinkAsset,
AskDeviceUnlinkAsset,
EventDeviceUpdateAfter,
EventDeviceUpdateBefore,
AskDeviceAttachEngine,
AskDeviceLinkAsset,
} from "./types/DeviceEvents";
import { ApiDeviceLinkAssetRequest } from "./types/DeviceApi";
import { AskPayloadReceiveFormated } from "../decoder/types/PayloadEvents";

type MeasureName = { asset: string; device: string; type: string };

Expand Down
4 changes: 2 additions & 2 deletions lib/modules/measure/MeasureExporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UUID } from "node:crypto";
import { InternalError, JSONObject, KHit, User } from "kuzzle";
import { ask } from "kuzzle-plugin-commons";
import _ from "lodash";
import { UUID } from "node:crypto";
// ? queryTranslator is not exposed by package kuzzle so we need to import directly th file
import QueryTranslator from "kuzzle/lib/service/storage/queryTranslator.js";

Expand All @@ -15,7 +16,6 @@ import {
Column,
DigitalTwinContent,
ExportParams,
ask,
flattenObject,
} from "../shared";

Expand Down
11 changes: 2 additions & 9 deletions lib/modules/measure/MeasureService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BadRequestError, JSONObject, KDocument } from "kuzzle";
import { ask, onAsk } from "kuzzle-plugin-commons";
import _ from "lodash";

import {
Expand All @@ -11,15 +12,7 @@ import {
} from "../asset";
import { DeviceContent } from "../device";
import { DeviceManagerPlugin, InternalCollection } from "../plugin";
import {
ask,
BaseService,
keepStack,
lock,
Metadata,
objectDiff,
onAsk,
} from "../shared";
import { BaseService, Metadata, keepStack, lock, objectDiff } from "../shared";

import { DecodedMeasurement, MeasureContent } from "./types/MeasureContent";
import {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/model/ModelService.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BadRequestError, Inflector, NotFoundError } from "kuzzle";
import { ask, onAsk } from "kuzzle-plugin-commons";
import { JSONObject, KDocument } from "kuzzle-sdk";

import {
AskEngineUpdateAll,
DeviceManagerPlugin,
InternalCollection,
} from "../plugin";
import { ask, onAsk } from "../shared/utils/ask";

import { AskAssetRefreshModel } from "../asset";
import { BaseService, flattenObject } from "../shared";
Expand Down
19 changes: 11 additions & 8 deletions lib/modules/plugin/DeviceManagerEngine.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import _ from "lodash";
import { Backend, InternalError, Plugin } from "kuzzle";
import {
AbstractEngine,
ConfigManager,
EngineContent,
onAsk,
} from "kuzzle-plugin-commons";
import { JSONObject } from "kuzzle-sdk";
import { AbstractEngine, ConfigManager } from "kuzzle-plugin-commons";
import { EngineContent } from "kuzzle-plugin-commons";
import _ from "lodash";

import { assetsHistoryMappings, assetGroupsMappings } from "../asset";
import { assetGroupsMappings, assetsHistoryMappings } from "../asset";
import { NamedMeasures } from "../decoder";
import { getEmbeddedMeasureMappings, measuresMappings } from "../measure";
import {
AssetModelContent,
DeviceModelContent,
MeasureModelContent,
} from "../model";
import { getEmbeddedMeasureMappings, measuresMappings } from "../measure";
import { onAsk } from "../shared";
import { NamedMeasures } from "../decoder";

import { DeviceManagerConfiguration } from "./types/DeviceManagerConfiguration";
import { DeviceManagerPlugin } from "./DeviceManagerPlugin";
import { DeviceManagerConfiguration } from "./types/DeviceManagerConfiguration";
import { InternalCollection } from "./types/InternalCollection";

export type AskEngineList = {
Expand Down
7 changes: 3 additions & 4 deletions lib/modules/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export * from "./services";
export * from "./Module";
export * from "./services";
export * from "./types/DigitalTwinContent";
export * from "./types/Metadata";
export * from "./types/EmbeddedMeasure";
export * from "./types/KuzzleRole";
export * from "./utils/lock";
export * from "./types/Metadata";
export * from "./utils/flattenObject";
export * from "./utils/ask";
export * from "./utils/keepStack";
export * from "./utils/lock";
export * from "./utils/objectDiff";
7 changes: 4 additions & 3 deletions lib/modules/shared/services/DigitalTwinExporter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { UUID } from "node:crypto";
import { JSONObject } from "kuzzle";
import { ask } from "kuzzle-plugin-commons";
import { UUID } from "node:crypto";

import { DigitalTwinContent, flattenObject } from "../";
import { NamedMeasures } from "../../decoder";
import { InternalCollection } from "../../plugin";
import {
AskModelMeasureGet,
AssetModelContent,
DeviceModelContent,
} from "../../model";
import { DigitalTwinContent, ask, flattenObject } from "../";
import { InternalCollection } from "../../plugin";
import { AbstractExporter, Column } from "./AbstractExporter";

interface MeasureColumn extends Column {
Expand Down
31 changes: 0 additions & 31 deletions lib/modules/shared/utils/ask.ts

This file was deleted.

Loading

0 comments on commit 698e591

Please sign in to comment.