apache-iggy 0.6.0 → 0.7.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 (149) hide show
  1. package/dist/client/client.connection.d.ts +49 -0
  2. package/dist/client/client.connection.js +79 -0
  3. package/dist/client/client.d.ts +46 -0
  4. package/dist/client/client.debug.d.ts +4 -0
  5. package/dist/client/client.debug.js +4 -0
  6. package/dist/client/client.js +65 -1
  7. package/dist/client/client.socket.d.ts +91 -0
  8. package/dist/client/client.socket.js +94 -0
  9. package/dist/client/client.type.d.ts +72 -0
  10. package/dist/client/client.type.js +3 -0
  11. package/dist/client/client.utils.d.ts +28 -0
  12. package/dist/client/client.utils.js +29 -0
  13. package/dist/e2e/tcp.cluster.e2e.js +1 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +3 -3
  16. package/dist/tcp.sm.utils.d.ts +31 -42
  17. package/dist/tcp.sm.utils.js +38 -22
  18. package/dist/type.utils.d.ts +14 -0
  19. package/dist/type.utils.js +9 -0
  20. package/dist/wire/command-set.d.ts +2 -9
  21. package/dist/wire/command.utils.d.ts +18 -0
  22. package/dist/wire/command.utils.js +9 -0
  23. package/dist/wire/consumer-group/create-group.command.d.ts +13 -0
  24. package/dist/wire/consumer-group/create-group.command.js +7 -0
  25. package/dist/wire/consumer-group/delete-group.command.d.ts +13 -0
  26. package/dist/wire/consumer-group/delete-group.command.js +7 -0
  27. package/dist/wire/consumer-group/ensure-group.virtual.command.d.ts +15 -1
  28. package/dist/wire/consumer-group/ensure-group.virtual.command.js +14 -0
  29. package/dist/wire/consumer-group/get-group.command.d.ts +13 -0
  30. package/dist/wire/consumer-group/get-group.command.js +7 -0
  31. package/dist/wire/consumer-group/get-groups.command.d.ts +12 -0
  32. package/dist/wire/consumer-group/get-groups.command.js +7 -0
  33. package/dist/wire/consumer-group/group.utils.d.ts +34 -0
  34. package/dist/wire/consumer-group/group.utils.js +22 -0
  35. package/dist/wire/consumer-group/join-group.command.d.ts +13 -0
  36. package/dist/wire/consumer-group/join-group.command.js +7 -0
  37. package/dist/wire/consumer-group/leave-group.command.d.ts +13 -0
  38. package/dist/wire/consumer-group/leave-group.command.js +7 -0
  39. package/dist/wire/identifier.utils.d.ts +11 -0
  40. package/dist/wire/identifier.utils.js +23 -1
  41. package/dist/wire/message/flush-unsaved-buffers.command.d.ts +13 -0
  42. package/dist/wire/message/flush-unsaved-buffers.command.js +7 -0
  43. package/dist/wire/message/header.type.d.ts +57 -15
  44. package/dist/wire/message/header.type.js +31 -18
  45. package/dist/wire/message/header.utils.d.ts +104 -10
  46. package/dist/wire/message/header.utils.js +233 -86
  47. package/dist/wire/message/header.utils.test.js +39 -16
  48. package/dist/wire/message/iggy-header.utils.d.ts +39 -1
  49. package/dist/wire/message/iggy-header.utils.js +30 -3
  50. package/dist/wire/message/index.d.ts +5 -5
  51. package/dist/wire/message/index.js +5 -5
  52. package/dist/wire/message/message.utils.d.ts +60 -0
  53. package/dist/wire/message/message.utils.js +54 -1
  54. package/dist/wire/message/partitioning.utils.d.ts +39 -0
  55. package/dist/wire/message/partitioning.utils.js +43 -1
  56. package/dist/wire/message/poll-messages.command.d.ts +17 -0
  57. package/dist/wire/message/poll-messages.command.js +7 -0
  58. package/dist/wire/message/poll.utils.d.ts +93 -12
  59. package/dist/wire/message/poll.utils.js +92 -21
  60. package/dist/wire/message/send-messages.command.d.ts +14 -0
  61. package/dist/wire/message/send-messages.command.js +7 -0
  62. package/dist/wire/message/send-messages.command.test.js +103 -39
  63. package/dist/wire/number.utils.d.ts +79 -0
  64. package/dist/wire/number.utils.js +79 -2
  65. package/dist/wire/offset/delete-offset.command.d.ts +13 -3
  66. package/dist/wire/offset/delete-offset.command.js +7 -0
  67. package/dist/wire/offset/get-offset.command.d.ts +14 -0
  68. package/dist/wire/offset/get-offset.command.js +7 -0
  69. package/dist/wire/offset/offset.utils.d.ts +48 -0
  70. package/dist/wire/offset/offset.utils.js +33 -0
  71. package/dist/wire/offset/store-offset.command.d.ts +15 -0
  72. package/dist/wire/offset/store-offset.command.js +7 -0
  73. package/dist/wire/partition/create-partition.command.d.ts +13 -0
  74. package/dist/wire/partition/create-partition.command.js +7 -0
  75. package/dist/wire/partition/delete-partition.command.d.ts +13 -0
  76. package/dist/wire/partition/delete-partition.command.js +7 -0
  77. package/dist/wire/partition/partition.utils.d.ts +9 -0
  78. package/dist/wire/partition/partition.utils.js +9 -0
  79. package/dist/wire/serialize.utils.d.ts +20 -0
  80. package/dist/wire/serialize.utils.js +20 -0
  81. package/dist/wire/session/login-with-token.command.d.ts +11 -0
  82. package/dist/wire/session/login-with-token.command.js +7 -0
  83. package/dist/wire/session/login.command.d.ts +7 -0
  84. package/dist/wire/session/login.command.js +7 -0
  85. package/dist/wire/session/login.utils.d.ts +25 -0
  86. package/dist/wire/session/login.utils.js +14 -0
  87. package/dist/wire/session/logout.command.d.ts +7 -0
  88. package/dist/wire/session/logout.command.js +7 -0
  89. package/dist/wire/stream/create-stream.command.d.ts +12 -0
  90. package/dist/wire/stream/create-stream.command.js +7 -0
  91. package/dist/wire/stream/delete-stream.command.d.ts +11 -0
  92. package/dist/wire/stream/delete-stream.command.js +7 -0
  93. package/dist/wire/stream/ensure-stream.virtual.command.d.ts +8 -1
  94. package/dist/wire/stream/ensure-stream.virtual.command.js +7 -0
  95. package/dist/wire/stream/get-stream.command.d.ts +11 -0
  96. package/dist/wire/stream/get-stream.command.js +7 -0
  97. package/dist/wire/stream/get-streams.command.d.ts +7 -0
  98. package/dist/wire/stream/get-streams.command.js +7 -0
  99. package/dist/wire/stream/purge-stream.command.d.ts +11 -0
  100. package/dist/wire/stream/purge-stream.command.js +7 -0
  101. package/dist/wire/stream/stream.utils.d.ts +22 -0
  102. package/dist/wire/stream/stream.utils.js +8 -0
  103. package/dist/wire/stream/update-stream.command.d.ts +12 -0
  104. package/dist/wire/stream/update-stream.command.js +7 -0
  105. package/dist/wire/token/create-token.command.d.ts +12 -0
  106. package/dist/wire/token/create-token.command.js +7 -0
  107. package/dist/wire/token/delete-token.command.d.ts +11 -0
  108. package/dist/wire/token/delete-token.command.js +7 -0
  109. package/dist/wire/token/get-tokens.command.d.ts +7 -0
  110. package/dist/wire/token/get-tokens.command.js +7 -0
  111. package/dist/wire/token/token.utils.d.ts +40 -0
  112. package/dist/wire/token/token.utils.js +21 -0
  113. package/dist/wire/topic/create-topic.command.d.ts +17 -0
  114. package/dist/wire/topic/create-topic.command.js +7 -0
  115. package/dist/wire/topic/delete-topic.command.d.ts +14 -2
  116. package/dist/wire/topic/delete-topic.command.js +7 -0
  117. package/dist/wire/topic/ensure-topic.virtual.command.d.ts +9 -2
  118. package/dist/wire/topic/ensure-topic.virtual.command.js +7 -0
  119. package/dist/wire/topic/get-topic.command.d.ts +13 -2
  120. package/dist/wire/topic/get-topic.command.js +7 -0
  121. package/dist/wire/topic/get-topics.command.d.ts +11 -0
  122. package/dist/wire/topic/get-topics.command.js +7 -0
  123. package/dist/wire/topic/purge-topic.command.d.ts +12 -0
  124. package/dist/wire/topic/purge-topic.command.js +7 -0
  125. package/dist/wire/topic/topic.utils.d.ts +73 -0
  126. package/dist/wire/topic/topic.utils.js +40 -0
  127. package/dist/wire/topic/update-topic.command.d.ts +17 -0
  128. package/dist/wire/topic/update-topic.command.js +7 -0
  129. package/dist/wire/user/change-password.command.d.ts +13 -0
  130. package/dist/wire/user/change-password.command.js +7 -0
  131. package/dist/wire/user/create-user.command.d.ts +14 -0
  132. package/dist/wire/user/create-user.command.js +7 -0
  133. package/dist/wire/user/delete-user.command.d.ts +11 -0
  134. package/dist/wire/user/delete-user.command.js +7 -0
  135. package/dist/wire/user/get-user.command.d.ts +11 -0
  136. package/dist/wire/user/get-user.command.js +7 -0
  137. package/dist/wire/user/get-users.command.d.ts +7 -0
  138. package/dist/wire/user/get-users.command.js +7 -0
  139. package/dist/wire/user/permissions.utils.d.ts +108 -0
  140. package/dist/wire/user/permissions.utils.js +68 -0
  141. package/dist/wire/user/update-permissions.command.d.ts +12 -0
  142. package/dist/wire/user/update-permissions.command.js +7 -0
  143. package/dist/wire/user/update-user.command.d.ts +13 -0
  144. package/dist/wire/user/update-user.command.js +7 -0
  145. package/dist/wire/user/user.utils.d.ts +40 -0
  146. package/dist/wire/user/user.utils.js +33 -0
  147. package/dist/wire/uuid.utils.d.ts +13 -0
  148. package/dist/wire/uuid.utils.js +13 -1
  149. package/package.json +2 -2
