@spotto/contract 0.2.6 → 0.2.7-alpha.0

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.
@@ -1,5 +1,6 @@
1
1
  import Joi from 'joi';
2
2
  import { IEntityMeta, IEmbeddedEntity } from '../../shared';
3
+ import { Point } from '../../geo-location';
3
4
  export interface ILastLocation extends IEmbeddedEntity {
4
5
  firstSeen: number;
5
6
  lastSeen: number;
@@ -7,15 +8,29 @@ export interface ILastLocation extends IEmbeddedEntity {
7
8
  export interface ICandidateLocation extends IEmbeddedEntity {
8
9
  confidence: number;
9
10
  }
11
+ export interface ITagTelemetry {
12
+ id: string;
13
+ battery?: number;
14
+ voltage?: number;
15
+ temperature?: number;
16
+ }
17
+ export interface IAssetTelemetry {
18
+ battery?: number;
19
+ geolocation?: Point;
20
+ tags?: ITagTelemetry[];
21
+ }
10
22
  export interface GetAssetResponse {
11
23
  id: string;
12
24
  name: string;
13
25
  tagIds?: string[];
14
26
  score?: number;
15
27
  meta?: IEntityMeta;
28
+ telemetry?: IAssetTelemetry;
16
29
  lastLocation?: ILastLocation;
17
30
  candidateLocations?: ICandidateLocation[];
18
31
  }
32
+ export declare const tagTelemetrySchema: Joi.ObjectSchema<ITagTelemetry>;
33
+ export declare const telemetrySchema: Joi.ObjectSchema<IAssetTelemetry>;
19
34
  export declare const candidateLocationSchema: Joi.ObjectSchema<IEmbeddedEntity & ICandidateLocation>;
20
35
  export declare const getAssetResponseSchema: Joi.ObjectSchema<GetAssetResponse>;
21
36
  export declare const validateGetAssetResponse: (payload: any) => GetAssetResponse;
@@ -3,9 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateGetAssetResponse = exports.getAssetResponseSchema = exports.candidateLocationSchema = void 0;
6
+ exports.validateGetAssetResponse = exports.getAssetResponseSchema = exports.candidateLocationSchema = exports.telemetrySchema = exports.tagTelemetrySchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  const shared_1 = require("../../shared");
9
+ const geo_location_1 = require("../../geo-location");
10
+ exports.tagTelemetrySchema = joi_1.default.object({
11
+ id: shared_1.xString,
12
+ battery: shared_1.xPercentage,
13
+ voltage: joi_1.default.number(),
14
+ temperature: joi_1.default.number(),
15
+ });
16
+ exports.telemetrySchema = joi_1.default.object({
17
+ battery: shared_1.xPercentage,
18
+ geolocation: geo_location_1.pointSchema,
19
+ tags: (0, shared_1.xArray)(exports.tagTelemetrySchema),
20
+ });
9
21
  exports.candidateLocationSchema = (0, shared_1.embeddedEntitySchema)().append({
10
22
  confidence: shared_1.xPercentage.required(),
11
23
  });
@@ -19,6 +31,7 @@ exports.getAssetResponseSchema = joi_1.default.object({
19
31
  firstSeen: shared_1.xTime.required(),
20
32
  lastSeen: shared_1.xTime.required(),
21
33
  }),
34
+ telemetry: exports.telemetrySchema,
22
35
  candidateLocations: (0, shared_1.xArray)(exports.candidateLocationSchema),
23
36
  });
24
37
  const validateGetAssetResponse = (payload) => (0, shared_1.validateJoiSchema)(exports.getAssetResponseSchema, payload);
