@qlever-llc/trellis 0.10.8 → 0.10.10

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 (210) hide show
  1. package/esm/contract_support/mod.d.ts +1 -1
  2. package/esm/contract_support/mod.d.ts.map +1 -1
  3. package/esm/contract_support/mod.js +1 -1
  4. package/esm/contract_support/protocol.d.ts +67 -0
  5. package/esm/contract_support/protocol.d.ts.map +1 -1
  6. package/esm/contract_support/protocol.js +90 -0
  7. package/esm/generated-sdk/auth/api.d.ts.map +1 -1
  8. package/esm/generated-sdk/auth/client.d.ts.map +1 -1
  9. package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
  10. package/esm/generated-sdk/auth/contract.js +9590 -7
  11. package/esm/generated-sdk/auth/mod.d.ts +3 -3
  12. package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
  13. package/esm/generated-sdk/auth/mod.js +1 -1
  14. package/esm/generated-sdk/auth/owned_api.d.ts.map +1 -1
  15. package/esm/generated-sdk/auth/owned_api.js +305 -62
  16. package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
  17. package/esm/generated-sdk/auth/schemas.js +6492 -139
  18. package/esm/generated-sdk/auth/types.d.ts +254 -254
  19. package/esm/generated-sdk/auth/types.d.ts.map +1 -1
  20. package/esm/generated-sdk/health/api.d.ts.map +1 -1
  21. package/esm/generated-sdk/health/client.d.ts.map +1 -1
  22. package/esm/generated-sdk/health/contract.d.ts.map +1 -1
  23. package/esm/generated-sdk/health/contract.js +117 -7
  24. package/esm/generated-sdk/health/mod.d.ts +2 -2
  25. package/esm/generated-sdk/health/mod.d.ts.map +1 -1
  26. package/esm/generated-sdk/health/mod.js +1 -1
  27. package/esm/generated-sdk/health/owned_api.d.ts.map +1 -1
  28. package/esm/generated-sdk/health/schemas.d.ts.map +1 -1
  29. package/esm/generated-sdk/health/schemas.js +79 -1
  30. package/esm/generated-sdk/health/types.d.ts +4 -4
  31. package/esm/generated-sdk/health/types.d.ts.map +1 -1
  32. package/esm/generated-sdk/jobs/api.d.ts.map +1 -1
  33. package/esm/generated-sdk/jobs/api.js +12 -4
  34. package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
  35. package/esm/generated-sdk/jobs/contract.d.ts.map +1 -1
  36. package/esm/generated-sdk/jobs/contract.js +1080 -7
  37. package/esm/generated-sdk/jobs/mod.d.ts +2 -2
  38. package/esm/generated-sdk/jobs/mod.d.ts.map +1 -1
  39. package/esm/generated-sdk/jobs/mod.js +1 -1
  40. package/esm/generated-sdk/jobs/owned_api.d.ts.map +1 -1
  41. package/esm/generated-sdk/jobs/owned_api.js +26 -6
  42. package/esm/generated-sdk/jobs/schemas.d.ts.map +1 -1
  43. package/esm/generated-sdk/jobs/schemas.js +768 -18
  44. package/esm/generated-sdk/jobs/types.d.ts +14 -14
  45. package/esm/generated-sdk/jobs/types.d.ts.map +1 -1
  46. package/esm/generated-sdk/state/api.d.ts.map +1 -1
  47. package/esm/generated-sdk/state/api.js +3 -1
  48. package/esm/generated-sdk/state/client.d.ts.map +1 -1
  49. package/esm/generated-sdk/state/contract.d.ts.map +1 -1
  50. package/esm/generated-sdk/state/contract.js +638 -7
  51. package/esm/generated-sdk/state/mod.d.ts +2 -2
  52. package/esm/generated-sdk/state/mod.d.ts.map +1 -1
  53. package/esm/generated-sdk/state/mod.js +1 -1
  54. package/esm/generated-sdk/state/owned_api.d.ts.map +1 -1
  55. package/esm/generated-sdk/state/owned_api.js +36 -8
  56. package/esm/generated-sdk/state/schemas.d.ts.map +1 -1
  57. package/esm/generated-sdk/state/schemas.js +441 -14
  58. package/esm/generated-sdk/state/types.d.ts +15 -15
  59. package/esm/generated-sdk/state/types.d.ts.map +1 -1
  60. package/esm/generated-sdk/trellis-core/api.d.ts.map +1 -1
  61. package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
  62. package/esm/generated-sdk/trellis-core/contract.d.ts.map +1 -1
  63. package/esm/generated-sdk/trellis-core/contract.js +744 -7
  64. package/esm/generated-sdk/trellis-core/mod.d.ts +2 -2
  65. package/esm/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  66. package/esm/generated-sdk/trellis-core/mod.js +1 -1
  67. package/esm/generated-sdk/trellis-core/owned_api.d.ts.map +1 -1
  68. package/esm/generated-sdk/trellis-core/owned_api.js +1 -1
  69. package/esm/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
  70. package/esm/generated-sdk/trellis-core/schemas.js +626 -8
  71. package/esm/generated-sdk/trellis-core/types.d.ts +14 -14
  72. package/esm/generated-sdk/trellis-core/types.d.ts.map +1 -1
  73. package/esm/index.d.ts +2 -2
  74. package/esm/index.d.ts.map +1 -1
  75. package/esm/index.js +1 -1
  76. package/esm/server/service.d.ts +40 -9
  77. package/esm/server/service.d.ts.map +1 -1
  78. package/esm/server/service.js +28 -4
  79. package/esm/service/deno.d.ts +1 -1
  80. package/esm/service/deno.d.ts.map +1 -1
  81. package/esm/service/mod.d.ts +1 -1
  82. package/esm/service/mod.d.ts.map +1 -1
  83. package/esm/service/node.d.ts +1 -1
  84. package/esm/service/node.d.ts.map +1 -1
  85. package/package.json +2 -2
  86. package/script/contract_support/mod.d.ts +1 -1
  87. package/script/contract_support/mod.d.ts.map +1 -1
  88. package/script/contract_support/mod.js +8 -1
  89. package/script/contract_support/protocol.d.ts +67 -0
  90. package/script/contract_support/protocol.d.ts.map +1 -1
  91. package/script/contract_support/protocol.js +96 -1
  92. package/script/generated-sdk/auth/api.d.ts.map +1 -1
  93. package/script/generated-sdk/auth/client.d.ts.map +1 -1
  94. package/script/generated-sdk/auth/contract.d.ts.map +1 -1
  95. package/script/generated-sdk/auth/contract.js +9590 -7
  96. package/script/generated-sdk/auth/mod.d.ts +3 -3
  97. package/script/generated-sdk/auth/mod.d.ts.map +1 -1
  98. package/script/generated-sdk/auth/mod.js +2 -2
  99. package/script/generated-sdk/auth/owned_api.d.ts.map +1 -1
  100. package/script/generated-sdk/auth/owned_api.js +304 -61
  101. package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
  102. package/script/generated-sdk/auth/schemas.js +6492 -139
  103. package/script/generated-sdk/auth/types.d.ts +254 -254
  104. package/script/generated-sdk/auth/types.d.ts.map +1 -1
  105. package/script/generated-sdk/health/api.d.ts.map +1 -1
  106. package/script/generated-sdk/health/client.d.ts.map +1 -1
  107. package/script/generated-sdk/health/contract.d.ts.map +1 -1
  108. package/script/generated-sdk/health/contract.js +117 -7
  109. package/script/generated-sdk/health/mod.d.ts +2 -2
  110. package/script/generated-sdk/health/mod.d.ts.map +1 -1
  111. package/script/generated-sdk/health/mod.js +2 -2
  112. package/script/generated-sdk/health/owned_api.d.ts.map +1 -1
  113. package/script/generated-sdk/health/schemas.d.ts.map +1 -1
  114. package/script/generated-sdk/health/schemas.js +79 -1
  115. package/script/generated-sdk/health/types.d.ts +4 -4
  116. package/script/generated-sdk/health/types.d.ts.map +1 -1
  117. package/script/generated-sdk/jobs/api.d.ts.map +1 -1
  118. package/script/generated-sdk/jobs/api.js +12 -4
  119. package/script/generated-sdk/jobs/client.d.ts.map +1 -1
  120. package/script/generated-sdk/jobs/contract.d.ts.map +1 -1
  121. package/script/generated-sdk/jobs/contract.js +1080 -7
  122. package/script/generated-sdk/jobs/mod.d.ts +2 -2
  123. package/script/generated-sdk/jobs/mod.d.ts.map +1 -1
  124. package/script/generated-sdk/jobs/mod.js +2 -2
  125. package/script/generated-sdk/jobs/owned_api.d.ts.map +1 -1
  126. package/script/generated-sdk/jobs/owned_api.js +25 -5
  127. package/script/generated-sdk/jobs/schemas.d.ts.map +1 -1
  128. package/script/generated-sdk/jobs/schemas.js +768 -18
  129. package/script/generated-sdk/jobs/types.d.ts +14 -14
  130. package/script/generated-sdk/jobs/types.d.ts.map +1 -1
  131. package/script/generated-sdk/state/api.d.ts.map +1 -1
  132. package/script/generated-sdk/state/api.js +3 -1
  133. package/script/generated-sdk/state/client.d.ts.map +1 -1
  134. package/script/generated-sdk/state/contract.d.ts.map +1 -1
  135. package/script/generated-sdk/state/contract.js +638 -7
  136. package/script/generated-sdk/state/mod.d.ts +2 -2
  137. package/script/generated-sdk/state/mod.d.ts.map +1 -1
  138. package/script/generated-sdk/state/mod.js +2 -2
  139. package/script/generated-sdk/state/owned_api.d.ts.map +1 -1
  140. package/script/generated-sdk/state/owned_api.js +35 -7
  141. package/script/generated-sdk/state/schemas.d.ts.map +1 -1
  142. package/script/generated-sdk/state/schemas.js +441 -14
  143. package/script/generated-sdk/state/types.d.ts +15 -15
  144. package/script/generated-sdk/state/types.d.ts.map +1 -1
  145. package/script/generated-sdk/trellis-core/api.d.ts.map +1 -1
  146. package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
  147. package/script/generated-sdk/trellis-core/contract.d.ts.map +1 -1
  148. package/script/generated-sdk/trellis-core/contract.js +744 -7
  149. package/script/generated-sdk/trellis-core/mod.d.ts +2 -2
  150. package/script/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  151. package/script/generated-sdk/trellis-core/mod.js +2 -2
  152. package/script/generated-sdk/trellis-core/owned_api.d.ts.map +1 -1
  153. package/script/generated-sdk/trellis-core/schemas.d.ts.map +1 -1
  154. package/script/generated-sdk/trellis-core/schemas.js +626 -8
  155. package/script/generated-sdk/trellis-core/types.d.ts +14 -14
  156. package/script/generated-sdk/trellis-core/types.d.ts.map +1 -1
  157. package/script/index.d.ts +2 -2
  158. package/script/index.d.ts.map +1 -1
  159. package/script/index.js +9 -2
  160. package/script/server/service.d.ts +40 -9
  161. package/script/server/service.d.ts.map +1 -1
  162. package/script/server/service.js +27 -3
  163. package/script/service/deno.d.ts +1 -1
  164. package/script/service/deno.d.ts.map +1 -1
  165. package/script/service/mod.d.ts +1 -1
  166. package/script/service/mod.d.ts.map +1 -1
  167. package/script/service/node.d.ts +1 -1
  168. package/script/service/node.d.ts.map +1 -1
  169. package/src/contract_support/mod.ts +12 -0
  170. package/src/contract_support/protocol.ts +137 -0
  171. package/src/index.ts +12 -0
  172. package/src/sdk/_generated/auth/api.ts +10 -21
  173. package/src/sdk/_generated/auth/client.ts +1178 -160
  174. package/src/sdk/_generated/auth/contract.ts +9637 -13
  175. package/src/sdk/_generated/auth/mod.ts +22 -3
  176. package/src/sdk/_generated/auth/owned_api.ts +897 -264
  177. package/src/sdk/_generated/auth/schemas.ts +6630 -278
  178. package/src/sdk/_generated/auth/types.ts +2950 -359
  179. package/src/sdk/_generated/core/api.ts +10 -21
  180. package/src/sdk/_generated/core/client.ts +105 -12
  181. package/src/sdk/_generated/core/contract.ts +774 -13
  182. package/src/sdk/_generated/core/mod.ts +17 -2
  183. package/src/sdk/_generated/core/owned_api.ts +40 -24
  184. package/src/sdk/_generated/core/schemas.ts +626 -9
  185. package/src/sdk/_generated/core/types.ts +233 -18
  186. package/src/sdk/_generated/health/api.ts +10 -21
  187. package/src/sdk/_generated/health/client.ts +104 -8
  188. package/src/sdk/_generated/health/contract.ts +144 -13
  189. package/src/sdk/_generated/health/mod.ts +17 -2
  190. package/src/sdk/_generated/health/owned_api.ts +4 -9
  191. package/src/sdk/_generated/health/schemas.ts +79 -2
  192. package/src/sdk/_generated/health/types.ts +31 -4
  193. package/src/sdk/_generated/jobs/api.ts +20 -18
  194. package/src/sdk/_generated/jobs/client.ts +199 -28
  195. package/src/sdk/_generated/jobs/contract.ts +1119 -13
  196. package/src/sdk/_generated/jobs/mod.ts +17 -2
  197. package/src/sdk/_generated/jobs/owned_api.ts +64 -27
  198. package/src/sdk/_generated/jobs/schemas.ts +776 -20
  199. package/src/sdk/_generated/jobs/types.ts +407 -34
  200. package/src/sdk/_generated/state/api.ts +11 -18
  201. package/src/sdk/_generated/state/client.ts +169 -22
  202. package/src/sdk/_generated/state/contract.ts +670 -13
  203. package/src/sdk/_generated/state/mod.ts +17 -2
  204. package/src/sdk/_generated/state/owned_api.ts +65 -25
  205. package/src/sdk/_generated/state/schemas.ts +441 -15
  206. package/src/sdk/_generated/state/types.ts +229 -26
  207. package/src/server/service.ts +133 -7
  208. package/src/service/deno.ts +4 -0
  209. package/src/service/mod.ts +4 -0
  210. package/src/service/node.ts +4 -0