@@ -19,13 +19,24 @@
19
19
  import type { CommandResponse } from '../../client/client.type.js';
20
20
  import { type Id } from '../identifier.utils.js';
21
21
  import { type User } from './user.utils.js';
22
+ /**
23
+ * Parameters for the get user command.
24
+ */
22
25
  export type GetUser = {
26
+ /** User identifier (ID or username) */
23
27
  userId: Id;
24
28
  };
29
+ /**
30
+ * Get user command definition.
31
+ * Retrieves a single user with permissions.
32
+ */
25
33
  export declare const GET_USER: {
26
34
  code: number;
27
35
  serialize: ({ userId }: GetUser) => Buffer<ArrayBufferLike>;
28
36
  deserialize: (r: CommandResponse) => User | null;
29
37
  };
38
+ /**
39
+ * Executable get user command function.
40
+ */
30
41
  export declare const getUser: (getClient: import("../../client/client.type.js").ClientProvider) => (arg: GetUser) => Promise<User | null>;
31
42
  //# sourceMappingURL=get-user.command.d.ts.map
@@ -20,6 +20,10 @@ import { wrapCommand } from '../command.utils.js';
20
20
  import { COMMAND_CODE } from '../command.code.js';
21
21
  import { serializeIdentifier } from '../identifier.utils.js';
