@slates/provider 1.0.0-rc.32 → 1.0.0-rc.33
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 +15 -3
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.module.js +14 -3
- package/package.json +1 -1
- package/src/context/context.ts +25 -3
- package/src/context/hook.ts +2 -0
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,7 @@ __export(index_exports, {
|
|
|
86
86
|
getMetaWebhookVerificationResponse: () => getMetaWebhookVerificationResponse,
|
|
87
87
|
getOAuthExpiresAtFromExpiresIn: () => getOAuthExpiresAtFromExpiresIn,
|
|
88
88
|
getResponseHeaderValue: () => getResponseHeaderValue,
|
|
89
|
+
getRuntimeInfo: () => getRuntimeInfo,
|
|
89
90
|
getServiceErrorData: () => getServiceErrorData,
|
|
90
91
|
graphWebhookHttp: () => graphWebhookHttp,
|
|
91
92
|
inferSlateErrorFromAxios: () => inferSlateErrorFromAxios,
|
|
@@ -1024,6 +1025,7 @@ var getCurrentContext = () => {
|
|
|
1024
1025
|
}
|
|
1025
1026
|
return context;
|
|
1026
1027
|
};
|
|
1028
|
+
var getRuntimeInfo = () => asyncLocalStorage.getStore()?.runtimeInfo ?? null;
|
|
1027
1029
|
|
|
1028
1030
|
// src/error/defaults.ts
|
|
1029
1031
|
var DEFAULT_CODE = "internal.unexpected";
|
|
@@ -2894,6 +2896,10 @@ var resolveDefaultExport = (value) => {
|
|
|
2894
2896
|
var PQueue = resolveDefaultExport(import_p_queue.default);
|
|
2895
2897
|
|
|
2896
2898
|
// src/context/context.ts
|
|
2899
|
+
var freezeRuntimeInfo = (runtimeInfo) => Object.freeze({
|
|
2900
|
+
...runtimeInfo,
|
|
2901
|
+
...runtimeInfo.metorial ? { metorial: Object.freeze({ ...runtimeInfo.metorial }) } : {}
|
|
2902
|
+
});
|
|
2897
2903
|
var isBufferLike = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
2898
2904
|
var toUint8Array = (value) => value instanceof ArrayBuffer ? new Uint8Array(value) : value;
|
|
2899
2905
|
var isReadableStream = (value) => typeof ReadableStream !== "undefined" && value instanceof ReadableStream;
|
|
@@ -2910,17 +2916,19 @@ var readStreamToBuffer = async (stream) => {
|
|
|
2910
2916
|
return Buffer.concat(chunks);
|
|
2911
2917
|
};
|
|
2912
2918
|
var SlatePublicContext = class {
|
|
2913
|
-
constructor(input, spec2, logger, liveInvocation = null) {
|
|
2919
|
+
constructor(input, spec2, logger, liveInvocation = null, runtimeInfo = null) {
|
|
2914
2920
|
this.spec = spec2;
|
|
2915
2921
|
this.logger = logger;
|
|
2916
2922
|
this.#input = input;
|
|
2917
2923
|
this.#liveInvocation = liveInvocation;
|
|
2924
|
+
this.#runtimeInfo = runtimeInfo && freezeRuntimeInfo(runtimeInfo);
|
|
2918
2925
|
}
|
|
2919
2926
|
spec;
|
|
2920
2927
|
logger;
|
|
2921
2928
|
#input;
|
|
2922
2929
|
#httpTraces = [];
|
|
2923
2930
|
#liveInvocation;
|
|
2931
|
+
#runtimeInfo;
|
|
2924
2932
|
#attachmentsDisabled = false;
|
|
2925
2933
|
#attachments = [];
|
|
2926
2934
|
#pendingUploads = [];
|
|
@@ -2931,6 +2939,9 @@ var SlatePublicContext = class {
|
|
|
2931
2939
|
}
|
|
2932
2940
|
return this.#uploadQueue;
|
|
2933
2941
|
}
|
|
2942
|
+
get runtimeInfo() {
|
|
2943
|
+
return this.#runtimeInfo;
|
|
2944
|
+
}
|
|
2934
2945
|
get specification() {
|
|
2935
2946
|
return this.spec;
|
|
2936
2947
|
}
|
|
@@ -3071,8 +3082,8 @@ var SlatePublicContext = class {
|
|
|
3071
3082
|
var SlateContext = class extends SlatePublicContext {
|
|
3072
3083
|
#config;
|
|
3073
3084
|
#auth;
|
|
3074
|
-
constructor(config2, input, auth2, spec2, logger, liveInvocation = null) {
|
|
3075
|
-
super(input, spec2, logger, liveInvocation);
|
|
3085
|
+
constructor(config2, input, auth2, spec2, logger, liveInvocation = null, runtimeInfo = null) {
|
|
3086
|
+
super(input, spec2, logger, liveInvocation, runtimeInfo);
|
|
3076
3087
|
this.#config = config2;
|
|
3077
3088
|
this.#auth = auth2;
|
|
3078
3089
|
}
|
|
@@ -3550,6 +3561,7 @@ var skipWebhook = (reason, response) => ({
|
|
|
3550
3561
|
getMetaWebhookVerificationResponse,
|
|
3551
3562
|
getOAuthExpiresAtFromExpiresIn,
|
|
3552
3563
|
getResponseHeaderValue,
|
|
3564
|
+
getRuntimeInfo,
|
|
3553
3565
|
getServiceErrorData,
|
|
3554
3566
|
graphWebhookHttp,
|
|
3555
3567
|
inferSlateErrorFromAxios,
|
package/dist/index.d.cts
CHANGED
|
@@ -459,6 +459,13 @@ declare class SlateSpecification<ConfigType extends {}, AuthType extends {}> {
|
|
|
459
459
|
}
|
|
460
460
|
declare let spec: <ConfigType extends {}, AuthType extends {}>(params: SlateSpecificationCreateParameters<ConfigType, AuthType>) => SlateSpecification<ConfigType, AuthType>;
|
|
461
461
|
|
|
462
|
+
interface SlateRuntimeInfo {
|
|
463
|
+
metorial?: {
|
|
464
|
+
apiUrl: string;
|
|
465
|
+
region?: string | null;
|
|
466
|
+
environment?: string | null;
|
|
467
|
+
};
|
|
468
|
+
}
|
|
462
469
|
type SlateAddAttachmentContent = Buffer | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | NodeJS.ReadableStream | Response;
|
|
463
470
|
type SlateAddAttachmentInput = {
|
|
464
471
|
type: 'url';
|
|
@@ -479,7 +486,8 @@ declare class SlatePublicContext<InputType extends {}> {
|
|
|
479
486
|
#private;
|
|
480
487
|
private readonly spec;
|
|
481
488
|
private readonly logger;
|
|
482
|
-
constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
|
|
489
|
+
constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null, runtimeInfo?: SlateRuntimeInfo | null);
|
|
490
|
+
get runtimeInfo(): Readonly<SlateRuntimeInfo> | null;
|
|
483
491
|
get specification(): SlateSpecification<any, any>;
|
|
484
492
|
get input(): Readonly<InputType>;
|
|
485
493
|
get event(): Readonly<InputType>;
|
|
@@ -517,7 +525,7 @@ declare class SlatePublicContext<InputType extends {}> {
|
|
|
517
525
|
}
|
|
518
526
|
declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType extends {}> extends SlatePublicContext<InputType> {
|
|
519
527
|
#private;
|
|
520
|
-
constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
|
|
528
|
+
constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null, runtimeInfo?: SlateRuntimeInfo | null);
|
|
521
529
|
get config(): Readonly<ConfigType>;
|
|
522
530
|
get auth(): Readonly<AuthType>;
|
|
523
531
|
_getAuthConfigForRedaction(): Record<string, unknown> | undefined;
|
|
@@ -525,6 +533,7 @@ declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
525
533
|
|
|
526
534
|
declare let runWithContext: <InputType extends {}, RV>(context: SlatePublicContext<InputType>, fn: () => Promise<RV>) => Promise<RV>;
|
|
527
535
|
declare let getCurrentContext: <ConfigType extends {}, AuthType extends {}, InputType extends {}>() => SlateContext<ConfigType, AuthType, InputType>;
|
|
536
|
+
declare let getRuntimeInfo: () => Readonly<SlateRuntimeInfo> | null;
|
|
528
537
|
|
|
529
538
|
declare let SlateDefaultPollingIntervalSeconds: number;
|
|
530
539
|
type SlateTriggerRoutingMatcher = Record<string, any>;
|
|
@@ -1206,4 +1215,4 @@ declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttp
|
|
|
1206
1215
|
response: Response | SlateWebhookHttpResponseInit;
|
|
1207
1216
|
};
|
|
1208
1217
|
|
|
1209
|
-
export { API_ERROR_MAX_DETAILS, API_ERROR_MAX_MESSAGE_LENGTH, API_ERROR_TRUNCATED_PLACEHOLDER, AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiErrorTextOptions, type ApiServiceError, type AuthConfigSecretFilter, AuthConfigSecretRedactor, type BoundedApiErrorDetailOptions, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type DecodeApiErrorBodyOptions, 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 SlateGatewayEvent, 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, SlateToolCategory, type SlateToolCategoryParameters, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupGatewayConnectHandler, type SlateTriggerGroupGatewayParameters, type SlateTriggerGroupGatewayReceiveHandler, 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, decodeApiErrorBody, extractApiErrorMessage, getApiErrorResponse, getApiErrorResponseWithBody, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, isUrlEmbeddedCredential, looksLikeHtmlErrorBody, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, pushBoundedApiErrorDetail, readApiErrorText, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, toolCategory, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|
|
1218
|
+
export { API_ERROR_MAX_DETAILS, API_ERROR_MAX_MESSAGE_LENGTH, API_ERROR_TRUNCATED_PLACEHOLDER, AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiErrorTextOptions, type ApiServiceError, type AuthConfigSecretFilter, AuthConfigSecretRedactor, type BoundedApiErrorDetailOptions, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type DecodeApiErrorBodyOptions, 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 SlateGatewayEvent, type SlateLiveInvocationInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateRuntimeInfo, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, SlateToolCategory, type SlateToolCategoryParameters, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupGatewayConnectHandler, type SlateTriggerGroupGatewayParameters, type SlateTriggerGroupGatewayReceiveHandler, 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, decodeApiErrorBody, extractApiErrorMessage, getApiErrorResponse, getApiErrorResponseWithBody, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getRuntimeInfo, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, isUrlEmbeddedCredential, looksLikeHtmlErrorBody, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, pushBoundedApiErrorDetail, readApiErrorText, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, toolCategory, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -459,6 +459,13 @@ declare class SlateSpecification<ConfigType extends {}, AuthType extends {}> {
|
|
|
459
459
|
}
|
|
460
460
|
declare let spec: <ConfigType extends {}, AuthType extends {}>(params: SlateSpecificationCreateParameters<ConfigType, AuthType>) => SlateSpecification<ConfigType, AuthType>;
|
|
461
461
|
|
|
462
|
+
interface SlateRuntimeInfo {
|
|
463
|
+
metorial?: {
|
|
464
|
+
apiUrl: string;
|
|
465
|
+
region?: string | null;
|
|
466
|
+
environment?: string | null;
|
|
467
|
+
};
|
|
468
|
+
}
|
|
462
469
|
type SlateAddAttachmentContent = Buffer | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | NodeJS.ReadableStream | Response;
|
|
463
470
|
type SlateAddAttachmentInput = {
|
|
464
471
|
type: 'url';
|
|
@@ -479,7 +486,8 @@ declare class SlatePublicContext<InputType extends {}> {
|
|
|
479
486
|
#private;
|
|
480
487
|
private readonly spec;
|
|
481
488
|
private readonly logger;
|
|
482
|
-
constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
|
|
489
|
+
constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null, runtimeInfo?: SlateRuntimeInfo | null);
|
|
490
|
+
get runtimeInfo(): Readonly<SlateRuntimeInfo> | null;
|
|
483
491
|
get specification(): SlateSpecification<any, any>;
|
|
484
492
|
get input(): Readonly<InputType>;
|
|
485
493
|
get event(): Readonly<InputType>;
|
|
@@ -517,7 +525,7 @@ declare class SlatePublicContext<InputType extends {}> {
|
|
|
517
525
|
}
|
|
518
526
|
declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType extends {}> extends SlatePublicContext<InputType> {
|
|
519
527
|
#private;
|
|
520
|
-
constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
|
|
528
|
+
constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null, runtimeInfo?: SlateRuntimeInfo | null);
|
|
521
529
|
get config(): Readonly<ConfigType>;
|
|
522
530
|
get auth(): Readonly<AuthType>;
|
|
523
531
|
_getAuthConfigForRedaction(): Record<string, unknown> | undefined;
|
|
@@ -525,6 +533,7 @@ declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
525
533
|
|
|
526
534
|
declare let runWithContext: <InputType extends {}, RV>(context: SlatePublicContext<InputType>, fn: () => Promise<RV>) => Promise<RV>;
|
|
527
535
|
declare let getCurrentContext: <ConfigType extends {}, AuthType extends {}, InputType extends {}>() => SlateContext<ConfigType, AuthType, InputType>;
|
|
536
|
+
declare let getRuntimeInfo: () => Readonly<SlateRuntimeInfo> | null;
|
|
528
537
|
|
|
529
538
|
declare let SlateDefaultPollingIntervalSeconds: number;
|
|
530
539
|
type SlateTriggerRoutingMatcher = Record<string, any>;
|
|
@@ -1206,4 +1215,4 @@ declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttp
|
|
|
1206
1215
|
response: Response | SlateWebhookHttpResponseInit;
|
|
1207
1216
|
};
|
|
1208
1217
|
|
|
1209
|
-
export { API_ERROR_MAX_DETAILS, API_ERROR_MAX_MESSAGE_LENGTH, API_ERROR_TRUNCATED_PLACEHOLDER, AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiErrorTextOptions, type ApiServiceError, type AuthConfigSecretFilter, AuthConfigSecretRedactor, type BoundedApiErrorDetailOptions, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type DecodeApiErrorBodyOptions, 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 SlateGatewayEvent, 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, SlateToolCategory, type SlateToolCategoryParameters, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupGatewayConnectHandler, type SlateTriggerGroupGatewayParameters, type SlateTriggerGroupGatewayReceiveHandler, 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, decodeApiErrorBody, extractApiErrorMessage, getApiErrorResponse, getApiErrorResponseWithBody, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, isUrlEmbeddedCredential, looksLikeHtmlErrorBody, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, pushBoundedApiErrorDetail, readApiErrorText, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, toolCategory, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|
|
1218
|
+
export { API_ERROR_MAX_DETAILS, API_ERROR_MAX_MESSAGE_LENGTH, API_ERROR_TRUNCATED_PLACEHOLDER, AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiErrorTextOptions, type ApiServiceError, type AuthConfigSecretFilter, AuthConfigSecretRedactor, type BoundedApiErrorDetailOptions, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type DecodeApiErrorBodyOptions, 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 SlateGatewayEvent, type SlateLiveInvocationInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateRuntimeInfo, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, SlateToolCategory, type SlateToolCategoryParameters, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupGatewayConnectHandler, type SlateTriggerGroupGatewayParameters, type SlateTriggerGroupGatewayReceiveHandler, 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, decodeApiErrorBody, extractApiErrorMessage, getApiErrorResponse, getApiErrorResponseWithBody, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getRuntimeInfo, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, isUrlEmbeddedCredential, looksLikeHtmlErrorBody, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, pushBoundedApiErrorDetail, readApiErrorText, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, toolCategory, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|
package/dist/index.module.js
CHANGED
|
@@ -899,6 +899,7 @@ var getCurrentContext = () => {
|
|
|
899
899
|
}
|
|
900
900
|
return context;
|
|
901
901
|
};
|
|
902
|
+
var getRuntimeInfo = () => asyncLocalStorage.getStore()?.runtimeInfo ?? null;
|
|
902
903
|
|
|
903
904
|
// src/error/defaults.ts
|
|
904
905
|
var DEFAULT_CODE = "internal.unexpected";
|
|
@@ -2769,6 +2770,10 @@ var resolveDefaultExport = (value) => {
|
|
|
2769
2770
|
var PQueue = resolveDefaultExport(PQueueImport);
|
|
2770
2771
|
|
|
2771
2772
|
// src/context/context.ts
|
|
2773
|
+
var freezeRuntimeInfo = (runtimeInfo) => Object.freeze({
|
|
2774
|
+
...runtimeInfo,
|
|
2775
|
+
...runtimeInfo.metorial ? { metorial: Object.freeze({ ...runtimeInfo.metorial }) } : {}
|
|
2776
|
+
});
|
|
2772
2777
|
var isBufferLike = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
2773
2778
|
var toUint8Array = (value) => value instanceof ArrayBuffer ? new Uint8Array(value) : value;
|
|
2774
2779
|
var isReadableStream = (value) => typeof ReadableStream !== "undefined" && value instanceof ReadableStream;
|
|
@@ -2785,17 +2790,19 @@ var readStreamToBuffer = async (stream) => {
|
|
|
2785
2790
|
return Buffer.concat(chunks);
|
|
2786
2791
|
};
|
|
2787
2792
|
var SlatePublicContext = class {
|
|
2788
|
-
constructor(input, spec2, logger, liveInvocation = null) {
|
|
2793
|
+
constructor(input, spec2, logger, liveInvocation = null, runtimeInfo = null) {
|
|
2789
2794
|
this.spec = spec2;
|
|
2790
2795
|
this.logger = logger;
|
|
2791
2796
|
this.#input = input;
|
|
2792
2797
|
this.#liveInvocation = liveInvocation;
|
|
2798
|
+
this.#runtimeInfo = runtimeInfo && freezeRuntimeInfo(runtimeInfo);
|
|
2793
2799
|
}
|
|
2794
2800
|
spec;
|
|
2795
2801
|
logger;
|
|
2796
2802
|
#input;
|
|
2797
2803
|
#httpTraces = [];
|
|
2798
2804
|
#liveInvocation;
|
|
2805
|
+
#runtimeInfo;
|
|
2799
2806
|
#attachmentsDisabled = false;
|
|
2800
2807
|
#attachments = [];
|
|
2801
2808
|
#pendingUploads = [];
|
|
@@ -2806,6 +2813,9 @@ var SlatePublicContext = class {
|
|
|
2806
2813
|
}
|
|
2807
2814
|
return this.#uploadQueue;
|
|
2808
2815
|
}
|
|
2816
|
+
get runtimeInfo() {
|
|
2817
|
+
return this.#runtimeInfo;
|
|
2818
|
+
}
|
|
2809
2819
|
get specification() {
|
|
2810
2820
|
return this.spec;
|
|
2811
2821
|
}
|
|
@@ -2946,8 +2956,8 @@ var SlatePublicContext = class {
|
|
|
2946
2956
|
var SlateContext = class extends SlatePublicContext {
|
|
2947
2957
|
#config;
|
|
2948
2958
|
#auth;
|
|
2949
|
-
constructor(config2, input, auth2, spec2, logger, liveInvocation = null) {
|
|
2950
|
-
super(input, spec2, logger, liveInvocation);
|
|
2959
|
+
constructor(config2, input, auth2, spec2, logger, liveInvocation = null, runtimeInfo = null) {
|
|
2960
|
+
super(input, spec2, logger, liveInvocation, runtimeInfo);
|
|
2951
2961
|
this.#config = config2;
|
|
2952
2962
|
this.#auth = auth2;
|
|
2953
2963
|
}
|
|
@@ -3424,6 +3434,7 @@ export {
|
|
|
3424
3434
|
getMetaWebhookVerificationResponse,
|
|
3425
3435
|
getOAuthExpiresAtFromExpiresIn,
|
|
3426
3436
|
getResponseHeaderValue,
|
|
3437
|
+
getRuntimeInfo,
|
|
3427
3438
|
getServiceErrorData,
|
|
3428
3439
|
graphWebhookHttp,
|
|
3429
3440
|
inferSlateErrorFromAxios,
|
package/package.json
CHANGED
package/src/context/context.ts
CHANGED
|
@@ -12,6 +12,20 @@ import { PQueue } from './pQueue';
|
|
|
12
12
|
|
|
13
13
|
export type { SlateLiveInvocationInfo };
|
|
14
14
|
|
|
15
|
+
export interface SlateRuntimeInfo {
|
|
16
|
+
metorial?: {
|
|
17
|
+
apiUrl: string;
|
|
18
|
+
region?: string | null;
|
|
19
|
+
environment?: string | null;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let freezeRuntimeInfo = (runtimeInfo: SlateRuntimeInfo): Readonly<SlateRuntimeInfo> =>
|
|
24
|
+
Object.freeze({
|
|
25
|
+
...runtimeInfo,
|
|
26
|
+
...(runtimeInfo.metorial ? { metorial: Object.freeze({ ...runtimeInfo.metorial }) } : {})
|
|
27
|
+
});
|
|
28
|
+
|
|
15
29
|
export type SlateAddAttachmentContent =
|
|
16
30
|
| Buffer
|
|
17
31
|
| Uint8Array
|
|
@@ -80,6 +94,7 @@ export class SlatePublicContext<InputType extends {}> {
|
|
|
80
94
|
#httpTraces: SlateHttpTrace[] = [];
|
|
81
95
|
|
|
82
96
|
#liveInvocation: SlateLiveInvocationInfo | null;
|
|
97
|
+
#runtimeInfo: Readonly<SlateRuntimeInfo> | null;
|
|
83
98
|
#attachmentsDisabled = false;
|
|
84
99
|
#attachments: SlateAttachment[] = [];
|
|
85
100
|
#pendingUploads: Promise<void>[] = [];
|
|
@@ -96,10 +111,16 @@ export class SlatePublicContext<InputType extends {}> {
|
|
|
96
111
|
input: InputType,
|
|
97
112
|
private readonly spec: SlateSpecification<any, any>,
|
|
98
113
|
private readonly logger: SlateLogger,
|
|
99
|
-
liveInvocation: SlateLiveInvocationInfo | null = null
|
|
114
|
+
liveInvocation: SlateLiveInvocationInfo | null = null,
|
|
115
|
+
runtimeInfo: SlateRuntimeInfo | null = null
|
|
100
116
|
) {
|
|
101
117
|
this.#input = input;
|
|
102
118
|
this.#liveInvocation = liveInvocation;
|
|
119
|
+
this.#runtimeInfo = runtimeInfo && freezeRuntimeInfo(runtimeInfo);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get runtimeInfo() {
|
|
123
|
+
return this.#runtimeInfo;
|
|
103
124
|
}
|
|
104
125
|
|
|
105
126
|
get specification() {
|
|
@@ -294,9 +315,10 @@ export class SlateContext<
|
|
|
294
315
|
auth: AuthType,
|
|
295
316
|
spec: SlateSpecification<ConfigType, AuthType>,
|
|
296
317
|
logger: SlateLogger,
|
|
297
|
-
liveInvocation: SlateLiveInvocationInfo | null = null
|
|
318
|
+
liveInvocation: SlateLiveInvocationInfo | null = null,
|
|
319
|
+
runtimeInfo: SlateRuntimeInfo | null = null
|
|
298
320
|
) {
|
|
299
|
-
super(input, spec, logger, liveInvocation);
|
|
321
|
+
super(input, spec, logger, liveInvocation, runtimeInfo);
|
|
300
322
|
this.#config = config;
|
|
301
323
|
this.#auth = auth;
|
|
302
324
|
}
|