@@ -3,42 +3,246 @@ import type { RpcHandlerFn } from "../../../index.js";
3
3
  import type { API } from "./api.js";
4
4
 
5
5
  export const CONTRACT_ID = "trellis.state@v1" as const;
6
- export const CONTRACT_DIGEST = "XfWDYLTBlYFjDqMPBEXrTBccZbFvHp0MnqscehdRKT4" as const;
6
+ export const CONTRACT_DIGEST =
7
+ "XfWDYLTBlYFjDqMPBEXrTBccZbFvHp0MnqscehdRKT4" as const;
7
8
 
8
- export type StateAdminDeleteInput = ({ contractDigest: string; contractId: string; expectedRevision?: string; key?: string; scope: "userApp"; store: string; user: { id: string; origin: string; userId?: string; }; } | { contractDigest: string; contractId: string; deviceId: string; expectedRevision?: string; key?: string; scope: "deviceApp"; store: string; });
9
- export type StateAdminDeleteOutput = { deleted: boolean; };
9
+ export type StateAdminDeleteInput = {
10
+ contractDigest: string;
11
+ contractId: string;
12
+ expectedRevision?: string;
13
+ key?: string;
14
+ scope: "userApp";
15
+ store: string;
16
+ user: { id: string; origin: string; userId?: string };
17
+ } | {
18
+ contractDigest: string;
19
+ contractId: string;
20
+ deviceId: string;
21
+ expectedRevision?: string;
22
+ key?: string;
23
+ scope: "deviceApp";
24
+ store: string;
25
+ };
26
+ export type StateAdminDeleteOutput = { deleted: boolean };
10
27
 
