Created
November 9, 2022 18:04
-
-
Save ldco2016/b741002d81ef23fe36d032c9554d350c to your computer and use it in GitHub Desktop.
a query management system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable max-len */ | |
declare namespace V2QMM {} | |
declare namespace V2QMM.TYPES { | |
/** | |
* Place holder for ISO DateTime strings. When we can properly extend primitives for custom "brand" types, this should be able to validate | |
* as formatted `yyyy-MM-DD'T'hh:mm:ss'Z"` | |
*/ | |
export type ISODateTime = string; | |
/** | |
* Place holder for ISO TimeOnle strings. When we can properly extend primitives for custom "brand" types, this should be able to validate | |
* as formatted `hh:mm:ss'Z"` | |
*/ | |
export type ISOTimeOnly = string; | |
/** | |
* Place holder for RegistrationID strings. When we can properly extend primitives for custom "brand" types, this should be able to | |
* validate as a UUID string | |
*/ | |
export type RegistrationID = string; | |
/** | |
* Define valid types for query level objects in pure json | |
*/ | |
export type SignalQueryTypes = V2QMM.JSON.QUERY.SIGNALS.Geofence | V2QMM.JSON.QUERY.SIGNALS.Device | V2QMM.JSON.QUERY.SIGNALS.IPAddress | V2QMM.JSON.QUERY.SIGNALS.Country; | |
/** | |
* Define valid types for query element level objects in pure json | |
*/ | |
export type SignalQueryElements = V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Area | V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Polygon | V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.RegistrationID | V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.IPAddress | V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Country; | |
/** | |
* Define the valid pure json types for signal searches | |
*/ | |
export type ValidSignalJson = V2QMM.TYPES.SignalQueryTypes | V2QMM.TYPES.SignalQueryElements; | |
/** | |
* Define the valid types for query level objects from Mongo | |
*/ | |
export type SignalMongoQueryTypes = V2QMM.MONGO.QUERY.SIGNALS.Geofence | V2QMM.MONGO.QUERY.SIGNALS.Device; | |
/** | |
* Define the valid types for query element level objects from Mongo | |
*/ | |
export type SignalMongoQueryElements = V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Area | V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Polygon | V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.RegistrationID | V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Country; | |
/** | |
* Define the valid Mongo types | |
*/ | |
export type ValidSignalMongo = V2QMM.TYPES.SignalMongoQueryTypes | V2QMM.TYPES.SignalMongoQueryElements; | |
} | |
/************************************************************** | |
* | |
* "Pure" JSON Specific Namespaces | |
* | |
*************************************************************/ | |
declare namespace V2QMM.JSON { | |
/** | |
* Defines a generic coordinate object | |
* @export | |
* @interface Coordinate | |
*/ | |
export interface Coordinate { | |
latitude: number; | |
longitude: number; | |
} | |
} | |
/** | |
* Namespace for shared properties across Signals and IP Address query level and query element level objects | |
*/ | |
declare namespace V2QMM.JSON.QUERY { | |
/** | |
* Defines common properties shared among signals query level and signals query element level json objects | |
* @export | |
* @interface SignalsShared | |
* @date 2022-05-26 Added apiVersion | |
*/ | |
export interface SignalsShared { | |
startDate: V2QMM.TYPES.ISODateTime; | |
endDate: V2QMM.TYPES.ISODateTime; | |
startTimeOfDay?: V2QMM.TYPES.ISOTimeOnly; | |
endTimeOfDay?: V2QMM.TYPES.ISOTimeOnly; | |
useTimeOfDay?: boolean; | |
includeFlags: number; | |
includeExactFlags?: number; | |
includeNoFlags: boolean; | |
excludeFlags: number; | |
excludeExactFlags?: number; | |
apiVersion?: string; | |
name?: string; | |
} | |
} | |
/** | |
* Namespace for Signals data query level objects | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-namespace | |
declare namespace V2QMM.JSON.QUERY.SIGNALS { | |
/** | |
* Defines Geofence signals query level objects | |
* @export | |
* @interface Geofence | |
* @extends {Partial<V2QMM.JSON.QUERY.SignalsShared>} | |
*/ | |
export interface Geofence extends Partial<V2QMM.JSON.QUERY.SignalsShared> { | |
areas: Partial<V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Area>[]; | |
polygons: Partial<V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Polygon>[]; | |
locations?: V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Location[]; | |
inAll: boolean; | |
} | |
/** | |
* Defines Device signals query level objects | |
* @export | |
* @interface Device | |
* @extends {Partial<V2QMM.JSON.QUERY.SignalsShared>} | |
*/ | |
export interface Device extends Partial<V2QMM.JSON.QUERY.SignalsShared> { | |
registrationIDs: Partial<V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.RegistrationID>[]; | |
} | |
/** | |
* Defines IP Address signals query level objects | |
* @export | |
* @interface IPAddress | |
* @extends {Partial<V2QMM.JSON.QUERY.SignalsShared>} | |
*/ | |
export interface IPAddress extends Partial<V2QMM.JSON.QUERY.SignalsShared> { | |
ipAddresses: Partial<V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.IPAddress>[]; | |
inMin: number; | |
} | |
/** | |
* Defines Country signals query level objects | |
* @export | |
* @interface IPAddress | |
* @extends {Partial<V2QMM.JSON.QUERY.SignalsShared>} | |
*/ | |
export interface Country extends Partial<V2QMM.JSON.QUERY.SignalsShared> { | |
countries: Partial<V2QMM.JSON.QUERY.SIGNALS.ELEMENTS.Country>[]; | |
inMin: number; | |
} | |
} | |
/** | |
* Namespace for Signals data query elements level objects | |
*/ | |
declare namespace V2QMM.JSON.QUERY.SIGNALS.ELEMENTS { | |
/** | |
* Defines Area Fence signals query elements level objects | |
* @export | |
* @interface Area | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface Area extends V2QMM.JSON.QUERY.SignalsShared { | |
radius: number; | |
latitude: number; | |
longitude: number; | |
} | |
/** | |
* Defines Polygon Fence signals query elements level objects | |
* @export | |
* @interface Polygon | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface Polygon extends V2QMM.JSON.QUERY.SignalsShared { | |
coordinates: V2QMM.JSON.Coordinate[]; | |
} | |
/** | |
* Defines RegistrationID (Device) signals query elements level objects | |
* @export | |
* @interface RegistrationID | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface RegistrationID extends V2QMM.JSON.QUERY.SignalsShared { | |
registrationID: V2QMM.TYPES.RegistrationID; | |
} | |
/** | |
* Defines IP Address signals query elements level objects | |
* @export | |
* @interface IPAddress | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface IPAddress extends V2QMM.JSON.QUERY.SignalsShared { | |
ipAddress: string; | |
} | |
/** | |
* Defines Country signals query elements level objects | |
* @export | |
* @interface Country | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface Country extends V2QMM.JSON.QUERY.SignalsShared { | |
countryCode: string; | |
countryName: string; | |
countryFlag: string; | |
} | |
export interface Location { | |
name?: string; | |
position: V2QMM.JSON.Coordinate; | |
} | |
} | |
/** | |
* Namespace for IP Address based device data query level objects | |
*/ | |
declare namespace V2QMM.JSON.QUERY.IPDEVICES { | |
/** | |
* Defines IP Address device query level objects | |
* @export | |
* @interface IPAddress | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface IPAddress extends V2QMM.JSON.QUERY.SignalsShared { | |
deviceCountOnly: boolean; | |
includeRegistrationIDs: V2QMM.TYPES.RegistrationID[]; | |
excludeRegistrationIDs: V2QMM.TYPES.RegistrationID[]; | |
ipAddresses: V2QMM.JSON.QUERY.IPDEVICES.ELEMENTS.IPDevice[]; | |
inMin: number; | |
} | |
} | |
/** | |
* Namespace for IP Address based device data query elements level objects | |
*/ | |
declare namespace V2QMM.JSON.QUERY.IPDEVICES.ELEMENTS { | |
/** | |
* Defines IP Address device query elements level objects | |
* @export | |
* @interface IPDevice | |
* @extends {V2QMM.JSON.QUERY.SignalsShared} | |
*/ | |
export interface IPDevice extends V2QMM.JSON.QUERY.SignalsShared { | |
ipAddress: string; | |
} | |
} | |
/************************************************************** | |
* | |
* Mongo Specific Namespaces | |
* | |
*************************************************************/ | |
declare namespace V2QMM.MONGO { | |
/** | |
* Defines some standard properties that all of our Mongo resources should have. Provides for '_id' and optional 'createdAt' and | |
* 'updatedAt' properties. | |
* @export | |
* @interface MongoStandardProperties | |
*/ | |
export interface MongoStandardProperties { | |
_id: string; | |
createdAt?: string; | |
updatedAt?: string; | |
} | |
/** | |
* Defines the properties all of our "Library" objects (query and query elements that can be saved) should have. Provides for 'name' and | |
* optional 'created', 'createdBy', 'sharedwith', 'favorite', 'accessedAt' properties. | |
* @export | |
* @interface LibraryObjectShared | |
* @extends {MongoStandardProperties} | |
*/ | |
export interface LibraryObjectShared extends V2QMM.MONGO.MongoStandardProperties { | |
name?: string; | |
created?: string; | |
createdBy?: string | V2QMM.MONGO.MongoUser; // ObjectID also | |
sharedwith?: string[]; // ObjectID or user account, | |
favorite?: string[]; // ObjectID or user account, | |
accessedAt?: string; | |
} | |
/** | |
* Defines the properties of a Mongo Account. | |
* @date 2020-11-03 | |
* @export | |
* @interface MongoUser | |
*/ | |
export interface MongoUser { | |
profile: { | |
firstname: string; | |
lastname: string; | |
email: string; | |
}; | |
_id: string; | |
} | |
/** | |
* Defines the properties that all mapped query objects should have coming back from Mongo | |
* @export | |
* @interface MappedQuery | |
* @extends {LibraryObjectShared} | |
*/ | |
export interface MappedQuery extends V2QMM.MONGO.LibraryObjectShared { | |
maxzoom: number; | |
map: { | |
center: { | |
lat: number; | |
lng: number; | |
}; | |
zoom: number; | |
}; | |
useTimeOfDay: boolean; | |
mapcanvas: string; | |
apiVersion: string; | |
} | |
/** | |
* @deprecated Use V2QMM.MONGO.LibraryObjectShared | |
*/ | |
export interface SharedQueryable { | |
_id: string; | |
name: string; | |
created: string; | |
createdAt?: string; | |
createdBy: string; // ObjectID also | |
sharedwith: string[]; // ObjectID or user account, | |
favorite: string[]; // ObjectID or user account, | |
accessedAt: string; | |
} | |
/** | |
* @deprecated use V2QMM.MONGO.MappedQuery | |
*/ | |
export interface SharedMapCentricQuery extends V2QMM.MONGO.LibraryObjectShared { | |
maxzoom: number; | |
map: { | |
center: { | |
lat: number; | |
lng: number; | |
}; | |
zoom: number; | |
}; | |
useTimeOfDay: boolean; | |
mapcanvas: string; | |
} | |
/** | |
* @deprecated use V2QMM.MONGO.QUERY.CommonParameters | |
*/ | |
export interface SharedParameters { | |
startDate: V2QMM.TYPES.ISODateTime; | |
endDate: V2QMM.TYPES.ISODateTime; | |
startTimeOfDay?: V2QMM.TYPES.ISOTimeOnly; | |
endTimeOfDay?: V2QMM.TYPES.ISOTimeOnly; | |
includeFlags: number; | |
includeExactFlags?: number; | |
includeNoFlags: boolean; | |
excludeFlags: number; | |
excludeExactFlags?: number; | |
} | |
} | |
declare namespace V2QMM.MONGO.QUERY { | |
/** | |
* Defines the properties common under the `parameters` key of any query level object. These properties may also be present under query | |
* elements level objects. | |
* @export | |
* @interface CommonParameters | |
* @date 2022-05-26 Added apiVersion | |
*/ | |
export interface CommonParameters { | |
startDate?: V2QMM.TYPES.ISODateTime; | |
endDate?: V2QMM.TYPES.ISODateTime; | |
startTimeOfDay?: V2QMM.TYPES.ISOTimeOnly; | |
endTimeOfDay?: V2QMM.TYPES.ISOTimeOnly; | |
useTimeOfDay?: boolean; | |
includeFlags: number; | |
includeExactFlags?: number; | |
includeNoFlags?: boolean; | |
excludeFlags?: number; | |
excludeExactFlags?: number; | |
apiVersion?: string; | |
} | |
export interface QuerySharedProperties extends V2QMM.MONGO.LibraryObjectShared { | |
maxzoom: number; | |
map: { | |
center: { | |
lat: number; | |
lng: number; | |
}; | |
zoom: number; | |
}; | |
useTimeOfDay: boolean; | |
mapcanvas: string; | |
} | |
export interface FenceParameters extends V2QMM.MONGO.QUERY.CommonParameters { | |
areas: V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Area[]; | |
polygons: V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Polygon[]; | |
locations: V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Location[]; | |
inAll: boolean; | |
} | |
export interface DeviceParameters extends V2QMM.MONGO.QUERY.CommonParameters { | |
registrationIDs: V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.RegistrationID[]; | |
unbound?: boolean; | |
} | |
export interface IPSearchParameters extends V2QMM.MONGO.QUERY.CommonParameters { | |
ipAddresses: V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.IPAddress[]; | |
inMin: number; | |
} | |
export interface CountryParameters extends V2QMM.MONGO.QUERY.CommonParameters { | |
countries: V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS.Country[]; | |
} | |
} | |
declare namespace V2QMM.MONGO.QUERY.SIGNALS { | |
/** | |
* Defines the Mongo structure of a GeoFence signals query library object | |
* @export | |
* @interface Geofence | |
* @extends {V2QMM.MONGO.MappedQuery} | |
*/ | |
export interface Geofence extends V2QMM.MONGO.MappedQuery { | |
parameters: Partial<V2QMM.MONGO.QUERY.FenceParameters>; | |
} | |
/** | |
* Defines the Mongo structure of a Device signals query library object | |
* @export | |
* @interface Device | |
* @extends {V2QMM.MONGO.MappedQuery} | |
*/ | |
export interface Device extends V2QMM.MONGO.MappedQuery { | |
parameters: Partial<V2QMM.MONGO.QUERY.DeviceParameters>; | |
} | |
/** | |
* Defines the Mongo structure of an IP Address signals query library object | |
* @export | |
* @interface IPAddress | |
* @extends {V2QMM.MONGO.MappedQuery} | |
*/ | |
export interface IPAddress extends V2QMM.MONGO.MappedQuery { | |
parameters: Partial<V2QMM.MONGO.QUERY.IPSearchParameters>; | |
ipSearch?: Partial<V2QMM.MONGO.QUERY.IPSearchParameters>; | |
} | |
/** | |
* Defines the Mongo structure of a County signals query library object | |
*/ | |
export interface Country extends V2QMM.MONGO.MappedQuery { | |
parameters: Partial<V2QMM.MONGO.QUERY.CountryParameters>; | |
} | |
} | |
declare namespace V2QMM.MONGO.QUERY.SIGNALS.ELEMENTS { | |
export interface Area extends Partial<V2QMM.MONGO.LibraryObjectShared>, Partial<V2QMM.MONGO.QUERY.CommonParameters> { | |
label: string; | |
type: string; | |
radius: number; | |
latitude: number; | |
longitude: number; | |
} | |
export interface Polygon extends Partial<V2QMM.MONGO.LibraryObjectShared>, Partial<V2QMM.MONGO.QUERY.CommonParameters> { | |
label: string; | |
type: string; | |
coordinates: V2QMM.JSON.Coordinate[]; | |
} | |
export interface Location extends V2QMM.MONGO.LibraryObjectShared { | |
position: V2QMM.JSON.Coordinate; | |
} | |
export interface RegistrationID extends Partial<V2QMM.MONGO.LibraryObjectShared>, Partial<V2QMM.MONGO.QUERY.CommonParameters> { | |
registrationID: string; | |
} | |
export interface IPAddress extends Partial<V2QMM.MONGO.LibraryObjectShared>, Partial<V2QMM.MONGO.QUERY.CommonParameters> { | |
ip?: string; | |
ipAddress?: string; | |
} | |
export interface Country extends Partial<V2QMM.MONGO.LibraryObjectShared>, Partial<V2QMM.MONGO.QUERY.CommonParameters> { | |
countryCode: string; | |
countryName: string; | |
countryFlag: string; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment