@omelhorsite/sdk 0.16.0 → 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 +1 -1
- package/dist/index.js +13 -0
- package/dist/types/resources/content/news/items.d.ts +40 -0
- package/dist/types/resources/cron.d.ts +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ const rows = await oms.http.get<{ id: string }[]>("/some/path");
|
|
|
132
132
|
- `oms.cron` - your TypeScript scripts run on a schedule by the server, with this SDK in scope; runs, logs and templates.
|
|
133
133
|
- `oms.search` - web, image, news and video search, and reading a page's text.
|
|
134
134
|
- `oms.social` - direct messages, friends, group chats.
|
|
135
|
-
- `oms.content.news` - news feeds: sources driven by scripts (RSS, Telegram, YouTube, a page with a selector), the items they produce, full-text search over them.
|
|
135
|
+
- `oms.content.news` - news feeds: sources driven by scripts (RSS, Telegram, YouTube, a page with a selector), the items they produce, full-text and similarity search over them.
|
|
136
136
|
- `oms.content` - blogs (several per account, public, unlisted or private with invited members; `oms.content.blogs.own` manages them), notifications, feedback, site status. `oms.content.notifications.unsubscribe(token)` honours the link at the foot of a notification email and needs no credential.
|
|
137
137
|
- `oms.tools` - media tools, each with its own daily quota.
|
|
138
138
|
- `oms.jobs`, `oms.quotas` - background jobs and account limits.
|
package/dist/index.js
CHANGED
|
@@ -11457,6 +11457,17 @@ class NewsItemsNamespace extends Resource {
|
|
|
11457
11457
|
async get(id, options = {}) {
|
|
11458
11458
|
return this.http.get(`/news_items/${encodeURIComponent(id)}`, options);
|
|
11459
11459
|
}
|
|
11460
|
+
async similar(params, options = {}) {
|
|
11461
|
+
const query = {
|
|
11462
|
+
text: params.text,
|
|
11463
|
+
item_id: params.itemId,
|
|
11464
|
+
news_feed_id: params.feedId,
|
|
11465
|
+
limit: params.limit,
|
|
11466
|
+
since: params.since,
|
|
11467
|
+
max_distance: params.maxDistance
|
|
11468
|
+
};
|
|
11469
|
+
return this.http.get("/news_items/similar", { ...options, query });
|
|
11470
|
+
}
|
|
11460
11471
|
async delete(id, options = {}) {
|
|
11461
11472
|
await this.http.delete(`/news_items/${encodeURIComponent(id)}`, options);
|
|
11462
11473
|
}
|
|
@@ -11788,6 +11799,7 @@ var CRON_JOB_MIN_INTERVAL_MINUTES = 5;
|
|
|
11788
11799
|
var CRON_JOB_MIN_TIMEOUT_SECONDS = 5;
|
|
11789
11800
|
var CRON_JOB_MAX_TIMEOUT_SECONDS = 1200;
|
|
11790
11801
|
var CRON_JOB_BASE_MAX_TIMEOUT_SECONDS = 120;
|
|
11802
|
+
var CRON_VAR_TYPES = Object.freeze(["string", "text", "number", "boolean", "list", "json"]);
|
|
11791
11803
|
var CRON_JOB_FILTER_COLUMNS = Object.freeze(["name", "enabled", "health", "template_slug"]);
|
|
11792
11804
|
var CRON_RUN_STATUSES = Object.freeze(["queued", "running", "ok", "error", "timeout", "skipped"]);
|
|
11793
11805
|
var CRON_RUN_TRIGGERS = Object.freeze(["schedule", "manual", "test"]);
|
|
@@ -16643,6 +16655,7 @@ export {
|
|
|
16643
16655
|
ChestsNamespace,
|
|
16644
16656
|
ChestEntriesNamespace,
|
|
16645
16657
|
CaptionsNamespace,
|
|
16658
|
+
CRON_VAR_TYPES,
|
|
16646
16659
|
CRON_RUN_TRIGGERS,
|
|
16647
16660
|
CRON_RUN_STATUSES,
|
|
16648
16661
|
CRON_RUN_FILTER_COLUMNS,
|
|
@@ -73,6 +73,30 @@ export interface ListNewsItemsParams extends ListParams<(typeof NEWS_ITEM_FILTER
|
|
|
73
73
|
/** Only items written at or before this instant (ISO 8601). */
|
|
74
74
|
readonly until?: string;
|
|
75
75
|
}
|
|
76
|
+
/** Parameters of {@link NewsItemsNamespace.similar}: an anchor plus optional narrowing. */
|
|
77
|
+
export type SimilarNewsItemsParams = ({
|
|
78
|
+
/** Free text to compare against. */
|
|
79
|
+
readonly text: string;
|
|
80
|
+
readonly itemId?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
/** One of your items to compare against. It never comes back in the results. */
|
|
83
|
+
readonly itemId: Id;
|
|
84
|
+
readonly text?: undefined;
|
|
85
|
+
}) & {
|
|
86
|
+
/** Only items of one feed. */
|
|
87
|
+
readonly feedId?: Id;
|
|
88
|
+
/** 1..50, default 10. */
|
|
89
|
+
readonly limit?: number;
|
|
90
|
+
/** Only items written at or after this instant (ISO 8601). */
|
|
91
|
+
readonly since?: string | Date;
|
|
92
|
+
/** Cosine distance ceiling, 0..1, default 0.35. Lower is stricter. */
|
|
93
|
+
readonly maxDistance?: number;
|
|
94
|
+
};
|
|
95
|
+
/** A hit of {@link NewsItemsNamespace.similar}: the item plus how far it sits from the anchor. */
|
|
96
|
+
export type SimilarNewsItem = NewsItem & {
|
|
97
|
+
/** Cosine distance to the anchor: `0` is the same text, `1` unrelated. */
|
|
98
|
+
readonly distance: number;
|
|
99
|
+
};
|
|
76
100
|
/**
|
|
77
101
|
* `/news_items` - the raw material.
|
|
78
102
|
*
|
|
@@ -102,6 +126,22 @@ export declare class NewsItemsNamespace extends Resource {
|
|
|
102
126
|
* @throws {OmsApiError} 404 when the item is not yours.
|
|
103
127
|
*/
|
|
104
128
|
get(id: Id, options?: RequestOptions): Promise<NewsItem>;
|
|
129
|
+
/**
|
|
130
|
+
* `GET /news_items/similar` - your items closest in meaning to a text or to
|
|
131
|
+
* one of your items, nearest first, no paging.
|
|
132
|
+
*
|
|
133
|
+
* Meaning, not words: "mesquita de Lisboa" finds an item about the mosque
|
|
134
|
+
* that never uses the word. Every item gets its vector shortly after it is
|
|
135
|
+
* written, so a fresh one may still be missing from the results; videos
|
|
136
|
+
* have none (the news cut from them do).
|
|
137
|
+
*
|
|
138
|
+
* @throws {OmsApiError} 400 when neither `text` nor `itemId` is given, `limit`
|
|
139
|
+
* is outside 1..50, `maxDistance` outside 0..1, or `since` is not ISO 8601.
|
|
140
|
+
* @throws {OmsApiError} 404 when `itemId` is not yours.
|
|
141
|
+
* @throws {OmsApiError} 422 when that item has no vector yet.
|
|
142
|
+
* @throws {OmsApiError} 502 when `text` cannot be embedded right now.
|
|
143
|
+
*/
|
|
144
|
+
similar(params: SimilarNewsItemsParams, options?: RequestOptions): Promise<SimilarNewsItem[]>;
|
|
105
145
|
/**
|
|
106
146
|
* `DELETE /news_items/:id`. `204`, empty body.
|
|
107
147
|
*
|
|
@@ -67,11 +67,25 @@ export interface CronJob {
|
|
|
67
67
|
/** Whether a run is queued or running right now. */
|
|
68
68
|
readonly running: boolean;
|
|
69
69
|
}
|
|
70
|
-
/**
|
|
70
|
+
/** The types a script may give a variable it declares with `// @var key type Label | description`. */
|
|
71
|
+
export declare const CRON_VAR_TYPES: readonly ["string", "text", "number", "boolean", "list", "json"];
|
|
72
|
+
export type CronVarType = (typeof CRON_VAR_TYPES)[number];
|
|
73
|
+
/**
|
|
74
|
+
* A variable a script declares as editable, parsed by the server from the
|
|
75
|
+
* `// @var` lines at the top of the code. Its value lives in `config[key]`.
|
|
76
|
+
*/
|
|
77
|
+
export interface CronVar {
|
|
78
|
+
readonly key: string;
|
|
79
|
+
readonly type: CronVarType;
|
|
80
|
+
readonly label: string;
|
|
81
|
+
readonly description: string | null;
|
|
82
|
+
}
|
|
83
|
+
/** `GET /cron_jobs/:id` (and every write) adds the code, the config, the state and the declared variables. */
|
|
71
84
|
export interface CronJobDetail extends CronJob {
|
|
72
85
|
readonly code: string;
|
|
73
86
|
readonly config: Record<string, Json>;
|
|
74
87
|
readonly state: Record<string, Json>;
|
|
88
|
+
readonly vars: CronVar[];
|
|
75
89
|
}
|
|
76
90
|
export declare const CRON_JOB_FILTER_COLUMNS: readonly ["name", "enabled", "health", "template_slug"];
|
|
77
91
|
export interface ListCronJobsParams extends ListParams<(typeof CRON_JOB_FILTER_COLUMNS)[number]> {
|
|
@@ -147,6 +161,8 @@ export interface CronTemplate {
|
|
|
147
161
|
readonly network: boolean;
|
|
148
162
|
/** The config the script reads, with defaults. */
|
|
149
163
|
readonly config: Record<string, Json>;
|
|
164
|
+
/** The variables the template declares as editable (`// @var`). */
|
|
165
|
+
readonly vars: CronVar[];
|
|
150
166
|
/** SHA-256 of the code, so a client can tell an edited copy from a pristine one. */
|
|
151
167
|
readonly hash: string;
|
|
152
168
|
}
|
package/package.json
CHANGED