11
- export type StateAdminGetInput = ({ contractDigest: string; contractId: string; key?: string; scope: "userApp"; store: string; user: { id: string; origin: string; userId?: string; }; } | { contractDigest: string; contractId: string; deviceId: string; key?: string; scope: "deviceApp"; store: string; });
12
- export type StateAdminGetOutput = ({ found: false; } | { entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; found: true; } | { currentStateVersion: string; entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; migrationRequired: true; stateVersion: string; writerContractDigest: string; });
28
+ export type StateAdminGetInput = {
29
+ contractDigest: string;
30
+ contractId: string;
31
+ key?: string;
32
+ scope: "userApp";
33
+ store: string;
34
+ user: { id: string; origin: string; userId?: string };
35
+ } | {
36
+ contractDigest: string;
37
+ contractId: string;
38
+ deviceId: string;
39
+ key?: string;
40
+ scope: "deviceApp";
41
+ store: string;
42
+ };
43
+ export type StateAdminGetOutput = { found: false } | {
44
+ entry: {
45
+ expiresAt?: string;
46
+ key?: string;
47
+ revision: string;
48
+ updatedAt: string;
49
+ value: unknown;
50
+ };
51
+ found: true;
52
+ } | {
53
+ currentStateVersion: string;
54
+ entry: {
55
+ expiresAt?: string;
56
+ key?: string;
57
+ revision: string;
58
+ updatedAt: string;
59
+ value: unknown;
60
+ };
61
+ migrationRequired: true;
62
+ stateVersion: string;
63
+ writerContractDigest: string;
64
+ };
13
65
 
