@letpeoplework/lighthouse-client 1.2.0 → 1.3.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/index.cjs +94 -19
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +94 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -579,6 +579,47 @@ var toApiError = (statusCode, reason) => ({
|
|
|
579
579
|
reason,
|
|
580
580
|
statusCode
|
|
581
581
|
});
|
|
582
|
+
var CONCURRENCY_CONFLICT_STATUS = 409;
|
|
583
|
+
var CONCURRENCY_CONFLICT_GUIDANCE = "This edit conflicts because the item was changed by someone else. Re-fetch the current settings to obtain the latest concurrency token, then re-apply your change.";
|
|
584
|
+
var getProblemDetailsMessage = (body) => {
|
|
585
|
+
if (!isObjectRecord(body)) {
|
|
586
|
+
return void 0;
|
|
587
|
+
}
|
|
588
|
+
for (const key of ["detail", "title", "message"]) {
|
|
589
|
+
const value = body[key];
|
|
590
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
591
|
+
return value.trim();
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return void 0;
|
|
595
|
+
};
|
|
596
|
+
var getResponseBody = async (response) => {
|
|
597
|
+
try {
|
|
598
|
+
if (response.json !== void 0) {
|
|
599
|
+
return await response.json();
|
|
600
|
+
}
|
|
601
|
+
return JSON.parse(await response.text());
|
|
602
|
+
} catch {
|
|
603
|
+
return void 0;
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
var toConcurrencyConflictError = (serverMessage) => ({
|
|
607
|
+
category: "concurrency-conflict",
|
|
608
|
+
reason: serverMessage === void 0 ? CONCURRENCY_CONFLICT_GUIDANCE : `${serverMessage} ${CONCURRENCY_CONFLICT_GUIDANCE}`,
|
|
609
|
+
statusCode: CONCURRENCY_CONFLICT_STATUS
|
|
610
|
+
});
|
|
611
|
+
var toResponseError = async (response) => {
|
|
612
|
+
if (response.status === CONCURRENCY_CONFLICT_STATUS) {
|
|
613
|
+
const serverMessage = getProblemDetailsMessage(
|
|
614
|
+
await getResponseBody(response)
|
|
615
|
+
);
|
|
616
|
+
return toConcurrencyConflictError(serverMessage);
|
|
617
|
+
}
|
|
618
|
+
return toApiError(
|
|
619
|
+
response.status,
|
|
620
|
+
`Request failed with status ${response.status}.`
|
|
621
|
+
);
|
|
622
|
+
};
|
|
582
623
|
var requestText = async (configuration, dependencies, route) => {
|
|
583
624
|
const fetchDependency = getFetchDependency(dependencies);
|
|
584
625
|
const connectivityResult = await validateLighthouseConnectivity(
|
|
@@ -597,12 +638,7 @@ var requestText = async (configuration, dependencies, route) => {
|
|
|
597
638
|
getRequestInit(configuration.auth)
|
|
598
639
|
);
|
|
599
640
|
if (!response.ok) {
|
|
600
|
-
return getErrorResult(
|
|
601
|
-
toApiError(
|
|
602
|
-
response.status,
|
|
603
|
-
`Request failed with status ${response.status}.`
|
|
604
|
-
)
|
|
605
|
-
);
|
|
641
|
+
return getErrorResult(await toResponseError(response));
|
|
606
642
|
}
|
|
607
643
|
return {
|
|
608
644
|
ok: true,
|
|
@@ -636,12 +672,7 @@ var requestJson = async (configuration, dependencies, route, requestOptions) =>
|
|
|
636
672
|
getRequestInit(configuration.auth, requestOptions)
|
|
637
673
|
);
|
|
638
674
|
if (!response.ok) {
|
|
639
|
-
return getErrorResult(
|
|
640
|
-
toApiError(
|
|
641
|
-
response.status,
|
|
642
|
-
`Request failed with status ${response.status}.`
|
|
643
|
-
)
|
|
644
|
-
);
|
|
675
|
+
return getErrorResult(await toResponseError(response));
|
|
645
676
|
}
|
|
646
677
|
if (response.json === void 0) {
|
|
647
678
|
return {
|
|
@@ -682,12 +713,7 @@ var requestNoContent = async (configuration, dependencies, route, requestOptions
|
|
|
682
713
|
getRequestInit(configuration.auth, requestOptions)
|
|
683
714
|
);
|
|
684
715
|
if (!response.ok) {
|
|
685
|
-
return getErrorResult(
|
|
686
|
-
toApiError(
|
|
687
|
-
response.status,
|
|
688
|
-
`Request failed with status ${response.status}.`
|
|
689
|
-
)
|
|
690
|
-
);
|
|
716
|
+
return getErrorResult(await toResponseError(response));
|
|
691
717
|
}
|
|
692
718
|
return {
|
|
693
719
|
ok: true,
|
|
@@ -756,7 +782,8 @@ var deriveTotalWorkItemAgeOverTime = (startDate, endDate, wipData) => {
|
|
|
756
782
|
return { startDate, endDate, daily };
|
|
757
783
|
};
|
|
758
784
|
var FEATURE_REQUIRES_SERVER_NEWER_THAN = {
|
|
759
|
-
cumulativeStateTime: "v26.5.24.10"
|
|
785
|
+
cumulativeStateTime: "v26.5.24.10",
|
|
786
|
+
recurringBlackoutRules: "v26.5.29.5"
|
|
760
787
|
};
|
|
761
788
|
var parseServerVersion = (raw) => {
|
|
762
789
|
const trimmed = raw.trim().replace(/^v/iu, "");
|
|
@@ -1300,6 +1327,54 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
|
|
|
1300
1327
|
`/v1/deliveries/${deliveryId}`,
|
|
1301
1328
|
{ method: "DELETE" }
|
|
1302
1329
|
),
|
|
1330
|
+
getRecurringBlackoutRules: async () => {
|
|
1331
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1332
|
+
if (unsupported) {
|
|
1333
|
+
return unsupported;
|
|
1334
|
+
}
|
|
1335
|
+
return requestJson(
|
|
1336
|
+
configuration,
|
|
1337
|
+
dependencies,
|
|
1338
|
+
"/v1/recurring-blackout-rules",
|
|
1339
|
+
{ method: "GET" }
|
|
1340
|
+
);
|
|
1341
|
+
},
|
|
1342
|
+
createRecurringBlackoutRule: async (payload) => {
|
|
1343
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1344
|
+
if (unsupported) {
|
|
1345
|
+
return unsupported;
|
|
1346
|
+
}
|
|
1347
|
+
return requestJson(
|
|
1348
|
+
configuration,
|
|
1349
|
+
dependencies,
|
|
1350
|
+
"/v1/recurring-blackout-rules",
|
|
1351
|
+
{ method: "POST", body: payload }
|
|
1352
|
+
);
|
|
1353
|
+
},
|
|
1354
|
+
updateRecurringBlackoutRule: async (id, payload) => {
|
|
1355
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1356
|
+
if (unsupported) {
|
|
1357
|
+
return unsupported;
|
|
1358
|
+
}
|
|
1359
|
+
return requestJson(
|
|
1360
|
+
configuration,
|
|
1361
|
+
dependencies,
|
|
1362
|
+
`/v1/recurring-blackout-rules/${id}`,
|
|
1363
|
+
{ method: "PUT", body: payload }
|
|
1364
|
+
);
|
|
1365
|
+
},
|
|
1366
|
+
deleteRecurringBlackoutRule: async (id) => {
|
|
1367
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1368
|
+
if (unsupported) {
|
|
1369
|
+
return unsupported;
|
|
1370
|
+
}
|
|
1371
|
+
return requestNoContent(
|
|
1372
|
+
configuration,
|
|
1373
|
+
dependencies,
|
|
1374
|
+
`/v1/recurring-blackout-rules/${id}`,
|
|
1375
|
+
{ method: "DELETE" }
|
|
1376
|
+
);
|
|
1377
|
+
},
|
|
1303
1378
|
runManualForecast: async (teamId, payload) => requestJson(
|
|
1304
1379
|
configuration,
|
|
1305
1380
|
dependencies,
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ type ClientPackageContract = {
|
|
|
4
4
|
readonly capabilities: readonly ClientCapability[];
|
|
5
5
|
};
|
|
6
6
|
declare const getClientPackageContract: () => ClientPackageContract;
|
|
7
|
-
type ConnectivityCategory = "success" | "unreachable" | "misconfigured" | "unauthorized" | "dependency-failure" | "unexpected";
|
|
7
|
+
type ConnectivityCategory = "success" | "unreachable" | "misconfigured" | "unauthorized" | "dependency-failure" | "concurrency-conflict" | "unexpected";
|
|
8
8
|
type StandaloneDiscoveryContract = {
|
|
9
9
|
readonly contractVersion: 1;
|
|
10
10
|
readonly lighthouseUrl: string;
|
|
@@ -257,6 +257,23 @@ type CumulativeStateTimeCandidateRow = {
|
|
|
257
257
|
type CumulativeStateTimeCandidatesResult = {
|
|
258
258
|
readonly items: readonly CumulativeStateTimeCandidateRow[];
|
|
259
259
|
};
|
|
260
|
+
type DayOfWeek = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday";
|
|
261
|
+
type RecurringBlackoutRule = {
|
|
262
|
+
readonly id: number;
|
|
263
|
+
readonly weekdays: readonly DayOfWeek[];
|
|
264
|
+
readonly intervalWeeks: number;
|
|
265
|
+
readonly start: string;
|
|
266
|
+
readonly end: string | null;
|
|
267
|
+
readonly description: string;
|
|
268
|
+
readonly summary: string;
|
|
269
|
+
};
|
|
270
|
+
type RecurringBlackoutRuleInput = {
|
|
271
|
+
readonly weekdays: readonly DayOfWeek[];
|
|
272
|
+
readonly intervalWeeks: number;
|
|
273
|
+
readonly start: string;
|
|
274
|
+
readonly end: string | null;
|
|
275
|
+
readonly description: string;
|
|
276
|
+
};
|
|
260
277
|
type LighthouseClient = {
|
|
261
278
|
readonly checkConnectivity: () => Promise<ConnectivityValidationResult>;
|
|
262
279
|
readonly getVersion: () => Promise<LighthouseApiResult<string>>;
|
|
@@ -312,6 +329,10 @@ type LighthouseClient = {
|
|
|
312
329
|
readonly createDelivery: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
|
|
313
330
|
readonly updateDelivery: (deliveryId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
|
|
314
331
|
readonly deleteDelivery: (deliveryId: number) => Promise<LighthouseApiResult<undefined>>;
|
|
332
|
+
readonly getRecurringBlackoutRules: () => Promise<LighthouseApiResult<readonly RecurringBlackoutRule[]>>;
|
|
333
|
+
readonly createRecurringBlackoutRule: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
|
|
334
|
+
readonly updateRecurringBlackoutRule: (id: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
|
|
335
|
+
readonly deleteRecurringBlackoutRule: (id: number) => Promise<LighthouseApiResult<undefined>>;
|
|
315
336
|
readonly runManualForecast: (teamId: number, payload: ManualForecastInput) => Promise<LighthouseApiResult<unknown>>;
|
|
316
337
|
readonly runBacktest: (teamId: number, payload: BacktestInput) => Promise<LighthouseApiResult<unknown>>;
|
|
317
338
|
};
|
|
@@ -326,4 +347,4 @@ type LighthouseClientDependencies = {
|
|
|
326
347
|
declare const isServerVersionNewerThan: (candidate: string, baseline: string) => boolean | null;
|
|
327
348
|
declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
|
|
328
349
|
|
|
329
|
-
export { type BacktestInput, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
|
|
350
|
+
export { type BacktestInput, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type DayOfWeek, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type RecurringBlackoutRule, type RecurringBlackoutRuleInput, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ type ClientPackageContract = {
|
|
|
4
4
|
readonly capabilities: readonly ClientCapability[];
|
|
5
5
|
};
|
|
6
6
|
declare const getClientPackageContract: () => ClientPackageContract;
|
|
7
|
-
type ConnectivityCategory = "success" | "unreachable" | "misconfigured" | "unauthorized" | "dependency-failure" | "unexpected";
|
|
7
|
+
type ConnectivityCategory = "success" | "unreachable" | "misconfigured" | "unauthorized" | "dependency-failure" | "concurrency-conflict" | "unexpected";
|
|
8
8
|
type StandaloneDiscoveryContract = {
|
|
9
9
|
readonly contractVersion: 1;
|
|
10
10
|
readonly lighthouseUrl: string;
|
|
@@ -257,6 +257,23 @@ type CumulativeStateTimeCandidateRow = {
|
|
|
257
257
|
type CumulativeStateTimeCandidatesResult = {
|
|
258
258
|
readonly items: readonly CumulativeStateTimeCandidateRow[];
|
|
259
259
|
};
|
|
260
|
+
type DayOfWeek = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday";
|
|
261
|
+
type RecurringBlackoutRule = {
|
|
262
|
+
readonly id: number;
|
|
263
|
+
readonly weekdays: readonly DayOfWeek[];
|
|
264
|
+
readonly intervalWeeks: number;
|
|
265
|
+
readonly start: string;
|
|
266
|
+
readonly end: string | null;
|
|
267
|
+
readonly description: string;
|
|
268
|
+
readonly summary: string;
|
|
269
|
+
};
|
|
270
|
+
type RecurringBlackoutRuleInput = {
|
|
271
|
+
readonly weekdays: readonly DayOfWeek[];
|
|
272
|
+
readonly intervalWeeks: number;
|
|
273
|
+
readonly start: string;
|
|
274
|
+
readonly end: string | null;
|
|
275
|
+
readonly description: string;
|
|
276
|
+
};
|
|
260
277
|
type LighthouseClient = {
|
|
261
278
|
readonly checkConnectivity: () => Promise<ConnectivityValidationResult>;
|
|
262
279
|
readonly getVersion: () => Promise<LighthouseApiResult<string>>;
|
|
@@ -312,6 +329,10 @@ type LighthouseClient = {
|
|
|
312
329
|
readonly createDelivery: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
|
|
313
330
|
readonly updateDelivery: (deliveryId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
|
|
314
331
|
readonly deleteDelivery: (deliveryId: number) => Promise<LighthouseApiResult<undefined>>;
|
|
332
|
+
readonly getRecurringBlackoutRules: () => Promise<LighthouseApiResult<readonly RecurringBlackoutRule[]>>;
|
|
333
|
+
readonly createRecurringBlackoutRule: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
|
|
334
|
+
readonly updateRecurringBlackoutRule: (id: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
|
|
335
|
+
readonly deleteRecurringBlackoutRule: (id: number) => Promise<LighthouseApiResult<undefined>>;
|
|
315
336
|
readonly runManualForecast: (teamId: number, payload: ManualForecastInput) => Promise<LighthouseApiResult<unknown>>;
|
|
316
337
|
readonly runBacktest: (teamId: number, payload: BacktestInput) => Promise<LighthouseApiResult<unknown>>;
|
|
317
338
|
};
|
|
@@ -326,4 +347,4 @@ type LighthouseClientDependencies = {
|
|
|
326
347
|
declare const isServerVersionNewerThan: (candidate: string, baseline: string) => boolean | null;
|
|
327
348
|
declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
|
|
328
349
|
|
|
329
|
-
export { type BacktestInput, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
|
|
350
|
+
export { type BacktestInput, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type DayOfWeek, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type RecurringBlackoutRule, type RecurringBlackoutRuleInput, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
|
package/dist/index.js
CHANGED
|
@@ -544,6 +544,47 @@ var toApiError = (statusCode, reason) => ({
|
|
|
544
544
|
reason,
|
|
545
545
|
statusCode
|
|
546
546
|
});
|
|
547
|
+
var CONCURRENCY_CONFLICT_STATUS = 409;
|
|
548
|
+
var CONCURRENCY_CONFLICT_GUIDANCE = "This edit conflicts because the item was changed by someone else. Re-fetch the current settings to obtain the latest concurrency token, then re-apply your change.";
|
|
549
|
+
var getProblemDetailsMessage = (body) => {
|
|
550
|
+
if (!isObjectRecord(body)) {
|
|
551
|
+
return void 0;
|
|
552
|
+
}
|
|
553
|
+
for (const key of ["detail", "title", "message"]) {
|
|
554
|
+
const value = body[key];
|
|
555
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
556
|
+
return value.trim();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return void 0;
|
|
560
|
+
};
|
|
561
|
+
var getResponseBody = async (response) => {
|
|
562
|
+
try {
|
|
563
|
+
if (response.json !== void 0) {
|
|
564
|
+
return await response.json();
|
|
565
|
+
}
|
|
566
|
+
return JSON.parse(await response.text());
|
|
567
|
+
} catch {
|
|
568
|
+
return void 0;
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
var toConcurrencyConflictError = (serverMessage) => ({
|
|
572
|
+
category: "concurrency-conflict",
|
|
573
|
+
reason: serverMessage === void 0 ? CONCURRENCY_CONFLICT_GUIDANCE : `${serverMessage} ${CONCURRENCY_CONFLICT_GUIDANCE}`,
|
|
574
|
+
statusCode: CONCURRENCY_CONFLICT_STATUS
|
|
575
|
+
});
|
|
576
|
+
var toResponseError = async (response) => {
|
|
577
|
+
if (response.status === CONCURRENCY_CONFLICT_STATUS) {
|
|
578
|
+
const serverMessage = getProblemDetailsMessage(
|
|
579
|
+
await getResponseBody(response)
|
|
580
|
+
);
|
|
581
|
+
return toConcurrencyConflictError(serverMessage);
|
|
582
|
+
}
|
|
583
|
+
return toApiError(
|
|
584
|
+
response.status,
|
|
585
|
+
`Request failed with status ${response.status}.`
|
|
586
|
+
);
|
|
587
|
+
};
|
|
547
588
|
var requestText = async (configuration, dependencies, route) => {
|
|
548
589
|
const fetchDependency = getFetchDependency(dependencies);
|
|
549
590
|
const connectivityResult = await validateLighthouseConnectivity(
|
|
@@ -562,12 +603,7 @@ var requestText = async (configuration, dependencies, route) => {
|
|
|
562
603
|
getRequestInit(configuration.auth)
|
|
563
604
|
);
|
|
564
605
|
if (!response.ok) {
|
|
565
|
-
return getErrorResult(
|
|
566
|
-
toApiError(
|
|
567
|
-
response.status,
|
|
568
|
-
`Request failed with status ${response.status}.`
|
|
569
|
-
)
|
|
570
|
-
);
|
|
606
|
+
return getErrorResult(await toResponseError(response));
|
|
571
607
|
}
|
|
572
608
|
return {
|
|
573
609
|
ok: true,
|
|
@@ -601,12 +637,7 @@ var requestJson = async (configuration, dependencies, route, requestOptions) =>
|
|
|
601
637
|
getRequestInit(configuration.auth, requestOptions)
|
|
602
638
|
);
|
|
603
639
|
if (!response.ok) {
|
|
604
|
-
return getErrorResult(
|
|
605
|
-
toApiError(
|
|
606
|
-
response.status,
|
|
607
|
-
`Request failed with status ${response.status}.`
|
|
608
|
-
)
|
|
609
|
-
);
|
|
640
|
+
return getErrorResult(await toResponseError(response));
|
|
610
641
|
}
|
|
611
642
|
if (response.json === void 0) {
|
|
612
643
|
return {
|
|
@@ -647,12 +678,7 @@ var requestNoContent = async (configuration, dependencies, route, requestOptions
|
|
|
647
678
|
getRequestInit(configuration.auth, requestOptions)
|
|
648
679
|
);
|
|
649
680
|
if (!response.ok) {
|
|
650
|
-
return getErrorResult(
|
|
651
|
-
toApiError(
|
|
652
|
-
response.status,
|
|
653
|
-
`Request failed with status ${response.status}.`
|
|
654
|
-
)
|
|
655
|
-
);
|
|
681
|
+
return getErrorResult(await toResponseError(response));
|
|
656
682
|
}
|
|
657
683
|
return {
|
|
658
684
|
ok: true,
|
|
@@ -721,7 +747,8 @@ var deriveTotalWorkItemAgeOverTime = (startDate, endDate, wipData) => {
|
|
|
721
747
|
return { startDate, endDate, daily };
|
|
722
748
|
};
|
|
723
749
|
var FEATURE_REQUIRES_SERVER_NEWER_THAN = {
|
|
724
|
-
cumulativeStateTime: "v26.5.24.10"
|
|
750
|
+
cumulativeStateTime: "v26.5.24.10",
|
|
751
|
+
recurringBlackoutRules: "v26.5.29.5"
|
|
725
752
|
};
|
|
726
753
|
var parseServerVersion = (raw) => {
|
|
727
754
|
const trimmed = raw.trim().replace(/^v/iu, "");
|
|
@@ -1265,6 +1292,54 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
|
|
|
1265
1292
|
`/v1/deliveries/${deliveryId}`,
|
|
1266
1293
|
{ method: "DELETE" }
|
|
1267
1294
|
),
|
|
1295
|
+
getRecurringBlackoutRules: async () => {
|
|
1296
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1297
|
+
if (unsupported) {
|
|
1298
|
+
return unsupported;
|
|
1299
|
+
}
|
|
1300
|
+
return requestJson(
|
|
1301
|
+
configuration,
|
|
1302
|
+
dependencies,
|
|
1303
|
+
"/v1/recurring-blackout-rules",
|
|
1304
|
+
{ method: "GET" }
|
|
1305
|
+
);
|
|
1306
|
+
},
|
|
1307
|
+
createRecurringBlackoutRule: async (payload) => {
|
|
1308
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1309
|
+
if (unsupported) {
|
|
1310
|
+
return unsupported;
|
|
1311
|
+
}
|
|
1312
|
+
return requestJson(
|
|
1313
|
+
configuration,
|
|
1314
|
+
dependencies,
|
|
1315
|
+
"/v1/recurring-blackout-rules",
|
|
1316
|
+
{ method: "POST", body: payload }
|
|
1317
|
+
);
|
|
1318
|
+
},
|
|
1319
|
+
updateRecurringBlackoutRule: async (id, payload) => {
|
|
1320
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1321
|
+
if (unsupported) {
|
|
1322
|
+
return unsupported;
|
|
1323
|
+
}
|
|
1324
|
+
return requestJson(
|
|
1325
|
+
configuration,
|
|
1326
|
+
dependencies,
|
|
1327
|
+
`/v1/recurring-blackout-rules/${id}`,
|
|
1328
|
+
{ method: "PUT", body: payload }
|
|
1329
|
+
);
|
|
1330
|
+
},
|
|
1331
|
+
deleteRecurringBlackoutRule: async (id) => {
|
|
1332
|
+
const unsupported = await ensureServerSupports("recurringBlackoutRules");
|
|
1333
|
+
if (unsupported) {
|
|
1334
|
+
return unsupported;
|
|
1335
|
+
}
|
|
1336
|
+
return requestNoContent(
|
|
1337
|
+
configuration,
|
|
1338
|
+
dependencies,
|
|
1339
|
+
`/v1/recurring-blackout-rules/${id}`,
|
|
1340
|
+
{ method: "DELETE" }
|
|
1341
|
+
);
|
|
1342
|
+
},
|
|
1268
1343
|
runManualForecast: async (teamId, payload) => requestJson(
|
|
1269
1344
|
configuration,
|
|
1270
1345
|
dependencies,
|
package/package.json
CHANGED