A SpaceTraders Agent

basic setup for models

altagos.dev b6f5095b d62936fd

verified
+155
+153
src/st/models.zig
··· 1 + pub fn Wrapper(comptime T: type) type { 2 + return struct { 3 + data: ?T = null, 4 + meta: ?Meta = null, 5 + @"error": ?Error = null, 6 + }; 7 + } 8 + 9 + pub const Meta = struct { 10 + total: u64 = 0, // [0, ∞) 11 + page: u64 = 1, // [1, ∞) 12 + limit: u8 = 10, // [1, 20] 13 + }; 14 + 15 + pub const Query = struct { 16 + page: u64 = 1, 17 + /// How many entries to return per page 18 + /// min: 1, max: 20 19 + limit: u64 = 20, 20 + }; 21 + 22 + pub const Error = struct { 23 + message: []const u8, 24 + code: ErrorCode, 25 + data: ?Data = null, 26 + 27 + pub const Data = struct { 28 + type: []const u8, 29 + retryAfter: u64, 30 + limitBurst: u64, 31 + limitPerSecond: u64, 32 + remaining: u64, 33 + reset: []const u8, 34 + }; 35 + }; 36 + 37 + /// List of Possible Error Codes 38 + /// 39 + /// Obtained via [/error-codes](https://spacetraders.io/openapi#tag/global/GET/error-codes) 40 + pub const ErrorCode = enum(u16) { 41 + // Standart Error Codes 42 + notFound = 404, 43 + tooManyRequests = 429, 44 + ddosProtection = 502, 45 + 46 + // SpaceTraders Error Codes 47 + responseSerializationError = 3000, 48 + unprocessableInputError = 3001, 49 + allErrorHandlersFailedError = 3002, 50 + systemStatusMaintenanceError = 3100, 51 + resetError = 3200, 52 + cooldownConflictError = 4000, 53 + waypointNoAccessError = 4001, 54 + tokenEmptyError = 4100, 55 + tokenMissingSubjectError = 4101, 56 + tokenInvalidSubjectError = 4102, 57 + missingTokenRequestError = 4103, 58 + invalidTokenRequestError = 4104, 59 + invalidTokenSubjectError = 4105, 60 + accountNotExistsError = 4106, 61 + agentNotExistsError = 4107, 62 + accountHasNoAgentError = 4108, 63 + tokenInvalidVersionError = 4109, 64 + registerAgentSymbolReservedError = 4110, 65 + registerAgentConflictSymbolError = 4111, 66 + registerAgentNoStartingLocationsError = 4112, 67 + tokenResetDateMismatchError = 4113, 68 + invalidAccountRoleError = 4114, 69 + invalidTokenError = 4115, 70 + missingAccountTokenRequest = 4116, 71 + navigateInTransitError = 4200, 72 + navigateInvalidDestinationError = 4201, 73 + navigateOutsideSystemError = 4202, 74 + navigateInsufficientFuelError = 4203, 75 + navigateSameDestinationError = 4204, 76 + shipExtractInvalidWaypointError = 4205, 77 + shipExtractPermissionError = 4206, 78 + shipInTransitError = 4214, 79 + shipMissingSensorArraysError = 4215, 80 + purchaseShipCreditsError = 4216, 81 + shipCargoExceedsLimitError = 4217, 82 + shipCargoMissingError = 4218, 83 + shipCargoUnitCountError = 4219, 84 + shipSurveyVerificationError = 4220, 85 + shipSurveyExpirationError = 4221, 86 + shipSurveyWaypointTypeError = 4222, 87 + shipSurveyOrbitError = 4223, 88 + shipSurveyExhaustedError = 4224, 89 + shipCargoFullError = 4228, 90 + waypointChartedError = 4230, 91 + shipTransferShipNotFound = 4231, 92 + shipTransferAgentConflict = 4232, 93 + shipTransferSameShipConflict = 4233, 94 + shipTransferLocationConflict = 4234, 95 + warpInsideSystemError = 4235, 96 + shipNotInOrbitError = 4236, 97 + shipInvalidRefineryGoodError = 4237, 98 + shipInvalidRefineryTypeError = 4238, 99 + shipMissingRefineryError = 4239, 100 + shipMissingSurveyorError = 4240, 101 + shipMissingWarpDriveError = 4241, 102 + shipMissingMineralProcessorError = 4242, 103 + shipMissingMiningLasersError = 4243, 104 + shipNotDockedError = 4244, 105 + purchaseShipNotPresentError = 4245, 106 + shipMountNoShipyardError = 4246, 107 + shipMissingMountError = 4247, 108 + shipMountInsufficientCreditsError = 4248, 109 + shipMissingPowerError = 4249, 110 + shipMissingSlotsError = 4250, 111 + shipMissingMountsError = 4251, 112 + shipMissingCrewError = 4252, 113 + shipExtractDestabilizedError = 4253, 114 + shipJumpInvalidOriginError = 4254, 115 + shipJumpInvalidWaypointError = 4255, 116 + shipJumpOriginUnderConstructionError = 4256, 117 + shipMissingGasProcessorError = 4257, 118 + shipMissingGasSiphonsError = 4258, 119 + shipSiphonInvalidWaypointError = 4259, 120 + shipSiphonPermissionError = 4260, 121 + waypointNoYieldError = 4261, 122 + shipJumpDestinationUnderConstructionError = 4262, 123 + shipScrapInvalidTraitError = 4263, 124 + shipRepairInvalidTraitError = 4264, 125 + agentInsufficientCreditsError = 4265, 126 + shipModuleNoShipyardError = 4266, 127 + shipModuleNotInstalledError = 4267, 128 + shipModuleInsufficientCreditsError = 4268, 129 + cantSlowDownWhileInTransitError = 4269, 130 + shipExtractInvalidSurveyLocationError = 4270, 131 + shipTransferDockedOrbitConflict = 4271, 132 + acceptContractNotAuthorizedError = 4500, 133 + acceptContractConflictError = 4501, 134 + fulfillContractDeliveryError = 4502, 135 + contractDeadlineError = 4503, 136 + contractFulfilledError = 4504, 137 + contractNotAcceptedError = 4505, 138 + contractNotAuthorizedError = 4506, 139 + shipDeliverTermsError = 4508, 140 + shipDeliverFulfilledError = 4509, 141 + shipDeliverInvalidLocationError = 4510, 142 + existingContractError = 4511, 143 + marketTradeInsufficientCreditsError = 4600, 144 + marketTradeNoPurchaseError = 4601, 145 + marketTradeNotSoldError = 4602, 146 + marketTradeUnitLimitError = 4604, 147 + shipNotAvailableForPurchaseError = 4605, 148 + waypointNoFactionError = 4700, 149 + constructionMaterialNotRequired = 4800, 150 + constructionMaterialFulfilled = 4801, 151 + shipConstructionInvalidLocationError = 4802, 152 + unsupportedMediaTypeError = 5000, 153 + };
+2
src/st/root.zig
··· 1 + pub const http = @import("http.zig"); 2 + pub const models = @import("models.zig");