@sonoransoftware/sonoran.js 1.0.41 → 1.0.42

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.
@@ -111,6 +111,29 @@ export interface CMSClockInType {
111
111
  id: string;
112
112
  label: string;
113
113
  }
114
+ export interface AccountActivityLog {
115
+ id: string;
116
+ status: boolean;
117
+ accId: string;
118
+ serverId: number;
119
+ start: string;
120
+ end: string | null;
121
+ clearReason: string | null;
122
+ metadata: Record<string, any>;
123
+ objKey: string;
124
+ }
125
+ export interface AccountClockInLog {
126
+ id: number;
127
+ startTime: string | null;
128
+ endTime: string | null;
129
+ completed: boolean;
130
+ notes: {
131
+ timestamp: string;
132
+ message: string;
133
+ }[];
134
+ type?: string;
135
+ objKey: string;
136
+ }
114
137
  export interface CMSGetClockInTypesPromiseResult {
115
138
  success: boolean;
116
139
  reason?: string;
@@ -119,7 +142,7 @@ export interface CMSGetClockInTypesPromiseResult {
119
142
  export interface CMSGetLatestActivityPromiseResult {
120
143
  success: boolean;
121
144
  reason?: string;
122
- data?: string | null;
145
+ data?: AccountClockInLog[] | AccountActivityLog[];
123
146
  }
124
147
  export interface CMSClockInOutParams {
125
148
  accId?: string;
@@ -578,7 +578,8 @@ class CMSManager extends BaseManager_1.BaseManager {
578
578
  var _a;
579
579
  try {
580
580
  const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_LATEST_ACTIVITY', params));
581
- resolve({ success: true, data: response });
581
+ const data = response && typeof response === 'object' && 'data' in response ? response.data : response;
582
+ resolve({ success: true, data });
582
583
  }
583
584
  catch (err) {
584
585
  if (err instanceof src_1.APIError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -232,7 +232,7 @@ const getRanks = await instance.cms.getAccountRanks(params);
232
232
  ### clockInOut(obj)
233
233
  Clock a user in or out in the CMS system
234
234
  #### Arugment `obj`
235
- ##### Type `object` `{accId?: string, apiId?: string, forceClockIn?: boolean, discord?: string, uniqueId?: string}`
235
+ ##### Type `object` `{accId?: string, apiId?: string, forceClockIn?: boolean, discord?: string, uniqueId?: string, type?: string}`
236
236
  ```js
237
237
  const params = {
238
238
  accId: '',
@@ -240,11 +240,19 @@ const params = {
240
240
  forceClockIn: true,
241
241
  discord: '',
242
242
  uniqueId: '1234',
243
+ type: 'clockin-type-uuid'
243
244
  };
244
245
  // Clocks a user in or out
245
246
  const clock = await instance.cms.clockInOut(params);
246
247
  ```
247
248
 
249
+ ### getClockInTypes()
250
+ Returns the configured clock-in types.
251
+ ```js
252
+ const types = await instance.cms.getClockInTypes();
253
+ // [{ id: 'uuid', label: 'Patrol' }]
254
+ ```
255
+
248
256
  ### checkComApiId(apiId)
249
257
  Checks if a given API ID is attatched to any account within the community, and if true, returns the username of the associated account.
250
258
  #### Arugment `apiId`
@@ -327,6 +335,16 @@ Fetches the current clock-in entry for the account if one exists.
327
335
  const currentEntry = await instance.cms.getCurrentClockIn({ apiId: '1234' });
328
336
  ```
329
337
 
338
+ ### getLatestActivity(params)
339
+ Gets the latest clock-in or activity entries for an account.
340
+ ```js
341
+ // Clock-in history
342
+ const clockins = await instance.cms.getLatestActivity({ accId: 'account-uuid', type: 'clockin' });
343
+ // Activity history (requires serverId)
344
+ const activity = await instance.cms.getLatestActivity({ accId: 'account-uuid', type: 'activity', serverId: 1 });
345
+ ```
346
+ *Returns an array of clock-in logs (`AccountClockInLog`) or activity logs (`AccountActivityLog`); each item includes `objKey` alongside the other fields.*
347
+
330
348
  ### getAccounts(options)
331
349
  Retrieves CMS accounts with optional pagination and status filters.
332
350
  ```js
package/src/constants.ts CHANGED
@@ -127,6 +127,31 @@ export interface CMSClockInType {
127
127
  label: string;
128
128
  }
129
129
 
130
+ export interface AccountActivityLog {
131
+ id: string;
132
+ status: boolean;
133
+ accId: string;
134
+ serverId: number;
135
+ start: string;
136
+ end: string | null;
137
+ clearReason: string | null;
138
+ metadata: Record<string, any>;
139
+ objKey: string;
140
+ }
141
+
142
+ export interface AccountClockInLog {
143
+ id: number;
144
+ startTime: string | null;
145
+ endTime: string | null;
146
+ completed: boolean;
147
+ notes: {
148
+ timestamp: string;
149
+ message: string;
150
+ }[];
151
+ type?: string;
152
+ objKey: string;
153
+ }
154
+
130
155
  export interface CMSGetClockInTypesPromiseResult {
131
156
  success: boolean;
132
157
  reason?: string;
@@ -136,7 +161,7 @@ export interface CMSGetClockInTypesPromiseResult {
136
161
  export interface CMSGetLatestActivityPromiseResult {
137
162
  success: boolean;
138
163
  reason?: string;
139
- data?: string | null;
164
+ data?: AccountClockInLog[] | AccountActivityLog[];
140
165
  }
141
166
 
142
167
  export interface CMSClockInOutParams {
@@ -520,7 +520,8 @@ export class CMSManager extends BaseManager {
520
520
  return new Promise(async (resolve, reject) => {
521
521
  try {
522
522
  const response: any = await this.rest?.request('GET_LATEST_ACTIVITY', params);
523
- resolve({ success: true, data: response });
523
+ const data = response && typeof response === 'object' && 'data' in response ? (response as any).data : response;
524
+ resolve({ success: true, data });
524
525
  } catch (err) {
525
526
  if (err instanceof APIError) {
526
527
  resolve({ success: false, reason: err.response });