Skip to content

Commit

Permalink
Add missing settings fields in plugin configuration and use it during…
Browse files Browse the repository at this point in the history
… indices creation
  • Loading branch information
alexandrebouthinon committed Mar 22, 2024
1 parent 698e591 commit 7cc0911
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 23 deletions.
41 changes: 27 additions & 14 deletions lib/modules/plugin/DeviceManagerEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,12 @@ export class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
engineGroup,
);

await this.sdk.collection.create(
engineId,
InternalCollection.ASSETS,
const settings = this.config.engineCollections.asset.settings;

await this.sdk.collection.create(engineId, InternalCollection.ASSETS, {
mappings,
);
settings,
});

return InternalCollection.ASSETS;
}
Expand All @@ -182,20 +183,30 @@ export class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {

_.merge(mappings.properties.asset, assetsCollectionMappings);

const settings = this.config.engineCollections.assetHistory.settings;

await this.sdk.collection.create(
engineId,
InternalCollection.ASSETS_HISTORY,
mappings,
{
mappings,
settings,
},
);

return InternalCollection.ASSETS_HISTORY;
}

async createAssetsGroupsCollection(engineId: string) {
const settings = this.config.engineCollections.assetGroup.settings;

await this.sdk.collection.create(
engineId,
InternalCollection.ASSETS_GROUPS,
{ mappings: assetGroupsMappings },
{
mappings: assetGroupsMappings,
settings,
},
);

return InternalCollection.ASSETS_GROUPS;
Expand Down Expand Up @@ -260,23 +271,25 @@ export class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
const mappings =
await this.getDigitalTwinMappings<DeviceModelContent>("device");

await this.sdk.collection.create(
engineId,
InternalCollection.DEVICES,
const settings = this.config.engineCollections.device.settings;

await this.sdk.collection.create(engineId, InternalCollection.DEVICES, {
mappings,
);
settings,
});

return InternalCollection.DEVICES;
}

async createMeasuresCollection(engineId: string, engineGroup: string) {
const mappings = await this.getMeasuresMappings(engineGroup);

await this.sdk.collection.create(
engineId,
InternalCollection.MEASURES,
const settings = this.config.engineCollections.measures.settings;

await this.sdk.collection.create(engineId, InternalCollection.MEASURES, {
mappings,
);
settings,
});

return InternalCollection.MEASURES;
}
Expand Down
13 changes: 9 additions & 4 deletions lib/modules/plugin/DeviceManagerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,14 @@ export class DeviceManagerPlugin extends Plugin {
dynamic: "strict",
properties: {},
},
settings: {},
},
devices: {
name: "devices",
mappings: devicesMappings,
settings: {},
},
payloads: {
name: "payloads",
mappings: payloadsMappings,
settings: {},
},
},
engineCollections: {
Expand All @@ -282,16 +279,24 @@ export class DeviceManagerPlugin extends Plugin {
dynamic: "strict",
properties: {},
},
settings: {},
},
asset: {
name: InternalCollection.ASSETS,
mappings: assetsMappings,
},
assetGroup: {
name: InternalCollection.ASSETS_GROUPS,
},
assetHistory: {
name: InternalCollection.ASSETS_HISTORY,
},
device: {
name: InternalCollection.DEVICES,
mappings: devicesMappings,
},
measures: {
name: InternalCollection.MEASURES,
},
},
};
/* eslint-enable sort-keys */
Expand Down
24 changes: 19 additions & 5 deletions lib/modules/plugin/types/DeviceManagerConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,49 @@ export type DeviceManagerConfiguration = {
config: {
name: string;
mappings: JSONObject;
settings: JSONObject;
settings?: JSONObject;
};

devices: {
name: string;
mappings: JSONObject;
settings: JSONObject;
settings?: JSONObject;
};

payloads: {
name: string;
mappings: JSONObject;
settings: JSONObject;
settings?: JSONObject;
};
};

engineCollections: {
config: {
name: string;
mappings: JSONObject;
settings: JSONObject;
mappings: CollectionMappings;
settings?: JSONObject;
};
asset: {
name: string;
mappings: CollectionMappings;
settings?: JSONObject;
};
assetGroup: {
name: string;
settings?: JSONObject;
};
assetHistory: {
name: string;
settings?: JSONObject;
};
device: {
name: string;
mappings: CollectionMappings;
settings?: JSONObject;
};
measures: {
name: string;
settings?: JSONObject;
};
};
};

0 comments on commit 7cc0911

Please sign in to comment.