@distilled.cloud/slack 1.0.0-rc.13 → 1.0.0-rc.15
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/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +3 -3
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js.map +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +12 -18
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.test.d.ts +2 -0
- package/lib/protocol.test.d.ts.map +1 -0
- package/lib/protocol.test.js +288 -0
- package/lib/protocol.test.js.map +1 -0
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/admin.d.ts +236 -29
- package/lib/services/admin.d.ts.map +1 -1
- package/lib/services/admin.js +417 -749
- package/lib/services/admin.js.map +1 -1
- package/lib/services/agents.d.ts +423 -0
- package/lib/services/agents.d.ts.map +1 -0
- package/lib/services/agents.js +315 -0
- package/lib/services/agents.js.map +1 -0
- package/lib/services/api.d.ts +1 -1
- package/lib/services/api.d.ts.map +1 -1
- package/lib/services/api.js +4 -6
- package/lib/services/api.js.map +1 -1
- package/lib/services/apps.d.ts +21 -3
- package/lib/services/apps.d.ts.map +1 -1
- package/lib/services/apps.js +65 -133
- package/lib/services/apps.js.map +1 -1
- package/lib/services/assistant.d.ts +4 -4
- package/lib/services/assistant.d.ts.map +1 -1
- package/lib/services/assistant.js +16 -38
- package/lib/services/assistant.js.map +1 -1
- package/lib/services/auth.d.ts +2 -2
- package/lib/services/auth.d.ts.map +1 -1
- package/lib/services/auth.js +11 -28
- package/lib/services/auth.js.map +1 -1
- package/lib/services/blocks.d.ts +1 -1
- package/lib/services/blocks.d.ts.map +1 -1
- package/lib/services/blocks.js +5 -9
- package/lib/services/blocks.js.map +1 -1
- package/lib/services/bookmarks.d.ts +4 -4
- package/lib/services/bookmarks.d.ts.map +1 -1
- package/lib/services/bookmarks.js +14 -30
- package/lib/services/bookmarks.js.map +1 -1
- package/lib/services/bots.d.ts +1 -1
- package/lib/services/bots.d.ts.map +1 -1
- package/lib/services/bots.js +7 -15
- package/lib/services/bots.js.map +1 -1
- package/lib/services/calls.d.ts +1 -1
- package/lib/services/calls.d.ts.map +1 -1
- package/lib/services/calls.js +13 -33
- package/lib/services/calls.js.map +1 -1
- package/lib/services/canvases.d.ts +22 -2
- package/lib/services/canvases.d.ts.map +1 -1
- package/lib/services/canvases.js +37 -48
- package/lib/services/canvases.js.map +1 -1
- package/lib/services/chat.d.ts +29 -25
- package/lib/services/chat.d.ts.map +1 -1
- package/lib/services/chat.js +47 -95
- package/lib/services/chat.js.map +1 -1
- package/lib/services/conversations.d.ts +10 -8
- package/lib/services/conversations.d.ts.map +1 -1
- package/lib/services/conversations.js +43 -115
- package/lib/services/conversations.js.map +1 -1
- package/lib/services/dialog.d.ts +1 -1
- package/lib/services/dialog.d.ts.map +1 -1
- package/lib/services/dialog.js +5 -9
- package/lib/services/dialog.js.map +1 -1
- package/lib/services/dnd.d.ts +1 -1
- package/lib/services/dnd.d.ts.map +1 -1
- package/lib/services/dnd.js +10 -24
- package/lib/services/dnd.js.map +1 -1
- package/lib/services/emoji.d.ts +1 -1
- package/lib/services/emoji.d.ts.map +1 -1
- package/lib/services/emoji.js +6 -11
- package/lib/services/emoji.js.map +1 -1
- package/lib/services/entity.d.ts +1 -1
- package/lib/services/entity.d.ts.map +1 -1
- package/lib/services/entity.js +8 -20
- package/lib/services/entity.js.map +1 -1
- package/lib/services/files.d.ts +5 -5
- package/lib/services/files.d.ts.map +1 -1
- package/lib/services/files.js +39 -109
- package/lib/services/files.js.map +1 -1
- package/lib/services/functions.d.ts +1 -1
- package/lib/services/functions.d.ts.map +1 -1
- package/lib/services/functions.js +28 -75
- package/lib/services/functions.js.map +1 -1
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +1 -0
- package/lib/services/index.js.map +1 -1
- package/lib/services/lists.d.ts +5 -1
- package/lib/services/lists.d.ts.map +1 -1
- package/lib/services/lists.js +35 -146
- package/lib/services/lists.js.map +1 -1
- package/lib/services/migration.d.ts +1 -1
- package/lib/services/migration.d.ts.map +1 -1
- package/lib/services/migration.js +5 -8
- package/lib/services/migration.js.map +1 -1
- package/lib/services/oauth.d.ts +38 -2
- package/lib/services/oauth.d.ts.map +1 -1
- package/lib/services/oauth.js +67 -50
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/openid.d.ts +1 -1
- package/lib/services/openid.d.ts.map +1 -1
- package/lib/services/openid.js +7 -15
- package/lib/services/openid.js.map +1 -1
- package/lib/services/pins.d.ts +1 -1
- package/lib/services/pins.d.ts.map +1 -1
- package/lib/services/pins.js +7 -15
- package/lib/services/pins.js.map +1 -1
- package/lib/services/reactions.d.ts +2 -2
- package/lib/services/reactions.d.ts.map +1 -1
- package/lib/services/reactions.js +13 -29
- package/lib/services/reactions.js.map +1 -1
- package/lib/services/reminders.d.ts +1 -1
- package/lib/services/reminders.d.ts.map +1 -1
- package/lib/services/reminders.js +13 -33
- package/lib/services/reminders.js.map +1 -1
- package/lib/services/rtm.d.ts +1 -1
- package/lib/services/rtm.d.ts.map +1 -1
- package/lib/services/rtm.js +9 -21
- package/lib/services/rtm.js.map +1 -1
- package/lib/services/search.d.ts +1 -1
- package/lib/services/search.d.ts.map +1 -1
- package/lib/services/search.js +13 -30
- package/lib/services/search.js.map +1 -1
- package/lib/services/stars.d.ts +1 -1
- package/lib/services/stars.d.ts.map +1 -1
- package/lib/services/stars.js +10 -20
- package/lib/services/stars.js.map +1 -1
- package/lib/services/team.d.ts +1 -1
- package/lib/services/team.d.ts.map +1 -1
- package/lib/services/team.js +25 -62
- package/lib/services/team.js.map +1 -1
- package/lib/services/tooling.d.ts +1 -1
- package/lib/services/tooling.d.ts.map +1 -1
- package/lib/services/tooling.js +5 -9
- package/lib/services/tooling.js.map +1 -1
- package/lib/services/usergroups.d.ts +8 -3
- package/lib/services/usergroups.d.ts.map +1 -1
- package/lib/services/usergroups.js +23 -51
- package/lib/services/usergroups.js.map +1 -1
- package/lib/services/users.d.ts +2 -2
- package/lib/services/users.d.ts.map +1 -1
- package/lib/services/users.js +28 -81
- package/lib/services/users.js.map +1 -1
- package/lib/services/views.d.ts +1 -1
- package/lib/services/views.d.ts.map +1 -1
- package/lib/services/views.js +11 -27
- package/lib/services/views.js.map +1 -1
- package/lib/services/workflows.d.ts +1 -1
- package/lib/services/workflows.d.ts.map +1 -1
- package/lib/services/workflows.js +27 -71
- package/lib/services/workflows.js.map +1 -1
- package/package.json +15 -11
- package/src/credentials.ts +8 -10
- package/src/errors.ts +17 -31
- package/src/index.ts +3 -7
- package/src/pagination.ts +2 -5
- package/src/protocol.test.ts +372 -0
- package/src/protocol.ts +34 -66
- package/src/retry.ts +4 -9
- package/src/services/admin.ts +1241 -1557
- package/src/services/agents.ts +853 -0
- package/src/services/api.ts +4 -10
- package/src/services/apps.ts +146 -243
- package/src/services/assistant.ts +93 -144
- package/src/services/auth.ts +12 -33
- package/src/services/blocks.ts +9 -24
- package/src/services/bookmarks.ts +14 -34
- package/src/services/bots.ts +7 -19
- package/src/services/calls.ts +15 -43
- package/src/services/canvases.ts +82 -85
- package/src/services/chat.ts +134 -254
- package/src/services/conversations.ts +101 -217
- package/src/services/dialog.ts +5 -13
- package/src/services/dnd.ts +11 -31
- package/src/services/emoji.ts +9 -19
- package/src/services/entity.ts +17 -45
- package/src/services/files.ts +72 -165
- package/src/services/functions.ts +95 -168
- package/src/services/index.ts +1 -0
- package/src/services/lists.ts +65 -208
- package/src/services/migration.ts +8 -17
- package/src/services/oauth.ts +127 -60
- package/src/services/openid.ts +12 -34
- package/src/services/pins.ts +7 -19
- package/src/services/reactions.ts +19 -43
- package/src/services/reminders.ts +13 -37
- package/src/services/rtm.ts +9 -25
- package/src/services/search.ts +51 -92
- package/src/services/stars.ts +20 -31
- package/src/services/team.ts +81 -155
- package/src/services/tooling.ts +5 -13
- package/src/services/usergroups.ts +37 -68
- package/src/services/users.ts +35 -102
- package/src/services/views.ts +11 -31
- package/src/services/workflows.ts +65 -129
- package/lib/response-validation.test.d.ts +0 -4
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -40
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -54
package/src/services/views.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import * as API from "@distilled.cloud/core/api";
|
|
1
2
|
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (docs.slack.dev JSON twins). Do not edit.
|
|
2
3
|
import * as S from "@distilled.cloud/core/schema";
|
|
3
|
-
import * as API from "@distilled.cloud/core/api";
|
|
4
|
-
import * as T from "../traits.ts";
|
|
5
|
-
import {
|
|
6
|
-
SlackProtocol,
|
|
7
|
-
type SlackOpError,
|
|
8
|
-
type SlackOpContext,
|
|
9
|
-
} from "../protocol.ts";
|
|
10
4
|
import { SlackError, SlackRateLimited } from "../errors.ts";
|
|
5
|
+
import { SlackProtocol, type SlackOpError, type SlackOpContext } from "../protocol.ts";
|
|
11
6
|
import * as Retry from "../retry.ts";
|
|
7
|
+
import * as T from "../traits.ts";
|
|
12
8
|
|
|
13
9
|
export type { SlackOpError, SlackOpContext };
|
|
14
10
|
|
|
@@ -28,9 +24,7 @@ export const PublishViewRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
28
24
|
hash: S.optional(S.String),
|
|
29
25
|
interactivity_pointer: S.optional(S.String),
|
|
30
26
|
}).pipe(T.Http({ method: "POST", uri: "/views.publish", code: 200 })),
|
|
31
|
-
).annotate({
|
|
32
|
-
identifier: "PublishViewRequest",
|
|
33
|
-
}) as any as S.Schema<PublishViewRequest>;
|
|
27
|
+
).annotate({ identifier: "PublishViewRequest" }) as any as S.Schema<PublishViewRequest>;
|
|
34
28
|
|
|
35
29
|
export interface PublishViewResponse {
|
|
36
30
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -42,9 +36,7 @@ export const PublishViewResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
42
36
|
ok: S.Boolean,
|
|
43
37
|
view: S.Unknown,
|
|
44
38
|
}),
|
|
45
|
-
).annotate({
|
|
46
|
-
identifier: "PublishViewResponse",
|
|
47
|
-
}) as any as S.Schema<PublishViewResponse>;
|
|
39
|
+
).annotate({ identifier: "PublishViewResponse" }) as any as S.Schema<PublishViewResponse>;
|
|
48
40
|
|
|
49
41
|
export interface UpdateViewRequest {
|
|
50
42
|
/** A unique identifier of the view to be updated. Either `view_id` or `external_id` is required. */
|
|
@@ -63,9 +55,7 @@ export const UpdateViewRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
63
55
|
view: S.Unknown,
|
|
64
56
|
hash: S.optional(S.String),
|
|
65
57
|
}).pipe(T.Http({ method: "POST", uri: "/views.update", code: 200 })),
|
|
66
|
-
).annotate({
|
|
67
|
-
identifier: "UpdateViewRequest",
|
|
68
|
-
}) as any as S.Schema<UpdateViewRequest>;
|
|
58
|
+
).annotate({ identifier: "UpdateViewRequest" }) as any as S.Schema<UpdateViewRequest>;
|
|
69
59
|
|
|
70
60
|
export interface UpdateViewResponse {
|
|
71
61
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -77,9 +67,7 @@ export const UpdateViewResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
77
67
|
ok: S.Boolean,
|
|
78
68
|
view: S.Unknown,
|
|
79
69
|
}),
|
|
80
|
-
).annotate({
|
|
81
|
-
identifier: "UpdateViewResponse",
|
|
82
|
-
}) as any as S.Schema<UpdateViewResponse>;
|
|
70
|
+
).annotate({ identifier: "UpdateViewResponse" }) as any as S.Schema<UpdateViewResponse>;
|
|
83
71
|
|
|
84
72
|
export type ViewsOpenRequestViewMap = { [key: string]: unknown | undefined };
|
|
85
73
|
export const ViewsOpenRequestViewMap = /*@__PURE__*/ S.Record(
|
|
@@ -101,9 +89,7 @@ export const ViewsOpenRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
101
89
|
interactivity_pointer: S.optional(S.NullOr(S.String)),
|
|
102
90
|
view: ViewsOpenRequestViewMap,
|
|
103
91
|
}).pipe(T.Http({ method: "POST", uri: "/views.open", code: 200 })),
|
|
104
|
-
).annotate({
|
|
105
|
-
identifier: "ViewsOpenRequest",
|
|
106
|
-
}) as any as S.Schema<ViewsOpenRequest>;
|
|
92
|
+
).annotate({ identifier: "ViewsOpenRequest" }) as any as S.Schema<ViewsOpenRequest>;
|
|
107
93
|
|
|
108
94
|
export interface ViewsOpenResponse {
|
|
109
95
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -115,9 +101,7 @@ export const ViewsOpenResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
115
101
|
ok: S.Boolean,
|
|
116
102
|
view: S.Unknown,
|
|
117
103
|
}),
|
|
118
|
-
).annotate({
|
|
119
|
-
identifier: "ViewsOpenResponse",
|
|
120
|
-
}) as any as S.Schema<ViewsOpenResponse>;
|
|
104
|
+
).annotate({ identifier: "ViewsOpenResponse" }) as any as S.Schema<ViewsOpenResponse>;
|
|
121
105
|
|
|
122
106
|
export interface ViewsPushRequest {
|
|
123
107
|
/** Exchange a trigger to post to the user. */
|
|
@@ -133,9 +117,7 @@ export const ViewsPushRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
133
117
|
interactivity_pointer: S.optional(S.NullOr(S.String)),
|
|
134
118
|
view: S.Unknown,
|
|
135
119
|
}).pipe(T.Http({ method: "POST", uri: "/views.push", code: 200 })),
|
|
136
|
-
).annotate({
|
|
137
|
-
identifier: "ViewsPushRequest",
|
|
138
|
-
}) as any as S.Schema<ViewsPushRequest>;
|
|
120
|
+
).annotate({ identifier: "ViewsPushRequest" }) as any as S.Schema<ViewsPushRequest>;
|
|
139
121
|
|
|
140
122
|
export interface ViewsPushResponse {
|
|
141
123
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -147,9 +129,7 @@ export const ViewsPushResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
147
129
|
ok: S.Boolean,
|
|
148
130
|
view: S.Unknown,
|
|
149
131
|
}),
|
|
150
|
-
).annotate({
|
|
151
|
-
identifier: "ViewsPushResponse",
|
|
152
|
-
}) as any as S.Schema<ViewsPushResponse>;
|
|
132
|
+
).annotate({ identifier: "ViewsPushResponse" }) as any as S.Schema<ViewsPushResponse>;
|
|
153
133
|
|
|
154
134
|
export type PublishViewError = SlackOpError;
|
|
155
135
|
/** Publish a static view for a User. Rate limit tier: 4 Method-specific errors (the `error` slug on the SlackError): - `duplicate_external_id` — Error returned when the given `external_id` has already be used. - `hash_conflict` — Error returned when the provided `hash` doesn't match the current stored value. - `missing_profile_id` — A profile id was not provided when trying to publish a view of type profile. - `not_allowed_token_type` — The type of token your app used when requesting this method is not allowed. - `not_enabled` — Error returned if a `home` view is published but the Home tab isn't enabled for the app. - `not_implemented` — The profile view experiment is not enabled for this user. - `view_too_large` — Error returned if the provided view is greater than 250kb. See https://docs.slack.dev/reference/methods/views.publish */
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import * as API from "@distilled.cloud/core/api";
|
|
1
2
|
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (docs.slack.dev JSON twins). Do not edit.
|
|
2
3
|
import * as S from "@distilled.cloud/core/schema";
|
|
3
|
-
import * as API from "@distilled.cloud/core/api";
|
|
4
|
-
import * as T from "../traits.ts";
|
|
5
|
-
import {
|
|
6
|
-
SlackProtocol,
|
|
7
|
-
type SlackOpError,
|
|
8
|
-
type SlackOpContext,
|
|
9
|
-
} from "../protocol.ts";
|
|
10
4
|
import { SlackError, SlackRateLimited } from "../errors.ts";
|
|
5
|
+
import { SlackProtocol, type SlackOpError, type SlackOpContext } from "../protocol.ts";
|
|
11
6
|
import * as Retry from "../retry.ts";
|
|
7
|
+
import * as T from "../traits.ts";
|
|
12
8
|
|
|
13
9
|
export type { SlackOpError, SlackOpContext };
|
|
14
10
|
|
|
@@ -28,12 +24,8 @@ export const AddFeaturedRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
28
24
|
S.Struct({
|
|
29
25
|
channel_id: S.String,
|
|
30
26
|
trigger_ids: AddFeaturedRequestTriggerIdsList,
|
|
31
|
-
}).pipe(
|
|
32
|
-
|
|
33
|
-
),
|
|
34
|
-
).annotate({
|
|
35
|
-
identifier: "AddFeaturedRequest",
|
|
36
|
-
}) as any as S.Schema<AddFeaturedRequest>;
|
|
27
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.featured.add", code: 200 })),
|
|
28
|
+
).annotate({ identifier: "AddFeaturedRequest" }) as any as S.Schema<AddFeaturedRequest>;
|
|
37
29
|
|
|
38
30
|
export interface AddFeaturedResponse {
|
|
39
31
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -43,9 +35,7 @@ export const AddFeaturedResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
43
35
|
S.Struct({
|
|
44
36
|
ok: S.Boolean,
|
|
45
37
|
}),
|
|
46
|
-
).annotate({
|
|
47
|
-
identifier: "AddFeaturedResponse",
|
|
48
|
-
}) as any as S.Schema<AddFeaturedResponse>;
|
|
38
|
+
).annotate({ identifier: "AddFeaturedResponse" }) as any as S.Schema<AddFeaturedResponse>;
|
|
49
39
|
|
|
50
40
|
/** List of encoded user IDs */
|
|
51
41
|
export type AddTriggersPermissionsRequestUserIdsList = Array<string>;
|
|
@@ -55,10 +45,9 @@ export const AddTriggersPermissionsRequestUserIdsList = /*@__PURE__*/ S.Array(
|
|
|
55
45
|
|
|
56
46
|
/** List of encoded channel IDs */
|
|
57
47
|
export type AddTriggersPermissionsRequestChannelIdsList = Array<string>;
|
|
58
|
-
export const AddTriggersPermissionsRequestChannelIdsList =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
) as any as S.Schema<AddTriggersPermissionsRequestChannelIdsList>;
|
|
48
|
+
export const AddTriggersPermissionsRequestChannelIdsList = /*@__PURE__*/ S.Array(
|
|
49
|
+
S.String,
|
|
50
|
+
) as any as S.Schema<AddTriggersPermissionsRequestChannelIdsList>;
|
|
62
51
|
|
|
63
52
|
/** List of encoded workspace IDs */
|
|
64
53
|
export type AddTriggersPermissionsRequestTeamIdsList = Array<string>;
|
|
@@ -91,13 +80,7 @@ export const AddTriggersPermissionsRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
91
80
|
channel_ids: S.optional(AddTriggersPermissionsRequestChannelIdsList),
|
|
92
81
|
team_ids: S.optional(AddTriggersPermissionsRequestTeamIdsList),
|
|
93
82
|
org_ids: S.optional(AddTriggersPermissionsRequestOrgIdsList),
|
|
94
|
-
}).pipe(
|
|
95
|
-
T.Http({
|
|
96
|
-
method: "POST",
|
|
97
|
-
uri: "/workflows.triggers.permissions.add",
|
|
98
|
-
code: 200,
|
|
99
|
-
}),
|
|
100
|
-
),
|
|
83
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.triggers.permissions.add", code: 200 })),
|
|
101
84
|
).annotate({
|
|
102
85
|
identifier: "AddTriggersPermissionsRequest",
|
|
103
86
|
}) as any as S.Schema<AddTriggersPermissionsRequest>;
|
|
@@ -127,34 +110,28 @@ export interface ListFeaturedRequest {
|
|
|
127
110
|
export const ListFeaturedRequest = /*@__PURE__*/ S.suspend(() =>
|
|
128
111
|
S.Struct({
|
|
129
112
|
channel_ids: ListFeaturedRequestChannelIdsList,
|
|
130
|
-
}).pipe(
|
|
131
|
-
|
|
132
|
-
),
|
|
133
|
-
).annotate({
|
|
134
|
-
identifier: "ListFeaturedRequest",
|
|
135
|
-
}) as any as S.Schema<ListFeaturedRequest>;
|
|
113
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.featured.list", code: 200 })),
|
|
114
|
+
).annotate({ identifier: "ListFeaturedRequest" }) as any as S.Schema<ListFeaturedRequest>;
|
|
136
115
|
|
|
137
116
|
export interface ListFeaturedResponseFeaturedWorkflowsItemTriggersItem {
|
|
138
117
|
id: string;
|
|
139
118
|
title: string;
|
|
140
119
|
}
|
|
141
|
-
export const ListFeaturedResponseFeaturedWorkflowsItemTriggersItem =
|
|
142
|
-
|
|
143
|
-
S.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}) as any as S.Schema<ListFeaturedResponseFeaturedWorkflowsItemTriggersItem>;
|
|
120
|
+
export const ListFeaturedResponseFeaturedWorkflowsItemTriggersItem = /*@__PURE__*/ S.suspend(() =>
|
|
121
|
+
S.Struct({
|
|
122
|
+
id: S.String,
|
|
123
|
+
title: S.String,
|
|
124
|
+
}),
|
|
125
|
+
).annotate({
|
|
126
|
+
identifier: "ListFeaturedResponseFeaturedWorkflowsItemTriggersItem",
|
|
127
|
+
}) as any as S.Schema<ListFeaturedResponseFeaturedWorkflowsItemTriggersItem>;
|
|
150
128
|
|
|
151
129
|
/** Array of triggers associated with channel */
|
|
152
130
|
export type ListFeaturedResponseFeaturedWorkflowsItemTriggersList =
|
|
153
131
|
Array<ListFeaturedResponseFeaturedWorkflowsItemTriggersItem>;
|
|
154
|
-
export const ListFeaturedResponseFeaturedWorkflowsItemTriggersList =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
) as any as S.Schema<ListFeaturedResponseFeaturedWorkflowsItemTriggersList>;
|
|
132
|
+
export const ListFeaturedResponseFeaturedWorkflowsItemTriggersList = /*@__PURE__*/ S.Array(
|
|
133
|
+
ListFeaturedResponseFeaturedWorkflowsItemTriggersItem,
|
|
134
|
+
) as any as S.Schema<ListFeaturedResponseFeaturedWorkflowsItemTriggersList>;
|
|
158
135
|
|
|
159
136
|
export interface ListFeaturedResponseFeaturedWorkflowsItem {
|
|
160
137
|
/** Channel where workflows are featured */
|
|
@@ -162,15 +139,14 @@ export interface ListFeaturedResponseFeaturedWorkflowsItem {
|
|
|
162
139
|
/** Array of triggers associated with channel */
|
|
163
140
|
triggers: ListFeaturedResponseFeaturedWorkflowsItemTriggersList;
|
|
164
141
|
}
|
|
165
|
-
export const ListFeaturedResponseFeaturedWorkflowsItem =
|
|
166
|
-
|
|
167
|
-
S.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}) as any as S.Schema<ListFeaturedResponseFeaturedWorkflowsItem>;
|
|
142
|
+
export const ListFeaturedResponseFeaturedWorkflowsItem = /*@__PURE__*/ S.suspend(() =>
|
|
143
|
+
S.Struct({
|
|
144
|
+
channel_id: S.String,
|
|
145
|
+
triggers: ListFeaturedResponseFeaturedWorkflowsItemTriggersList,
|
|
146
|
+
}),
|
|
147
|
+
).annotate({
|
|
148
|
+
identifier: "ListFeaturedResponseFeaturedWorkflowsItem",
|
|
149
|
+
}) as any as S.Schema<ListFeaturedResponseFeaturedWorkflowsItem>;
|
|
174
150
|
|
|
175
151
|
export type ListFeaturedResponseFeaturedWorkflowsList =
|
|
176
152
|
Array<ListFeaturedResponseFeaturedWorkflowsItem>;
|
|
@@ -188,9 +164,7 @@ export const ListFeaturedResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
188
164
|
ok: S.Boolean,
|
|
189
165
|
featured_workflows: ListFeaturedResponseFeaturedWorkflowsList,
|
|
190
166
|
}),
|
|
191
|
-
).annotate({
|
|
192
|
-
identifier: "ListFeaturedResponse",
|
|
193
|
-
}) as any as S.Schema<ListFeaturedResponse>;
|
|
167
|
+
).annotate({ identifier: "ListFeaturedResponse" }) as any as S.Schema<ListFeaturedResponse>;
|
|
194
168
|
|
|
195
169
|
export interface ListTriggersPermissionsRequest {
|
|
196
170
|
/** Encoded ID of the trigger */
|
|
@@ -199,13 +173,7 @@ export interface ListTriggersPermissionsRequest {
|
|
|
199
173
|
export const ListTriggersPermissionsRequest = /*@__PURE__*/ S.suspend(() =>
|
|
200
174
|
S.Struct({
|
|
201
175
|
trigger_id: S.String,
|
|
202
|
-
}).pipe(
|
|
203
|
-
T.Http({
|
|
204
|
-
method: "POST",
|
|
205
|
-
uri: "/workflows.triggers.permissions.list",
|
|
206
|
-
code: 200,
|
|
207
|
-
}),
|
|
208
|
-
),
|
|
176
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.triggers.permissions.list", code: 200 })),
|
|
209
177
|
).annotate({
|
|
210
178
|
identifier: "ListTriggersPermissionsRequest",
|
|
211
179
|
}) as any as S.Schema<ListTriggersPermissionsRequest>;
|
|
@@ -238,12 +206,8 @@ export const RemoveFeaturedRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
238
206
|
S.Struct({
|
|
239
207
|
channel_id: S.String,
|
|
240
208
|
trigger_ids: RemoveFeaturedRequestTriggerIdsList,
|
|
241
|
-
}).pipe(
|
|
242
|
-
|
|
243
|
-
),
|
|
244
|
-
).annotate({
|
|
245
|
-
identifier: "RemoveFeaturedRequest",
|
|
246
|
-
}) as any as S.Schema<RemoveFeaturedRequest>;
|
|
209
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.featured.remove", code: 200 })),
|
|
210
|
+
).annotate({ identifier: "RemoveFeaturedRequest" }) as any as S.Schema<RemoveFeaturedRequest>;
|
|
247
211
|
|
|
248
212
|
export interface RemoveFeaturedResponse {
|
|
249
213
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -253,30 +217,25 @@ export const RemoveFeaturedResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
253
217
|
S.Struct({
|
|
254
218
|
ok: S.Boolean,
|
|
255
219
|
}),
|
|
256
|
-
).annotate({
|
|
257
|
-
identifier: "RemoveFeaturedResponse",
|
|
258
|
-
}) as any as S.Schema<RemoveFeaturedResponse>;
|
|
220
|
+
).annotate({ identifier: "RemoveFeaturedResponse" }) as any as S.Schema<RemoveFeaturedResponse>;
|
|
259
221
|
|
|
260
222
|
/** List of encoded user IDs */
|
|
261
223
|
export type RemoveTriggersPermissionsRequestUserIdsList = Array<string>;
|
|
262
|
-
export const RemoveTriggersPermissionsRequestUserIdsList =
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
) as any as S.Schema<RemoveTriggersPermissionsRequestUserIdsList>;
|
|
224
|
+
export const RemoveTriggersPermissionsRequestUserIdsList = /*@__PURE__*/ S.Array(
|
|
225
|
+
S.String,
|
|
226
|
+
) as any as S.Schema<RemoveTriggersPermissionsRequestUserIdsList>;
|
|
266
227
|
|
|
267
228
|
/** List of encoded channel IDs */
|
|
268
229
|
export type RemoveTriggersPermissionsRequestChannelIdsList = Array<string>;
|
|
269
|
-
export const RemoveTriggersPermissionsRequestChannelIdsList =
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
) as any as S.Schema<RemoveTriggersPermissionsRequestChannelIdsList>;
|
|
230
|
+
export const RemoveTriggersPermissionsRequestChannelIdsList = /*@__PURE__*/ S.Array(
|
|
231
|
+
S.String,
|
|
232
|
+
) as any as S.Schema<RemoveTriggersPermissionsRequestChannelIdsList>;
|
|
273
233
|
|
|
274
234
|
/** List of encoded workspace IDs */
|
|
275
235
|
export type RemoveTriggersPermissionsRequestTeamIdsList = Array<string>;
|
|
276
|
-
export const RemoveTriggersPermissionsRequestTeamIdsList =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
) as any as S.Schema<RemoveTriggersPermissionsRequestTeamIdsList>;
|
|
236
|
+
export const RemoveTriggersPermissionsRequestTeamIdsList = /*@__PURE__*/ S.Array(
|
|
237
|
+
S.String,
|
|
238
|
+
) as any as S.Schema<RemoveTriggersPermissionsRequestTeamIdsList>;
|
|
280
239
|
|
|
281
240
|
/** List of encoded organization IDs */
|
|
282
241
|
export type RemoveTriggersPermissionsRequestOrgIdsList = Array<string>;
|
|
@@ -303,13 +262,7 @@ export const RemoveTriggersPermissionsRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
303
262
|
channel_ids: S.optional(RemoveTriggersPermissionsRequestChannelIdsList),
|
|
304
263
|
team_ids: S.optional(RemoveTriggersPermissionsRequestTeamIdsList),
|
|
305
264
|
org_ids: S.optional(RemoveTriggersPermissionsRequestOrgIdsList),
|
|
306
|
-
}).pipe(
|
|
307
|
-
T.Http({
|
|
308
|
-
method: "POST",
|
|
309
|
-
uri: "/workflows.triggers.permissions.remove",
|
|
310
|
-
code: 200,
|
|
311
|
-
}),
|
|
312
|
-
),
|
|
265
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.triggers.permissions.remove", code: 200 })),
|
|
313
266
|
).annotate({
|
|
314
267
|
identifier: "RemoveTriggersPermissionsRequest",
|
|
315
268
|
}) as any as S.Schema<RemoveTriggersPermissionsRequest>;
|
|
@@ -322,30 +275,26 @@ export const RemoveTriggersPermissionsResponsePermissionType = S.String;
|
|
|
322
275
|
|
|
323
276
|
/** A list of encoded user IDs. */
|
|
324
277
|
export type RemoveTriggersPermissionsResponseUserIdsList = Array<string>;
|
|
325
|
-
export const RemoveTriggersPermissionsResponseUserIdsList =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
) as any as S.Schema<RemoveTriggersPermissionsResponseUserIdsList>;
|
|
278
|
+
export const RemoveTriggersPermissionsResponseUserIdsList = /*@__PURE__*/ S.Array(
|
|
279
|
+
S.String,
|
|
280
|
+
) as any as S.Schema<RemoveTriggersPermissionsResponseUserIdsList>;
|
|
329
281
|
|
|
330
282
|
/** A list of encoded channel IDs. */
|
|
331
283
|
export type RemoveTriggersPermissionsResponseChannelIdsList = Array<string>;
|
|
332
|
-
export const RemoveTriggersPermissionsResponseChannelIdsList =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
) as any as S.Schema<RemoveTriggersPermissionsResponseChannelIdsList>;
|
|
284
|
+
export const RemoveTriggersPermissionsResponseChannelIdsList = /*@__PURE__*/ S.Array(
|
|
285
|
+
S.String,
|
|
286
|
+
) as any as S.Schema<RemoveTriggersPermissionsResponseChannelIdsList>;
|
|
336
287
|
|
|
337
288
|
/** Encoded workspace IDs. */
|
|
338
289
|
export type RemoveTriggersPermissionsResponseTeamIdsList = Array<string>;
|
|
339
|
-
export const RemoveTriggersPermissionsResponseTeamIdsList =
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
) as any as S.Schema<RemoveTriggersPermissionsResponseTeamIdsList>;
|
|
290
|
+
export const RemoveTriggersPermissionsResponseTeamIdsList = /*@__PURE__*/ S.Array(
|
|
291
|
+
S.String,
|
|
292
|
+
) as any as S.Schema<RemoveTriggersPermissionsResponseTeamIdsList>;
|
|
343
293
|
|
|
344
294
|
export type RemoveTriggersPermissionsResponseOrgIdsList = Array<string>;
|
|
345
|
-
export const RemoveTriggersPermissionsResponseOrgIdsList =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
) as any as S.Schema<RemoveTriggersPermissionsResponseOrgIdsList>;
|
|
295
|
+
export const RemoveTriggersPermissionsResponseOrgIdsList = /*@__PURE__*/ S.Array(
|
|
296
|
+
S.String,
|
|
297
|
+
) as any as S.Schema<RemoveTriggersPermissionsResponseOrgIdsList>;
|
|
349
298
|
|
|
350
299
|
export interface RemoveTriggersPermissionsResponse {
|
|
351
300
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -388,12 +337,8 @@ export const SetFeaturedRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
388
337
|
S.Struct({
|
|
389
338
|
channel_id: S.String,
|
|
390
339
|
trigger_ids: SetFeaturedRequestTriggerIdsList,
|
|
391
|
-
}).pipe(
|
|
392
|
-
|
|
393
|
-
),
|
|
394
|
-
).annotate({
|
|
395
|
-
identifier: "SetFeaturedRequest",
|
|
396
|
-
}) as any as S.Schema<SetFeaturedRequest>;
|
|
340
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.featured.set", code: 200 })),
|
|
341
|
+
).annotate({ identifier: "SetFeaturedRequest" }) as any as S.Schema<SetFeaturedRequest>;
|
|
397
342
|
|
|
398
343
|
export interface SetFeaturedResponse {
|
|
399
344
|
/** Always `true` (a failed call raises a typed error instead). */
|
|
@@ -403,9 +348,7 @@ export const SetFeaturedResponse = /*@__PURE__*/ S.suspend(() =>
|
|
|
403
348
|
S.Struct({
|
|
404
349
|
ok: S.Boolean,
|
|
405
350
|
}),
|
|
406
|
-
).annotate({
|
|
407
|
-
identifier: "SetFeaturedResponse",
|
|
408
|
-
}) as any as S.Schema<SetFeaturedResponse>;
|
|
351
|
+
).annotate({ identifier: "SetFeaturedResponse" }) as any as S.Schema<SetFeaturedResponse>;
|
|
409
352
|
|
|
410
353
|
/** The type of permission that defines who can run a trigger */
|
|
411
354
|
export type SetTriggersPermissionsRequestPermissionType =
|
|
@@ -422,10 +365,9 @@ export const SetTriggersPermissionsRequestUserIdsList = /*@__PURE__*/ S.Array(
|
|
|
422
365
|
|
|
423
366
|
/** List of encoded channel IDs */
|
|
424
367
|
export type SetTriggersPermissionsRequestChannelIdsList = Array<string>;
|
|
425
|
-
export const SetTriggersPermissionsRequestChannelIdsList =
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
) as any as S.Schema<SetTriggersPermissionsRequestChannelIdsList>;
|
|
368
|
+
export const SetTriggersPermissionsRequestChannelIdsList = /*@__PURE__*/ S.Array(
|
|
369
|
+
S.String,
|
|
370
|
+
) as any as S.Schema<SetTriggersPermissionsRequestChannelIdsList>;
|
|
429
371
|
|
|
430
372
|
/** List of encoded workspace IDs */
|
|
431
373
|
export type SetTriggersPermissionsRequestTeamIdsList = Array<string>;
|
|
@@ -461,13 +403,7 @@ export const SetTriggersPermissionsRequest = /*@__PURE__*/ S.suspend(() =>
|
|
|
461
403
|
channel_ids: S.optional(SetTriggersPermissionsRequestChannelIdsList),
|
|
462
404
|
team_ids: S.optional(SetTriggersPermissionsRequestTeamIdsList),
|
|
463
405
|
org_ids: S.optional(SetTriggersPermissionsRequestOrgIdsList),
|
|
464
|
-
}).pipe(
|
|
465
|
-
T.Http({
|
|
466
|
-
method: "POST",
|
|
467
|
-
uri: "/workflows.triggers.permissions.set",
|
|
468
|
-
code: 200,
|
|
469
|
-
}),
|
|
470
|
-
),
|
|
406
|
+
}).pipe(T.Http({ method: "POST", uri: "/workflows.triggers.permissions.set", code: 200 })),
|
|
471
407
|
).annotate({
|
|
472
408
|
identifier: "SetTriggersPermissionsRequest",
|
|
473
409
|
}) as any as S.Schema<SetTriggersPermissionsRequest>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA4ClD,eAAO,MAAM,oBAAoB,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,GACvE,IAAI,GACJ,KAAY,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { runValidationModes } from "@distilled.cloud/core/testing";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { credentials } from "./credentials.js";
|
|
5
|
-
import { SlackParseError } from "./errors.js";
|
|
6
|
-
import * as Retry from "./retry.js";
|
|
7
|
-
import { billingInfo } from "./services/team.js";
|
|
8
|
-
// team.billing.info declares `{ ok: boolean; plan: string }`; the payload
|
|
9
|
-
// shares the level of Slack's `{ ok: true, ... }` envelope.
|
|
10
|
-
const run = (body, headers) => runValidationModes(billingInfo({}).pipe(Retry.none, Effect.provide(credentials({ token: "xoxb-test" }))), { body, headers });
|
|
11
|
-
describe("Slack response validation", () => {
|
|
12
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
13
|
-
const body = { ok: true, plan: "free" };
|
|
14
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
15
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
16
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
17
|
-
});
|
|
18
|
-
test("a body missing required members: lenient returns it, strict fails", async () => {
|
|
19
|
-
const body = { ok: true };
|
|
20
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
21
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
22
|
-
expect(strict._tag).toBe("Failure");
|
|
23
|
-
expect(strict.failure).toBeInstanceOf(SlackParseError);
|
|
24
|
-
});
|
|
25
|
-
// A non-JSON 2xx body is read as raw bytes (the admin.analytics.getFile
|
|
26
|
-
// download); lenient returns them, strict fails them for a struct output.
|
|
27
|
-
test("a non-JSON body: lenient returns the raw bytes, strict fails", async () => {
|
|
28
|
-
const { lenient, strict } = await run("not json", {
|
|
29
|
-
"content-type": "application/gzip",
|
|
30
|
-
});
|
|
31
|
-
expect(lenient._tag).toBe("Success");
|
|
32
|
-
const bytes = lenient.success;
|
|
33
|
-
expect(bytes).toBeInstanceOf(Uint8Array);
|
|
34
|
-
expect(new TextDecoder().decode(bytes)).toBe("not json");
|
|
35
|
-
expect(strict.failure).toBeInstanceOf(SlackParseError);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
// SlackParseError is part of every operation's declared error type.
|
|
39
|
-
export const parseErrorIsDeclared = true;
|
|
40
|
-
//# sourceMappingURL=response-validation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.js","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,0EAA0E;AAC1E,4DAA4D;AAC5D,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,OAAgC,EAAE,EAAE,CAC7D,kBAAkB,CAChB,WAAW,CAAC,EAAE,CAAC,CAAC,IAAI,CAClB,KAAK,CAAC,IAAI,EACV,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CACpD,EACD,EAAE,IAAI,EAAE,OAAO,EAAE,CAClB,CAAC;AAEJ,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACxC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;QACnF,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QAC1B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,MAAM,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,0EAA0E;IAC1E,IAAI,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,kBAAkB;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,KAAK,GAAI,OAAe,CAAC,OAAO,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { runValidationModes } from "@distilled.cloud/core/testing";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { credentials } from "./credentials.ts";
|
|
5
|
-
import { SlackParseError } from "./errors.ts";
|
|
6
|
-
import * as Retry from "./retry.ts";
|
|
7
|
-
import { billingInfo } from "./services/team.ts";
|
|
8
|
-
import type { SlackOpError } from "./protocol.ts";
|
|
9
|
-
|
|
10
|
-
// team.billing.info declares `{ ok: boolean; plan: string }`; the payload
|
|
11
|
-
// shares the level of Slack's `{ ok: true, ... }` envelope.
|
|
12
|
-
const run = (body: string, headers?: Record<string, string>) =>
|
|
13
|
-
runValidationModes(
|
|
14
|
-
billingInfo({}).pipe(
|
|
15
|
-
Retry.none,
|
|
16
|
-
Effect.provide(credentials({ token: "xoxb-test" })),
|
|
17
|
-
),
|
|
18
|
-
{ body, headers },
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
describe("Slack response validation", () => {
|
|
22
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
23
|
-
const body = { ok: true, plan: "free" };
|
|
24
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
25
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
26
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("a body missing required members: lenient returns it, strict fails", async () => {
|
|
30
|
-
const body = { ok: true };
|
|
31
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
32
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
33
|
-
expect(strict._tag).toBe("Failure");
|
|
34
|
-
expect((strict as any).failure).toBeInstanceOf(SlackParseError);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// A non-JSON 2xx body is read as raw bytes (the admin.analytics.getFile
|
|
38
|
-
// download); lenient returns them, strict fails them for a struct output.
|
|
39
|
-
test("a non-JSON body: lenient returns the raw bytes, strict fails", async () => {
|
|
40
|
-
const { lenient, strict } = await run("not json", {
|
|
41
|
-
"content-type": "application/gzip",
|
|
42
|
-
});
|
|
43
|
-
expect(lenient._tag).toBe("Success");
|
|
44
|
-
const bytes = (lenient as any).success;
|
|
45
|
-
expect(bytes).toBeInstanceOf(Uint8Array);
|
|
46
|
-
expect(new TextDecoder().decode(bytes)).toBe("not json");
|
|
47
|
-
expect((strict as any).failure).toBeInstanceOf(SlackParseError);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// SlackParseError is part of every operation's declared error type.
|
|
52
|
-
export const parseErrorIsDeclared: [SlackParseError] extends [SlackOpError]
|
|
53
|
-
? true
|
|
54
|
-
: false = true;
|