@perspectask/sdk 1.0.0 → 1.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/README.md +20 -0
- package/dist/index.cjs +169 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +347 -2
- package/dist/index.d.ts +347 -2
- package/dist/index.js +156 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -400,6 +400,28 @@ type PullRequest = {
|
|
|
400
400
|
*/
|
|
401
401
|
linked_by: 'auto' | 'manual';
|
|
402
402
|
};
|
|
403
|
+
type KpiEntry = {
|
|
404
|
+
/**
|
|
405
|
+
* Id of this entry. Pass it to update or delete.
|
|
406
|
+
*/
|
|
407
|
+
id: string;
|
|
408
|
+
/**
|
|
409
|
+
* `target` = the number you aim for (by `at`); `actual` = a reading of where it stands at `at`.
|
|
410
|
+
*/
|
|
411
|
+
kind: 'target' | 'actual';
|
|
412
|
+
/**
|
|
413
|
+
* ISO 8601 UTC instant. Omitted for a target with no date.
|
|
414
|
+
*/
|
|
415
|
+
at?: string;
|
|
416
|
+
/**
|
|
417
|
+
* The number. Omitted when the entry was saved end-to-end encrypted (then `encrypted` is true).
|
|
418
|
+
*/
|
|
419
|
+
value?: number;
|
|
420
|
+
/**
|
|
421
|
+
* Only present when the value is end-to-end encrypted and so not readable over the API.
|
|
422
|
+
*/
|
|
423
|
+
encrypted?: true;
|
|
424
|
+
};
|
|
403
425
|
type ListTasksData = {
|
|
404
426
|
body?: never;
|
|
405
427
|
path?: never;
|
|
@@ -650,6 +672,149 @@ type UnlinkTaskPullRequestResponses = {
|
|
|
650
672
|
204: void;
|
|
651
673
|
};
|
|
652
674
|
type UnlinkTaskPullRequestResponse = UnlinkTaskPullRequestResponses[keyof UnlinkTaskPullRequestResponses];
|
|
675
|
+
type ListKpiTasksData = {
|
|
676
|
+
body?: never;
|
|
677
|
+
path?: never;
|
|
678
|
+
query?: never;
|
|
679
|
+
url: '/kpis';
|
|
680
|
+
};
|
|
681
|
+
type ListKpiTasksResponses = {
|
|
682
|
+
/**
|
|
683
|
+
* Short ids of the tasks that have KPI entries.
|
|
684
|
+
*/
|
|
685
|
+
200: Array<string>;
|
|
686
|
+
};
|
|
687
|
+
type ListKpiTasksResponse = ListKpiTasksResponses[keyof ListKpiTasksResponses];
|
|
688
|
+
type ListTaskKpisData = {
|
|
689
|
+
body?: never;
|
|
690
|
+
path: {
|
|
691
|
+
id: string;
|
|
692
|
+
};
|
|
693
|
+
query?: never;
|
|
694
|
+
url: '/tasks/{id}/kpis';
|
|
695
|
+
};
|
|
696
|
+
type ListTaskKpisErrors = {
|
|
697
|
+
/**
|
|
698
|
+
* Task is encrypted
|
|
699
|
+
*/
|
|
700
|
+
403: unknown;
|
|
701
|
+
/**
|
|
702
|
+
* Task not found
|
|
703
|
+
*/
|
|
704
|
+
404: unknown;
|
|
705
|
+
};
|
|
706
|
+
type ListTaskKpisResponses = {
|
|
707
|
+
/**
|
|
708
|
+
* KPI entries
|
|
709
|
+
*/
|
|
710
|
+
200: Array<KpiEntry>;
|
|
711
|
+
};
|
|
712
|
+
type ListTaskKpisResponse = ListTaskKpisResponses[keyof ListTaskKpisResponses];
|
|
713
|
+
type CreateTaskKpiData = {
|
|
714
|
+
body: {
|
|
715
|
+
kind: 'target' | 'actual';
|
|
716
|
+
value: number;
|
|
717
|
+
/**
|
|
718
|
+
* When the target is due, or when the actual was measured. Required for an actual; a target may have none.
|
|
719
|
+
*/
|
|
720
|
+
at?: string;
|
|
721
|
+
};
|
|
722
|
+
path: {
|
|
723
|
+
id: string;
|
|
724
|
+
};
|
|
725
|
+
query?: never;
|
|
726
|
+
url: '/tasks/{id}/kpis';
|
|
727
|
+
};
|
|
728
|
+
type CreateTaskKpiErrors = {
|
|
729
|
+
/**
|
|
730
|
+
* Invalid entry (e.g. an actual without `at`)
|
|
731
|
+
*/
|
|
732
|
+
400: unknown;
|
|
733
|
+
/**
|
|
734
|
+
* Task is encrypted
|
|
735
|
+
*/
|
|
736
|
+
403: unknown;
|
|
737
|
+
/**
|
|
738
|
+
* Task not found
|
|
739
|
+
*/
|
|
740
|
+
404: unknown;
|
|
741
|
+
};
|
|
742
|
+
type CreateTaskKpiResponses = {
|
|
743
|
+
/**
|
|
744
|
+
* Created
|
|
745
|
+
*/
|
|
746
|
+
201: KpiEntry;
|
|
747
|
+
};
|
|
748
|
+
type CreateTaskKpiResponse = CreateTaskKpiResponses[keyof CreateTaskKpiResponses];
|
|
749
|
+
type DeleteTaskKpiData = {
|
|
750
|
+
body?: never;
|
|
751
|
+
path: {
|
|
752
|
+
id: string;
|
|
753
|
+
/**
|
|
754
|
+
* The entry id (`id` from the KPI list).
|
|
755
|
+
*/
|
|
756
|
+
kpiId: string;
|
|
757
|
+
};
|
|
758
|
+
query?: never;
|
|
759
|
+
url: '/tasks/{id}/kpis/{kpiId}';
|
|
760
|
+
};
|
|
761
|
+
type DeleteTaskKpiErrors = {
|
|
762
|
+
/**
|
|
763
|
+
* Task is encrypted
|
|
764
|
+
*/
|
|
765
|
+
403: unknown;
|
|
766
|
+
/**
|
|
767
|
+
* Task or entry not found
|
|
768
|
+
*/
|
|
769
|
+
404: unknown;
|
|
770
|
+
};
|
|
771
|
+
type DeleteTaskKpiResponses = {
|
|
772
|
+
/**
|
|
773
|
+
* Deleted
|
|
774
|
+
*/
|
|
775
|
+
204: void;
|
|
776
|
+
};
|
|
777
|
+
type DeleteTaskKpiResponse = DeleteTaskKpiResponses[keyof DeleteTaskKpiResponses];
|
|
778
|
+
type UpdateTaskKpiData = {
|
|
779
|
+
body: {
|
|
780
|
+
kind?: 'target' | 'actual';
|
|
781
|
+
value?: number;
|
|
782
|
+
/**
|
|
783
|
+
* `null` removes the date (a target only).
|
|
784
|
+
*/
|
|
785
|
+
at?: string | null;
|
|
786
|
+
};
|
|
787
|
+
path: {
|
|
788
|
+
id: string;
|
|
789
|
+
/**
|
|
790
|
+
* The entry id (`id` from the KPI list).
|
|
791
|
+
*/
|
|
792
|
+
kpiId: string;
|
|
793
|
+
};
|
|
794
|
+
query?: never;
|
|
795
|
+
url: '/tasks/{id}/kpis/{kpiId}';
|
|
796
|
+
};
|
|
797
|
+
type UpdateTaskKpiErrors = {
|
|
798
|
+
/**
|
|
799
|
+
* Nothing to update, or an actual left without `at`
|
|
800
|
+
*/
|
|
801
|
+
400: unknown;
|
|
802
|
+
/**
|
|
803
|
+
* Task is encrypted
|
|
804
|
+
*/
|
|
805
|
+
403: unknown;
|
|
806
|
+
/**
|
|
807
|
+
* Task or entry not found
|
|
808
|
+
*/
|
|
809
|
+
404: unknown;
|
|
810
|
+
};
|
|
811
|
+
type UpdateTaskKpiResponses = {
|
|
812
|
+
/**
|
|
813
|
+
* Updated
|
|
814
|
+
*/
|
|
815
|
+
200: KpiEntry;
|
|
816
|
+
};
|
|
817
|
+
type UpdateTaskKpiResponse = UpdateTaskKpiResponses[keyof UpdateTaskKpiResponses];
|
|
653
818
|
|
|
654
819
|
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
|
|
655
820
|
/**
|
|
@@ -702,6 +867,36 @@ declare class PullRequests {
|
|
|
702
867
|
*/
|
|
703
868
|
static unlinkTaskPullRequest<ThrowOnError extends boolean = false>(options: Options<UnlinkTaskPullRequestData, ThrowOnError>): RequestResult<UnlinkTaskPullRequestResponses, UnlinkTaskPullRequestErrors, ThrowOnError, "fields">;
|
|
704
869
|
}
|
|
870
|
+
declare class Kpis {
|
|
871
|
+
/**
|
|
872
|
+
* List tasks with KPIs
|
|
873
|
+
*
|
|
874
|
+
* Short ids of your tasks that have KPI entries. Encrypted tasks are left out. Fetch a task with `GET /tasks/{id}` for its title.
|
|
875
|
+
*/
|
|
876
|
+
static listKpiTasks<ThrowOnError extends boolean = false>(options?: Options<ListKpiTasksData, ThrowOnError>): RequestResult<ListKpiTasksResponses, unknown, ThrowOnError, "fields">;
|
|
877
|
+
/**
|
|
878
|
+
* List the KPI entries of a task
|
|
879
|
+
*
|
|
880
|
+
* The task's targets and actuals, oldest first (dateless targets first). Encrypted tasks are refused (403). An entry saved end-to-end encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
881
|
+
*/
|
|
882
|
+
static listTaskKpis<ThrowOnError extends boolean = false>(options: Options<ListTaskKpisData, ThrowOnError>): RequestResult<ListTaskKpisResponses, ListTaskKpisErrors, ThrowOnError, "fields">;
|
|
883
|
+
/**
|
|
884
|
+
* Add a KPI entry to a task
|
|
885
|
+
*
|
|
886
|
+
* Add a target (the number to reach, optionally by a date) or an actual (a reading at a moment; `at` required). Encrypted tasks are refused (403). An entry saved end-to-end encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
887
|
+
*/
|
|
888
|
+
static createTaskKpi<ThrowOnError extends boolean = false>(options: Options<CreateTaskKpiData, ThrowOnError>): RequestResult<CreateTaskKpiResponses, CreateTaskKpiErrors, ThrowOnError, "fields">;
|
|
889
|
+
/**
|
|
890
|
+
* Delete a KPI entry
|
|
891
|
+
*/
|
|
892
|
+
static deleteTaskKpi<ThrowOnError extends boolean = false>(options: Options<DeleteTaskKpiData, ThrowOnError>): RequestResult<DeleteTaskKpiResponses, DeleteTaskKpiErrors, ThrowOnError, "fields">;
|
|
893
|
+
/**
|
|
894
|
+
* Update a KPI entry
|
|
895
|
+
*
|
|
896
|
+
* Change any of `kind`, `value` and `at`. Only the fields you send change.
|
|
897
|
+
*/
|
|
898
|
+
static updateTaskKpi<ThrowOnError extends boolean = false>(options: Options<UpdateTaskKpiData, ThrowOnError>): RequestResult<UpdateTaskKpiResponses, UpdateTaskKpiErrors, ThrowOnError, "fields">;
|
|
899
|
+
}
|
|
705
900
|
|
|
706
901
|
declare const zTask: z.ZodMiniObject<{
|
|
707
902
|
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -760,6 +955,16 @@ declare const zPullRequest: z.ZodMiniObject<{
|
|
|
760
955
|
manual: "manual";
|
|
761
956
|
}>;
|
|
762
957
|
}, z.core.$strip>;
|
|
958
|
+
declare const zKpiEntry: z.ZodMiniObject<{
|
|
959
|
+
id: z.ZodMiniUUID;
|
|
960
|
+
kind: z.ZodMiniEnum<{
|
|
961
|
+
target: "target";
|
|
962
|
+
actual: "actual";
|
|
963
|
+
}>;
|
|
964
|
+
at: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
965
|
+
value: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
966
|
+
encrypted: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
|
|
967
|
+
}, z.core.$strip>;
|
|
763
968
|
declare const zListTasksQuery: z.ZodMiniObject<{
|
|
764
969
|
includeEncrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
765
970
|
tree: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
@@ -1009,11 +1214,89 @@ declare const zUnlinkTaskPullRequestPath: z.ZodMiniObject<{
|
|
|
1009
1214
|
* Unlinked
|
|
1010
1215
|
*/
|
|
1011
1216
|
declare const zUnlinkTaskPullRequestResponse: z.ZodMiniVoid;
|
|
1217
|
+
/**
|
|
1218
|
+
* Short ids of the tasks that have KPI entries.
|
|
1219
|
+
*/
|
|
1220
|
+
declare const zListKpiTasksResponse: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
1221
|
+
declare const zListTaskKpisPath: z.ZodMiniObject<{
|
|
1222
|
+
id: z.ZodMiniString<string>;
|
|
1223
|
+
}, z.core.$strip>;
|
|
1224
|
+
/**
|
|
1225
|
+
* KPI entries
|
|
1226
|
+
*/
|
|
1227
|
+
declare const zListTaskKpisResponse: z.ZodMiniArray<z.ZodMiniObject<{
|
|
1228
|
+
id: z.ZodMiniUUID;
|
|
1229
|
+
kind: z.ZodMiniEnum<{
|
|
1230
|
+
target: "target";
|
|
1231
|
+
actual: "actual";
|
|
1232
|
+
}>;
|
|
1233
|
+
at: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1234
|
+
value: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1235
|
+
encrypted: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
|
|
1236
|
+
}, z.core.$strip>>;
|
|
1237
|
+
declare const zCreateTaskKpiBody: z.ZodMiniObject<{
|
|
1238
|
+
kind: z.ZodMiniEnum<{
|
|
1239
|
+
target: "target";
|
|
1240
|
+
actual: "actual";
|
|
1241
|
+
}>;
|
|
1242
|
+
value: z.ZodMiniNumber<number>;
|
|
1243
|
+
at: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
|
|
1244
|
+
}, z.core.$strip>;
|
|
1245
|
+
declare const zCreateTaskKpiPath: z.ZodMiniObject<{
|
|
1246
|
+
id: z.ZodMiniString<string>;
|
|
1247
|
+
}, z.core.$strip>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Created
|
|
1250
|
+
*/
|
|
1251
|
+
declare const zCreateTaskKpiResponse: z.ZodMiniObject<{
|
|
1252
|
+
id: z.ZodMiniUUID;
|
|
1253
|
+
kind: z.ZodMiniEnum<{
|
|
1254
|
+
target: "target";
|
|
1255
|
+
actual: "actual";
|
|
1256
|
+
}>;
|
|
1257
|
+
at: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1258
|
+
value: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1259
|
+
encrypted: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
|
|
1260
|
+
}, z.core.$strip>;
|
|
1261
|
+
declare const zDeleteTaskKpiPath: z.ZodMiniObject<{
|
|
1262
|
+
id: z.ZodMiniString<string>;
|
|
1263
|
+
kpiId: z.ZodMiniUUID;
|
|
1264
|
+
}, z.core.$strip>;
|
|
1265
|
+
/**
|
|
1266
|
+
* Deleted
|
|
1267
|
+
*/
|
|
1268
|
+
declare const zDeleteTaskKpiResponse: z.ZodMiniVoid;
|
|
1269
|
+
declare const zUpdateTaskKpiBody: z.ZodMiniObject<{
|
|
1270
|
+
kind: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
1271
|
+
target: "target";
|
|
1272
|
+
actual: "actual";
|
|
1273
|
+
}>>;
|
|
1274
|
+
value: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1275
|
+
at: z.ZodMiniOptional<z.ZodMiniNullable<z.iso.ZodMiniISODateTime>>;
|
|
1276
|
+
}, z.core.$strip>;
|
|
1277
|
+
declare const zUpdateTaskKpiPath: z.ZodMiniObject<{
|
|
1278
|
+
id: z.ZodMiniString<string>;
|
|
1279
|
+
kpiId: z.ZodMiniUUID;
|
|
1280
|
+
}, z.core.$strip>;
|
|
1281
|
+
/**
|
|
1282
|
+
* Updated
|
|
1283
|
+
*/
|
|
1284
|
+
declare const zUpdateTaskKpiResponse: z.ZodMiniObject<{
|
|
1285
|
+
id: z.ZodMiniUUID;
|
|
1286
|
+
kind: z.ZodMiniEnum<{
|
|
1287
|
+
target: "target";
|
|
1288
|
+
actual: "actual";
|
|
1289
|
+
}>;
|
|
1290
|
+
at: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1291
|
+
value: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1292
|
+
encrypted: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
|
|
1293
|
+
}, z.core.$strip>;
|
|
1012
1294
|
|
|
1013
1295
|
interface PerspecTaskOptions {
|
|
1014
1296
|
/**
|
|
1015
1297
|
* Your PerspecTask API key (begins with `pt_live_`). Create one in the web
|
|
1016
|
-
* app under **Account → API Keys**. Carries `tasks:read` / `tasks:write`
|
|
1298
|
+
* app under **Account → API Keys**. Carries `tasks:read` / `tasks:write`
|
|
1299
|
+
* scopes, and `kpis:read` / `kpis:write` for KPIs.
|
|
1017
1300
|
*
|
|
1018
1301
|
* Or a function returning a token, called before every request: that's how
|
|
1019
1302
|
* a `pt login` OAuth token is refreshed when it expires (see
|
|
@@ -1141,6 +1424,68 @@ declare function createTasksNamespace(client: Client): {
|
|
|
1141
1424
|
response?: Response;
|
|
1142
1425
|
}>;
|
|
1143
1426
|
};
|
|
1427
|
+
/**
|
|
1428
|
+
* A task's KPI: `target` entries (the number to reach, optionally by a
|
|
1429
|
+
* date) and `actual` entries (readings over time). Needs the `kpis:read` /
|
|
1430
|
+
* `kpis:write` scopes.
|
|
1431
|
+
*/
|
|
1432
|
+
kpis: {
|
|
1433
|
+
/** Short ids of the tasks that have KPI entries. Wraps `Kpis.listKpiTasks`. */
|
|
1434
|
+
listTasks: () => Promise<({
|
|
1435
|
+
data: undefined;
|
|
1436
|
+
error: unknown;
|
|
1437
|
+
} | {
|
|
1438
|
+
data: string[];
|
|
1439
|
+
error: undefined;
|
|
1440
|
+
}) & {
|
|
1441
|
+
request?: Request;
|
|
1442
|
+
response?: Response;
|
|
1443
|
+
}>;
|
|
1444
|
+
/** The task's entries, oldest first. Wraps `Kpis.listTaskKpis`. */
|
|
1445
|
+
list: (id: string) => Promise<({
|
|
1446
|
+
data: KpiEntry[];
|
|
1447
|
+
error: undefined;
|
|
1448
|
+
} | {
|
|
1449
|
+
data: undefined;
|
|
1450
|
+
error: unknown;
|
|
1451
|
+
}) & {
|
|
1452
|
+
request?: Request;
|
|
1453
|
+
response?: Response;
|
|
1454
|
+
}>;
|
|
1455
|
+
/** Add a target or an actual (`at` required for an actual). Wraps `Kpis.createTaskKpi`. */
|
|
1456
|
+
create: (id: string, body: CreateTaskKpiData["body"]) => Promise<({
|
|
1457
|
+
data: KpiEntry;
|
|
1458
|
+
error: undefined;
|
|
1459
|
+
} | {
|
|
1460
|
+
data: undefined;
|
|
1461
|
+
error: unknown;
|
|
1462
|
+
}) & {
|
|
1463
|
+
request?: Request;
|
|
1464
|
+
response?: Response;
|
|
1465
|
+
}>;
|
|
1466
|
+
/** Change an entry's kind, value or at (`at: null` drops a target's date). Wraps `Kpis.updateTaskKpi`. */
|
|
1467
|
+
update: (id: string, kpiId: string, body: UpdateTaskKpiData["body"]) => Promise<({
|
|
1468
|
+
data: KpiEntry;
|
|
1469
|
+
error: undefined;
|
|
1470
|
+
} | {
|
|
1471
|
+
data: undefined;
|
|
1472
|
+
error: unknown;
|
|
1473
|
+
}) & {
|
|
1474
|
+
request?: Request;
|
|
1475
|
+
response?: Response;
|
|
1476
|
+
}>;
|
|
1477
|
+
/** Delete an entry by its `id` from `list`. Wraps `Kpis.deleteTaskKpi`. */
|
|
1478
|
+
delete: (id: string, kpiId: string) => Promise<({
|
|
1479
|
+
data: void;
|
|
1480
|
+
error: undefined;
|
|
1481
|
+
} | {
|
|
1482
|
+
data: undefined;
|
|
1483
|
+
error: unknown;
|
|
1484
|
+
}) & {
|
|
1485
|
+
request?: Request;
|
|
1486
|
+
response?: Response;
|
|
1487
|
+
}>;
|
|
1488
|
+
};
|
|
1144
1489
|
};
|
|
1145
1490
|
|
|
1146
|
-
export { type ClientOptions, type CreateTaskData, type CreateTaskResponse, type CreateTaskResponses, type GetTaskData, type GetTaskErrors, type GetTaskResponse, type GetTaskResponses, type LinkTaskPullRequestData, type LinkTaskPullRequestErrors, type LinkTaskPullRequestResponse, type LinkTaskPullRequestResponses, type ListTaskPullRequestsData, type ListTaskPullRequestsErrors, type ListTaskPullRequestsResponse, type ListTaskPullRequestsResponses, type ListTasksData, type ListTasksResponse, type ListTasksResponses, type Options, PerspecTask, type PerspecTaskOptions, type PullRequest, PullRequests, type Task, Tasks, type UnlinkTaskPullRequestData, type UnlinkTaskPullRequestErrors, type UnlinkTaskPullRequestResponse, type UnlinkTaskPullRequestResponses, type UpdateTaskData, type UpdateTaskErrors, type UpdateTaskResponse, type UpdateTaskResponses, PerspecTask as default, zCreateTaskBody, zCreateTaskResponse, zGetTaskPath, zGetTaskQuery, zGetTaskResponse, zLinkTaskPullRequestBody, zLinkTaskPullRequestPath, zLinkTaskPullRequestResponse, zListTaskPullRequestsPath, zListTaskPullRequestsResponse, zListTasksQuery, zListTasksResponse, zPullRequest, zTask, zUnlinkTaskPullRequestPath, zUnlinkTaskPullRequestResponse, zUpdateTaskBody, zUpdateTaskPath, zUpdateTaskResponse };
|
|
1491
|
+
export { type ClientOptions, type CreateTaskData, type CreateTaskKpiData, type CreateTaskKpiErrors, type CreateTaskKpiResponse, type CreateTaskKpiResponses, type CreateTaskResponse, type CreateTaskResponses, type DeleteTaskKpiData, type DeleteTaskKpiErrors, type DeleteTaskKpiResponse, type DeleteTaskKpiResponses, type GetTaskData, type GetTaskErrors, type GetTaskResponse, type GetTaskResponses, type KpiEntry, Kpis, type LinkTaskPullRequestData, type LinkTaskPullRequestErrors, type LinkTaskPullRequestResponse, type LinkTaskPullRequestResponses, type ListKpiTasksData, type ListKpiTasksResponse, type ListKpiTasksResponses, type ListTaskKpisData, type ListTaskKpisErrors, type ListTaskKpisResponse, type ListTaskKpisResponses, type ListTaskPullRequestsData, type ListTaskPullRequestsErrors, type ListTaskPullRequestsResponse, type ListTaskPullRequestsResponses, type ListTasksData, type ListTasksResponse, type ListTasksResponses, type Options, PerspecTask, type PerspecTaskOptions, type PullRequest, PullRequests, type Task, Tasks, type UnlinkTaskPullRequestData, type UnlinkTaskPullRequestErrors, type UnlinkTaskPullRequestResponse, type UnlinkTaskPullRequestResponses, type UpdateTaskData, type UpdateTaskErrors, type UpdateTaskKpiData, type UpdateTaskKpiErrors, type UpdateTaskKpiResponse, type UpdateTaskKpiResponses, type UpdateTaskResponse, type UpdateTaskResponses, PerspecTask as default, zCreateTaskBody, zCreateTaskKpiBody, zCreateTaskKpiPath, zCreateTaskKpiResponse, zCreateTaskResponse, zDeleteTaskKpiPath, zDeleteTaskKpiResponse, zGetTaskPath, zGetTaskQuery, zGetTaskResponse, zKpiEntry, zLinkTaskPullRequestBody, zLinkTaskPullRequestPath, zLinkTaskPullRequestResponse, zListKpiTasksResponse, zListTaskKpisPath, zListTaskKpisResponse, zListTaskPullRequestsPath, zListTaskPullRequestsResponse, zListTasksQuery, zListTasksResponse, zPullRequest, zTask, zUnlinkTaskPullRequestPath, zUnlinkTaskPullRequestResponse, zUpdateTaskBody, zUpdateTaskKpiBody, zUpdateTaskKpiPath, zUpdateTaskKpiResponse, zUpdateTaskPath, zUpdateTaskResponse };
|
package/dist/index.js
CHANGED
|
@@ -889,6 +889,74 @@ var PullRequests = class {
|
|
|
889
889
|
});
|
|
890
890
|
}
|
|
891
891
|
};
|
|
892
|
+
var Kpis = class {
|
|
893
|
+
/**
|
|
894
|
+
* List tasks with KPIs
|
|
895
|
+
*
|
|
896
|
+
* Short ids of your tasks that have KPI entries. Encrypted tasks are left out. Fetch a task with `GET /tasks/{id}` for its title.
|
|
897
|
+
*/
|
|
898
|
+
static listKpiTasks(options) {
|
|
899
|
+
return (options?.client ?? client).get({
|
|
900
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
901
|
+
url: "/kpis",
|
|
902
|
+
...options
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* List the KPI entries of a task
|
|
907
|
+
*
|
|
908
|
+
* The task's targets and actuals, oldest first (dateless targets first). Encrypted tasks are refused (403). An entry saved end-to-end encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
909
|
+
*/
|
|
910
|
+
static listTaskKpis(options) {
|
|
911
|
+
return (options.client ?? client).get({
|
|
912
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
913
|
+
url: "/tasks/{id}/kpis",
|
|
914
|
+
...options
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Add a KPI entry to a task
|
|
919
|
+
*
|
|
920
|
+
* Add a target (the number to reach, optionally by a date) or an actual (a reading at a moment; `at` required). Encrypted tasks are refused (403). An entry saved end-to-end encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
921
|
+
*/
|
|
922
|
+
static createTaskKpi(options) {
|
|
923
|
+
return (options.client ?? client).post({
|
|
924
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
925
|
+
url: "/tasks/{id}/kpis",
|
|
926
|
+
...options,
|
|
927
|
+
headers: {
|
|
928
|
+
"Content-Type": "application/json",
|
|
929
|
+
...options.headers
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Delete a KPI entry
|
|
935
|
+
*/
|
|
936
|
+
static deleteTaskKpi(options) {
|
|
937
|
+
return (options.client ?? client).delete({
|
|
938
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
939
|
+
url: "/tasks/{id}/kpis/{kpiId}",
|
|
940
|
+
...options
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Update a KPI entry
|
|
945
|
+
*
|
|
946
|
+
* Change any of `kind`, `value` and `at`. Only the fields you send change.
|
|
947
|
+
*/
|
|
948
|
+
static updateTaskKpi(options) {
|
|
949
|
+
return (options.client ?? client).patch({
|
|
950
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
951
|
+
url: "/tasks/{id}/kpis/{kpiId}",
|
|
952
|
+
...options,
|
|
953
|
+
headers: {
|
|
954
|
+
"Content-Type": "application/json",
|
|
955
|
+
...options.headers
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
};
|
|
892
960
|
|
|
893
961
|
// src/generated/zod.gen.ts
|
|
894
962
|
import * as z from "zod/mini";
|
|
@@ -981,6 +1049,23 @@ var zPullRequest = z.object({
|
|
|
981
1049
|
description: "`auto` = linked by the pt- code in the PR; `manual` = linked by URL."
|
|
982
1050
|
})
|
|
983
1051
|
});
|
|
1052
|
+
var zKpiEntry = z.object({
|
|
1053
|
+
id: z.uuid().register(z.globalRegistry, {
|
|
1054
|
+
description: "Id of this entry. Pass it to update or delete."
|
|
1055
|
+
}),
|
|
1056
|
+
kind: z.enum(["target", "actual"]).register(z.globalRegistry, {
|
|
1057
|
+
description: "`target` = the number you aim for (by `at`); `actual` = a reading of where it stands at `at`."
|
|
1058
|
+
}),
|
|
1059
|
+
at: z.optional(z.string().register(z.globalRegistry, {
|
|
1060
|
+
description: "ISO 8601 UTC instant. Omitted for a target with no date."
|
|
1061
|
+
})),
|
|
1062
|
+
value: z.optional(z.number().register(z.globalRegistry, {
|
|
1063
|
+
description: "The number. Omitted when the entry was saved end-to-end encrypted (then `encrypted` is true)."
|
|
1064
|
+
})),
|
|
1065
|
+
encrypted: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1066
|
+
description: "Only present when the value is end-to-end encrypted and so not readable over the API."
|
|
1067
|
+
}))
|
|
1068
|
+
});
|
|
984
1069
|
var zListTasksQuery = z.object({
|
|
985
1070
|
includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
|
|
986
1071
|
description: "Defaults to false. In tree mode, encrypted tasks are pruned UNLESS they lie on the path to an unencrypted task \u2014 so an encrypted parent of a readable task is kept (with `encrypted: true` and no title/description keys) to preserve structure, while fully-encrypted branches are hidden. In flat mode, encrypted tasks are simply omitted. Set to true to include ALL end-to-end-encrypted tasks for full visibility."
|
|
@@ -1113,6 +1198,47 @@ var zUnlinkTaskPullRequestPath = z.object({
|
|
|
1113
1198
|
var zUnlinkTaskPullRequestResponse = z.void().register(z.globalRegistry, {
|
|
1114
1199
|
description: "Unlinked"
|
|
1115
1200
|
});
|
|
1201
|
+
var zListKpiTasksResponse = z.array(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))).register(z.globalRegistry, {
|
|
1202
|
+
description: "Short ids of the tasks that have KPI entries."
|
|
1203
|
+
});
|
|
1204
|
+
var zListTaskKpisPath = z.object({
|
|
1205
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
|
|
1206
|
+
});
|
|
1207
|
+
var zListTaskKpisResponse = z.array(zKpiEntry).register(z.globalRegistry, {
|
|
1208
|
+
description: "KPI entries"
|
|
1209
|
+
});
|
|
1210
|
+
var zCreateTaskKpiBody = z.object({
|
|
1211
|
+
kind: z.enum(["target", "actual"]),
|
|
1212
|
+
value: z.number(),
|
|
1213
|
+
at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1214
|
+
description: "When the target is due, or when the actual was measured. Required for an actual; a target may have none."
|
|
1215
|
+
}))
|
|
1216
|
+
});
|
|
1217
|
+
var zCreateTaskKpiPath = z.object({
|
|
1218
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
|
|
1219
|
+
});
|
|
1220
|
+
var zCreateTaskKpiResponse = zKpiEntry;
|
|
1221
|
+
var zDeleteTaskKpiPath = z.object({
|
|
1222
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)),
|
|
1223
|
+
kpiId: z.uuid().register(z.globalRegistry, {
|
|
1224
|
+
description: "The entry id (`id` from the KPI list)."
|
|
1225
|
+
})
|
|
1226
|
+
});
|
|
1227
|
+
var zDeleteTaskKpiResponse = z.void().register(z.globalRegistry, {
|
|
1228
|
+
description: "Deleted"
|
|
1229
|
+
});
|
|
1230
|
+
var zUpdateTaskKpiBody = z.object({
|
|
1231
|
+
kind: z.optional(z.enum(["target", "actual"])),
|
|
1232
|
+
value: z.optional(z.number()),
|
|
1233
|
+
at: z.nullish(z.iso.datetime())
|
|
1234
|
+
});
|
|
1235
|
+
var zUpdateTaskKpiPath = z.object({
|
|
1236
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)),
|
|
1237
|
+
kpiId: z.uuid().register(z.globalRegistry, {
|
|
1238
|
+
description: "The entry id (`id` from the KPI list)."
|
|
1239
|
+
})
|
|
1240
|
+
});
|
|
1241
|
+
var zUpdateTaskKpiResponse = zKpiEntry;
|
|
1116
1242
|
|
|
1117
1243
|
// src/index.ts
|
|
1118
1244
|
var PerspecTask = class {
|
|
@@ -1161,6 +1287,23 @@ function createTasksNamespace(client2) {
|
|
|
1161
1287
|
link: (id, url) => PullRequests.linkTaskPullRequest({ client: client2, path: { id }, body: { url } }),
|
|
1162
1288
|
/** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
|
|
1163
1289
|
unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
|
|
1290
|
+
},
|
|
1291
|
+
/**
|
|
1292
|
+
* A task's KPI: `target` entries (the number to reach, optionally by a
|
|
1293
|
+
* date) and `actual` entries (readings over time). Needs the `kpis:read` /
|
|
1294
|
+
* `kpis:write` scopes.
|
|
1295
|
+
*/
|
|
1296
|
+
kpis: {
|
|
1297
|
+
/** Short ids of the tasks that have KPI entries. Wraps `Kpis.listKpiTasks`. */
|
|
1298
|
+
listTasks: () => Kpis.listKpiTasks({ client: client2 }),
|
|
1299
|
+
/** The task's entries, oldest first. Wraps `Kpis.listTaskKpis`. */
|
|
1300
|
+
list: (id) => Kpis.listTaskKpis({ client: client2, path: { id } }),
|
|
1301
|
+
/** Add a target or an actual (`at` required for an actual). Wraps `Kpis.createTaskKpi`. */
|
|
1302
|
+
create: (id, body) => Kpis.createTaskKpi({ client: client2, path: { id }, body }),
|
|
1303
|
+
/** Change an entry's kind, value or at (`at: null` drops a target's date). Wraps `Kpis.updateTaskKpi`. */
|
|
1304
|
+
update: (id, kpiId, body) => Kpis.updateTaskKpi({ client: client2, path: { id, kpiId }, body }),
|
|
1305
|
+
/** Delete an entry by its `id` from `list`. Wraps `Kpis.deleteTaskKpi`. */
|
|
1306
|
+
delete: (id, kpiId) => Kpis.deleteTaskKpi({ client: client2, path: { id, kpiId } })
|
|
1164
1307
|
}
|
|
1165
1308
|
};
|
|
1166
1309
|
}
|
|
@@ -1168,6 +1311,7 @@ var index_default = PerspecTask;
|
|
|
1168
1311
|
export {
|
|
1169
1312
|
CLI_CLIENT_ID,
|
|
1170
1313
|
DEFAULT_BASE_URL,
|
|
1314
|
+
Kpis,
|
|
1171
1315
|
OAuthTokenError,
|
|
1172
1316
|
PerspecTask,
|
|
1173
1317
|
PullRequests,
|
|
@@ -1178,13 +1322,22 @@ export {
|
|
|
1178
1322
|
startDeviceLogin,
|
|
1179
1323
|
waitForDeviceLogin,
|
|
1180
1324
|
zCreateTaskBody,
|
|
1325
|
+
zCreateTaskKpiBody,
|
|
1326
|
+
zCreateTaskKpiPath,
|
|
1327
|
+
zCreateTaskKpiResponse,
|
|
1181
1328
|
zCreateTaskResponse,
|
|
1329
|
+
zDeleteTaskKpiPath,
|
|
1330
|
+
zDeleteTaskKpiResponse,
|
|
1182
1331
|
zGetTaskPath,
|
|
1183
1332
|
zGetTaskQuery,
|
|
1184
1333
|
zGetTaskResponse,
|
|
1334
|
+
zKpiEntry,
|
|
1185
1335
|
zLinkTaskPullRequestBody,
|
|
1186
1336
|
zLinkTaskPullRequestPath,
|
|
1187
1337
|
zLinkTaskPullRequestResponse,
|
|
1338
|
+
zListKpiTasksResponse,
|
|
1339
|
+
zListTaskKpisPath,
|
|
1340
|
+
zListTaskKpisResponse,
|
|
1188
1341
|
zListTaskPullRequestsPath,
|
|
1189
1342
|
zListTaskPullRequestsResponse,
|
|
1190
1343
|
zListTasksQuery,
|
|
@@ -1194,6 +1347,9 @@ export {
|
|
|
1194
1347
|
zUnlinkTaskPullRequestPath,
|
|
1195
1348
|
zUnlinkTaskPullRequestResponse,
|
|
1196
1349
|
zUpdateTaskBody,
|
|
1350
|
+
zUpdateTaskKpiBody,
|
|
1351
|
+
zUpdateTaskKpiPath,
|
|
1352
|
+
zUpdateTaskKpiResponse,
|
|
1197
1353
|
zUpdateTaskPath,
|
|
1198
1354
|
zUpdateTaskResponse
|
|
1199
1355
|
};
|