@markwharton/liquidplanner 3.0.0 → 3.1.0
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/dist/client.d.ts +3 -3
- package/dist/client.js +14 -4
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://api-docs.liquidplanner.com/
|
|
8
8
|
*/
|
|
9
9
|
import type { Result } from '@markwharton/api-core';
|
|
10
|
-
import type { LPConfig, LPWorkspace, LPMember, LPItem, LPCostCode, LPSyncResult, LPTimesheetEntry, LPUpsertOptions, LPAssignment, LPAncestor, LPFindItemsOptions, LPWorkspaceTree } from './types.js';
|
|
10
|
+
import type { LPConfig, LPWorkspace, LPMember, LPItem, LPCostCode, LPSyncResult, LPTimesheetEntry, LPTimesheetOptions, LPUpsertOptions, LPAssignment, LPAncestor, LPFindItemsOptions, LPWorkspaceTree } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* LiquidPlanner API Client
|
|
13
13
|
*
|
|
@@ -202,9 +202,9 @@ export declare class LPClient {
|
|
|
202
202
|
* @see https://api-docs.liquidplanner.com/docs/task-status-1
|
|
203
203
|
*
|
|
204
204
|
* @param date - Date(s) in YYYY-MM-DD format (string or array)
|
|
205
|
-
* @param
|
|
205
|
+
* @param options - Optional filters (itemId, memberId)
|
|
206
206
|
*/
|
|
207
|
-
getTimesheetEntries(date: string | string[],
|
|
207
|
+
getTimesheetEntries(date: string | string[], options?: LPTimesheetOptions): Promise<Result<LPTimesheetEntry[]>>;
|
|
208
208
|
/**
|
|
209
209
|
* Update an existing timesheet entry
|
|
210
210
|
*
|
package/dist/client.js
CHANGED
|
@@ -576,12 +576,18 @@ export class LPClient {
|
|
|
576
576
|
* @see https://api-docs.liquidplanner.com/docs/task-status-1
|
|
577
577
|
*
|
|
578
578
|
* @param date - Date(s) in YYYY-MM-DD format (string or array)
|
|
579
|
-
* @param
|
|
579
|
+
* @param options - Optional filters (itemId, memberId)
|
|
580
580
|
*/
|
|
581
|
-
async getTimesheetEntries(date,
|
|
581
|
+
async getTimesheetEntries(date, options) {
|
|
582
582
|
const dates = Array.isArray(date) ? date : [date];
|
|
583
583
|
const sortedKey = [...dates].sort().join(',');
|
|
584
|
-
const
|
|
584
|
+
const { itemId, memberId } = options || {};
|
|
585
|
+
// Build cache key from all filter dimensions
|
|
586
|
+
let cacheKey = `timesheet:${sortedKey}`;
|
|
587
|
+
if (itemId)
|
|
588
|
+
cacheKey += `:item=${itemId}`;
|
|
589
|
+
if (memberId)
|
|
590
|
+
cacheKey += `:member=${memberId}`;
|
|
585
591
|
return this.cached(cacheKey, this.cacheTtl.timesheetTtl, async () => {
|
|
586
592
|
// Build query with date[in] filter (supports multiple dates)
|
|
587
593
|
let baseUrl = this.workspaceUrl(`logged-time-entries/v1?${filterIn('date', dates)}`);
|
|
@@ -589,6 +595,10 @@ export class LPClient {
|
|
|
589
595
|
if (itemId) {
|
|
590
596
|
baseUrl += `&${filterIs('itemId', itemId)}`;
|
|
591
597
|
}
|
|
598
|
+
// Optional filter by memberId (server-side user filtering)
|
|
599
|
+
if (memberId) {
|
|
600
|
+
baseUrl += `&${filterIs('userId', memberId)}`;
|
|
601
|
+
}
|
|
592
602
|
return paginatedFetch({
|
|
593
603
|
fetchFn: (url) => this.fetch(url),
|
|
594
604
|
baseUrl,
|
|
@@ -679,7 +689,7 @@ export class LPClient {
|
|
|
679
689
|
async upsertTimesheetEntry(entry, options = {}) {
|
|
680
690
|
const { accumulate = true } = options;
|
|
681
691
|
// Fetch existing entries for this date/item first
|
|
682
|
-
const fetchResult = await this.getTimesheetEntries(entry.date, entry.itemId);
|
|
692
|
+
const fetchResult = await this.getTimesheetEntries(entry.date, { itemId: entry.itemId });
|
|
683
693
|
if (!fetchResult.ok) {
|
|
684
694
|
return { ok: false, error: fetchResult.error, status: fetchResult.status };
|
|
685
695
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
export { LPClient } from './client.js';
|
|
32
32
|
export { resolveTaskToAssignment } from './workflows.js';
|
|
33
|
-
export type { LPConfig, LPCacheConfig, LPRetryConfig, LPItemType, LPUserType, LPHierarchyItem, LPItem, LPAncestor, LPWorkspace, LPMember, LPCostCode, LPSyncResult, LPTimesheetEntry, LPTaskResolution, LPUpsertOptions, LPAssignment, LPFindItemsOptions, LPTreeNode, LPWorkspaceTree, } from './types.js';
|
|
33
|
+
export type { LPConfig, LPCacheConfig, LPRetryConfig, LPItemType, LPUserType, LPHierarchyItem, LPItem, LPAncestor, LPWorkspace, LPMember, LPCostCode, LPSyncResult, LPTimesheetEntry, LPTaskResolution, LPTimesheetOptions, LPUpsertOptions, LPAssignment, LPFindItemsOptions, LPTreeNode, LPWorkspaceTree, } from './types.js';
|
|
34
34
|
export type { AccessTier } from './types.js';
|
|
35
35
|
export { METHOD_TIERS, ENTITIES } from './types.js';
|
|
36
36
|
export { ok, err, getErrorMessage, normalizeEnum, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
|
package/dist/types.d.ts
CHANGED
|
@@ -245,6 +245,15 @@ export interface LPTimesheetEntry {
|
|
|
245
245
|
/** User ID who logged the time (present in API responses) */
|
|
246
246
|
userId?: number;
|
|
247
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Options for querying timesheet entries
|
|
250
|
+
*/
|
|
251
|
+
export interface LPTimesheetOptions {
|
|
252
|
+
/** Filter by assignment/item ID (itemId[is]) */
|
|
253
|
+
itemId?: number;
|
|
254
|
+
/** Filter by member ID (userId[is]) — server-side user filtering */
|
|
255
|
+
memberId?: number;
|
|
256
|
+
}
|
|
248
257
|
/**
|
|
249
258
|
* Options for upsert timesheet entry operation
|
|
250
259
|
*/
|