@stanterprise/protobuf 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -1 +1,129 @@
1
- # Stanterprise test solution Typescript Protobuf implementations
1
+ # @stanterprise/protobuf
2
+
3
+ TypeScript protobuf definitions and RPC service stubs for the Test System domain (attachments, events, observer service, and test entities). Generated code targets both ESM and CJS using `tsup`.
4
+
5
+ > NOTE: The currently committed generated TypeScript sources do not fully match the proto definitions under `protobuf/testsystem/v1/**` (naming & package/version differences). See "Schema Status" below. This will be aligned in upcoming steps.
6
+
7
+ ## Contents
8
+
9
+ - Generated message & enum types (`lib/*.ts`)
10
+ - gRPC / protobuf-ts style service client & service descriptors
11
+ - Proto source files (versioned) in `protobuf/testsystem/v1/**`
12
+ - Build tooling via `tsup`
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @stanterprise/protobuf
18
+ ```
19
+
20
+ ## Quick Usage
21
+
22
+ Encoding / decoding a message (protobuf-ts runtime):
23
+
24
+ ```ts
25
+ import { Attachment } from "@stanterprise/protobuf";
26
+ import { WireType, BinaryWriter, BinaryReader } from "@protobuf-ts/runtime";
27
+
28
+ const a = Attachment.create({
29
+ name: "log.txt",
30
+ mimeType: "text/plain",
31
+ content: new Uint8Array([1, 2, 3]),
32
+ });
33
+ // Encode
34
+ const writer = new BinaryWriter();
35
+ Attachment.internalBinaryWrite(a, writer, { writeUnknownFields: false });
36
+ const bytes = writer.finish();
37
+ // Decode
38
+ const decoded = Attachment.internalBinaryRead(
39
+ new BinaryReader(bytes),
40
+ bytes.length,
41
+ { readUnknownField: false }
42
+ );
43
+ ```
44
+
45
+ Calling an RPC (unary) with a transport implementation:
46
+
47
+ ```ts
48
+ import {
49
+ TestEventCollectorClient,
50
+ TestStartEvent,
51
+ } from "@stanterprise/protobuf";
52
+ import { GrpcTransport } from "@protobuf-ts/grpc-transport"; // example transport
53
+
54
+ const transport = new GrpcTransport({
55
+ host: "https://observer.example.com",
56
+ });
57
+
58
+ const client = new TestEventCollectorClient(transport);
59
+
60
+ const call = client.reportTestStart({
61
+ testId: "T-123",
62
+ testName: "Sample test",
63
+ metadata: { browser: "chrome" },
64
+ });
65
+
66
+ call.response.then((resp) => {
67
+ console.log("Ack:", resp);
68
+ });
69
+ ```
70
+
71
+ ## Schema Status (Current Divergences)
72
+
73
+ | Aspect | Proto (`protobuf/testsystem/v1`) | Generated TS (lib) | Divergence |
74
+ | -------------- | -------------------------------- | ---------------------- | ------------------------------ | ------------- |
75
+ | Package paths | `testsystem.v1.*` | `testsystem.*` | Missing `v1` in generated code |
76
+ | Event messages | `*EventRequest` suffix | `TestStartEvent`, etc. | Name suffix removed |
77
+ | Ack message | `AckResponse` w/ `error_code` | `Ack` (no error_code) | Field & name mismatch |
78
+ | Attachment | `oneof payload { content | uri }` | Single `content` bytes field | Oneof missing |
79
+ | Entities | `TestSuite` has `id` | No `id` field present | Field missing |
80
+
81
+ These will be reconciled in a future regeneration step. Until then the published package reflects the generated TS API, not the proto sources.
82
+
83
+ ## Regeneration (Planned Standard)
84
+
85
+ Planned one-generator approach (protobuf-ts):
86
+
87
+ ```bash
88
+ mkdir -p lib
89
+ protoc \
90
+ --plugin=./node_modules/.bin/protoc-gen-ts_proto \
91
+ --ts_out lib \
92
+ --ts_opt long_type_string,optimize_code_size \
93
+ --proto_path ./protobuf \
94
+ $(git ls-files 'protobuf/testsystem/v1/**/*.proto')
95
+ node scripts/gen-index.js
96
+ ```
97
+
98
+ > The exact command will be updated once the generator set is trimmed and version pinning strategy finalized.
99
+
100
+ ## Versioning Policy
101
+
102
+ - Patch: Non-breaking regeneration (comments, doc, internal tooling changes)
103
+ - Minor: Additive schema changes (new optional fields, new messages, new RPC methods)
104
+ - Major: Breaking schema changes (renames, removed fields/messages, package path changes)
105
+
106
+ ## Design Notes
107
+
108
+ - Dual ESM/CJS build via `tsup` for Node + bundlers.
109
+ - Externalized protobuf runtime libraries to keep package lean.
110
+ - Auto-generated `lib/index.ts` consolidates exports (watch for accidental surface expansion if helper files are added).
111
+
112
+ ## Roadmap (Short Term)
113
+
114
+ 1. Align generated code with `v1` proto packages & names
115
+ 2. Implement `Attachment.payload` oneof correctly
116
+ 3. Drop unused generator dependencies (`ts-proto`, `ts-protoc-gen`, etc.)
117
+ 4. Add `exports` map and remove `prepare` generation hook
118
+ 5. Introduce linting + formatting + CI regeneration verification
119
+ 6. Document RPC transport setup examples
120
+
121
+ ## Contributing
122
+
123
+ 1. Install deps: `npm install`
124
+ 2. (Temporary) Generated code is committed; do NOT run `npm run generate` until after divergence plan is executed.
125
+ 3. Open PRs referencing which proto changes (if any) they rely on.
126
+
127
+ ## License
128
+
129
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,407 +1,2 @@
1
- import * as _protobuf_ts_runtime from '@protobuf-ts/runtime';
2
- import { MessageType, PartialMessage, IBinaryReader, BinaryReadOptions, IBinaryWriter, BinaryWriteOptions, JsonWriteOptions, JsonValue, JsonReadOptions } from '@protobuf-ts/runtime';
3
- import * as _protobuf_ts_runtime_rpc from '@protobuf-ts/runtime-rpc';
4
- import { ServiceType, RpcOptions, UnaryCall, ServiceInfo, RpcTransport } from '@protobuf-ts/runtime-rpc';
5
-
6
- /**
7
- * Enum for test result statuses
8
- *
9
- * @generated from protobuf enum testsystem.common.TestStatus
10
- */
11
- declare enum TestStatus {
12
- /**
13
- * @generated from protobuf enum value: UNKNOWN = 0;
14
- */
15
- UNKNOWN = 0,
16
- /**
17
- * @generated from protobuf enum value: PASSED = 1;
18
- */
19
- PASSED = 1,
20
- /**
21
- * @generated from protobuf enum value: FAILED = 2;
22
- */
23
- FAILED = 2,
24
- /**
25
- * @generated from protobuf enum value: SKIPPED = 3;
26
- */
27
- SKIPPED = 3,
28
- /**
29
- * @generated from protobuf enum value: BROKEN = 4;
30
- */
31
- BROKEN = 4
32
- }
33
- declare class Attachment$Type extends MessageType<Attachment> {
34
- constructor();
35
- create(value?: PartialMessage<Attachment>): Attachment;
36
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Attachment): Attachment;
37
- internalBinaryWrite(message: Attachment, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
38
- }
39
- /**
40
- * Message for attachments
41
- *
42
- * @generated from protobuf message testsystem.common.Attachment
43
- */
44
- interface Attachment {
45
- /**
46
- * @generated from protobuf field: string name = 1
47
- */
48
- name: string;
49
- /**
50
- * @generated from protobuf field: string mime_type = 2
51
- */
52
- mimeType: string;
53
- /**
54
- * @generated from protobuf field: bytes content = 3
55
- */
56
- content: Uint8Array;
57
- }
58
- /**
59
- * @generated MessageType for protobuf message testsystem.common.Attachment
60
- */
61
- declare const Attachment: Attachment$Type;
62
-
63
- declare class Timestamp$Type extends MessageType<Timestamp> {
64
- constructor();
65
- /**
66
- * Creates a new `Timestamp` for the current time.
67
- */
68
- now(): Timestamp;
69
- /**
70
- * Converts a `Timestamp` to a JavaScript Date.
71
- */
72
- toDate(message: Timestamp): Date;
73
- /**
74
- * Converts a JavaScript Date to a `Timestamp`.
75
- */
76
- fromDate(date: Date): Timestamp;
77
- /**
78
- * In JSON format, the `Timestamp` type is encoded as a string
79
- * in the RFC 3339 format.
80
- */
81
- internalJsonWrite(message: Timestamp, options: JsonWriteOptions): JsonValue;
82
- /**
83
- * In JSON format, the `Timestamp` type is encoded as a string
84
- * in the RFC 3339 format.
85
- */
86
- internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Timestamp): Timestamp;
87
- create(value?: PartialMessage<Timestamp>): Timestamp;
88
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Timestamp): Timestamp;
89
- internalBinaryWrite(message: Timestamp, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
90
- }
91
- /**
92
- * A Timestamp represents a point in time independent of any time zone or local
93
- * calendar, encoded as a count of seconds and fractions of seconds at
94
- * nanosecond resolution. The count is relative to an epoch at UTC midnight on
95
- * January 1, 1970, in the proleptic Gregorian calendar which extends the
96
- * Gregorian calendar backwards to year one.
97
- *
98
- * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
99
- * second table is needed for interpretation, using a [24-hour linear
100
- * smear](https://developers.google.com/time/smear).
101
- *
102
- * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
103
- * restricting to that range, we ensure that we can convert to and from [RFC
104
- * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
105
- *
106
- * # Examples
107
- *
108
- * Example 1: Compute Timestamp from POSIX `time()`.
109
- *
110
- * Timestamp timestamp;
111
- * timestamp.set_seconds(time(NULL));
112
- * timestamp.set_nanos(0);
113
- *
114
- * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
115
- *
116
- * struct timeval tv;
117
- * gettimeofday(&tv, NULL);
118
- *
119
- * Timestamp timestamp;
120
- * timestamp.set_seconds(tv.tv_sec);
121
- * timestamp.set_nanos(tv.tv_usec * 1000);
122
- *
123
- * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
124
- *
125
- * FILETIME ft;
126
- * GetSystemTimeAsFileTime(&ft);
127
- * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
128
- *
129
- * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
130
- * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
131
- * Timestamp timestamp;
132
- * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
133
- * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
134
- *
135
- * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
136
- *
137
- * long millis = System.currentTimeMillis();
138
- *
139
- * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
140
- * .setNanos((int) ((millis % 1000) * 1000000)).build();
141
- *
142
- * Example 5: Compute Timestamp from Java `Instant.now()`.
143
- *
144
- * Instant now = Instant.now();
145
- *
146
- * Timestamp timestamp =
147
- * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
148
- * .setNanos(now.getNano()).build();
149
- *
150
- * Example 6: Compute Timestamp from current time in Python.
151
- *
152
- * timestamp = Timestamp()
153
- * timestamp.GetCurrentTime()
154
- *
155
- * # JSON Mapping
156
- *
157
- * In JSON format, the Timestamp type is encoded as a string in the
158
- * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
159
- * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
160
- * where {year} is always expressed using four digits while {month}, {day},
161
- * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
162
- * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
163
- * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
164
- * is required. A proto3 JSON serializer should always use UTC (as indicated by
165
- * "Z") when printing the Timestamp type and a proto3 JSON parser should be
166
- * able to accept both UTC and other timezones (as indicated by an offset).
167
- *
168
- * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
169
- * 01:30 UTC on January 15, 2017.
170
- *
171
- * In JavaScript, one can convert a Date object to this format using the
172
- * standard
173
- * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
174
- * method. In Python, a standard `datetime.datetime` object can be converted
175
- * to this format using
176
- * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
177
- * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
178
- * the Joda Time's [`ISODateTimeFormat.dateTime()`](
179
- * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
180
- * ) to obtain a formatter capable of generating timestamps in this format.
181
- *
182
- *
183
- * @generated from protobuf message google.protobuf.Timestamp
184
- */
185
- interface Timestamp {
186
- /**
187
- * Represents seconds of UTC time since Unix epoch
188
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
189
- * 9999-12-31T23:59:59Z inclusive.
190
- *
191
- * @generated from protobuf field: int64 seconds = 1
192
- */
193
- seconds: string;
194
- /**
195
- * Non-negative fractions of a second at nanosecond resolution. Negative
196
- * second values with fractions must still have non-negative nanos values
197
- * that count forward in time. Must be from 0 to 999,999,999
198
- * inclusive.
199
- *
200
- * @generated from protobuf field: int32 nanos = 2
201
- */
202
- nanos: number;
203
- }
204
- /**
205
- * @generated MessageType for protobuf message google.protobuf.Timestamp
206
- */
207
- declare const Timestamp: Timestamp$Type;
208
-
209
- declare class TestStartEvent$Type extends MessageType<TestStartEvent> {
210
- constructor();
211
- create(value?: PartialMessage<TestStartEvent>): TestStartEvent;
212
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestStartEvent): TestStartEvent;
213
- private binaryReadMap4;
214
- internalBinaryWrite(message: TestStartEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
215
- }
216
- /**
217
- * @generated from protobuf message testsystem.events.TestStartEvent
218
- */
219
- interface TestStartEvent {
220
- /**
221
- * @generated from protobuf field: string test_id = 1
222
- */
223
- testId: string;
224
- /**
225
- * @generated from protobuf field: string test_name = 2
226
- */
227
- testName: string;
228
- /**
229
- * @generated from protobuf field: google.protobuf.Timestamp start_time = 3
230
- */
231
- startTime?: Timestamp;
232
- /**
233
- * @generated from protobuf field: map<string, string> metadata = 4
234
- */
235
- metadata: {
236
- [key: string]: string;
237
- };
238
- }
239
- /**
240
- * @generated MessageType for protobuf message testsystem.events.TestStartEvent
241
- */
242
- declare const TestStartEvent: TestStartEvent$Type;
243
- declare class TestFinishEvent$Type extends MessageType<TestFinishEvent> {
244
- constructor();
245
- create(value?: PartialMessage<TestFinishEvent>): TestFinishEvent;
246
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestFinishEvent): TestFinishEvent;
247
- internalBinaryWrite(message: TestFinishEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
248
- }
249
- /**
250
- * @generated from protobuf message testsystem.events.TestFinishEvent
251
- */
252
- interface TestFinishEvent {
253
- /**
254
- * @generated from protobuf field: string test_id = 1
255
- */
256
- testId: string;
257
- /**
258
- * @generated from protobuf field: testsystem.common.TestStatus status = 2
259
- */
260
- status: TestStatus;
261
- /**
262
- * @generated from protobuf field: google.protobuf.Timestamp end_time = 3
263
- */
264
- endTime?: Timestamp;
265
- /**
266
- * @generated from protobuf field: repeated testsystem.common.Attachment attachments = 4
267
- */
268
- attachments: Attachment[];
269
- /**
270
- * @generated from protobuf field: string error_message = 5
271
- */
272
- errorMessage: string;
273
- /**
274
- * @generated from protobuf field: string stack_trace = 6
275
- */
276
- stackTrace: string;
277
- }
278
- /**
279
- * @generated MessageType for protobuf message testsystem.events.TestFinishEvent
280
- */
281
- declare const TestFinishEvent: TestFinishEvent$Type;
282
- declare class TestStep$Type extends MessageType<TestStep> {
283
- constructor();
284
- create(value?: PartialMessage<TestStep>): TestStep;
285
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestStep): TestStep;
286
- internalBinaryWrite(message: TestStep, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
287
- }
288
- /**
289
- * @generated from protobuf message testsystem.events.TestStep
290
- */
291
- interface TestStep {
292
- /**
293
- * @generated from protobuf field: string description = 1
294
- */
295
- description: string;
296
- /**
297
- * @generated from protobuf field: google.protobuf.Timestamp timestamp = 2
298
- */
299
- timestamp?: Timestamp;
300
- /**
301
- * @generated from protobuf field: testsystem.common.TestStatus status = 3
302
- */
303
- status: TestStatus;
304
- /**
305
- * @generated from protobuf field: repeated testsystem.common.Attachment attachments = 4
306
- */
307
- attachments: Attachment[];
308
- }
309
- /**
310
- * @generated MessageType for protobuf message testsystem.events.TestStep
311
- */
312
- declare const TestStep: TestStep$Type;
313
- declare class TestStepEvent$Type extends MessageType<TestStepEvent> {
314
- constructor();
315
- create(value?: PartialMessage<TestStepEvent>): TestStepEvent;
316
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestStepEvent): TestStepEvent;
317
- internalBinaryWrite(message: TestStepEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
318
- }
319
- /**
320
- * @generated from protobuf message testsystem.events.TestStepEvent
321
- */
322
- interface TestStepEvent {
323
- /**
324
- * @generated from protobuf field: string test_id = 1
325
- */
326
- testId: string;
327
- /**
328
- * @generated from protobuf field: repeated testsystem.events.TestStep steps = 2
329
- */
330
- steps: TestStep[];
331
- }
332
- /**
333
- * @generated MessageType for protobuf message testsystem.events.TestStepEvent
334
- */
335
- declare const TestStepEvent: TestStepEvent$Type;
336
-
337
- declare class Ack$Type extends MessageType<Ack> {
338
- constructor();
339
- create(value?: PartialMessage<Ack>): Ack;
340
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Ack): Ack;
341
- internalBinaryWrite(message: Ack, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
342
- }
343
- /**
344
- * @generated from protobuf message testsystem.observer.Ack
345
- */
346
- interface Ack {
347
- /**
348
- * @generated from protobuf field: bool success = 1
349
- */
350
- success: boolean;
351
- /**
352
- * @generated from protobuf field: string message = 2
353
- */
354
- message: string;
355
- }
356
- /**
357
- * @generated MessageType for protobuf message testsystem.observer.Ack
358
- */
359
- declare const Ack: Ack$Type;
360
- /**
361
- * @generated ServiceType for protobuf service testsystem.observer.TestEventCollector
362
- */
363
- declare const TestEventCollector: ServiceType;
364
-
365
- /**
366
- * @generated from protobuf service testsystem.observer.TestEventCollector
367
- */
368
- interface ITestEventCollectorClient {
369
- /**
370
- * @generated from protobuf rpc: ReportTestStart
371
- */
372
- reportTestStart(input: TestStartEvent, options?: RpcOptions): UnaryCall<TestStartEvent, Ack>;
373
- /**
374
- * @generated from protobuf rpc: ReportTestFinish
375
- */
376
- reportTestFinish(input: TestFinishEvent, options?: RpcOptions): UnaryCall<TestFinishEvent, Ack>;
377
- /**
378
- * @generated from protobuf rpc: ReportTestStep
379
- */
380
- reportTestStep(input: TestStepEvent, options?: RpcOptions): UnaryCall<TestStepEvent, Ack>;
381
- }
382
- /**
383
- * @generated from protobuf service testsystem.observer.TestEventCollector
384
- */
385
- declare class TestEventCollectorClient implements ITestEventCollectorClient, ServiceInfo {
386
- private readonly _transport;
387
- typeName: string;
388
- methods: _protobuf_ts_runtime_rpc.MethodInfo<any, any>[];
389
- options: {
390
- [extensionName: string]: _protobuf_ts_runtime.JsonValue;
391
- };
392
- constructor(_transport: RpcTransport);
393
- /**
394
- * @generated from protobuf rpc: ReportTestStart
395
- */
396
- reportTestStart(input: TestStartEvent, options?: RpcOptions): UnaryCall<TestStartEvent, Ack>;
397
- /**
398
- * @generated from protobuf rpc: ReportTestFinish
399
- */
400
- reportTestFinish(input: TestFinishEvent, options?: RpcOptions): UnaryCall<TestFinishEvent, Ack>;
401
- /**
402
- * @generated from protobuf rpc: ReportTestStep
403
- */
404
- reportTestStep(input: TestStepEvent, options?: RpcOptions): UnaryCall<TestStepEvent, Ack>;
405
- }
406
-
407
- export { Ack, Attachment, type ITestEventCollectorClient, TestEventCollector, TestEventCollectorClient, TestFinishEvent, TestStartEvent, TestStatus, TestStep, TestStepEvent };
1
+ export * from "./lib";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}