busroot-sdk 0.0.7-alpha.6 → 0.0.7-alpha.8

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/build/index.d.ts CHANGED
@@ -3740,6 +3740,277 @@ export type ScheduleViewModel = z.infer<typeof ScheduleViewModel>;
3740
3740
  export interface BusrootSignals extends BusrootSignalsPayload {
3741
3741
  sku_code?: string;
3742
3742
  }
3743
+ export interface OverviewProductionAmounts {
3744
+ idealQuantityTotal: number;
3745
+ idealQuantityGood: number;
3746
+ idealQuantityBad: number;
3747
+ actualQuantityTotal: number;
3748
+ actualQuantityGood: number;
3749
+ actualQuantityBad: number;
3750
+ idealValueTotal: number;
3751
+ idealValueGood: number;
3752
+ idealValueBad: number;
3753
+ actualValueTotal: number;
3754
+ actualValueGood: number;
3755
+ actualValueBad: number;
3756
+ }
3757
+ export interface OverviewMetrics {
3758
+ schedule: {
3759
+ inShiftDurationMs: number;
3760
+ scheduledProductionDurationMs: number;
3761
+ scheduledNonProductionDurationMs: number;
3762
+ unscheduledDurationMs: number;
3763
+ scheduledNonProductionByReason: {
3764
+ reasonCode: string;
3765
+ durationMs: number;
3766
+ }[];
3767
+ };
3768
+ production: {
3769
+ amounts: OverviewProductionAmounts;
3770
+ byHour: {
3771
+ startHour: string;
3772
+ amounts: OverviewProductionAmounts;
3773
+ }[];
3774
+ bySku: {
3775
+ skuCode: string;
3776
+ amounts: OverviewProductionAmounts;
3777
+ }[];
3778
+ byWoRefAndSku: {
3779
+ woRef: string;
3780
+ scheduledDurationMs: number;
3781
+ amounts: OverviewProductionAmounts;
3782
+ skus: {
3783
+ skuCode: string;
3784
+ scheduledDurationMs: number;
3785
+ amounts: OverviewProductionAmounts;
3786
+ }[];
3787
+ }[];
3788
+ };
3789
+ downtime: {
3790
+ totalDurationMs: number;
3791
+ byReason: {
3792
+ reasonCode: string;
3793
+ durationMs: number;
3794
+ }[];
3795
+ };
3796
+ utilisation: {
3797
+ productiveDurationMs: number;
3798
+ inShiftProductiveDurationMs: number;
3799
+ inScheduleProductiveDurationMs: number;
3800
+ };
3801
+ }
3802
+ export interface OverviewViewModel extends OverviewMetrics {
3803
+ range: {
3804
+ rangeCode: string;
3805
+ duration: number;
3806
+ fromIso: string;
3807
+ toIso: string;
3808
+ };
3809
+ stations: ({
3810
+ code: string;
3811
+ name: string;
3812
+ } & OverviewMetrics)[];
3813
+ }
3814
+ declare const PlantGetParams: z.ZodObject<{
3815
+ plantCode: z.ZodString;
3816
+ }, "strip", z.ZodTypeAny, {
3817
+ plantCode: string;
3818
+ }, {
3819
+ plantCode: string;
3820
+ }>;
3821
+ declare const PlantCreateUpdateParams: z.ZodObject<{
3822
+ code: z.ZodString;
3823
+ name: z.ZodOptional<z.ZodString>;
3824
+ timezone: z.ZodOptional<z.ZodString>;
3825
+ dayStartHour: z.ZodOptional<z.ZodNumber>;
3826
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
3827
+ code: z.ZodString;
3828
+ name: z.ZodOptional<z.ZodString>;
3829
+ timezone: z.ZodOptional<z.ZodString>;
3830
+ dayStartHour: z.ZodOptional<z.ZodNumber>;
3831
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
3832
+ code: z.ZodString;
3833
+ name: z.ZodOptional<z.ZodString>;
3834
+ timezone: z.ZodOptional<z.ZodString>;
3835
+ dayStartHour: z.ZodOptional<z.ZodNumber>;
3836
+ }, z.ZodTypeAny, "passthrough">>;
3837
+ declare const StationGetParams: z.ZodObject<{
3838
+ stationCode: z.ZodString;
3839
+ }, "strip", z.ZodTypeAny, {
3840
+ stationCode: string;
3841
+ }, {
3842
+ stationCode: string;
3843
+ }>;
3844
+ declare const StationCreateUpdateParams: z.ZodObject<{
3845
+ code: z.ZodString;
3846
+ name: z.ZodOptional<z.ZodString>;
3847
+ groupCode: z.ZodOptional<z.ZodString>;
3848
+ shiftPatternId: z.ZodOptional<z.ZodNumber>;
3849
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
3850
+ code: z.ZodString;
3851
+ name: z.ZodOptional<z.ZodString>;
3852
+ groupCode: z.ZodOptional<z.ZodString>;
3853
+ shiftPatternId: z.ZodOptional<z.ZodNumber>;
3854
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
3855
+ code: z.ZodString;
3856
+ name: z.ZodOptional<z.ZodString>;
3857
+ groupCode: z.ZodOptional<z.ZodString>;
3858
+ shiftPatternId: z.ZodOptional<z.ZodNumber>;
3859
+ }, z.ZodTypeAny, "passthrough">>;
3860
+ declare const StationSignalParams: z.ZodObject<{
3861
+ stationCode: z.ZodString;
3862
+ payload: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
3863
+ }, "strip", z.ZodTypeAny, {
3864
+ stationCode: string;
3865
+ payload: {} & {
3866
+ [k: string]: unknown;
3867
+ };
3868
+ }, {
3869
+ stationCode: string;
3870
+ payload: {} & {
3871
+ [k: string]: unknown;
3872
+ };
3873
+ }>;
3874
+ declare const ProductionGetParams: z.ZodObject<{
3875
+ plantCode: z.ZodString;
3876
+ stationCodes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3877
+ rangeCode: z.ZodString;
3878
+ }, "strip", z.ZodTypeAny, {
3879
+ plantCode: string;
3880
+ rangeCode: string;
3881
+ stationCodes?: string[] | undefined;
3882
+ }, {
3883
+ plantCode: string;
3884
+ rangeCode: string;
3885
+ stationCodes?: string[] | undefined;
3886
+ }>;
3887
+ declare const ProductionGetRawParams: z.ZodObject<{
3888
+ plantCode: z.ZodString;
3889
+ stationCodes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3890
+ rangeCode: z.ZodString;
3891
+ }, "strip", z.ZodTypeAny, {
3892
+ plantCode: string;
3893
+ rangeCode: string;
3894
+ stationCodes?: string[] | undefined;
3895
+ }, {
3896
+ plantCode: string;
3897
+ rangeCode: string;
3898
+ stationCodes?: string[] | undefined;
3899
+ }>;
3900
+ declare const MetricsGetParams: z.ZodObject<{
3901
+ plantCode: z.ZodString;
3902
+ stationCodes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3903
+ rangeCode: z.ZodString;
3904
+ aggregateWindow: z.ZodString;
3905
+ }, "strip", z.ZodTypeAny, {
3906
+ plantCode: string;
3907
+ rangeCode: string;
3908
+ aggregateWindow: string;
3909
+ stationCodes?: string[] | undefined;
3910
+ }, {
3911
+ plantCode: string;
3912
+ rangeCode: string;
3913
+ aggregateWindow: string;
3914
+ stationCodes?: string[] | undefined;
3915
+ }>;
3916
+ declare const DowntimeGetParams: z.ZodObject<{
3917
+ plantCode: z.ZodString;
3918
+ stationCodes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3919
+ rangeCode: z.ZodString;
3920
+ }, "strip", z.ZodTypeAny, {
3921
+ plantCode: string;
3922
+ rangeCode: string;
3923
+ stationCodes?: string[] | undefined;
3924
+ }, {
3925
+ plantCode: string;
3926
+ rangeCode: string;
3927
+ stationCodes?: string[] | undefined;
3928
+ }>;
3929
+ declare const OverviewGetParams: z.ZodObject<{
3930
+ plantCode: z.ZodString;
3931
+ rangeCode: z.ZodString;
3932
+ rangeFrom: z.ZodOptional<z.ZodString>;
3933
+ rangeTo: z.ZodOptional<z.ZodString>;
3934
+ }, "strip", z.ZodTypeAny, {
3935
+ plantCode: string;
3936
+ rangeCode: string;
3937
+ rangeFrom?: string | undefined;
3938
+ rangeTo?: string | undefined;
3939
+ }, {
3940
+ plantCode: string;
3941
+ rangeCode: string;
3942
+ rangeFrom?: string | undefined;
3943
+ rangeTo?: string | undefined;
3944
+ }>;
3945
+ declare const SkuGetParams: z.ZodObject<{
3946
+ skuCode: z.ZodString;
3947
+ }, "strip", z.ZodTypeAny, {
3948
+ skuCode: string;
3949
+ }, {
3950
+ skuCode: string;
3951
+ }>;
3952
+ declare const SkuCreateUpdateParams: z.ZodObject<{
3953
+ code: z.ZodString;
3954
+ name: z.ZodOptional<z.ZodString>;
3955
+ cycleTime: z.ZodOptional<z.ZodNumber>;
3956
+ value: z.ZodOptional<z.ZodNumber>;
3957
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
3958
+ code: z.ZodString;
3959
+ name: z.ZodOptional<z.ZodString>;
3960
+ cycleTime: z.ZodOptional<z.ZodNumber>;
3961
+ value: z.ZodOptional<z.ZodNumber>;
3962
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
3963
+ code: z.ZodString;
3964
+ name: z.ZodOptional<z.ZodString>;
3965
+ cycleTime: z.ZodOptional<z.ZodNumber>;
3966
+ value: z.ZodOptional<z.ZodNumber>;
3967
+ }, z.ZodTypeAny, "passthrough">>;
3968
+ declare const ScheduleGetParams: z.ZodObject<{
3969
+ scheduleId: z.ZodNumber;
3970
+ }, "strip", z.ZodTypeAny, {
3971
+ scheduleId: number;
3972
+ }, {
3973
+ scheduleId: number;
3974
+ }>;
3975
+ declare const ScheduleCreateUpdateParams: z.ZodObject<{
3976
+ stationCode: z.ZodOptional<z.ZodString>;
3977
+ skuCode: z.ZodOptional<z.ZodString>;
3978
+ plannedStartAt: z.ZodOptional<z.ZodString>;
3979
+ plannedQuantity: z.ZodOptional<z.ZodNumber>;
3980
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
3981
+ stationCode: z.ZodOptional<z.ZodString>;
3982
+ skuCode: z.ZodOptional<z.ZodString>;
3983
+ plannedStartAt: z.ZodOptional<z.ZodString>;
3984
+ plannedQuantity: z.ZodOptional<z.ZodNumber>;
3985
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
3986
+ stationCode: z.ZodOptional<z.ZodString>;
3987
+ skuCode: z.ZodOptional<z.ZodString>;
3988
+ plannedStartAt: z.ZodOptional<z.ZodString>;
3989
+ plannedQuantity: z.ZodOptional<z.ZodNumber>;
3990
+ }, z.ZodTypeAny, "passthrough">>;
3991
+ declare const AccountCreateParams: z.ZodObject<{
3992
+ domain: z.ZodString;
3993
+ plantName: z.ZodString;
3994
+ }, "strip", z.ZodTypeAny, {
3995
+ domain: string;
3996
+ plantName: string;
3997
+ }, {
3998
+ domain: string;
3999
+ plantName: string;
4000
+ }>;
4001
+ export interface ParamDescriptor {
4002
+ name: string;
4003
+ required: boolean;
4004
+ description: string;
4005
+ type: string;
4006
+ }
4007
+ export interface CapabilityDescriptor {
4008
+ name: string;
4009
+ description: string;
4010
+ method: "GET" | "POST";
4011
+ params: ParamDescriptor[];
4012
+ }
4013
+ export declare function describeCapabilities(): CapabilityDescriptor[];
3743
4014
  export declare const MqttEventType: {
3744
4015
  StationMetricNew: string;
3745
4016
  StationChanged: string;
@@ -3778,65 +4049,52 @@ export declare class BusrootClient {
3778
4049
  mqttClient: mqtt.MqttClient | undefined;
3779
4050
  listenersByEventType: Map<"StationMetricNew" | "StationChanged" | "ScheduleChanged" | "ScheduleStarted" | "ScheduleEnded" | "ProductionNew", Set<Listener>>;
3780
4051
  static version: string;
4052
+ static describe: typeof describeCapabilities;
3781
4053
  constructor(config: Config);
3782
4054
  destroy(): void;
3783
4055
  private get;
3784
4056
  private post;
3785
- get profile(): {
4057
+ profile: {
3786
4058
  get: () => Promise<any>;
3787
4059
  };
3788
- get account(): {
3789
- create: (domain: string, plantName: string) => Promise<{
4060
+ account: {
4061
+ create: ({ domain, plantName }: z.infer<typeof AccountCreateParams>) => Promise<{
3790
4062
  account: AccountViewModel;
3791
4063
  apiKey: string;
3792
4064
  }>;
3793
4065
  };
3794
- get apiKey(): {
4066
+ apiKey: {
3795
4067
  create: () => Promise<ApiKeySchema>;
3796
4068
  };
3797
- get plant(): {
3798
- get: (plantCode: string) => Promise<PlantViewModel>;
3799
- createUpdate: (plant: Partial<PlantSchema>) => Promise<PlantViewModel>;
4069
+ plant: {
4070
+ get: ({ plantCode }: z.infer<typeof PlantGetParams>) => Promise<PlantViewModel>;
4071
+ createUpdate: (plant: z.infer<typeof PlantCreateUpdateParams>) => Promise<PlantViewModel>;
4072
+ };
4073
+ station: {
4074
+ get: ({ stationCode }: z.infer<typeof StationGetParams>) => Promise<StationViewModel[]>;
4075
+ createUpdate: (station: z.infer<typeof StationCreateUpdateParams>) => Promise<StationViewModel>;
4076
+ signal: (_params: z.infer<typeof StationSignalParams>) => void;
3800
4077
  };
3801
- get station(): {
3802
- get: (stationCode: string) => Promise<StationViewModel[]>;
3803
- createUpdate: (station: Partial<StationSchema>) => Promise<StationViewModel>;
3804
- signal: (stationCode: string, payload: BusrootSignals) => void;
4078
+ production: {
4079
+ get: ({ plantCode, stationCodes, rangeCode }: z.infer<typeof ProductionGetParams>) => Promise<ProductionViewModel[]>;
4080
+ getRaw: ({ plantCode, stationCodes, rangeCode }: z.infer<typeof ProductionGetRawParams>) => Promise<ProductionViewModel[]>;
3805
4081
  };
3806
- get production(): {
3807
- get: ({ plantCode, stationCodes, rangeCode, }: {
3808
- plantCode: string;
3809
- stationCodes?: string[];
3810
- rangeCode: string;
3811
- }) => Promise<ProductionViewModel[]>;
3812
- getRaw: ({ plantCode, stationCodes, rangeCode, }: {
3813
- plantCode: string;
3814
- stationCodes?: string[];
3815
- rangeCode: string;
3816
- }) => Promise<ProductionViewModel[]>;
4082
+ metrics: {
4083
+ get: ({ plantCode, stationCodes, rangeCode, aggregateWindow, }: z.infer<typeof MetricsGetParams>) => Promise<AggregatedStationWindowsByStation[]>;
3817
4084
  };
3818
- get metrics(): {
3819
- get: ({ plantCode, stationCodes, rangeCode, aggregateWindow, }: {
3820
- plantCode: string;
3821
- stationCodes?: string[];
3822
- rangeCode: string;
3823
- aggregateWindow: string;
3824
- }) => Promise<AggregatedStationWindowsByStation[]>;
4085
+ downtime: {
4086
+ get: ({ plantCode, stationCodes, rangeCode }: z.infer<typeof DowntimeGetParams>) => Promise<AggregatedDowntime[]>;
3825
4087
  };
3826
- get downtime(): {
3827
- get: ({ plantCode, stationCodes, rangeCode, }: {
3828
- plantCode: string;
3829
- stationCodes?: string[];
3830
- rangeCode: string;
3831
- }) => Promise<AggregatedDowntime[]>;
4088
+ overview: {
4089
+ get: ({ plantCode, rangeCode, rangeFrom, rangeTo }: z.infer<typeof OverviewGetParams>) => Promise<OverviewViewModel>;
3832
4090
  };
3833
4091
  sku: {
3834
- get: (skuCode: string) => Promise<SkuViewModel>;
3835
- createUpdate: (sku: Partial<SkuViewModel>) => Promise<SkuViewModel>;
4092
+ get: ({ skuCode }: z.infer<typeof SkuGetParams>) => Promise<SkuViewModel>;
4093
+ createUpdate: (sku: z.infer<typeof SkuCreateUpdateParams>) => Promise<SkuViewModel>;
3836
4094
  };
3837
4095
  schedule: {
3838
- get: (scheduleId: number) => Promise<ScheduleViewModel[]>;
3839
- createUpdate: (schedule: Partial<ScheduleViewModel>) => Promise<ScheduleViewModel>;
4096
+ get: ({ scheduleId }: z.infer<typeof ScheduleGetParams>) => Promise<ScheduleViewModel[]>;
4097
+ createUpdate: (schedule: z.infer<typeof ScheduleCreateUpdateParams>) => Promise<ScheduleViewModel>;
3840
4098
  };
3841
4099
  on(event: MqttEventType, listener: Listener): void;
3842
4100
  off(event: MqttEventType, listener: Listener): void;
package/build/index.js CHANGED
@@ -1096,6 +1096,7 @@ __export(index_exports, {
1096
1096
  BusrootClient: () => BusrootClient,
1097
1097
  Config: () => Config,
1098
1098
  MqttEventType: () => MqttEventType,
1099
+ describeCapabilities: () => describeCapabilities,
1099
1100
  formattedDateTime: () => import_times.formattedDateTime,
1100
1101
  formattedDuration: () => import_times.formattedDuration,
1101
1102
  useBusroot: () => useBusroot
@@ -1103,7 +1104,227 @@ __export(index_exports, {
1103
1104
  module.exports = __toCommonJS(index_exports);
1104
1105
 
1105
1106
  // src/client.ts
1107
+ var import_zod2 = require("zod");
1108
+
1109
+ // src/capabilities.ts
1106
1110
  var import_zod = require("zod");
1111
+ var PlantGetParams = import_zod.z.object({
1112
+ plantCode: import_zod.z.string().describe("Unique plant identifier code")
1113
+ });
1114
+ var PlantCreateUpdateParams = import_zod.z.object({
1115
+ code: import_zod.z.string().describe("Unique plant identifier code"),
1116
+ name: import_zod.z.string().optional().describe("Display name for the plant"),
1117
+ timezone: import_zod.z.string().optional().describe("IANA timezone (e.g. Europe/London)"),
1118
+ dayStartHour: import_zod.z.number().optional().describe("Hour the production day starts (0-23)")
1119
+ }).passthrough();
1120
+ var StationGetParams = import_zod.z.object({
1121
+ stationCode: import_zod.z.string().describe("Unique station identifier code")
1122
+ });
1123
+ var StationCreateUpdateParams = import_zod.z.object({
1124
+ code: import_zod.z.string().describe("Unique station identifier code"),
1125
+ name: import_zod.z.string().optional().describe("Display name for the station"),
1126
+ groupCode: import_zod.z.string().optional().describe("Group code to assign the station to"),
1127
+ shiftPatternId: import_zod.z.number().optional().describe("Shift pattern ID to assign")
1128
+ }).passthrough();
1129
+ var StationSignalParams = import_zod.z.object({
1130
+ stationCode: import_zod.z.string().describe("Target station code"),
1131
+ payload: import_zod.z.object({}).passthrough().describe("Signal payload object")
1132
+ });
1133
+ var ProductionGetParams = import_zod.z.object({
1134
+ plantCode: import_zod.z.string().describe("Plant code to query"),
1135
+ stationCodes: import_zod.z.array(import_zod.z.string()).optional().describe("Filter by station codes"),
1136
+ rangeCode: import_zod.z.string().describe("Time range code (e.g. today, yesterday, last7days)")
1137
+ });
1138
+ var ProductionGetRawParams = import_zod.z.object({
1139
+ plantCode: import_zod.z.string().describe("Plant code to query"),
1140
+ stationCodes: import_zod.z.array(import_zod.z.string()).optional().describe("Filter by station codes"),
1141
+ rangeCode: import_zod.z.string().describe("Time range code (e.g. today, yesterday, last7days)")
1142
+ });
1143
+ var MetricsGetParams = import_zod.z.object({
1144
+ plantCode: import_zod.z.string().describe("Plant code to query"),
1145
+ stationCodes: import_zod.z.array(import_zod.z.string()).optional().describe("Filter by station codes"),
1146
+ rangeCode: import_zod.z.string().describe("Time range code (e.g. today, yesterday, last7days)"),
1147
+ aggregateWindow: import_zod.z.string().describe("Aggregation window (e.g. 1h, 1d)")
1148
+ });
1149
+ var DowntimeGetParams = import_zod.z.object({
1150
+ plantCode: import_zod.z.string().describe("Plant code to query"),
1151
+ stationCodes: import_zod.z.array(import_zod.z.string()).optional().describe("Filter by station codes"),
1152
+ rangeCode: import_zod.z.string().describe("Time range code (e.g. today, yesterday, last7days)")
1153
+ });
1154
+ var OverviewGetParams = import_zod.z.object({
1155
+ plantCode: import_zod.z.string().describe("Plant code to query"),
1156
+ rangeCode: import_zod.z.string().describe("Time range code (e.g. today, yesterday, last7days)"),
1157
+ rangeFrom: import_zod.z.string().optional().describe("Custom range start (ISO 8601)"),
1158
+ rangeTo: import_zod.z.string().optional().describe("Custom range end (ISO 8601)")
1159
+ });
1160
+ var SkuGetParams = import_zod.z.object({
1161
+ skuCode: import_zod.z.string().describe("Unique SKU identifier code")
1162
+ });
1163
+ var SkuCreateUpdateParams = import_zod.z.object({
1164
+ code: import_zod.z.string().describe("Unique SKU identifier code"),
1165
+ name: import_zod.z.string().optional().describe("Display name for the SKU"),
1166
+ cycleTime: import_zod.z.number().optional().describe("Ideal cycle time in seconds"),
1167
+ value: import_zod.z.number().optional().describe("Monetary value per unit")
1168
+ }).passthrough();
1169
+ var ScheduleGetParams = import_zod.z.object({
1170
+ scheduleId: import_zod.z.number().describe("Numeric schedule ID")
1171
+ });
1172
+ var ScheduleCreateUpdateParams = import_zod.z.object({
1173
+ stationCode: import_zod.z.string().optional().describe("Station code to assign the schedule to"),
1174
+ skuCode: import_zod.z.string().optional().describe("SKU code for this schedule"),
1175
+ plannedStartAt: import_zod.z.string().optional().describe("Planned start time (ISO 8601)"),
1176
+ plannedQuantity: import_zod.z.number().optional().describe("Planned production quantity")
1177
+ }).passthrough();
1178
+ var AccountCreateParams = import_zod.z.object({
1179
+ domain: import_zod.z.string().describe("Account domain name"),
1180
+ plantName: import_zod.z.string().describe("Name of the initial plant to create")
1181
+ });
1182
+ var capabilities = [
1183
+ {
1184
+ name: "profile.get",
1185
+ description: "Get the authenticated user's profile",
1186
+ httpMethod: "GET",
1187
+ params: null
1188
+ },
1189
+ {
1190
+ name: "account.create",
1191
+ description: "Create a new account with an initial plant",
1192
+ httpMethod: "POST",
1193
+ params: AccountCreateParams
1194
+ },
1195
+ {
1196
+ name: "apiKey.create",
1197
+ description: "Create a new API key for the current account",
1198
+ httpMethod: "POST",
1199
+ params: null
1200
+ },
1201
+ {
1202
+ name: "plant.get",
1203
+ description: "Get a plant by its code",
1204
+ httpMethod: "GET",
1205
+ params: PlantGetParams
1206
+ },
1207
+ {
1208
+ name: "plant.createUpdate",
1209
+ description: "Create or update a plant",
1210
+ httpMethod: "POST",
1211
+ params: PlantCreateUpdateParams
1212
+ },
1213
+ {
1214
+ name: "station.get",
1215
+ description: "Get stations by station code",
1216
+ httpMethod: "GET",
1217
+ params: StationGetParams
1218
+ },
1219
+ {
1220
+ name: "station.createUpdate",
1221
+ description: "Create or update a station",
1222
+ httpMethod: "POST",
1223
+ params: StationCreateUpdateParams
1224
+ },
1225
+ {
1226
+ name: "station.signal",
1227
+ description: "Send a signal to a station",
1228
+ httpMethod: "POST",
1229
+ params: StationSignalParams
1230
+ },
1231
+ {
1232
+ name: "production.get",
1233
+ description: "Get aggregated production data for a plant and time range",
1234
+ httpMethod: "GET",
1235
+ params: ProductionGetParams
1236
+ },
1237
+ {
1238
+ name: "production.getRaw",
1239
+ description: "Get raw production data for a plant and time range",
1240
+ httpMethod: "GET",
1241
+ params: ProductionGetRawParams
1242
+ },
1243
+ {
1244
+ name: "metrics.get",
1245
+ description: "Get aggregated station metrics (windows) for a plant and time range",
1246
+ httpMethod: "GET",
1247
+ params: MetricsGetParams
1248
+ },
1249
+ {
1250
+ name: "downtime.get",
1251
+ description: "Get aggregated downtime data for a plant and time range",
1252
+ httpMethod: "GET",
1253
+ params: DowntimeGetParams
1254
+ },
1255
+ {
1256
+ name: "overview.get",
1257
+ description: "Get a full overview of plant performance for a time range",
1258
+ httpMethod: "GET",
1259
+ params: OverviewGetParams
1260
+ },
1261
+ {
1262
+ name: "sku.get",
1263
+ description: "Get a SKU by its code",
1264
+ httpMethod: "GET",
1265
+ params: SkuGetParams
1266
+ },
1267
+ {
1268
+ name: "sku.createUpdate",
1269
+ description: "Create or update a SKU",
1270
+ httpMethod: "POST",
1271
+ params: SkuCreateUpdateParams
1272
+ },
1273
+ {
1274
+ name: "schedule.get",
1275
+ description: "Get a schedule by its ID",
1276
+ httpMethod: "GET",
1277
+ params: ScheduleGetParams
1278
+ },
1279
+ {
1280
+ name: "schedule.createUpdate",
1281
+ description: "Create or update a schedule",
1282
+ httpMethod: "POST",
1283
+ params: ScheduleCreateUpdateParams
1284
+ }
1285
+ ];
1286
+ function resolveZodType(schema) {
1287
+ if (schema instanceof import_zod.z.ZodOptional || schema instanceof import_zod.z.ZodNullable) {
1288
+ return resolveZodType(schema.unwrap());
1289
+ }
1290
+ if (schema instanceof import_zod.z.ZodString) {
1291
+ return "string";
1292
+ }
1293
+ if (schema instanceof import_zod.z.ZodNumber) {
1294
+ return "number";
1295
+ }
1296
+ if (schema instanceof import_zod.z.ZodBoolean) {
1297
+ return "boolean";
1298
+ }
1299
+ if (schema instanceof import_zod.z.ZodArray) {
1300
+ return "array";
1301
+ }
1302
+ if (schema instanceof import_zod.z.ZodObject) {
1303
+ return "object";
1304
+ }
1305
+ if (schema instanceof import_zod.z.ZodEnum) {
1306
+ return "string";
1307
+ }
1308
+ return "unknown";
1309
+ }
1310
+ function describeCapabilities() {
1311
+ return capabilities.map((cap) => ({
1312
+ name: cap.name,
1313
+ description: cap.description,
1314
+ method: cap.httpMethod,
1315
+ params: cap.params ? Object.entries(cap.params.shape).map(([key, value]) => {
1316
+ const zodValue = value;
1317
+ return {
1318
+ name: key,
1319
+ required: !zodValue.isOptional(),
1320
+ description: zodValue.description ?? "",
1321
+ type: resolveZodType(zodValue)
1322
+ };
1323
+ }) : []
1324
+ }));
1325
+ }
1326
+
1327
+ // src/client.ts
1107
1328
  var import_mqtt = __toESM(require("mqtt"));
1108
1329
  var MqttEventType = {
1109
1330
  StationMetricNew: "STATION_METRIC_NEW",
@@ -1119,13 +1340,13 @@ var MqttEventType = {
1119
1340
  ProductionNew: "PRODUCTION_NEW"
1120
1341
  // When new production is added. NOT IMPLEMENTED FOR MANUAL PRODUCTION YET.
1121
1342
  };
1122
- var Config = import_zod.z.object({
1123
- accountId: import_zod.z.string().max(255),
1124
- apiKey: import_zod.z.string().max(255),
1125
- apiEndpoint: import_zod.z.string().max(255),
1126
- mqttHost: import_zod.z.string().max(255),
1127
- enableMqtt: import_zod.z.boolean().optional(),
1128
- enableDebug: import_zod.z.boolean().optional()
1343
+ var Config = import_zod2.z.object({
1344
+ accountId: import_zod2.z.string().max(255),
1345
+ apiKey: import_zod2.z.string().max(255),
1346
+ apiEndpoint: import_zod2.z.string().max(255),
1347
+ mqttHost: import_zod2.z.string().max(255),
1348
+ enableMqtt: import_zod2.z.boolean().optional(),
1349
+ enableDebug: import_zod2.z.boolean().optional()
1129
1350
  });
1130
1351
  var BusrootClient = class {
1131
1352
  constructor(config) {
@@ -1168,6 +1389,7 @@ var BusrootClient = class {
1168
1389
  mqttClient;
1169
1390
  listenersByEventType = /* @__PURE__ */ new Map();
1170
1391
  static version = "v0";
1392
+ static describe = describeCapabilities;
1171
1393
  destroy() {
1172
1394
  if (this.mqttClient != null) {
1173
1395
  this.mqttClient.end();
@@ -1205,121 +1427,104 @@ var BusrootClient = class {
1205
1427
  const resJson = await res.json();
1206
1428
  return resJson;
1207
1429
  }
1208
- get profile() {
1209
- return {
1210
- get: async () => {
1211
- const res = await this.get("/auth/profile");
1212
- return res.result;
1213
- }
1214
- };
1215
- }
1216
- get account() {
1217
- return {
1218
- create: async (domain, plantName) => {
1219
- const res = await this.post("/account/new", { domain, plantName });
1220
- return res.result;
1221
- }
1222
- };
1223
- }
1224
- get apiKey() {
1225
- return {
1226
- create: async () => {
1227
- const res = await this.post("/api-key", {});
1228
- return res.result;
1229
- }
1230
- };
1231
- }
1232
- get plant() {
1233
- return {
1234
- get: async (plantCode) => {
1235
- const res = await this.get("/plant", { plantCode });
1236
- return res.result;
1237
- },
1238
- createUpdate: async (plant) => {
1239
- const res = await this.post("/plant", plant);
1240
- return res.result;
1241
- }
1242
- };
1243
- }
1244
- get station() {
1245
- return {
1246
- get: async (stationCode) => {
1247
- const res = await this.get("/station", { stationcodes: stationCode });
1248
- return res.results;
1249
- },
1250
- createUpdate: async (station) => {
1251
- const res = await this.post("/station", station);
1252
- return res.result;
1253
- },
1254
- signal: (stationCode, payload) => {
1255
- throw new Error("noop");
1256
- }
1257
- };
1258
- }
1259
- get production() {
1260
- return {
1261
- get: async ({
1262
- plantCode,
1263
- stationCodes,
1264
- rangeCode
1265
- }) => {
1266
- const res = await this.get("/production", {
1267
- plantcode: plantCode,
1268
- stationcodes: stationCodes?.join(","),
1269
- rangecode: rangeCode
1270
- });
1271
- return res.results;
1272
- },
1273
- getRaw: async ({
1274
- plantCode,
1275
- stationCodes,
1276
- rangeCode
1277
- }) => {
1278
- const res = await this.get("/production/raw", {
1279
- plantcode: plantCode,
1280
- stationcodes: stationCodes?.join(","),
1281
- rangecode: rangeCode
1282
- });
1283
- return res.results;
1284
- }
1285
- };
1286
- }
1287
- get metrics() {
1288
- return {
1289
- get: async ({
1290
- plantCode,
1291
- stationCodes,
1292
- rangeCode,
1293
- aggregateWindow
1294
- }) => {
1295
- const res = await this.get("/station-windows", {
1296
- plantcode: plantCode,
1297
- stationcodes: stationCodes?.join(","),
1298
- rangecode: rangeCode,
1299
- aggregatewindow: aggregateWindow
1300
- });
1301
- return res.results;
1302
- }
1303
- };
1304
- }
1305
- get downtime() {
1306
- return {
1307
- get: async ({
1308
- plantCode,
1309
- stationCodes,
1310
- rangeCode
1311
- }) => {
1312
- const res = await this.get("/downtime", {
1313
- plantcode: plantCode,
1314
- stationcodes: stationCodes?.join(","),
1315
- rangecode: rangeCode
1316
- });
1317
- return res.results;
1318
- }
1319
- };
1320
- }
1430
+ profile = {
1431
+ get: async () => {
1432
+ const res = await this.get("/auth/profile");
1433
+ return res.result;
1434
+ }
1435
+ };
1436
+ account = {
1437
+ create: async ({ domain, plantName }) => {
1438
+ const res = await this.post("/account/new", { domain, plantName });
1439
+ return res.result;
1440
+ }
1441
+ };
1442
+ apiKey = {
1443
+ create: async () => {
1444
+ const res = await this.post("/api-key", {});
1445
+ return res.result;
1446
+ }
1447
+ };
1448
+ plant = {
1449
+ get: async ({ plantCode }) => {
1450
+ const res = await this.get("/plant", { plantCode });
1451
+ return res.result;
1452
+ },
1453
+ createUpdate: async (plant) => {
1454
+ const res = await this.post("/plant", plant);
1455
+ return res.result;
1456
+ }
1457
+ };
1458
+ station = {
1459
+ get: async ({ stationCode }) => {
1460
+ const res = await this.get("/station", { stationcodes: stationCode });
1461
+ return res.results;
1462
+ },
1463
+ createUpdate: async (station) => {
1464
+ const res = await this.post("/station", station);
1465
+ return res.result;
1466
+ },
1467
+ signal: (_params) => {
1468
+ throw new Error("noop");
1469
+ }
1470
+ };
1471
+ production = {
1472
+ get: async ({ plantCode, stationCodes, rangeCode }) => {
1473
+ const res = await this.get("/production", {
1474
+ plantcode: plantCode,
1475
+ stationcodes: stationCodes?.join(","),
1476
+ rangecode: rangeCode
1477
+ });
1478
+ return res.results;
1479
+ },
1480
+ getRaw: async ({ plantCode, stationCodes, rangeCode }) => {
1481
+ const res = await this.get("/production/raw", {
1482
+ plantcode: plantCode,
1483
+ stationcodes: stationCodes?.join(","),
1484
+ rangecode: rangeCode
1485
+ });
1486
+ return res.results;
1487
+ }
1488
+ };
1489
+ metrics = {
1490
+ get: async ({
1491
+ plantCode,
1492
+ stationCodes,
1493
+ rangeCode,
1494
+ aggregateWindow
1495
+ }) => {
1496
+ const res = await this.get("/station-windows", {
1497
+ plantcode: plantCode,
1498
+ stationcodes: stationCodes?.join(","),
1499
+ rangecode: rangeCode,
1500
+ aggregatewindow: aggregateWindow
1501
+ });
1502
+ return res.results;
1503
+ }
1504
+ };
1505
+ downtime = {
1506
+ get: async ({ plantCode, stationCodes, rangeCode }) => {
1507
+ const res = await this.get("/downtime", {
1508
+ plantcode: plantCode,
1509
+ stationcodes: stationCodes?.join(","),
1510
+ rangecode: rangeCode
1511
+ });
1512
+ return res.results;
1513
+ }
1514
+ };
1515
+ overview = {
1516
+ get: async ({ plantCode, rangeCode, rangeFrom, rangeTo }) => {
1517
+ const res = await this.get("/overview", {
1518
+ plantcode: plantCode,
1519
+ rangecode: rangeCode,
1520
+ rangefrom: rangeFrom,
1521
+ rangeto: rangeTo
1522
+ });
1523
+ return res.result;
1524
+ }
1525
+ };
1321
1526
  sku = {
1322
- get: async (skuCode) => {
1527
+ get: async ({ skuCode }) => {
1323
1528
  const res = await this.get("/sku", { skucodes: skuCode });
1324
1529
  return res.result;
1325
1530
  },
@@ -1329,7 +1534,7 @@ var BusrootClient = class {
1329
1534
  }
1330
1535
  };
1331
1536
  schedule = {
1332
- get: async (scheduleId) => {
1537
+ get: async ({ scheduleId }) => {
1333
1538
  const res = await this.get("/schedule", { ids: String(scheduleId) });
1334
1539
  return res.results;
1335
1540
  },
@@ -1404,6 +1609,7 @@ var import_times = __toESM(require_times());
1404
1609
  BusrootClient,
1405
1610
  Config,
1406
1611
  MqttEventType,
1612
+ describeCapabilities,
1407
1613
  formattedDateTime,
1408
1614
  formattedDuration,
1409
1615
  useBusroot
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busroot-sdk",
3
- "version": "0.0.7-alpha.6",
3
+ "version": "0.0.7-alpha.8",
4
4
  "description": "An SDK for accessing Busroot from output.industries",
5
5
  "homepage": "https://www.output.industries",
6
6
  "main": "./build/index.js",