@slates/provider 1.0.0-rc.25 → 1.0.0-rc.27
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/dist/index.cjs +14 -5
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.module.js +13 -5
- package/package.json +1 -1
- package/src/action/triggerGroup.ts +5 -0
- package/src/auth/types.ts +4 -0
- package/src/error/base.ts +1 -1
- package/src/error/declaration.ts +1 -1
- package/src/error/utils.ts +6 -2
- package/src/specification/slate.test.ts +14 -0
- package/src/specification/slate.ts +4 -4
- package/src/webhook/index.ts +1 -0
- package/src/webhook/skip.ts +10 -0
package/dist/index.cjs
CHANGED
|
@@ -99,6 +99,7 @@ __export(index_exports, {
|
|
|
99
99
|
runWithContext: () => runWithContext,
|
|
100
100
|
scopeClause: () => scopeClause,
|
|
101
101
|
setIfDefined: () => setIfDefined,
|
|
102
|
+
skipWebhook: () => skipWebhook,
|
|
102
103
|
spec: () => spec,
|
|
103
104
|
statusLabelForApiError: () => statusLabelForApiError,
|
|
104
105
|
tool: () => tool,
|
|
@@ -405,7 +406,7 @@ var normalizeRetryable = (code, retryable) => {
|
|
|
405
406
|
};
|
|
406
407
|
var getDefaultMessage = (code, message) => {
|
|
407
408
|
if (message?.trim()) return message;
|
|
408
|
-
return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE];
|
|
409
|
+
return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE] ?? "An unexpected internal error occurred.";
|
|
409
410
|
};
|
|
410
411
|
var cleanRecord = (value) => {
|
|
411
412
|
if (!value) return void 0;
|
|
@@ -2803,7 +2804,7 @@ var Slate = class _Slate {
|
|
|
2803
2804
|
);
|
|
2804
2805
|
}
|
|
2805
2806
|
seenAdapterIds.add(adapter.id);
|
|
2806
|
-
for (let action of adapter.actions) {
|
|
2807
|
+
for (let action of adapter.actions ?? []) {
|
|
2807
2808
|
let existing = seenActionKeys.get(action.key);
|
|
2808
2809
|
if (existing && existing !== action) {
|
|
2809
2810
|
throw new SlateDeclarationError(
|
|
@@ -2840,13 +2841,13 @@ var Slate = class _Slate {
|
|
|
2840
2841
|
return this._spec;
|
|
2841
2842
|
}
|
|
2842
2843
|
get actions() {
|
|
2843
|
-
return this._actions;
|
|
2844
|
+
return this._actions ?? [];
|
|
2844
2845
|
}
|
|
2845
2846
|
get adapters() {
|
|
2846
|
-
return this._adapters;
|
|
2847
|
+
return this._adapters ?? [];
|
|
2847
2848
|
}
|
|
2848
2849
|
get triggerGroups() {
|
|
2849
|
-
return this._triggerGroups;
|
|
2850
|
+
return this._triggerGroups ?? [];
|
|
2850
2851
|
}
|
|
2851
2852
|
};
|
|
2852
2853
|
|
|
@@ -2946,6 +2947,13 @@ var getMetaWebhookVerificationResponse = (request, expectedVerifyToken) => {
|
|
|
2946
2947
|
body: challenge
|
|
2947
2948
|
};
|
|
2948
2949
|
};
|
|
2950
|
+
|
|
2951
|
+
// src/webhook/skip.ts
|
|
2952
|
+
var skipWebhook = (reason, response) => ({
|
|
2953
|
+
events: [],
|
|
2954
|
+
skipped: { reason },
|
|
2955
|
+
response: response ?? { status: 200, body: "" }
|
|
2956
|
+
});
|
|
2949
2957
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2950
2958
|
0 && (module.exports = {
|
|
2951
2959
|
AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX,
|
|
@@ -3017,6 +3025,7 @@ var getMetaWebhookVerificationResponse = (request, expectedVerifyToken) => {
|
|
|
3017
3025
|
runWithContext,
|
|
3018
3026
|
scopeClause,
|
|
3019
3027
|
setIfDefined,
|
|
3028
|
+
skipWebhook,
|
|
3020
3029
|
spec,
|
|
3021
3030
|
statusLabelForApiError,
|
|
3022
3031
|
tool,
|
package/dist/index.d.cts
CHANGED
|
@@ -150,6 +150,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
|
|
|
150
150
|
scope: string;
|
|
151
151
|
}[];
|
|
152
152
|
adapters?: string[];
|
|
153
|
+
syncTokensAcrossConnections?: boolean;
|
|
153
154
|
docs?: SlateAuthDocsReference[];
|
|
154
155
|
inputSchema?: z.ZodType<InputType>;
|
|
155
156
|
onInputChanged?: (params: {
|
|
@@ -564,7 +565,11 @@ type SlateWebhookProcessHandler = (context: SlateContext<{}, {}, {
|
|
|
564
565
|
idempotencyKey?: string;
|
|
565
566
|
}[];
|
|
566
567
|
response?: Response | SlateWebhookHttpResponseInit;
|
|
568
|
+
skipped?: SlateWebhookSkipped;
|
|
567
569
|
}>;
|
|
570
|
+
interface SlateWebhookSkipped {
|
|
571
|
+
reason: string;
|
|
572
|
+
}
|
|
568
573
|
interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType extends {}> {
|
|
569
574
|
intervalSeconds: number;
|
|
570
575
|
pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
|
|
@@ -1081,4 +1086,12 @@ declare const metaWebhookHttp: {
|
|
|
1081
1086
|
};
|
|
1082
1087
|
declare let getMetaWebhookVerificationResponse: (request: Request, expectedVerifyToken: string | undefined) => SlateWebhookHttpResponseInit | null;
|
|
1083
1088
|
|
|
1084
|
-
|
|
1089
|
+
declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttpResponseInit) => {
|
|
1090
|
+
events: never[];
|
|
1091
|
+
skipped: {
|
|
1092
|
+
reason: string;
|
|
1093
|
+
};
|
|
1094
|
+
response: Response | SlateWebhookHttpResponseInit;
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
export { AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiServiceError, AuthConfigSecretRedactor, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, GET_FILE_URL_TOOL_ID, type GetFileUrlHandler, type GetFileUrlToolInput, type GetFileUrlToolOutput, type NormalizeOAuthTokenResponseOptions, type OAuthExpiresAtOptions, type OAuthRefreshTokenFallbackMode, type OAuthTokenResponse, Slate, SlateAction, SlateActionBuilder, type SlateActionCreateParameters, type SlateActionDocsReference, type SlateActionParameters, type SlateActionParametersAny, type SlateActionParametersTool, type SlateActionParametersTrigger, type SlateActionScopeClause, type SlateActionScopeClauseInput, type SlateActionScopeValue, type SlateActionScopes, type SlateActionScopesInput, type SlateActionType, SlateAdapter, type SlateAdapterCapability, SlateAdapterSpec, type SlateAdapterSpecParameters, type SlateAddAttachmentContent, type SlateAddAttachmentInput, type SlateAttachment, type SlateAttachmentInlineContent, type SlateAttachmentUploadReferenceContent, type SlateAttachmentUrlContent, SlateAuth, type SlateAuthDocsReference, type SlateAuthType, type SlateAuthWithCustomData, type SlateAuthWithNone, type SlateAuthWithOauth, type SlateAuthWithServiceAccount, type SlateAuthWithToken, type SlateAuthenticatedAxiosDefaults, type SlateAxiosDefaults, type SlateAxiosErrorAdapter, type SlateAxiosErrorOptions, SlateConfig, type SlateConfigDocsReference, SlateContext, SlateDeclarationError, SlateDefaultPollingIntervalSeconds, type SlateDirectUploadInput, type SlateDocsReference, SlateError, type SlateErrorInput, type SlateErrorIssue, type SlateErrorKind, type SlateErrorProviderInfo, type SlateErrorResponse, type SlateErrorUpstreamInfo, type SlateLiveInvocationInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupParameters, type SlateTriggerGroupPollHandler, type SlateTriggerGroupPollingParameters, type SlateTriggerGroupRoutingMatchersHandler, type SlateTriggerGroupWebhookAutoRegistrationParameters, type SlateTriggerGroupWebhookManualRegistrationParameters, type SlateTriggerGroupWebhookParameters, type SlateTriggerMappingHandler, type SlateTriggerMatchesHandler, type SlateTriggerParameters, type SlateTriggerRoutingMatcher, type SlateTypedDocsReference, type SlateWebhookHttpResponseInit, type SlateWebhookManualFinishHandler, type SlateWebhookManualSetupHandler, type SlateWebhookProcessHandler, type SlateWebhookRegisterHandler, type SlateWebhookSkipped, type SlateWebhookTarget, type SlateWebhookTargetListHandler, type SlateWebhookTargetOwnership, type SlateWebhookUnregisterHandler, type VerifyHmacSignatureOptions, adapterSpec, allOf, anyOf, auth, axios, buildApiServiceError, collectApiErrorDetails, config, createApiServiceError, createAuthenticatedAxios, createAxios, createBase64Attachment, createHmacSignature, createSlateError, createTextAttachment, createUrlAttachment, extractApiErrorMessage, getApiErrorResponse, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, trigger, triggerGroup, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -150,6 +150,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
|
|
|
150
150
|
scope: string;
|
|
151
151
|
}[];
|
|
152
152
|
adapters?: string[];
|
|
153
|
+
syncTokensAcrossConnections?: boolean;
|
|
153
154
|
docs?: SlateAuthDocsReference[];
|
|
154
155
|
inputSchema?: z.ZodType<InputType>;
|
|
155
156
|
onInputChanged?: (params: {
|
|
@@ -564,7 +565,11 @@ type SlateWebhookProcessHandler = (context: SlateContext<{}, {}, {
|
|
|
564
565
|
idempotencyKey?: string;
|
|
565
566
|
}[];
|
|
566
567
|
response?: Response | SlateWebhookHttpResponseInit;
|
|
568
|
+
skipped?: SlateWebhookSkipped;
|
|
567
569
|
}>;
|
|
570
|
+
interface SlateWebhookSkipped {
|
|
571
|
+
reason: string;
|
|
572
|
+
}
|
|
568
573
|
interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType extends {}> {
|
|
569
574
|
intervalSeconds: number;
|
|
570
575
|
pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
|
|
@@ -1081,4 +1086,12 @@ declare const metaWebhookHttp: {
|
|
|
1081
1086
|
};
|
|
1082
1087
|
declare let getMetaWebhookVerificationResponse: (request: Request, expectedVerifyToken: string | undefined) => SlateWebhookHttpResponseInit | null;
|
|
1083
1088
|
|
|
1084
|
-
|
|
1089
|
+
declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttpResponseInit) => {
|
|
1090
|
+
events: never[];
|
|
1091
|
+
skipped: {
|
|
1092
|
+
reason: string;
|
|
1093
|
+
};
|
|
1094
|
+
response: Response | SlateWebhookHttpResponseInit;
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
export { AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiServiceError, AuthConfigSecretRedactor, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, GET_FILE_URL_TOOL_ID, type GetFileUrlHandler, type GetFileUrlToolInput, type GetFileUrlToolOutput, type NormalizeOAuthTokenResponseOptions, type OAuthExpiresAtOptions, type OAuthRefreshTokenFallbackMode, type OAuthTokenResponse, Slate, SlateAction, SlateActionBuilder, type SlateActionCreateParameters, type SlateActionDocsReference, type SlateActionParameters, type SlateActionParametersAny, type SlateActionParametersTool, type SlateActionParametersTrigger, type SlateActionScopeClause, type SlateActionScopeClauseInput, type SlateActionScopeValue, type SlateActionScopes, type SlateActionScopesInput, type SlateActionType, SlateAdapter, type SlateAdapterCapability, SlateAdapterSpec, type SlateAdapterSpecParameters, type SlateAddAttachmentContent, type SlateAddAttachmentInput, type SlateAttachment, type SlateAttachmentInlineContent, type SlateAttachmentUploadReferenceContent, type SlateAttachmentUrlContent, SlateAuth, type SlateAuthDocsReference, type SlateAuthType, type SlateAuthWithCustomData, type SlateAuthWithNone, type SlateAuthWithOauth, type SlateAuthWithServiceAccount, type SlateAuthWithToken, type SlateAuthenticatedAxiosDefaults, type SlateAxiosDefaults, type SlateAxiosErrorAdapter, type SlateAxiosErrorOptions, SlateConfig, type SlateConfigDocsReference, SlateContext, SlateDeclarationError, SlateDefaultPollingIntervalSeconds, type SlateDirectUploadInput, type SlateDocsReference, SlateError, type SlateErrorInput, type SlateErrorIssue, type SlateErrorKind, type SlateErrorProviderInfo, type SlateErrorResponse, type SlateErrorUpstreamInfo, type SlateLiveInvocationInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupParameters, type SlateTriggerGroupPollHandler, type SlateTriggerGroupPollingParameters, type SlateTriggerGroupRoutingMatchersHandler, type SlateTriggerGroupWebhookAutoRegistrationParameters, type SlateTriggerGroupWebhookManualRegistrationParameters, type SlateTriggerGroupWebhookParameters, type SlateTriggerMappingHandler, type SlateTriggerMatchesHandler, type SlateTriggerParameters, type SlateTriggerRoutingMatcher, type SlateTypedDocsReference, type SlateWebhookHttpResponseInit, type SlateWebhookManualFinishHandler, type SlateWebhookManualSetupHandler, type SlateWebhookProcessHandler, type SlateWebhookRegisterHandler, type SlateWebhookSkipped, type SlateWebhookTarget, type SlateWebhookTargetListHandler, type SlateWebhookTargetOwnership, type SlateWebhookUnregisterHandler, type VerifyHmacSignatureOptions, adapterSpec, allOf, anyOf, auth, axios, buildApiServiceError, collectApiErrorDetails, config, createApiServiceError, createAuthenticatedAxios, createAxios, createBase64Attachment, createHmacSignature, createSlateError, createTextAttachment, createUrlAttachment, extractApiErrorMessage, getApiErrorResponse, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, trigger, triggerGroup, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|
package/dist/index.module.js
CHANGED
|
@@ -293,7 +293,7 @@ var normalizeRetryable = (code, retryable) => {
|
|
|
293
293
|
};
|
|
294
294
|
var getDefaultMessage = (code, message) => {
|
|
295
295
|
if (message?.trim()) return message;
|
|
296
|
-
return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE];
|
|
296
|
+
return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE] ?? "An unexpected internal error occurred.";
|
|
297
297
|
};
|
|
298
298
|
var cleanRecord = (value) => {
|
|
299
299
|
if (!value) return void 0;
|
|
@@ -2691,7 +2691,7 @@ var Slate = class _Slate {
|
|
|
2691
2691
|
);
|
|
2692
2692
|
}
|
|
2693
2693
|
seenAdapterIds.add(adapter.id);
|
|
2694
|
-
for (let action of adapter.actions) {
|
|
2694
|
+
for (let action of adapter.actions ?? []) {
|
|
2695
2695
|
let existing = seenActionKeys.get(action.key);
|
|
2696
2696
|
if (existing && existing !== action) {
|
|
2697
2697
|
throw new SlateDeclarationError(
|
|
@@ -2728,13 +2728,13 @@ var Slate = class _Slate {
|
|
|
2728
2728
|
return this._spec;
|
|
2729
2729
|
}
|
|
2730
2730
|
get actions() {
|
|
2731
|
-
return this._actions;
|
|
2731
|
+
return this._actions ?? [];
|
|
2732
2732
|
}
|
|
2733
2733
|
get adapters() {
|
|
2734
|
-
return this._adapters;
|
|
2734
|
+
return this._adapters ?? [];
|
|
2735
2735
|
}
|
|
2736
2736
|
get triggerGroups() {
|
|
2737
|
-
return this._triggerGroups;
|
|
2737
|
+
return this._triggerGroups ?? [];
|
|
2738
2738
|
}
|
|
2739
2739
|
};
|
|
2740
2740
|
|
|
@@ -2834,6 +2834,13 @@ var getMetaWebhookVerificationResponse = (request, expectedVerifyToken) => {
|
|
|
2834
2834
|
body: challenge
|
|
2835
2835
|
};
|
|
2836
2836
|
};
|
|
2837
|
+
|
|
2838
|
+
// src/webhook/skip.ts
|
|
2839
|
+
var skipWebhook = (reason, response) => ({
|
|
2840
|
+
events: [],
|
|
2841
|
+
skipped: { reason },
|
|
2842
|
+
response: response ?? { status: 200, body: "" }
|
|
2843
|
+
});
|
|
2837
2844
|
export {
|
|
2838
2845
|
AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX,
|
|
2839
2846
|
AuthConfigSecretRedactor,
|
|
@@ -2904,6 +2911,7 @@ export {
|
|
|
2904
2911
|
runWithContext,
|
|
2905
2912
|
scopeClause,
|
|
2906
2913
|
setIfDefined,
|
|
2914
|
+
skipWebhook,
|
|
2907
2915
|
spec,
|
|
2908
2916
|
statusLabelForApiError,
|
|
2909
2917
|
tool,
|
package/package.json
CHANGED
|
@@ -106,8 +106,13 @@ export type SlateWebhookProcessHandler = (
|
|
|
106
106
|
idempotencyKey?: string;
|
|
107
107
|
}[];
|
|
108
108
|
response?: Response | SlateWebhookHttpResponseInit;
|
|
109
|
+
skipped?: SlateWebhookSkipped;
|
|
109
110
|
}>;
|
|
110
111
|
|
|
112
|
+
export interface SlateWebhookSkipped {
|
|
113
|
+
reason: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
111
116
|
export interface SlateTriggerGroupPollingParameters<
|
|
112
117
|
ConfigType extends {},
|
|
113
118
|
AuthType extends {}
|
package/src/auth/types.ts
CHANGED
|
@@ -24,6 +24,10 @@ export type SlateAuthWithOauth<
|
|
|
24
24
|
|
|
25
25
|
adapters?: string[];
|
|
26
26
|
|
|
27
|
+
// Set when the provider issues the same rotating token pair to every
|
|
28
|
+
// connection of one installation, so a refresh must update all of them.
|
|
29
|
+
syncTokensAcrossConnections?: boolean;
|
|
30
|
+
|
|
27
31
|
docs?: SlateAuthDocsReference[];
|
|
28
32
|
|
|
29
33
|
inputSchema?: z.ZodType<InputType>;
|
package/src/error/base.ts
CHANGED
package/src/error/declaration.ts
CHANGED
|
@@ -11,7 +11,7 @@ export class SlateDeclarationError extends SlateError {
|
|
|
11
11
|
this.name = 'SlateError.DeclarationError';
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
static is(error: unknown): error is SlateDeclarationError {
|
|
14
|
+
static override is(error: unknown): error is SlateDeclarationError {
|
|
15
15
|
return error instanceof SlateDeclarationError;
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/error/utils.ts
CHANGED
|
@@ -61,9 +61,13 @@ export let normalizeRetryable = (code: string, retryable?: boolean) => {
|
|
|
61
61
|
);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
export let getDefaultMessage = (code: string, message?: string) => {
|
|
64
|
+
export let getDefaultMessage = (code: string, message?: string): string => {
|
|
65
65
|
if (message?.trim()) return message;
|
|
66
|
-
return
|
|
66
|
+
return (
|
|
67
|
+
DEFAULT_MESSAGES[code] ??
|
|
68
|
+
DEFAULT_MESSAGES[DEFAULT_CODE] ??
|
|
69
|
+
'An unexpected internal error occurred.'
|
|
70
|
+
);
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
export let cleanRecord = <Value extends Record<string, unknown> | undefined>(value: Value) => {
|
|
@@ -102,4 +102,18 @@ describe('Slate.create', () => {
|
|
|
102
102
|
'auto_group'
|
|
103
103
|
]);
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
it('treats omitted adapters, trigger groups, and adapter actions as empty collections', () => {
|
|
107
|
+
let spec = createTestSpec();
|
|
108
|
+
let slate = Slate.create({
|
|
109
|
+
spec,
|
|
110
|
+
tools: [],
|
|
111
|
+
triggers: [],
|
|
112
|
+
adapters: [{ id: 'legacy' } as any]
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(slate.adapters).toHaveLength(1);
|
|
116
|
+
expect(slate.actions).toEqual([]);
|
|
117
|
+
expect(slate.triggerGroups).toEqual([]);
|
|
118
|
+
});
|
|
105
119
|
});
|
|
@@ -34,7 +34,7 @@ export class Slate<ConfigType extends {}, AuthType extends {}> {
|
|
|
34
34
|
}
|
|
35
35
|
seenAdapterIds.add(adapter.id);
|
|
36
36
|
|
|
37
|
-
for (let action of adapter.actions) {
|
|
37
|
+
for (let action of adapter.actions ?? []) {
|
|
38
38
|
let existing = seenActionKeys.get(action.key);
|
|
39
39
|
if (existing && existing !== action) {
|
|
40
40
|
throw new SlateDeclarationError(
|
|
@@ -79,14 +79,14 @@ export class Slate<ConfigType extends {}, AuthType extends {}> {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
get actions() {
|
|
82
|
-
return this._actions;
|
|
82
|
+
return this._actions ?? [];
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
get adapters() {
|
|
86
|
-
return this._adapters;
|
|
86
|
+
return this._adapters ?? [];
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
get triggerGroups() {
|
|
90
|
-
return this._triggerGroups;
|
|
90
|
+
return this._triggerGroups ?? [];
|
|
91
91
|
}
|
|
92
92
|
}
|
package/src/webhook/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SlateWebhookHttpResponseInit, SlateWebhookSkipped } from '../action';
|
|
2
|
+
|
|
3
|
+
export let skipWebhook = (
|
|
4
|
+
reason: string,
|
|
5
|
+
response?: Response | SlateWebhookHttpResponseInit
|
|
6
|
+
) => ({
|
|
7
|
+
events: [],
|
|
8
|
+
skipped: { reason } satisfies SlateWebhookSkipped,
|
|
9
|
+
response: response ?? { status: 200, body: '' }
|
|
10
|
+
});
|