@rackbops/docket-types 0.0.1 → 0.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 +9 -5
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/reminder.d.ts +14 -0
- package/dist/reminder.d.ts.map +1 -0
- package/dist/reminder.js +47 -0
- package/dist/reminder.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# @rackbops/docket-types
|
|
2
2
|
|
|
3
|
-
The tracker's task types
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
The tracker's task types, built on `@rackbops/docket-core`'s contract. Shipped so far:
|
|
4
|
+
`reminder` (Lepid-Labs/city-hall#7): notify lane, `once` or `calendar`, done and snooze replies.
|
|
5
|
+
The others land with their epics: renewal and price (#11), scout and wantlist (#13), research
|
|
6
|
+
with the runner (E8).
|
|
7
7
|
|
|
8
8
|
```ts
|
|
9
|
-
import {
|
|
9
|
+
import { TASK_TYPES, reminder, TYPE_IDS, isTypeId } from "@rackbops/docket-types"
|
|
10
10
|
```
|
|
11
|
+
|
|
12
|
+
`TASK_TYPES` is every shipped type keyed by id, ready for the dispatcher. Every type is declared
|
|
13
|
+
through `defineTaskType`, which refuses a capability outside the grantable set, and a test here
|
|
14
|
+
asserts that over the whole map.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @rackbops/docket-types -- the tracker's task types, built on @rackbops/docket-core.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The six categories of the plan (section 1.2) as type identifiers, and the types shipped so far:
|
|
5
|
+
* `reminder` with the reminder slice (Lepid-Labs/city-hall#7). The others land with their epics
|
|
6
|
+
* (#11: renewal, price; #13: scout, wantlist; research with E8).
|
|
7
7
|
*/
|
|
8
|
+
import type { TaskType } from "@rackbops/docket-core";
|
|
8
9
|
export type { Lane } from "@rackbops/docket-core";
|
|
10
|
+
export { DEFAULT_SNOOZE_MS, type ReminderConfig, reminder, snoozeUntil } from "./reminder.js";
|
|
9
11
|
/** The six task categories the tracker starts with (plan section 1.2), as type identifiers. */
|
|
10
12
|
export declare const TYPE_IDS: readonly ["reminder", "renewal", "price", "research", "scout", "wantlist"];
|
|
11
13
|
export type TypeId = (typeof TYPE_IDS)[number];
|
|
12
14
|
/** True when `value` names a task type. Narrows a string read from storage or the wire. */
|
|
13
15
|
export declare function isTypeId(value: string): value is TypeId;
|
|
16
|
+
/** Every shipped type, keyed by id, ready for the dispatcher's `types`. */
|
|
17
|
+
export declare const TASK_TYPES: Readonly<Record<string, TaskType<unknown>>>;
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGrD,YAAY,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE7F,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,YAAI,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAU,CAAA;AAElG,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9C,2FAA2F;AAC3F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAEvD;AAED,2EAA2E;AAC3E,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAEjE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @rackbops/docket-types -- the tracker's task types, built on @rackbops/docket-core.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The six categories of the plan (section 1.2) as type identifiers, and the types shipped so far:
|
|
5
|
+
* `reminder` with the reminder slice (Lepid-Labs/city-hall#7). The others land with their epics
|
|
6
|
+
* (#11: renewal, price; #13: scout, wantlist; research with E8).
|
|
7
7
|
*/
|
|
8
|
+
import { reminder } from "./reminder.js";
|
|
9
|
+
export { DEFAULT_SNOOZE_MS, reminder, snoozeUntil } from "./reminder.js";
|
|
8
10
|
/** The six task categories the tracker starts with (plan section 1.2), as type identifiers. */
|
|
9
11
|
export const TYPE_IDS = ["reminder", "renewal", "price", "research", "scout", "wantlist"];
|
|
10
12
|
/** True when `value` names a task type. Narrows a string read from storage or the wire. */
|
|
11
13
|
export function isTypeId(value) {
|
|
12
14
|
return TYPE_IDS.includes(value);
|
|
13
15
|
}
|
|
16
|
+
/** Every shipped type, keyed by id, ready for the dispatcher's `types`. */
|
|
17
|
+
export const TASK_TYPES = Object.freeze({
|
|
18
|
+
reminder: reminder,
|
|
19
|
+
});
|
|
14
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,iBAAiB,EAAuB,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE7F,+FAA+F;AAC/F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAU,CAAA;AAIlG,2FAA2F;AAC3F,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAQ,QAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxD,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAgD,MAAM,CAAC,MAAM,CAAC;IACnF,QAAQ,EAAE,QAA6B;CACxC,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Category 4 (plan section 1.2): "remind me to X at ..." and "every <cadence> remind me ...".
|
|
3
|
+
* Notify lane, tier 0 only, `once` or `calendar`. The person answers done or snooze; a snooze
|
|
4
|
+
* makes the dispatcher queue a new occurrence at the requested instant.
|
|
5
|
+
*/
|
|
6
|
+
export interface ReminderConfig {
|
|
7
|
+
/** What the reminder says. */
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_SNOOZE_MS: number;
|
|
11
|
+
/** The snooze a reply asks for: `{ until }` as an instant, `{ minutes }`, or the default hour. */
|
|
12
|
+
export declare function snoozeUntil(payload: unknown, now: Date): Date;
|
|
13
|
+
export declare const reminder: import("@rackbops/docket-core").TaskType<ReminderConfig>;
|
|
14
|
+
//# sourceMappingURL=reminder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reminder.d.ts","sourceRoot":"","sources":["../src/reminder.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,iBAAiB,QAAc,CAAA;AAE5C,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,CAS7D;AAED,eAAO,MAAM,QAAQ,0DA8BnB,CAAA"}
|
package/dist/reminder.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { defineTaskType, } from "@rackbops/docket-core";
|
|
2
|
+
export const DEFAULT_SNOOZE_MS = 60 * 60_000;
|
|
3
|
+
/** The snooze a reply asks for: `{ until }` as an instant, `{ minutes }`, or the default hour. */
|
|
4
|
+
export function snoozeUntil(payload, now) {
|
|
5
|
+
if (typeof payload === "object" && payload !== null) {
|
|
6
|
+
const p = payload;
|
|
7
|
+
if (typeof p.until === "string" && !Number.isNaN(Date.parse(p.until)))
|
|
8
|
+
return new Date(p.until);
|
|
9
|
+
if (typeof p.minutes === "number" && Number.isFinite(p.minutes) && p.minutes > 0) {
|
|
10
|
+
return new Date(now.getTime() + p.minutes * 60_000);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return new Date(now.getTime() + DEFAULT_SNOOZE_MS);
|
|
14
|
+
}
|
|
15
|
+
export const reminder = defineTaskType({
|
|
16
|
+
id: "reminder",
|
|
17
|
+
lane: "notify",
|
|
18
|
+
capabilities: ["notify"],
|
|
19
|
+
schedule: ["once", "calendar"],
|
|
20
|
+
intake: {
|
|
21
|
+
options: [
|
|
22
|
+
{ name: "text", description: "What to be reminded of", required: true, kind: "string" },
|
|
23
|
+
{
|
|
24
|
+
name: "at",
|
|
25
|
+
description: "When, for a one-off reminder (an instant; the bot parses the person's words)",
|
|
26
|
+
required: false,
|
|
27
|
+
kind: "datetime",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
async run(ctx) {
|
|
32
|
+
return {
|
|
33
|
+
notify: { text: ctx.config.text, actions: ["done", "snooze"] },
|
|
34
|
+
summary: ctx.config.text,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
async onReply(ctx) {
|
|
38
|
+
if (ctx.reply.kind === "snooze") {
|
|
39
|
+
const until = snoozeUntil(ctx.reply.payload, ctx.now);
|
|
40
|
+
return { snoozeUntil: until, summary: `snoozed until ${until.toISOString()}` };
|
|
41
|
+
}
|
|
42
|
+
if (ctx.reply.kind === "done")
|
|
43
|
+
return { summary: "done" };
|
|
44
|
+
return {};
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=reminder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reminder.js","sourceRoot":"","sources":["../src/reminder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAIf,MAAM,uBAAuB,CAAA;AAa9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,MAAM,CAAA;AAE5C,kGAAkG;AAClG,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,GAAS;IACrD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,CAAC,GAAG,OAAiD,CAAA;QAC3D,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QAC/F,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YACjF,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,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E,CAAA;QACzD,OAAO,EAAE,CAAA;IACX,CAAC;CACF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rackbops/docket-types",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "The tracker's task types: reminder, renewal, price, research, scout, wantlist. Built on @rackbops/docket-core.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@rackbops/docket-core": "^0.0
|
|
32
|
+
"@rackbops/docket-core": "^0.1.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc",
|