@tolinax/ayoune-interfaces 2026.44.0 → 2026.46.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.
@@ -538,6 +538,7 @@ export declare enum aMN {
538
538
  RunningPipelines = "RunningPipelines",
539
539
  SalesTemplates = "SalesTemplates",
540
540
  ScoreLogs = "ScoreLogs",
541
+ ScraperQuotaUsage = "ScraperQuotaUsage",
541
542
  SearchBars = "SearchBars",
542
543
  SearchBoxes = "SearchBoxes",
543
544
  SearchKeywords = "SearchKeywords",
@@ -542,6 +542,7 @@ var aMN;
542
542
  aMN["RunningPipelines"] = "RunningPipelines";
543
543
  aMN["SalesTemplates"] = "SalesTemplates";
544
544
  aMN["ScoreLogs"] = "ScoreLogs";
545
+ aMN["ScraperQuotaUsage"] = "ScraperQuotaUsage";
545
546
  aMN["SearchBars"] = "SearchBars";
546
547
  aMN["SearchBoxes"] = "SearchBoxes";
547
548
  aMN["SearchKeywords"] = "SearchKeywords";
@@ -6291,6 +6291,19 @@ const modelsAndRights = [
6291
6291
  updateBy: "_id",
6292
6292
  availableInSDK: false,
6293
6293
  },
6294
+ {
6295
+ // Scraper Platform-Service Refactor (Phase 1) — Platform-Asset,
6296
+ // kein _customerID-Field. Nur via api-superuser lesbar.
6297
+ plural: "ScraperQuotaUsage",
6298
+ singular: "ScraperQuotaUsage",
6299
+ module: "su",
6300
+ right: "su.scraper-quota",
6301
+ readOnly: true,
6302
+ importable: false,
6303
+ allowDuplicate: false,
6304
+ updateBy: "_id",
6305
+ availableInSDK: false,
6306
+ },
6294
6307
  {
6295
6308
  plural: "SearchBars",
6296
6309
  singular: "SearchBar",
@@ -1,4 +1,15 @@
1
1
  import { IDefaultFields } from "./IDefaultFields";
2
+ /**
3
+ * Direction of a charge entry.
4
+ * - "inbound" = customer → Tolinax (metered usage, existing default)
5
+ * - "outbound" = Tolinax → third-party provider (platform cost telemetry)
6
+ */
7
+ export type ChargeDirection = "inbound" | "outbound";
8
+ /**
9
+ * Known outbound providers. Kept as a string literal union rather than an
10
+ * enum so consumers can declare their own providers without a type release.
11
+ */
12
+ export type ChargeProvider = "gcp" | "openai" | "anthropic" | "vertex" | "bitbucket" | "atlas" | "hetzner" | "cloudflare" | "npm" | string;
2
13
  export interface ICharge extends IDefaultFields {
3
14
  _customerID: ObjectId;
4
15
  _product?: ObjectId;
@@ -22,4 +33,23 @@ export interface ICharge extends IDefaultFields {
22
33
  dateTime?: Date;
23
34
  billable?: boolean;
24
35
  invoiced?: boolean;
36
+ /**
37
+ * Cost-telemetry extension (2026-04-20). All fields optional; existing
38
+ * inbound customer charges stay untouched. For outbound charges the
39
+ * `direction` field flips to "outbound" and `_customerID` is set to
40
+ * the TOLINAX_CUSTOMERID so multi-tenant indexes keep working without
41
+ * special-cases.
42
+ */
43
+ direction?: ChargeDirection;
44
+ provider?: ChargeProvider;
45
+ amountUSD?: number;
46
+ exchangeRate?: number;
47
+ /**
48
+ * When an outbound cost can be attributed to a specific customer (e.g.
49
+ * AI tokens consumed by a customer-scoped request), set this to that
50
+ * customer's _id. Leave undefined for platform-wide overhead.
51
+ */
52
+ attributedCustomerID?: ObjectId;
53
+ /** Provider-specific payload (gcp service code, openai model, etc.). */
54
+ meta?: any;
25
55
  }
@@ -139,5 +139,15 @@ export interface IKeywordResearch extends IDefaultFields {
139
139
  maxCPCs: number[];
140
140
  costRuns: ICostRun[];
141
141
  results: IResults;
142
+ /**
143
+ * Scraper-Service-Tier — determiniert welcher Scraper-Provider für Jobs
144
+ * aus dieser KeywordResearch gewählt wird. Default 'standard'.
145
+ * Siehe `platform/core/src/lib/flags/README.md`.
146
+ */
147
+ scraperTier?: "economy" | "standard" | "premium";
148
+ /**
149
+ * Opt-in-Fallback auf Eigen-Infrastruktur (Phase 1.5 / Phase 7).
150
+ */
151
+ preferOwnInfra?: boolean;
142
152
  }
143
153
  export {};
@@ -84,4 +84,16 @@ export interface IMarketResearch extends IDefaultFields {
84
84
  };
85
85
  maxCPCs: number[];
86
86
  costRuns: ICostRun[];
87
+ /**
88
+ * Scraper-Service-Tier — determiniert welcher Scraper-Provider für Jobs
89
+ * aus dieser MarketResearch gewählt wird. Default 'standard'.
90
+ * Siehe `platform/core/src/lib/flags/README.md` und
91
+ * `crawlers/core-scraper-apis/src/lib/providerRegistry.ts`.
92
+ */
93
+ scraperTier?: "economy" | "standard" | "premium";
94
+ /**
95
+ * Opt-in-Fallback auf Eigen-Infrastruktur (Phase 1.5 / Phase 7).
96
+ * In Phase 1: triggert Silent-Fallback auf Nimble weil ownInfra Stub.
97
+ */
98
+ preferOwnInfra?: boolean;
87
99
  }
@@ -0,0 +1,37 @@
1
+ import { IDefaultFields } from "./IDefaultFields";
2
+ import { ScraperProviderName } from "./INormalizedSerp";
3
+ /**
4
+ * Scraper-Provider Monats-Quota-Verbrauch (Hot-Path-State für das
5
+ * Quota-Gate in der Provider-Registry).
6
+ *
7
+ * Ein Dokument pro (provider, month). `_id` ist der String
8
+ * `"YYYY-MM:{provider}"`, z.B. `"2026-04:nimble"`. Pro Provider-Call wird
9
+ * `requestsUsed` mit atomarem `$inc` hochgezählt — keine Redis-Counter,
10
+ * kein Sync-Worker (bei ~8 req/s Peak gesamt ist Mongo-$inc auf einem
11
+ * Dokument pro Provider+Monat trivial).
12
+ *
13
+ * Siehe:
14
+ * - `crawlers/core-scraper-apis/src/lib/quotaGate.ts` (Hot-Path + Gate)
15
+ * - `platform/core/src/lib/flags/README.md` (Pricing-Flag-Konventionen)
16
+ * - Plan §1.6 + §1.9
17
+ *
18
+ * **Platform-Service-Konvention**: kein `_customerID`-Feld. Scraper-Kapazität
19
+ * ist Tolinax-Platform-Asset, nicht tenant-scoped. Per-Customer-Attribution
20
+ * des Verbrauchs läuft über Events (`scraper-request` Events mit
21
+ * `_customerID` im Event-Doc), nicht über ScraperQuotaUsage.
22
+ */
23
+ export interface IScraperQuotaUsage extends Omit<IDefaultFields, "_id"> {
24
+ _id: string;
25
+ provider: ScraperProviderName;
26
+ monthStart: Date;
27
+ monthEnd: Date;
28
+ /** Snapshot aus `scraper.pricing.{provider}.monthlyQuota` zum Monatsstart */
29
+ quotaLimit: number;
30
+ /** Atomarer Counter, `$inc` pro Provider-Call */
31
+ requestsUsed: number;
32
+ /** Erhöht statt requestsUsed sobald requestsUsed > quotaLimit */
33
+ overageRequests: number;
34
+ lastUpdated: Date;
35
+ /** Snapshot der `scraper.pricing.{provider}.version` zum Monatsstart — für Audit-Trail */
36
+ pricingVersion: number;
37
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import { IDefaultFields } from "./IDefaultFields";
2
+ import { INormalizedSerp, ScraperProviderName } from "./INormalizedSerp";
2
3
  interface ICrawlingAgent {
3
4
  _crawlingAgent: ObjectId;
4
5
  _device: ObjectId;
@@ -111,5 +112,18 @@ export interface ISerp extends IDefaultFields {
111
112
  parsingErrors?: any;
112
113
  proxyHostName?: string;
113
114
  raw?: any;
115
+ /**
116
+ * Scraper Platform-Service Refactor (Phase 1) — welcher Provider hat
117
+ * dieses SERP geliefert. Legacy-Pfad-Serps haben keinen provider-Eintrag
118
+ * (undefined). Werte: 'nimble' | 'oxy' | 'soax' | 'ownInfra'.
119
+ */
120
+ provider?: ScraperProviderName;
121
+ /**
122
+ * Scraper Platform-Service Refactor (Phase 1) — normalisierte Provider-
123
+ * agnostische Repräsentation. `raw` bleibt befüllt als Forensik + für
124
+ * existierende `storeSEA*`-Konsumenten. Phase 4 (Storage-Decompose)
125
+ * migriert Konsumenten auf `normalized`.
126
+ */
127
+ normalized?: INormalizedSerp;
114
128
  }
115
129
  export {};
@@ -572,6 +572,7 @@ export * from "./IRolloutStrategy";
572
572
  export * from "./IRunningPipeline";
573
573
  export * from "./ISalesTemplate";
574
574
  export * from "./IScoreLog";
575
+ export * from "./IScraperQuotaUsage";
575
576
  export * from "./ISearchBar";
576
577
  export * from "./ISearchBox";
577
578
  export * from "./ISearchKeyword";
@@ -588,6 +588,7 @@ __exportStar(require("./IRolloutStrategy"), exports);
588
588
  __exportStar(require("./IRunningPipeline"), exports);
589
589
  __exportStar(require("./ISalesTemplate"), exports);
590
590
  __exportStar(require("./IScoreLog"), exports);
591
+ __exportStar(require("./IScraperQuotaUsage"), exports);
591
592
  __exportStar(require("./ISearchBar"), exports);
592
593
  __exportStar(require("./ISearchBox"), exports);
593
594
  __exportStar(require("./ISearchKeyword"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-interfaces",
3
- "version": "2026.44.0",
3
+ "version": "2026.46.0",
4
4
  "description": "Houses TypeScript interfaces for aYOUne",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",