@wirecat/cli-core 0.703.0 → 0.705.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/bot/api-http.d.ts +8 -2
  4. package/dist/cli/bot/api-http.js +20 -4
  5. package/dist/cli/documents/words.d.ts +1 -1
  6. package/dist/cli/index.d.ts +3 -3
  7. package/dist/cli/index.js +3 -3
  8. package/dist/cli/messenger/store-maintenance-command.js +6 -2
  9. package/dist/cli/service-api-call.d.ts +13 -3
  10. package/dist/cli/service-api-call.js +19 -9
  11. package/dist/cli/service-api-manifest.d.ts +11 -2
  12. package/dist/cli/service-api-manifest.js +30 -9
  13. package/dist/cli/service-api.d.ts +14 -6
  14. package/dist/cli/service-api.js +137 -29
  15. package/dist/cli/token-session.d.ts +5 -2
  16. package/dist/cli/token-session.js +13 -4
  17. package/dist/content/cli/index.d.ts +33 -0
  18. package/dist/content/cli/index.js +368 -0
  19. package/dist/content/index.d.ts +8 -0
  20. package/dist/content/index.js +7 -0
  21. package/dist/content/manifest/index.d.ts +4 -0
  22. package/dist/content/manifest/index.js +4 -0
  23. package/dist/content/manifest/manifest.d.ts +92 -0
  24. package/dist/content/manifest/manifest.js +137 -0
  25. package/dist/content/manifest/map.d.ts +25 -0
  26. package/dist/content/manifest/map.js +94 -0
  27. package/dist/content/manifest/source.d.ts +41 -0
  28. package/dist/content/manifest/source.js +288 -0
  29. package/dist/content/manifest/writer.d.ts +26 -0
  30. package/dist/content/manifest/writer.js +133 -0
  31. package/dist/content/source.d.ts +64 -0
  32. package/dist/content/source.js +2 -0
  33. package/dist/content/sync.d.ts +61 -0
  34. package/dist/content/sync.js +387 -0
  35. package/dist/content/testing/index.d.ts +4 -0
  36. package/dist/content/testing/index.js +4 -0
  37. package/dist/content/testing/source-contract.d.ts +38 -0
  38. package/dist/content/testing/source-contract.js +274 -0
  39. package/dist/content/testing/source.d.ts +55 -0
  40. package/dist/content/testing/source.js +276 -0
  41. package/dist/content/testing/sync-contract.d.ts +10 -0
  42. package/dist/content/testing/sync-contract.js +172 -0
  43. package/dist/content/testing/write-contract.d.ts +14 -0
  44. package/dist/content/testing/write-contract.js +102 -0
  45. package/dist/content/writer.d.ts +64 -0
  46. package/dist/content/writer.js +38 -0
  47. package/dist/content/writes.d.ts +58 -0
  48. package/dist/content/writes.js +129 -0
  49. package/dist/documents/file-mirror-model.d.ts +90 -0
  50. package/dist/documents/file-mirror-model.js +1 -0
  51. package/dist/documents/index.d.ts +6 -3
  52. package/dist/documents/index.js +3 -1
  53. package/dist/documents/push-model.d.ts +3 -0
  54. package/dist/domain/content.d.ts +102 -0
  55. package/dist/domain/content.js +11 -0
  56. package/dist/embeddings/onnx-runtime.d.ts +1 -1
  57. package/dist/embeddings/onnx-runtime.js +42 -61
  58. package/dist/errors/reasons.js +22 -0
  59. package/dist/manifest/index.d.ts +21 -7
  60. package/dist/manifest/index.js +7 -4
  61. package/dist/ports/wirecat-tools.js +7 -0
  62. package/dist/sends/upload.js +0 -1
  63. package/dist/services/documents/mirror-watch.d.ts +12 -4
  64. package/dist/services/documents/mirror-watch.js +2 -0
  65. package/dist/services/documents/mirrors.d.ts +67 -35
  66. package/dist/services/documents/mirrors.js +72 -66
  67. package/dist/services/documents/push.d.ts +56 -4
  68. package/dist/services/documents/push.js +131 -24
  69. package/dist/services/files/mirror.d.ts +157 -0
  70. package/dist/services/files/mirror.js +660 -0
  71. package/dist/services/files/versions.d.ts +60 -0
  72. package/dist/services/files/versions.js +177 -0
  73. package/dist/services/metadata.d.ts +1 -1
  74. package/dist/store/exports.d.ts +1 -0
  75. package/dist/store/exports.js +1 -0
  76. package/dist/store/recover.js +2 -0
  77. package/dist/store/sqlite/account-purge.js +7 -0
  78. package/dist/store/sqlite/content.d.ts +100 -0
  79. package/dist/store/sqlite/content.js +375 -0
  80. package/dist/store/sqlite/entity-types.d.ts +1 -0
  81. package/dist/store/sqlite/entity-types.js +1 -0
  82. package/dist/store/sqlite/manifest.js +2 -0
  83. package/dist/store/sqlite/migrations.generated.js +26 -0
  84. package/dist/store/sqlite/schema.d.ts +1140 -0
  85. package/dist/store/sqlite/schema.js +100 -0
  86. package/dist/store/store.d.ts +3 -0
  87. package/dist/store/store.js +5 -0
  88. package/package.json +12 -4