14
- export type StateAdminListInput = ({ contractDigest: string; contractId: string; limit: number; offset?: number; prefix?: string; scope: "userApp"; store: string; user: { id: string; origin: string; userId?: string; }; } | { contractDigest: string; contractId: string; deviceId: string; limit: number; offset?: number; prefix?: string; scope: "deviceApp"; store: string; });
15
- export type StateAdminListOutput = { count: number; entries: Array<({ expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; } | { currentStateVersion: string; entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; migrationRequired: true; stateVersion: string; writerContractDigest: string; })>; limit: number; nextOffset?: number; offset: number; };
66
+ export type StateAdminListInput = {
67
+ contractDigest: string;
68
+ contractId: string;
69
+ limit: number;
70
+ offset?: number;
71
+ prefix?: string;
72
+ scope: "userApp";
73
+ store: string;
74
+ user: { id: string; origin: string; userId?: string };
75
+ } | {
76
+ contractDigest: string;
77
+ contractId: string;
78
+ deviceId: string;
79
+ limit: number;
80
+ offset?: number;
81
+ prefix?: string;
82
+ scope: "deviceApp";
83
+ store: string;
84
+ };
85
+ export type StateAdminListOutput = {
86
+ count: number;
87
+ entries: Array<
88
+ ({
89
+ expiresAt?: string;
90
+ key?: string;
91
+ revision: string;
92
+ updatedAt: string;
93
+ value: unknown;
94
+ } | {
95
+ currentStateVersion: string;
96
+ entry: {
97
+ expiresAt?: string;
98
+ key?: string;
99
+ revision: string;
100
+ updatedAt: string;
101
+ value: unknown;
102
+ };
103
+ migrationRequired: true;
104
+ stateVersion: string;
105
+ writerContractDigest: string;
106
+ })
107
+ >;
108
+ limit: number;
109
+ nextOffset?: number;
110
+ offset: number;
111
+ };
16
112
 
17
- export type StateDeleteInput = { expectedRevision?: string; key?: string; store: string; };
18
- export type StateDeleteOutput = { deleted: boolean; };
113
+ export type StateDeleteInput = {
114
+ expectedRevision?: string;
115
+ key?: string;
116
+ store: string;
117
+ };
118
+ export type StateDeleteOutput = { deleted: boolean };
19
119
 
