@omelhorsite/sdk 0.13.0 → 0.16.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 +399 -170
- 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 +115 -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 +209 -0
- package/dist/types/resources/index.d.ts +1 -0
- package/dist/types/resources/llm.d.ts +71 -0
- package/dist/types/resources/music/social.d.ts +121 -81
- package/dist/types/resources/music/songs.d.ts +39 -1
- 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,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;
|