@shipload/sdk 1.0.0-next.10 → 1.0.0-next.12

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.
Files changed (39) hide show
  1. package/lib/shipload.d.ts +759 -868
  2. package/lib/shipload.js +2463 -2588
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +2432 -2557
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/data/entities.json +13 -0
  8. package/src/data/item-ids.ts +1 -0
  9. package/src/data/items.json +6 -0
  10. package/src/data/kind-registry.json +78 -0
  11. package/src/data/kind-registry.ts +133 -0
  12. package/src/data/metadata.ts +6 -0
  13. package/src/data/recipes.json +57 -0
  14. package/src/derivation/capabilities.ts +397 -0
  15. package/src/derivation/crafting.ts +1 -1
  16. package/src/entities/entity.ts +98 -0
  17. package/src/entities/makers.ts +76 -170
  18. package/src/errors.ts +10 -13
  19. package/src/index-module.ts +39 -22
  20. package/src/managers/entities.ts +18 -80
  21. package/src/managers/index.ts +1 -1
  22. package/src/nft/atomicdata.ts +5 -0
  23. package/src/nft/description.ts +1 -1
  24. package/src/resolution/resolve-item.ts +3 -2
  25. package/src/scheduling/projection.ts +2 -2
  26. package/src/subscriptions/manager.ts +3 -5
  27. package/src/subscriptions/mappers.ts +3 -8
  28. package/src/subscriptions/types.ts +2 -2
  29. package/src/testing/catalog-hash.ts +19 -0
  30. package/src/testing/index.ts +2 -0
  31. package/src/testing/projection-parity.ts +143 -0
  32. package/src/types/index.ts +0 -1
  33. package/src/types.ts +0 -9
  34. package/src/entities/container.ts +0 -123
  35. package/src/entities/extractor.ts +0 -144
  36. package/src/entities/ship-deploy.ts +0 -316
  37. package/src/entities/ship.ts +0 -221
  38. package/src/entities/warehouse.ts +0 -136
  39. package/src/types/entity-traits.ts +0 -132
@@ -1,132 +0,0 @@
1
- import {Name} from '@wharfkit/antelope'
2
- import {
3
- ITEM_CONTAINER_T1_PACKED,
4
- ITEM_CONTAINER_T2_PACKED,
5
- ITEM_EXTRACTOR_T1_PACKED,
6
- ITEM_SHIP_T1_PACKED,
7
- ITEM_WAREHOUSE_T1_PACKED,
8
- } from '../data/item-ids'
9
-
10
- export const ENTITY_SHIP = Name.from('ship')
11
- export const ENTITY_WAREHOUSE = Name.from('warehouse')
12
- export const ENTITY_EXTRACTOR = Name.from('extractor')
13
- export const ENTITY_CONTAINER = Name.from('container')
14
-
15
- export enum EntityClass {
16
- OrbitalVessel = 0,
17
- PlanetaryStructure = 1,
18
- }
19
-
20
- export function getEntityClass(entityType: Name | EntityTypeName): EntityClass {
21
- const typeName = typeof entityType === 'string' ? entityType : entityType.toString()
22
- switch (typeName) {
23
- case 'ship':
24
- case 'container':
25
- return EntityClass.OrbitalVessel
26
- case 'warehouse':
27
- case 'extractor':
28
- return EntityClass.PlanetaryStructure
29
- default:
30
- throw new Error(`Entity type has no class: ${typeName}`)
31
- }
32
- }
33
-
34
- export function getPackedEntityType(itemId: number): Name | null {
35
- switch (itemId) {
36
- case ITEM_SHIP_T1_PACKED:
37
- return ENTITY_SHIP
38
- case ITEM_CONTAINER_T1_PACKED:
39
- case ITEM_CONTAINER_T2_PACKED:
40
- return ENTITY_CONTAINER
41
- case ITEM_WAREHOUSE_T1_PACKED:
42
- return ENTITY_WAREHOUSE
43
- case ITEM_EXTRACTOR_T1_PACKED:
44
- return ENTITY_EXTRACTOR
45
- default:
46
- return null
47
- }
48
- }
49
-
50
- export type EntityTypeName = 'ship' | 'warehouse' | 'extractor' | 'container'
51
-
52
- export interface EntityTraits {
53
- typeName: Name
54
- isMovable: boolean
55
- hasEnergy: boolean
56
- hasLoaders: boolean
57
- hasModules: boolean
58
- notFoundError: string
59
- }
60
-
61
- export const shipTraits: EntityTraits = {
62
- typeName: ENTITY_SHIP,
63
- isMovable: true,
64
- hasEnergy: true,
65
- hasLoaders: true,
66
- hasModules: true,
67
-
68
- notFoundError: 'ship not found',
69
- }
70
-
71
- export const warehouseTraits: EntityTraits = {
72
- typeName: ENTITY_WAREHOUSE,
73
- isMovable: false,
74
- hasEnergy: false,
75
- hasLoaders: true,
76
- hasModules: true,
77
-
78
- notFoundError: 'warehouse not found',
79
- }
80
-
81
- export const extractorTraits: EntityTraits = {
82
- typeName: ENTITY_EXTRACTOR,
83
- isMovable: false,
84
- hasEnergy: true,
85
- hasLoaders: false,
86
- hasModules: true,
87
-
88
- notFoundError: 'extractor not found',
89
- }
90
-
91
- export const containerTraits: EntityTraits = {
92
- typeName: ENTITY_CONTAINER,
93
- isMovable: true,
94
- hasEnergy: false,
95
- hasLoaders: false,
96
- hasModules: false,
97
-
98
- notFoundError: 'container not found',
99
- }
100
-
101
- export function getEntityTraits(entityType: Name | EntityTypeName): EntityTraits {
102
- const typeName = typeof entityType === 'string' ? entityType : entityType.toString()
103
-
104
- switch (typeName) {
105
- case 'ship':
106
- return shipTraits
107
- case 'warehouse':
108
- return warehouseTraits
109
- case 'extractor':
110
- return extractorTraits
111
- case 'container':
112
- return containerTraits
113
- default:
114
- throw new Error(`Unknown entity type: ${typeName}`)
115
- }
116
- }
117
-
118
- export function isShip(entity: {type?: Name}): boolean {
119
- return entity.type?.equals(ENTITY_SHIP) ?? false
120
- }
121
-
122
- export function isWarehouse(entity: {type?: Name}): boolean {
123
- return entity.type?.equals(ENTITY_WAREHOUSE) ?? false
124
- }
125
-
126
- export function isExtractor(entity: {type?: Name}): boolean {
127
- return entity.type?.equals(ENTITY_EXTRACTOR) ?? false
128
- }
129
-
130
- export function isContainer(entity: {type?: Name}): boolean {
131
- return entity.type?.equals(ENTITY_CONTAINER) ?? false
132
- }