@@ -2401,6 +2401,106 @@ export const trackerItems = sqliteTable("tracker_items", {
2401
2401
  unique().on(table.accountId, table.kind, table.externalId),
2402
2402
  index("tracker_items_by_account_id_kind_parent_id").on(table.accountId, table.kind, table.parentId),
2403
2403
  ]);
2404
+ /** A site or a social account a content account publishes on. */
2405
+ export const contentChannels = sqliteTable("content_channels", {
2406
+ id: integer("id").primaryKey(),
2407
+ accountId: integer("account_id")
2408
+ .notNull()
2409
+ .references(() => accounts.id),
2410
+ externalId: text("external_id").notNull(),
2411
+ kind: text("kind").notNull(),
2412
+ network: text("network").notNull(),
2413
+ name: text("name").notNull(),
2414
+ url: text("url"),
2415
+ handle: text("handle"),
2416
+ deletedAt: integer("deleted_at"),
2417
+ syncedAt: integer("synced_at").notNull(),
2418
+ }, (table) => [unique().on(table.accountId, table.externalId)]);
2419
+ export const contentAuthors = sqliteTable("content_authors", {
2420
+ id: integer("id").primaryKey(),
2421
+ accountId: integer("account_id")
2422
+ .notNull()
2423
+ .references(() => accounts.id),
2424
+ externalId: text("external_id").notNull(),
2425
+ name: text("name").notNull(),
2426
+ email: text("email"),
2427
+ data: text("data").notNull(),
2428
+ sourceUpdatedAt: integer("source_updated_at"),
2429
+ deletedAt: integer("deleted_at"),
2430
+ syncedAt: integer("synced_at").notNull(),
2431
+ }, (table) => [unique().on(table.accountId, table.externalId)]);
2432
+ export const contentTerms = sqliteTable("content_terms", {
2433
+ id: integer("id").primaryKey(),
2434
+ accountId: integer("account_id")
2435
+ .notNull()
2436
+ .references(() => accounts.id),
2437
+ externalId: text("external_id").notNull(),
2438
+ kind: text("kind").notNull(),
2439
+ name: text("name").notNull(),
2440
+ slug: text("slug"),
2441
+ parentId: text("parent_id"),
2442
+ tagId: integer("tag_id").references(() => canonicalTags.id),
2443
+ data: text("data").notNull(),
2444
+ sourceUpdatedAt: integer("source_updated_at"),
2445
+ deletedAt: integer("deleted_at"),
2446
+ syncedAt: integer("synced_at").notNull(),
2447
+ }, (table) => [unique().on(table.accountId, table.externalId), index("content_terms_by_tag_id").on(table.tagId)]);
2448
+ /** A post or page of a blog, or a social post, with its text as Markdown; the rest of the record is `data`. */
2449
+ export const contentPosts = sqliteTable("content_posts", {
2450
+ id: integer("id").primaryKey(),
2451
+ accountId: integer("account_id")
2452
+ .notNull()
2453
+ .references(() => accounts.id),
2454
+ externalId: text("external_id").notNull(),
2455
+ channelId: text("channel_id"),
2456
+ type: text("type").notNull(),
2457
+ title: text("title"),
2458
+ titleFolded: text("title_folded").notNull(),
2459
+ body: text("body"),
2460
+ contentHash: text("content_hash").notNull(),
2461
+ status: text("status").notNull(),
2462
+ publishedAt: integer("published_at"),
2463
+ scheduledFor: integer("scheduled_for"),
2464
+ sourceCreatedAt: integer("source_created_at"),
2465
+ sourceUpdatedAt: integer("source_updated_at"),
2466
+ version: text("version"),
2467
+ normalizedText: text("normalized_text").notNull(),
2468
+ data: text("data").notNull(),
2469
+ deletedAt: integer("deleted_at"),
2470
+ syncedAt: integer("synced_at").notNull(),
2471
+ }, (table) => [
2472
+ unique().on(table.accountId, table.externalId),
2473
+ index("content_posts_by_account_id_status").on(table.accountId, table.status),
2474
+ index("content_posts_by_account_id_published_at").on(table.accountId, table.publishedAt),
2475
+ ]);
2476
+ /** What a sync or a write replaced in a post, and a post the source deleted, kept before the change. */
2477
+ export const contentPostRevisions = sqliteTable("content_post_revisions", {
2478
+ id: integer("id").primaryKey(),
2479
+ postId: integer("post_id")
2480
+ .notNull()
2481
+ .references(() => contentPosts.id),
2482
+ title: text("title"),
2483
+ body: text("body"),
2484
+ status: text("status").notNull(),
2485
+ contentHash: text("content_hash").notNull(),
2486
+ version: text("version"),
2487
+ reason: text("reason").notNull(),
2488
+ createdAt: integer("created_at").notNull(),
2489
+ }, (table) => [index("content_post_revisions_by_post_id_created_at").on(table.postId, table.createdAt)]);
2490
+ /** One reading of a post's numbers; each reading is a new row. */
2491
+ export const contentMetrics = sqliteTable("content_metrics", {
2492
+ id: integer("id").primaryKey(),
2493
+ postId: integer("post_id")
2494
+ .notNull()
2495
+ .references(() => contentPosts.id),
2496
+ at: integer("at").notNull(),
2497
+ views: integer("views"),
2498
+ reactions: integer("reactions"),
2499
+ comments: integer("comments"),
2500
+ shares: integer("shares"),
2501
+ clicks: integer("clicks"),
2502
+ raw: text("raw"),
2503
+ }, (table) => [index("content_metrics_by_post_id_at").on(table.postId, table.at)]);
2404
2504
  /** Settings of the store file itself, shared by every profile, tg and MAX — unlike a profile's config file. */
