@skrr-ai/signals 0.1.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/CHANGELOG.md +11 -0
- package/README.md +41 -0
- package/contracts/README.md +28 -0
- package/contracts/asyncapi.v1.json +80 -0
- package/contracts/public-signal-source.v1.schema.json +58 -0
- package/contracts/signal-envelope.v1.schema.json +94 -0
- package/contracts/signal-receipt.v1.schema.json +27 -0
- package/contracts/signal-source-credential-grant.v1.schema.json +26 -0
- package/contracts/signal-type-definition.v1.schema.json +146 -0
- package/dist/index.cjs +563 -0
- package/dist/index.d.cts +254 -0
- package/dist/index.d.ts +254 -0
- package/dist/index.js +527 -0
- package/package.json +62 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/** CloudEvents structured-mode media type accepted by the Signal API. */
|
|
2
|
+
declare const SIGNAL_CLOUDEVENTS_CONTENT_TYPE = "application/cloudevents+json";
|
|
3
|
+
declare const SIGNAL_API_VERSION = "v1";
|
|
4
|
+
declare const CLOUD_EVENTS_V1: "1.0";
|
|
5
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
6
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
7
|
+
interface JsonObject {
|
|
8
|
+
[key: string]: JsonValue;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extension attributes are intentionally limited to normal CloudEvents extension
|
|
12
|
+
* names. They cannot carry source identity, authorization, Monitor, Commitment,
|
|
13
|
+
* or Agent selection data.
|
|
14
|
+
*/
|
|
15
|
+
type SignalExtensions = Record<string, JsonPrimitive>;
|
|
16
|
+
/**
|
|
17
|
+
* The public v1 Signal envelope. It is CloudEvents 1.0 in structured JSON mode.
|
|
18
|
+
* `source + id` is the occurrence identity used for deduplication.
|
|
19
|
+
*/
|
|
20
|
+
interface SignalEnvelope<TData extends JsonValue = JsonValue> {
|
|
21
|
+
specversion: typeof CLOUD_EVENTS_V1;
|
|
22
|
+
id: string;
|
|
23
|
+
source: string;
|
|
24
|
+
type: string;
|
|
25
|
+
subject?: string;
|
|
26
|
+
time: string;
|
|
27
|
+
datacontenttype: 'application/json';
|
|
28
|
+
/** Immutable URI for the source-reviewed payload schema. Required because
|
|
29
|
+
* server acceptance is bound to a registered (type, dataschema) pair. */
|
|
30
|
+
dataschema: string;
|
|
31
|
+
data: TData;
|
|
32
|
+
traceparent?: string;
|
|
33
|
+
tracestate?: string;
|
|
34
|
+
[extension: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** A trace context is evidence correlation only; it is never authorization. */
|
|
37
|
+
interface SignalTraceContext {
|
|
38
|
+
traceparent: string;
|
|
39
|
+
tracestate?: string;
|
|
40
|
+
}
|
|
41
|
+
interface SignalEmitInput<TData extends JsonValue = JsonValue> {
|
|
42
|
+
/** Stable across a caller's retries. A UUID is generated when omitted. */
|
|
43
|
+
id?: string;
|
|
44
|
+
type: string;
|
|
45
|
+
subject?: string;
|
|
46
|
+
/** Defaults to the publisher's current UTC time. */
|
|
47
|
+
time?: string | Date;
|
|
48
|
+
/** Immutable schema URI registered for this Signal type. */
|
|
49
|
+
dataschema: string;
|
|
50
|
+
data: TData;
|
|
51
|
+
extensions?: SignalExtensions;
|
|
52
|
+
}
|
|
53
|
+
interface SignalValidationIssue {
|
|
54
|
+
path: string;
|
|
55
|
+
code: 'required' | 'type' | 'format' | 'value' | 'unsupported' | 'reserved_attribute' | 'unsafe_extension';
|
|
56
|
+
message: string;
|
|
57
|
+
}
|
|
58
|
+
interface SignalValidationSuccess<T> {
|
|
59
|
+
ok: true;
|
|
60
|
+
value: T;
|
|
61
|
+
}
|
|
62
|
+
interface SignalValidationFailure {
|
|
63
|
+
ok: false;
|
|
64
|
+
issues: SignalValidationIssue[];
|
|
65
|
+
}
|
|
66
|
+
type SignalValidationResult<T> = SignalValidationSuccess<T> | SignalValidationFailure;
|
|
67
|
+
declare class SignalContractError extends TypeError {
|
|
68
|
+
readonly issues: readonly SignalValidationIssue[];
|
|
69
|
+
constructor(message: string, issues: readonly SignalValidationIssue[]);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validates the generic public envelope only. Source credential binding,
|
|
73
|
+
* registered type/schema checks, redaction, quotas, and payload limits are
|
|
74
|
+
* server-owned policies and intentionally do not live in the publisher SDK.
|
|
75
|
+
*/
|
|
76
|
+
declare function validateSignalEnvelope<TData extends JsonValue = JsonValue>(input: unknown): SignalValidationResult<SignalEnvelope<TData>>;
|
|
77
|
+
declare function parseSignalEnvelope<TData extends JsonValue = JsonValue>(input: unknown): SignalEnvelope<TData>;
|
|
78
|
+
declare function createSignalEnvelope<TData extends JsonValue = JsonValue>(source: string, input: SignalEmitInput<TData>, traceContext?: SignalTraceContext): SignalEnvelope<TData>;
|
|
79
|
+
type SignalSourceTransport = 'sdk' | 'direct_api' | 'webhook' | 'oauth_connector' | 'otel' | 'pull_connector';
|
|
80
|
+
type SignalSourceStatus = 'active' | 'paused' | 'disabled';
|
|
81
|
+
type SignalCredentialKind = 'bearer_token' | 'webhook_hmac';
|
|
82
|
+
type SignalCredentialStatus = 'active' | 'revoked' | 'expired';
|
|
83
|
+
type SignalFieldDataType = 'string' | 'number' | 'integer' | 'boolean' | 'timestamp' | 'uri';
|
|
84
|
+
type SignalFieldClassification = 'filterable' | 'groupable' | 'displayable' | 'sensitive' | 'evidence_only';
|
|
85
|
+
type SignalCardinality = 'low' | 'bounded' | 'high';
|
|
86
|
+
/** A safe, schema-declared field. The field name is not an arbitrary JSONPath. */
|
|
87
|
+
interface SignalFieldDefinition {
|
|
88
|
+
name: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
dataType: SignalFieldDataType;
|
|
91
|
+
classifications: readonly SignalFieldClassification[];
|
|
92
|
+
required?: boolean;
|
|
93
|
+
cardinality: SignalCardinality;
|
|
94
|
+
maxLength?: number;
|
|
95
|
+
description?: string;
|
|
96
|
+
}
|
|
97
|
+
interface SignalTypeDefinition {
|
|
98
|
+
type: string;
|
|
99
|
+
dataschema: string;
|
|
100
|
+
displayName: string;
|
|
101
|
+
description: string;
|
|
102
|
+
subjectKinds: readonly string[];
|
|
103
|
+
fields: readonly SignalFieldDefinition[];
|
|
104
|
+
/** Existing Monitors pin to this range; breaking changes require a new type major. */
|
|
105
|
+
compatibility: 'backward_compatible_additions';
|
|
106
|
+
deprecatedAt?: string;
|
|
107
|
+
migrationGuide?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Size and shape limits applied to an accepted Signal. These are returned by
|
|
111
|
+
* the management API so a producer can adapt before the delivery endpoint
|
|
112
|
+
* rejects an oversized payload.
|
|
113
|
+
*/
|
|
114
|
+
interface SignalSchemaPolicy {
|
|
115
|
+
maxEventBytes: number;
|
|
116
|
+
maxDataBytes: number;
|
|
117
|
+
maxDataDepth: number;
|
|
118
|
+
maxDataFields: number;
|
|
119
|
+
}
|
|
120
|
+
/** The per-source delivery allowance enforced by the Signal API. */
|
|
121
|
+
interface SignalSourceRateLimit {
|
|
122
|
+
maxPerMinute: number;
|
|
123
|
+
}
|
|
124
|
+
/** The retention boundary advertised for normalized Signal records. */
|
|
125
|
+
interface SignalSourceRetentionPolicy {
|
|
126
|
+
normalizedSignalDays: number;
|
|
127
|
+
residency?: string;
|
|
128
|
+
}
|
|
129
|
+
interface PublicSignalSourcePolicy {
|
|
130
|
+
limits: SignalSchemaPolicy;
|
|
131
|
+
rateLimit: SignalSourceRateLimit;
|
|
132
|
+
redaction: {
|
|
133
|
+
additionalSensitiveKeys: readonly string[];
|
|
134
|
+
retainTracestate: boolean;
|
|
135
|
+
};
|
|
136
|
+
retention: SignalSourceRetentionPolicy;
|
|
137
|
+
}
|
|
138
|
+
/** Safe credential metadata returned by normal source reads. It never includes secret material. */
|
|
139
|
+
interface PublicSignalSourceCredential {
|
|
140
|
+
id: string;
|
|
141
|
+
credentialId: string;
|
|
142
|
+
sourceId: string;
|
|
143
|
+
kind: SignalCredentialKind;
|
|
144
|
+
status: SignalCredentialStatus;
|
|
145
|
+
label: string;
|
|
146
|
+
algorithm: 'bearer-token' | 'hmac-sha256';
|
|
147
|
+
notBefore: string;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
lastUsedAt?: string;
|
|
150
|
+
expiresAt?: string;
|
|
151
|
+
revokedAt?: string;
|
|
152
|
+
revokeReason?: string;
|
|
153
|
+
lastRotatedAt?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Secret material appears only on credential creation or rotation. Do not
|
|
157
|
+
* persist or log this object; retrieve future state through the public shape.
|
|
158
|
+
*/
|
|
159
|
+
interface SignalSourceCredentialGrant {
|
|
160
|
+
credential: PublicSignalSourceCredential;
|
|
161
|
+
secret: string;
|
|
162
|
+
secretKind: 'bearer_token' | 'webhook_hmac';
|
|
163
|
+
shownOnce: true;
|
|
164
|
+
}
|
|
165
|
+
interface PublicSignalSource {
|
|
166
|
+
sourceId: string;
|
|
167
|
+
workspaceId: string;
|
|
168
|
+
label: string;
|
|
169
|
+
cloudEventSource: string;
|
|
170
|
+
transport: SignalSourceTransport;
|
|
171
|
+
status: SignalSourceStatus;
|
|
172
|
+
typeDefinitions: readonly (SignalTypeDefinition & {
|
|
173
|
+
schemaVersion: string;
|
|
174
|
+
enabled: boolean;
|
|
175
|
+
})[];
|
|
176
|
+
credentialCount: number;
|
|
177
|
+
policy: PublicSignalSourcePolicy;
|
|
178
|
+
health: {
|
|
179
|
+
lastAcceptedAt?: string;
|
|
180
|
+
lastRejectedAt?: string;
|
|
181
|
+
lastErrorCode?: string;
|
|
182
|
+
};
|
|
183
|
+
createdAt: string;
|
|
184
|
+
updatedAt: string;
|
|
185
|
+
}
|
|
186
|
+
interface CreateSignalSourceResult {
|
|
187
|
+
source: PublicSignalSource;
|
|
188
|
+
credential?: SignalSourceCredentialGrant;
|
|
189
|
+
}
|
|
190
|
+
interface RotateSignalSourceCredentialResult {
|
|
191
|
+
credential: SignalSourceCredentialGrant;
|
|
192
|
+
}
|
|
193
|
+
declare function validateSignalTypeDefinition(input: unknown): SignalValidationResult<SignalTypeDefinition>;
|
|
194
|
+
declare function parseSignalTypeDefinition(input: unknown): SignalTypeDefinition;
|
|
195
|
+
|
|
196
|
+
interface SignalPublisherOptions {
|
|
197
|
+
/** The full ingestion URL, normally `https://api.oversky.ai/v1/signals`. */
|
|
198
|
+
endpoint: string;
|
|
199
|
+
/** The Signal Source's canonical CloudEvents source URI. */
|
|
200
|
+
source: string;
|
|
201
|
+
/** Source-scoped bearer token. Do not reuse a user API key. */
|
|
202
|
+
token: string;
|
|
203
|
+
fetch?: typeof globalThis.fetch;
|
|
204
|
+
timeoutMs?: number;
|
|
205
|
+
maxRetries?: number;
|
|
206
|
+
defaultHeaders?: Record<string, string>;
|
|
207
|
+
/** Optional bridge to OpenTelemetry or another W3C Trace Context provider. */
|
|
208
|
+
traceContextProvider?: () => SignalTraceContext | undefined;
|
|
209
|
+
}
|
|
210
|
+
interface SignalReceipt {
|
|
211
|
+
receiptId: string;
|
|
212
|
+
sourceId: string;
|
|
213
|
+
canonicalSource: string;
|
|
214
|
+
eventId: string;
|
|
215
|
+
outcome: 'accepted' | 'duplicate';
|
|
216
|
+
processingStatus: 'pending' | 'processing' | 'completed';
|
|
217
|
+
receivedAt: string;
|
|
218
|
+
requestId?: string;
|
|
219
|
+
}
|
|
220
|
+
interface SignalAPIErrorBody {
|
|
221
|
+
error?: {
|
|
222
|
+
code?: string;
|
|
223
|
+
message?: string;
|
|
224
|
+
details?: unknown;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
declare class SignalAPIError extends Error {
|
|
228
|
+
readonly status: number;
|
|
229
|
+
readonly code: string;
|
|
230
|
+
readonly requestId: string | null;
|
|
231
|
+
readonly details: unknown;
|
|
232
|
+
constructor(message: string, status: number, code: string, requestId: string | null, details?: unknown);
|
|
233
|
+
get isRetriable(): boolean;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* A generic, source-scoped publisher. It emits facts only; it cannot name a
|
|
237
|
+
* Monitor, Commitment, Agent, workspace, or execution policy.
|
|
238
|
+
*/
|
|
239
|
+
declare class SignalPublisher {
|
|
240
|
+
readonly endpoint: string;
|
|
241
|
+
readonly source: string;
|
|
242
|
+
readonly timeoutMs: number;
|
|
243
|
+
readonly maxRetries: number;
|
|
244
|
+
readonly defaultHeaders: Record<string, string>;
|
|
245
|
+
private readonly token;
|
|
246
|
+
private readonly fetchImplementation;
|
|
247
|
+
private readonly traceContextProvider?;
|
|
248
|
+
constructor(options: SignalPublisherOptions);
|
|
249
|
+
create<TData extends JsonValue>(input: SignalEmitInput<TData>): SignalEnvelope<TData>;
|
|
250
|
+
emit<TData extends JsonValue>(input: SignalEmitInput<TData>): Promise<SignalReceipt>;
|
|
251
|
+
publish<TData extends JsonValue>(event: SignalEnvelope<TData>): Promise<SignalReceipt>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export { type CreateSignalSourceResult, type JsonObject, type JsonPrimitive, type JsonValue, type PublicSignalSource, type PublicSignalSourceCredential, type RotateSignalSourceCredentialResult, SIGNAL_API_VERSION, SIGNAL_CLOUDEVENTS_CONTENT_TYPE, SignalAPIError, type SignalAPIErrorBody, type SignalCardinality, SignalContractError, type SignalCredentialKind, type SignalCredentialStatus, type SignalEmitInput, type SignalEnvelope, type SignalExtensions, type SignalFieldClassification, type SignalFieldDataType, type SignalFieldDefinition, SignalPublisher, type SignalPublisherOptions, type SignalReceipt, type SignalSchemaPolicy, type SignalSourceCredentialGrant, type SignalSourceRateLimit, type SignalSourceRetentionPolicy, type SignalSourceStatus, type SignalSourceTransport, type SignalTraceContext, type SignalTypeDefinition, type SignalValidationFailure, type SignalValidationIssue, type SignalValidationResult, type SignalValidationSuccess, createSignalEnvelope, parseSignalEnvelope, parseSignalTypeDefinition, validateSignalEnvelope, validateSignalTypeDefinition };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/** CloudEvents structured-mode media type accepted by the Signal API. */
|
|
2
|
+
declare const SIGNAL_CLOUDEVENTS_CONTENT_TYPE = "application/cloudevents+json";
|
|
3
|
+
declare const SIGNAL_API_VERSION = "v1";
|
|
4
|
+
declare const CLOUD_EVENTS_V1: "1.0";
|
|
5
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
6
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
7
|
+
interface JsonObject {
|
|
8
|
+
[key: string]: JsonValue;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extension attributes are intentionally limited to normal CloudEvents extension
|
|
12
|
+
* names. They cannot carry source identity, authorization, Monitor, Commitment,
|
|
13
|
+
* or Agent selection data.
|
|
14
|
+
*/
|
|
15
|
+
type SignalExtensions = Record<string, JsonPrimitive>;
|
|
16
|
+
/**
|
|
17
|
+
* The public v1 Signal envelope. It is CloudEvents 1.0 in structured JSON mode.
|
|
18
|
+
* `source + id` is the occurrence identity used for deduplication.
|
|
19
|
+
*/
|
|
20
|
+
interface SignalEnvelope<TData extends JsonValue = JsonValue> {
|
|
21
|
+
specversion: typeof CLOUD_EVENTS_V1;
|
|
22
|
+
id: string;
|
|
23
|
+
source: string;
|
|
24
|
+
type: string;
|
|
25
|
+
subject?: string;
|
|
26
|
+
time: string;
|
|
27
|
+
datacontenttype: 'application/json';
|
|
28
|
+
/** Immutable URI for the source-reviewed payload schema. Required because
|
|
29
|
+
* server acceptance is bound to a registered (type, dataschema) pair. */
|
|
30
|
+
dataschema: string;
|
|
31
|
+
data: TData;
|
|
32
|
+
traceparent?: string;
|
|
33
|
+
tracestate?: string;
|
|
34
|
+
[extension: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** A trace context is evidence correlation only; it is never authorization. */
|
|
37
|
+
interface SignalTraceContext {
|
|
38
|
+
traceparent: string;
|
|
39
|
+
tracestate?: string;
|
|
40
|
+
}
|
|
41
|
+
interface SignalEmitInput<TData extends JsonValue = JsonValue> {
|
|
42
|
+
/** Stable across a caller's retries. A UUID is generated when omitted. */
|
|
43
|
+
id?: string;
|
|
44
|
+
type: string;
|
|
45
|
+
subject?: string;
|
|
46
|
+
/** Defaults to the publisher's current UTC time. */
|
|
47
|
+
time?: string | Date;
|
|
48
|
+
/** Immutable schema URI registered for this Signal type. */
|
|
49
|
+
dataschema: string;
|
|
50
|
+
data: TData;
|
|
51
|
+
extensions?: SignalExtensions;
|
|
52
|
+
}
|
|
53
|
+
interface SignalValidationIssue {
|
|
54
|
+
path: string;
|
|
55
|
+
code: 'required' | 'type' | 'format' | 'value' | 'unsupported' | 'reserved_attribute' | 'unsafe_extension';
|
|
56
|
+
message: string;
|
|
57
|
+
}
|
|
58
|
+
interface SignalValidationSuccess<T> {
|
|
59
|
+
ok: true;
|
|
60
|
+
value: T;
|
|
61
|
+
}
|
|
62
|
+
interface SignalValidationFailure {
|
|
63
|
+
ok: false;
|
|
64
|
+
issues: SignalValidationIssue[];
|
|
65
|
+
}
|
|
66
|
+
type SignalValidationResult<T> = SignalValidationSuccess<T> | SignalValidationFailure;
|
|
67
|
+
declare class SignalContractError extends TypeError {
|
|
68
|
+
readonly issues: readonly SignalValidationIssue[];
|
|
69
|
+
constructor(message: string, issues: readonly SignalValidationIssue[]);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validates the generic public envelope only. Source credential binding,
|
|
73
|
+
* registered type/schema checks, redaction, quotas, and payload limits are
|
|
74
|
+
* server-owned policies and intentionally do not live in the publisher SDK.
|
|
75
|
+
*/
|
|
76
|
+
declare function validateSignalEnvelope<TData extends JsonValue = JsonValue>(input: unknown): SignalValidationResult<SignalEnvelope<TData>>;
|
|
77
|
+
declare function parseSignalEnvelope<TData extends JsonValue = JsonValue>(input: unknown): SignalEnvelope<TData>;
|
|
78
|
+
declare function createSignalEnvelope<TData extends JsonValue = JsonValue>(source: string, input: SignalEmitInput<TData>, traceContext?: SignalTraceContext): SignalEnvelope<TData>;
|
|
79
|
+
type SignalSourceTransport = 'sdk' | 'direct_api' | 'webhook' | 'oauth_connector' | 'otel' | 'pull_connector';
|
|
80
|
+
type SignalSourceStatus = 'active' | 'paused' | 'disabled';
|
|
81
|
+
type SignalCredentialKind = 'bearer_token' | 'webhook_hmac';
|
|
82
|
+
type SignalCredentialStatus = 'active' | 'revoked' | 'expired';
|
|
83
|
+
type SignalFieldDataType = 'string' | 'number' | 'integer' | 'boolean' | 'timestamp' | 'uri';
|
|
84
|
+
type SignalFieldClassification = 'filterable' | 'groupable' | 'displayable' | 'sensitive' | 'evidence_only';
|
|
85
|
+
type SignalCardinality = 'low' | 'bounded' | 'high';
|
|
86
|
+
/** A safe, schema-declared field. The field name is not an arbitrary JSONPath. */
|
|
87
|
+
interface SignalFieldDefinition {
|
|
88
|
+
name: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
dataType: SignalFieldDataType;
|
|
91
|
+
classifications: readonly SignalFieldClassification[];
|
|
92
|
+
required?: boolean;
|
|
93
|
+
cardinality: SignalCardinality;
|
|
94
|
+
maxLength?: number;
|
|
95
|
+
description?: string;
|
|
96
|
+
}
|
|
97
|
+
interface SignalTypeDefinition {
|
|
98
|
+
type: string;
|
|
99
|
+
dataschema: string;
|
|
100
|
+
displayName: string;
|
|
101
|
+
description: string;
|
|
102
|
+
subjectKinds: readonly string[];
|
|
103
|
+
fields: readonly SignalFieldDefinition[];
|
|
104
|
+
/** Existing Monitors pin to this range; breaking changes require a new type major. */
|
|
105
|
+
compatibility: 'backward_compatible_additions';
|
|
106
|
+
deprecatedAt?: string;
|
|
107
|
+
migrationGuide?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Size and shape limits applied to an accepted Signal. These are returned by
|
|
111
|
+
* the management API so a producer can adapt before the delivery endpoint
|
|
112
|
+
* rejects an oversized payload.
|
|
113
|
+
*/
|
|
114
|
+
interface SignalSchemaPolicy {
|
|
115
|
+
maxEventBytes: number;
|
|
116
|
+
maxDataBytes: number;
|
|
117
|
+
maxDataDepth: number;
|
|
118
|
+
maxDataFields: number;
|
|
119
|
+
}
|
|
120
|
+
/** The per-source delivery allowance enforced by the Signal API. */
|
|
121
|
+
interface SignalSourceRateLimit {
|
|
122
|
+
maxPerMinute: number;
|
|
123
|
+
}
|
|
124
|
+
/** The retention boundary advertised for normalized Signal records. */
|
|
125
|
+
interface SignalSourceRetentionPolicy {
|
|
126
|
+
normalizedSignalDays: number;
|
|
127
|
+
residency?: string;
|
|
128
|
+
}
|
|
129
|
+
interface PublicSignalSourcePolicy {
|
|
130
|
+
limits: SignalSchemaPolicy;
|
|
131
|
+
rateLimit: SignalSourceRateLimit;
|
|
132
|
+
redaction: {
|
|
133
|
+
additionalSensitiveKeys: readonly string[];
|
|
134
|
+
retainTracestate: boolean;
|
|
135
|
+
};
|
|
136
|
+
retention: SignalSourceRetentionPolicy;
|
|
137
|
+
}
|
|
138
|
+
/** Safe credential metadata returned by normal source reads. It never includes secret material. */
|
|
139
|
+
interface PublicSignalSourceCredential {
|
|
140
|
+
id: string;
|
|
141
|
+
credentialId: string;
|
|
142
|
+
sourceId: string;
|
|
143
|
+
kind: SignalCredentialKind;
|
|
144
|
+
status: SignalCredentialStatus;
|
|
145
|
+
label: string;
|
|
146
|
+
algorithm: 'bearer-token' | 'hmac-sha256';
|
|
147
|
+
notBefore: string;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
lastUsedAt?: string;
|
|
150
|
+
expiresAt?: string;
|
|
151
|
+
revokedAt?: string;
|
|
152
|
+
revokeReason?: string;
|
|
153
|
+
lastRotatedAt?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Secret material appears only on credential creation or rotation. Do not
|
|
157
|
+
* persist or log this object; retrieve future state through the public shape.
|
|
158
|
+
*/
|
|
159
|
+
interface SignalSourceCredentialGrant {
|
|
160
|
+
credential: PublicSignalSourceCredential;
|
|
161
|
+
secret: string;
|
|
162
|
+
secretKind: 'bearer_token' | 'webhook_hmac';
|
|
163
|
+
shownOnce: true;
|
|
164
|
+
}
|
|
165
|
+
interface PublicSignalSource {
|
|
166
|
+
sourceId: string;
|
|
167
|
+
workspaceId: string;
|
|
168
|
+
label: string;
|
|
169
|
+
cloudEventSource: string;
|
|
170
|
+
transport: SignalSourceTransport;
|
|
171
|
+
status: SignalSourceStatus;
|
|
172
|
+
typeDefinitions: readonly (SignalTypeDefinition & {
|
|
173
|
+
schemaVersion: string;
|
|
174
|
+
enabled: boolean;
|
|
175
|
+
})[];
|
|
176
|
+
credentialCount: number;
|
|
177
|
+
policy: PublicSignalSourcePolicy;
|
|
178
|
+
health: {
|
|
179
|
+
lastAcceptedAt?: string;
|
|
180
|
+
lastRejectedAt?: string;
|
|
181
|
+
lastErrorCode?: string;
|
|
182
|
+
};
|
|
183
|
+
createdAt: string;
|
|
184
|
+
updatedAt: string;
|
|
185
|
+
}
|
|
186
|
+
interface CreateSignalSourceResult {
|
|
187
|
+
source: PublicSignalSource;
|
|
188
|
+
credential?: SignalSourceCredentialGrant;
|
|
189
|
+
}
|
|
190
|
+
interface RotateSignalSourceCredentialResult {
|
|
191
|
+
credential: SignalSourceCredentialGrant;
|
|
192
|
+
}
|
|
193
|
+
declare function validateSignalTypeDefinition(input: unknown): SignalValidationResult<SignalTypeDefinition>;
|
|
194
|
+
declare function parseSignalTypeDefinition(input: unknown): SignalTypeDefinition;
|
|
195
|
+
|
|
196
|
+
interface SignalPublisherOptions {
|
|
197
|
+
/** The full ingestion URL, normally `https://api.oversky.ai/v1/signals`. */
|
|
198
|
+
endpoint: string;
|
|
199
|
+
/** The Signal Source's canonical CloudEvents source URI. */
|
|
200
|
+
source: string;
|
|
201
|
+
/** Source-scoped bearer token. Do not reuse a user API key. */
|
|
202
|
+
token: string;
|
|
203
|
+
fetch?: typeof globalThis.fetch;
|
|
204
|
+
timeoutMs?: number;
|
|
205
|
+
maxRetries?: number;
|
|
206
|
+
defaultHeaders?: Record<string, string>;
|
|
207
|
+
/** Optional bridge to OpenTelemetry or another W3C Trace Context provider. */
|
|
208
|
+
traceContextProvider?: () => SignalTraceContext | undefined;
|
|
209
|
+
}
|
|
210
|
+
interface SignalReceipt {
|
|
211
|
+
receiptId: string;
|
|
212
|
+
sourceId: string;
|
|
213
|
+
canonicalSource: string;
|
|
214
|
+
eventId: string;
|
|
215
|
+
outcome: 'accepted' | 'duplicate';
|
|
216
|
+
processingStatus: 'pending' | 'processing' | 'completed';
|
|
217
|
+
receivedAt: string;
|
|
218
|
+
requestId?: string;
|
|
219
|
+
}
|
|
220
|
+
interface SignalAPIErrorBody {
|
|
221
|
+
error?: {
|
|
222
|
+
code?: string;
|
|
223
|
+
message?: string;
|
|
224
|
+
details?: unknown;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
declare class SignalAPIError extends Error {
|
|
228
|
+
readonly status: number;
|
|
229
|
+
readonly code: string;
|
|
230
|
+
readonly requestId: string | null;
|
|
231
|
+
readonly details: unknown;
|
|
232
|
+
constructor(message: string, status: number, code: string, requestId: string | null, details?: unknown);
|
|
233
|
+
get isRetriable(): boolean;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* A generic, source-scoped publisher. It emits facts only; it cannot name a
|
|
237
|
+
* Monitor, Commitment, Agent, workspace, or execution policy.
|
|
238
|
+
*/
|
|
239
|
+
declare class SignalPublisher {
|
|
240
|
+
readonly endpoint: string;
|
|
241
|
+
readonly source: string;
|
|
242
|
+
readonly timeoutMs: number;
|
|
243
|
+
readonly maxRetries: number;
|
|
244
|
+
readonly defaultHeaders: Record<string, string>;
|
|
245
|
+
private readonly token;
|
|
246
|
+
private readonly fetchImplementation;
|
|
247
|
+
private readonly traceContextProvider?;
|
|
248
|
+
constructor(options: SignalPublisherOptions);
|
|
249
|
+
create<TData extends JsonValue>(input: SignalEmitInput<TData>): SignalEnvelope<TData>;
|
|
250
|
+
emit<TData extends JsonValue>(input: SignalEmitInput<TData>): Promise<SignalReceipt>;
|
|
251
|
+
publish<TData extends JsonValue>(event: SignalEnvelope<TData>): Promise<SignalReceipt>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export { type CreateSignalSourceResult, type JsonObject, type JsonPrimitive, type JsonValue, type PublicSignalSource, type PublicSignalSourceCredential, type RotateSignalSourceCredentialResult, SIGNAL_API_VERSION, SIGNAL_CLOUDEVENTS_CONTENT_TYPE, SignalAPIError, type SignalAPIErrorBody, type SignalCardinality, SignalContractError, type SignalCredentialKind, type SignalCredentialStatus, type SignalEmitInput, type SignalEnvelope, type SignalExtensions, type SignalFieldClassification, type SignalFieldDataType, type SignalFieldDefinition, SignalPublisher, type SignalPublisherOptions, type SignalReceipt, type SignalSchemaPolicy, type SignalSourceCredentialGrant, type SignalSourceRateLimit, type SignalSourceRetentionPolicy, type SignalSourceStatus, type SignalSourceTransport, type SignalTraceContext, type SignalTypeDefinition, type SignalValidationFailure, type SignalValidationIssue, type SignalValidationResult, type SignalValidationSuccess, createSignalEnvelope, parseSignalEnvelope, parseSignalTypeDefinition, validateSignalEnvelope, validateSignalTypeDefinition };
|