From 9cfc675194cca4b692e735af8de565ac33a18280 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 15 Jan 2025 22:55:18 +0200 Subject: [PATCH] move /api under /lib --- cli/main.zig | 12 ++++++------ gui/app.zig | 18 +++++++++--------- gui/main.zig | 4 +++- {api => lib/api}/enum_string_utils.zig | 0 {api => lib/api}/errors.zig | 0 {api => lib/api}/json_utils.zig | 0 {api => lib/api}/ratelimit.zig | 0 {api => lib/api}/root.zig | 2 +- {api => lib/api}/schemas/character.zig | 2 +- {api => lib/api}/schemas/cooldown.zig | 2 +- {api => lib/api}/schemas/craft.zig | 0 {api => lib/api}/schemas/drop_rate.zig | 0 {api => lib/api}/schemas/elemental_stat.zig | 0 {api => lib/api}/schemas/equip_result.zig | 0 {api => lib/api}/schemas/equipment.zig | 0 {api => lib/api}/schemas/ge_order.zig | 2 +- {api => lib/api}/schemas/item.zig | 0 {api => lib/api}/schemas/map.zig | 0 {api => lib/api}/schemas/monster.zig | 0 {api => lib/api}/schemas/move_result.zig | 0 {api => lib/api}/schemas/position.zig | 0 {api => lib/api}/schemas/resource.zig | 0 {api => lib/api}/schemas/simple_item.zig | 0 .../api}/schemas/skill_info_details.zig | 0 .../api}/schemas/skill_usage_result.zig | 0 {api => lib/api}/schemas/status.zig | 2 +- {api => lib/api}/schemas/task.zig | 0 {api => lib/api}/server.zig | 4 ++-- {api => lib/api}/store.zig | 0 lib/artificer.zig | 2 +- lib/craft_goal.zig | 2 +- {api => lib}/date_time/parse.zig | 0 {api => lib}/date_time/timegm.c | 0 {api => lib}/date_time/timegm.h | 0 lib/equip_goal.zig | 2 +- lib/gather_goal.zig | 2 +- lib/root.zig | 2 +- lib/sim_server.zig | 2 +- {api => lib}/stb_image/root.zig | 0 {api => lib}/stb_image/stb_image.c | 0 {api => lib}/stb_image/stb_image.h | 0 41 files changed, 31 insertions(+), 29 deletions(-) rename {api => lib/api}/enum_string_utils.zig (100%) rename {api => lib/api}/errors.zig (100%) rename {api => lib/api}/json_utils.zig (100%) rename {api => lib/api}/ratelimit.zig (100%) rename {api => lib/api}/root.zig (96%) rename {api => lib/api}/schemas/character.zig (98%) rename {api => lib/api}/schemas/cooldown.zig (97%) rename {api => lib/api}/schemas/craft.zig (100%) rename {api => lib/api}/schemas/drop_rate.zig (100%) rename {api => lib/api}/schemas/elemental_stat.zig (100%) rename {api => lib/api}/schemas/equip_result.zig (100%) rename {api => lib/api}/schemas/equipment.zig (100%) rename {api => lib/api}/schemas/ge_order.zig (95%) rename {api => lib/api}/schemas/item.zig (100%) rename {api => lib/api}/schemas/map.zig (100%) rename {api => lib/api}/schemas/monster.zig (100%) rename {api => lib/api}/schemas/move_result.zig (100%) rename {api => lib/api}/schemas/position.zig (100%) rename {api => lib/api}/schemas/resource.zig (100%) rename {api => lib/api}/schemas/simple_item.zig (100%) rename {api => lib/api}/schemas/skill_info_details.zig (100%) rename {api => lib/api}/schemas/skill_usage_result.zig (100%) rename {api => lib/api}/schemas/status.zig (97%) rename {api => lib/api}/schemas/task.zig (100%) rename {api => lib/api}/server.zig (99%) rename {api => lib/api}/store.zig (100%) rename {api => lib}/date_time/parse.zig (100%) rename {api => lib}/date_time/timegm.c (100%) rename {api => lib}/date_time/timegm.h (100%) rename {api => lib}/stb_image/root.zig (100%) rename {api => lib}/stb_image/stb_image.c (100%) rename {api => lib}/stb_image/stb_image.h (100%) diff --git a/cli/main.zig b/cli/main.zig index 7ff0179..458ccad 100644 --- a/cli/main.zig +++ b/cli/main.zig @@ -3,8 +3,8 @@ const std = @import("std"); const builtin = @import("builtin"); const Allocator = std.mem.Allocator; -const Artificer = @import("artificer"); -const Api = @import("artifacts-api"); +const Lib = @import("lib"); +const Api = Lib.Api; const simulated = true; @@ -60,8 +60,8 @@ pub fn main() !void { const character_id = (try server.getCharacter("Blondie")).?; - var system_clock = Artificer.SystemClock{}; - var sim_server = Artificer.SimServer.init(0, &store); + var system_clock = Lib.SystemClock{}; + var sim_server = Lib.SimServer.init(0, &store); if (simulated) { const character = store.characters.get(character_id).?; @@ -69,9 +69,9 @@ pub fn main() !void { } var artificer = if (simulated) - try Artificer.ArtificerSim.init(allocator, &store, &sim_server.clock, &sim_server, character_id) + try Lib.ArtificerSim.init(allocator, &store, &sim_server.clock, &sim_server, character_id) else - try Artificer.ArtificerApi.init(allocator, &store, &system_clock, &server, character_id); + try Lib.ArtificerApi.init(allocator, &store, &system_clock, &server, character_id); defer artificer.deinit(allocator); diff --git a/gui/app.zig b/gui/app.zig index acb6165..b239a00 100644 --- a/gui/app.zig +++ b/gui/app.zig @@ -1,7 +1,6 @@ // zig fmt: off const std = @import("std"); -const Api = @import("artifacts-api"); -const Artificer = @import("artificer"); +const Lib = @import("lib"); const UI = @import("./ui.zig"); const RectUtils = @import("./rect-utils.zig"); const rl = @import("raylib"); @@ -13,6 +12,7 @@ const rlgl_h = @cImport({ const assert = std.debug.assert; const log = std.log.scoped(.app); +const Api = Lib.Api; const App = @This(); @@ -39,11 +39,11 @@ blur_shader: rl.Shader, simulation: bool = false, -system_clock: Artificer.SystemClock, +system_clock: Lib.SystemClock, started_at: i128, -artificer: Artificer.ArtificerApi, -sim_artificer: Artificer.ArtificerSim, -sim_server: Artificer.SimServer, +artificer: Lib.ArtificerApi, +sim_artificer: Lib.ArtificerSim, +sim_server: Lib.SimServer, sim_started_at: i128, last_sim_timestamp: i128 = 0, @@ -144,7 +144,7 @@ pub fn init(allocator: std.mem.Allocator, store: *Api.Store, server: *Api.Server const character_id = store.characters.getId("Blondie").?; - const sim_server = Artificer.SimServer.init(0, store); + const sim_server = Lib.SimServer.init(0, store); var app = try allocator.create(App); errdefer allocator.destroy(app); @@ -177,10 +177,10 @@ pub fn init(allocator: std.mem.Allocator, store: *Api.Store, server: *Api.Server }; app.started_at = app.system_clock.nanoTimestamp(); - app.sim_artificer = try Artificer.ArtificerSim.init(allocator, store, &app.sim_server.clock, &app.sim_server, character_id); + app.sim_artificer = try Lib.ArtificerSim.init(allocator, store, &app.sim_server.clock, &app.sim_server, character_id); errdefer app.sim_artificer.deinit(allocator); - app.artificer = try Artificer.ArtificerApi.init(allocator, store, &app.system_clock, server, character_id); + app.artificer = try Lib.ArtificerApi.init(allocator, store, &app.system_clock, server, character_id); errdefer app.artificer.deinit(allocator); app.artificer_thread = try std.Thread.spawn(.{ .allocator = allocator }, artificer_thread_cb, .{ app }); diff --git a/gui/main.zig b/gui/main.zig index c96e283..2dbf33f 100644 --- a/gui/main.zig +++ b/gui/main.zig @@ -1,6 +1,6 @@ // zig fmt: off const std = @import("std"); -const Api = @import("artifacts-api"); +const Lib = @import("lib"); const rl = @import("raylib"); const raylib_h = @cImport({ @cInclude("stdio.h"); @@ -8,6 +8,8 @@ const raylib_h = @cImport({ }); const App = @import("./app.zig"); +const Api = Lib.Api; + pub const std_options = .{ .log_scope_levels = &[_]std.log.ScopeLevel{ .{ .scope = .api, .level = .warn }, diff --git a/api/enum_string_utils.zig b/lib/api/enum_string_utils.zig similarity index 100% rename from api/enum_string_utils.zig rename to lib/api/enum_string_utils.zig diff --git a/api/errors.zig b/lib/api/errors.zig similarity index 100% rename from api/errors.zig rename to lib/api/errors.zig diff --git a/api/json_utils.zig b/lib/api/json_utils.zig similarity index 100% rename from api/json_utils.zig rename to lib/api/json_utils.zig diff --git a/api/ratelimit.zig b/lib/api/ratelimit.zig similarity index 100% rename from api/ratelimit.zig rename to lib/api/ratelimit.zig diff --git a/api/root.zig b/lib/api/root.zig similarity index 96% rename from api/root.zig rename to lib/api/root.zig index 49650c8..5136f90 100644 --- a/api/root.zig +++ b/lib/api/root.zig @@ -10,7 +10,7 @@ pub const images_uri = std.Uri.parse(images_url) catch @compileError("Images ser pub const api_url = "https://api.artifactsmmo.com"; pub const docs_url = api_url ++ "/openapi.json"; -pub const parseDateTime = @import("./date_time/parse.zig").parseDateTime; +pub const parseDateTime = @import("../date_time/parse.zig").parseDateTime; pub const Server = @import("server.zig"); pub const RateLimit = @import("./ratelimit.zig"); diff --git a/api/schemas/character.zig b/lib/api/schemas/character.zig similarity index 98% rename from api/schemas/character.zig rename to lib/api/schemas/character.zig index d3b02fe..e40908d 100644 --- a/api/schemas/character.zig +++ b/lib/api/schemas/character.zig @@ -2,7 +2,7 @@ const std = @import("std"); const Store = @import("../store.zig"); const EnumStringUtils = @import("../enum_string_utils.zig").EnumStringUtils; -const parseDateTime = @import("../date_time/parse.zig").parseDateTime; +const parseDateTime = @import("../../date_time/parse.zig").parseDateTime; const json_utils = @import("../json_utils.zig"); pub const Equipment = @import("./equipment.zig"); const Task = @import("./task.zig"); diff --git a/api/schemas/cooldown.zig b/lib/api/schemas/cooldown.zig similarity index 97% rename from api/schemas/cooldown.zig rename to lib/api/schemas/cooldown.zig index 8c61ba9..df21798 100644 --- a/api/schemas/cooldown.zig +++ b/lib/api/schemas/cooldown.zig @@ -2,7 +2,7 @@ const std = @import("std"); const Store = @import("../store.zig"); const json_utils = @import("../json_utils.zig"); -const parseDateTime = @import("../date_time/parse.zig").parseDateTime; +const parseDateTime = @import("../../date_time/parse.zig").parseDateTime; const EnumStringUtils = @import("../enum_string_utils.zig").EnumStringUtils; const Cooldown = @This(); diff --git a/api/schemas/craft.zig b/lib/api/schemas/craft.zig similarity index 100% rename from api/schemas/craft.zig rename to lib/api/schemas/craft.zig diff --git a/api/schemas/drop_rate.zig b/lib/api/schemas/drop_rate.zig similarity index 100% rename from api/schemas/drop_rate.zig rename to lib/api/schemas/drop_rate.zig diff --git a/api/schemas/elemental_stat.zig b/lib/api/schemas/elemental_stat.zig similarity index 100% rename from api/schemas/elemental_stat.zig rename to lib/api/schemas/elemental_stat.zig diff --git a/api/schemas/equip_result.zig b/lib/api/schemas/equip_result.zig similarity index 100% rename from api/schemas/equip_result.zig rename to lib/api/schemas/equip_result.zig diff --git a/api/schemas/equipment.zig b/lib/api/schemas/equipment.zig similarity index 100% rename from api/schemas/equipment.zig rename to lib/api/schemas/equipment.zig diff --git a/api/schemas/ge_order.zig b/lib/api/schemas/ge_order.zig similarity index 95% rename from api/schemas/ge_order.zig rename to lib/api/schemas/ge_order.zig index 9d565d1..e2783ab 100644 --- a/api/schemas/ge_order.zig +++ b/lib/api/schemas/ge_order.zig @@ -2,7 +2,7 @@ const std = @import("std"); const Character = @import("./character.zig"); const json_utils = @import("../json_utils.zig"); -const parseDateTime = @import("../date_time/parse.zig").parseDateTime; +const parseDateTime = @import("../../date_time/parse.zig").parseDateTime; const Store = @import("../store.zig"); const Item = @import("./item.zig"); diff --git a/api/schemas/item.zig b/lib/api/schemas/item.zig similarity index 100% rename from api/schemas/item.zig rename to lib/api/schemas/item.zig diff --git a/api/schemas/map.zig b/lib/api/schemas/map.zig similarity index 100% rename from api/schemas/map.zig rename to lib/api/schemas/map.zig diff --git a/api/schemas/monster.zig b/lib/api/schemas/monster.zig similarity index 100% rename from api/schemas/monster.zig rename to lib/api/schemas/monster.zig diff --git a/api/schemas/move_result.zig b/lib/api/schemas/move_result.zig similarity index 100% rename from api/schemas/move_result.zig rename to lib/api/schemas/move_result.zig diff --git a/api/schemas/position.zig b/lib/api/schemas/position.zig similarity index 100% rename from api/schemas/position.zig rename to lib/api/schemas/position.zig diff --git a/api/schemas/resource.zig b/lib/api/schemas/resource.zig similarity index 100% rename from api/schemas/resource.zig rename to lib/api/schemas/resource.zig diff --git a/api/schemas/simple_item.zig b/lib/api/schemas/simple_item.zig similarity index 100% rename from api/schemas/simple_item.zig rename to lib/api/schemas/simple_item.zig diff --git a/api/schemas/skill_info_details.zig b/lib/api/schemas/skill_info_details.zig similarity index 100% rename from api/schemas/skill_info_details.zig rename to lib/api/schemas/skill_info_details.zig diff --git a/api/schemas/skill_usage_result.zig b/lib/api/schemas/skill_usage_result.zig similarity index 100% rename from api/schemas/skill_usage_result.zig rename to lib/api/schemas/skill_usage_result.zig diff --git a/api/schemas/status.zig b/lib/api/schemas/status.zig similarity index 97% rename from api/schemas/status.zig rename to lib/api/schemas/status.zig index e6a2f1d..beb8c8c 100644 --- a/api/schemas/status.zig +++ b/lib/api/schemas/status.zig @@ -2,7 +2,7 @@ const std = @import("std"); const Store = @import("../store.zig"); const json_utils = @import("../json_utils.zig"); -const parseDateTime = @import("../date_time/parse.zig").parseDateTime; +const parseDateTime = @import("../../date_time/parse.zig").parseDateTime; const json = std.json; const Allocator = std.mem.Allocator; diff --git a/api/schemas/task.zig b/lib/api/schemas/task.zig similarity index 100% rename from api/schemas/task.zig rename to lib/api/schemas/task.zig diff --git a/api/server.zig b/lib/api/server.zig similarity index 99% rename from api/server.zig rename to lib/api/server.zig index a502cef..d147f33 100644 --- a/api/server.zig +++ b/lib/api/server.zig @@ -2,9 +2,9 @@ const Root = @import("root.zig"); const Store = @import("./store.zig"); const std = @import("std"); -const json_utils = @import("json_utils.zig"); +const json_utils = @import("./json_utils.zig"); const errors = @import("./errors.zig"); -const stb_image = @import("./stb_image/root.zig"); +const stb_image = @import("../stb_image/root.zig"); const RateLimit = @import("./ratelimit.zig"); const FetchError = errors.FetchError; diff --git a/api/store.zig b/lib/api/store.zig similarity index 100% rename from api/store.zig rename to lib/api/store.zig diff --git a/lib/artificer.zig b/lib/artificer.zig index c5d852a..a6c3d37 100644 --- a/lib/artificer.zig +++ b/lib/artificer.zig @@ -1,6 +1,6 @@ // zig fmt: off const std = @import("std"); -const Api = @import("artifacts-api"); +const Api = @import("./api/root.zig"); const Allocator = std.mem.Allocator; const GatherGoal = @import("gather_goal.zig"); diff --git a/lib/craft_goal.zig b/lib/craft_goal.zig index 73d9b71..cb17a5e 100644 --- a/lib/craft_goal.zig +++ b/lib/craft_goal.zig @@ -1,5 +1,5 @@ // zig fmt: off -const Api = @import("artifacts-api"); +const Api = @import("./api/root.zig"); const Artificer = @import("./artificer.zig"); const Context = Artificer.GoalContext; diff --git a/api/date_time/parse.zig b/lib/date_time/parse.zig similarity index 100% rename from api/date_time/parse.zig rename to lib/date_time/parse.zig diff --git a/api/date_time/timegm.c b/lib/date_time/timegm.c similarity index 100% rename from api/date_time/timegm.c rename to lib/date_time/timegm.c diff --git a/api/date_time/timegm.h b/lib/date_time/timegm.h similarity index 100% rename from api/date_time/timegm.h rename to lib/date_time/timegm.h diff --git a/lib/equip_goal.zig b/lib/equip_goal.zig index b4418da..6bde3ca 100644 --- a/lib/equip_goal.zig +++ b/lib/equip_goal.zig @@ -1,6 +1,6 @@ // zig fmt: off const std = @import("std"); -const Api = @import("artifacts-api"); +const Api = @import("./api/root.zig"); const Artificer = @import("./artificer.zig"); const Context = Artificer.GoalContext; diff --git a/lib/gather_goal.zig b/lib/gather_goal.zig index e9ff651..2c66c70 100644 --- a/lib/gather_goal.zig +++ b/lib/gather_goal.zig @@ -1,5 +1,5 @@ // zig fmt: off -const Api = @import("artifacts-api"); +const Api = @import("./api/root.zig"); const Artificer = @import("./artificer.zig"); const Context = Artificer.GoalContext; diff --git a/lib/root.zig b/lib/root.zig index c3b370d..2e36460 100644 --- a/lib/root.zig +++ b/lib/root.zig @@ -1,5 +1,5 @@ // zig fmt: off -const Api = @import("artifacts-api"); +pub const Api = @import("./api/root.zig"); pub const ArtificerType = @import("./artificer.zig").ArtificerType; pub const SimServer = @import("./sim_server.zig"); diff --git a/lib/sim_server.zig b/lib/sim_server.zig index 8478707..b458ef7 100644 --- a/lib/sim_server.zig +++ b/lib/sim_server.zig @@ -1,6 +1,6 @@ // zig fmt: off const std = @import("std"); -const Api = @import("artifacts-api"); +const Api = @import("./api/root.zig"); const SimClock = @import("./sim_clock.zig"); const Server = @This(); diff --git a/api/stb_image/root.zig b/lib/stb_image/root.zig similarity index 100% rename from api/stb_image/root.zig rename to lib/stb_image/root.zig diff --git a/api/stb_image/stb_image.c b/lib/stb_image/stb_image.c similarity index 100% rename from api/stb_image/stb_image.c rename to lib/stb_image/stb_image.c diff --git a/api/stb_image/stb_image.h b/lib/stb_image/stb_image.h similarity index 100% rename from api/stb_image/stb_image.h rename to lib/stb_image/stb_image.h