@dsh-enhanced/lark-channel 0.1.24 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/docs/operations.md +8 -0
- package/docs/setup.md +3 -0
- package/lib/adapter.d.ts +7 -0
- package/lib/adapter.d.ts.map +1 -1
- package/lib/adapter.js +18 -4
- package/lib/adapter.js.map +1 -1
- package/lib/config.d.ts +3 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +8 -0
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/sdk.d.ts +17 -2
- package/lib/sdk.d.ts.map +1 -1
- package/lib/sdk.js +170 -76
- package/lib/sdk.js.map +1 -1
- package/lib/service.d.ts +17 -0
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +68 -5
- package/lib/service.js.map +1 -1
- package/lib/setup-profile.d.ts.map +1 -1
- package/lib/setup-profile.js +1 -0
- package/lib/setup-profile.js.map +1 -1
- package/lib/setup.d.ts +4 -0
- package/lib/setup.d.ts.map +1 -1
- package/lib/setup.js +313 -242
- package/lib/setup.js.map +1 -1
- package/lib/supervised-growth-profile.d.ts +27 -0
- package/lib/supervised-growth-profile.d.ts.map +1 -1
- package/lib/supervised-growth-profile.js +112 -0
- package/lib/supervised-growth-profile.js.map +1 -1
- package/lib/supervised-growth-setup.d.ts +82 -1
- package/lib/supervised-growth-setup.d.ts.map +1 -1
- package/lib/supervised-growth-setup.js +430 -85
- package/lib/supervised-growth-setup.js.map +1 -1
- package/lib/types.d.ts +12 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +14 -14
package/lib/config.js
CHANGED
|
@@ -16,12 +16,15 @@ const schema = Schema.object({
|
|
|
16
16
|
maxTextBytes: Schema.number().step(1).min(1).max(1024 * 1024).default(65_536),
|
|
17
17
|
staleAfterMs: Schema.number().step(1).min(1_000).max(86_400_000).default(300_000),
|
|
18
18
|
handshakeTimeoutMs: Schema.number().step(1).min(1_000).max(120_000).default(15_000),
|
|
19
|
+
requestTimeoutMs: Schema.number().step(1).min(1_000).max(120_000).default(30_000),
|
|
19
20
|
imageDownloadTimeoutMs: Schema.number().step(1).min(1_000).max(120_000).default(30_000),
|
|
20
21
|
userQuestionTtlMs: Schema.number().step(1).min(60_000).max(7 * 24 * 60 * 60 * 1_000)
|
|
21
22
|
.default(24 * 60 * 60 * 1_000),
|
|
23
|
+
allowedCalendarIds: Schema.array(Schema.string().min(1).max(512)).default([]),
|
|
22
24
|
});
|
|
23
25
|
const fields = new Set([
|
|
24
26
|
'account',
|
|
27
|
+
'allowedCalendarIds',
|
|
25
28
|
'appId',
|
|
26
29
|
'appSecretEnv',
|
|
27
30
|
'credentialHandle',
|
|
@@ -30,6 +33,7 @@ const fields = new Set([
|
|
|
30
33
|
'domain',
|
|
31
34
|
'enabled',
|
|
32
35
|
'handshakeTimeoutMs',
|
|
36
|
+
'requestTimeoutMs',
|
|
33
37
|
'imageDownloadTimeoutMs',
|
|
34
38
|
'maxTextBytes',
|
|
35
39
|
'progressDetails',
|
|
@@ -55,6 +59,10 @@ export const Config = new Proxy(schema, {
|
|
|
55
59
|
if (parsed.enabled && parsed.appSecretEnv === undefined && parsed.credentialHandle === undefined) {
|
|
56
60
|
throw new Error('lark-channel: enabled channel requires credentialHandle or appSecretEnv');
|
|
57
61
|
}
|
|
62
|
+
if (new Set(parsed.allowedCalendarIds ?? []).size !== (parsed.allowedCalendarIds ?? []).length
|
|
63
|
+
|| (parsed.allowedCalendarIds ?? []).some(value => value.trim() !== value || /[\p{Cc}]/u.test(value))) {
|
|
64
|
+
throw new Error('lark-channel: allowedCalendarIds must be unique stable Calendar IDs');
|
|
65
|
+
}
|
|
58
66
|
return parsed;
|
|
59
67
|
},
|
|
60
68
|
});
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,0BAA0B,CAAA;AA0B7C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,QAAQ,EAAE;IAC1F,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,QAAQ,EAAE;IACzF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,QAAQ,EAAE;IAClE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAC3D,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,sCAAsC,CAAC;IACjF,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IACrG,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IACzF,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAU,CAAC,CAAC,OAAO,CAAC,QAAQ,CA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AA;QACrG,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,CAAW,CAAA;QACtE,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YAC/E,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;QACvF,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACjG,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAA;QAC5F,CAAC;QACD,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,MAAM;eACzF,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACxG,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAA;QACxF,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAmB,CAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export * from './systemd.js';
|
|
|
16
16
|
export * from './windows-task.js';
|
|
17
17
|
export { createKeychainWriteRequest, createLarkRegistrationOptions, createSecretServiceWriteRequest, createWindowsDpapiWriteRequest, assertLinuxSecretServiceAvailable, assertLinuxProtectedFileAvailable, credentialProviderForPlatform, formatLarkSetupError, isMainEntry, matchOwnerHandshake, parseLarkSetupArgs, preflightLarkCredentialProvider, readSecretFromRawTerminal, retryDeferredLarkCredentialCleanup, selectLarkCredentialProvider, runLarkSetup, } from './setup.js';
|
|
18
18
|
export type { LarkSetupRuntime, RawSecretTerminalOptions } from './setup.js';
|
|
19
|
-
export { assertSupervisedGrowthAutomationGuard, commitSupervisedGrowthPatch, parseSupervisedGrowthSetupArgs, runSupervisedGrowthSetup, selectUniqueOwnerBinding, } from './supervised-growth-setup.js';
|
|
19
|
+
export { SUPERVISED_GROWTH_LIFECYCLE_ATTESTATION_PROTOCOL, SUPERVISED_GROWTH_MANAGED_AUTOMATION_PROJECTION_PROTOCOL, assertSupervisedGrowthAutomationGuard, captureSupervisedGrowthLifecycleAttestation, commitSupervisedGrowthPatch, expectedSupervisedGrowthManagedAutomationDigest, expectedSupervisedGrowthRecoveryBootstrap, parseSupervisedGrowthSetupArgs, runSupervisedGrowthSetup, selectUniqueOwnerBinding, supervisedGrowthLifecycleAttestationDigest, verifySupervisedGrowthLifecycleSuccessor, } from './supervised-growth-setup.js';
|
|
20
|
+
export type { SupervisedGrowthLifecycleAttestation, SupervisedGrowthLifecycleAttestationDependencies, SupervisedGrowthLifecycleAttestationInput, SupervisedGrowthManagedAutomationProjection, SupervisedGrowthManagedAutomationProjectionRecord, } from './supervised-growth-setup.js';
|
|
20
21
|
export declare function apply(ctx: Context, config: import('./config.js').Config): void;
|
|
21
22
|
declare const plugin: {
|
|
22
23
|
name: string;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,eAAO,MAAM,IAAI,8BAA8B,CAAA;AAC/C,eAAO,MAAM,MAAM,UAAwB,CAAA;AAC3C,OAAO,EAAE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AAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,iCAAiC,EACjC,6BAA6B,EAC7B,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,+BAA+B,EAC/B,yBAAyB,EACzB,kCAAkC,EAClC,4BAA4B,EAC5B,YAAY,GACb,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EACL,gDAAgD,EAChD,wDAAwD,EACxD,qCAAqC,EACrC,2CAA2C,EAC3C,2BAA2B,EAC3B,+CAA+C,EAC/C,yCAAyC,EACzC,8BAA8B,EAC9B,wBAAwB,EACxB,wBAAwB,EACxB,0CAA0C,EAC1C,wCAAwC,GACzC,MAAM,8BAA8B,CAAA;AACrC,YAAY,EACV,oCAAoC,EACpC,gDAAgD,EAChD,yCAAyC,EACzC,2CAA2C,EAC3C,iDAAiD,GAClD,MAAM,8BAA8B,CAAA;AAErC,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,aAAa,EAAE,MAAM,GAAG,IAAI,CAS9E;AAED,QAAA,MAAM,MAAM;;;;;CAAkC,CAAA;AAE9C,eAAe,MAAM,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export * from './resident.js';
|
|
|
14
14
|
export * from './systemd.js';
|
|
15
15
|
export * from './windows-task.js';
|
|
16
16
|
export { createKeychainWriteRequest, createLarkRegistrationOptions, createSecretServiceWriteRequest, createWindowsDpapiWriteRequest, assertLinuxSecretServiceAvailable, assertLinuxProtectedFileAvailable, credentialProviderForPlatform, formatLarkSetupError, isMainEntry, matchOwnerHandshake, parseLarkSetupArgs, preflightLarkCredentialProvider, readSecretFromRawTerminal, retryDeferredLarkCredentialCleanup, selectLarkCredentialProvider, runLarkSetup, } from './setup.js';
|
|
17
|
-
export { assertSupervisedGrowthAutomationGuard, commitSupervisedGrowthPatch, parseSupervisedGrowthSetupArgs, runSupervisedGrowthSetup, selectUniqueOwnerBinding, } from './supervised-growth-setup.js';
|
|
17
|
+
export { SUPERVISED_GROWTH_LIFECYCLE_ATTESTATION_PROTOCOL, SUPERVISED_GROWTH_MANAGED_AUTOMATION_PROJECTION_PROTOCOL, assertSupervisedGrowthAutomationGuard, captureSupervisedGrowthLifecycleAttestation, commitSupervisedGrowthPatch, expectedSupervisedGrowthManagedAutomationDigest, expectedSupervisedGrowthRecoveryBootstrap, parseSupervisedGrowthSetupArgs, runSupervisedGrowthSetup, selectUniqueOwnerBinding, supervisedGrowthLifecycleAttestationDigest, verifySupervisedGrowthLifecycleSuccessor, } from './supervised-growth-setup.js';
|
|
18
18
|
export function apply(ctx, config) {
|
|
19
19
|
const normalized = Config(config);
|
|
20
20
|
if (normalized.enabled && normalized.credentialHandle !== undefined) {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,IAAI,GAAG,2BAA2B,CAAA;AAC/C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAA;AAC9C,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,mBAAmB,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AA0B,EAC1B,6BAA6B,EAC7B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,iCAAiC,EACjC,6BAA6B,EAC7B,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,+BAA+B,EAC/B,yBAAyB,EACzB,kCAAkC,EAClC,4BAA4B,EAC5B,YAAY,GACb,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,gDAAgD,EAChD,wDAAwD,EACxD,qCAAqC,EACrC,2CAA2C,EAC3C,2BAA2B,EAC3B,+CAA+C,EAC/C,yCAAyC,EACzC,8BAA8B,EAC9B,wBAAwB,EACxB,wBAAwB,EACxB,0CAA0C,EAC1C,wCAAwC,GACzC,MAAM,8BAA8B,CAAA;AASrC,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAoC;IACtE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IACjC,IAAI,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE;YACrD,IAAI,kBAAkB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QACF,OAAM;IACR,CAAC;IACD,IAAI,kBAAkB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAE9C,eAAe,MAAM,CAAA"}
|
package/lib/sdk.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface OfficialLarkTransportOptions {
|
|
|
41
41
|
appSecret: string;
|
|
42
42
|
domain: 'feishu' | 'lark';
|
|
43
43
|
handshakeTimeoutMs: number;
|
|
44
|
+
/** Defaults to 30 seconds for direct SDK consumers predating this option. */
|
|
45
|
+
requestTimeoutMs?: number;
|
|
44
46
|
imageDownloadTimeoutMs: number;
|
|
45
47
|
}
|
|
46
48
|
export declare function classifyLarkSdkFailure(error: unknown): {
|
|
@@ -55,7 +57,8 @@ export declare function larkRequestUuid(idempotencyKey: string): string;
|
|
|
55
57
|
export declare function createLarkProgressRequest(chatId: string, options: {
|
|
56
58
|
replyTo: string;
|
|
57
59
|
hidden: boolean;
|
|
58
|
-
}): {
|
|
60
|
+
}, signal?: AbortSignal): {
|
|
61
|
+
signal?: AbortSignal;
|
|
59
62
|
method: "POST";
|
|
60
63
|
url: string;
|
|
61
64
|
data: {
|
|
@@ -66,7 +69,8 @@ export declare function createLarkProgressRequest(chatId: string, options: {
|
|
|
66
69
|
update_feed_rank: boolean;
|
|
67
70
|
};
|
|
68
71
|
};
|
|
69
|
-
export declare function writeLarkProgressRequest(handle: LarkProgressHandle, events: readonly LarkProgressEvent[]): {
|
|
72
|
+
export declare function writeLarkProgressRequest(handle: LarkProgressHandle, events: readonly LarkProgressEvent[], signal?: AbortSignal): {
|
|
73
|
+
signal?: AbortSignal;
|
|
70
74
|
method: "PUT";
|
|
71
75
|
url: string;
|
|
72
76
|
data: {
|
|
@@ -109,6 +113,7 @@ export declare class OfficialLarkTransport implements LarkTransport {
|
|
|
109
113
|
private readonly dispatcher;
|
|
110
114
|
private readonly ws;
|
|
111
115
|
private readonly handshakeTimeoutMs;
|
|
116
|
+
private readonly requestTimeoutMs;
|
|
112
117
|
private readonly imageDownloadTimeoutMs;
|
|
113
118
|
private readonly lifecycleController;
|
|
114
119
|
private handlers;
|
|
@@ -118,6 +123,8 @@ export declare class OfficialLarkTransport implements LarkTransport {
|
|
|
118
123
|
subscribe(handlers: LarkTransportHandlers): () => void;
|
|
119
124
|
connect(): Promise<void>;
|
|
120
125
|
disconnect(): Promise<void>;
|
|
126
|
+
private requestDeadline;
|
|
127
|
+
private boundedSdkRequest;
|
|
121
128
|
downloadMessageImage(messageId: string, fileKey: string, options: {
|
|
122
129
|
maxBytes: number;
|
|
123
130
|
signal: AbortSignal;
|
|
@@ -125,6 +132,14 @@ export declare class OfficialLarkTransport implements LarkTransport {
|
|
|
125
132
|
data: Uint8Array;
|
|
126
133
|
mediaType: LarkImageMediaType;
|
|
127
134
|
}>;
|
|
135
|
+
readCalendarEventPage(input: Readonly<{
|
|
136
|
+
calendarId: string;
|
|
137
|
+
startTime: number;
|
|
138
|
+
endTime: number;
|
|
139
|
+
pageSize: number;
|
|
140
|
+
pageToken?: string;
|
|
141
|
+
signal: AbortSignal;
|
|
142
|
+
}>): Promise<unknown>;
|
|
128
143
|
addReaction(messageId: string, emojiType: string): Promise<string>;
|
|
129
144
|
createProgress(chatId: string, options: {
|
|
130
145
|
replyTo: string;
|
package/lib/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAcL,KAAK,iBAAiB,EAGvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAE3B,MAAM,YAAY,CAAA;AAUnB,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,CAAA;AAExF,KAAK,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAA;AAE7F,UAAU,yBAAyB;IACjC,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,mBAAmB,CAAA;CAC7B;AAeD,wBAAgB,8B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
|
124
124
|
* request exists, so request-local Axios limits cannot cover a cache miss.
|
|
125
|
-
* Keep
|
|
125
|
+
* Keep each SDK client's complete HTTP stack bounded instead.
|
|
126
126
|
*/
|
|
127
|
-
function
|
|
127
|
+
function boundedHttpInstance(hardTimeoutMs, lifecycleSignal) {
|
|
128
128
|
if (!Number.isSafeInteger(hardTimeoutMs) || hardTimeoutMs < 1) {
|
|
129
|
-
throw new Error('lark-channel: invalid
|
|
129
|
+
throw new Error('lark-channel: invalid HTTP timeout');
|
|
130
130
|
}
|
|
131
131
|
return {
|
|
132
132
|
request(options) {
|
|
@@ -155,6 +155,40 @@ function boundedImageHttpInstance(hardTimeoutMs, lifecycleSignal) {
|
|
|
155
155
|
},
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* The official SDK accepts an AbortSignal only on its low-level request API.
|
|
160
|
+
* Race every SDK operation locally as well: an SDK/token-manager promise that
|
|
161
|
+
* ignores that signal must never retain a Delivery lease past this deadline.
|
|
162
|
+
* A later transport rejection is deliberately observed and discarded.
|
|
163
|
+
*/
|
|
164
|
+
function awaitBoundedSdkRequest(signal, request) {
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
166
|
+
let settled = false;
|
|
167
|
+
const finish = (complete) => {
|
|
168
|
+
if (settled)
|
|
169
|
+
return false;
|
|
170
|
+
settled = true;
|
|
171
|
+
signal.removeEventListener('abort', abort);
|
|
172
|
+
complete();
|
|
173
|
+
return true;
|
|
174
|
+
};
|
|
175
|
+
const abort = () => { finish(() => reject(abortReason(signal))); };
|
|
176
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
177
|
+
if (signal.aborted) {
|
|
178
|
+
abort();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
let pending;
|
|
182
|
+
try {
|
|
183
|
+
pending = request();
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
finish(() => reject(error));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
void pending.then(value => { finish(() => resolve(value)); }, error => { finish(() => reject(error)); });
|
|
190
|
+
});
|
|
191
|
+
}
|
|
158
192
|
function awaitImageResourceRequest(signal, request) {
|
|
159
193
|
return new Promise((resolve, reject) => {
|
|
160
194
|
let settled = false;
|
|
@@ -377,7 +411,7 @@ export async function classifyLarkImageSdkFailure(error, signal) {
|
|
|
377
411
|
export function larkRequestUuid(idempotencyKey) {
|
|
378
412
|
return createHash('sha256').update(idempotencyKey).digest('hex').slice(0, 32);
|
|
379
413
|
}
|
|
380
|
-
export function createLarkProgressRequest(chatId, options) {
|
|
414
|
+
export function createLarkProgressRequest(chatId, options, signal) {
|
|
381
415
|
return {
|
|
382
416
|
method: 'POST',
|
|
383
417
|
url: `${LARK_PROGRESS_API}?receive_id_type=chat_id`,
|
|
@@ -388,9 +422,10 @@ export function createLarkProgressRequest(chatId, options) {
|
|
|
388
422
|
enable_badge: false,
|
|
389
423
|
update_feed_rank: false,
|
|
390
424
|
},
|
|
425
|
+
...(signal === undefined ? {} : { signal }),
|
|
391
426
|
};
|
|
392
427
|
}
|
|
393
|
-
export function writeLarkProgressRequest(handle, events) {
|
|
428
|
+
export function writeLarkProgressRequest(handle, events, signal) {
|
|
394
429
|
return {
|
|
395
430
|
method: 'PUT',
|
|
396
431
|
url: LARK_PROGRESS_API,
|
|
@@ -403,6 +438,39 @@ export function writeLarkProgressRequest(handle, events) {
|
|
|
403
438
|
timestamp: event.timestamp,
|
|
404
439
|
})),
|
|
405
440
|
},
|
|
441
|
+
...(signal === undefined ? {} : { signal }),
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function createLarkMessageSendRequest(chatId, rendered, uuid, options, signal) {
|
|
445
|
+
if (options.replyTo === undefined) {
|
|
446
|
+
return {
|
|
447
|
+
method: 'POST',
|
|
448
|
+
url: LARK_MESSAGE_API,
|
|
449
|
+
params: { receive_id_type: 'chat_id' },
|
|
450
|
+
data: { receive_id: chatId, msg_type: rendered.msgType, content: rendered.content, uuid },
|
|
451
|
+
signal,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
const replyTo = assertResourceIdentifier(options.replyTo, 'reply message');
|
|
455
|
+
return {
|
|
456
|
+
method: 'POST',
|
|
457
|
+
url: `${LARK_MESSAGE_API}/${encodeURIComponent(replyTo)}/reply`,
|
|
458
|
+
data: {
|
|
459
|
+
msg_type: rendered.msgType,
|
|
460
|
+
content: rendered.content,
|
|
461
|
+
uuid,
|
|
462
|
+
...(options.replyInThread === undefined ? {} : { reply_in_thread: options.replyInThread }),
|
|
463
|
+
},
|
|
464
|
+
signal,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function createLarkReactionRequest(messageId, emojiType, signal) {
|
|
468
|
+
const message = assertResourceIdentifier(messageId, 'message');
|
|
469
|
+
return {
|
|
470
|
+
method: 'POST',
|
|
471
|
+
url: `${LARK_MESSAGE_API}/${encodeURIComponent(message)}/reactions`,
|
|
472
|
+
data: { reaction_type: { emoji_type: emojiType } },
|
|
473
|
+
signal,
|
|
406
474
|
};
|
|
407
475
|
}
|
|
408
476
|
export function createLarkRawCardUpdateRequest(messageId, card, signal) {
|
|
@@ -1015,6 +1083,7 @@ export class OfficialLarkTransport {
|
|
|
1015
1083
|
dispatcher;
|
|
1016
1084
|
ws;
|
|
1017
1085
|
handshakeTimeoutMs;
|
|
1086
|
+
requestTimeoutMs;
|
|
1018
1087
|
imageDownloadTimeoutMs;
|
|
1019
1088
|
lifecycleController = new AbortController();
|
|
1020
1089
|
handlers;
|
|
@@ -1025,12 +1094,17 @@ export class OfficialLarkTransport {
|
|
|
1025
1094
|
const shared = { appId: options.appId, appSecret: options.appSecret, domain,
|
|
1026
1095
|
logger: silentLogger, loggerLevel: LoggerLevel.error, source: 'dsh-enhanced-lark-channel' };
|
|
1027
1096
|
this.handshakeTimeoutMs = options.handshakeTimeoutMs;
|
|
1097
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? 30_000;
|
|
1028
1098
|
this.imageDownloadTimeoutMs = options.imageDownloadTimeoutMs;
|
|
1029
|
-
this.client = new Client({
|
|
1099
|
+
this.client = new Client({
|
|
1100
|
+
...shared,
|
|
1101
|
+
appType: AppType.SelfBuild,
|
|
1102
|
+
httpInstance: boundedHttpInstance(this.requestTimeoutMs, this.lifecycleController.signal),
|
|
1103
|
+
});
|
|
1030
1104
|
this.imageClient = new Client({
|
|
1031
1105
|
...shared,
|
|
1032
1106
|
appType: AppType.SelfBuild,
|
|
1033
|
-
httpInstance:
|
|
1107
|
+
httpInstance: boundedHttpInstance(options.imageDownloadTimeoutMs, this.lifecycleController.signal),
|
|
1034
1108
|
});
|
|
1035
1109
|
this.dispatcher = new EventDispatcher({ logger: silentLogger, loggerLevel: LoggerLevel.error });
|
|
1036
1110
|
this.dispatcher.register({
|
|
@@ -1127,6 +1201,46 @@ export class OfficialLarkTransport {
|
|
|
1127
1201
|
this.pendingHandshake?.reject(new LarkTransportError('not_connected', 'Lark transport stopped'));
|
|
1128
1202
|
this.ws.close({ force: true });
|
|
1129
1203
|
}
|
|
1204
|
+
requestDeadline(callerSignal) {
|
|
1205
|
+
const controller = new AbortController();
|
|
1206
|
+
const timer = setTimeout(() => controller.abort(new Error('lark-channel: OpenAPI request deadline exceeded')), this.requestTimeoutMs);
|
|
1207
|
+
timer.unref?.();
|
|
1208
|
+
const timeoutSignal = controller.signal;
|
|
1209
|
+
const signals = callerSignal === undefined
|
|
1210
|
+
? [timeoutSignal, this.lifecycleController.signal]
|
|
1211
|
+
: [callerSignal, timeoutSignal, this.lifecycleController.signal];
|
|
1212
|
+
return { signal: AbortSignal.any(signals), timeoutSignal, dispose: () => clearTimeout(timer) };
|
|
1213
|
+
}
|
|
1214
|
+
async boundedSdkRequest(request, failureMessage, callerSignal) {
|
|
1215
|
+
const deadline = this.requestDeadline(callerSignal);
|
|
1216
|
+
let started = false;
|
|
1217
|
+
try {
|
|
1218
|
+
return await awaitBoundedSdkRequest(deadline.signal, () => {
|
|
1219
|
+
started = true;
|
|
1220
|
+
return request(deadline.signal);
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
catch (error) {
|
|
1224
|
+
if (deadline.timeoutSignal.aborted) {
|
|
1225
|
+
// A timeout can happen after the provider has accepted the request.
|
|
1226
|
+
// The Delivery adapter deliberately maps send_timeout to unknown_after_send.
|
|
1227
|
+
throw new LarkTransportError('send_timeout', `${failureMessage} timed out`);
|
|
1228
|
+
}
|
|
1229
|
+
if (callerSignal?.aborted || this.lifecycleController.signal.aborted) {
|
|
1230
|
+
if (started) {
|
|
1231
|
+
throw new LarkTransportError('unknown', `${failureMessage} outcome is unknown after cancellation`);
|
|
1232
|
+
}
|
|
1233
|
+
throw new LarkTransportError('not_connected', `${failureMessage} was cancelled`);
|
|
1234
|
+
}
|
|
1235
|
+
if (error instanceof LarkTransportError)
|
|
1236
|
+
throw error;
|
|
1237
|
+
const classified = classifyLarkSdkFailure(error);
|
|
1238
|
+
throw new LarkTransportError(classified.code, `${failureMessage} failed`, classified.retryAfterMs);
|
|
1239
|
+
}
|
|
1240
|
+
finally {
|
|
1241
|
+
deadline.dispose();
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1130
1244
|
async downloadMessageImage(messageId, fileKey, options) {
|
|
1131
1245
|
const timeoutSignal = AbortSignal.timeout(this.imageDownloadTimeoutMs);
|
|
1132
1246
|
const signal = AbortSignal.any([options.signal, timeoutSignal, this.lifecycleController.signal]);
|
|
@@ -1184,12 +1298,40 @@ export class OfficialLarkTransport {
|
|
|
1184
1298
|
throw new LarkTransportError(classified.code, message, classified.retryAfterMs);
|
|
1185
1299
|
}
|
|
1186
1300
|
}
|
|
1187
|
-
async
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1301
|
+
async readCalendarEventPage(input) {
|
|
1302
|
+
if (!/^[\s\S]{1,512}$/u.test(input.calendarId) || input.calendarId.trim() !== input.calendarId || /[\p{Cc}]/u.test(input.calendarId)
|
|
1303
|
+
|| !Number.isSafeInteger(input.startTime) || !Number.isSafeInteger(input.endTime) || input.startTime < 0 || input.endTime <= input.startTime
|
|
1304
|
+
|| !Number.isSafeInteger(input.pageSize) || input.pageSize < 1 || input.pageSize > 1_000
|
|
1305
|
+
|| (input.pageToken !== undefined && (input.pageToken.length === 0 || input.pageToken.length > 4_096 || /[\p{Cc}]/u.test(input.pageToken)))) {
|
|
1306
|
+
throw new LarkTransportError('format_error', 'Lark calendar request is invalid');
|
|
1307
|
+
}
|
|
1308
|
+
if (input.signal.aborted || this.lifecycleController.signal.aborted) {
|
|
1309
|
+
throw new LarkTransportError('not_connected', 'Lark calendar request was cancelled');
|
|
1310
|
+
}
|
|
1311
|
+
return await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1312
|
+
const params = new URLSearchParams({ page_size: String(input.pageSize), start_time: String(input.startTime), end_time: String(input.endTime) });
|
|
1313
|
+
if (input.pageToken !== undefined)
|
|
1314
|
+
params.set('page_token', input.pageToken);
|
|
1315
|
+
const response = await this.client.request({
|
|
1316
|
+
url: `/open-apis/calendar/v4/calendars/${encodeURIComponent(input.calendarId)}/events?${params.toString()}`,
|
|
1317
|
+
method: 'GET', signal: deadlineSignal,
|
|
1318
|
+
maxContentLength: 1_048_576, maxBodyLength: 1_048_576,
|
|
1192
1319
|
});
|
|
1320
|
+
if (response !== null && typeof response === 'object' && 'code' in response) {
|
|
1321
|
+
const code = response.code;
|
|
1322
|
+
if (code !== undefined && code !== 0)
|
|
1323
|
+
throw providerError({ code: typeof code === 'number' ? code : undefined, msg: undefined });
|
|
1324
|
+
}
|
|
1325
|
+
const data = response !== null && typeof response === 'object' && 'data' in response
|
|
1326
|
+
? response.data : undefined;
|
|
1327
|
+
if (data === undefined)
|
|
1328
|
+
throw new LarkTransportError('unknown', 'Lark calendar response omitted data');
|
|
1329
|
+
return data;
|
|
1330
|
+
}, 'Lark calendar request', input.signal);
|
|
1331
|
+
}
|
|
1332
|
+
async addReaction(messageId, emojiType) {
|
|
1333
|
+
return await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1334
|
+
const response = await this.client.request(createLarkReactionRequest(messageId, emojiType, deadlineSignal));
|
|
1193
1335
|
if (response.code !== undefined && response.code !== 0) {
|
|
1194
1336
|
throw providerError({ code: response.code, msg: response.msg });
|
|
1195
1337
|
}
|
|
@@ -1198,17 +1340,11 @@ export class OfficialLarkTransport {
|
|
|
1198
1340
|
throw new LarkTransportError('unknown', 'Lark accepted reaction omitted reaction identity');
|
|
1199
1341
|
}
|
|
1200
1342
|
return reactionId;
|
|
1201
|
-
}
|
|
1202
|
-
catch (error) {
|
|
1203
|
-
if (error instanceof LarkTransportError)
|
|
1204
|
-
throw error;
|
|
1205
|
-
const classified = classifyLarkSdkFailure(error);
|
|
1206
|
-
throw new LarkTransportError(classified.code, 'Lark reaction request failed', classified.retryAfterMs);
|
|
1207
|
-
}
|
|
1343
|
+
}, 'Lark reaction request');
|
|
1208
1344
|
}
|
|
1209
1345
|
async createProgress(chatId, options) {
|
|
1210
|
-
|
|
1211
|
-
const response = await this.client.request(createLarkProgressRequest(chatId, options));
|
|
1346
|
+
return await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1347
|
+
const response = await this.client.request(createLarkProgressRequest(chatId, options, deadlineSignal));
|
|
1212
1348
|
if (response.code !== undefined && response.code !== 0) {
|
|
1213
1349
|
throw providerError({ code: response.code, msg: response.msg });
|
|
1214
1350
|
}
|
|
@@ -1218,92 +1354,50 @@ export class OfficialLarkTransport {
|
|
|
1218
1354
|
throw new LarkTransportError('unknown', 'Lark accepted progress request omitted progress identity');
|
|
1219
1355
|
}
|
|
1220
1356
|
return { cotId, messageId };
|
|
1221
|
-
}
|
|
1222
|
-
catch (error) {
|
|
1223
|
-
if (error instanceof LarkTransportError)
|
|
1224
|
-
throw error;
|
|
1225
|
-
const classified = classifyLarkSdkFailure(error);
|
|
1226
|
-
throw new LarkTransportError(classified.code, 'Lark progress request failed', classified.retryAfterMs);
|
|
1227
|
-
}
|
|
1357
|
+
}, 'Lark progress request');
|
|
1228
1358
|
}
|
|
1229
1359
|
async writeProgress(handle, events) {
|
|
1230
|
-
|
|
1231
|
-
const response = await this.client.request(writeLarkProgressRequest(handle, events));
|
|
1360
|
+
await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1361
|
+
const response = await this.client.request(writeLarkProgressRequest(handle, events, deadlineSignal));
|
|
1232
1362
|
if (response.code !== undefined && response.code !== 0) {
|
|
1233
1363
|
throw providerError({ code: response.code, msg: response.msg });
|
|
1234
1364
|
}
|
|
1235
|
-
}
|
|
1236
|
-
catch (error) {
|
|
1237
|
-
if (error instanceof LarkTransportError)
|
|
1238
|
-
throw error;
|
|
1239
|
-
const classified = classifyLarkSdkFailure(error);
|
|
1240
|
-
throw new LarkTransportError(classified.code, 'Lark progress update failed', classified.retryAfterMs);
|
|
1241
|
-
}
|
|
1365
|
+
}, 'Lark progress update');
|
|
1242
1366
|
}
|
|
1243
1367
|
async updateRawCard(messageId, card, signal) {
|
|
1244
1368
|
if (signal.aborted || this.lifecycleController.signal.aborted) {
|
|
1245
1369
|
throw new LarkTransportError('not_connected', 'Lark card update was cancelled');
|
|
1246
1370
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
const response = await this.client.request(createLarkRawCardUpdateRequest(messageId, card, combined));
|
|
1371
|
+
await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1372
|
+
const response = await this.client.request(createLarkRawCardUpdateRequest(messageId, card, deadlineSignal));
|
|
1250
1373
|
if (response.code !== undefined && response.code !== 0) {
|
|
1251
1374
|
throw providerError({ code: response.code, msg: response.msg });
|
|
1252
1375
|
}
|
|
1253
|
-
}
|
|
1254
|
-
catch (error) {
|
|
1255
|
-
if (error instanceof LarkTransportError)
|
|
1256
|
-
throw error;
|
|
1257
|
-
if (combined.aborted)
|
|
1258
|
-
throw new LarkTransportError('not_connected', 'Lark card update was cancelled');
|
|
1259
|
-
const classified = classifyLarkSdkFailure(error);
|
|
1260
|
-
throw new LarkTransportError(classified.code, 'Lark card update failed', classified.retryAfterMs);
|
|
1261
|
-
}
|
|
1376
|
+
}, 'Lark card update', signal);
|
|
1262
1377
|
}
|
|
1263
1378
|
async send(chatId, input, options = {}) {
|
|
1264
1379
|
const rendered = renderLarkMessage(input);
|
|
1265
1380
|
const uuid = larkRequestUuid(options.requestKey ?? `${chatId}:${rendered.content}`);
|
|
1266
|
-
|
|
1267
|
-
const response =
|
|
1268
|
-
? await this.client.im.v1.message.create({
|
|
1269
|
-
params: { receive_id_type: 'chat_id' },
|
|
1270
|
-
data: { receive_id: chatId, msg_type: rendered.msgType, content: rendered.content, uuid },
|
|
1271
|
-
})
|
|
1272
|
-
: await this.client.im.v1.message.reply({
|
|
1273
|
-
path: { message_id: options.replyTo },
|
|
1274
|
-
data: { msg_type: rendered.msgType, content: rendered.content, uuid,
|
|
1275
|
-
...(options.replyInThread === undefined ? {} : { reply_in_thread: options.replyInThread }) },
|
|
1276
|
-
});
|
|
1381
|
+
return await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1382
|
+
const response = await this.client.request(createLarkMessageSendRequest(chatId, rendered, uuid, options, deadlineSignal));
|
|
1277
1383
|
if (response.code !== 0)
|
|
1278
1384
|
throw providerError({ code: response.code, msg: response.msg });
|
|
1279
1385
|
const messageId = response.data?.message_id;
|
|
1280
1386
|
if (messageId === undefined)
|
|
1281
1387
|
throw new LarkTransportError('unknown', 'Lark accepted response omitted message identity');
|
|
1282
1388
|
return { messageId };
|
|
1283
|
-
}
|
|
1284
|
-
catch (error) {
|
|
1285
|
-
if (error instanceof LarkTransportError)
|
|
1286
|
-
throw error;
|
|
1287
|
-
const classified = classifyLarkSdkFailure(error);
|
|
1288
|
-
throw new LarkTransportError(classified.code, 'Lark SDK request failed', classified.retryAfterMs);
|
|
1289
|
-
}
|
|
1389
|
+
}, 'Lark SDK request');
|
|
1290
1390
|
}
|
|
1291
1391
|
async fetchBotIdentity() {
|
|
1292
|
-
|
|
1392
|
+
return await this.boundedSdkRequest(async (deadlineSignal) => {
|
|
1293
1393
|
const response = await this.client.request({
|
|
1294
|
-
url: '/open-apis/bot/v3/info', method: 'GET',
|
|
1394
|
+
url: '/open-apis/bot/v3/info', method: 'GET', signal: deadlineSignal,
|
|
1295
1395
|
});
|
|
1296
1396
|
if (response.bot?.open_id === undefined) {
|
|
1297
1397
|
throw new LarkTransportError('permission_denied', 'Lark bot identity is unavailable');
|
|
1298
1398
|
}
|
|
1299
1399
|
return { openId: response.bot.open_id, name: response.bot.app_name ?? 'bot' };
|
|
1300
|
-
}
|
|
1301
|
-
catch (error) {
|
|
1302
|
-
if (error instanceof LarkTransportError)
|
|
1303
|
-
throw error;
|
|
1304
|
-
const classified = classifyLarkSdkFailure(error);
|
|
1305
|
-
throw new LarkTransportError(classified.code, 'Lark bot identity request failed', classified.retryAfterMs);
|
|
1306
|
-
}
|
|
1400
|
+
}, 'Lark bot identity request');
|
|
1307
1401
|
}
|
|
1308
1402
|
}
|
|
1309
1403
|
export function createOfficialLarkTransport(options) {
|