20
- export type StateGetInput = { key?: string; store: string; };
21
- export type StateGetOutput = ({ found: false; } | { entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; found: true; } | { currentStateVersion: string; entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; migrationRequired: true; stateVersion: string; writerContractDigest: string; });
120
+ export type StateGetInput = { key?: string; store: string };
121
+ export type StateGetOutput = { found: false } | {
122
+ entry: {
123
+ expiresAt?: string;
124
+ key?: string;
125
+ revision: string;
126
+ updatedAt: string;
127
+ value: unknown;
128
+ };
129
+ found: true;
130
+ } | {
131
+ currentStateVersion: string;
132
+ entry: {
133
+ expiresAt?: string;
134
+ key?: string;
135
+ revision: string;
136
+ updatedAt: string;
137
+ value: unknown;
138
+ };
139
+ migrationRequired: true;
140
+ stateVersion: string;
141
+ writerContractDigest: string;
142
+ };
22
143
 
23
- export type StateListInput = { limit: number; offset?: number; prefix?: string; store: string; };
24
- export type StateListOutput = { count: number; entries: Array<({ expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; } | { currentStateVersion: string; entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; migrationRequired: true; stateVersion: string; writerContractDigest: string; })>; limit: number; nextOffset?: number; offset: number; };
144
+ export type StateListInput = {
145
+ limit: number;
146
+ offset?: number;
147
+ prefix?: string;
148
+ store: string;
149
+ };
150
+ export type StateListOutput = {
151
+ count: number;
152
+ entries: Array<
153
+ ({
154
+ expiresAt?: string;
155
+ key?: string;
156
+ revision: string;
157
+ updatedAt: string;
158
+ value: unknown;
159
+ } | {
160
+ currentStateVersion: string;
161
+ entry: {
162
+ expiresAt?: string;
163
+ key?: string;
164
+ revision: string;
165
+ updatedAt: string;
166
+ value: unknown;
167
+ };
168
+ migrationRequired: true;
169
+ stateVersion: string;
170
+ writerContractDigest: string;
171
+ })
172
+ >;
173
+ limit: number;
174
+ nextOffset?: number;
175
+ offset: number;
176
+ };
25
177
 
26
- export type StatePutInput = { expectedRevision?: (string | null); key?: string; store: string; ttlMs?: number; value: unknown; };
27
- export type StatePutOutput = ({ applied: true; entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; } | { applied: false; entry?: ({ expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; } | { currentStateVersion: string; entry: { expiresAt?: string; key?: string; revision: string; updatedAt: string; value: unknown; }; migrationRequired: true; stateVersion: string; writerContractDigest: string; }); found: boolean; });
178
+ export type StatePutInput = {
179
+ expectedRevision?: string | null;
180
+ key?: string;
181
+ store: string;
182
+ ttlMs?: number;
183
+ value: unknown;
184
+ };
185
+ export type StatePutOutput = {
186
+ applied: true;
187
+ entry: {
188
+ expiresAt?: string;
189
+ key?: string;
190
+ revision: string;
191
+ updatedAt: string;
192
+ value: unknown;
193
+ };
194
+ } | {
195
+ applied: false;
196
+ entry?: {
197
+ expiresAt?: string;
198
+ key?: string;
199
+ revision: string;
200
+ updatedAt: string;
201
+ value: unknown;
202
+ } | {
203
+ currentStateVersion: string;
204
+ entry: {
205
+ expiresAt?: string;
206
+ key?: string;
207
+ revision: string;
208
+ updatedAt: string;
209
+ value: unknown;
210
+ };
211
+ migrationRequired: true;
212
+ stateVersion: string;
213
+ writerContractDigest: string;
214
+ };
215
+ found: boolean;
216
+ };
28
217
 
29
218
  export interface RpcMap {
30
- "State.Admin.Delete": { input: StateAdminDeleteInput; output: StateAdminDeleteOutput; };
31
- "State.Admin.Get": { input: StateAdminGetInput; output: StateAdminGetOutput; };
32
- "State.Admin.List": { input: StateAdminListInput; output: StateAdminListOutput; };
33
- "State.Delete": { input: StateDeleteInput; output: StateDeleteOutput; };
34
- "State.Get": { input: StateGetInput; output: StateGetOutput; };
35
- "State.List": { input: StateListInput; output: StateListOutput; };
36
- "State.Put": { input: StatePutInput; output: StatePutOutput; };
219
+ "State.Admin.Delete": {
220
+ input: StateAdminDeleteInput;
221
+ output: StateAdminDeleteOutput;
222
+ };
223
+ "State.Admin.Get": { input: StateAdminGetInput; output: StateAdminGetOutput };
224
+ "State.Admin.List": {
225
+ input: StateAdminListInput;
226
+ output: StateAdminListOutput;
227
+ };
228
+ "State.Delete": { input: StateDeleteInput; output: StateDeleteOutput };
229
+ "State.Get": { input: StateGetInput; output: StateGetOutput };
230
+ "State.List": { input: StateListInput; output: StateListOutput };
231
+ "State.Put": { input: StatePutInput; output: StatePutOutput };
37
232
  }
