@skillcdn/console 0.4.1 → 0.4.3
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 +19 -2
- package/SKILLCDN.md +7 -5
- package/dist/api.d.ts +5 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +5 -4
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +569 -48
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +34 -3
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +283 -7
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +44 -7
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/plugin-check.d.ts +26 -0
- package/dist/cli/plugin-check.d.ts.map +1 -0
- package/dist/cli/plugin-check.js +396 -0
- package/dist/cli/plugin-check.js.map +1 -0
- package/dist/cli/plugin-cli.d.ts +20 -0
- package/dist/cli/plugin-cli.d.ts.map +1 -0
- package/dist/cli/plugin-cli.js +189 -0
- package/dist/cli/plugin-cli.js.map +1 -0
- package/dist/cli/plugin-init.d.ts +37 -0
- package/dist/cli/plugin-init.d.ts.map +1 -0
- package/dist/cli/plugin-init.js +206 -0
- package/dist/cli/plugin-init.js.map +1 -0
- package/dist/cli/plugin-main.d.ts +3 -0
- package/dist/cli/plugin-main.d.ts.map +1 -0
- package/dist/cli/plugin-main.js +28 -0
- package/dist/cli/plugin-main.js.map +1 -0
- package/dist/client.d.ts +100 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +79 -7
- package/dist/client.js.map +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +2 -2
- package/dist/components/board.d.ts +8 -0
- package/dist/components/board.d.ts.map +1 -1
- package/dist/components/board.js +59 -15
- package/dist/components/board.js.map +1 -1
- package/dist/components/comments.d.ts.map +1 -1
- package/dist/components/comments.js +1 -1
- package/dist/components/comments.js.map +1 -1
- package/dist/components/decision-form.d.ts +2 -1
- package/dist/components/decision-form.d.ts.map +1 -1
- package/dist/components/decision-form.js +36 -4
- package/dist/components/decision-form.js.map +1 -1
- package/dist/components/decision-list.d.ts +4 -0
- package/dist/components/decision-list.d.ts.map +1 -1
- package/dist/components/decision-list.js +29 -3
- package/dist/components/decision-list.js.map +1 -1
- package/dist/components/event-feed.d.ts +1 -1
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +33 -1
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/my-decisions.d.ts +2 -0
- package/dist/components/my-decisions.d.ts.map +1 -1
- package/dist/components/my-decisions.js +2 -2
- package/dist/components/my-decisions.js.map +1 -1
- package/dist/components/plugin-frame.d.ts +52 -0
- package/dist/components/plugin-frame.d.ts.map +1 -0
- package/dist/components/plugin-frame.js +314 -0
- package/dist/components/plugin-frame.js.map +1 -0
- package/dist/components/plugin-settings.d.ts +38 -0
- package/dist/components/plugin-settings.d.ts.map +1 -0
- package/dist/components/plugin-settings.js +348 -0
- package/dist/components/plugin-settings.js.map +1 -0
- package/dist/components/shell.d.ts +2 -0
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +26 -1
- package/dist/components/shell.js.map +1 -1
- package/dist/components/task-view.d.ts +2 -1
- package/dist/components/task-view.d.ts.map +1 -1
- package/dist/components/task-view.js.map +1 -1
- package/dist/components/workspace.d.ts +7 -1
- package/dist/components/workspace.d.ts.map +1 -1
- package/dist/components/workspace.js +1 -1
- package/dist/components/workspace.js.map +1 -1
- package/dist/console.css +330 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +152 -41
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +9 -2
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +45 -9
- package/dist/data.js.map +1 -1
- package/dist/i18n/en.d.ts +155 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +166 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +150 -0
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +2 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +2 -0
- package/dist/limits.js.map +1 -1
- package/dist/plugin/args.d.ts +148 -0
- package/dist/plugin/args.d.ts.map +1 -0
- package/dist/plugin/args.js +369 -0
- package/dist/plugin/args.js.map +1 -0
- package/dist/plugin/bridge.d.ts +146 -0
- package/dist/plugin/bridge.d.ts.map +1 -0
- package/dist/plugin/bridge.js +125 -0
- package/dist/plugin/bridge.js.map +1 -0
- package/dist/plugin/capabilities.d.ts +20 -0
- package/dist/plugin/capabilities.d.ts.map +1 -0
- package/dist/plugin/capabilities.js +133 -0
- package/dist/plugin/capabilities.js.map +1 -0
- package/dist/plugin/context.d.ts +380 -0
- package/dist/plugin/context.d.ts.map +1 -0
- package/dist/plugin/context.js +2 -0
- package/dist/plugin/context.js.map +1 -0
- package/dist/plugin/define.d.ts +208 -0
- package/dist/plugin/define.d.ts.map +1 -0
- package/dist/plugin/define.js +482 -0
- package/dist/plugin/define.js.map +1 -0
- package/dist/plugin/definition-error.d.ts +11 -0
- package/dist/plugin/definition-error.d.ts.map +1 -0
- package/dist/plugin/definition-error.js +17 -0
- package/dist/plugin/definition-error.js.map +1 -0
- package/dist/plugin/limits.d.ts +67 -0
- package/dist/plugin/limits.d.ts.map +1 -0
- package/dist/plugin/limits.js +70 -0
- package/dist/plugin/limits.js.map +1 -0
- package/dist/plugin/load-worker.d.ts +7 -0
- package/dist/plugin/load-worker.d.ts.map +1 -0
- package/dist/plugin/load-worker.js +41 -0
- package/dist/plugin/load-worker.js.map +1 -0
- package/dist/plugin/load.d.ts +18 -0
- package/dist/plugin/load.d.ts.map +1 -0
- package/dist/plugin/load.js +62 -0
- package/dist/plugin/load.js.map +1 -0
- package/dist/plugin/manifest.d.ts +237 -0
- package/dist/plugin/manifest.d.ts.map +1 -0
- package/dist/plugin/manifest.js +411 -0
- package/dist/plugin/manifest.js.map +1 -0
- package/dist/plugin/refusals.d.ts +49 -0
- package/dist/plugin/refusals.d.ts.map +1 -0
- package/dist/plugin/refusals.js +79 -0
- package/dist/plugin/refusals.js.map +1 -0
- package/dist/plugin/rest-schemas.d.ts +556 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -0
- package/dist/plugin/rest-schemas.js +262 -0
- package/dist/plugin/rest-schemas.js.map +1 -0
- package/dist/plugin/sandbox.d.ts +23 -0
- package/dist/plugin/sandbox.d.ts.map +1 -0
- package/dist/plugin/sandbox.js +99 -0
- package/dist/plugin/sandbox.js.map +1 -0
- package/dist/plugin/testing.d.ts +45 -0
- package/dist/plugin/testing.d.ts.map +1 -0
- package/dist/plugin/testing.js +420 -0
- package/dist/plugin/testing.js.map +1 -0
- package/dist/plugin/web-react.d.ts +11 -0
- package/dist/plugin/web-react.d.ts.map +1 -0
- package/dist/plugin/web-react.js +34 -0
- package/dist/plugin/web-react.js.map +1 -0
- package/dist/plugin/web.d.ts +95 -0
- package/dist/plugin/web.d.ts.map +1 -0
- package/dist/plugin/web.js +245 -0
- package/dist/plugin/web.js.map +1 -0
- package/dist/plugin-nav.d.ts +29 -0
- package/dist/plugin-nav.d.ts.map +1 -0
- package/dist/plugin-nav.js +92 -0
- package/dist/plugin-nav.js.map +1 -0
- package/dist/plugin-testing.d.ts +2 -0
- package/dist/plugin-testing.d.ts.map +1 -0
- package/dist/plugin-testing.js +4 -0
- package/dist/plugin-testing.js.map +1 -0
- package/dist/plugin-web-react.d.ts +3 -0
- package/dist/plugin-web-react.d.ts.map +1 -0
- package/dist/plugin-web-react.js +3 -0
- package/dist/plugin-web-react.js.map +1 -0
- package/dist/plugin-web.d.ts +4 -0
- package/dist/plugin-web.d.ts.map +1 -0
- package/dist/plugin-web.js +5 -0
- package/dist/plugin-web.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +15 -0
- package/dist/plugin.js.map +1 -0
- package/dist/router.d.ts +28 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +47 -0
- package/dist/router.js.map +1 -1
- package/dist/routes.d.ts +4 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +6 -0
- package/dist/routes.js.map +1 -1
- package/dist/schemas.d.ts +194 -9
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +98 -17
- package/dist/schemas.js.map +1 -1
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +101 -0
- package/dist/tokens.js.map +1 -0
- package/dist/vocabulary.d.ts +11 -1
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +24 -0
- package/dist/vocabulary.js.map +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +2 -0
- package/dist/web.js.map +1 -1
- package/docs/specs/cli.md +12 -5
- package/docs/specs/plugins.md +488 -0
- package/docs/specs/rest.md +11 -9
- package/package.json +26 -8
- package/skills/building-a-console/SKILL.md +25 -26
- package/skills/building-a-console/references/configuring.md +40 -0
- package/skills/building-a-console/references/the-default-console.md +1 -1
- package/skills/building-a-console/references/the-look-from-a-website.md +5 -5
- package/skills/building-a-plugin/SKILL.md +137 -0
- package/skills/deploying-a-console/SKILL.md +24 -26
- package/skills/deploying-a-console/references/access.md +13 -9
- package/skills/deploying-a-console/references/resources.md +25 -10
- package/skills/deploying-a-console/references/running-it-again.md +15 -0
- package/skills/deploying-a-console/references/sizing.md +2 -0
- package/skills/planning-the-board/SKILL.md +96 -0
- package/skills/planning-the-board/references/a-task.md +36 -0
- package/skills/planning-the-board/references/setting-up.md +44 -0
- package/skills/working-the-board/SKILL.md +43 -34
- package/skills/working-the-board/references/the-pack.md +19 -0
- package/src/api.ts +12 -0
- package/src/cli/cli.ts +737 -55
- package/src/cli/format.ts +368 -10
- package/src/cli/help.ts +50 -6
- package/src/cli/plugin-check.ts +497 -0
- package/src/cli/plugin-cli.ts +237 -0
- package/src/cli/plugin-init.ts +257 -0
- package/src/cli/plugin-main.ts +30 -0
- package/src/client.ts +322 -9
- package/src/compat.ts +2 -2
- package/src/components/board.tsx +62 -14
- package/src/components/comments.tsx +1 -0
- package/src/components/decision-form.tsx +92 -11
- package/src/components/decision-list.tsx +71 -2
- package/src/components/event-feed.tsx +42 -1
- package/src/components/my-decisions.tsx +4 -1
- package/src/components/plugin-frame.tsx +437 -0
- package/src/components/plugin-settings.tsx +1111 -0
- package/src/components/shell.tsx +82 -14
- package/src/components/task-view.tsx +2 -1
- package/src/components/workspace.tsx +18 -0
- package/src/console.tsx +304 -31
- package/src/data.ts +59 -11
- package/src/i18n/en.ts +175 -0
- package/src/i18n/ko.ts +155 -0
- package/src/index.ts +12 -0
- package/src/limits.ts +2 -0
- package/src/plugin/args.ts +526 -0
- package/src/plugin/bridge.ts +314 -0
- package/src/plugin/capabilities.ts +150 -0
- package/src/plugin/context.ts +421 -0
- package/src/plugin/define.ts +792 -0
- package/src/plugin/definition-error.ts +19 -0
- package/src/plugin/limits.ts +70 -0
- package/src/plugin/load-worker.ts +50 -0
- package/src/plugin/load.ts +82 -0
- package/src/plugin/manifest.ts +561 -0
- package/src/plugin/refusals.ts +94 -0
- package/src/plugin/rest-schemas.ts +354 -0
- package/src/plugin/sandbox.ts +123 -0
- package/src/plugin/testing.ts +612 -0
- package/src/plugin/web-react.ts +45 -0
- package/src/plugin/web.ts +403 -0
- package/src/plugin-nav.ts +132 -0
- package/src/plugin-testing.ts +10 -0
- package/src/plugin-web-react.ts +4 -0
- package/src/plugin-web.ts +35 -0
- package/src/plugin.ts +126 -0
- package/src/router.ts +73 -0
- package/src/routes.ts +7 -0
- package/src/schemas.ts +115 -18
- package/src/styles/console.css +330 -1
- package/src/tokens.ts +101 -0
- package/src/vocabulary.ts +30 -0
- package/src/web.ts +2 -0
- package/template/plugin/.gitignore +2 -0
- package/template/plugin/README.md +26 -0
- package/template/plugin/SKILLCDN.md +13 -0
- package/template/plugin/build.mjs +40 -0
- package/template/plugin/console-plugin.json +50 -0
- package/template/plugin/package.json +27 -0
- package/template/plugin/skills/__key__/SKILL.md +23 -0
- package/template/plugin/src/check.test.ts +34 -0
- package/template/plugin/src/server/index.test.ts +41 -0
- package/template/plugin/src/server/index.ts +72 -0
- package/template/plugin/src/web/index.css +51 -0
- package/template/plugin/src/web/index.ts +115 -0
- package/template/plugin/tsconfig.json +17 -0
- package/skills/working-the-board/references/setting-up.md +0 -3
- /package/skills/{working-the-board → planning-the-board}/references/project-rules.md +0 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
// What plugin code is handed (docs/specs/plugins.md, "The context"): every call on `ctx` is a
|
|
2
|
+
// message to the console, which decides it by the capabilities consented to and, for a person's
|
|
3
|
+
// call, by the person's roles and the console's own policy. These are the types; the host builds
|
|
4
|
+
// the object in the plugin's thread, and `@skillcdn/console/plugin/testing` builds one in memory.
|
|
5
|
+
import type { TaskFilter } from "../client.js";
|
|
6
|
+
import type {
|
|
7
|
+
RestComment,
|
|
8
|
+
RestDecision,
|
|
9
|
+
RestDocument,
|
|
10
|
+
RestDocumentSummary,
|
|
11
|
+
RestMember,
|
|
12
|
+
RestPerson,
|
|
13
|
+
RestProject,
|
|
14
|
+
RestRun,
|
|
15
|
+
RestTask,
|
|
16
|
+
RestTaskInput,
|
|
17
|
+
RestTaskPatch,
|
|
18
|
+
} from "../schemas.js";
|
|
19
|
+
import type { PluginFileHandle } from "./args.js";
|
|
20
|
+
|
|
21
|
+
/** A schema as the Standard Schema interface spells one: what every build of zod implements, so that a plugin's own copy validates its records. */
|
|
22
|
+
export interface RecordSchema<T = unknown> {
|
|
23
|
+
readonly "~standard": {
|
|
24
|
+
readonly version: 1;
|
|
25
|
+
readonly vendor: string;
|
|
26
|
+
readonly validate: (value: unknown) => RecordSchemaResult<T> | Promise<RecordSchemaResult<T>>;
|
|
27
|
+
readonly types?: { readonly input: unknown; readonly output: T } | undefined;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type RecordSchemaResult<T> =
|
|
32
|
+
| { readonly value: T; readonly issues?: undefined }
|
|
33
|
+
| {
|
|
34
|
+
readonly issues: readonly {
|
|
35
|
+
readonly message: string;
|
|
36
|
+
readonly path?: readonly (PropertyKey | { readonly key: PropertyKey })[] | undefined;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** The data a record of a collection holds, from its schema. */
|
|
41
|
+
export type RecordData<S> = S extends RecordSchema<infer T> ? T : never;
|
|
42
|
+
|
|
43
|
+
/** A collection as `defineCollection` yields it: the name, the schema, and what the console indexes and who reads. */
|
|
44
|
+
export interface CollectionDefinition<S extends RecordSchema = RecordSchema> {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly schema: S;
|
|
47
|
+
readonly indexes: readonly string[];
|
|
48
|
+
readonly search: readonly string[];
|
|
49
|
+
readonly owner: string | null;
|
|
50
|
+
readonly project: "none" | "optional" | "required";
|
|
51
|
+
readonly read: readonly string[];
|
|
52
|
+
readonly readOwn: readonly string[];
|
|
53
|
+
readonly history: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface PluginRecord<T = Record<string, unknown>> {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly collection: string;
|
|
59
|
+
/** The id of the project the record is linked to, or none. */
|
|
60
|
+
readonly project: string | null;
|
|
61
|
+
/** The id of the person the record is about, where the collection has an `owner`. */
|
|
62
|
+
readonly owner: string | null;
|
|
63
|
+
readonly data: T;
|
|
64
|
+
readonly version: number;
|
|
65
|
+
readonly createdAt: string;
|
|
66
|
+
readonly updatedAt: string;
|
|
67
|
+
/** The person who caused the write, or none for the console. */
|
|
68
|
+
readonly createdBy: string | null;
|
|
69
|
+
readonly updatedBy: string | null;
|
|
70
|
+
readonly archivedAt: string | null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface RecordVersion<T = Record<string, unknown>> {
|
|
74
|
+
readonly version: number;
|
|
75
|
+
readonly data: T;
|
|
76
|
+
readonly at: string;
|
|
77
|
+
readonly by: string | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type WhereScalar = string | number | boolean | null;
|
|
81
|
+
|
|
82
|
+
/** One condition on an indexed field: equal, one of, within bounds, or present at all. */
|
|
83
|
+
export type WhereValue =
|
|
84
|
+
| WhereScalar
|
|
85
|
+
| { readonly in: readonly WhereScalar[] }
|
|
86
|
+
| {
|
|
87
|
+
readonly gte?: WhereScalar;
|
|
88
|
+
readonly gt?: WhereScalar;
|
|
89
|
+
readonly lte?: WhereScalar;
|
|
90
|
+
readonly lt?: WhereScalar;
|
|
91
|
+
}
|
|
92
|
+
| { readonly exists: boolean };
|
|
93
|
+
|
|
94
|
+
export type Where = Readonly<Record<string, WhereValue>>;
|
|
95
|
+
|
|
96
|
+
export interface RecordOrder {
|
|
97
|
+
readonly field: string;
|
|
98
|
+
readonly descending?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface RecordQuery {
|
|
102
|
+
readonly where?: Where;
|
|
103
|
+
readonly order?: RecordOrder;
|
|
104
|
+
/** Up to the list bound; the bound when left out. */
|
|
105
|
+
readonly limit?: number;
|
|
106
|
+
/** The cursor the last page answered with. */
|
|
107
|
+
readonly after?: string;
|
|
108
|
+
/** The key of a project the records are linked to. */
|
|
109
|
+
readonly project?: string;
|
|
110
|
+
/** Archived records too; left out, they are not listed. */
|
|
111
|
+
readonly archived?: boolean;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface RecordPage<T> {
|
|
115
|
+
readonly items: readonly PluginRecord<T>[];
|
|
116
|
+
/** The cursor for the next page, or none when this was the last. */
|
|
117
|
+
readonly after: string | null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface RecordAggregation {
|
|
121
|
+
readonly where?: Where;
|
|
122
|
+
/** Up to two indexed fields. */
|
|
123
|
+
readonly groupBy?: readonly string[];
|
|
124
|
+
readonly count?: boolean;
|
|
125
|
+
readonly sum?: readonly string[];
|
|
126
|
+
readonly min?: readonly string[];
|
|
127
|
+
readonly max?: readonly string[];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface RecordAggregate {
|
|
131
|
+
readonly group: Readonly<Record<string, WhereScalar>>;
|
|
132
|
+
readonly count?: number;
|
|
133
|
+
readonly sum?: Readonly<Record<string, number>>;
|
|
134
|
+
readonly min?: Readonly<Record<string, WhereScalar>>;
|
|
135
|
+
readonly max?: Readonly<Record<string, WhereScalar>>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** What a record may be linked to: an item of the board, a project, or a record of any plugin. */
|
|
139
|
+
export type LinkTarget =
|
|
140
|
+
| { readonly kind: "task" | "decision" | "document" | "run" | "project"; readonly id: string }
|
|
141
|
+
| {
|
|
142
|
+
readonly kind: "record";
|
|
143
|
+
readonly plugin?: string;
|
|
144
|
+
readonly collection: string;
|
|
145
|
+
readonly id: string;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export interface RecordFile {
|
|
149
|
+
readonly id: string;
|
|
150
|
+
readonly name: string;
|
|
151
|
+
readonly type: string;
|
|
152
|
+
readonly bytes: number;
|
|
153
|
+
readonly sha256: string;
|
|
154
|
+
readonly createdAt: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface RecordFiles {
|
|
158
|
+
/** A handle a command received or a page uploaded, kept on the record; `files` capability. */
|
|
159
|
+
attach(
|
|
160
|
+
handle: PluginFileHandle | string,
|
|
161
|
+
options?: { readonly name?: string; readonly type?: string },
|
|
162
|
+
): Promise<RecordFile>;
|
|
163
|
+
list(): Promise<readonly RecordFile[]>;
|
|
164
|
+
remove(fileId: string): Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A plugin's records of one collection. */
|
|
168
|
+
export interface PluginRecords<T = Record<string, unknown>> {
|
|
169
|
+
create(
|
|
170
|
+
data: T,
|
|
171
|
+
options?: { readonly project?: string; readonly owner?: string },
|
|
172
|
+
): Promise<PluginRecord<T>>;
|
|
173
|
+
/** The record, or none when there is no such record in this collection. */
|
|
174
|
+
get(id: string): Promise<PluginRecord<T> | null>;
|
|
175
|
+
/** The fields given replace those of the record; `baseVersion` refuses with `plugin.conflict` when the record moved on. */
|
|
176
|
+
update(
|
|
177
|
+
id: string,
|
|
178
|
+
patch: Partial<T>,
|
|
179
|
+
options?: { readonly baseVersion?: number },
|
|
180
|
+
): Promise<PluginRecord<T>>;
|
|
181
|
+
archive(id: string): Promise<void>;
|
|
182
|
+
restore(id: string): Promise<void>;
|
|
183
|
+
list(query?: RecordQuery): Promise<RecordPage<T>>;
|
|
184
|
+
search(
|
|
185
|
+
words: string,
|
|
186
|
+
options?: Pick<RecordQuery, "where" | "limit" | "project">,
|
|
187
|
+
): Promise<RecordPage<T>>;
|
|
188
|
+
aggregate(aggregation: RecordAggregation): Promise<readonly RecordAggregate[]>;
|
|
189
|
+
versions(id: string): Promise<readonly RecordVersion<T>[]>;
|
|
190
|
+
link(id: string, target: LinkTarget): Promise<void>;
|
|
191
|
+
unlink(id: string, target: LinkTarget): Promise<void>;
|
|
192
|
+
links(id: string): Promise<readonly LinkTarget[]>;
|
|
193
|
+
files(id: string): RecordFiles;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface PluginInfo {
|
|
197
|
+
readonly key: string;
|
|
198
|
+
readonly version: string;
|
|
199
|
+
readonly dataVersion: number;
|
|
200
|
+
/** The settings as the administrator set them, by key, without the secrets. */
|
|
201
|
+
readonly settings: Readonly<Record<string, unknown>>;
|
|
202
|
+
/** The board project, or none. */
|
|
203
|
+
readonly board: { readonly id: string; readonly key: string } | null;
|
|
204
|
+
/** The projects the plugin is on: all, or their keys. */
|
|
205
|
+
readonly projects: "all" | readonly string[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface CallerPerson {
|
|
209
|
+
readonly id: string;
|
|
210
|
+
readonly login: string;
|
|
211
|
+
readonly name: string | null;
|
|
212
|
+
readonly language: string;
|
|
213
|
+
readonly admin: boolean;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface CallerProject {
|
|
217
|
+
readonly id: string;
|
|
218
|
+
readonly key: string;
|
|
219
|
+
readonly name: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Who a command, a query or a person's endpoint acts as, and with which roles in this plugin. */
|
|
223
|
+
export interface PersonCaller {
|
|
224
|
+
readonly kind: "person";
|
|
225
|
+
readonly person: CallerPerson;
|
|
226
|
+
/** The agent's name where a token acts, or none for a person on the pages. */
|
|
227
|
+
readonly agent: string | null;
|
|
228
|
+
readonly roles: readonly string[];
|
|
229
|
+
/** The caller's open run in the board project, if any. */
|
|
230
|
+
readonly run: { readonly id: string; readonly taskNumber: number | null } | null;
|
|
231
|
+
/** The project the call is on, if any. */
|
|
232
|
+
readonly project: CallerProject | null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The console itself: a job, a hook, an upgrade or a webhook, with every role. */
|
|
236
|
+
export interface ConsoleCaller {
|
|
237
|
+
readonly kind: "console";
|
|
238
|
+
readonly roles: readonly string[];
|
|
239
|
+
readonly project: CallerProject | null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export type PluginCaller = PersonCaller | ConsoleCaller;
|
|
243
|
+
|
|
244
|
+
export interface PluginWorkspace {
|
|
245
|
+
readonly name: string;
|
|
246
|
+
readonly languages: readonly string[];
|
|
247
|
+
readonly timeZone: string;
|
|
248
|
+
readonly categories: readonly {
|
|
249
|
+
readonly key: string;
|
|
250
|
+
readonly name: string;
|
|
251
|
+
readonly color: string;
|
|
252
|
+
}[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface DecisionAsk {
|
|
256
|
+
readonly question: string;
|
|
257
|
+
readonly body?: string;
|
|
258
|
+
/**
|
|
259
|
+
* The options, each a label and optionally a key (spelled as a plugin's key is, each once),
|
|
260
|
+
* which the answered event carries back as `optionKey`, so that the plugin reads the answer
|
|
261
|
+
* without comparing labels.
|
|
262
|
+
*/
|
|
263
|
+
readonly options: readonly { readonly label: string; readonly key?: string }[];
|
|
264
|
+
/** Who is to answer: a person who may work in the project; the project's owners when left out. */
|
|
265
|
+
readonly deciderId?: string;
|
|
266
|
+
readonly taskId?: string;
|
|
267
|
+
/** The record the decision is for, by which the plugin maps the answer back. */
|
|
268
|
+
readonly about: { readonly collection: string; readonly id: string };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** The console's board, as a plugin reaches it with the `board:*` capabilities, each read the caller's own. */
|
|
272
|
+
export interface PluginConsole {
|
|
273
|
+
workspace(): Promise<PluginWorkspace>;
|
|
274
|
+
people: {
|
|
275
|
+
list(options?: { readonly q?: string }): Promise<readonly RestPerson[]>;
|
|
276
|
+
get(id: string): Promise<RestPerson | null>;
|
|
277
|
+
};
|
|
278
|
+
projects: {
|
|
279
|
+
list(): Promise<readonly RestProject[]>;
|
|
280
|
+
get(key: string): Promise<RestProject | null>;
|
|
281
|
+
members(key: string): Promise<readonly RestMember[]>;
|
|
282
|
+
};
|
|
283
|
+
tasks: {
|
|
284
|
+
list(project: string, filter?: TaskFilter): Promise<readonly RestTask[]>;
|
|
285
|
+
get(project: string, number: number): Promise<RestTask | null>;
|
|
286
|
+
create(project: string, task: RestTaskInput): Promise<RestTask>;
|
|
287
|
+
update(project: string, number: number, patch: RestTaskPatch): Promise<RestTask>;
|
|
288
|
+
comment(project: string, number: number, body: string): Promise<RestComment>;
|
|
289
|
+
};
|
|
290
|
+
decisions: {
|
|
291
|
+
list(project: string): Promise<readonly RestDecision[]>;
|
|
292
|
+
get(id: string): Promise<RestDecision | null>;
|
|
293
|
+
ask(project: string, decision: DecisionAsk): Promise<RestDecision>;
|
|
294
|
+
};
|
|
295
|
+
documents: {
|
|
296
|
+
list(project: string, folder?: string): Promise<readonly RestDocumentSummary[]>;
|
|
297
|
+
read(project: string, path: string): Promise<RestDocument | null>;
|
|
298
|
+
/** Under `plugins/<key>/`; anywhere else is `plugin.forbidden`. */
|
|
299
|
+
write(
|
|
300
|
+
project: string,
|
|
301
|
+
path: string,
|
|
302
|
+
document: { readonly title: string; readonly body: string; readonly baseVersion?: number },
|
|
303
|
+
): Promise<RestDocument>;
|
|
304
|
+
};
|
|
305
|
+
runs: {
|
|
306
|
+
list(project: string): Promise<readonly RestRun[]>;
|
|
307
|
+
get(id: string): Promise<RestRun | null>;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface PluginSqlResult<Row> {
|
|
312
|
+
readonly rows: readonly Row[];
|
|
313
|
+
readonly rowCount: number;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface PluginSqlClient {
|
|
317
|
+
query<Row = Record<string, unknown>>(
|
|
318
|
+
text: string,
|
|
319
|
+
params?: readonly unknown[],
|
|
320
|
+
): Promise<PluginSqlResult<Row>>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** SQL on the plugin's own schema and role, with `storage:sql`. */
|
|
324
|
+
export interface PluginSql extends PluginSqlClient {
|
|
325
|
+
transaction<T>(work: (tx: PluginSqlClient) => Promise<T>): Promise<T>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Where the console puts a secret into an outbound request. */
|
|
329
|
+
export type SecretPlacement = `header:${string}` | `query:${string}` | "basic";
|
|
330
|
+
|
|
331
|
+
export interface PluginFetchInit {
|
|
332
|
+
readonly method?: string;
|
|
333
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
334
|
+
readonly body?: string | Uint8Array;
|
|
335
|
+
/** A secret setting, put where `as` says: a header, a query parameter, or as basic authentication (`user:password`). */
|
|
336
|
+
readonly secret?: { readonly name: string; readonly as: SecretPlacement };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** An outbound answer, whole: the host reads it to the bound before handing it over. */
|
|
340
|
+
export interface PluginFetchResponse {
|
|
341
|
+
readonly status: number;
|
|
342
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
343
|
+
readonly bytes: Uint8Array;
|
|
344
|
+
text(): string;
|
|
345
|
+
json(): unknown;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export interface PluginSecrets {
|
|
349
|
+
has(name: string): Promise<boolean>;
|
|
350
|
+
sign(name: string, payload: string | Uint8Array, algorithm: "hmac-sha256"): Promise<string>;
|
|
351
|
+
verify(
|
|
352
|
+
name: string,
|
|
353
|
+
payload: string | Uint8Array,
|
|
354
|
+
signature: string,
|
|
355
|
+
algorithm: "hmac-sha256",
|
|
356
|
+
): Promise<boolean>;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface OtherPlugin {
|
|
360
|
+
readonly version: string;
|
|
361
|
+
readonly api: Readonly<Record<string, (input: unknown) => Promise<unknown>>>;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface PluginLog {
|
|
365
|
+
info(message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
366
|
+
warn(message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
367
|
+
error(message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** Everything a plugin does to the console: one object, handed to every function the plugin defines. */
|
|
371
|
+
export interface PluginContext {
|
|
372
|
+
readonly plugin: PluginInfo;
|
|
373
|
+
readonly caller: PluginCaller;
|
|
374
|
+
/** The records of a collection, typed by its definition, or by name. */
|
|
375
|
+
records<S extends RecordSchema>(
|
|
376
|
+
collection: CollectionDefinition<S>,
|
|
377
|
+
): PluginRecords<RecordData<S>>;
|
|
378
|
+
records(collection: string): PluginRecords<Record<string, unknown>>;
|
|
379
|
+
readonly sql: PluginSql;
|
|
380
|
+
readonly console: PluginConsole;
|
|
381
|
+
readonly events: { emit(kind: string, data: unknown): Promise<void> };
|
|
382
|
+
fetch(url: string, init?: PluginFetchInit): Promise<PluginFetchResponse>;
|
|
383
|
+
readonly secrets: PluginSecrets;
|
|
384
|
+
readonly plugins: { get(key: string): Promise<OtherPlugin> };
|
|
385
|
+
readonly log: PluginLog;
|
|
386
|
+
now(): Date;
|
|
387
|
+
/** The caller's language, `en` for the console. */
|
|
388
|
+
readonly language: string;
|
|
389
|
+
/** Fires when the call's time is up; the thread is ended soon after. */
|
|
390
|
+
readonly signal: AbortSignal;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** An event a hook receives: the console's, of the plugin's board projects, or another plugin's. */
|
|
394
|
+
export interface PluginHookEvent {
|
|
395
|
+
readonly source: "console" | "plugin";
|
|
396
|
+
/** `console:<kind>` or `plugin:<key>:<kind>`, as the hook was named. */
|
|
397
|
+
readonly kind: string;
|
|
398
|
+
readonly at: string;
|
|
399
|
+
/** The plugin that emitted or caused it, or none. */
|
|
400
|
+
readonly plugin: string | null;
|
|
401
|
+
readonly project: { readonly id: string; readonly key: string } | null;
|
|
402
|
+
readonly data: unknown;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** What an endpoint receives: the request, bounded, with the headers the definition named. */
|
|
406
|
+
export interface EndpointRequest {
|
|
407
|
+
readonly method: string;
|
|
408
|
+
/** What followed the endpoint's name. */
|
|
409
|
+
readonly path: string;
|
|
410
|
+
readonly query: Readonly<Record<string, string>>;
|
|
411
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
412
|
+
readonly body: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface EndpointResponse {
|
|
416
|
+
readonly status: number;
|
|
417
|
+
readonly headers?: Readonly<
|
|
418
|
+
Partial<Record<"content-type" | "location" | "cache-control", string>>
|
|
419
|
+
>;
|
|
420
|
+
readonly body?: string | Readonly<Record<string, unknown>> | readonly unknown[];
|
|
421
|
+
}
|