@omelhorsite/sdk 0.15.1 → 0.17.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/README.md +26 -3
- package/dist/index.js +385 -146
- package/dist/types/auth/tokens.d.ts +1 -1
- package/dist/types/client.d.ts +3 -0
- package/dist/types/resources/admin/llm.d.ts +9 -1
- package/dist/types/resources/admin/quotas.d.ts +14 -0
- package/dist/types/resources/content/blogs.d.ts +111 -31
- package/dist/types/resources/content/index.d.ts +4 -4
- package/dist/types/resources/content/news/feeds.d.ts +56 -0
- package/dist/types/resources/content/news/index.d.ts +36 -0
- package/dist/types/resources/content/news/items.d.ts +155 -0
- package/dist/types/resources/content/{intel → news}/scripts.d.ts +35 -35
- package/dist/types/resources/content/{intel → news}/sources.d.ts +62 -59
- package/dist/types/resources/content/notifications.d.ts +2 -2
- package/dist/types/resources/cron.d.ts +225 -0
- package/dist/types/resources/index.d.ts +1 -0
- package/dist/types/resources/llm.d.ts +71 -0
- package/dist/types/resources/quotas.d.ts +8 -5
- package/dist/types/resources/search.d.ts +36 -0
- package/package.json +1 -1
- package/dist/types/resources/content/intel/articles.d.ts +0 -230
- package/dist/types/resources/content/intel/config.d.ts +0 -135
- package/dist/types/resources/content/intel/index.d.ts +0 -53
- package/dist/types/resources/content/intel/items.d.ts +0 -91
- package/dist/types/resources/content/intel/reports.d.ts +0 -108
- package/dist/types/resources/content/intel/stats.d.ts +0 -105
- package/dist/types/resources/content/intel/types.d.ts +0 -86
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/** Intel config: the per-user pipeline settings. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { Id, RequestOptions, Timestamp } from "../../../types";
|
|
4
|
-
/**
|
|
5
|
-
* The only keys {@link IntelConfig.prompts} accepts.
|
|
6
|
-
*
|
|
7
|
-
* Any other key fails the whole `PATCH` with
|
|
8
|
-
* `400 "Prompts unknown keys: <the offenders>"`. A key that is present but
|
|
9
|
-
* empty is not the same as an absent one: absent means "use the platform
|
|
10
|
-
* default", present-and-empty means the pipeline gets an empty prompt.
|
|
11
|
-
*/
|
|
12
|
-
export declare const INTEL_PROMPT_KEYS: readonly ["build", "enrich_plan", "enrich_actors", "enrich_synth", "report"];
|
|
13
|
-
/** One overridable prompt in the analysis pipeline. */
|
|
14
|
-
export type IntelPromptKey = (typeof INTEL_PROMPT_KEYS)[number];
|
|
15
|
-
/**
|
|
16
|
-
* The per-user knobs on the analysis pipeline. One row per user, created on
|
|
17
|
-
* demand - see {@link IntelConfigNamespace.get}.
|
|
18
|
-
*/
|
|
19
|
-
export interface IntelConfig {
|
|
20
|
-
readonly id: Id;
|
|
21
|
-
readonly created_at: Timestamp;
|
|
22
|
-
readonly updated_at: Timestamp;
|
|
23
|
-
/**
|
|
24
|
-
* Free text telling the classifier what "important" means for you. `null`
|
|
25
|
-
* falls back to the platform default. This is the single highest-leverage
|
|
26
|
-
* field here: everything else is a threshold applied to the score this
|
|
27
|
-
* produces.
|
|
28
|
-
*/
|
|
29
|
-
readonly rubric: string | null;
|
|
30
|
-
/**
|
|
31
|
-
* Prompt overrides, keyed by {@link IntelPromptKey}. `{}` means "platform
|
|
32
|
-
* defaults everywhere"; a key present means that one stage is overridden.
|
|
33
|
-
*
|
|
34
|
-
* Nullable at the database level even though it defaults to `{}`.
|
|
35
|
-
*/
|
|
36
|
-
readonly prompts: Partial<Record<IntelPromptKey, string>> | null;
|
|
37
|
-
/** LLM for the story-building pass. `null` uses the platform default. */
|
|
38
|
-
readonly build_model: string | null;
|
|
39
|
-
/** LLM for report generation. `null` uses the platform default. */
|
|
40
|
-
readonly report_model: string | null;
|
|
41
|
-
/** Stories below this importance are left out of reports. 0-10, default 4. */
|
|
42
|
-
readonly report_min_importance: number;
|
|
43
|
-
/**
|
|
44
|
-
* Stories below this importance are never web-enriched. 0-10, default 6.
|
|
45
|
-
*
|
|
46
|
-
* Lowering it does not enrich the backlog quickly: the job does three
|
|
47
|
-
* stories per run, highest importance first.
|
|
48
|
-
*/
|
|
49
|
-
readonly enrich_min_importance: number;
|
|
50
|
-
/**
|
|
51
|
-
* Master switch for the enrichment pass. `false` leaves every story at
|
|
52
|
-
* `enriched: false` and `details: null` for ever.
|
|
53
|
-
*/
|
|
54
|
-
readonly web_search: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* How many {@link IntelSource} rows you may own. 1-500, default 50.
|
|
57
|
-
*
|
|
58
|
-
* Enforced on CREATE only (`validate :within_source_quota, on: :create`), so
|
|
59
|
-
* lowering it below your current count does not delete anything - it just
|
|
60
|
-
* stops the next create with `400 "Source limit reached (N)"`.
|
|
61
|
-
*/
|
|
62
|
-
readonly max_sources: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Arguments for {@link IntelConfigNamespace.update}.
|
|
66
|
-
*
|
|
67
|
-
* Every key is optional and only the keys you send are written -
|
|
68
|
-
* `assign_attributes` over a permitted hash - so this is a genuine partial
|
|
69
|
-
* update, unlike {@link UpdateIntelSourceInput.config}.
|
|
70
|
-
*/
|
|
71
|
-
export interface UpdateIntelConfigInput {
|
|
72
|
-
readonly rubric?: string | null;
|
|
73
|
-
/**
|
|
74
|
-
* REPLACES the whole prompts object. Same trap as
|
|
75
|
-
* {@link UpdateIntelSourceInput.config}: it is one JSON column, so a partial
|
|
76
|
-
* object drops the keys you left out. Spread the current value.
|
|
77
|
-
*
|
|
78
|
-
* Only {@link INTEL_PROMPT_KEYS} are accepted; anything else fails the whole
|
|
79
|
-
* request with a 400 naming the offenders.
|
|
80
|
-
*/
|
|
81
|
-
readonly prompts?: Partial<Record<IntelPromptKey, string>>;
|
|
82
|
-
readonly buildModel?: string | null;
|
|
83
|
-
readonly reportModel?: string | null;
|
|
84
|
-
/** 0-10. Outside the range is a 400, not a clamp. */
|
|
85
|
-
readonly reportMinImportance?: number;
|
|
86
|
-
/** 0-10. Outside the range is a 400, not a clamp. */
|
|
87
|
-
readonly enrichMinImportance?: number;
|
|
88
|
-
readonly webSearch?: boolean;
|
|
89
|
-
/** 1-500. Outside the range is a 400, not a clamp. */
|
|
90
|
-
readonly maxSources?: number;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* `/intel_config` - the per-user pipeline settings.
|
|
94
|
-
*
|
|
95
|
-
* A Rails SINGULAR resource (`resource :intel_config`), so the path has no id
|
|
96
|
-
* and there is no listing: `GET /intel_config` and `PATCH /intel_config` are
|
|
97
|
-
* the whole surface. Both act on the caller's own row and there is no way to
|
|
98
|
-
* address anybody else's.
|
|
99
|
-
*/
|
|
100
|
-
export declare class IntelConfigNamespace extends Resource {
|
|
101
|
-
/**
|
|
102
|
-
* `GET /intel_config` - your settings.
|
|
103
|
-
*
|
|
104
|
-
* **This read WRITES.** The controller calls `IntelConfig.for(Current.user)`,
|
|
105
|
-
* which is `find_or_create_by!`, so a first call inserts the row with the
|
|
106
|
-
* column defaults and returns it. Consequences worth knowing: it is not safe
|
|
107
|
-
* to fire at high frequency (two concurrent first calls race on the unique
|
|
108
|
-
* index and one raises), the response is a `200` even when it just created
|
|
109
|
-
* something, and `created_at` on a "read" can be now.
|
|
110
|
-
*
|
|
111
|
-
* @throws {OmsApiError} 403 `"Intel access is restricted."` outside the
|
|
112
|
-
* allowlist - checked before the row is created, so a refused caller does
|
|
113
|
-
* not leave a row behind.
|
|
114
|
-
*/
|
|
115
|
-
get(options?: RequestOptions): Promise<IntelConfig>;
|
|
116
|
-
/**
|
|
117
|
-
* `PATCH /intel_config` - changes settings. Answers with the whole row.
|
|
118
|
-
*
|
|
119
|
-
* A genuine partial update for the scalar fields, and a whole-object replace
|
|
120
|
-
* for `prompts` - see {@link UpdateIntelConfigInput.prompts}.
|
|
121
|
-
*
|
|
122
|
-
* The route also accepts `PUT`, and it means exactly the same thing: Rails
|
|
123
|
-
* maps both onto `update` and the controller does not read the verb. There is
|
|
124
|
-
* no "replace the whole config" call.
|
|
125
|
-
*
|
|
126
|
-
* Failures are a `400` whose body is ONE sentence, not a field map:
|
|
127
|
-
* `ApplicationRecord#error_messages` is `errors.full_messages.to_sentence`,
|
|
128
|
-
* so several violations arrive joined by commas and "and". Parse it for
|
|
129
|
-
* humans, not for code.
|
|
130
|
-
*
|
|
131
|
-
* @throws {OmsApiError} 400 for a threshold outside `0..10`, a `max_sources`
|
|
132
|
-
* outside `1..500`, or a `prompts` key outside {@link INTEL_PROMPT_KEYS}.
|
|
133
|
-
*/
|
|
134
|
-
update(input: UpdateIntelConfigInput, options?: RequestOptions): Promise<IntelConfig>;
|
|
135
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/** The `intel` namespace and everything under it. */
|
|
2
|
-
import { type ApiClient, Resource } from "../../../http";
|
|
3
|
-
import { IntelArticlesNamespace } from "./articles";
|
|
4
|
-
import { IntelConfigNamespace } from "./config";
|
|
5
|
-
import { IntelItemsNamespace } from "./items";
|
|
6
|
-
import { IntelReportsNamespace } from "./reports";
|
|
7
|
-
import { IntelScriptsNamespace } from "./scripts";
|
|
8
|
-
import { IntelSourcesNamespace } from "./sources";
|
|
9
|
-
import { IntelStatsNamespace } from "./stats";
|
|
10
|
-
export * from "./articles";
|
|
11
|
-
export * from "./config";
|
|
12
|
-
export * from "./items";
|
|
13
|
-
export * from "./reports";
|
|
14
|
-
export * from "./scripts";
|
|
15
|
-
export * from "./sources";
|
|
16
|
-
export * from "./stats";
|
|
17
|
-
export * from "./types";
|
|
18
|
-
/**
|
|
19
|
-
* The `intel` namespace, reachable as `oms.content.intel`.
|
|
20
|
-
*
|
|
21
|
-
* A tour of the data model, because the names do not give it away:
|
|
22
|
-
*
|
|
23
|
-
* 1. a {@link IntelScript} knows HOW to fetch one kind of feed;
|
|
24
|
-
* 2. an {@link IntelSource} is that script plus its settings - a feed you
|
|
25
|
-
* actually follow;
|
|
26
|
-
* 3. polling a source writes {@link IntelItem} rows: raw, unprocessed, one per
|
|
27
|
-
* thing the feed published;
|
|
28
|
-
* 4. the analysis pipeline groups items into {@link IntelArticle} stories,
|
|
29
|
-
* scores them against your {@link IntelConfig} rubric, enriches the
|
|
30
|
-
* important ones and links related ones together;
|
|
31
|
-
* 5. {@link IntelReport} digests summarise a closed time window of stories.
|
|
32
|
-
*
|
|
33
|
-
* Only steps 1 and 2 are yours to write. Everything from step 3 on is produced
|
|
34
|
-
* by background jobs and is read-only over HTTP - a delete is the only mutation
|
|
35
|
-
* you get, and it is a hide, not an undo.
|
|
36
|
-
*/
|
|
37
|
-
export declare class IntelNamespace extends Resource {
|
|
38
|
-
/** Stories: the analysed, grouped, scored output. Read plus delete. */
|
|
39
|
-
readonly articles: IntelArticlesNamespace;
|
|
40
|
-
/** Generated digests over closed time windows. Read plus delete. */
|
|
41
|
-
readonly reports: IntelReportsNamespace;
|
|
42
|
-
/** The feeds you follow. Full CRUD, plus a manual run. */
|
|
43
|
-
readonly sources: IntelSourcesNamespace;
|
|
44
|
-
/** The fetchers. Full CRUD over yours; the built-ins are read-only. */
|
|
45
|
-
readonly scripts: IntelScriptsNamespace;
|
|
46
|
-
/** The raw material behind the stories. Read plus delete. */
|
|
47
|
-
readonly items: IntelItemsNamespace;
|
|
48
|
-
/** Your rubric, thresholds and prompt overrides. */
|
|
49
|
-
readonly config: IntelConfigNamespace;
|
|
50
|
-
/** Dashboard counters, in one expensive call. */
|
|
51
|
-
readonly stats: IntelStatsNamespace;
|
|
52
|
-
constructor(http: ApiClient);
|
|
53
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/** Intel items: the raw material behind the stories. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { ListParams } from "../../../listing";
|
|
4
|
-
import type { Id, Paginated, RequestOptions, Timestamp } from "../../../types";
|
|
5
|
-
/**
|
|
6
|
-
* A raw item, exactly as a script returned it.
|
|
7
|
-
*
|
|
8
|
-
* Written only by `Intel::FetchSourceJob`; over HTTP it is read-only plus a
|
|
9
|
-
* delete. Items are the substrate the stories are built from - the story never
|
|
10
|
-
* copies the body, it points here.
|
|
11
|
-
*/
|
|
12
|
-
export interface IntelItem {
|
|
13
|
-
readonly id: Id;
|
|
14
|
-
readonly created_at: Timestamp;
|
|
15
|
-
readonly updated_at: Timestamp;
|
|
16
|
-
/** Which source produced it. */
|
|
17
|
-
readonly intel_source_id: Id;
|
|
18
|
-
/**
|
|
19
|
-
* The script's own id for this item, unique per source. This is the
|
|
20
|
-
* de-duplication key: a second poll that returns the same `external_id` does
|
|
21
|
-
* not create a second row.
|
|
22
|
-
*/
|
|
23
|
-
readonly external_id: string;
|
|
24
|
-
readonly title: string | null;
|
|
25
|
-
/** The body the script extracted. Can be large; a listing carries all of it. */
|
|
26
|
-
readonly content: string | null;
|
|
27
|
-
readonly url: string | null;
|
|
28
|
-
readonly author: string | null;
|
|
29
|
-
/** Publication time as the feed reported it, not as we saw it. */
|
|
30
|
-
readonly published_at: Timestamp | null;
|
|
31
|
-
/** When the poll that produced this item ran. Never null. */
|
|
32
|
-
readonly fetched_at: Timestamp;
|
|
33
|
-
}
|
|
34
|
-
/** Filter columns of `GET /intel_items`, on top of {@link BASE_FILTER_COLUMNS}. */
|
|
35
|
-
export declare const INTEL_ITEM_FILTER_COLUMNS: readonly ["intel_source_id", "external_id", "title", "content", "url"];
|
|
36
|
-
/** Filters for {@link IntelItemsNamespace.list}. */
|
|
37
|
-
export interface ListIntelItemsParams extends ListParams<(typeof INTEL_ITEM_FILTER_COLUMNS)[number]> {
|
|
38
|
-
/** Only items produced by one source. Sent as `exact_search[intel_source_id]`. */
|
|
39
|
-
readonly sourceId?: Id;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* `/intel_items` - the raw material.
|
|
43
|
-
*
|
|
44
|
-
* Read-only plus a delete: `creatable_by?` and `updatable_by?` are hard `false`
|
|
45
|
-
* and the route is `only: [:index, :show, :destroy]`. Items are written by
|
|
46
|
-
* `Intel::FetchSourceJob` and by nothing else.
|
|
47
|
-
*
|
|
48
|
-
* It is here because the stories only carry a citation stub
|
|
49
|
-
* ({@link IntelArticleSourceRef}) and this is the only way to read the body
|
|
50
|
-
* behind one.
|
|
51
|
-
*/
|
|
52
|
-
export declare class IntelItemsNamespace extends Resource {
|
|
53
|
-
/**
|
|
54
|
-
* `GET /intel_items` - raw items, newest first.
|
|
55
|
-
*
|
|
56
|
-
* **Heavy.** Every row carries {@link IntelItem.content} in full - the whole
|
|
57
|
-
* article text a script scraped - and there is no lighter view. The SDK
|
|
58
|
-
* defaults to a page of 25 for that reason; raising it is how you get a
|
|
59
|
-
* multi-megabyte response.
|
|
60
|
-
*
|
|
61
|
-
* Declared filters: `intel_source_id`, `external_id`, `title`, `content`,
|
|
62
|
-
* `url`, plus the inherited three. Note `processed_at` is NOT among them and
|
|
63
|
-
* is not on the payload either, so there is no way to list only the
|
|
64
|
-
* unprocessed items - {@link IntelStats.totals.pending_items} is the only
|
|
65
|
-
* window onto that backlog.
|
|
66
|
-
*
|
|
67
|
-
* The controller sets no ordering; the SDK sends `created_at:desc`.
|
|
68
|
-
*/
|
|
69
|
-
list(params?: ListIntelItemsParams, options?: RequestOptions): Promise<Paginated<IntelItem>>;
|
|
70
|
-
/**
|
|
71
|
-
* `GET /intel_items/:id` - one raw item.
|
|
72
|
-
*
|
|
73
|
-
* There are no `:extended` extras, so this is the same shape a listing row
|
|
74
|
-
* has. Use it to expand one {@link IntelArticleSourceRef} without
|
|
75
|
-
* pulling a page of bodies.
|
|
76
|
-
*
|
|
77
|
-
* @throws {OmsApiError} 404 when the item is not yours.
|
|
78
|
-
*/
|
|
79
|
-
get(id: Id, options?: RequestOptions): Promise<IntelItem>;
|
|
80
|
-
/**
|
|
81
|
-
* `DELETE /intel_items/:id`. `204`, empty body.
|
|
82
|
-
*
|
|
83
|
-
* Rarely what you want. The item's `external_id` uniqueness is what stops the
|
|
84
|
-
* next poll re-fetching it, so deleting one invites it straight back on the
|
|
85
|
-
* following run - and if the story built from it survives, you get a second
|
|
86
|
-
* citation of the same thing. Delete the SOURCE, or leave items alone.
|
|
87
|
-
*
|
|
88
|
-
* @throws {OmsApiError} 404 when the item is not yours.
|
|
89
|
-
*/
|
|
90
|
-
delete(id: Id, options?: RequestOptions): Promise<void>;
|
|
91
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/** Intel reports: generated digests over closed time windows. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { ListParams } from "../../../listing";
|
|
4
|
-
import type { Id, Json, Paginated, RequestOptions, Timestamp } from "../../../types";
|
|
5
|
-
import type { IntelArticleCategory, IntelReportKind } from "./types";
|
|
6
|
-
/** A story as a report inlines it. Four keys, no summary and no body. */
|
|
7
|
-
export interface IntelReportArticleRef {
|
|
8
|
-
readonly id: Id;
|
|
9
|
-
readonly title: string | null;
|
|
10
|
-
readonly importance: number;
|
|
11
|
-
readonly category: IntelArticleCategory | null;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A generated report over one closed time window.
|
|
15
|
-
*
|
|
16
|
-
* The index shape. `GET /intel_reports/:id` adds three keys - see
|
|
17
|
-
* {@link IntelReportDetail}.
|
|
18
|
-
*
|
|
19
|
-
* There is at most ONE report per `(user, kind, period_end)`: the migration
|
|
20
|
-
* puts a unique index on that triple precisely so a re-run of
|
|
21
|
-
* `GenerateReportJob` cannot mint a duplicate. Windows are the last CLOSED
|
|
22
|
-
* period, computed by `IntelReport.last_window`, so a `"day"` report covers
|
|
23
|
-
* yesterday and never the day in progress.
|
|
24
|
-
*/
|
|
25
|
-
export interface IntelReport {
|
|
26
|
-
readonly id: Id;
|
|
27
|
-
readonly created_at: Timestamp;
|
|
28
|
-
readonly updated_at: Timestamp;
|
|
29
|
-
/** Which window: see {@link INTEL_REPORT_KINDS}. */
|
|
30
|
-
readonly kind: IntelReportKind;
|
|
31
|
-
/** Title the model wrote. Nullable. */
|
|
32
|
-
readonly title: string | null;
|
|
33
|
-
/** Start of the window, inclusive. */
|
|
34
|
-
readonly period_start: Timestamp;
|
|
35
|
-
/** End of the window, exclusive. Also the sort key of the listing. */
|
|
36
|
-
readonly period_end: Timestamp;
|
|
37
|
-
/** LLM that wrote it, as configured at generation time. Nullable. */
|
|
38
|
-
readonly model: string | null;
|
|
39
|
-
}
|
|
40
|
-
/** `GET /intel_reports/:id` - the `:extended` view. */
|
|
41
|
-
export interface IntelReportDetail extends IntelReport {
|
|
42
|
-
/** The report body, usually Markdown. `null` if generation failed halfway. */
|
|
43
|
-
readonly content: string | null;
|
|
44
|
-
/**
|
|
45
|
-
* Whatever the generator chose to record about the run. A free-form JSON
|
|
46
|
-
* object with no schema on either side, defaulting to `{}` - which is why it
|
|
47
|
-
* is typed as a bag rather than as fields. Read it defensively.
|
|
48
|
-
*/
|
|
49
|
-
readonly stats: Record<string, Json> | null;
|
|
50
|
-
/** The stories the report covered, most important first. */
|
|
51
|
-
readonly articles: IntelReportArticleRef[];
|
|
52
|
-
}
|
|
53
|
-
/** Filter columns of `GET /intel_reports`, on top of {@link BASE_FILTER_COLUMNS}. */
|
|
54
|
-
export declare const INTEL_REPORT_FILTER_COLUMNS: readonly ["kind"];
|
|
55
|
-
/** Filters for {@link IntelReportsNamespace.list}. */
|
|
56
|
-
export interface ListIntelReportsParams extends ListParams<(typeof INTEL_REPORT_FILTER_COLUMNS)[number]> {
|
|
57
|
-
/**
|
|
58
|
-
* Narrow to one window, e.g. `"day"`. Sent as `exact_search[kind]`, so it is
|
|
59
|
-
* equality rather than a prefix match - `"6h"` will not also match `"6hx"`.
|
|
60
|
-
*
|
|
61
|
-
* Passing it through {@link ListParams.search} instead would be a
|
|
62
|
-
* partial match and would work too; `kind` is on this controller's
|
|
63
|
-
* `search_params` allowlist. Equality is what you want.
|
|
64
|
-
*/
|
|
65
|
-
readonly kind?: IntelReportKind;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* `GET /intel_reports` - the generated digests.
|
|
69
|
-
*
|
|
70
|
-
* Read-only plus a delete, for the same reason as the stories: reports come
|
|
71
|
-
* from `Intel::GenerateReportJob`. There is no way to ask for one to be
|
|
72
|
-
* generated over HTTP.
|
|
73
|
-
*/
|
|
74
|
-
export declare class IntelReportsNamespace extends Resource {
|
|
75
|
-
/**
|
|
76
|
-
* `GET /intel_reports` - your reports, newest window first.
|
|
77
|
-
*
|
|
78
|
-
* `period_end DESC` is applied by the controller; as with the stories, a
|
|
79
|
-
* `order` of your own becomes the PRIMARY key and this becomes the
|
|
80
|
-
* tie-breaker.
|
|
81
|
-
*
|
|
82
|
-
* `kind` is the only declared filter beyond the inherited three. Use
|
|
83
|
-
* {@link ListIntelReportsParams.kind}, which sends it as an exact match.
|
|
84
|
-
*
|
|
85
|
-
* @throws {OmsApiError} 403 `"Intel access is restricted."` outside the
|
|
86
|
-
* allowlist.
|
|
87
|
-
*/
|
|
88
|
-
list(params?: ListIntelReportsParams, options?: RequestOptions): Promise<Paginated<IntelReport>>;
|
|
89
|
-
/**
|
|
90
|
-
* `GET /intel_reports/:id` - the report with its body and its stories.
|
|
91
|
-
*
|
|
92
|
-
* @throws {OmsApiError} 404 when the report is not yours.
|
|
93
|
-
*/
|
|
94
|
-
get(id: Id, options?: RequestOptions): Promise<IntelReportDetail>;
|
|
95
|
-
/**
|
|
96
|
-
* `DELETE /intel_reports/:id`. `204`, empty body.
|
|
97
|
-
*
|
|
98
|
-
* The stories it cited are untouched - only the join rows go.
|
|
99
|
-
*
|
|
100
|
-
* A deleted report can come back: `GenerateReportJob` is keyed by the unique
|
|
101
|
-
* `(user, kind, period_end)` index, and deleting the row frees that key, so
|
|
102
|
-
* the next dispatcher pass over the same window will regenerate it. Delete a
|
|
103
|
-
* report to re-run it, not to suppress it.
|
|
104
|
-
*
|
|
105
|
-
* @throws {OmsApiError} 404 when the report is not yours.
|
|
106
|
-
*/
|
|
107
|
-
delete(id: Id, options?: RequestOptions): Promise<void>;
|
|
108
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/** Intel stats: the dashboard counters. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { RequestOptions } from "../../../types";
|
|
4
|
-
/** One category bucket of {@link IntelStats}. */
|
|
5
|
-
export interface IntelCategoryCount {
|
|
6
|
-
readonly category: string;
|
|
7
|
-
/** Named `c`, not `count`. */
|
|
8
|
-
readonly c: number;
|
|
9
|
-
}
|
|
10
|
-
/** One day of the {@link IntelStats} histogram. */
|
|
11
|
-
export interface IntelDayCount {
|
|
12
|
-
/** `YYYY-MM-DD`, from Postgres `DATE(last_seen_at)`. Not a full timestamp. */
|
|
13
|
-
readonly day: string;
|
|
14
|
-
readonly c: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* The importance histogram, with the backend's own Portuguese bucket names.
|
|
18
|
-
*
|
|
19
|
-
* The boundaries are hard-coded server-side and are not
|
|
20
|
-
* configurable: `critico` >=9, `alta` 7-8, `media` 5-6, `baixa` 3-4, `ruido`
|
|
21
|
-
* <3. Note they are NOT the same thresholds as
|
|
22
|
-
* {@link IntelConfig.report_min_importance} or
|
|
23
|
-
* {@link IntelConfig.enrich_min_importance} - those are yours, these are the
|
|
24
|
-
* dashboard's.
|
|
25
|
-
*/
|
|
26
|
-
export interface IntelImportanceBuckets {
|
|
27
|
-
readonly critico: number;
|
|
28
|
-
readonly alta: number;
|
|
29
|
-
readonly media: number;
|
|
30
|
-
readonly baixa: number;
|
|
31
|
-
readonly ruido: number;
|
|
32
|
-
}
|
|
33
|
-
/** Row counts on the {@link IntelStats} answer. */
|
|
34
|
-
export interface IntelStatsTotals {
|
|
35
|
-
/** Stories you own. */
|
|
36
|
-
readonly articles: number;
|
|
37
|
-
/**
|
|
38
|
-
* **Not the number of feeds you have configured.** This counts the
|
|
39
|
-
* story-to-item POINTER rows, so this is "how many citations exist across
|
|
40
|
-
* all my stories" and it grows without bound as
|
|
41
|
-
* stories accumulate. If you want the number of configured sources, read the
|
|
42
|
-
* length of {@link IntelSourcesNamespace.list}. The name is the backend's and
|
|
43
|
-
* the SDK does not rename it, but do not put it under a "Sources" label.
|
|
44
|
-
*/
|
|
45
|
-
readonly sources: number;
|
|
46
|
-
readonly reports: number;
|
|
47
|
-
/** Raw items you own, processed or not. */
|
|
48
|
-
readonly items: number;
|
|
49
|
-
/**
|
|
50
|
-
* Items the analysis pipeline has not consumed yet (`processed_at IS NULL`).
|
|
51
|
-
*
|
|
52
|
-
* The one number worth watching: a figure that climbs and never falls means
|
|
53
|
-
* the pipeline is not running - most often because `Intel::LlmClient` is
|
|
54
|
-
* disabled for want of an API key, in which case `AnalysisDispatcherJob`
|
|
55
|
-
* returns immediately and silently.
|
|
56
|
-
*/
|
|
57
|
-
readonly pending_items: number;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* `GET /intel_stats` - counters for the intel dashboard.
|
|
61
|
-
*
|
|
62
|
-
* Not a record: it has no `id`, no timestamps and no `:extended` view.
|
|
63
|
-
*/
|
|
64
|
-
export interface IntelStats {
|
|
65
|
-
readonly totals: IntelStatsTotals;
|
|
66
|
-
/**
|
|
67
|
-
* Categories by story count, descending. Stories with a `null` category are
|
|
68
|
-
* EXCLUDED, so these do not sum to `totals.articles`.
|
|
69
|
-
*/
|
|
70
|
-
readonly by_category: IntelCategoryCount[];
|
|
71
|
-
/**
|
|
72
|
-
* The last 30 days by `last_seen_at`, ascending.
|
|
73
|
-
*
|
|
74
|
-
* Sparse: a day with no activity is simply ABSENT, not present with zero.
|
|
75
|
-
* Fill the gaps before plotting or the line will lie about its own x-axis.
|
|
76
|
-
*/
|
|
77
|
-
readonly by_day: IntelDayCount[];
|
|
78
|
-
readonly by_importance: IntelImportanceBuckets;
|
|
79
|
-
/** Stories touched in the last 24 hours. */
|
|
80
|
-
readonly last24h: number;
|
|
81
|
-
}
|
|
82
|
-
/** `/intel_stats` - the dashboard counters. One route, one verb. */
|
|
83
|
-
export declare class IntelStatsNamespace extends Resource {
|
|
84
|
-
/**
|
|
85
|
-
* `GET /intel_stats` - every counter the intel dashboard shows, in one call.
|
|
86
|
-
*
|
|
87
|
-
* Also a Rails singular resource, so the path is `/intel_stats` with no id
|
|
88
|
-
* despite the plural spelling.
|
|
89
|
-
*
|
|
90
|
-
* **Cost, and the reason not to poll this.** The controller does
|
|
91
|
-
* `articles.pluck(:importance)` - it loads the importance of EVERY story you
|
|
92
|
-
* own into Ruby memory to build {@link IntelStats.by_importance} - and then
|
|
93
|
-
* runs five more aggregate queries beside it. There is no cache, no `ETag`
|
|
94
|
-
* (the hand-written action never calls `stale?`, unlike every list in this
|
|
95
|
-
* file) and therefore no `304`. Cost grows linearly with your story count for
|
|
96
|
-
* ever. Fetch it on a dashboard open, not on a timer.
|
|
97
|
-
*
|
|
98
|
-
* Read {@link IntelStatsTotals.sources} before you label it: it does not
|
|
99
|
-
* count your feeds.
|
|
100
|
-
*
|
|
101
|
-
* @throws {OmsApiError} 403 `"Intel access is restricted."` outside the
|
|
102
|
-
* allowlist.
|
|
103
|
-
*/
|
|
104
|
-
get(options?: RequestOptions): Promise<IntelStats>;
|
|
105
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/** Vocabulary shared across the intel families. */
|
|
2
|
-
/**
|
|
3
|
-
* ## Access: this is effectively a one-user feature
|
|
4
|
-
*
|
|
5
|
-
* Every intel route is gated by a fixed allowlist of one handle plus admins.
|
|
6
|
-
* So: anonymous is `401`, any other signed-in account is
|
|
7
|
-
* `403 "Intel access is restricted."`, and no amount of correct request
|
|
8
|
-
* shaping changes that. Do not build a shared feature on it, and do not
|
|
9
|
-
* treat a 403 here as a bug in the caller.
|
|
10
|
-
*
|
|
11
|
-
* An OAuth access token is `403 {"error":"insufficient_scope"}` on every
|
|
12
|
-
* route below. Session credential only.
|
|
13
|
-
*
|
|
14
|
-
* ## Ids are STRINGS here
|
|
15
|
-
*
|
|
16
|
-
* Articles, reports, sources, scripts, items and the config row all carry
|
|
17
|
-
* opaque string ids, unlike blogs, notifications, jokes and Space Invaders
|
|
18
|
-
* games, whose ids are integers. Nothing in intel is ever a number you can
|
|
19
|
-
* compare or sort by.
|
|
20
|
-
*
|
|
21
|
-
* ## Ceilings
|
|
22
|
-
*
|
|
23
|
-
* None of their own. Every route rides the general bucket: 600 requests per
|
|
24
|
-
* minute for an authenticated caller. Two of them are still expensive and are
|
|
25
|
-
* documented as such - {@link IntelStatsNamespace.get} and
|
|
26
|
-
* {@link IntelSourcesNamespace.run}.
|
|
27
|
-
*/
|
|
28
|
-
/** Categories a story can carry. `null` when the classifier declined to pick one. */
|
|
29
|
-
export declare const INTEL_ARTICLE_CATEGORIES: readonly ["incidente", "politica", "comunidade", "sociedade", "internacional", "economia", "outro"];
|
|
30
|
-
/**
|
|
31
|
-
* A story's category.
|
|
32
|
-
*
|
|
33
|
-
* Widened with `string & {}` deliberately: the list is a Ruby constant that a
|
|
34
|
-
* migration can extend without the SDK noticing, and a `switch` that fails to
|
|
35
|
-
* compile on a new category is worse than one that falls through to a default.
|
|
36
|
-
* The backend DOES validate inclusion, so a value outside the list can only
|
|
37
|
-
* mean the constant moved.
|
|
38
|
-
*/
|
|
39
|
-
export type IntelArticleCategory = (typeof INTEL_ARTICLE_CATEGORIES)[number] | (string & {});
|
|
40
|
-
/** Report windows a report can cover. */
|
|
41
|
-
export declare const INTEL_REPORT_KINDS: readonly ["6h", "day", "week", "month"];
|
|
42
|
-
/** Which window a report covers. */
|
|
43
|
-
export type IntelReportKind = (typeof INTEL_REPORT_KINDS)[number] | (string & {});
|
|
44
|
-
/**
|
|
45
|
-
* Base of the third-party image proxy {@link intelArticleImageUrl} builds on.
|
|
46
|
-
*
|
|
47
|
-
* `wsrv.nl` is a free public image CDN. It is NOT this API and NOT our
|
|
48
|
-
* infrastructure.
|
|
49
|
-
*/
|
|
50
|
-
export declare const INTEL_IMAGE_PROXY_BASE_URL = "https://wsrv.nl/";
|
|
51
|
-
/** Knobs for {@link intelArticleImageUrl}. */
|
|
52
|
-
export interface IntelImageOptions {
|
|
53
|
-
/** Target width in pixels. Default 480. Height follows the aspect ratio. */
|
|
54
|
-
readonly width?: number;
|
|
55
|
-
/** Quality, 1-100. Default 45 - low on purpose; these are thumbnails. */
|
|
56
|
-
readonly quality?: number;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Builds a resized, re-compressed URL for {@link IntelArticle.image_url}.
|
|
60
|
-
*
|
|
61
|
-
* Pure string building, no request, isolate-safe. Returns `""` for a story with
|
|
62
|
-
* no image so it can be dropped straight into an `<img src>` without a
|
|
63
|
-
* conditional - though a real client should test the field and render nothing.
|
|
64
|
-
*
|
|
65
|
-
* ## What this actually does, and why you might not want it
|
|
66
|
-
*
|
|
67
|
-
* `image_url` is the raw `og:image` of a news site: full size, arbitrary
|
|
68
|
-
* format, arbitrary weight, and served from that site's own host. Nothing in
|
|
69
|
-
* this API resizes it. This helper routes it through `wsrv.nl`, a free public
|
|
70
|
-
* image CDN, which fetches the origin image and hands back a width-limited
|
|
71
|
-
* WebP.
|
|
72
|
-
*
|
|
73
|
-
* The trade is explicit and it is not the SDK's to make silently:
|
|
74
|
-
*
|
|
75
|
-
* - the ORIGIN URL is sent to a third party in a query string, so wsrv.nl
|
|
76
|
-
* learns which article your user is looking at, and so does anyone reading
|
|
77
|
-
* the request. There is no credential involved - the images are public - but
|
|
78
|
-
* it is still a referrer-shaped leak;
|
|
79
|
-
* - availability is theirs, not ours. A wsrv.nl outage is a page of broken
|
|
80
|
-
* images, and there is no fallback in the URL;
|
|
81
|
-
* - `&we` asks it not to enlarge images smaller than `width`.
|
|
82
|
-
*
|
|
83
|
-
* If neither trade suits you, use {@link IntelArticle.image_url} directly and
|
|
84
|
-
* size it in CSS.
|
|
85
|
-
*/
|
|
86
|
-
export declare function intelArticleImageUrl(imageUrl: string | null | undefined, options?: IntelImageOptions): string;
|