38
233
 
39
- export type StateAdminDeleteHandler = RpcHandlerFn<typeof API.owned, "State.Admin.Delete">;
40
- export type StateAdminGetHandler = RpcHandlerFn<typeof API.owned, "State.Admin.Get">;
41
- export type StateAdminListHandler = RpcHandlerFn<typeof API.owned, "State.Admin.List">;
234
+ export type StateAdminDeleteHandler = RpcHandlerFn<
235
+ typeof API.owned,
236
+ "State.Admin.Delete"
237
+ >;
238
+ export type StateAdminGetHandler = RpcHandlerFn<
239
+ typeof API.owned,
240
+ "State.Admin.Get"
241
+ >;
242
+ export type StateAdminListHandler = RpcHandlerFn<
243
+ typeof API.owned,
244
+ "State.Admin.List"
245
+ >;
42
246
  export type StateDeleteHandler = RpcHandlerFn<typeof API.owned, "State.Delete">;
43
247
  export type StateGetHandler = RpcHandlerFn<typeof API.owned, "State.Get">;
44
248
  export type StateListHandler = RpcHandlerFn<typeof API.owned, "State.List">;
@@ -52,4 +256,3 @@ export interface FeedMap {
52
256
 
53
257
  export interface SubjectMap {
54
258
  }
55
-
@@ -49,7 +49,12 @@ import {
49
49
  } from "@qlever-llc/result";
50
50
  import { Type } from "typebox";
51
51
  import { Value } from "typebox/value";
52
- import { type HealthCheckFn, ServiceHealth } from "./health.js";
52
+ import {
53
+ type HealthCheckFn,
54
+ ServiceHealth,
55
+ type ServiceHealthCheck,
56
+ type ServiceHealthInfo,
57
+ } from "./health.js";
53
58
  import { mountStandardHealthRpc } from "./health_rpc.js";
54
59
  import type { EventDesc, RPCDesc } from "../contracts.js";
55
60
  import type {
@@ -951,6 +956,22 @@ type ContractJobName<
951
956
  >,
952
957
  > = keyof ContractJobsOf<TContract> & string;
953
958
 
959
+ type ContractEventName<
960
+ TContract extends ServiceContract<
961
+ TrellisAPI,
962
+ TrellisAPI | undefined,
963
+ ContractJobsMetadata
964
+ >,
965
+ > = ServiceEventName<ContractTrellisApi<TContract>>;
966
+
967
+ type ContractFeedName<
968
+ TContract extends ServiceContract<
969
+ TrellisAPI,
970
+ TrellisAPI | undefined,
971
+ ContractJobsMetadata
972
+ >,
973
+ > = keyof ContractOwnedApi<TContract>["feeds"] & string;
974
+
954
975
  type ContractOperationName<
955
976
  TContract extends ServiceContract<
956
977
  TrellisAPI,
@@ -986,6 +1007,7 @@ export type JobArgs<
986
1007
  ContractKvMetadata
987
1008
  >,
988
1009
  TJob extends ContractJobName<TContract>,
1010
+ TDeps = undefined,
989
1011
  > = {
990
1012
  job: PublicActiveJob<
991
1013
  ContractJobPayload<TContract, TJob>,
@@ -996,7 +1018,7 @@ export type JobArgs<
996
1018
  ContractKvOf<TContract>,
997
1019
  ContractJobsOf<TContract>
998
1020
  >;
999
- };
1021
+ } & WithDeps<TDeps>;
1000
1022
 
1001
1023
  /** Result returned by a typed Trellis service job handler. */
1002
1024
  export type JobResult<
@@ -1009,6 +1031,9 @@ export type JobResult<
1009
1031
  TJob extends ContractJobName<TContract>,
1010
1032
  > = Result<ContractJobResult<TContract, TJob>, BaseError>;
1011
1033
 
1034
+ type WithDeps<TDeps> = [TDeps] extends [undefined] ? {} : { deps: TDeps };
1035
+
1036
+ /** Typed RPC handler function for an extracted Trellis service handler. */
1012
1037
  export type RpcHandler<
1013
1038
  TContract extends ServiceContract<
1014
1039
  TrellisAPI,
@@ -1017,6 +1042,7 @@ export type RpcHandler<
1017
1042
  ContractKvMetadata
1018
1043
  >,
1019
1044
  M extends RpcMethodName<ContractOwnedApi<TContract>>,
1045
+ TDeps = undefined,
1020
1046
  > = ({
1021
1047
  input,
1022
1048
  context,
@@ -1029,7 +1055,7 @@ export type RpcHandler<
1029
1055
  ContractKvOf<TContract>,
1030
1056
  ContractJobsOf<TContract>
1031
1057
  >;
1032
- }) =>
1058
+ } & WithDeps<TDeps>) =>
1033
1059
  | Promise<
1034
1060
  Result<
1035
1061
  RpcMethodOutput<ContractOwnedApi<TContract>, M>,
