@contractspec/integration.runtime 1.57.0 → 1.59.0
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/health.d.ts +14 -18
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js +71 -68
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +828 -9
- package/dist/node/health.js +72 -0
- package/dist/node/index.js +827 -0
- package/dist/node/runtime.js +208 -0
- package/dist/node/secrets/env-secret-provider.js +158 -0
- package/dist/node/secrets/gcp-secret-manager.js +346 -0
- package/dist/node/secrets/index.js +549 -0
- package/dist/node/secrets/manager.js +182 -0
- package/dist/node/secrets/provider.js +73 -0
- package/dist/runtime.d.ts +86 -90
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +204 -181
- package/dist/secrets/env-secret-provider.d.ts +20 -23
- package/dist/secrets/env-secret-provider.d.ts.map +1 -1
- package/dist/secrets/env-secret-provider.js +157 -80
- package/dist/secrets/gcp-secret-manager.d.ts +25 -28
- package/dist/secrets/gcp-secret-manager.d.ts.map +1 -1
- package/dist/secrets/gcp-secret-manager.js +339 -222
- package/dist/secrets/index.d.ts +5 -5
- package/dist/secrets/index.d.ts.map +1 -0
- package/dist/secrets/index.js +549 -5
- package/dist/secrets/manager.d.ts +32 -35
- package/dist/secrets/manager.d.ts.map +1 -1
- package/dist/secrets/manager.js +180 -101
- package/dist/secrets/provider.d.ts +42 -45
- package/dist/secrets/provider.d.ts.map +1 -1
- package/dist/secrets/provider.js +69 -54
- package/package.json +76 -30
- package/dist/health.js.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/secrets/env-secret-provider.js.map +0 -1
- package/dist/secrets/gcp-secret-manager.js.map +0 -1
- package/dist/secrets/manager.js.map +0 -1
- package/dist/secrets/provider.js.map +0 -1
package/dist/health.d.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface IntegrationHealthCheckResult extends IntegrationConnectionHealth {
|
|
6
|
-
metadata?: Record<string, string>;
|
|
1
|
+
import type { IntegrationConnectionHealth } from '@contractspec/lib.contracts/integrations/connection';
|
|
2
|
+
import type { IntegrationContext, IntegrationTelemetryEmitter } from './runtime';
|
|
3
|
+
export interface IntegrationHealthCheckResult extends IntegrationConnectionHealth {
|
|
4
|
+
metadata?: Record<string, string>;
|
|
7
5
|
}
|
|
8
|
-
type IntegrationHealthCheckExecutor = (context: IntegrationContext) => Promise<void>;
|
|
9
|
-
interface IntegrationHealthServiceOptions {
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export type IntegrationHealthCheckExecutor = (context: IntegrationContext) => Promise<void>;
|
|
7
|
+
export interface IntegrationHealthServiceOptions {
|
|
8
|
+
telemetry?: IntegrationTelemetryEmitter;
|
|
9
|
+
now?: () => Date;
|
|
12
10
|
}
|
|
13
|
-
declare class IntegrationHealthService {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export declare class IntegrationHealthService {
|
|
12
|
+
private readonly telemetry?;
|
|
13
|
+
private readonly nowFn;
|
|
14
|
+
constructor(options?: IntegrationHealthServiceOptions);
|
|
15
|
+
check(context: IntegrationContext, executor: IntegrationHealthCheckExecutor): Promise<IntegrationHealthCheckResult>;
|
|
16
|
+
private emitTelemetry;
|
|
19
17
|
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { IntegrationHealthCheckExecutor, IntegrationHealthCheckResult, IntegrationHealthService, IntegrationHealthServiceOptions };
|
|
22
18
|
//# sourceMappingURL=health.d.ts.map
|
package/dist/health.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,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41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
1
|
+
// @bun
|
|
2
|
+
// src/health.ts
|
|
3
|
+
class IntegrationHealthService {
|
|
4
|
+
telemetry;
|
|
5
|
+
nowFn;
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.telemetry = options.telemetry;
|
|
8
|
+
this.nowFn = options.now ?? (() => new Date);
|
|
9
|
+
}
|
|
10
|
+
async check(context, executor) {
|
|
11
|
+
const start = this.nowFn();
|
|
12
|
+
try {
|
|
13
|
+
await executor(context);
|
|
14
|
+
const end = this.nowFn();
|
|
15
|
+
const result = {
|
|
16
|
+
status: "connected",
|
|
17
|
+
checkedAt: end,
|
|
18
|
+
latencyMs: end.getTime() - start.getTime()
|
|
19
|
+
};
|
|
20
|
+
this.emitTelemetry(context, result, "success");
|
|
21
|
+
return result;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
const end = this.nowFn();
|
|
24
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
25
|
+
const code = extractErrorCode(error);
|
|
26
|
+
const result = {
|
|
27
|
+
status: "error",
|
|
28
|
+
checkedAt: end,
|
|
29
|
+
latencyMs: end.getTime() - start.getTime(),
|
|
30
|
+
errorMessage: message,
|
|
31
|
+
errorCode: code
|
|
32
|
+
};
|
|
33
|
+
this.emitTelemetry(context, result, "error", code, message);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
emitTelemetry(context, result, status, errorCode, errorMessage) {
|
|
38
|
+
if (!this.telemetry)
|
|
39
|
+
return;
|
|
40
|
+
this.telemetry.record({
|
|
41
|
+
tenantId: context.tenantId,
|
|
42
|
+
appId: context.appId,
|
|
43
|
+
environment: context.environment,
|
|
44
|
+
slotId: context.slotId,
|
|
45
|
+
integrationKey: context.spec.meta.key,
|
|
46
|
+
integrationVersion: context.spec.meta.version,
|
|
47
|
+
connectionId: context.connection.meta.id,
|
|
48
|
+
status,
|
|
49
|
+
durationMs: result.latencyMs,
|
|
50
|
+
errorCode,
|
|
51
|
+
errorMessage,
|
|
52
|
+
occurredAt: result.checkedAt ?? this.nowFn(),
|
|
53
|
+
metadata: {
|
|
54
|
+
...context.trace ? {
|
|
55
|
+
blueprint: `${context.trace.blueprintName}.v${context.trace.blueprintVersion}`,
|
|
56
|
+
configVersion: context.trace.configVersion
|
|
57
|
+
} : {},
|
|
58
|
+
status: result.status
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
61
63
|
function extractErrorCode(error) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (!error || typeof error !== "object")
|
|
65
|
+
return;
|
|
66
|
+
const candidate = error;
|
|
67
|
+
if (candidate.code == null)
|
|
68
|
+
return;
|
|
69
|
+
return String(candidate.code);
|
|
66
70
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=health.js.map
|
|
71
|
+
export {
|
|
72
|
+
IntegrationHealthService
|
|
73
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { EnvSecretProvider } from "./secrets/env-secret-provider.js";
|
|
6
|
-
import { SecretProviderManager, SecretProviderManagerOptions } from "./secrets/manager.js";
|
|
7
|
-
import "./secrets/index.js";
|
|
8
|
-
export { EnvSecretProvider, GcpSecretManagerProvider, IntegrationCallContext, IntegrationCallError, IntegrationCallGuard, IntegrationCallGuardOptions, IntegrationCallResult, IntegrationContext, IntegrationHealthCheckExecutor, IntegrationHealthCheckResult, IntegrationHealthService, IntegrationHealthServiceOptions, IntegrationInvocationStatus, IntegrationTelemetryEmitter, IntegrationTelemetryEvent, IntegrationTraceMetadata, ParsedSecretUri, SecretFetchOptions, SecretPayloadEncoding, SecretProvider, SecretProviderError, SecretProviderManager, SecretProviderManagerOptions, SecretReference, SecretRotationResult, SecretValue, SecretWritePayload, connectionStatusLabel, ensureConnectionReady, normalizeSecretPayload, parseSecretUri };
|
|
1
|
+
export * from './runtime';
|
|
2
|
+
export * from './health';
|
|
3
|
+
export * from './secrets';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|