22
22
  import { deserializeUser } from './user.utils.js';
23
+ /**
24
+ * Get user command definition.
25
+ * Retrieves a single user with permissions.
26
+ */
23
27
  export const GET_USER = {
24
28
  code: COMMAND_CODE.GetUser,
25
29
  serialize: ({ userId }) => {
@@ -31,5 +35,8 @@ export const GET_USER = {
31
35
  return deserializeUser(r.data);
32
36
  }
33
37
  };
38
+ /**
39
+ * Executable get user command function.
40
+ */
34
41
  export const getUser = wrapCommand(GET_USER);
35
42
  //# sourceMappingURL=get-user.command.js.map
@@ -18,10 +18,17 @@
18
18
  */
19
19
  import type { CommandResponse } from '../../client/client.type.js';
20
20
  import { type BaseUser } from './user.utils.js';
21
+ /**
22
+ * Get users command definition.
23
+ * Retrieves all users (without permissions).
24
+ */
21
25
  export declare const GET_USERS: {
22
26
  code: number;
23
27
  serialize: () => Buffer<ArrayBuffer>;
24
28
  deserialize: (r: CommandResponse) => BaseUser[];
25
29
  };
30
+ /**
31
+ * Executable get users command function.
32
+ */
26
33
  export declare const getUsers: (getClient: import("../../client/client.type.js").ClientProvider) => (arg: void) => Promise<BaseUser[]>;
27
34
  //# sourceMappingURL=get-users.command.d.ts.map
@@ -19,10 +19,17 @@
19
19
  import { wrapCommand } from '../command.utils.js';
20
20
  import { COMMAND_CODE } from '../command.code.js';
21
21
  import { deserializeUsers } from './user.utils.js';
22
+ /**
23
+ * Get users command definition.
24
+ * Retrieves all users (without permissions).
25
+ */
22
26
  export const GET_USERS = {
23
27
  code: COMMAND_CODE.GetUsers,
24
28
  serialize: () => Buffer.alloc(0),
25
29
  deserialize: (r) => deserializeUsers(r.data)
26
30
  };
31
+ /**
32
+ * Executable get users command function.
33
+ */
27
34
  export const getUsers = wrapCommand(GET_USERS);
28
35
  //# sourceMappingURL=get-users.command.js.map
@@ -16,62 +16,170 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ /**
20
+ * Global permissions for server-wide operations.
21
+ */
19
22
  export type GlobalPermissions = {
23
+ /** Can manage server configuration */
20
24
  ManageServers: boolean;
25
+ /** Can read server information */
21
26
  ReadServers: boolean;
27
+ /** Can manage users */
22
28
  ManageUsers: boolean;
29
+ /** Can read user information */
23
30
  ReadUsers: boolean;
31
+ /** Can manage streams */
24
32
  ManageStreams: boolean;
33
+ /** Can read stream information */
25
34
  ReadStreams: boolean;
35
+ /** Can manage topics */
26
36
  ManageTopics: boolean;
37
+ /** Can read topic information */
27
38
  ReadTopics: boolean;
39
+ /** Can poll messages */
28
40
  PollMessages: boolean;
41
+ /** Can send messages */
29
42
  SendMessages: boolean;
30
43
  };
44
+ /**
45
+ * Result of deserializing global permissions.
46
+ */
31
47
  type GlobalPermissionsDeserialized = {
48
+ /** Number of bytes consumed */
32
49
  bytesRead: number;
50
+ /** Deserialized permissions */
33
51
  data: GlobalPermissions;
34
52
  };
53
+ /**
54
+ * Permissions for a specific topic.
55
+ */
35
56
  export type TopicPermissions = {
57
+ /** Can manage the topic */
36
58
  manage: boolean;
59
+ /** Can read the topic */
37
60
  read: boolean;
61
+ /** Can poll messages from the topic */
38
62
  pollMessages: boolean;
63
+ /** Can send messages to the topic */
39
64
  sendMessages: boolean;
40
65
  };
66
+ /**
67
+ * Topic permissions with topic identifier.
68
+ */
41
69
  export type TopicPerms = {
70
+ /** Topic ID */
42
71
  topicId: number;
72
+ /** Topic permissions */
43
73
  permissions: TopicPermissions;
44
74
  };
75
+ /** Result of deserializing topic permissions */
45
76
  type TopicPermissionsDeserialized = {
46
77
  bytesRead: number;
47
78
  } & TopicPerms;
79
+ /**
80
+ * Permissions for a specific stream.
81
+ */
48
82
  export type StreamPermissions = {
83
+ /** Can manage the stream */
49
84
  manageStream: boolean;
85
+ /** Can read the stream */
50
86
  readStream: boolean;
87
+ /** Can manage topics within the stream */
51
88
  manageTopics: boolean;
89
+ /** Can read topics within the stream */
52
90
  readTopics: boolean;
91
+ /** Can poll messages from the stream */
53
92
  pollMessages: boolean;
93
+ /** Can send messages to the stream */
54
94
  sendMessages: boolean;
55
95
  };
96
+ /**
97
+ * Stream permissions with stream identifier and topic permissions.
98
+ */
56
99
  export type StreamPerms = {
100
+ /** Stream ID */
57
101
  streamId: number;
102
+ /** Stream-level permissions */
58
103
  permissions: StreamPermissions;
104
+ /** Topic-specific permissions within the stream */
59
105
  topics: TopicPerms[];
60
106
  };
107
+ /** Result of deserializing stream permissions */
61
108
  type StreamPermissionsDeserialized = {
62
109
  bytesRead: number;
63
110
  } & StreamPerms;
111
+ /**
112
+ * Complete user permissions including global and stream-level permissions.
113
+ */
64
114
  export type UserPermissions = {
115
+ /** Global permissions */
65
116
  global: GlobalPermissions;
117
+ /** Stream-specific permissions */
66
118
  streams: StreamPerms[];
67
119
  };
120
+ /**
121
+ * Deserializes global permissions from a buffer.
122
+ *
123
+ * @param p - Buffer containing serialized permissions
124
+ * @param pos - Starting position in the buffer
125
+ * @returns Object with bytes read and deserialized permissions
126
+ */
68
127
  export declare const deserializeGlobalPermissions: (p: Buffer, pos?: number) => GlobalPermissionsDeserialized;
128
+ /**
129
+ * Serializes global permissions to a buffer.
130
+ *
131
+ * @param p - Global permissions to serialize
132
+ * @returns Serialized permissions buffer (10 bytes)
133
+ */
69
134
  export declare const serializeGlobalPermission: (p: GlobalPermissions) => Buffer<ArrayBuffer>;
135
+ /**
136
+ * Deserializes topic permissions from a buffer.
137
+ *
138
+ * @param p - Buffer containing serialized permissions
139
+ * @param pos - Starting position in the buffer
140
+ * @returns Object with bytes read, topic ID, and permissions
141
+ */
70
142
  export declare const deserializeTopicPermissions: (p: Buffer, pos?: number) => TopicPermissionsDeserialized;
143
+ /**
144
+ * Serializes topic permissions to a buffer.
145
+ *
146
+ * @param p - Topic permissions to serialize
147
+ * @returns Serialized permissions buffer (8 bytes)
148
+ */
71
149
  export declare const serializeTopicPermissions: (p: TopicPerms) => Buffer<ArrayBuffer>;
150
+ /**
151
+ * Deserializes stream permissions from a buffer.
152
+ * Includes nested topic permissions if present.
153
+ *
154
+ * @param p - Buffer containing serialized permissions
155
+ * @param pos - Starting position in the buffer
156
+ * @returns Object with bytes read, stream ID, permissions, and topics
157
+ */
72
158
  export declare const deserializeStreamPermissions: (p: Buffer, pos?: number) => StreamPermissionsDeserialized;
159
+ /**
160
+ * Serializes stream permissions to a buffer.
161
+ * Includes nested topic permissions if present.
162
+ *
163
+ * @param p - Stream permissions to serialize
164
+ * @returns Serialized permissions buffer
165
+ */
73
166
  export declare const serializeStreamPermissions: (p: StreamPerms) => Buffer<ArrayBuffer>;
167
+ /**
168
+ * Deserializes complete user permissions from a buffer.
169
+ * Includes global permissions and stream-level permissions.
170
+ *
171
+ * @param p - Buffer containing serialized permissions
172
+ * @param pos - Starting position in the buffer
173
+ * @returns Deserialized user permissions
174
+ */
74
175
  export declare const deserializePermissions: (p: Buffer, pos?: number) => UserPermissions;
176
+ /**
177
+ * Serializes user permissions to a buffer.
178
+ * Returns a single zero byte if no permissions provided.
179
+ *
180
+ * @param p - Optional user permissions to serialize
181
+ * @returns Serialized permissions buffer
182
+ */
75
183
  export declare const serializePermissions: (p?: UserPermissions) => Buffer<ArrayBuffer>;
76
184
  export {};
77
185
  //# sourceMappingURL=permissions.utils.d.ts.map
@@ -17,8 +17,27 @@
17
17
  * under the License.
18
18
  */
19
19
  import { uint8ToBuf, uint32ToBuf } from '../number.utils.js';
20
+ /**
21
+ * Converts a number to a boolean (1 = true).
22
+ *
23
+ * @param u - Number to convert
24
+ * @returns True if u equals 1
25
+ */
20
26
  const toBool = (u) => u === 1;
27
+ /**
28
+ * Converts a boolean to a byte value.
29
+ *
30
+ * @param b - Boolean value
31
+ * @returns 1 if true, 0 if false
32
+ */
21
33
  const boolToByte = (b) => b ? 1 : 0;
34
+ /**
35
+ * Deserializes global permissions from a buffer.
36
+ *
37
+ * @param p - Buffer containing serialized permissions
38
+ * @param pos - Starting position in the buffer
39
+ * @returns Object with bytes read and deserialized permissions
40
+ */
22
41
  export const deserializeGlobalPermissions = (p, pos = 0) => {
23
42
  return {
24
43
  bytesRead: 10,
@@ -36,6 +55,12 @@ export const deserializeGlobalPermissions = (p, pos = 0) => {
36
55
  }
37
56
  };
38
57
  };
58
+ /**
59
+ * Serializes global permissions to a buffer.
60
+ *
61
+ * @param p - Global permissions to serialize
62
+ * @returns Serialized permissions buffer (10 bytes)
63
+ */
39
64
  export const serializeGlobalPermission = (p) => {
40
65
  return Buffer.concat([
41
66
  uint8ToBuf(boolToByte(p.ManageServers)),
@@ -50,6 +75,13 @@ export const serializeGlobalPermission = (p) => {
50
75
  uint8ToBuf(boolToByte(p.SendMessages)),
51
76
  ]);
52
77
  };
78
+ /**
79
+ * Deserializes topic permissions from a buffer.
80
+ *
81
+ * @param p - Buffer containing serialized permissions
82
+ * @param pos - Starting position in the buffer
83
+ * @returns Object with bytes read, topic ID, and permissions
84
+ */
53
85
  export const deserializeTopicPermissions = (p, pos = 0) => {
54
86
  const topicId = p.readUInt32LE(pos);
55
87
  const permissions = {
@@ -64,6 +96,12 @@ export const deserializeTopicPermissions = (p, pos = 0) => {
64
96
  permissions
65
97
  };
66
98
  };
99
+ /**
100
+ * Serializes topic permissions to a buffer.
101
+ *
102
+ * @param p - Topic permissions to serialize
103
+ * @returns Serialized permissions buffer (8 bytes)
104
+ */
67
105
  export const serializeTopicPermissions = (p) => {
68
106
  return Buffer.concat([
69
107
  uint32ToBuf(p.topicId),
@@ -73,6 +111,14 @@ export const serializeTopicPermissions = (p) => {
73
111
  uint8ToBuf(boolToByte(p.permissions.sendMessages)),
74
112
  ]);
75
113
  };
114
+ /**
115
+ * Deserializes stream permissions from a buffer.
116
+ * Includes nested topic permissions if present.
117
+ *
118
+ * @param p - Buffer containing serialized permissions
119
+ * @param pos - Starting position in the buffer
120
+ * @returns Object with bytes read, stream ID, permissions, and topics
121
+ */
76
122
  export const deserializeStreamPermissions = (p, pos = 0) => {
77
123
  const start = pos;
78
124
  const streamId = p.readUInt32LE(pos);
@@ -105,6 +151,13 @@ export const deserializeStreamPermissions = (p, pos = 0) => {
105
151
  topics
106
152
  };
107
153
  };
154
+ /**
155
+ * Serializes stream permissions to a buffer.
156
+ * Includes nested topic permissions if present.
157
+ *
158
+ * @param p - Stream permissions to serialize
159
+ * @returns Serialized permissions buffer
160
+ */
108
161
  export const serializeStreamPermissions = (p) => {
109
162
  const bStream = Buffer.concat([
110
163
  uint32ToBuf(p.streamId),
@@ -124,6 +177,14 @@ export const serializeStreamPermissions = (p) => {
124
177
  ac, serializeTopicPermissions(c)
125
178
  ]), bHead);
126
179
  };
180
+ /**
181
+ * Deserializes complete user permissions from a buffer.
182
+ * Includes global permissions and stream-level permissions.
183
+ *
184
+ * @param p - Buffer containing serialized permissions
185
+ * @param pos - Starting position in the buffer
186
+ * @returns Deserialized user permissions
187
+ */
127
188
  export const deserializePermissions = (p, pos = 0) => {
128
189
  const { bytesRead, data } = deserializeGlobalPermissions(p, pos);
129
190
  pos += bytesRead;
@@ -145,6 +206,13 @@ export const deserializePermissions = (p, pos = 0) => {
145
206
  streams
146
207
  };
147
208
  };
209
+ /**
210
+ * Serializes user permissions to a buffer.
211
+ * Returns a single zero byte if no permissions provided.
212
+ *
213
+ * @param p - Optional user permissions to serialize
214
+ * @returns Serialized permissions buffer
215
+ */
148
216
  export const serializePermissions = (p) => {
149
217
  if (!p)
150
218
  return uint8ToBuf(0);
@@ -18,14 +18,26 @@
18
18
  */
19
19
  import { type Id } from '../identifier.utils.js';
20
20
  import { type UserPermissions } from './permissions.utils.js';
21
+ /**
22
+ * Parameters for the update permissions command.
23
+ */
21
24
  export type UpdatePermissions = {
25
+ /** User identifier (ID or username) */
22
26
  userId: Id;
27
+ /** New permissions to set */
23
28
  permissions: UserPermissions;
24
29
  };
30
+ /**
31
+ * Update permissions command definition.
32
+ * Updates a user's permissions.
33
+ */
25
34
  export declare const UPDATE_PERMISSIONS: {
26
35
  code: number;
27
36
  serialize: ({ userId, permissions }: UpdatePermissions) => Buffer<ArrayBuffer>;
28
37
  deserialize: (r: import("../../index.js").CommandResponse) => boolean;
29
38
  };
39
+ /**
40
+ * Executable update permissions command function.
41
+ */
30
42
  export declare const updatePermissions: (getClient: import("../../index.js").ClientProvider) => (arg: UpdatePermissions) => Promise<boolean>;
31
43
  //# sourceMappingURL=update-permissions.command.d.ts.map
@@ -22,6 +22,10 @@ import { deserializeVoidResponse } from '../../client/client.utils.js';
22
22
  import { uint32ToBuf, boolToBuf } from '../number.utils.js';
23
23
  import { serializeIdentifier } from '../identifier.utils.js';
24
24
  import { serializePermissions } from './permissions.utils.js';
25
+ /**
26
+ * Update permissions command definition.
27
+ * Updates a user's permissions.
28
+ */
25
29
  export const UPDATE_PERMISSIONS = {
26
30
  code: COMMAND_CODE.UpdatePermissions,
27
31
  serialize: ({ userId, permissions }) => {
@@ -35,5 +39,8 @@ export const UPDATE_PERMISSIONS = {
35
39
  },
36
40
  deserialize: deserializeVoidResponse
37
41
  };
42
+ /**
43
+ * Executable update permissions command function.
44
+ */
38
45
  export const updatePermissions = wrapCommand(UPDATE_PERMISSIONS);
39
46
  //# sourceMappingURL=update-permissions.command.js.map
@@ -18,15 +18,28 @@
18
18
  */
19
19
  import type { UserStatus } from './user.utils.js';
20
20
  import { type Id } from '../identifier.utils.js';
21
+ /**
22
+ * Parameters for the update user command.
23
+ */
21
24
  export type UpdateUser = {
25
+ /** User identifier (ID or username) */
22
26
  userId: Id;
27
+ /** Optional new username (1-255 bytes) */
23
28
  username?: string;
29
+ /** Optional new status */
24
30
  status?: UserStatus;
25
31
  };
32
+ /**
33
+ * Update user command definition.
34
+ * Updates a user's username and/or status.
35
+ */
26
36
  export declare const UPDATE_USER: {
27
37
  code: number;
28
38
  serialize: ({ userId, username, status }: UpdateUser) => Buffer<ArrayBuffer>;
29
39
  deserialize: (r: import("../../index.js").CommandResponse) => boolean;
30
40
  };
41
+ /**
42
+ * Executable update user command function.
43
+ */
31
44
  export declare const updateUser: (getClient: import("../../index.js").ClientProvider) => (arg: UpdateUser) => Promise<boolean>;
32
45
  //# sourceMappingURL=update-user.command.d.ts.map
@@ -21,6 +21,10 @@ import { COMMAND_CODE } from '../command.code.js';
21
21
  import { deserializeVoidResponse } from '../../client/client.utils.js';
22
22
  import { serializeIdentifier } from '../identifier.utils.js';
23
23
  import { uint8ToBuf } from '../number.utils.js';
24
+ /**
25
+ * Update user command definition.
26
+ * Updates a user's username and/or status.
27
+ */
24
28
  export const UPDATE_USER = {
25
29
  code: COMMAND_CODE.UpdateUser,
26
30
  serialize: ({ userId, username, status }) => {
@@ -50,5 +54,8 @@ export const UPDATE_USER = {
50
54
  },
51
55
  deserialize: deserializeVoidResponse
52
56
  };
57
+ /**
58
+ * Executable update user command function.
59
+ */
53
60
  export const updateUser = wrapCommand(UPDATE_USER);
54
61
  //# sourceMappingURL=update-user.command.js.map
@@ -17,25 +17,65 @@
17
17
  * under the License.
18
18
  */
19
19
  import { type UserPermissions } from './permissions.utils.js';
20
+ /**
21
+ * Basic user information without permissions.
22
+ */
20
23
  export type BaseUser = {
24
+ /** User ID */
21
25
  id: number;
26
+ /** User creation timestamp */
22
27
  createdAt: Date;
28
+ /** User status (Active/Inactive) */
23
29
  status: string;
30
+ /** Username */
24
31
  userName: string;
25
32
  };
33
+ /**
34
+ * Result of deserializing a base user.
35
+ */
26
36
  type BaseUserDeserialized = {
37
+ /** Number of bytes consumed */
27
38
  bytesRead: number;
39
+ /** Deserialized user data */
28
40
  data: BaseUser;
29
41
  };
42
+ /** User with permissions information */
30
43
  export type User = BaseUser & {
31
44
  permissions: UserPermissions | null;
32
45
  };
46
+ /**
47
+ * User status enumeration.
48
+ */
33
49
  export declare enum UserStatus {
50
+ /** Active user */
34
51
  Active = 1,
52
+ /** Inactive user */
35
53
  Inactive = 2
36
54
  }
55
+ /**
56
+ * Deserializes a base user from a buffer.
57
+ *
58
+ * @param p - Buffer containing serialized user data
59
+ * @param pos - Starting position in the buffer
60
+ * @returns Object with bytes read and deserialized user data
61
+ * @throws Error if the buffer is empty (user does not exist)
62
+ */
37
63
  export declare const deserializeBaseUser: (p: Buffer, pos?: number) => BaseUserDeserialized;
64
+ /**
65
+ * Deserializes a user with permissions from a buffer.
66
+ *
67
+ * @param p - Buffer containing serialized user data
68
+ * @param pos - Starting position in the buffer
69
+ * @returns Deserialized user with permissions
70
+ */
38
71
  export declare const deserializeUser: (p: Buffer, pos?: number) => User;
72
+ /**
73
+ * Deserializes multiple base users from a buffer.
74
+ *
75
+ * @param p - Buffer containing serialized users data
76
+ * @param pos - Starting position in the buffer
77
+ * @returns Array of deserialized base users
78
+ */
39
79
  export declare const deserializeUsers: (p: Buffer, pos?: number) => BaseUser[];
40
80
  export {};
41
81
  //# sourceMappingURL=user.utils.d.ts.map
@@ -18,12 +18,23 @@
18
18
  */
19
19
  import { toDate } from '../serialize.utils.js';
20
20
  import { deserializePermissions } from './permissions.utils.js';
21
+ /**
22
+ * User status enumeration.
23
+ */
21
24
  export var UserStatus;
22
25
  (function (UserStatus) {
26
+ /** Active user */
23
27
  UserStatus[UserStatus["Active"] = 1] = "Active";
28
+ /** Inactive user */
24
29
  UserStatus[UserStatus["Inactive"] = 2] = "Inactive";
25
30
  })(UserStatus || (UserStatus = {}));
26
31
  ;
32
+ /**
33
+ * Converts a numeric status code to a status string.
34
+ *
35
+ * @param t - Numeric status code
36
+ * @returns Status string ('Active', 'Inactive', or unknown)
37
+ */
27
38
  const statusString = (t) => {
28
39
  switch (t.toString()) {
29
40
  case '1': return 'Active';
@@ -32,6 +43,14 @@ const statusString = (t) => {
32
43
  // default: throw new Error(`unknown_status_${t}`);
33
44
  }
34
45
  };
46
+ /**
47
+ * Deserializes a base user from a buffer.
48
+ *
49
+ * @param p - Buffer containing serialized user data
50
+ * @param pos - Starting position in the buffer
51
+ * @returns Object with bytes read and deserialized user data
52
+ * @throws Error if the buffer is empty (user does not exist)
53
+ */
35
54
  export const deserializeBaseUser = (p, pos = 0) => {
36
55
  if (p.length === 0)
37
56
  throw new Error('User does not exist');
@@ -50,6 +69,13 @@ export const deserializeBaseUser = (p, pos = 0) => {
50
69
  }
51
70
  };
52
71
  };
72
+ /**
73
+ * Deserializes a user with permissions from a buffer.
74
+ *
75
+ * @param p - Buffer containing serialized user data
76
+ * @param pos - Starting position in the buffer
77
+ * @returns Deserialized user with permissions
78
+ */
53
79
  export const deserializeUser = (p, pos = 0) => {
54
80
  const { bytesRead, data } = deserializeBaseUser(p, pos);
55
81
  pos += bytesRead;
@@ -63,6 +89,13 @@ export const deserializeUser = (p, pos = 0) => {
63
89
  }
64
90
  return { ...data, permissions };
65
91
  };
92
+ /**
93
+ * Deserializes multiple base users from a buffer.
94
+ *
95
+ * @param p - Buffer containing serialized users data
96
+ * @param pos - Starting position in the buffer
97
+ * @returns Array of deserialized base users
98
+ */
66
99
  export const deserializeUsers = (p, pos = 0) => {
67
100
  const users = [];
68
101
  const end = p.length;
@@ -17,6 +17,19 @@
17
17
  * under the License.
18
18
  */
19
19
  import { UUID } from "uuidv7";
20
+ /**
21
+ * Parses a UUID string into a UUID object.
22
+ *
23
+ * @param uid - UUID string to parse
24
+ * @returns Parsed UUID object
25
+ */
20
26
  export declare const parse: (uid: string) => UUID;
27
+ /**
28
+ * Generates a new UUID v7 (time-ordered) string.
29
+ * UUID v7 is a time-ordered UUID that provides better database indexing performance.
30
+ *
31
+ * @returns UUID v7 string
32
+ * @see https://github.com/LiosK/uuidv7
33
+ */
21
34
  export declare const v7: () => string;
22
35
  //# sourceMappingURL=uuid.utils.d.ts.map
@@ -17,7 +17,19 @@
17
17
  * under the License.
18
18
  */
19
19
  import { uuidv7, UUID } from "uuidv7";
20
+ /**
21
+ * Parses a UUID string into a UUID object.
22
+ *
23
+ * @param uid - UUID string to parse
24
+ * @returns Parsed UUID object
25
+ */
20
26
  export const parse = (uid) => UUID.parse(uid);
21
- // https://github.com/LiosK/uuidv7
27
+ /**
28
+ * Generates a new UUID v7 (time-ordered) string.
29
+ * UUID v7 is a time-ordered UUID that provides better database indexing performance.
30
+ *
31
+ * @returns UUID v7 string
32
+ * @see https://github.com/LiosK/uuidv7
33
+ */
22
34
  export const v7 = () => uuidv7();
23
35
  //# sourceMappingURL=uuid.utils.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "apache-iggy",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.7.0",
5
5
  "description": "Official Apache Iggy NodeJS SDK",
6
6
  "keywords": [
7
7
  "iggy",
@@ -42,7 +42,7 @@
42
42
  "commitlint": "commitlint --edit",
43
43
  "build": "tsc -p tsconfig.json",
44
44
  "start": "node dist/index.js",
45
- "prepare": "husky"
45
+ "prepare": "husky || true"
46
46
  },
47
47
  "author": "github.com/T1B0",
48
48
  "license": "Apache-2.0",