@scalemule/sdk 0.0.51 → 0.0.53

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.d.mts CHANGED
@@ -2394,6 +2394,29 @@ interface Like {
2394
2394
  user_id: string;
2395
2395
  created_at: string;
2396
2396
  }
2397
+ /**
2398
+ * Bipolar vote state. Score = up_count - down_count.
2399
+ *
2400
+ * `value` is the *caller's* current vote on the target:
2401
+ * 1 = upvote, -1 = downvote, 0 = no vote.
2402
+ */
2403
+ interface VoteState {
2404
+ value: 1 | -1 | 0;
2405
+ up_count: number;
2406
+ down_count: number;
2407
+ score: number;
2408
+ }
2409
+ /**
2410
+ * View counters for a target.
2411
+ *
2412
+ * `view_count` is total recorded views. `unique_viewer_count` is the
2413
+ * count of distinct (viewer, day) buckets — i.e. how many distinct
2414
+ * people viewed across all time, deduped per day.
2415
+ */
2416
+ interface ViewState {
2417
+ view_count: number;
2418
+ unique_viewer_count: number;
2419
+ }
2397
2420
  declare class SocialService extends ServiceModule {
2398
2421
  protected basePath: string;
2399
2422
  follow(userId: string, options?: RequestOptions): Promise<ApiResponse<{
@@ -2422,6 +2445,41 @@ declare class SocialService extends ServiceModule {
2422
2445
  unliked: boolean;
2423
2446
  }>>;
2424
2447
  getLikes(targetType: string, targetId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Like>>;
2448
+ /**
2449
+ * Cast, change, or clear the caller's vote on a target.
2450
+ *
2451
+ * `value`: 1 = upvote, -1 = downvote, 0 = clear.
2452
+ *
2453
+ * Idempotent: re-casting the same value is a no-op; clearing when no
2454
+ * vote exists is a no-op. Server validates `target_type` matches
2455
+ * `[a-z0-9_]{1,64}`. Convention: prefix per app (`weekmob_post`,
2456
+ * `gistyo_gist`).
2457
+ *
2458
+ * Requires an authenticated session; anonymous calls return 401.
2459
+ */
2460
+ vote(targetType: string, targetId: string, value: 1 | -1 | 0, options?: RequestOptions): Promise<ApiResponse<VoteState>>;
2461
+ /**
2462
+ * Read the caller's current vote on a target plus the aggregate counts.
2463
+ * `value` is 0 when the caller has no vote.
2464
+ *
2465
+ * Requires an authenticated session.
2466
+ */
2467
+ getVote(targetType: string, targetId: string, options?: RequestOptions): Promise<ApiResponse<VoteState>>;
2468
+ /**
2469
+ * Record a view of a target. Increments the total counter
2470
+ * unconditionally; increments the unique-viewer counter once per
2471
+ * (viewer, UTC day).
2472
+ *
2473
+ * Authenticated callers don't need to pass `viewerFingerprint` — the
2474
+ * user_id is used. Anonymous callers may pass a 64-hex-char
2475
+ * fingerprint hash to participate in unique-viewer dedupe; without
2476
+ * one, only the total counter moves.
2477
+ */
2478
+ recordView(targetType: string, targetId: string, viewerFingerprint?: string, options?: RequestOptions): Promise<ApiResponse<ViewState>>;
2479
+ /**
2480
+ * Read view counters for a target.
2481
+ */
2482
+ getViews(targetType: string, targetId: string, options?: RequestOptions): Promise<ApiResponse<ViewState>>;
2425
2483
  comment(postId: string, data: {
2426
2484
  content: string;
2427
2485
  }, options?: RequestOptions): Promise<ApiResponse<Comment>>;
package/dist/index.d.ts CHANGED
@@ -2394,6 +2394,29 @@ interface Like {
2394
2394
  user_id: string;
2395
2395
  created_at: string;
2396
2396
  }
2397
+ /**
2398
+ * Bipolar vote state. Score = up_count - down_count.
2399
+ *
2400
+ * `value` is the *caller's* current vote on the target:
2401
+ * 1 = upvote, -1 = downvote, 0 = no vote.
2402
+ */
2403
+ interface VoteState {
2404
+ value: 1 | -1 | 0;
2405
+ up_count: number;
2406
+ down_count: number;
2407
+ score: number;
2408
+ }
2409
+ /**
2410
+ * View counters for a target.
2411
+ *
2412
+ * `view_count` is total recorded views. `unique_viewer_count` is the
2413
+ * count of distinct (viewer, day) buckets — i.e. how many distinct
2414
+ * people viewed across all time, deduped per day.
2415
+ */
2416
+ interface ViewState {
2417
+ view_count: number;
2418
+ unique_viewer_count: number;
2419
+ }
2397
2420
  declare class SocialService extends ServiceModule {
2398
2421
  protected basePath: string;
2399
2422
  follow(userId: string, options?: RequestOptions): Promise<ApiResponse<{
@@ -2422,6 +2445,41 @@ declare class SocialService extends ServiceModule {
2422
2445
  unliked: boolean;
2423
2446
  }>>;
2424
2447
  getLikes(targetType: string, targetId: string, params?: PaginationParams, requestOptions?: RequestOptions): Promise<PaginatedResponse<Like>>;
2448
+ /**
2449
+ * Cast, change, or clear the caller's vote on a target.
2450
+ *
2451
+ * `value`: 1 = upvote, -1 = downvote, 0 = clear.
2452
+ *
2453
+ * Idempotent: re-casting the same value is a no-op; clearing when no
2454
+ * vote exists is a no-op. Server validates `target_type` matches
2455
+ * `[a-z0-9_]{1,64}`. Convention: prefix per app (`weekmob_post`,
2456
+ * `gistyo_gist`).
2457
+ *
2458
+ * Requires an authenticated session; anonymous calls return 401.
2459
+ */
2460
+ vote(targetType: string, targetId: string, value: 1 | -1 | 0, options?: RequestOptions): Promise<ApiResponse<VoteState>>;
2461
+ /**
2462
+ * Read the caller's current vote on a target plus the aggregate counts.
2463
+ * `value` is 0 when the caller has no vote.
2464
+ *
2465
+ * Requires an authenticated session.
2466
+ */
2467
+ getVote(targetType: string, targetId: string, options?: RequestOptions): Promise<ApiResponse<VoteState>>;
2468
+ /**
2469
+ * Record a view of a target. Increments the total counter
2470
+ * unconditionally; increments the unique-viewer counter once per
2471
+ * (viewer, UTC day).
2472
+ *
2473
+ * Authenticated callers don't need to pass `viewerFingerprint` — the
2474
+ * user_id is used. Anonymous callers may pass a 64-hex-char
2475
+ * fingerprint hash to participate in unique-viewer dedupe; without
2476
+ * one, only the total counter moves.
2477
+ */
2478
+ recordView(targetType: string, targetId: string, viewerFingerprint?: string, options?: RequestOptions): Promise<ApiResponse<ViewState>>;
2479
+ /**
2480
+ * Read view counters for a target.
2481
+ */
2482
+ getViews(targetType: string, targetId: string, options?: RequestOptions): Promise<ApiResponse<ViewState>>;
2425
2483
  comment(postId: string, data: {
2426
2484
  content: string;
2427
2485
  }, options?: RequestOptions): Promise<ApiResponse<Comment>>;
package/dist/index.js CHANGED
@@ -4854,6 +4854,56 @@ var SocialService = class extends ServiceModule {
4854
4854
  return this._list(`/${targetType}/${targetId}/likes`, params, requestOptions);
4855
4855
  }
4856
4856
  // --------------------------------------------------------------------------
4857
+ // Voting (bipolar — up/down with score)
4858
+ // --------------------------------------------------------------------------
4859
+ /**
4860
+ * Cast, change, or clear the caller's vote on a target.
4861
+ *
4862
+ * `value`: 1 = upvote, -1 = downvote, 0 = clear.
4863
+ *
4864
+ * Idempotent: re-casting the same value is a no-op; clearing when no
4865
+ * vote exists is a no-op. Server validates `target_type` matches
4866
+ * `[a-z0-9_]{1,64}`. Convention: prefix per app (`weekmob_post`,
4867
+ * `gistyo_gist`).
4868
+ *
4869
+ * Requires an authenticated session; anonymous calls return 401.
4870
+ */
4871
+ async vote(targetType, targetId, value, options) {
4872
+ return this.put(`/${targetType}/${targetId}/vote`, { value }, options);
4873
+ }
4874
+ /**
4875
+ * Read the caller's current vote on a target plus the aggregate counts.
4876
+ * `value` is 0 when the caller has no vote.
4877
+ *
4878
+ * Requires an authenticated session.
4879
+ */
4880
+ async getVote(targetType, targetId, options) {
4881
+ return this._get(`/${targetType}/${targetId}/vote`, options);
4882
+ }
4883
+ // --------------------------------------------------------------------------
4884
+ // View counters
4885
+ // --------------------------------------------------------------------------
4886
+ /**
4887
+ * Record a view of a target. Increments the total counter
4888
+ * unconditionally; increments the unique-viewer counter once per
4889
+ * (viewer, UTC day).
4890
+ *
4891
+ * Authenticated callers don't need to pass `viewerFingerprint` — the
4892
+ * user_id is used. Anonymous callers may pass a 64-hex-char
4893
+ * fingerprint hash to participate in unique-viewer dedupe; without
4894
+ * one, only the total counter moves.
4895
+ */
4896
+ async recordView(targetType, targetId, viewerFingerprint, options) {
4897
+ const body = viewerFingerprint ? { viewer_fingerprint: viewerFingerprint } : {};
4898
+ return this.post(`/${targetType}/${targetId}/views`, body, options);
4899
+ }
4900
+ /**
4901
+ * Read view counters for a target.
4902
+ */
4903
+ async getViews(targetType, targetId, options) {
4904
+ return this._get(`/${targetType}/${targetId}/views`, options);
4905
+ }
4906
+ // --------------------------------------------------------------------------
4857
4907
  // Comments
4858
4908
  // --------------------------------------------------------------------------
4859
4909
  async comment(postId, data, options) {
package/dist/index.mjs CHANGED
@@ -4480,6 +4480,56 @@ var SocialService = class extends ServiceModule {
4480
4480
  return this._list(`/${targetType}/${targetId}/likes`, params, requestOptions);
4481
4481
  }
4482
4482
  // --------------------------------------------------------------------------
4483
+ // Voting (bipolar — up/down with score)
4484
+ // --------------------------------------------------------------------------
4485
+ /**
4486
+ * Cast, change, or clear the caller's vote on a target.
4487
+ *
4488
+ * `value`: 1 = upvote, -1 = downvote, 0 = clear.
4489
+ *
4490
+ * Idempotent: re-casting the same value is a no-op; clearing when no
4491
+ * vote exists is a no-op. Server validates `target_type` matches
4492
+ * `[a-z0-9_]{1,64}`. Convention: prefix per app (`weekmob_post`,
4493
+ * `gistyo_gist`).
4494
+ *
4495
+ * Requires an authenticated session; anonymous calls return 401.
4496
+ */
4497
+ async vote(targetType, targetId, value, options) {
4498
+ return this.put(`/${targetType}/${targetId}/vote`, { value }, options);
4499
+ }
4500
+ /**
4501
+ * Read the caller's current vote on a target plus the aggregate counts.
4502
+ * `value` is 0 when the caller has no vote.
4503
+ *
4504
+ * Requires an authenticated session.
4505
+ */
4506
+ async getVote(targetType, targetId, options) {
4507
+ return this._get(`/${targetType}/${targetId}/vote`, options);
4508
+ }
4509
+ // --------------------------------------------------------------------------
4510
+ // View counters
4511
+ // --------------------------------------------------------------------------
4512
+ /**
4513
+ * Record a view of a target. Increments the total counter
4514
+ * unconditionally; increments the unique-viewer counter once per
4515
+ * (viewer, UTC day).
4516
+ *
4517
+ * Authenticated callers don't need to pass `viewerFingerprint` — the
4518
+ * user_id is used. Anonymous callers may pass a 64-hex-char
4519
+ * fingerprint hash to participate in unique-viewer dedupe; without
4520
+ * one, only the total counter moves.
4521
+ */
4522
+ async recordView(targetType, targetId, viewerFingerprint, options) {
4523
+ const body = viewerFingerprint ? { viewer_fingerprint: viewerFingerprint } : {};
4524
+ return this.post(`/${targetType}/${targetId}/views`, body, options);
4525
+ }
4526
+ /**
4527
+ * Read view counters for a target.
4528
+ */
4529
+ async getViews(targetType, targetId, options) {
4530
+ return this._get(`/${targetType}/${targetId}/views`, options);
4531
+ }
4532
+ // --------------------------------------------------------------------------
4483
4533
  // Comments
4484
4534
  // --------------------------------------------------------------------------
4485
4535
  async comment(postId, data, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/sdk",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "Official TypeScript/JavaScript SDK for ScaleMule Backend-as-a-Service",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",