2405
2505
  export const storeSettings = sqliteTable("store_settings", {
2406
2506
  key: text("key").primaryKey(),
@@ -25,6 +25,7 @@ import { type BotUpdateStore } from "./sqlite/bot-updates.js";
25
25
  import { type ContractsStore } from "./sqlite/business-contracts.js";
26
26
  import { type BusinessSearchStore } from "./sqlite/business-search.js";
27
27
  import { type CatalogStore } from "./sqlite/catalog.js";
28
+ import { type ContentStore } from "./sqlite/content.js";
28
29
  import { type CrmCopies } from "./sqlite/crm.js";
29
30
  import { type CrmFileStore } from "./sqlite/crm-files.js";
30
31
  import { type DealsStore } from "./sqlite/deals.js";
@@ -145,6 +146,8 @@ export interface MessageStore {
145
146
  readonly crmFiles: CrmFileStore;
146
147
  /** Issue trackers' copies: teams, users, states, labels, projects, issues and comments, as last synced. */
147
148
  readonly tracker: TrackerStore;
149
+ /** Blogs' and social accounts' copies: channels, authors, terms, posts with their versions, and metrics. */
150
+ readonly content: ContentStore;
148
151
  /** Relationships a source account reports, written as a diff that never overrides the owner's. */
149
152
  readonly relations: RelationsStore;
150
153
  /** The one-time keys behind the buttons of a message that asks the owner to decide a batch. */
@@ -22,6 +22,7 @@ import { contractsStoreOver } from "./sqlite/business-contracts.js";
22
22
  import { businessSearchOver } from "./sqlite/business-search.js";
23
23
  import { eventStoreOver } from "./sqlite/calendar.js";
24
24
  import { catalogStoreOver } from "./sqlite/catalog.js";
25
+ import { contentStoreOver } from "./sqlite/content.js";
25
26
  import { contextEvidenceOver, contextIndexOver, contextRecordsOver } from "./sqlite/context-evidence.js";
26
27
  import { crmCopiesOver } from "./sqlite/crm.js";
27
28
  import { crmFilesOver } from "./sqlite/crm-files.js";
@@ -143,6 +144,7 @@ const storeOver = (context) => {
143
144
  const crm = once(() => crmCopiesOver(context, accountPeopleOver(context)));
144
145
  const crmFiles = once(() => crmFilesOver(context));
145
146
  const tracker = once(() => trackerStoreOver(context));
147
+ const content = once(() => contentStoreOver(context));
146
148
  const relations = once(() => relationsStoreOver(context));
147
149
  const decisionRequests = once(() => decisionRequestStoreOver(context));
148
150
  const templates = once(() => templateStoreOver(context));
@@ -291,6 +293,9 @@ const storeOver = (context) => {
291
293
  get tracker() {
292
294
  return tracker();
293
295
  },
296
+ get content() {
297
+ return content();
298
+ },
294
299
  get crmFiles() {
295
300
  return crmFiles();
296
301
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.703.0",
3
+ "version": "0.705.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -15,7 +15,7 @@
15
15
  "type": "module",
16
16
  "wirecat": {
17
17
  "store": {
18
- "speaks": 70,
18
+ "speaks": 71,
19
19
  "minCompatible": 56
20
20
  }
21
21
  },
@@ -159,6 +159,14 @@
159
159
  "types": "./dist/crm/testing/index.d.ts",
160
160
  "default": "./dist/crm/testing/index.js"
161
161
  },
162
+ "./content": {
163
+ "types": "./dist/content/index.d.ts",
164
+ "default": "./dist/content/index.js"
165
+ },
166
+ "./content/testing": {
167
+ "types": "./dist/content/testing/index.d.ts",
168
+ "default": "./dist/content/testing/index.js"
169
+ },
162
170
  "./tracker": {
163
171
  "types": "./dist/tracker/index.d.ts",
164
172
  "default": "./dist/tracker/index.js"
@@ -318,7 +326,7 @@
318
326
  "@types/pngjs": "6.0.5",
319
327
  "@types/ssh2": "1.15.5",
320
328
  "@vitest/coverage-v8": "^5.0.5",
321
- "@wirecat/cli-base": "0.118.0",
329
+ "@wirecat/cli-base": "0.120.0",
322
330
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
323
331
  "ajv": "8.17.1",
324
332
  "commander": "15.0.0",
@@ -342,7 +350,7 @@
342
350
  },
343
351
  "peerDependencies": {
344
352
  "@napi-rs/canvas": ">=0.1.69 <2",
345
- "@wirecat/cli-base": ">=0.118.0 <1.0.0",
353
+ "@wirecat/cli-base": ">=0.120.0 <1.0.0",
346
354
  "commander": ">=15",
347
355
  "mysql2": "^3.24.6",
348
356
  "pg": "^8.23.1",