@alva-ai/toolkit 0.28.1-beta.0 → 0.29.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/dist/index.cjs CHANGED
@@ -633,7 +633,8 @@ var ReleaseResource = class {
633
633
  version: params.version,
634
634
  feeds: params.feeds,
635
635
  changelog: params.changelog,
636
- readme_url: params.readme_url
636
+ readme_url: params.readme_url,
637
+ confirm_bundled_feed_exposure: params.confirm_bundled_feed_exposure
637
638
  }
638
639
  });
639
640
  }
@@ -4156,6 +4157,47 @@ var ThesesResource = class {
4156
4157
  await this.client._request("GET", `/api/v1/theses/${requireID(id, "id")}`)
4157
4158
  );
4158
4159
  }
4160
+ async getVersion(id, authorVersionID) {
4161
+ this.client._requireAuth();
4162
+ const thesisID = requireID(id, "id");
4163
+ const versionID = requireID(authorVersionID, "author_version_id");
4164
+ const response = thesisResponse(
4165
+ await this.client._request(
4166
+ "GET",
4167
+ `/api/v1/theses/${thesisID}/versions/${versionID}`
4168
+ )
4169
+ );
4170
+ if (response.thesis.id !== thesisID || response.thesis.author_version_id !== versionID) {
4171
+ throw invalidResponse2(
4172
+ "version response must match the requested thesis and author version"
4173
+ );
4174
+ }
4175
+ return response;
4176
+ }
4177
+ async signals(id, params = {}) {
4178
+ this.client._requireAuth();
4179
+ const first = params.first ?? 20;
4180
+ if (!Number.isInteger(first) || first < 1 || first > 50) {
4181
+ throw invalidArgument("first must be an integer between 1 and 50");
4182
+ }
4183
+ if (params.cursor !== void 0 && typeof params.cursor !== "string") {
4184
+ throw invalidArgument("cursor must be a string");
4185
+ }
4186
+ return thesisSignalsResponse(
4187
+ await this.client._request(
4188
+ "GET",
4189
+ `/api/v1/theses/${requireID(id, "id")}/signals`,
4190
+ {
4191
+ query: {
4192
+ first,
4193
+ ...params.cursor === void 0 ? {} : { cursor: params.cursor }
4194
+ }
4195
+ }
4196
+ ),
4197
+ id,
4198
+ first
4199
+ );
4200
+ }
4159
4201
  async update(id, params) {
4160
4202
  this.client._requireAuth();
4161
4203
  const body = updateBody(params);
@@ -4169,6 +4211,27 @@ var ThesesResource = class {
4169
4211
  )
4170
4212
  );
4171
4213
  }
