@slates/provider 1.0.0-rc.25 → 1.0.0-rc.26
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 +13 -4
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.module.js +12 -4
- package/package.json +1 -1
- package/src/action/triggerGroup.ts +5 -0
- 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,
|
|
@@ -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
|
@@ -564,7 +564,11 @@ type SlateWebhookProcessHandler = (context: SlateContext<{}, {}, {
|
|
|
564
564
|
idempotencyKey?: string;
|
|
565
565
|
}[];
|
|
566
566
|
response?: Response | SlateWebhookHttpResponseInit;
|
|
567
|
+
skipped?: SlateWebhookSkipped;
|
|
567
568
|
}>;
|
|
569
|
+
interface SlateWebhookSkipped {
|
|
570
|
+
reason: string;
|
|
571
|
+
}
|
|
568
572
|
interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType extends {}> {
|
|
569
573
|
intervalSeconds: number;
|
|
570
574
|
pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
|
|
@@ -1081,4 +1085,12 @@ declare const metaWebhookHttp: {
|
|
|
1081
1085
|
};
|
|
1082
1086
|
declare let getMetaWebhookVerificationResponse: (request: Request, expectedVerifyToken: string | undefined) => SlateWebhookHttpResponseInit | null;
|
|
1083
1087
|
|
|
1084
|
-
|
|
1088
|
+
declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttpResponseInit) => {
|
|
1089
|
+
events: never[];
|
|
1090
|
+
skipped: {
|
|
1091
|
+
reason: string;
|
|
1092
|
+
};
|
|
1093
|
+
response: Response | SlateWebhookHttpResponseInit;
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
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
|
@@ -564,7 +564,11 @@ type SlateWebhookProcessHandler = (context: SlateContext<{}, {}, {
|
|
|
564
564
|
idempotencyKey?: string;
|
|
565
565
|
}[];
|
|
566
566
|
response?: Response | SlateWebhookHttpResponseInit;
|
|
567
|
+
skipped?: SlateWebhookSkipped;
|
|
567
568
|
}>;
|
|
569
|
+
interface SlateWebhookSkipped {
|
|
570
|
+
reason: string;
|
|
571
|
+
}
|
|
568
572
|
interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType extends {}> {
|
|
569
573
|
intervalSeconds: number;
|
|
570
574
|
pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
|
|
@@ -1081,4 +1085,12 @@ declare const metaWebhookHttp: {
|
|
|
1081
1085
|
};
|
|
1082
1086
|
declare let getMetaWebhookVerificationResponse: (request: Request, expectedVerifyToken: string | undefined) => SlateWebhookHttpResponseInit | null;
|
|
1083
1087
|
|
|
1084
|
-
|
|
1088
|
+
declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttpResponseInit) => {
|
|
1089
|
+
events: never[];
|
|
1090
|
+
skipped: {
|
|
1091
|
+
reason: string;
|
|
1092
|
+
};
|
|
1093
|
+
response: Response | SlateWebhookHttpResponseInit;
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
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
|
@@ -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 {}
|
|
@@ -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
|
+
});
|