@ziffr/sdk 0.14.0 → 0.15.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 +1 -1
- package/dist/index.d.ts +54 -9
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ A key sees exactly what the person who made it sees, no more. A Metric it may no
|
|
|
50
50
|
| `projections.list(slug)`, `projections.set(slug, [{ period, value }])` | `GET`, `POST /api/v1/metrics/{slug}/projections` (the current period or later) |
|
|
51
51
|
| `observations.list(slug, { from, to, limit, cursor })`, `observations.all(slug, { from, to })` | `GET /api/v1/metrics/{slug}/observations` |
|
|
52
52
|
| `observations.submit(slug, { value, period, breakdown }, { idempotencyKey })` | `POST /api/v1/metrics/{slug}/observations` |
|
|
53
|
-
| `workspace()` | `GET /api/v1/workspace`: the month the fiscal year starts in, where quarters and years begin |
|
|
53
|
+
| `workspace()` | `GET /api/v1/workspace`: the month the fiscal year starts in, where quarters and years begin, the Number Style, the time zone, the hour Workflows ask at, the week start and how the key's creator can be reached |
|
|
54
54
|
| `schedule({ from, to, person_id })` | `GET /api/v1/schedule`: what the key's creator has to do, overdue first, then by day; an Owner or Admin may name a teammate |
|
|
55
55
|
| `people.list(options)`, `people.all()` | `GET /api/v1/people` |
|
|
56
56
|
| `groups.list(options)`, `groups.all()` | `GET /api/v1/groups` |
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,28 @@ export type Metric = {
|
|
|
30
30
|
starts_on: string;
|
|
31
31
|
}) | null;
|
|
32
32
|
};
|
|
33
|
+
/** A Metric on its own (`metrics.get`, `create` and `update` answer this): its description, its Workflow and when a value is due next. */
|
|
34
|
+
export type MetricDetail = Metric & {
|
|
35
|
+
/** Where the Metric is in Ziffr, to give the person a link; needs a sign-in. */
|
|
36
|
+
url: string;
|
|
37
|
+
/** When its Workflow asks next (day, whole hour, time zone); null without a Workflow, and for a Derived or Archived Metric. */
|
|
38
|
+
next_asked: {
|
|
39
|
+
day: string;
|
|
40
|
+
hour: number;
|
|
41
|
+
time_zone: string;
|
|
42
|
+
} | null;
|
|
43
|
+
/** The Workflow that asks for its values, or null; `yours` says whether the key's creator owns it. */
|
|
44
|
+
workflow: {
|
|
45
|
+
id: number;
|
|
46
|
+
name: string;
|
|
47
|
+
yours: boolean;
|
|
48
|
+
} | null;
|
|
49
|
+
/** The next Due Date (YYYY-MM-DD) and the first day of the period it is for; null without a Workflow, and for a Derived or Archived Metric. */
|
|
50
|
+
next_due: {
|
|
51
|
+
date: string;
|
|
52
|
+
period: string;
|
|
53
|
+
} | null;
|
|
54
|
+
};
|
|
33
55
|
/** A Retention (GLOSSARY: Retention): keep values for `keep_months` months (at least 13), then condense older ones into a longer period or delete them. */
|
|
34
56
|
export type Retention = {
|
|
35
57
|
keep_months: number;
|
|
@@ -139,10 +161,21 @@ export type NewMetric = {
|
|
|
139
161
|
sources?: Source[];
|
|
140
162
|
/** Who submits: ids from `people` and `feeds`, at most 20; each gets a first Prompt. Needs scope metrics:edit too. */
|
|
141
163
|
submitters?: string[];
|
|
164
|
+
/** One of your own Workflows, by id or exact name, so the Metric is asked for on its schedule at once. Needs scope metrics:edit too. */
|
|
165
|
+
workflow?: number | string | null;
|
|
142
166
|
};
|
|
143
|
-
/** What `metrics.update` may change of a Metric (scope metrics:edit): its
|
|
144
|
-
* Each part left out stays; null clears an end of the Target Range
|
|
167
|
+
/** What `metrics.update` may change of a Metric (scope metrics:edit): its description, Sources, Target Range and
|
|
168
|
+
* Workflow. Each part left out stays; null clears an end of the Target Range, the Metric's own Attainment method or its Workflow. */
|
|
145
169
|
export type MetricPatch = {
|
|
170
|
+
name?: string;
|
|
171
|
+
description?: string;
|
|
172
|
+
unit?: string;
|
|
173
|
+
format?: Metric["format"];
|
|
174
|
+
/** Only while the Metric has no values and no targets or projections by period. */
|
|
175
|
+
period?: Metric["period"];
|
|
176
|
+
submission_rule?: "reject" | "overwrite" | "add" | "keep_both";
|
|
177
|
+
/** One of your own Workflows, by id or exact name, or null for none; only the Metric's owner. */
|
|
178
|
+
workflow?: number | string | null;
|
|
146
179
|
/** Its Sources, all of them: the ones left out are turned off. */
|
|
147
180
|
sources?: Source[];
|
|
148
181
|
polarity?: "higher" | "lower" | "target";
|
|
@@ -209,9 +242,17 @@ export type FeedOverview = {
|
|
|
209
242
|
year_start_month: number;
|
|
210
243
|
metrics: Page<FeedMetric>;
|
|
211
244
|
};
|
|
212
|
-
/** What GET /workspace answers: the month the workspace's fiscal year starts in, 1 (January) to 12. */
|
|
245
|
+
/** What GET /workspace answers: the month the workspace's fiscal year starts in, 1 (January) to 12, and how it writes numbers. */
|
|
213
246
|
export type Workspace = {
|
|
214
247
|
year_start_month: number;
|
|
248
|
+
number_style: "1,234.5" | "1.234,5" | "1 234,5" | "1'234.5";
|
|
249
|
+
/** The workspace's time zone (IANA name), which days, hours and Due Dates are in. */
|
|
250
|
+
time_zone: string;
|
|
251
|
+
/** The whole hour Workflows ask at unless they have an Asking Schedule of their own. */
|
|
252
|
+
run_hour: number;
|
|
253
|
+
week_start: "monday" | "sunday";
|
|
254
|
+
/** The ways Ziffr can reach the key's creator to ask for a value now. */
|
|
255
|
+
reached_by: ("email" | "slack" | "telegram")[];
|
|
215
256
|
};
|
|
216
257
|
/** One thing `find` found: a Metric, or its value for one period (`period` is the period's first day, null for the Metric alone). */
|
|
217
258
|
export type Found = {
|
|
@@ -329,7 +370,11 @@ export type WorkflowDetail = {
|
|
|
329
370
|
lock_summary: boolean;
|
|
330
371
|
steps: WorkflowStep[];
|
|
331
372
|
asking: AskingSchedule | null;
|
|
332
|
-
metrics: number;
|
|
373
|
+
metrics: number; /** The Metrics that use it which the key's creator sees (at most 50). */
|
|
374
|
+
used_by: {
|
|
375
|
+
slug: string;
|
|
376
|
+
name: string;
|
|
377
|
+
}[];
|
|
333
378
|
updated_at: string;
|
|
334
379
|
};
|
|
335
380
|
/** What to say to make a Workflow. */
|
|
@@ -739,12 +784,12 @@ export declare class Ziffr {
|
|
|
739
784
|
archived?: boolean;
|
|
740
785
|
}) => AsyncGenerator<Metric, any, any>;
|
|
741
786
|
/** One Metric's description. */
|
|
742
|
-
get: (slug: string) => Promise<
|
|
787
|
+
get: (slug: string) => Promise<MetricDetail>;
|
|
743
788
|
/** Creates a Metric owned by the key's creator (scope metrics:write). A fresh idempotency key is sent unless one is
|
|
744
789
|
* given; pass your own to make retries across runs of your program safe too. */
|
|
745
790
|
create: (metric: NewMetric, options?: {
|
|
746
791
|
idempotencyKey?: string;
|
|
747
|
-
}) => Promise<
|
|
792
|
+
}) => Promise<MetricDetail & {
|
|
748
793
|
replayed: boolean;
|
|
749
794
|
}>;
|
|
750
795
|
/** Deletes a Metric the key's creator owns (scope metrics:write), repeating its exact name to confirm. Refused
|
|
@@ -758,9 +803,9 @@ export declare class Ziffr {
|
|
|
758
803
|
archive: (slug: string) => Promise<Metric>;
|
|
759
804
|
/** Brings an Archived Metric back (scope metrics:write), under the same rule. Answers the Metric as it is now. */
|
|
760
805
|
restore: (slug: string) => Promise<Metric>;
|
|
761
|
-
/** Changes a Metric's
|
|
762
|
-
*
|
|
763
|
-
update: (slug: string, patch: MetricPatch) => Promise<
|
|
806
|
+
/** Changes a Metric's description, Sources, Target Range or Workflow (scope metrics:edit), when the key's creator
|
|
807
|
+
* owns it or is its Editor (its Workflow: its owner). Answers the Metric as it is now. */
|
|
808
|
+
update: (slug: string, patch: MetricPatch) => Promise<MetricDetail>;
|
|
764
809
|
/** Who submits to a Metric (scope metrics:read). */
|
|
765
810
|
submitters: (slug: string) => Promise<Submitter[]>;
|
|
766
811
|
/** Adds and removes up to 20 Submitters each (scope metrics:edit), when the key's creator owns the Metric or is its
|
package/dist/index.js
CHANGED
|
@@ -64,8 +64,8 @@ export class Ziffr {
|
|
|
64
64
|
archive: async (slug) => (await this.request("POST", `/metrics/${encodeURIComponent(slug)}/archive`)).body,
|
|
65
65
|
/** Brings an Archived Metric back (scope metrics:write), under the same rule. Answers the Metric as it is now. */
|
|
66
66
|
restore: async (slug) => (await this.request("POST", `/metrics/${encodeURIComponent(slug)}/restore`)).body,
|
|
67
|
-
/** Changes a Metric's
|
|
68
|
-
*
|
|
67
|
+
/** Changes a Metric's description, Sources, Target Range or Workflow (scope metrics:edit), when the key's creator
|
|
68
|
+
* owns it or is its Editor (its Workflow: its owner). Answers the Metric as it is now. */
|
|
69
69
|
update: async (slug, patch) => (await this.request("PATCH", `/metrics/${encodeURIComponent(slug)}`, undefined, patch)).body,
|
|
70
70
|
/** Who submits to a Metric (scope metrics:read). */
|
|
71
71
|
submitters: async (slug) => (await this.get(`/metrics/${encodeURIComponent(slug)}/submitters`)).items,
|