4214
+ async setVisibility(id, params) {
4215
+ this.client._requireAuth();
4216
+ if (!params) {
4217
+ throw invalidArgument("params is required");
4218
+ }
4219
+ const thesisID = requireID(id, "id");
4220
+ const visibility = requireVisibility(params.visibility);
4221
+ const response = thesisResponse(
4222
+ await this.client._request(
4223
+ "POST",
4224
+ `/api/v1/theses/${thesisID}/visibility`,
4225
+ { body: { visibility } }
4226
+ )
4227
+ );
4228
+ if (response.thesis.id !== thesisID || response.thesis.visibility !== visibility) {
4229
+ throw invalidResponse2(
4230
+ "visibility response must match the requested thesis and visibility"
4231
+ );
4232
+ }
4233
+ return response;
4234
+ }
4172
4235
  async close(id, params) {
4173
4236
  this.client._requireAuth();
4174
4237
  const body = {
@@ -4216,13 +4279,16 @@ var ThesesResource = class {
4216
4279
  }
4217
4280
  };
4218
4281
  function createBody(params) {
4219
- return {
4282
+ const body = {
4220
4283
  request_id: requireRequestID(params.request_id),
4221
4284
  body: requireBody(params.body),
4222
4285
  title: requireTitle(params.title ?? ""),
4223
4286
  entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
4224
4287
  visibility: requireVisibility(params.visibility ?? "public")
4225
4288
  };
4289
+ if (params.tickers !== void 0)
4290
+ body.tickers = requireTickers(params.tickers);
4291
+ return body;
4226
4292
  }
4227
4293
  function updateBody(params) {
4228
4294
  return {
@@ -4303,6 +4369,112 @@ function thesisGetResponse(response) {
4303
4369
  });
4304
4370
  return { thesis: base.thesis, author, entities };
4305
4371
  }
4372
+ function thesisSignalsResponse(response, thesisID, first) {
4373
+ if (!isRecord2(response) || !isRecord2(response.research) || !Array.isArray(response.entries) || response.entries.length > first) {
4374
+ throw invalidResponse2("invalid Signal history response");
4375
+ }
4376
+ const research = response.research;
4377
+ const status = {
4378
+ state: responseText(research.state, "research.state"),
4379
+ pending_work: responseNonnegativeInteger(
4380
+ research.pending_work,
4381
+ "research.pending_work"
4382
+ ),
4383
+ read_complete: responseBoolean(
4384
+ research.read_complete,
4385
+ "research.read_complete"
4386
+ )
4387
+ };
4388
+ if (research.last_attempt_ms !== void 0)
4389
+ status.last_attempt_ms = responseNonnegativeInteger(
4390
+ research.last_attempt_ms,
4391
+ "research.last_attempt_ms"
4392
+ );
4393
+ if (research.last_completed_ms !== void 0)
4394
+ status.last_completed_ms = responseNonnegativeInteger(
4395
+ research.last_completed_ms,
4396
+ "research.last_completed_ms"
4397
+ );
4398
+ const entries = response.entries.map((raw) => {
4399
+ if (!isRecord2(raw) || !isRecord2(raw.signal) || !isRecord2(raw.signal.source)) {
4400
+ throw invalidResponse2("entry must include a Signal and source");
4401
+ }
4402
+ const signal = raw.signal;
4403
+ const source = signal.source;
4404
+ const signalID = responseID(signal.thesis_id, "signal.thesis_id");
4405
+ if (signalID !== thesisID)
4406
+ throw invalidResponse2("Signal belongs to another Thesis");
4407
+ const cursor = responseNonemptyText(raw.cursor, "entry.cursor");
4408
+ const mappedSource = {
4409
+ title: responseText(source.title, "source.title")
4410
+ };
4411
+ if (source.url !== void 0)
4412
+ mappedSource.url = responseText(source.url, "source.url");
4413
+ if (source.published_at_ms !== void 0)
4414
+ mappedSource.published_at_ms = responseNonnegativeInteger(
4415
+ source.published_at_ms,
4416
+ "source.published_at_ms"
4417
+ );
4418
+ const mappedSignal = {
4419
+ id: responseID(signal.id, "signal.id"),
4420
+ thesis_id: signalID,
4421
+ author_version_id: responseID(
4422
+ signal.author_version_id,
4423
+ "signal.author_version_id"
4424
+ ),
4425
+ statement_snapshot: responseNonemptyText(
4426
+ signal.statement_snapshot,
4427
+ "signal.statement_snapshot"
4428
+ ),
4429
+ stance: responseText(signal.stance, "signal.stance"),
4430
+ explanation: responseText(signal.explanation, "signal.explanation"),
4431
+ information_kind: responseText(
4432
+ signal.information_kind,
4433
+ "signal.information_kind"
4434
+ ),
4435
+ source: mappedSource
4436
+ };
4437
+ if (signal.evidence_excerpt !== void 0) {
4438
+ if (!isRecord2(signal.evidence_excerpt))
4439
+ throw invalidResponse2("invalid evidence excerpt");
4440
+ mappedSignal.evidence_excerpt = {
4441
+ text: responseNonemptyText(
4442
+ signal.evidence_excerpt.text,
4443
+ "evidence_excerpt.text"
4444
+ ),
4445
+ omitted_before: responseBoolean(
4446
+ signal.evidence_excerpt.omitted_before,
4447
+ "evidence_excerpt.omitted_before"
4448
+ ),
4449
+ omitted_after: responseBoolean(
4450
+ signal.evidence_excerpt.omitted_after,
4451
+ "evidence_excerpt.omitted_after"
4452
+ )
4453
+ };
4454
+ }
4455
+ return {
4456
+ feed_entry_id: responseID(raw.feed_entry_id, "feed_entry_id"),
4457
+ cursor,
4458
+ signal: mappedSignal
4459
+ };
4460
+ });
4461
+ const nextCursor = responseText(response.next_cursor, "next_cursor");
4462
+ if (nextCursor && nextCursor !== entries[entries.length - 1]?.cursor) {
4463
+ throw invalidResponse2("next_cursor must match the final entry");
4464
+ }
4465
+ return { research: status, entries, next_cursor: nextCursor };
4466
+ }
4467
+ function responseNonnegativeInteger(value, field) {
4468
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
4469
+ throw invalidResponse2(field + " must be a nonnegative safe integer");
4470
+ }
4471
+ return value;
4472
+ }
4473
+ function responseNonemptyText(value, field) {
4474
+ const valueText = responseText(value, field);
4475
+ if (!valueText.trim()) throw invalidResponse2(field + " must be nonempty");
4476
+ return valueText;
4477
+ }
4306
4478
  function requireRequestID(value) {
4307
4479
  if (!UUID.test(value) || /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(value)) {
4308
4480
  throw invalidArgument("request_id must be a non-zero RFC 4122 UUID");
@@ -4326,6 +4498,19 @@ function requireIDs(value, field) {
4326
4498
  }
4327
4499
  return value.map((item, index) => requireID(item, `${field}[${index}]`));
4328
4500
  }
4501
+ function requireTickers(value) {
4502
+ if (!Array.isArray(value)) throw invalidArgument("tickers must be an array");
4503
+ if (value.length > 100) {
4504
+ throw invalidArgument("tickers must contain at most 100 values");
4505
+ }
4506
+ return value.map((item, index) => {
4507
+ const ticker = requireText2(item, `tickers[${index}]`);
4508
+ if (ticker.trim() === "" || ticker.includes("\0")) {
4509
+ throw invalidArgument(`tickers[${index}] must be non-empty`);
4510
+ }
4511
+ return ticker;
4512
+ });
4513
+ }
4329
4514
  function requireBody(value) {
4330
4515
  const body = requireText2(value, "body");
4331
4516
  if (body.trim().length === 0) throw invalidArgument("body must not be blank");
@@ -5280,7 +5465,7 @@ var installPlaybookRuntime = (targetWindow) => {
5280
5465
  };
5281
5466
 
5282
5467
  // src/index.ts
5283
- var VERSION = true ? "0.28.1-beta.0" : "dev";
5468
+ var VERSION = true ? "0.29.0" : "dev";
5284
5469
  // Annotate the CommonJS export names for ESM import in node:
5285
5470
  0 && (module.exports = {
5286
5471
  AlertsResource,