@@ -1041,6 +1067,55 @@ export type RpcHandler<
1041
1067
  RpcHandlerErrorOf<ContractOwnedApi<TContract>, M>
1042
1068
  >;
1043
1069
 
1070
+ /** Typed event listener function for an extracted Trellis service listener. */
1071
+ export type ServiceEventHandler<
1072
+ TContract extends ServiceContract<
1073
+ TrellisAPI,
1074
+ TrellisAPI | undefined,
1075
+ ContractJobsMetadata,
1076
+ ContractKvMetadata
1077
+ >,
1078
+ E extends ContractEventName<TContract>,
1079
+ TDeps = undefined,
1080
+ > = (
1081
+ args: {
1082
+ event: ServiceEventOf<ContractTrellisApi<TContract>, E>;
1083
+ context: EventListenerContext;
1084
+ client: Trellis<
1085
+ ContractTrellisApi<TContract>,
1086
+ ContractKvOf<TContract>,
1087
+ ContractJobsOf<TContract>
1088
+ >;
1089
+ } & WithDeps<TDeps>,
1090
+ ) => MaybeAsync<void, BaseError>;
1091
+
1092
+ /** Typed feed handler function for an extracted Trellis service handler. */
1093
+ export type FeedHandler<
1094
+ TContract extends ServiceContract<
1095
+ TrellisAPI,
1096
+ TrellisAPI | undefined,
1097
+ ContractJobsMetadata,
1098
+ ContractKvMetadata
1099
+ >,
1100
+ F extends ContractFeedName<TContract>,
1101
+ TDeps = undefined,
1102
+ > = (
1103
+ context: {
1104
+ input: FeedInputOf<ContractOwnedApi<TContract>, F>;
1105
+ caller: unknown;
1106
+ signal: AbortSignal;
1107
+ emit(
1108
+ event: FeedEventOf<ContractOwnedApi<TContract>, F>,
1109
+ ): AsyncResult<void, ValidationError | UnexpectedError>;
1110
+ client: Trellis<
1111
+ ContractTrellisApi<TContract>,
1112
+ ContractKvOf<TContract>,
1113
+ ContractJobsOf<TContract>
1114
+ >;
1115
+ } & WithDeps<TDeps>,
1116
+ ) => unknown | Promise<unknown>;
1117
+
1118
+ /** Typed job handler function for an extracted Trellis service job handler. */
1044
1119
  export type JobHandler<
1045
1120
  TContract extends ServiceContract<
1046
1121
  TrellisAPI,
@@ -1049,8 +1124,12 @@ export type JobHandler<
1049
1124
  ContractKvMetadata
1050
1125
  >,
1051
1126
  TJob extends ContractJobName<TContract>,
1052
- > = (args: JobArgs<TContract, TJob>) => Promise<JobResult<TContract, TJob>>;
1127
+ TDeps = undefined,
1128
+ > = (args: JobArgs<TContract, TJob, TDeps>) => Promise<
1129
+ JobResult<TContract, TJob>
1130
+ >;
1053
1131
 
1132
+ /** Typed operation handler function for an extracted Trellis service handler. */
1054
1133
  export type OperationHandler<
1055
1134
  TContract extends ServiceContract<
1056
1135
  TrellisAPI,
@@ -1059,6 +1138,7 @@ export type OperationHandler<
1059
1138
  ContractKvMetadata
1060
1139
  >,
1061
1140
  O extends ContractOperationName<TContract>,
1141
+ TDeps = undefined,
1062
1142
  > = (
1063
1143
  args:
1064
1144
  & OperationHandlerContext<
@@ -1073,9 +1153,20 @@ export type OperationHandler<
1073
1153
  ContractKvOf<TContract>,
1074
1154
  ContractJobsOf<TContract>
1075
1155
  >;
1076
- },
1156
+ }
1157
+ & WithDeps<TDeps>,
1077
1158
  ) => unknown | Promise<unknown>;
1078
1159
 
1160
+ /** Typed health info function for an extracted bound service health handler. */
1161
+ export type HealthInfoHandler<TDeps = undefined> = (
1162
+ args: WithDeps<TDeps>,
1163
+ ) => ServiceHealthInfo | undefined | Promise<ServiceHealthInfo | undefined>;
1164
+
1165
+ /** Typed health check function for an extracted bound service health handler. */
1166
+ export type HealthCheckHandler<TDeps = undefined> = (
1167
+ args: WithDeps<TDeps>,
1168
+ ) => ServiceHealthCheck | Promise<ServiceHealthCheck>;
1169
+
1079
1170
  export type JobQueue<
1080
1171
  TPayload,
1081
1172
  TResult,
@@ -1320,6 +1411,14 @@ type BoundJobsFacadeOf<
1320
1411
  >;
1321
1412
  };
1322
1413
 
1414
+ type BoundServiceHealth<TDeps> = Omit<ServiceHealth, "add" | "setInfo"> & {
1415
+ setInfo(info: ServiceHealthInfo | HealthInfoHandler<TDeps>): void;
1416
+ add(
1417
+ name: string,
1418
+ check: HealthCheckHandler<TDeps>,
1419
+ ): () => void;
1420
+ };
1421
+
1323
1422
  /** Service wrapper returned by `TrellisService.with(deps)`. */
