@shipload/sdk 2.0.0-rc12 → 2.0.0-rc13
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.
- package/lib/shipload.d.ts +5 -2
- package/lib/shipload.js +7 -3
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +7 -3
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/index-module.ts +1 -1
- package/src/scheduling/projection.ts +14 -3
package/package.json
CHANGED
package/src/index-module.ts
CHANGED
|
@@ -143,7 +143,7 @@ export {
|
|
|
143
143
|
projectEntityAt,
|
|
144
144
|
validateSchedule,
|
|
145
145
|
} from './scheduling/projection'
|
|
146
|
-
export type {Projectable, ProjectedEntity} from './scheduling/projection'
|
|
146
|
+
export type {Projectable, ProjectedEntity, ProjectionOptions} from './scheduling/projection'
|
|
147
147
|
|
|
148
148
|
export * from './types/capabilities'
|
|
149
149
|
export * from './types/entity'
|
|
@@ -259,11 +259,22 @@ function applyTask(projected: ProjectedEntity, task: ServerContract.Types.task):
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
export
|
|
262
|
+
export interface ProjectionOptions {
|
|
263
|
+
upToTaskIndex?: number
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function projectEntity(entity: Projectable, options?: ProjectionOptions): ProjectedEntity {
|
|
263
267
|
const projected = createProjectedEntity(entity)
|
|
264
268
|
if (!entity.schedule || entity.schedule.tasks.length === 0) return projected
|
|
265
|
-
|
|
266
|
-
|
|
269
|
+
|
|
270
|
+
const tasks = entity.schedule.tasks
|
|
271
|
+
const taskCount =
|
|
272
|
+
options?.upToTaskIndex !== undefined
|
|
273
|
+
? Math.max(0, Math.min(options.upToTaskIndex, tasks.length))
|
|
274
|
+
: tasks.length
|
|
275
|
+
|
|
276
|
+
for (let i = 0; i < taskCount; i++) {
|
|
277
|
+
applyTask(projected, tasks[i])
|
|
267
278
|
}
|
|
268
279
|
return projected
|
|
269
280
|
}
|