@shipload/sdk 1.0.0-next.72 → 1.0.0-next.74
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 +576 -133
- package/lib/shipload.js +6019 -5114
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +6002 -5108
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +194 -52
- package/lib/testing.js +767 -468
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +767 -468
- package/lib/testing.m.js.map +1 -1
- package/package.json +1 -1
- package/src/contracts/server.ts +523 -143
- package/src/data/catalog.test.ts +81 -1
- package/src/data/catalog.ts +6 -4
- package/src/data/entities.json +2 -2
- package/src/data/metadata.ts +197 -363
- package/src/data/task-types.json +184 -0
- package/src/entities/makers.ts +2 -2
- package/src/index-module.ts +31 -2
- package/src/influence/civic-shuttle.test.ts +58 -0
- package/src/influence/civic-shuttle.ts +52 -6
- package/src/influence/duration.ts +0 -65
- package/src/influence/index.ts +4 -5
- package/src/influence/influence.test.ts +51 -136
- package/src/influence/valuation.ts +75 -0
- package/src/managers/actions.ts +49 -10
- package/src/managers/balances.test.ts +33 -0
- package/src/managers/balances.ts +15 -0
- package/src/managers/context.ts +50 -11
- package/src/managers/index.ts +14 -0
- package/src/managers/jobs.test.ts +82 -1
- package/src/managers/jobs.ts +41 -2
- package/src/managers/nft.test.ts +173 -1
- package/src/managers/nft.ts +35 -2
- package/src/managers/shuttle.test.ts +562 -0
- package/src/managers/shuttle.ts +397 -0
- package/src/resolution/resolve-item.ts +2 -2
- package/src/scheduling/availability.ts +10 -0
- package/src/scheduling/energy.ts +55 -1
- package/src/scheduling/jobs.test.ts +171 -1
- package/src/scheduling/jobs.ts +110 -13
- package/src/scheduling/projection.ts +2 -1
- package/src/scheduling/task-effects.ts +38 -0
- package/src/scheduling/unwrap.test.ts +60 -0
- package/src/scheduling/unwrap.ts +24 -8
- package/src/shipload.ts +23 -4
- package/src/types.ts +1 -0
package/src/data/catalog.test.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {describe, expect, test} from 'bun:test'
|
|
2
|
-
import {getItems, itemTypeIndex, typeLabel} from './catalog'
|
|
2
|
+
import {getComponents, getItem, getItems, itemTypeIndex, typeLabel} from './catalog'
|
|
3
|
+
import {getRecipe} from './recipes-runtime'
|
|
4
|
+
import items from './items.json'
|
|
5
|
+
import {itemFamilies, itemFamilyKey} from './metadata'
|
|
3
6
|
|
|
4
7
|
describe('itemTypeIndex', () => {
|
|
5
8
|
test('agrees with typeLabel for every item in the catalog', () => {
|
|
@@ -17,3 +20,80 @@ describe('itemTypeIndex', () => {
|
|
|
17
20
|
expect(() => itemTypeIndex(65535)).toThrow()
|
|
18
21
|
})
|
|
19
22
|
})
|
|
23
|
+
|
|
24
|
+
const catalogItems = () => (items as Array<{id: number}>).map((raw) => getItem(raw.id))
|
|
25
|
+
|
|
26
|
+
describe('item families', () => {
|
|
27
|
+
test('every item resolves to a family that carries its name', () => {
|
|
28
|
+
for (const item of catalogItems()) {
|
|
29
|
+
expect(itemFamilies[item.family]?.name).toBe(item.name)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('every tier of a family shares one name, description, and colour', () => {
|
|
34
|
+
const seen = new Map<string, {name: string; description: string; color: string}>()
|
|
35
|
+
for (const item of catalogItems()) {
|
|
36
|
+
const prior = seen.get(item.family)
|
|
37
|
+
if (prior) {
|
|
38
|
+
expect({
|
|
39
|
+
name: item.name,
|
|
40
|
+
description: item.description,
|
|
41
|
+
color: item.color,
|
|
42
|
+
}).toEqual(prior)
|
|
43
|
+
} else {
|
|
44
|
+
seen.set(item.family, {
|
|
45
|
+
name: item.name,
|
|
46
|
+
description: item.description,
|
|
47
|
+
color: item.color,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('every family is reachable from at least one item id', () => {
|
|
54
|
+
const reachable = new Set(catalogItems().map((item) => item.family))
|
|
55
|
+
for (const id of [10202, 10203, 10204, 10207]) reachable.add(itemFamilyKey(id)!)
|
|
56
|
+
expect([...Object.keys(itemFamilies)].filter((key) => !reachable.has(key))).toEqual([])
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('descriptions never name a tier', () => {
|
|
60
|
+
for (const [key, family] of Object.entries(itemFamilies)) {
|
|
61
|
+
expect(`${key}: ${family.description}`).not.toMatch(/\btier\b|\bT\d\b/i)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
describe('component descriptions', () => {
|
|
67
|
+
test('name only items that a recipe actually builds from the component', () => {
|
|
68
|
+
const consumers = new Map<string, Set<string>>()
|
|
69
|
+
for (const output of getItems()) {
|
|
70
|
+
const recipe = getRecipe(output.id)
|
|
71
|
+
if (!recipe) continue
|
|
72
|
+
for (const input of recipe.inputs) {
|
|
73
|
+
const inputItem = getItem(input.itemId)
|
|
74
|
+
if (inputItem.type !== 'component') continue
|
|
75
|
+
if (!consumers.has(inputItem.family)) consumers.set(inputItem.family, new Set())
|
|
76
|
+
consumers
|
|
77
|
+
.get(inputItem.family)!
|
|
78
|
+
.add(
|
|
79
|
+
output.type === 'entity' && output.family !== 'container'
|
|
80
|
+
? 'hulls'
|
|
81
|
+
: output.name
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const item of getComponents({tier: 1})) {
|
|
86
|
+
const named = item.description
|
|
87
|
+
.replace(/^Goes into /, '')
|
|
88
|
+
.replace(/\.$/, '')
|
|
89
|
+
.split(/, and |, | and /)
|
|
90
|
+
.map((name) => name.replace(/s$/, ''))
|
|
91
|
+
for (const name of named) {
|
|
92
|
+
const plain = name === 'hull' ? 'hulls' : name
|
|
93
|
+
expect(consumers.get(item.family)?.has(plain), `${item.name} -> ${plain}`).toBe(
|
|
94
|
+
true
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
})
|
package/src/data/catalog.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {UInt16, type UInt16Type} from '@wharfkit/antelope'
|
|
2
2
|
import items from './items.json'
|
|
3
|
-
import {
|
|
3
|
+
import {getItemFamily, itemFamilyKey} from './metadata'
|
|
4
4
|
import {
|
|
5
5
|
CATEGORY_LABELS,
|
|
6
6
|
type Item,
|
|
@@ -12,12 +12,14 @@ import {
|
|
|
12
12
|
const itemsById = new Map<number, Item>()
|
|
13
13
|
|
|
14
14
|
for (const raw of items as any[]) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const family = itemFamilyKey(raw.id)
|
|
16
|
+
const meta = getItemFamily(raw.id)
|
|
17
|
+
if (!family || !meta) {
|
|
18
|
+
throw new Error(`Missing family for item ${raw.id}. Add an entry to metadata.ts.`)
|
|
18
19
|
}
|
|
19
20
|
itemsById.set(raw.id, {
|
|
20
21
|
id: raw.id,
|
|
22
|
+
family,
|
|
21
23
|
name: meta.name,
|
|
22
24
|
description: meta.description,
|
|
23
25
|
color: meta.color,
|
package/src/data/entities.json
CHANGED