1324
1423
  export type BoundTrellisService<
1325
1424
  TOwnedApi extends TrellisAPI = TrellisAPI,
@@ -1335,7 +1434,6 @@ export type BoundTrellisService<
1335
1434
  | "nc"
1336
1435
  | "kv"
1337
1436
  | "store"
1338
- | "health"
1339
1437
  | "connection"
1340
1438
  | "createTransfer"
1341
1439
  | "completeOperation"
@@ -1350,6 +1448,7 @@ export type BoundTrellisService<
1350
1448
  TJobs,
1351
1449
  TDeps
1352
1450
  >;
1451
+ readonly health: BoundServiceHealth<TDeps>;
1353
1452
  readonly jobs: BoundJobsFacadeOf<TJobs, TTrellisApi, TKv, TDeps>;
1354
1453
  readonly handle: BoundTypedServiceHandleFacade<
1355
1454
  TOwnedApi,
@@ -2691,7 +2790,7 @@ export class TrellisService<
2691
2790
  kv: this.kv,
2692
2791
  store: this.store,
2693
2792
  jobs: createBoundJobsFacade({ jobs: this.jobs, deps }),
2694
- health: this.health,
2793
+ health: this.#createBoundHealth(deps),
2695
2794
  handle: this.#createBoundHandleFacade(deps),
2696
2795
  connection: this.connection,
2697
2796
  createTransfer: (args) => this.createTransfer(args),
@@ -2703,6 +2802,33 @@ export class TrellisService<
2703
2802
  };
2704
2803
  }
2705
2804
 
2805
+ #createBoundHealth<TDeps>(deps: TDeps): BoundServiceHealth<TDeps> {
2806
+ const health = this.health;
2807
+ return {
2808
+ serviceName: health.serviceName,
2809
+ kind: health.kind,
2810
+ instanceId: health.instanceId,
2811
+ contractId: health.contractId,
2812
+ contractDigest: health.contractDigest,
2813
+ startedAt: health.startedAt,
2814
+ publishIntervalMs: health.publishIntervalMs,
2815
+ setInfo(info) {
2816
+ if (typeof info !== "function") {
2817
+ health.setInfo(info);
2818
+ return;
2819
+ }
2820
+
2821
+ health.setInfo(() => info({ deps }));
2822
+ },
2823
+ add(name, check) {
2824
+ return health.add(name, () => check({ deps }));
2825
+ },
2826
+ checks: () => health.checks(),
2827
+ response: () => health.response(),
2828
+ heartbeat: () => health.heartbeat(),
2829
+ };
2830
+ }
2831
+
2706
2832
  #createBoundEventFacade<TDeps>(
2707
2833
  deps: TDeps,
2708
2834
  ): BoundActiveEventFacade<TTrellisApi, TTrellisApi, TKv, TJobs, TDeps> {
@@ -1,6 +1,9 @@
1
1
  import "../_dnt.polyfills.js";
2
2
  export {
3
3
  type BoundTrellisService,
4
+ type FeedHandler,
5
+ type HealthCheckHandler,
6
+ type HealthInfoHandler,
4
7
  type JobArgs,
5
8
  type JobHandler,
6
9
  type JobQueue,
@@ -10,6 +13,7 @@ export {
10
13
  type OperationRegistration,
11
14
  type RpcHandler,
12
15
  type ServiceContract,
16
+ type ServiceEventHandler,
13
17
  type Trellis,
14
18
  TrellisService,
15
19
  type TrellisServiceConnectOpts,
@@ -37,6 +37,9 @@ export {
37
37
  } from "../server/health_schemas.js";
38
38
  export {
39
39
  type BoundTrellisService,
40
+ type FeedHandler,
41
+ type HealthCheckHandler,
42
+ type HealthInfoHandler,
40
43
  type JobArgs,
41
44
  type JobHandler,
42
45
  type JobQueue,
@@ -46,6 +49,7 @@ export {
46
49
  type OperationRegistration,
47
50
  type RpcHandler,
48
51
  type ServiceContract,
52
+ type ServiceEventHandler,
49
53
  StoreHandle,
50
54
  type Trellis,
51
55
  TrellisService,
@@ -1,6 +1,9 @@
1
1
  import "../_dnt.polyfills.js";
2
2
  export {
3
3
  type BoundTrellisService,
4
+ type FeedHandler,
5
+ type HealthCheckHandler,
6
+ type HealthInfoHandler,
4
7
  type JobArgs,
5
8
  type JobHandler,
6
9
  type JobQueue,
@@ -10,6 +13,7 @@ export {
10
13
  type OperationRegistration,
11
14
  type RpcHandler,
12
15
  type ServiceContract,
16
+ type ServiceEventHandler,
13
17
  type Trellis,
14
18
  TrellisService,
15
19
  type TrellisServiceConnectOpts,