@@ -1 +1 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/types/assets/[id]/get.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,yCAYsB;AAmCT,QAAA,uBAAuB,GAClC,IAAA,6BAAoB,GAAsB,CAAC,MAAM,CAAC;IAChD,UAAU,EAAE,oBAAW,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEQ,QAAA,sBAAsB,GAAG,aAAG,CAAC,MAAM,CAAyB;IAEvE,EAAE,EAAE,kBAAS,CAAC,QAAQ,EAAE;IACxB,IAAI,EAAE,gBAAO,CAAC,QAAQ,EAAE;IAGxB,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC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AC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,IAAI,EAAE,yBAAgB;IACtB,MAAM,EAAE,IAAA,wBAAe,GAAE;IACzB,YAAY,EAAE,IAAA,6BAAoB,GAAiB,CAAC,MAAM,CAAC;QACzD,SAAS,EAAE,cAAK,CAAC,QAAQ,EAAE;QAC3B,QAAQ,EAAE,cAAK,CAAC,QAAQ,EAAE;KAC3B,CAAC;IACF,SAAS,EAAE,uBAAe;IAC1B,kBAAkB,EAAE,IAAA,eAAM,EAAC,+BAAuB,CAAC;CACpD,CAAC,CAAC;AAEI,MAAM,wBAAwB,GAAG,CAAC,OAAY,EAAE,EAAE,CACvD,IAAA,0BAAiB,EAAmB,8BAAsB,EAAE,OAAO,CAAC,CAAC;AAD1D,QAAA,wBAAwB,4BACkC"}
@@ -1,7 +1,7 @@
1
1
  import Joi from 'joi';
2
2
  import { SearchableSortFields, SortOrders } from '../../shared';
3
3
  export declare type AssetSearchField = 'name' | 'tagIds';
