@geoly-ai/social-hub-sdk 0.0.44 → 0.0.46

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.d.ts CHANGED
@@ -283,6 +283,103 @@ export type ScheduleCommentDraftBody = {
283
283
  runAt: string;
284
284
  windowMinutes?: number;
285
285
  };
286
+ export type DeliveryBundleStatusLike = "open" | "closed" | "cancelled";
287
+ /** 客户面列 bundle:brandId 服务端**必填**(客户按 brand 收窄);SDK 类型强制。 */
288
+ export type ListClientDeliveryBundlesParams = {
289
+ brandId: string;
290
+ status?: DeliveryBundleStatusLike;
291
+ limit?: number;
292
+ offset?: number;
293
+ };
294
+ /** staff 建 bundle。 */
295
+ export type CreateClientDeliveryBundleBody = {
296
+ brandId: string;
297
+ bundleCode: string;
298
+ name: string;
299
+ clientDueAt?: string | null;
300
+ };
301
+ /** staff upsert item(帖/评 + 矩阵规划字段)。 */
302
+ export type UpsertClientDeliveryItemBody = {
303
+ kind: "post" | "comment";
304
+ itemCode: string;
305
+ contentDraftId?: string | null;
306
+ commentDraftId?: string | null;
307
+ ordinal?: number;
308
+ boundProductId?: string | null;
309
+ primaryPostType?: string[] | null;
310
+ writingVariant?: string | null;
311
+ structureFamily?: string | null;
312
+ contentFunction?: string | null;
313
+ functionDetail?: string | null;
314
+ brandEntryMode?: string | null;
315
+ anchorSlot?: string | null;
316
+ mappingRuleId?: string | null;
317
+ vocabularyVersion?: string | null;
318
+ };
319
+ /** staff 送审 revision(note 可选)。 */
320
+ export type SubmitClientDeliveryRevisionBody = {
321
+ note?: string;
322
+ };
323
+ export type ClientDeliveryInventoryStatus = "in_stock" | "low_stock" | "out_of_stock" | "preorder" | "discontinued" | "unknown";
324
+ /** 产品事实版本 body(客户面:正文/draft 字段物理不接受;仅事实)。 */
325
+ export type ClientDeliveryFactVersionBody = {
326
+ positioning?: string | null;
327
+ materials?: string | null;
328
+ priceAmount?: string | null;
329
+ priceCurrency?: string | null;
330
+ inventoryStatus?: ClientDeliveryInventoryStatus | null;
331
+ inventoryAsOf?: string | null;
332
+ shippingDaysMin?: number | null;
333
+ shippingDaysMax?: number | null;
334
+ factsJson?: Record<string, string | number | boolean | null>;
335
+ effectiveAt?: string | null;
336
+ expiresAt?: string | null;
337
+ sourceRef?: string | null;
338
+ };
339
+ /** staff 事实版本 body:额外可指定 provenance(默认 staff)。 */
340
+ export type StaffClientDeliveryFactVersionBody = ClientDeliveryFactVersionBody & {
341
+ provenance?: "client" | "staff" | "import";
342
+ };
343
+ /** staff 建产品身份。 */
344
+ export type CreateClientDeliveryProductBody = {
345
+ brandId: string;
346
+ sku: string;
347
+ brandRegistryId?: string | null;
348
+ modelName?: string | null;
349
+ market?: string | null;
350
+ status?: string;
351
+ };
352
+ /** staff 建品牌内容政策版本。 */
353
+ export type CreateClientDeliveryPolicyVersionBody = {
354
+ brandId: string;
355
+ market?: string | null;
356
+ provenance?: "client" | "staff" | "import";
357
+ policyJson?: Record<string, unknown>;
358
+ effectiveAt?: string | null;
359
+ };
360
+ /** 字段级评论(request-changes 内嵌 / 独立讨论)。 */
361
+ export type ClientDeliveryDecisionComment = {
362
+ fieldKey: string;
363
+ quotedText?: string;
364
+ body: string;
365
+ };
366
+ /** 客户批准(CAS:expectedRevisionHash)。 */
367
+ export type ApproveClientDeliveryRevisionBody = {
368
+ expectedRevisionHash: string;
369
+ note?: string;
370
+ };
371
+ /** 客户请求修改(CAS + 字段级评论,至少一条)。 */
372
+ export type RequestChangesClientDeliveryRevisionBody = {
373
+ expectedRevisionHash: string;
374
+ comments: ClientDeliveryDecisionComment[];
375
+ note?: string;
376
+ };
377
+ /** 客户字段级讨论评论。 */
378
+ export type AddClientDeliveryCommentBody = {
379
+ fieldKey: string;
380
+ quotedText?: string;
381
+ body: string;
382
+ };
286
383
  export type UpdateNotificationChannelBody = {
287
384
  provider?: string;
288
385
  externalId?: string;
@@ -416,6 +513,30 @@ export declare class RegistryProposalSdkError extends Error {
416
513
  constructor(status: number, code: string | undefined, staleCode: string | undefined, message: string);
417
514
  get isStale(): boolean;
418
515
  }
516
+ /**
517
+ * Hub API 的结构化 HTTP 错误。
518
+ *
519
+ * `message` 保持与历史一致(`HTTP <status>: <message>`),所以既有 `catch (e) { e.message }`
520
+ * 的调用方不受影响;新增的 `status` / `code` / `details` 让调用方(尤其是要把服务端错误
521
+ * 映射成**退出码**的 CLI)不必 regex 解析 message。
522
+ *
523
+ * `retryAfterSeconds` 取自 `Retry-After` 响应头(仅当其为整数秒时)。
524
+ */
525
+ export declare class SocialHubHttpError extends Error {
526
+ readonly status: number;
527
+ readonly code?: string;
528
+ readonly details?: unknown;
529
+ readonly retryAfterSeconds?: number;
530
+ readonly body?: string;
531
+ constructor(args: {
532
+ status: number;
533
+ message: string;
534
+ code?: string;
535
+ details?: unknown;
536
+ retryAfterSeconds?: number;
537
+ body?: string;
538
+ });
539
+ }
419
540
  export declare class SocialHubClient {
420
541
  private readonly opts;
421
542
  constructor(opts: SocialHubClientOptions);
@@ -487,6 +608,19 @@ export declare class SocialHubClient {
487
608
  ok: boolean;
488
609
  warning?: string;
489
610
  }>;
611
+ /**
612
+ * 归属桶(teams.kind='bucket':未配置/外部)。这些团队没有 membership、不出现
613
+ * 在 `listTeams()` 里,所以外部来源帖要回填进桶就只能先从这里拿到 UUID,
614
+ * 再把它当 `teamId` 传给 createRedditPostSnapshot / batchUpsertRedditPostSnapshots。
615
+ */
616
+ listRedditPostTeamBuckets(): Promise<{
617
+ items: Array<{
618
+ id: string;
619
+ slug: string;
620
+ name: string;
621
+ kind: string;
622
+ }>;
623
+ }>;
490
624
  listRedditPostSnapshots(teamId: string, params?: ListRedditPostSnapshotsParams): Promise<{
491
625
  items: unknown[];
492
626
  total?: number;
@@ -650,6 +784,101 @@ export declare class SocialHubClient {
650
784
  /** BullMQ 入队失败时的告警(job 仍 scheduled,可被 ops 领)。 */
651
785
  warning?: string;
652
786
  }>;
787
+ private clientDeliveryBase;
788
+ /** GET client-delivery/bundles?brandId=(必填)&status=&limit=&offset= — 客户面 bundle 列表。 */
789
+ clientDeliveryListBundles(teamId: string, params: ListClientDeliveryBundlesParams): Promise<{
790
+ items: unknown[];
791
+ }>;
792
+ /** GET client-delivery/bundles/:id — 单个 bundle(client 视图脱敏 / staff 完整)。 */
793
+ clientDeliveryGetBundle(teamId: string, bundleId: string): Promise<unknown>;
794
+ /** GET client-delivery/bundles/:id/items — bundle 下条目列表。 */
795
+ clientDeliveryListItems(teamId: string, bundleId: string): Promise<{
796
+ items: unknown[];
797
+ }>;
798
+ /** GET client-delivery/items/:id — 单个条目。 */
799
+ clientDeliveryGetItem(teamId: string, itemId: string): Promise<unknown>;
800
+ /** GET client-delivery/items/:id/revisions — 条目下 revision 列表。 */
801
+ clientDeliveryListRevisions(teamId: string, itemId: string): Promise<{
802
+ items: unknown[];
803
+ }>;
804
+ /** GET client-delivery/revisions/:id — 单个 revision(含 sourceContentHash 作 CAS 凭证)。 */
805
+ clientDeliveryGetRevision(teamId: string, revisionId: string): Promise<unknown>;
806
+ /** GET client-delivery/revisions/:id/comments — revision 字段级评论列表。 */
807
+ clientDeliveryListComments(teamId: string, revisionId: string): Promise<{
808
+ items: unknown[];
809
+ }>;
810
+ /** GET client-delivery/revisions/:id/events — revision 决策事件链(append-only)。 */
811
+ clientDeliveryListEvents(teamId: string, revisionId: string): Promise<{
812
+ items: unknown[];
813
+ }>;
814
+ /**
815
+ * POST client-delivery/revisions/:id/approve — 客户批准(CAS)。expectedRevisionHash 与服务端
816
+ * 当前 revision hash 不符 → 409(SDK 透传为 `HTTP 409:` Error);须 user 凭证(拒 api_key)。
817
+ */
818
+ clientDeliveryApproveRevision(teamId: string, revisionId: string, body: ApproveClientDeliveryRevisionBody): Promise<{
819
+ revision: unknown;
820
+ }>;
821
+ /**
822
+ * POST client-delivery/revisions/:id/request-changes — 客户请求修改 + 字段级评论(CAS)。
823
+ * hash 不符 → 409;须 user 凭证。
824
+ */
825
+ clientDeliveryRequestChanges(teamId: string, revisionId: string, body: RequestChangesClientDeliveryRevisionBody): Promise<{
826
+ revision: unknown;
827
+ }>;
828
+ /** POST client-delivery/revisions/:id/comments — 客户字段级讨论(非决策);须 user 凭证。 */
829
+ clientDeliveryAddComment(teamId: string, revisionId: string, body: AddClientDeliveryCommentBody): Promise<{
830
+ comment: unknown;
831
+ }>;
832
+ /** POST client-delivery/comments/:id/resolve — 客户关闭讨论(幂等);须 user 凭证。 */
833
+ clientDeliveryResolveComment(teamId: string, commentId: string): Promise<{
834
+ comment: unknown;
835
+ }>;
836
+ /**
837
+ * POST client-delivery/products/:productId/fact-versions(**客户面**)— 客户提交产品事实版本。
838
+ * provenance 服务端强制 'client';正文/draft 字段物理不接受。须 user 凭证。
839
+ */
840
+ clientDeliveryCreateClientFactVersion(teamId: string, productId: string, body: ClientDeliveryFactVersionBody): Promise<{
841
+ factVersion: unknown;
842
+ }>;
843
+ /** POST client-delivery/bundles — staff 建 bundle。 */
844
+ clientDeliveryCreateBundle(teamId: string, body: CreateClientDeliveryBundleBody): Promise<{
845
+ bundle: unknown;
846
+ }>;
847
+ /** POST client-delivery/bundles/:id/items — staff upsert 条目(帖/评 + 矩阵字段)。 */
848
+ clientDeliveryUpsertItem(teamId: string, bundleId: string, body: UpsertClientDeliveryItemBody): Promise<{
849
+ item: unknown;
850
+ }>;
851
+ /** POST client-delivery/items/:id/revisions — staff 建不可变送审快照(无 body)。 */
852
+ clientDeliveryCreateRevision(teamId: string, itemId: string): Promise<{
853
+ revision: unknown;
854
+ }>;
855
+ /** POST client-delivery/revisions/:id/submit — staff 送审(not_submitted|withdrawn → pending)。 */
856
+ clientDeliverySubmitRevision(teamId: string, revisionId: string, body?: SubmitClientDeliveryRevisionBody): Promise<{
857
+ revision: unknown;
858
+ }>;
859
+ /** POST client-delivery/products — staff 建产品身份。 */
860
+ clientDeliveryCreateProduct(teamId: string, body: CreateClientDeliveryProductBody): Promise<{
861
+ product: unknown;
862
+ }>;
863
+ /**
864
+ * POST client-delivery/products/:productId/fact-versions(**staff 面**)— staff 提交事实版本。
865
+ * provenance 由 body 决定(默认 staff)。须 user 凭证。
866
+ */
867
+ clientDeliveryCreateFactVersion(teamId: string, productId: string, body: StaffClientDeliveryFactVersionBody): Promise<{
868
+ factVersion: unknown;
869
+ }>;
870
+ /** POST client-delivery/products/:productId/fact-versions/:fvId/activate — staff 激活 + stale 传播。 */
871
+ clientDeliveryActivateFactVersion(teamId: string, productId: string, factVersionId: string): Promise<{
872
+ factVersion: unknown;
873
+ }>;
874
+ /** POST client-delivery/policy-versions — staff 建品牌内容政策版本。 */
875
+ clientDeliveryCreatePolicyVersion(teamId: string, body: CreateClientDeliveryPolicyVersionBody): Promise<{
876
+ policyVersion: unknown;
877
+ }>;
878
+ /** POST client-delivery/policy-versions/:id/activate — staff 激活政策版本。 */
879
+ clientDeliveryActivatePolicyVersion(teamId: string, policyVersionId: string): Promise<{
880
+ policyVersion: unknown;
881
+ }>;
653
882
  listReports(teamId: string, options?: ListReportsParams | number): Promise<{
654
883
  items: unknown[];
655
884
  }>;
@@ -1991,5 +2220,308 @@ export declare class SocialHubClient {
1991
2220
  count: number;
1992
2221
  runs: unknown[];
1993
2222
  }>;
2223
+ private subscriptionsBase;
2224
+ private eventsBase;
2225
+ private sourcesBase;
2226
+ /**
2227
+ * GET .../notification-subscriptions
2228
+ * 非 manager/admin 只看得到自己拥有(`ownerUserId`)的订阅 —— 别人机器的消费位点
2229
+ * 露出来只会诱发误 ack。
2230
+ */
2231
+ listNotificationSubscriptions(teamId: string, params?: {
2232
+ status?: NotificationSubscriptionStatus;
2233
+ sourceId?: string;
2234
+ /** 常驻消费方解析订阅名时传入,便于 Ctrl-C 立即中断。 */
2235
+ signal?: AbortSignal;
2236
+ }): Promise<{
2237
+ items: NotificationSubscriptionDto[];
2238
+ }>;
2239
+ /** GET .../notification-subscriptions/:id —— 返回**裸** subscription(无包装)。 */
2240
+ getNotificationSubscription(teamId: string, subscriptionId: string,
2241
+ /** 常驻消费方轮询游标时传入,便于 Ctrl-C 立即中断。 */
2242
+ opts?: {
2243
+ signal?: AbortSignal;
2244
+ }): Promise<NotificationSubscriptionDto>;
2245
+ /** POST .../notification-subscriptions(201,裸 subscription)。 */
2246
+ createNotificationSubscription(teamId: string, body: CreateNotificationSubscriptionSdkBody): Promise<NotificationSubscriptionDto>;
2247
+ /**
2248
+ * PATCH .../notification-subscriptions/:id —— 乐观锁 CAS(`expectedRowVersion` 必填)。
2249
+ * `status` 只能是 active|paused;pause/resume 另有语义化捷径端点(走同一把锁)。
2250
+ */
2251
+ updateNotificationSubscription(teamId: string, subscriptionId: string, body: UpdateNotificationSubscriptionSdkBody): Promise<NotificationSubscriptionDto>;
2252
+ /**
2253
+ * POST .../notification-subscriptions/:id/pause|resume。
2254
+ * `expectedRowVersion` 可省(服务端用当前值),显式传则是真 CAS。
2255
+ */
2256
+ setNotificationSubscriptionPaused(teamId: string, subscriptionId: string, paused: boolean, body?: {
2257
+ expectedRowVersion?: number;
2258
+ }): Promise<NotificationSubscriptionDto>;
2259
+ /** DELETE .../notification-subscriptions/:id —— 软删(保留审计),**204 无响应体**。 */
2260
+ deleteNotificationSubscription(teamId: string, subscriptionId: string): Promise<void>;
2261
+ /**
2262
+ * POST .../notification-subscriptions/:id/reset —— 重设游标起点(stale 恢复的唯一出口)。
2263
+ * `startPosition` 与 `cursorSeq` **互斥**;后者是运维手工修复面,服务端会 clamp 在
2264
+ * `[floor - 1, latestSeq]`。reset 会 bump `receiptEpoch`,作废全部在途 receipt。
2265
+ *
2266
+ * ⚠️ `expectedRowVersion` **必填**:reset 是破坏性写,服务端做真 CAS,冲突返回
2267
+ * `409 SUBSCRIPTION_ROW_VERSION_CONFLICT`。调用前先 GET 订阅拿当前 `rowVersion`。
2268
+ *
2269
+ * ⚠️ reset **不是** resume:`paused` 订阅 reset 后**仍是** paused;只有 `stale`
2270
+ * 会被恢复成 `active`。
2271
+ */
2272
+ resetNotificationSubscriptionCursor(teamId: string, subscriptionId: string, body: {
2273
+ expectedRowVersion: number;
2274
+ startPosition?: NotificationSubscriptionStartPosition;
2275
+ cursorSeq?: string;
2276
+ }): Promise<NotificationSubscriptionDto>;
2277
+ /**
2278
+ * POST .../notification-events/pull —— long-poll 拉事件。**幂等**:不推进游标。
2279
+ *
2280
+ * `limit` 默认 1:游标是**连续 watermark**(`cursorSeq = N` 表示 seq ≤ N 的匹配事件均已完成),
2281
+ * 一次拉 N 条却只在中间某条失败,就无法安全 ack 其后的任何一条。
2282
+ */
2283
+ pullNotificationEvents(teamId: string, body: {
2284
+ subscriptionId: string;
2285
+ /** 1..50,默认 1。 */
2286
+ limit?: number;
2287
+ /** 0..30 秒;0 = 立即返回(可能空)。 */
2288
+ waitSeconds?: number;
2289
+ },
2290
+ /** long-poll 可能挂满 30 秒;常驻消费方必须能被 Ctrl-C 立即中断。 */
2291
+ opts?: {
2292
+ signal?: AbortSignal;
2293
+ }): Promise<NotificationPullResponseDto>;
2294
+ /**
2295
+ * POST .../notification-events/ack —— 推进连续 watermark。
2296
+ * 语义是「本订阅所有匹配事件中 seq ≤ throughSeq 的**均已完成**」,**不是**执行回执。
2297
+ * 409 `SUBSCRIPTION_CURSOR_CONFLICT` = CAS 冲突(含重放);410 = 游标已过保留 floor。
2298
+ */
2299
+ ackNotificationCursor(teamId: string, body: {
2300
+ subscriptionId: string;
2301
+ expectedCursorSeq: string;
2302
+ throughSeq: string;
2303
+ receipt: NotificationPullReceiptDto;
2304
+ }): Promise<{
2305
+ subscriptionId: string;
2306
+ cursorSeq: string;
2307
+ }>;
2308
+ /** GET .../notification-events —— 运维列表(**元数据摘要**,不含 payload)。 */
2309
+ listNotificationEvents(teamId: string, params?: {
2310
+ afterSeq?: string;
2311
+ sourceId?: string;
2312
+ limit?: number;
2313
+ }): Promise<{
2314
+ items: NotificationEventSummaryDto[];
2315
+ latestSeq: string;
2316
+ earliestAvailableSeq: string;
2317
+ }>;
2318
+ /** GET .../notification-events/:seq —— 单条完整 envelope(按事件行冻结的权限重验)。 */
2319
+ getNotificationEventBySeq(teamId: string, seq: string): Promise<NotificationEventEnvelopeDto>;
2320
+ /** GET .../notification-sources —— registry 声明 + 本 team 的 active config 摘要。 */
2321
+ listNotificationSources(teamId: string): Promise<{
2322
+ items: {
2323
+ definition: unknown;
2324
+ activeConfig: NotificationSourceConfigDto | null;
2325
+ }[];
2326
+ }>;
2327
+ /** GET .../notification-sources/:sourceId/configs —— 该 source 的历史 version 列表。 */
2328
+ listNotificationSourceConfigs(teamId: string, sourceId: string, params?: {
2329
+ limit?: number;
2330
+ }): Promise<{
2331
+ items: NotificationSourceConfigDto[];
2332
+ }>;
2333
+ /** GET .../notification-sources/:sourceId/configs/:configId(裸 config)。 */
2334
+ getNotificationSourceConfig(teamId: string, sourceId: string, configId: string): Promise<NotificationSourceConfigDto>;
2335
+ /**
2336
+ * POST .../notification-sources/:sourceId/configs —— 创建**新的不可变 version**
2337
+ * (`activate` 默认 true;除 enabled 外任何变更都是新 version,只影响新物化的 schedule)。
2338
+ * 409 `SOURCE_CONFIG_REQUIRED_FIELDS_CONFLICT` = 会打掉某些 active 订阅的 requiredFields。
2339
+ */
2340
+ createNotificationSourceConfig(teamId: string, sourceId: string, body: UpsertNotificationSourceConfigSdkBody, params?: {
2341
+ activate?: boolean;
2342
+ }): Promise<NotificationSourceConfigDto>;
2343
+ /** POST .../notification-sources/:sourceId/configs/:configId/activate。 */
2344
+ activateNotificationSourceConfig(teamId: string, sourceId: string, configId: string): Promise<NotificationSourceConfigDto>;
2345
+ /**
2346
+ * PUT .../notification-sources/:sourceId/enabled —— 实时 kill switch。
2347
+ *
2348
+ * 🔴 按 **sourceId 身份**而不是 version id:DB 语义是改 `(teamId, sourceId)` 下
2349
+ * **全部历史 version 行**(在途 schedule 引用的是物化时那一行,只改 active 行 =
2350
+ * 开关形同虚设)。本操作**不** bump sourceConfigVersion。
2351
+ * disabled 期间到点的 schedule 标 `missed`,重新 enable **不补发**。
2352
+ */
2353
+ setNotificationSourceEnabled(teamId: string, sourceId: string, enabled: boolean): Promise<{
2354
+ totalVersions: number;
2355
+ updatedVersions: number;
2356
+ enabled: boolean;
2357
+ }>;
1994
2358
  }
2359
+ export type NotificationSubscriptionStatus = "active" | "paused"
2360
+ /** 游标落后于保留 floor,已无法保证不漏;需人工确认后 reset。 */
2361
+ | "stale" | "deleted";
2362
+ export type NotificationSubscriptionStartPosition = "now" | "earliest";
2363
+ /** 同字段内多值 = OR,跨字段 = AND;空数组 = 不过滤该维度。 */
2364
+ export type NotificationFiltersDto = {
2365
+ brandIds?: string[];
2366
+ socialAccountIds?: string[];
2367
+ subreddits?: string[];
2368
+ };
2369
+ export type NotificationSubscriptionDto = {
2370
+ id: string;
2371
+ teamId: string;
2372
+ name: string;
2373
+ sourceIds: string[];
2374
+ filters: NotificationFiltersDto;
2375
+ requiredFields: string[];
2376
+ /** 匹配面(sourceIds/filters/requiredFields)变化时 +1。 */
2377
+ filterVersion: number;
2378
+ /** 「哪一代 pull 结果仍可推进游标」的身份;变了 → 在途 receipt 全部作废。 */
2379
+ receiptEpoch: number;
2380
+ /** 连续 watermark,十进制字符串。 */
2381
+ cursorSeq: string;
2382
+ /** 乐观锁,update DTO 的 CAS 用;**不进** receipt。 */
2383
+ rowVersion: number;
2384
+ startPosition: NotificationSubscriptionStartPosition;
2385
+ status: NotificationSubscriptionStatus;
2386
+ lastPulledAt: string | null;
2387
+ createdAt: string;
2388
+ updatedAt: string;
2389
+ /** 服务端附加的归属信息(不在冻结契约里,仅供展示/排障)。 */
2390
+ ownerUserId?: string | null;
2391
+ isOwner?: boolean;
2392
+ lastAckedAt?: string | null;
2393
+ staleAt?: string | null;
2394
+ };
2395
+ /** `GET .../notification-events` 的运维摘要行(**不含 payload / includedFields**)。 */
2396
+ export type NotificationEventSummaryDto = {
2397
+ eventId: string;
2398
+ seq: string;
2399
+ teamId: string;
2400
+ sourceId: string;
2401
+ canonicalTopic: string;
2402
+ dedupeKey: string;
2403
+ sourceConfigVersion: number;
2404
+ fieldSetVersion: string;
2405
+ payloadStatus: "active" | "expired";
2406
+ maxSensitivity: string;
2407
+ requiredPermissions: string[];
2408
+ brandId: string | null;
2409
+ socialAccountId: string | null;
2410
+ subreddit: string | null;
2411
+ occurredAt: string;
2412
+ emittedAt: string;
2413
+ };
2414
+ export type CreateNotificationSubscriptionSdkBody = {
2415
+ name: string;
2416
+ /** **升序去重**(进 filterVersion 计算,不规范化会误伤在途 receipt)。 */
2417
+ sourceIds: string[];
2418
+ filters?: NotificationFiltersDto;
2419
+ /** 「没有这些字段就别发给我」;必须 ⊆ 当前生效 config 的 configuredFields。 */
2420
+ requiredFields?: string[];
2421
+ /** 默认 `now`,避免新机器一上线被历史事件淹没。 */
2422
+ startPosition?: NotificationSubscriptionStartPosition;
2423
+ };
2424
+ export type UpdateNotificationSubscriptionSdkBody = {
2425
+ /** 必填:并发改配置时的 CAS。 */
2426
+ expectedRowVersion: number;
2427
+ name?: string;
2428
+ sourceIds?: string[];
2429
+ filters?: NotificationFiltersDto;
2430
+ requiredFields?: string[];
2431
+ /** pause/resume 就走这里(不能改成 stale/deleted)。 */
2432
+ status?: "active" | "paused";
2433
+ };
2434
+ export type NotificationNodeSpecDto = {
2435
+ key: string;
2436
+ offsetSeconds: number;
2437
+ maxLatenessSeconds: number;
2438
+ };
2439
+ export type UpsertNotificationSourceConfigSdkBody = {
2440
+ sourceId: string;
2441
+ nodes: NotificationNodeSpecDto[];
2442
+ filters?: NotificationFiltersDto;
2443
+ /** 只能勾 registry `optionalFields`;required 不可勾也不可取消。 */
2444
+ selectedFields?: string[];
2445
+ retentionDays?: number;
2446
+ displayName: string;
2447
+ /** 展示用,**不参与**路由/过滤/去重。 */
2448
+ displayTopicLabel?: string | null;
2449
+ };
2450
+ export type NotificationSourceConfigDto = {
2451
+ id: string;
2452
+ teamId: string;
2453
+ sourceId: string;
2454
+ version: number;
2455
+ enabled: boolean;
2456
+ nodes: NotificationNodeSpecDto[];
2457
+ filters: NotificationFiltersDto;
2458
+ selectedFields: string[];
2459
+ fieldSetVersion: string;
2460
+ retentionDays: number;
2461
+ displayName: string;
2462
+ displayTopicLabel: string | null;
2463
+ activatedAt: string | null;
2464
+ createdAt: string;
2465
+ updatedAt: string;
2466
+ /** 以下是服务端在冻结契约之外附加的只读字段(后台展示/排障用)。 */
2467
+ isActive?: boolean;
2468
+ supersededAt?: string | null;
2469
+ sourceDefinitionVersion?: number;
2470
+ payloadSchemaVersion?: string;
2471
+ /** 配置级暴露政策(= fieldSetVersion 的哈希输入)。 */
2472
+ configuredFields?: string[];
2473
+ /** registry 推导的字段级 authz 并集(AND 语义),只读。 */
2474
+ requiredPermissions?: string[];
2475
+ };
2476
+ /**
2477
+ * 事件信封。四层版本 + `includedFields` 决定形状,消费方按 `payloadSchemaVersion` 分支;
2478
+ * **遇到未知版本应拒绝处理但不 ack**(并打印 eventId/sourceId/payloadSchemaVersion)。
2479
+ *
2480
+ * `payloadStatus === "expired"` 是 **tombstone**:`payload` 为 null、`includedFields` 为空。
2481
+ * 收到它**不得**当业务事件处理,但**必须**照常 ack —— 否则一条过期事件会把游标永久卡死。
2482
+ */
2483
+ export type NotificationEventEnvelopeDto = {
2484
+ eventId: string;
2485
+ /** 十进制字符串(bigint)。 */
2486
+ seq: string;
2487
+ teamId: string;
2488
+ sourceId: string;
2489
+ canonicalTopic: string;
2490
+ /** agent 侧幂等键(**不是** seq —— seq 只表示顺序)。 */
2491
+ dedupeKey: string;
2492
+ envelopeVersion: number;
2493
+ sourceDefinitionVersion: number;
2494
+ payloadSchemaVersion: string;
2495
+ sourceConfigVersion: number;
2496
+ fieldSetVersion: string;
2497
+ occurredAt: string;
2498
+ emittedAt: string;
2499
+ payloadStatus: "active" | "expired";
2500
+ includedFields: string[];
2501
+ payload: Record<string, unknown> | null;
2502
+ };
2503
+ /** 不落库的签名凭据;ack 必须原样回传**整个对象**(不只是 signature)。 */
2504
+ export type NotificationPullReceiptDto = {
2505
+ subscriptionId: string;
2506
+ fromCursorSeq: string;
2507
+ maxDeliveredSeq: string;
2508
+ filterVersion: number;
2509
+ receiptEpoch: number;
2510
+ expiresAt: string;
2511
+ signature: string;
2512
+ };
2513
+ export type NotificationPullResponseDto = {
2514
+ /** 严格按 seq 升序的 `seq > cursorSeq` 前 N 条匹配事件。 */
2515
+ events: NotificationEventEnvelopeDto[];
2516
+ receipt: NotificationPullReceiptDto;
2517
+ /** = receipt.fromCursorSeq。 */
2518
+ cursorSeq: string;
2519
+ /** 流末尾,供 agent 估算落后量;不参与任何校验。 */
2520
+ latestSeq: string;
2521
+ };
2522
+ /**
2523
+ * 十进制 seq 字符串的数值比较(BigInt,不走 Number —— 53 bit 之后会静默丢精度)。
2524
+ * 与 contracts `compareNotificationSeq` 同口径;SDK 侧复刻是因为不能引 contracts。
2525
+ */
2526
+ export declare function compareNotificationSeqStrings(left: string, right: string): number;
1995
2527
  //# sourceMappingURL=index.d.ts.map