@trash-streamers/common 1.2.32 → 1.2.36

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.
@@ -24,4 +24,9 @@ export declare const GRPC_CLIENTS: {
24
24
  readonly protoPath: string;
25
25
  readonly env: "VIDEO_GRPC_URL";
26
26
  };
27
+ readonly CATEGORY_PACKAGE: {
28
+ readonly package: "category.v1";
29
+ readonly protoPath: string;
30
+ readonly env: "CATEGORY_GRPC_URL";
31
+ };
27
32
  };
@@ -28,4 +28,9 @@ exports.GRPC_CLIENTS = {
28
28
  protoPath: contracts_1.PROTO_PATHS.VIDEO,
29
29
  env: "VIDEO_GRPC_URL",
30
30
  },
31
+ CATEGORY_PACKAGE: {
32
+ package: "category.v1",
33
+ protoPath: contracts_1.PROTO_PATHS.CATEGORY,
34
+ env: "CATEGORY_GRPC_URL",
35
+ },
31
36
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const field_mask_utils_1 = require("./field-mask.utils");
4
+ describe("Field Mask Utils", () => {
5
+ describe("generateFieldMask", () => {
6
+ it("should generate paths for a flat object", () => {
7
+ const input = { title: "Hello", description: "World" };
8
+ const result = (0, field_mask_utils_1.generateFieldMask)(input);
9
+ expect(result).toEqual(["title", "description"]);
10
+ });
11
+ it("should generate nested paths", () => {
12
+ const input = {
13
+ video: {
14
+ title: "Title",
15
+ meta: { duration: 100 },
16
+ },
17
+ };
18
+ const result = (0, field_mask_utils_1.generateFieldMask)(input);
19
+ expect(result).toEqual(["video.title", "video.meta.duration"]);
20
+ });
21
+ it("should handle dates correctly (not treat as objects to recurse)", () => {
22
+ const input = { updatedAt: new Date() };
23
+ const result = (0, field_mask_utils_1.generateFieldMask)(input);
24
+ expect(result).toEqual(["updatedAt"]);
25
+ });
26
+ it("should escape dots in keys", () => {
27
+ const input = { "version.1": "active" };
28
+ const result = (0, field_mask_utils_1.generateFieldMask)(input);
29
+ expect(result).toEqual(["version\\.1"]);
30
+ });
31
+ });
32
+ describe("applyFieldMask", () => {
33
+ const source = {
34
+ id: "1",
35
+ title: "Original Title",
36
+ description: "Original Desc",
37
+ author: {
38
+ name: "John",
39
+ age: 30,
40
+ },
41
+ tags: ["action", "sci-fi"],
42
+ };
43
+ it("should pick only specified top-level fields", () => {
44
+ const mask = ["title", "description"];
45
+ const result = (0, field_mask_utils_1.applyFieldMask)(source, mask);
46
+ expect(result).toEqual({
47
+ title: "Original Title",
48
+ description: "Original Desc",
49
+ });
50
+ expect(result).not.toHaveProperty("id");
51
+ expect(result).not.toHaveProperty("author");
52
+ });
53
+ it("should pick nested fields and construct the object structure", () => {
54
+ const mask = ["author.name"];
55
+ const result = (0, field_mask_utils_1.applyFieldMask)(source, mask);
56
+ expect(result).toEqual({
57
+ author: {
58
+ name: "John",
59
+ },
60
+ });
61
+ expect(result.author).not.toHaveProperty("age");
62
+ });
63
+ it("should handle complex mixed masks", () => {
64
+ const mask = ["id", "author.age", "tags"];
65
+ const result = (0, field_mask_utils_1.applyFieldMask)(source, mask);
66
+ expect(result).toEqual({
67
+ id: "1",
68
+ author: {
69
+ age: 30,
70
+ },
71
+ tags: ["action", "sci-fi"],
72
+ });
73
+ });
74
+ it("should handle escaped dots when picking fields", () => {
75
+ const escapedSource = { "meta.data": "value", regular: "field" };
76
+ const mask = ["meta\\.data"];
77
+ const result = (0, field_mask_utils_1.applyFieldMask)(escapedSource, mask);
78
+ expect(result).toEqual({ "meta.data": "value" });
79
+ });
80
+ it("should return undefined for non-existent paths in mask", () => {
81
+ const mask = ["nonExistent.path"];
82
+ const result = (0, field_mask_utils_1.applyFieldMask)(source, mask);
83
+ expect(result).toEqual({});
84
+ });
85
+ });
86
+ describe("Integration: generate and apply", () => {
87
+ it("should result in a deep clone of the input when applying generated mask", () => {
88
+ const input = { a: 1, b: { c: 2 }, d: new Date() };
89
+ const mask = (0, field_mask_utils_1.generateFieldMask)(input);
90
+ const result = (0, field_mask_utils_1.applyFieldMask)(input, mask);
91
+ expect(result).toEqual(input);
92
+ expect(result).not.toBe(input);
93
+ });
94
+ });
95
+ });
@@ -1,3 +1,4 @@
1
1
  export * from "./env";
2
- export * from "./to-timestamp";
3
- export * from "./timestamp-to-date";
2
+ export * from "./to-timestamp.utils";
3
+ export * from "./timestamp-to-date.utils";
4
+ export * from "./field-mask.utils";
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./env"), exports);
18
- __exportStar(require("./to-timestamp"), exports);
19
- __exportStar(require("./timestamp-to-date"), exports);
18
+ __exportStar(require("./to-timestamp.utils"), exports);
19
+ __exportStar(require("./timestamp-to-date.utils"), exports);
20
+ __exportStar(require("./field-mask.utils"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trash-streamers/common",
3
- "version": "1.2.32",
3
+ "version": "1.2.36",
4
4
  "description": "Core shared component for Trash-streamers microservice ecosystem",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,14 +12,19 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "tsc -p tsconfig.build.json",
15
- "format": "prettier --write \"src/**/*.ts\""
15
+ "format": "prettier --write \"src/**/*.ts\"",
16
+ "test": "jest",
17
+ "test:watch": "jest --watch"
16
18
  },
17
19
  "devDependencies": {
18
20
  "@trash-streamers/core": "^1.0.2",
21
+ "@types/jest": "^30.0.0",
19
22
  "@types/node": "^25.0.3",
20
23
  "class-transformer": "^0.5.1",
21
24
  "class-validator": "^0.14.3",
25
+ "jest": "^30.2.0",
22
26
  "prettier": "^3.7.4",
27
+ "ts-jest": "^29.4.6",
23
28
  "typescript": "^5.9.3"
24
29
  },
25
30
  "peerDependencies": {
@@ -29,6 +34,6 @@
29
34
  "dependencies": {
30
35
  "@nestjs/common": "^11.1.12",
31
36
  "@nestjs/config": "^4.0.2",
32
- "@trash-streamers/contracts": "^1.1.67"
37
+ "@trash-streamers/contracts": "^1.1.72"
33
38
  }
34
39
  }