4
- export declare type AssetEmbedField = 'meta' | 'tagIds' | 'lastLocation' | 'candidateLocations';
4
+ export declare type AssetEmbedField = 'meta' | 'tagIds' | 'lastLocation' | 'candidateLocations' | 'telemetry';
5
5
  export interface GetAssetsQuery {
6
6
  page?: number;
7
7
  limit?: number;
@@ -18,7 +18,7 @@ exports.getAssetsQuerySchema = joi_1.default.object({
18
18
  search: shared_1.xString.lowercase(),
19
19
  searchFuzzy: shared_1.xBool,
20
20
  searchFields: (0, shared_1.xArrayOfRequiredStrings)('name', 'tagIds'),
21
- embed: (0, shared_1.xArrayOfRequiredStrings)('meta', 'tagIds', 'lastLocation', 'candidateLocations'),
21
+ embed: (0, shared_1.xArrayOfRequiredStrings)('meta', 'tagIds', 'lastLocation', 'candidateLocations', 'telemetry'),
22
22
  });
23
23
  const validateGetAssetsQuery = (payload) => (0, shared_1.validateOptionalJoiSchema)(exports.getAssetsQuerySchema, payload);
24
24
  exports.validateGetAssetsQuery = validateGetAssetsQuery;
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/types/assets/get/query.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,yCAYsB;AA4ET,QAAA,oBAAoB,GAAG,aAAG,CAAC,MAAM,CAAuB;IAEnE,IAAI,EAAE,aAAI;IACV,KAAK,EAAE,aAAI;IAGX,GAAG,EAAE,IAAA,0BAAiB,EAAC,IAAI,CAAC;IAC5B,MAAM,EAAE,IAAA,wBAAe,EAAC,IAAI,CAAC;IAC7B,OAAO,EAAE,cAAK;IACd,QAAQ,EAAE,cAAK;IAGf,IAAI,EAAE,8BAAqB;IAC3B,SAAS,EAAE,mBAAU;IAGrB,MAAM,EAAE,gBAAO,CAAC,SAAS,EAAE;IAC3B,WAAW,EAAE,cAAK;IAClB,YAAY,EAAE,IAAA,gCAAuB,EAAC,MAAM,EAAE,QAAQ,CAAC;IAGvD,KAAK,EAAE,IAAA,gCAAuB,EAC5B,MAAM,EACN,QAAQ,EACR,cAAc,EACd,oBAAoB,CACrB;CACF,CAAC,CAAC;AAEI,MAAM,sBAAsB,GAAG,CAAC,OAAY,EAAE,EAAE,CACrD,IAAA,kCAAyB,EAAiB,4BAAoB,EAAE,OAAO,CAAC,CAAC;AAD9D,QAAA,sBAAsB,0BACwC"}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/types/assets/get/query.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,yCAYsB;AA6ET,QAAA,oBAAoB,GAAG,aAAG,CAAC,MAAM,CAAuB;IAEnE,IAAI,EAAE,aAAI;IACV,KAAK,EAAE,aAAI;IAGX,GAAG,EAAE,IAAA,0BAAiB,EAAC,IAAI,CAAC;IAC5B,MAAM,EAAE,IAAA,wBAAe,EAAC,IAAI,CAAC;IAC7B,OAAO,EAAE,cAAK;IACd,QAAQ,EAAE,cAAK;IAGf,IAAI,EAAE,8BAAqB;IAC3B,SAAS,EAAE,mBAAU;IAGrB,MAAM,EAAE,gBAAO,CAAC,SAAS,EAAE;IAC3B,WAAW,EAAE,cAAK;IAClB,YAAY,EAAE,IAAA,gCAAuB,EAAC,MAAM,EAAE,QAAQ,CAAC;IAGvD,KAAK,EAAE,IAAA,gCAAuB,EAC5B,MAAM,EACN,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,WAAW,CACZ;CACF,CAAC,CAAC;AAEI,MAAM,sBAAsB,GAAG,CAAC,OAAY,EAAE,EAAE,CACrD,IAAA,kCAAyB,EAAiB,4BAAoB,EAAE,OAAO,CAAC,CAAC;AAD9D,QAAA,sBAAsB,0BACwC"}
@@ -0,0 +1,17 @@
1
+ import Joi from 'joi';
2
+ export declare type GeoJsonGeometryTypes = Geometry['type'];
3
+ export declare type GeoJsonTypes = GeoJSON['type'];
4
+ export declare type BBox = [number, number, number, number] | [number, number, number, number, number, number];
5
+ export declare type Position = number[];
6
+ export interface GeoJsonObject {
7
+ type: GeoJsonTypes;
8
+ bbox?: BBox | undefined;
9
+ }
10
+ export declare type GeoJSON = Geometry;
11
+ export declare type Geometry = Point;
12
+ export declare type GeometryObject = Geometry;
13
+ export interface Point extends GeoJsonObject {
14
+ type: 'Point';
15
+ coordinates: Position;
16
+ }
17
+ export declare const pointSchema: Joi.ObjectSchema<Point>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pointSchema = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const schema_1 = require("./shared/schema");
9
+ exports.pointSchema = joi_1.default.object({
10
+ type: schema_1.xString.required(),
11
+ bbox: joi_1.default.array().items(joi_1.default.number()),
12
+ coordinates: joi_1.default.array().items(joi_1.default.number()),
13
+ });
14
+ //# sourceMappingURL=geo-location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-location.js","sourceRoot":"","sources":["../../src/types/geo-location.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,4CAA0C;AA6B7B,QAAA,WAAW,GAAG,aAAG,CAAC,MAAM,CAAc;IACjD,IAAI,EAAE,gBAAO,CAAC,QAAQ,EAAE;IACxB,IAAI,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC;IACrC,WAAW,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC;CAC7C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotto/contract",
3
3
  "license": "ISC",
4
- "version": "0.2.6",
4
+ "version": "0.2.7-alpha.0",
5
5
  "description": "Spotto's API Contract",
6
6
  "main": "./dist/index.js",
7
7
  "files": [
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@airtasker/spot": "^1.4.0",
20
- "@spotto/core-lib": "^0.2.6",
20
+ "@spotto/core-lib": "^0.2.7-alpha.0",
21
21
  "geojson-validation": "^1.0.2",
22
22
  "joi": "^17.4.2",
23
23
  "qs": "^6.9.4"
@@ -30,5 +30,5 @@
30
30
  "@babel/preset-typescript": "^7.12.7",
31
31
  "jest": "^27.3.0"
32
32
  },
33
- "gitHead": "bf4c1be49c3a402cc9f6a9bbd5f55f5488feb059"
33
+ "gitHead": "210f91c69f5675d3fff101d99365d1cbf25c9d45"
34
34
  }