@assistant-ui/react-generative-ui 0.0.24 → 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 +2 -0
- package/dist/a2ui.d.ts +1 -4
- package/dist/a2ui.d.ts.map +1 -1
- package/dist/a2ui.js +1 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/dist/index.server.d.ts +1 -2
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +1 -10
- package/dist/ir.d.ts +1 -111
- package/dist/ir.d.ts.map +1 -1
- package/dist/ir.js +1 -175
- package/dist/slack.d.ts +1 -4
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +1 -4
- package/dist/teams.d.ts +1 -4
- package/dist/teams.d.ts.map +1 -1
- package/dist/teams.js +1 -4
- package/package.json +4 -5
- package/src/a2ui.ts +1 -22
- package/src/index.server.ts +1 -2
- package/src/index.test.ts +75 -0
- package/src/index.ts +1 -2
- package/src/ir.ts +1 -279
- package/src/slack.ts +1 -39
- package/src/teams.ts +1 -35
- package/dist/JSONGenerativeUI.client.d.ts +0 -28
- package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.client.js +0 -101
- package/dist/JSONGenerativeUI.client.js.map +0 -1
- package/dist/JSONGenerativeUI.server.d.ts +0 -21
- package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.server.js +0 -32
- package/dist/JSONGenerativeUI.server.js.map +0 -1
- package/dist/JSONGenerativeUI.shared.d.ts +0 -63
- package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
- package/dist/JSONGenerativeUI.shared.js +0 -31
- package/dist/JSONGenerativeUI.shared.js.map +0 -1
- package/dist/RadioGroupScope.d.ts +0 -6
- package/dist/RadioGroupScope.d.ts.map +0 -1
- package/dist/RadioGroupScope.js +0 -25
- package/dist/RadioGroupScope.js.map +0 -1
- package/dist/a2ui/BindingContext.d.ts +0 -11
- package/dist/a2ui/BindingContext.d.ts.map +0 -1
- package/dist/a2ui/BindingContext.js +0 -12
- package/dist/a2ui/BindingContext.js.map +0 -1
- package/dist/a2ui/PresentRenderer.d.ts +0 -11
- package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
- package/dist/a2ui/PresentRenderer.js +0 -39
- package/dist/a2ui/PresentRenderer.js.map +0 -1
- package/dist/a2ui/convert.d.ts +0 -15
- package/dist/a2ui/convert.d.ts.map +0 -1
- package/dist/a2ui/convert.js +0 -728
- package/dist/a2ui/convert.js.map +0 -1
- package/dist/a2ui/dataModel.d.ts +0 -9
- package/dist/a2ui/dataModel.d.ts.map +0 -1
- package/dist/a2ui/dataModel.js +0 -44
- package/dist/a2ui/dataModel.js.map +0 -1
- package/dist/a2ui/reducer.d.ts +0 -8
- package/dist/a2ui/reducer.d.ts.map +0 -1
- package/dist/a2ui/reducer.js +0 -242
- package/dist/a2ui/reducer.js.map +0 -1
- package/dist/a2ui/snapshot.d.ts +0 -3
- package/dist/a2ui/snapshot.d.ts.map +0 -1
- package/dist/a2ui/snapshot.js +0 -33
- package/dist/a2ui/snapshot.js.map +0 -1
- package/dist/a2ui/types.d.ts +0 -88
- package/dist/a2ui/types.d.ts.map +0 -1
- package/dist/a2ui/types.js +0 -6
- package/dist/a2ui/types.js.map +0 -1
- package/dist/a2ui/valueFunctions.d.ts +0 -16
- package/dist/a2ui/valueFunctions.d.ts.map +0 -1
- package/dist/a2ui/valueFunctions.js +0 -332
- package/dist/a2ui/valueFunctions.js.map +0 -1
- package/dist/actionRegistry.d.ts +0 -29
- package/dist/actionRegistry.d.ts.map +0 -1
- package/dist/actionRegistry.js +0 -41
- package/dist/actionRegistry.js.map +0 -1
- package/dist/answeredValues.d.ts +0 -16
- package/dist/answeredValues.d.ts.map +0 -1
- package/dist/answeredValues.js +0 -37
- package/dist/answeredValues.js.map +0 -1
- package/dist/buildPresentParameters.d.ts +0 -21
- package/dist/buildPresentParameters.d.ts.map +0 -1
- package/dist/buildPresentParameters.js +0 -95
- package/dist/buildPresentParameters.js.map +0 -1
- package/dist/constants.d.ts +0 -15
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -19
- package/dist/constants.js.map +0 -1
- package/dist/convert/boundSpec.d.ts +0 -48
- package/dist/convert/boundSpec.d.ts.map +0 -1
- package/dist/convert/boundSpec.js +0 -108
- package/dist/convert/boundSpec.js.map +0 -1
- package/dist/convert/copyBounded.d.ts +0 -25
- package/dist/convert/copyBounded.d.ts.map +0 -1
- package/dist/convert/copyBounded.js +0 -38
- package/dist/convert/copyBounded.js.map +0 -1
- package/dist/convert/isElement.d.ts +0 -3
- package/dist/convert/isElement.d.ts.map +0 -1
- package/dist/convert/isElement.js +0 -6
- package/dist/convert/isElement.js.map +0 -1
- package/dist/convert/takeRun.d.ts +0 -6
- package/dist/convert/takeRun.d.ts.map +0 -1
- package/dist/convert/takeRun.js +0 -20
- package/dist/convert/takeRun.js.map +0 -1
- package/dist/defineGenerativeComponents.d.ts +0 -29
- package/dist/defineGenerativeComponents.d.ts.map +0 -1
- package/dist/defineGenerativeComponents.js +0 -34
- package/dist/defineGenerativeComponents.js.map +0 -1
- package/dist/fieldReferences.d.ts +0 -9
- package/dist/fieldReferences.d.ts.map +0 -1
- package/dist/fieldReferences.js +0 -53
- package/dist/fieldReferences.js.map +0 -1
- package/dist/generativeUIToJSX.d.ts +0 -18
- package/dist/generativeUIToJSX.d.ts.map +0 -1
- package/dist/generativeUIToJSX.js +0 -76
- package/dist/generativeUIToJSX.js.map +0 -1
- package/dist/index.shared.d.ts +0 -15
- package/dist/index.shared.d.ts.map +0 -1
- package/dist/index.shared.js +0 -9
- package/dist/ir.js.map +0 -1
- package/dist/renderGenerativeUI.d.ts +0 -14
- package/dist/renderGenerativeUI.d.ts.map +0 -1
- package/dist/renderGenerativeUI.js +0 -83
- package/dist/renderGenerativeUI.js.map +0 -1
- package/dist/scopeSchema.d.ts +0 -6
- package/dist/scopeSchema.d.ts.map +0 -1
- package/dist/scopeSchema.js +0 -56
- package/dist/scopeSchema.js.map +0 -1
- package/dist/slack/constants.d.ts +0 -93
- package/dist/slack/constants.d.ts.map +0 -1
- package/dist/slack/constants.js +0 -146
- package/dist/slack/constants.js.map +0 -1
- package/dist/slack/decodeBlockAction.d.ts +0 -10
- package/dist/slack/decodeBlockAction.d.ts.map +0 -1
- package/dist/slack/decodeBlockAction.js +0 -129
- package/dist/slack/decodeBlockAction.js.map +0 -1
- package/dist/slack/fromSlackBlocks.d.ts +0 -27
- package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
- package/dist/slack/fromSlackBlocks.js +0 -483
- package/dist/slack/fromSlackBlocks.js.map +0 -1
- package/dist/slack/toSlackBlocks.d.ts +0 -4
- package/dist/slack/toSlackBlocks.d.ts.map +0 -1
- package/dist/slack/toSlackBlocks.js +0 -901
- package/dist/slack/toSlackBlocks.js.map +0 -1
- package/dist/slack/types.d.ts +0 -204
- package/dist/slack/types.d.ts.map +0 -1
- package/dist/slack/types.js +0 -0
- package/dist/teams/constants.d.ts +0 -34
- package/dist/teams/constants.d.ts.map +0 -1
- package/dist/teams/constants.js +0 -68
- package/dist/teams/constants.js.map +0 -1
- package/dist/teams/decodeSubmitData.d.ts +0 -26
- package/dist/teams/decodeSubmitData.d.ts.map +0 -1
- package/dist/teams/decodeSubmitData.js +0 -70
- package/dist/teams/decodeSubmitData.js.map +0 -1
- package/dist/teams/temporalId.d.ts +0 -5
- package/dist/teams/temporalId.d.ts.map +0 -1
- package/dist/teams/temporalId.js +0 -28
- package/dist/teams/temporalId.js.map +0 -1
- package/dist/teams/toAdaptiveCard.d.ts +0 -45
- package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
- package/dist/teams/toAdaptiveCard.js +0 -642
- package/dist/teams/toAdaptiveCard.js.map +0 -1
- package/dist/teams/toTeamsAttachments.d.ts +0 -10
- package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
- package/dist/teams/toTeamsAttachments.js +0 -99
- package/dist/teams/toTeamsAttachments.js.map +0 -1
- package/dist/teams/types.d.ts +0 -224
- package/dist/teams/types.d.ts.map +0 -1
- package/dist/teams/types.js +0 -0
- package/dist/temporal.d.ts +0 -33
- package/dist/temporal.d.ts.map +0 -1
- package/dist/temporal.js +0 -153
- package/dist/temporal.js.map +0 -1
- package/dist/types.d.ts +0 -99
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -0
- package/dist/vocabulary/alert.d.ts +0 -32
- package/dist/vocabulary/alert.d.ts.map +0 -1
- package/dist/vocabulary/alert.js +0 -160
- package/dist/vocabulary/alert.js.map +0 -1
- package/dist/vocabulary/collectFormValues.d.ts +0 -23
- package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
- package/dist/vocabulary/collectFormValues.js +0 -44
- package/dist/vocabulary/collectFormValues.js.map +0 -1
- package/dist/vocabulary/data.d.ts +0 -66
- package/dist/vocabulary/data.d.ts.map +0 -1
- package/dist/vocabulary/data.js +0 -503
- package/dist/vocabulary/data.js.map +0 -1
- package/dist/vocabulary/dispatch.d.ts +0 -9
- package/dist/vocabulary/dispatch.d.ts.map +0 -1
- package/dist/vocabulary/dispatch.js +0 -50
- package/dist/vocabulary/dispatch.js.map +0 -1
- package/dist/vocabulary/fact.d.ts +0 -19
- package/dist/vocabulary/fact.d.ts.map +0 -1
- package/dist/vocabulary/fact.js +0 -51
- package/dist/vocabulary/fact.js.map +0 -1
- package/dist/vocabulary/form.d.ts +0 -11
- package/dist/vocabulary/form.d.ts.map +0 -1
- package/dist/vocabulary/form.js +0 -23
- package/dist/vocabulary/form.js.map +0 -1
- package/dist/vocabulary/formatValue.d.ts +0 -7
- package/dist/vocabulary/formatValue.d.ts.map +0 -1
- package/dist/vocabulary/formatValue.js +0 -76
- package/dist/vocabulary/formatValue.js.map +0 -1
- package/dist/vocabulary/icon.d.ts +0 -41
- package/dist/vocabulary/icon.d.ts.map +0 -1
- package/dist/vocabulary/icon.js +0 -272
- package/dist/vocabulary/icon.js.map +0 -1
- package/dist/vocabulary/index.d.ts +0 -12
- package/dist/vocabulary/index.d.ts.map +0 -1
- package/dist/vocabulary/index.js +0 -36
- package/dist/vocabulary/index.js.map +0 -1
- package/dist/vocabulary/interactive.d.ts +0 -230
- package/dist/vocabulary/interactive.d.ts.map +0 -1
- package/dist/vocabulary/interactive.js +0 -584
- package/dist/vocabulary/interactive.js.map +0 -1
- package/dist/vocabulary/layout.d.ts +0 -79
- package/dist/vocabulary/layout.d.ts.map +0 -1
- package/dist/vocabulary/layout.js +0 -139
- package/dist/vocabulary/layout.js.map +0 -1
- package/dist/vocabulary/list.d.ts +0 -14
- package/dist/vocabulary/list.d.ts.map +0 -1
- package/dist/vocabulary/list.js +0 -50
- package/dist/vocabulary/list.js.map +0 -1
- package/dist/vocabulary/media.d.ts +0 -25
- package/dist/vocabulary/media.d.ts.map +0 -1
- package/dist/vocabulary/media.js +0 -42
- package/dist/vocabulary/media.js.map +0 -1
- package/dist/vocabulary/text.d.ts +0 -57
- package/dist/vocabulary/text.d.ts.map +0 -1
- package/dist/vocabulary/text.js +0 -49
- package/dist/vocabulary/text.js.map +0 -1
- package/dist/vocabulary/toTextContent.d.ts +0 -2
- package/dist/vocabulary/toTextContent.d.ts.map +0 -1
- package/dist/vocabulary/toTextContent.js +0 -6
- package/dist/vocabulary/toTextContent.js.map +0 -1
- package/src/JSONGenerativeUI.client.tsx +0 -168
- package/src/JSONGenerativeUI.server.tsx +0 -39
- package/src/JSONGenerativeUI.shared.ts +0 -90
- package/src/JSONGenerativeUI.test.tsx +0 -1298
- package/src/RadioGroupScope.server.test.tsx +0 -24
- package/src/RadioGroupScope.tsx +0 -34
- package/src/a2ui/BindingContext.ts +0 -26
- package/src/a2ui/PresentRenderer.tsx +0 -83
- package/src/a2ui/convert.test.ts +0 -2923
- package/src/a2ui/convert.ts +0 -1207
- package/src/a2ui/dataModel.ts +0 -69
- package/src/a2ui/reducer.test.ts +0 -422
- package/src/a2ui/reducer.ts +0 -363
- package/src/a2ui/snapshot.test.ts +0 -52
- package/src/a2ui/snapshot.ts +0 -52
- package/src/a2ui/types.ts +0 -114
- package/src/a2ui/valueFunctions.test.ts +0 -271
- package/src/a2ui/valueFunctions.ts +0 -523
- package/src/actionRegistry.test.ts +0 -90
- package/src/actionRegistry.ts +0 -88
- package/src/answeredValues.test.ts +0 -33
- package/src/answeredValues.tsx +0 -70
- package/src/buildPresentParameters.test.ts +0 -246
- package/src/buildPresentParameters.ts +0 -130
- package/src/constants.ts +0 -17
- package/src/convert/boundSpec.test.ts +0 -192
- package/src/convert/boundSpec.ts +0 -134
- package/src/convert/copyBounded.test.ts +0 -131
- package/src/convert/copyBounded.ts +0 -38
- package/src/convert/isElement.ts +0 -6
- package/src/convert/takeRun.test.ts +0 -64
- package/src/convert/takeRun.ts +0 -19
- package/src/defineGenerativeComponents.ts +0 -38
- package/src/fieldReferences.test.ts +0 -66
- package/src/fieldReferences.ts +0 -83
- package/src/generativeUIToJSX.test.ts +0 -268
- package/src/generativeUIToJSX.ts +0 -152
- package/src/index.server.test.ts +0 -106
- package/src/index.shared.ts +0 -61
- package/src/ir.test.ts +0 -203
- package/src/renderGenerativeUI.test.tsx +0 -373
- package/src/renderGenerativeUI.tsx +0 -165
- package/src/scopeSchema.test.ts +0 -72
- package/src/scopeSchema.ts +0 -71
- package/src/slack/a2uiSlack.test.ts +0 -198
- package/src/slack/constants.ts +0 -194
- package/src/slack/datePicker.test.ts +0 -612
- package/src/slack/decodeBlockAction.test.ts +0 -233
- package/src/slack/decodeBlockAction.ts +0 -232
- package/src/slack/fromSlackBlocks.test.ts +0 -1465
- package/src/slack/fromSlackBlocks.ts +0 -789
- package/src/slack/toSlackBlocks.test.ts +0 -3065
- package/src/slack/toSlackBlocks.ts +0 -1818
- package/src/slack/types.ts +0 -264
- package/src/teams/constants.ts +0 -93
- package/src/teams/decodeSubmitData.test.ts +0 -397
- package/src/teams/decodeSubmitData.ts +0 -110
- package/src/teams/temporal.test.ts +0 -766
- package/src/teams/temporalId.ts +0 -56
- package/src/teams/toAdaptiveCard.test.ts +0 -1897
- package/src/teams/toAdaptiveCard.ts +0 -1057
- package/src/teams/toTeamsAttachments.test.ts +0 -74
- package/src/teams/toTeamsAttachments.ts +0 -133
- package/src/teams/types.ts +0 -266
- package/src/temporal.test.ts +0 -337
- package/src/temporal.ts +0 -263
- package/src/types.ts +0 -119
- package/src/vocabulary/alert.test.tsx +0 -427
- package/src/vocabulary/alert.tsx +0 -217
- package/src/vocabulary/collectFormValues.test.ts +0 -389
- package/src/vocabulary/collectFormValues.ts +0 -116
- package/src/vocabulary/data.test.tsx +0 -858
- package/src/vocabulary/data.tsx +0 -819
- package/src/vocabulary/datepicker.dom.test.tsx +0 -1457
- package/src/vocabulary/dispatch.ts +0 -83
- package/src/vocabulary/fact.test.tsx +0 -94
- package/src/vocabulary/fact.tsx +0 -54
- package/src/vocabulary/form.test.tsx +0 -113
- package/src/vocabulary/form.tsx +0 -39
- package/src/vocabulary/formatValue.test.ts +0 -72
- package/src/vocabulary/formatValue.ts +0 -127
- package/src/vocabulary/icon.test.tsx +0 -64
- package/src/vocabulary/icon.tsx +0 -174
- package/src/vocabulary/index.test.ts +0 -65
- package/src/vocabulary/index.ts +0 -33
- package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
- package/src/vocabulary/interactive.dom.test.tsx +0 -1747
- package/src/vocabulary/interactive.test.tsx +0 -377
- package/src/vocabulary/interactive.tsx +0 -1109
- package/src/vocabulary/layout.test.tsx +0 -323
- package/src/vocabulary/layout.tsx +0 -247
- package/src/vocabulary/list.test.tsx +0 -222
- package/src/vocabulary/list.tsx +0 -50
- package/src/vocabulary/media.test.tsx +0 -85
- package/src/vocabulary/media.tsx +0 -56
- package/src/vocabulary/text.test.tsx +0 -102
- package/src/vocabulary/text.tsx +0 -60
- package/src/vocabulary/toTextContent.ts +0 -2
package/src/slack/types.ts
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import type { UIElement } from "../ir";
|
|
2
|
-
|
|
3
|
-
export type FieldMapping = {
|
|
4
|
-
readonly actionId: string;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly component: string;
|
|
7
|
-
readonly inputType?: "time" | "datetime";
|
|
8
|
-
readonly offset?: string;
|
|
9
|
-
readonly part?: "date" | "time";
|
|
10
|
-
readonly pairId?: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/** A Slack plain-text composition object. */
|
|
14
|
-
export interface SlackPlainText {
|
|
15
|
-
readonly type: "plain_text";
|
|
16
|
-
readonly text: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** A Slack mrkdwn composition object. */
|
|
20
|
-
export interface SlackMrkdwnText {
|
|
21
|
-
readonly type: "mrkdwn";
|
|
22
|
-
readonly text: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** A text composition object accepted by card and alert text fields. */
|
|
26
|
-
export type SlackTextObject = SlackPlainText | SlackMrkdwnText;
|
|
27
|
-
|
|
28
|
-
/** A selectable Slack option. */
|
|
29
|
-
export interface SlackOption {
|
|
30
|
-
readonly text: SlackPlainText;
|
|
31
|
-
readonly value: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** A Slack button element. */
|
|
35
|
-
export interface SlackButtonElement {
|
|
36
|
-
readonly type: "button";
|
|
37
|
-
readonly text: SlackPlainText;
|
|
38
|
-
readonly action_id: string;
|
|
39
|
-
readonly value?: string;
|
|
40
|
-
readonly style?: "primary" | "danger";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** A Slack static-select element. */
|
|
44
|
-
export interface SlackStaticSelectElement {
|
|
45
|
-
readonly type: "static_select";
|
|
46
|
-
readonly action_id: string;
|
|
47
|
-
readonly options: readonly SlackOption[];
|
|
48
|
-
readonly initial_option?: SlackOption;
|
|
49
|
-
readonly placeholder?: SlackPlainText;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** A Slack date-picker element. */
|
|
53
|
-
export interface SlackDatePickerElement {
|
|
54
|
-
readonly type: "datepicker";
|
|
55
|
-
readonly action_id: string;
|
|
56
|
-
readonly initial_date?: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface SlackTimePickerElement {
|
|
60
|
-
readonly type: "timepicker";
|
|
61
|
-
readonly action_id: string;
|
|
62
|
-
readonly initial_time?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface SlackDateTimePickerElement {
|
|
66
|
-
readonly type: "datetimepicker";
|
|
67
|
-
readonly action_id: string;
|
|
68
|
-
readonly initial_date_time?: number;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** A Slack checkbox-group element. */
|
|
72
|
-
export interface SlackCheckboxesElement {
|
|
73
|
-
readonly type: "checkboxes";
|
|
74
|
-
readonly action_id: string;
|
|
75
|
-
readonly options: readonly SlackOption[];
|
|
76
|
-
readonly initial_options?: readonly SlackOption[];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** A Slack radio-button element. */
|
|
80
|
-
export interface SlackRadioButtonsElement {
|
|
81
|
-
readonly type: "radio_buttons";
|
|
82
|
-
readonly action_id: string;
|
|
83
|
-
readonly options: readonly SlackOption[];
|
|
84
|
-
readonly initial_option?: SlackOption;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** A Slack plain-text input element. */
|
|
88
|
-
export interface SlackPlainTextInputElement {
|
|
89
|
-
readonly type: "plain_text_input";
|
|
90
|
-
readonly action_id: string;
|
|
91
|
-
readonly multiline?: boolean;
|
|
92
|
-
readonly initial_value?: string;
|
|
93
|
-
readonly placeholder?: SlackPlainText;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** An element accepted by a Slack actions block. */
|
|
97
|
-
export type SlackActionElement =
|
|
98
|
-
| SlackButtonElement
|
|
99
|
-
| SlackStaticSelectElement
|
|
100
|
-
| SlackDatePickerElement
|
|
101
|
-
| SlackTimePickerElement
|
|
102
|
-
| SlackDateTimePickerElement
|
|
103
|
-
| SlackCheckboxesElement
|
|
104
|
-
| SlackRadioButtonsElement;
|
|
105
|
-
|
|
106
|
-
/** A Slack header block. */
|
|
107
|
-
export interface SlackHeaderBlock {
|
|
108
|
-
readonly type: "header";
|
|
109
|
-
readonly text: SlackPlainText;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** A Slack section block. */
|
|
113
|
-
export interface SlackSectionBlock {
|
|
114
|
-
readonly type: "section";
|
|
115
|
-
readonly text?: SlackMrkdwnText;
|
|
116
|
-
readonly fields?: readonly SlackMrkdwnText[];
|
|
117
|
-
readonly accessory?: SlackButtonElement;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** A Slack context block. */
|
|
121
|
-
export interface SlackContextBlock {
|
|
122
|
-
readonly type: "context";
|
|
123
|
-
readonly elements: readonly SlackMrkdwnText[];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** A Slack image block. */
|
|
127
|
-
export interface SlackImageBlock {
|
|
128
|
-
readonly type: "image";
|
|
129
|
-
readonly image_url: string;
|
|
130
|
-
readonly alt_text: string;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** A Slack divider block. */
|
|
134
|
-
export interface SlackDividerBlock {
|
|
135
|
-
readonly type: "divider";
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** A Slack actions block. */
|
|
139
|
-
export interface SlackActionsBlock {
|
|
140
|
-
readonly type: "actions";
|
|
141
|
-
readonly block_id?: string;
|
|
142
|
-
readonly elements: readonly SlackActionElement[];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** A Slack input block. */
|
|
146
|
-
export interface SlackInputBlock {
|
|
147
|
-
readonly type: "input";
|
|
148
|
-
readonly block_id?: string;
|
|
149
|
-
readonly label: SlackPlainText;
|
|
150
|
-
readonly element: SlackPlainTextInputElement;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/** A text cell in a Slack data-table block. */
|
|
154
|
-
export interface SlackDataTableRawTextCell {
|
|
155
|
-
readonly type: "raw_text";
|
|
156
|
-
readonly text: string;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** A numeric cell in a Slack data-table block. */
|
|
160
|
-
export interface SlackDataTableRawNumberCell {
|
|
161
|
-
readonly type: "raw_number";
|
|
162
|
-
readonly text: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** A cell value in a Slack data-table block. */
|
|
166
|
-
export type SlackDataTableCell =
|
|
167
|
-
| SlackDataTableRawTextCell
|
|
168
|
-
| SlackDataTableRawNumberCell;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* A Slack card block. A card does not nest arbitrary blocks: content is
|
|
172
|
-
* limited to a hero image, title, subtitle, body, subtext, and up to three
|
|
173
|
-
* action buttons. At least one of `hero_image`, `title`, `actions`, or `body`
|
|
174
|
-
* is required.
|
|
175
|
-
*/
|
|
176
|
-
export interface SlackCardBlock {
|
|
177
|
-
readonly type: "card";
|
|
178
|
-
readonly hero_image?: SlackImageBlock;
|
|
179
|
-
readonly title?: SlackTextObject;
|
|
180
|
-
readonly subtitle?: SlackTextObject;
|
|
181
|
-
readonly body?: SlackTextObject;
|
|
182
|
-
readonly subtext?: SlackTextObject;
|
|
183
|
-
readonly actions?: readonly SlackButtonElement[];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/** A Slack carousel block: a horizontally scrollable group of card blocks. */
|
|
187
|
-
export interface SlackCarouselBlock {
|
|
188
|
-
readonly type: "carousel";
|
|
189
|
-
readonly elements: readonly SlackCardBlock[];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/** A Slack data-table block. The first entry in `rows` is the header row. */
|
|
193
|
-
export interface SlackDataTableBlock {
|
|
194
|
-
readonly type: "data_table";
|
|
195
|
-
readonly caption: string;
|
|
196
|
-
readonly rows: readonly (readonly SlackDataTableCell[])[];
|
|
197
|
-
readonly page_size?: number;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/** A Slack markdown block. */
|
|
201
|
-
export interface SlackMarkdownBlock {
|
|
202
|
-
readonly type: "markdown";
|
|
203
|
-
readonly text: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/** The severity level accepted by a Slack alert block. */
|
|
207
|
-
export type SlackAlertLevel =
|
|
208
|
-
| "default"
|
|
209
|
-
| "info"
|
|
210
|
-
| "warning"
|
|
211
|
-
| "error"
|
|
212
|
-
| "success";
|
|
213
|
-
|
|
214
|
-
/** A Slack alert block. Alert blocks are only supported in modals. */
|
|
215
|
-
export interface SlackAlertBlock {
|
|
216
|
-
readonly type: "alert";
|
|
217
|
-
readonly text: SlackTextObject;
|
|
218
|
-
readonly level?: SlackAlertLevel;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/** A block emitted by the Slack converter. */
|
|
222
|
-
export type SlackBlock =
|
|
223
|
-
| SlackHeaderBlock
|
|
224
|
-
| SlackSectionBlock
|
|
225
|
-
| SlackContextBlock
|
|
226
|
-
| SlackImageBlock
|
|
227
|
-
| SlackDividerBlock
|
|
228
|
-
| SlackActionsBlock
|
|
229
|
-
| SlackInputBlock
|
|
230
|
-
| SlackCardBlock
|
|
231
|
-
| SlackCarouselBlock
|
|
232
|
-
| SlackDataTableBlock
|
|
233
|
-
| SlackMarkdownBlock
|
|
234
|
-
| SlackAlertBlock;
|
|
235
|
-
|
|
236
|
-
/** Options that select the target Slack surface. */
|
|
237
|
-
export interface ToSlackBlocksOptions {
|
|
238
|
-
readonly surface?: "message" | "modal";
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* A non-fatal note reported during Slack conversion.
|
|
243
|
-
*
|
|
244
|
-
* `clamped` removed content to fit a limit, `dropped` discarded a node or one
|
|
245
|
-
* of its props and may leave a placeholder note behind, and `fallback` emitted
|
|
246
|
-
* the node in a different form than requested.
|
|
247
|
-
*/
|
|
248
|
-
export interface SlackConversionWarning {
|
|
249
|
-
readonly code: "clamped" | "dropped" | "fallback";
|
|
250
|
-
readonly component: string;
|
|
251
|
-
readonly detail: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** The blocks and non-fatal warnings produced by Slack conversion. */
|
|
255
|
-
export interface SlackBlocksResult {
|
|
256
|
-
readonly blocks: SlackBlock[];
|
|
257
|
-
readonly warnings: SlackConversionWarning[];
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/** The IR nodes and non-fatal warnings produced by converting Slack Block Kit JSON back into generative UI. */
|
|
261
|
-
export interface FromSlackBlocksResult {
|
|
262
|
-
readonly nodes: UIElement[];
|
|
263
|
-
readonly warnings: SlackConversionWarning[];
|
|
264
|
-
}
|
package/src/teams/constants.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
TeamsAdaptiveCard,
|
|
3
|
-
TeamsCardAttachment,
|
|
4
|
-
TeamsCardElement,
|
|
5
|
-
TeamsSubmitAction,
|
|
6
|
-
TeamsSubmitData,
|
|
7
|
-
} from "./types";
|
|
8
|
-
|
|
9
|
-
/** The Adaptive Card schema version emitted by {@link toAdaptiveCard}: the Teams desktop/web cap (mobile clients cap at 1.2). */
|
|
10
|
-
export const AC_VERSION = "1.5";
|
|
11
|
-
|
|
12
|
-
/** The `$schema` URL stamped on every emitted card. */
|
|
13
|
-
export const ADAPTIVE_CARD_SCHEMA =
|
|
14
|
-
"http://adaptivecards.io/schemas/adaptive-card.json";
|
|
15
|
-
|
|
16
|
-
/** The `contentType` stamped on every emitted attachment. */
|
|
17
|
-
export const ATTACHMENT_CONTENT_TYPE =
|
|
18
|
-
"application/vnd.microsoft.card.adaptive";
|
|
19
|
-
|
|
20
|
-
/** The maximum number of attachments produced from a root-level Carousel. */
|
|
21
|
-
export const CAROUSEL_ATTACHMENT_CAP = 10;
|
|
22
|
-
|
|
23
|
-
/** The maximum number of primary-mode actions in one ActionSet; extras are set to secondary mode instead of being dropped. */
|
|
24
|
-
export const PRIMARY_ACTION_CAP = 6;
|
|
25
|
-
|
|
26
|
-
/** The maximum number of data rows in a Table. */
|
|
27
|
-
export const TABLE_ROW_CAP = 100;
|
|
28
|
-
|
|
29
|
-
/** The maximum number of columns in a Table. */
|
|
30
|
-
export const TABLE_COLUMN_CAP = 20;
|
|
31
|
-
|
|
32
|
-
/** The maximum number of choices in a Select, RadioGroup, or CheckboxGroup. */
|
|
33
|
-
export const CHOICE_OPTION_CAP = 100;
|
|
34
|
-
|
|
35
|
-
/** The soft byte-count budget for a serialized card, past which a warning notes Teams' 100 KB bot message limit (the card is never truncated to fit it). */
|
|
36
|
-
export const PAYLOAD_SOFT_CAP = 80000;
|
|
37
|
-
|
|
38
|
-
const textEncoder = new TextEncoder();
|
|
39
|
-
|
|
40
|
-
/** Measures the wire size of `value` in UTF-8 bytes rather than UTF-16 code units. */
|
|
41
|
-
export function utf8ByteLength(value: string): number {
|
|
42
|
-
return textEncoder.encode(value).byteLength;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Builds the fixed-shape Adaptive Card envelope around a converted body. */
|
|
46
|
-
export function buildCard(body: TeamsCardElement[]): TeamsAdaptiveCard {
|
|
47
|
-
return {
|
|
48
|
-
$schema: ADAPTIVE_CARD_SCHEMA,
|
|
49
|
-
type: "AdaptiveCard",
|
|
50
|
-
version: AC_VERSION,
|
|
51
|
-
body,
|
|
52
|
-
actions: [],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Wraps a card as a bot-framework message attachment. */
|
|
57
|
-
export function buildAttachment(card: TeamsAdaptiveCard): TeamsCardAttachment {
|
|
58
|
-
return { contentType: ATTACHMENT_CONTENT_TYPE, content: card };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
62
|
-
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Nests an IR action under an `aui` key so `decodeSubmitData` can invert it
|
|
66
|
-
* back out of the merged `activity.value` object a Teams bot receives,
|
|
67
|
-
* alongside whatever other named inputs shared the card.
|
|
68
|
-
*/
|
|
69
|
-
export function buildSubmitData(action: unknown): TeamsSubmitData {
|
|
70
|
-
if (!isRecord(action)) return { aui: { type: "action" } };
|
|
71
|
-
const { type: rawType, ...payload } = action;
|
|
72
|
-
const type = typeof rawType === "string" ? rawType : "action";
|
|
73
|
-
return {
|
|
74
|
-
aui: {
|
|
75
|
-
type,
|
|
76
|
-
...(Object.keys(payload).length > 0 ? { payload } : {}),
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Builds an Action.Submit carrying `action` in the `aui` envelope. */
|
|
82
|
-
export function buildSubmitAction(
|
|
83
|
-
title: string,
|
|
84
|
-
action: unknown,
|
|
85
|
-
mode?: "secondary",
|
|
86
|
-
): TeamsSubmitAction {
|
|
87
|
-
return {
|
|
88
|
-
type: "Action.Submit",
|
|
89
|
-
title,
|
|
90
|
-
data: buildSubmitData(action),
|
|
91
|
-
...(mode !== undefined ? { mode } : {}),
|
|
92
|
-
};
|
|
93
|
-
}
|