@spytecgps/nova-orm 1.4.243 → 1.4.245

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,4 +1,24 @@
1
- export type JobStatus = 'Upcoming' | 'In Progress' | 'Completed';
1
+ /**
2
+ * Legacy three-state status. The processor keeps this in sync with `lifecycle`
3
+ * via {@link deriveLegacyStatus} so existing FE callers continue to work while
4
+ * the three-axis model rolls out.
5
+ */
6
+ export type JobStatus = 'Upcoming' | 'In Progress' | 'Completed' | 'Cancelled';
7
+ /**
8
+ * Mutually exclusive lifecycle phase. Exactly one at any time.
9
+ * Drives the primary status chip on the job card.
10
+ */
11
+ export type JobLifecycle = 'Upcoming' | 'AwaitingUpdate' | 'AtOrigin' | 'InProgress' | 'Arriving' | 'Arrived' | 'Complete' | 'Cancelled';
12
+ /**
13
+ * Non-exclusive health signals. Zero or more apply at once.
14
+ */
15
+ export type JobHealthChip = 'OnTrack' | 'Delayed' | 'DelayedStart' | 'NotReporting' | 'RuleViolation' | 'LowBattery';
16
+ /**
17
+ * Arrival evidence state. Mutually exclusive.
18
+ */
19
+ export type JobProofState = 'NotArrived' | 'FirstObserved' | 'ArrivalConfirmed' | 'Unknown';
20
+ /** Derived when lifecycle reaches Complete. */
21
+ export type JobOutcome = 'on_time' | 'late' | 'early';
2
22
  export interface JobRule {
3
23
  id: string;
4
24
  kind: string;
@@ -6,6 +26,7 @@ export interface JobRule {
6
26
  config?: Record<string, unknown>;
7
27
  violated?: boolean;
8
28
  violationDetail?: string;
29
+ violatedAt?: string;
9
30
  }
10
31
  export interface JobTimelineEvent {
11
32
  id: string;
@@ -13,23 +34,43 @@ export interface JobTimelineEvent {
13
34
  time: string;
14
35
  kind?: 'now' | 'alert' | 'info';
15
36
  }
37
+ export declare const ACTIVE_JOB_LIFECYCLES: ReadonlySet<JobLifecycle>;
38
+ export declare const deriveLegacyStatus: (lifecycle: JobLifecycle) => JobStatus;
16
39
  export declare class Job {
17
40
  id: number;
18
41
  clientId: number;
19
42
  imei: string;
20
43
  name: string;
44
+ /** Legacy three-state — kept in sync with {@link lifecycle} by the processor. */
21
45
  status: JobStatus;
46
+ lifecycle: JobLifecycle;
47
+ healthChips: JobHealthChip[] | null;
48
+ proofState: JobProofState;
49
+ outcome: JobOutcome | null;
22
50
  startLat: number | null;
23
51
  startLng: number | null;
24
52
  startLabel: string | null;
25
53
  startDetail: string | null;
54
+ startRadiusM: number;
26
55
  endLat: number | null;
27
56
  endLng: number | null;
28
57
  endLabel: string | null;
29
58
  endDetail: string | null;
59
+ endRadiusM: number;
30
60
  scheduledStart: Date | null;
31
61
  targetArrival: Date | null;
62
+ startedAt: Date | null;
63
+ firstObservedAt: Date | null;
32
64
  arrivedAt: Date | null;
65
+ completedAt: Date | null;
66
+ cancelledAt: Date | null;
67
+ pingsInEndZone: number;
68
+ lastPositionAt: Date | null;
69
+ lastEvaluatedAt: Date | null;
70
+ etaArrivalAt: Date | null;
71
+ etaUpdatedAt: Date | null;
72
+ etaDriveSeconds: number | null;
73
+ etaDistanceMeters: number | null;
33
74
  rules: JobRule[] | null;
34
75
  timeline: JobTimelineEvent[] | null;
35
76
  liveLinkToken: string | null;
@@ -1 +1 @@
1
- "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("typeorm"),a=require("../utils/uuidTransformer.js");exports.Job=class Job{id;clientId;imei;name;status;startLat;startLng;startLabel;startDetail;endLat;endLng;endLabel;endDetail;scheduledStart;targetArrival;arrivedAt;rules;timeline;liveLinkToken;createdBy;createdAt;modifiedBy;modifiedAt;deletedAt;deletedBy},e.__decorate([t.PrimaryGeneratedColumn({type:"int",name:"id"}),e.__metadata("design:type",Number)],exports.Job.prototype,"id",void 0),e.__decorate([t.Column("int",{name:"clientId"}),e.__metadata("design:type",Number)],exports.Job.prototype,"clientId",void 0),e.__decorate([t.Column("varchar",{name:"imei",length:15}),e.__metadata("design:type",String)],exports.Job.prototype,"imei",void 0),e.__decorate([t.Column("varchar",{name:"name",length:255}),e.__metadata("design:type",String)],exports.Job.prototype,"name",void 0),e.__decorate([t.Column("varchar",{name:"status",length:20}),e.__metadata("design:type",String)],exports.Job.prototype,"status",void 0),e.__decorate([t.Column("double",{name:"startLat",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"startLat",void 0),e.__decorate([t.Column("double",{name:"startLng",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"startLng",void 0),e.__decorate([t.Column("varchar",{name:"startLabel",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"startLabel",void 0),e.__decorate([t.Column("varchar",{name:"startDetail",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"startDetail",void 0),e.__decorate([t.Column("double",{name:"endLat",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"endLat",void 0),e.__decorate([t.Column("double",{name:"endLng",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"endLng",void 0),e.__decorate([t.Column("varchar",{name:"endLabel",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"endLabel",void 0),e.__decorate([t.Column("varchar",{name:"endDetail",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"endDetail",void 0),e.__decorate([t.Column("datetime",{name:"scheduledStart",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"scheduledStart",void 0),e.__decorate([t.Column("datetime",{name:"targetArrival",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"targetArrival",void 0),e.__decorate([t.Column("datetime",{name:"arrivedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"arrivedAt",void 0),e.__decorate([t.Column("json",{name:"rules",nullable:!0}),e.__metadata("design:type",Array)],exports.Job.prototype,"rules",void 0),e.__decorate([t.Column("json",{name:"timeline",nullable:!0}),e.__metadata("design:type",Array)],exports.Job.prototype,"timeline",void 0),e.__decorate([t.Column("binary",{name:"liveLinkToken",length:16,nullable:!0,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"liveLinkToken",void 0),e.__decorate([t.Column("binary",{name:"createdBy",length:16,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"createdBy",void 0),e.__decorate([t.CreateDateColumn({name:"createdAt"}),e.__metadata("design:type",Date)],exports.Job.prototype,"createdAt",void 0),e.__decorate([t.Column("binary",{name:"modifiedBy",length:16,nullable:!0,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"modifiedBy",void 0),e.__decorate([t.UpdateDateColumn({name:"modifiedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"modifiedAt",void 0),e.__decorate([t.DeleteDateColumn({name:"deletedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"deletedAt",void 0),e.__decorate([t.Column("binary",{name:"deletedBy",length:16,nullable:!0,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"deletedBy",void 0),exports.Job=e.__decorate([t.Index("ixJobClientIdStatus",["clientId","status"],{}),t.Index("ixJobClientIdCreatedBy",["clientId","createdBy"],{}),t.Index("uxJobLiveLinkToken",["liveLinkToken"],{unique:!0}),t.Entity("job",{schema:"nova"})],exports.Job);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("typeorm"),a=require("../utils/uuidTransformer.js");const o=new Set(["Upcoming","AwaitingUpdate","AtOrigin","InProgress","Arriving","Arrived"]),r={Upcoming:"Upcoming",AwaitingUpdate:"Upcoming",AtOrigin:"In Progress",InProgress:"In Progress",Arriving:"In Progress",Arrived:"In Progress",Complete:"Completed",Cancelled:"Cancelled"};exports.Job=class Job{id;clientId;imei;name;status;lifecycle;healthChips;proofState;outcome;startLat;startLng;startLabel;startDetail;startRadiusM;endLat;endLng;endLabel;endDetail;endRadiusM;scheduledStart;targetArrival;startedAt;firstObservedAt;arrivedAt;completedAt;cancelledAt;pingsInEndZone;lastPositionAt;lastEvaluatedAt;etaArrivalAt;etaUpdatedAt;etaDriveSeconds;etaDistanceMeters;rules;timeline;liveLinkToken;createdBy;createdAt;modifiedBy;modifiedAt;deletedAt;deletedBy},e.__decorate([t.PrimaryGeneratedColumn({type:"int",name:"id"}),e.__metadata("design:type",Number)],exports.Job.prototype,"id",void 0),e.__decorate([t.Column("int",{name:"clientId"}),e.__metadata("design:type",Number)],exports.Job.prototype,"clientId",void 0),e.__decorate([t.Column("varchar",{name:"imei",length:15}),e.__metadata("design:type",String)],exports.Job.prototype,"imei",void 0),e.__decorate([t.Column("varchar",{name:"name",length:255}),e.__metadata("design:type",String)],exports.Job.prototype,"name",void 0),e.__decorate([t.Column("varchar",{name:"status",length:20}),e.__metadata("design:type",String)],exports.Job.prototype,"status",void 0),e.__decorate([t.Column("varchar",{name:"lifecycle",length:20,default:"Upcoming"}),e.__metadata("design:type",String)],exports.Job.prototype,"lifecycle",void 0),e.__decorate([t.Column("json",{name:"healthChips",nullable:!0}),e.__metadata("design:type",Array)],exports.Job.prototype,"healthChips",void 0),e.__decorate([t.Column("varchar",{name:"proofState",length:20,default:"NotArrived"}),e.__metadata("design:type",String)],exports.Job.prototype,"proofState",void 0),e.__decorate([t.Column("varchar",{name:"outcome",length:10,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"outcome",void 0),e.__decorate([t.Column("double",{name:"startLat",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"startLat",void 0),e.__decorate([t.Column("double",{name:"startLng",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"startLng",void 0),e.__decorate([t.Column("varchar",{name:"startLabel",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"startLabel",void 0),e.__decorate([t.Column("varchar",{name:"startDetail",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"startDetail",void 0),e.__decorate([t.Column("int",{name:"startRadiusM",default:150}),e.__metadata("design:type",Number)],exports.Job.prototype,"startRadiusM",void 0),e.__decorate([t.Column("double",{name:"endLat",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"endLat",void 0),e.__decorate([t.Column("double",{name:"endLng",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"endLng",void 0),e.__decorate([t.Column("varchar",{name:"endLabel",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"endLabel",void 0),e.__decorate([t.Column("varchar",{name:"endDetail",length:500,nullable:!0}),e.__metadata("design:type",String)],exports.Job.prototype,"endDetail",void 0),e.__decorate([t.Column("int",{name:"endRadiusM",default:150}),e.__metadata("design:type",Number)],exports.Job.prototype,"endRadiusM",void 0),e.__decorate([t.Column("datetime",{name:"scheduledStart",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"scheduledStart",void 0),e.__decorate([t.Column("datetime",{name:"targetArrival",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"targetArrival",void 0),e.__decorate([t.Column("datetime",{name:"startedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"startedAt",void 0),e.__decorate([t.Column("datetime",{name:"firstObservedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"firstObservedAt",void 0),e.__decorate([t.Column("datetime",{name:"arrivedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"arrivedAt",void 0),e.__decorate([t.Column("datetime",{name:"completedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"completedAt",void 0),e.__decorate([t.Column("datetime",{name:"cancelledAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"cancelledAt",void 0),e.__decorate([t.Column("int",{name:"pingsInEndZone",default:0}),e.__metadata("design:type",Number)],exports.Job.prototype,"pingsInEndZone",void 0),e.__decorate([t.Column("datetime",{name:"lastPositionAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"lastPositionAt",void 0),e.__decorate([t.Column("datetime",{name:"lastEvaluatedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"lastEvaluatedAt",void 0),e.__decorate([t.Column("datetime",{name:"etaArrivalAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"etaArrivalAt",void 0),e.__decorate([t.Column("datetime",{name:"etaUpdatedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"etaUpdatedAt",void 0),e.__decorate([t.Column("int",{name:"etaDriveSeconds",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"etaDriveSeconds",void 0),e.__decorate([t.Column("int",{name:"etaDistanceMeters",nullable:!0}),e.__metadata("design:type",Number)],exports.Job.prototype,"etaDistanceMeters",void 0),e.__decorate([t.Column("json",{name:"rules",nullable:!0}),e.__metadata("design:type",Array)],exports.Job.prototype,"rules",void 0),e.__decorate([t.Column("json",{name:"timeline",nullable:!0}),e.__metadata("design:type",Array)],exports.Job.prototype,"timeline",void 0),e.__decorate([t.Column("binary",{name:"liveLinkToken",length:16,nullable:!0,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"liveLinkToken",void 0),e.__decorate([t.Column("binary",{name:"createdBy",length:16,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"createdBy",void 0),e.__decorate([t.CreateDateColumn({name:"createdAt"}),e.__metadata("design:type",Date)],exports.Job.prototype,"createdAt",void 0),e.__decorate([t.Column("binary",{name:"modifiedBy",length:16,nullable:!0,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"modifiedBy",void 0),e.__decorate([t.UpdateDateColumn({name:"modifiedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"modifiedAt",void 0),e.__decorate([t.DeleteDateColumn({name:"deletedAt",nullable:!0}),e.__metadata("design:type",Date)],exports.Job.prototype,"deletedAt",void 0),e.__decorate([t.Column("binary",{name:"deletedBy",length:16,nullable:!0,transformer:a.UUIDTransformer}),e.__metadata("design:type",String)],exports.Job.prototype,"deletedBy",void 0),exports.Job=e.__decorate([t.Index("ixJobClientIdStatus",["clientId","status"],{}),t.Index("ixJobClientIdLifecycle",["clientId","lifecycle"],{}),t.Index("ixJobImeiLifecycle",["imei","lifecycle"],{}),t.Index("ixJobClientIdCreatedBy",["clientId","createdBy"],{}),t.Index("uxJobLiveLinkToken",["liveLinkToken"],{unique:!0}),t.Entity("job",{schema:"nova"})],exports.Job),exports.ACTIVE_JOB_LIFECYCLES=o,exports.deriveLegacyStatus=e=>r[e];
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Repository } from 'typeorm';
2
2
  import * as Cache from './cache';
3
3
  import * as Entities from './entities';
4
+ import { ACTIVE_JOB_LIFECYCLES, deriveLegacyStatus, type JobHealthChip, type JobLifecycle, type JobOutcome, type JobProofState, type JobRule, type JobStatus, type JobTimelineEvent } from './entities/job';
4
5
  import { NovaDataSource, NovaDataSourceConfig } from './novaDataSource';
5
6
  import { syncSchemaFromDump, SyncSchemaFromDumpConfig } from './syncSchemaFromDump';
6
7
  import * as Types from './types';
@@ -25,4 +26,4 @@ declare const Utils: {
25
26
  addMonthsToNow: (months: number) => Date;
26
27
  mapRawEntityToEntity: <T>(rawEntity: any, columnsPrefix?: string) => T;
27
28
  };
28
- export { Cache, ConsoleLogger, Entities, Enums, NovaDataSource, NovaDataSourceConfig, queryTags, Repository, syncSchemaFromDump, SyncSchemaFromDumpConfig, Types, Utils, };
29
+ export { ACTIVE_JOB_LIFECYCLES, Cache, ConsoleLogger, deriveLegacyStatus, Entities, Enums, JobHealthChip, JobLifecycle, JobOutcome, JobProofState, JobRule, JobStatus, JobTimelineEvent, NovaDataSource, NovaDataSourceConfig, queryTags, Repository, syncSchemaFromDump, SyncSchemaFromDumpConfig, Types, Utils, };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("typeorm"),r=require("./cache/index.js"),t=require("./entities/index.js"),o=require("./novaDataSource.js"),a=require("./syncSchemaFromDump.js"),s=require("./types/index.js"),i=require("./types/enums.js"),n=require("./utils/consoleLogger.js"),u=require("./utils/dateTool.js"),l=require("./utils/mapRawEntityToEntity.js"),y=require("./utils/paramsValidators.js"),g=require("./utils/parsingTools.js"),m=require("./utils/queryTags.js"),d=require("./utils/randomizer.js"),p=require("./utils/uuidHelpers.js");const q={uuidStringToBinaryBuffer:p.uuidStringToBinaryBuffer,binaryBufferToUuidString:p.binaryBufferToUuidString,getRandomBoolean:d.getRandomBoolean,getRandomImei:d.getRandomImei,getRandomDateInRange:d.getRandomDateInRange,getRandomInteger:d.getRandomInteger,getRandomString:d.getRandomString,tryParseBoolean:g.tryParseBoolean,tryParseDate:g.tryParseDate,tryParseFloat:g.tryParseFloat,allAttributesAreNull:y.allAttributesAreNull,anyAttributeInArrayIsNull:y.anyAttributeInArrayIsNull,anyAttributeIsNull:y.anyAttributeIsNull,now:u.now,addMonthsToNow:u.addMonthsToNow,mapRawEntityToEntity:l.mapRawEntityToEntity};Object.defineProperty(exports,"Repository",{enumerable:!0,get:function(){return e.Repository}}),exports.Cache=r,exports.Entities=t,exports.NovaDataSource=o.NovaDataSource,exports.syncSchemaFromDump=a.syncSchemaFromDump,exports.Types=s,exports.Enums=i,exports.ConsoleLogger=n.ConsoleLogger,exports.queryTags=m.queryTags,exports.Utils=q;
1
+ "use strict";var e=require("typeorm"),r=require("./cache/index.js"),t=require("./entities/index.js"),o=require("./entities/job.js"),s=require("./novaDataSource.js"),a=require("./syncSchemaFromDump.js"),i=require("./types/index.js"),n=require("./types/enums.js"),u=require("./utils/consoleLogger.js"),l=require("./utils/dateTool.js"),y=require("./utils/mapRawEntityToEntity.js"),g=require("./utils/paramsValidators.js"),m=require("./utils/parsingTools.js"),d=require("./utils/queryTags.js"),p=require("./utils/randomizer.js"),c=require("./utils/uuidHelpers.js");const q={uuidStringToBinaryBuffer:c.uuidStringToBinaryBuffer,binaryBufferToUuidString:c.binaryBufferToUuidString,getRandomBoolean:p.getRandomBoolean,getRandomImei:p.getRandomImei,getRandomDateInRange:p.getRandomDateInRange,getRandomInteger:p.getRandomInteger,getRandomString:p.getRandomString,tryParseBoolean:m.tryParseBoolean,tryParseDate:m.tryParseDate,tryParseFloat:m.tryParseFloat,allAttributesAreNull:g.allAttributesAreNull,anyAttributeInArrayIsNull:g.anyAttributeInArrayIsNull,anyAttributeIsNull:g.anyAttributeIsNull,now:l.now,addMonthsToNow:l.addMonthsToNow,mapRawEntityToEntity:y.mapRawEntityToEntity};Object.defineProperty(exports,"Repository",{enumerable:!0,get:function(){return e.Repository}}),exports.Cache=r,exports.Entities=t,exports.ACTIVE_JOB_LIFECYCLES=o.ACTIVE_JOB_LIFECYCLES,exports.deriveLegacyStatus=o.deriveLegacyStatus,exports.NovaDataSource=s.NovaDataSource,exports.syncSchemaFromDump=a.syncSchemaFromDump,exports.Types=i,exports.Enums=n,exports.ConsoleLogger=u.ConsoleLogger,exports.queryTags=d.queryTags,exports.Utils=q;
@@ -2,12 +2,12 @@
2
2
 
3
3
  var _1684483704434AddLowerCaseIndex = require('../1684483704434-addLowerCaseIndex.js');
4
4
  var _1684483705001UpdateSecurityUserViewsV1 = require('../1684483705001-updateSecurityUserViewsV1.js');
5
- var _1746434400000AddQuickSearchFulltextIndexes = require('../1746434400000-addQuickSearchFulltextIndexes.js');
6
5
  var _1684483705002UpdateSecurityUserViewsV2 = require('../1684483705002-updateSecurityUserViewsV2.js');
6
+ var _1746434400000AddQuickSearchFulltextIndexes = require('../1746434400000-addQuickSearchFulltextIndexes.js');
7
7
 
8
8
 
9
9
 
10
10
  exports.addLowerCaseIndex1684483704434 = _1684483704434AddLowerCaseIndex.addLowerCaseIndex1684483704434;
11
11
  exports.updateSecurityUserViewsV11684483705001 = _1684483705001UpdateSecurityUserViewsV1.updateSecurityUserViewsV11684483705001;
12
- exports.addQuickSearchFulltextIndexes1746434400000 = _1746434400000AddQuickSearchFulltextIndexes.addQuickSearchFulltextIndexes1746434400000;
13
12
  exports.updateSecurityUserViewsV21684483705002 = _1684483705002UpdateSecurityUserViewsV2.updateSecurityUserViewsV21684483705002;
13
+ exports.addQuickSearchFulltextIndexes1746434400000 = _1746434400000AddQuickSearchFulltextIndexes.addQuickSearchFulltextIndexes1746434400000;
@@ -1 +1 @@
1
- "use strict";var e=require("@opentelemetry/api"),r=require("typeorm"),t=require("./cache/attachIoredisErrorHandler.js"),a=require("./cache/InstrumentedQueryResultCache.js"),s=require("./cache/LruQueryResultCache.js"),i=require("./entities/index.js"),n=require("./subscribers/index.js"),o=require("./utils/mysqlSpanProcessor.js"),c=require("./utils/queryLogger.js"),u=require("./utils/queryTags.js"),l=require("./utils/spanSubscriber.js");require("fs"),require("mysql2/promise"),require("path"),require("./types/enums.js"),require("./types/logger.js"),require("./entities/retailAlertExternalRecipient.js"),require("./utils/dateTool.js");exports.NovaDataSource=class NovaDataSource{dataSource;logger;constructor(e,t,a){this.logger=t;const s=[];for(const e in i){const r=i[e];s.push(r)}const o=[];for(const e in n){const r=n[e];o.push(r)}const u={host:"aws.connect.psdb.cloud",port:3306,database:"nova",ssl:{rejectUnauthorized:!0}};this.dataSource=new r.DataSource({type:"mysql",connectorPackage:"mysql2",synchronize:!1,logging:!0,logger:new c.QueryLogger(this.logger,e.logging),entities:s,subscribers:o,migrations:["node_modules/@spytecgps/nova-orm/dist/migration/*.js"],supportBigNumbers:!0,bigNumberStrings:!1,extra:{decimalNumbers:!0},...u,...e,replication:{master:{...u,...e},slaves:a?[{...u,...a}]:[{...u,...e}],defaultMode:e.replicationMode??"master"}})}async connect(){if(!this.dataSource.isInitialized){const r=e.trace.getTracer("@spytecgps/nova-orm");await r.startActiveSpan("nova-orm.connect",(async r=>{try{await this.dataSource.initialize(),r.setAttribute("db.system","mysql");const e=this.dataSource.options;e.database&&r.setAttribute("db.name",e.database),r.setAttribute("nova_orm.entity_count",this.dataSource.entityMetadatas.length)}catch(t){throw r.recordException(t),r.setStatus({code:e.SpanStatusCode.ERROR}),t}finally{r.end()}}))}if(o.isOtelAutoInstrumented())o.installMysqlSpanRenamer();else if(!this.dataSource.subscribers.some((e=>e._spanSubscriber))){const e=l.createSpanSubscriber(this.logger);e._spanSubscriber=!0,this.dataSource.subscribers.push(e)}this.wrapQueryResultCache()}wrapQueryResultCache(){const e=this.dataSource.queryResultCache;if(!e||e.__novaInstrumented)return;let r="unknown";e instanceof s.LruQueryResultCache?r="lru":"RedisQueryResultCache"===e.constructor?.name&&(r="redis",t.attachIoredisErrorHandler(e,this.logger));const i=new a.InstrumentedQueryResultCache(e,{kind:r,logger:this.logger});i.__novaInstrumented=!0,this.dataSource.queryResultCache=i}flushCacheSummary(){const e=this.dataSource.queryResultCache;e instanceof a.InstrumentedQueryResultCache&&e.flushSummary()}async disconnect(){try{this.dataSource.isInitialized&&await this.dataSource.destroy()}catch(e){this.logger.error({error:e},"Failed to close connection to database")}}getRepository(e){return this.dataSource.getRepository(e)}async query(e,r,t){const a=/^\s*(?:\/\*[\s\S]*?\*\/\s*)*(INSERT|UPDATE|DELETE|REPLACE|TRUNCATE|CREATE|ALTER|DROP|RENAME|GRANT|REVOKE|LOCK|UNLOCK|SET|CALL|START|COMMIT|ROLLBACK)\b/i.test(e);if(t?.usePrimary||a)return this.dataSource.query(e,r,null);const s=this.dataSource.createQueryRunner("slave");try{return await s.query(e,r)}finally{await s.release()}}async createQueryBuilder(e,r){return this.dataSource.createQueryBuilder(e,r,null)}createQueryRunner(e){return this.dataSource.createQueryRunner(e)}createQueryRunnerFromParams(e){const r=e?.queryOptions?.forceUseReplica?"slave":"master";return this.logger.trace({replicationMode:r},"Creating query runner with replication mode"),this.dataSource.createQueryRunner(r)}async safeQuery(e,r,t){try{await this.connect();return await e(this,t)}catch(e){throw this.logger.error({error:e},r?r+" ":"Error while executing query"),e}finally{t&&await t.release(),await this.disconnect()}}async safeQuery2(r,t,a){this.dataSource.isInitialized||(this.logger.info("nova-orm new connection"),await this.connect());return e.trace.getTracer("nova-orm").startActiveSpan(t??"safeQuery2",(async s=>{try{return await r(this,a)}catch(r){throw s.recordException(r),s.setStatus({code:e.SpanStatusCode.ERROR,message:r?.message}),this.logger.error({error:r},t?t+" ":"Error while executing query"),r}finally{s.end(),a&&await a.release()}}))}async safeQuery3(e,r,t,{replicationMode:a,tag:s}={}){return(async()=>{let i;try{await this.connect(),a?(this.logger.trace({replicationMode:a},"Creating query runner with replication mode"),i=this.dataSource.createQueryRunner(a)):this.logger.trace({replicationMode:this.dataSource.defaultReplicationModeForReads},"Creating query builder with default replication mode for reads");const n=this.dataSource.createQueryBuilder(e,r,i);s&&n.comment(u.queryTags({action:s}));return await t(n)}catch(e){throw this.logger.error({error:e},s?s+" ":"Error while executing query"),e}finally{i&&await i.release()}})()}async syncSchema(e=!0){this.logger.warn("Initiating schema sync"),await this.connect(),await this.dataSource.synchronize(e),await this.dataSource.runMigrations()}async clearCache(){this.dataSource.queryResultCache?(this.logger.info("Clearing query result cache"),await this.dataSource.queryResultCache.clear()):this.logger.info("No query result cache to clear")}async invalidateCacheKey(e){this.dataSource.queryResultCache&&(this.logger.info("Invalidating cache key",{key:e}),await this.dataSource.queryResultCache.remove([e]))}};
1
+ "use strict";var e=require("@opentelemetry/api"),r=require("typeorm"),t=require("./cache/attachIoredisErrorHandler.js"),a=require("./cache/InstrumentedQueryResultCache.js"),s=require("./cache/LruQueryResultCache.js"),i=require("./entities/index.js");require("./entities/job.js");var n=require("./subscribers/index.js"),o=require("./utils/mysqlSpanProcessor.js"),c=require("./utils/queryLogger.js"),u=require("./utils/queryTags.js"),l=require("./utils/spanSubscriber.js");require("fs"),require("mysql2/promise"),require("path"),require("./types/enums.js"),require("./types/logger.js"),require("./entities/retailAlertExternalRecipient.js"),require("./utils/dateTool.js");exports.NovaDataSource=class NovaDataSource{dataSource;logger;constructor(e,t,a){this.logger=t;const s=[];for(const e in i){const r=i[e];s.push(r)}const o=[];for(const e in n){const r=n[e];o.push(r)}const u={host:"aws.connect.psdb.cloud",port:3306,database:"nova",ssl:{rejectUnauthorized:!0}};this.dataSource=new r.DataSource({type:"mysql",connectorPackage:"mysql2",synchronize:!1,logging:!0,logger:new c.QueryLogger(this.logger,e.logging),entities:s,subscribers:o,migrations:["node_modules/@spytecgps/nova-orm/dist/migration/*.js"],supportBigNumbers:!0,bigNumberStrings:!1,extra:{decimalNumbers:!0},...u,...e,replication:{master:{...u,...e},slaves:a?[{...u,...a}]:[{...u,...e}],defaultMode:e.replicationMode??"master"}})}async connect(){if(!this.dataSource.isInitialized){const r=e.trace.getTracer("@spytecgps/nova-orm");await r.startActiveSpan("nova-orm.connect",(async r=>{try{await this.dataSource.initialize(),r.setAttribute("db.system","mysql");const e=this.dataSource.options;e.database&&r.setAttribute("db.name",e.database),r.setAttribute("nova_orm.entity_count",this.dataSource.entityMetadatas.length)}catch(t){throw r.recordException(t),r.setStatus({code:e.SpanStatusCode.ERROR}),t}finally{r.end()}}))}if(o.isOtelAutoInstrumented())o.installMysqlSpanRenamer();else if(!this.dataSource.subscribers.some((e=>e._spanSubscriber))){const e=l.createSpanSubscriber(this.logger);e._spanSubscriber=!0,this.dataSource.subscribers.push(e)}this.wrapQueryResultCache()}wrapQueryResultCache(){const e=this.dataSource.queryResultCache;if(!e||e.__novaInstrumented)return;let r="unknown";e instanceof s.LruQueryResultCache?r="lru":"RedisQueryResultCache"===e.constructor?.name&&(r="redis",t.attachIoredisErrorHandler(e,this.logger));const i=new a.InstrumentedQueryResultCache(e,{kind:r,logger:this.logger});i.__novaInstrumented=!0,this.dataSource.queryResultCache=i}flushCacheSummary(){const e=this.dataSource.queryResultCache;e instanceof a.InstrumentedQueryResultCache&&e.flushSummary()}async disconnect(){try{this.dataSource.isInitialized&&await this.dataSource.destroy()}catch(e){this.logger.error({error:e},"Failed to close connection to database")}}getRepository(e){return this.dataSource.getRepository(e)}async query(e,r,t){const a=/^\s*(?:\/\*[\s\S]*?\*\/\s*)*(INSERT|UPDATE|DELETE|REPLACE|TRUNCATE|CREATE|ALTER|DROP|RENAME|GRANT|REVOKE|LOCK|UNLOCK|SET|CALL|START|COMMIT|ROLLBACK)\b/i.test(e);if(t?.usePrimary||a)return this.dataSource.query(e,r,null);const s=this.dataSource.createQueryRunner("slave");try{return await s.query(e,r)}finally{await s.release()}}async createQueryBuilder(e,r){return this.dataSource.createQueryBuilder(e,r,null)}createQueryRunner(e){return this.dataSource.createQueryRunner(e)}createQueryRunnerFromParams(e){const r=e?.queryOptions?.forceUseReplica?"slave":"master";return this.logger.trace({replicationMode:r},"Creating query runner with replication mode"),this.dataSource.createQueryRunner(r)}async safeQuery(e,r,t){try{await this.connect();return await e(this,t)}catch(e){throw this.logger.error({error:e},r?r+" ":"Error while executing query"),e}finally{t&&await t.release(),await this.disconnect()}}async safeQuery2(r,t,a){this.dataSource.isInitialized||(this.logger.info("nova-orm new connection"),await this.connect());return e.trace.getTracer("nova-orm").startActiveSpan(t??"safeQuery2",(async s=>{try{return await r(this,a)}catch(r){throw s.recordException(r),s.setStatus({code:e.SpanStatusCode.ERROR,message:r?.message}),this.logger.error({error:r},t?t+" ":"Error while executing query"),r}finally{s.end(),a&&await a.release()}}))}async safeQuery3(e,r,t,{replicationMode:a,tag:s}={}){return(async()=>{let i;try{await this.connect(),a?(this.logger.trace({replicationMode:a},"Creating query runner with replication mode"),i=this.dataSource.createQueryRunner(a)):this.logger.trace({replicationMode:this.dataSource.defaultReplicationModeForReads},"Creating query builder with default replication mode for reads");const n=this.dataSource.createQueryBuilder(e,r,i);s&&n.comment(u.queryTags({action:s}));return await t(n)}catch(e){throw this.logger.error({error:e},s?s+" ":"Error while executing query"),e}finally{i&&await i.release()}})()}async syncSchema(e=!0){this.logger.warn("Initiating schema sync"),await this.connect(),await this.dataSource.synchronize(e),await this.dataSource.runMigrations()}async clearCache(){this.dataSource.queryResultCache?(this.logger.info("Clearing query result cache"),await this.dataSource.queryResultCache.clear()):this.logger.info("No query result cache to clear")}async invalidateCacheKey(e){this.dataSource.queryResultCache&&(this.logger.info("Invalidating cache key",{key:e}),await this.dataSource.queryResultCache.remove([e]))}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "1.4.243",
3
+ "version": "1.4.245",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/schema.sql CHANGED
@@ -1,6 +1,6 @@
1
- -- nova-orm-schema-checksum: 2cf05ba22d935b6ff23e793dd72eb97d
1
+ -- nova-orm-schema-checksum: 0627f4fb03367dbb125489af14db66d4
2
2
  -- Nova ORM Schema Dump
3
- -- Generated at: 2026-05-25T05:05:23.896Z
3
+ -- Generated at: 2026-05-26T03:34:24.120Z
4
4
 
5
5
  SET FOREIGN_KEY_CHECKS = 0;
6
6
 
@@ -2229,17 +2229,34 @@ CREATE TABLE `job` (
2229
2229
  `imei` varchar(15) NOT NULL,
2230
2230
  `name` varchar(255) NOT NULL,
2231
2231
  `status` varchar(20) NOT NULL,
2232
+ `lifecycle` varchar(20) NOT NULL DEFAULT 'Upcoming',
2233
+ `healthChips` json DEFAULT NULL,
2234
+ `proofState` varchar(20) NOT NULL DEFAULT 'NotArrived',
2235
+ `outcome` varchar(10) DEFAULT NULL,
2232
2236
  `startLat` double DEFAULT NULL,
2233
2237
  `startLng` double DEFAULT NULL,
2234
2238
  `startLabel` varchar(500) DEFAULT NULL,
2235
2239
  `startDetail` varchar(500) DEFAULT NULL,
2240
+ `startRadiusM` int NOT NULL DEFAULT '150',
2236
2241
  `endLat` double DEFAULT NULL,
2237
2242
  `endLng` double DEFAULT NULL,
2238
2243
  `endLabel` varchar(500) DEFAULT NULL,
2239
2244
  `endDetail` varchar(500) DEFAULT NULL,
2245
+ `endRadiusM` int NOT NULL DEFAULT '150',
2240
2246
  `scheduledStart` datetime DEFAULT NULL,
2241
2247
  `targetArrival` datetime DEFAULT NULL,
2248
+ `startedAt` datetime DEFAULT NULL,
2249
+ `firstObservedAt` datetime DEFAULT NULL,
2242
2250
  `arrivedAt` datetime DEFAULT NULL,
2251
+ `completedAt` datetime DEFAULT NULL,
2252
+ `cancelledAt` datetime DEFAULT NULL,
2253
+ `pingsInEndZone` int NOT NULL DEFAULT '0',
2254
+ `lastPositionAt` datetime DEFAULT NULL,
2255
+ `lastEvaluatedAt` datetime DEFAULT NULL,
2256
+ `etaArrivalAt` datetime DEFAULT NULL,
2257
+ `etaUpdatedAt` datetime DEFAULT NULL,
2258
+ `etaDriveSeconds` int DEFAULT NULL,
2259
+ `etaDistanceMeters` int DEFAULT NULL,
2243
2260
  `rules` json DEFAULT NULL,
2244
2261
  `timeline` json DEFAULT NULL,
2245
2262
  `liveLinkToken` binary(16) DEFAULT NULL,
@@ -2252,6 +2269,8 @@ CREATE TABLE `job` (
2252
2269
  PRIMARY KEY (`id`),
2253
2270
  UNIQUE KEY `uxJobLiveLinkToken` (`liveLinkToken`),
2254
2271
  KEY `ixJobClientIdCreatedBy` (`clientId`,`createdBy`),
2272
+ KEY `ixJobImeiLifecycle` (`imei`,`lifecycle`),
2273
+ KEY `ixJobClientIdLifecycle` (`clientId`,`lifecycle`),
2255
2274
  KEY `ixJobClientIdStatus` (`clientId`,`status`)
2256
2275
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2257
2276