@amqp-contract/contract 0.23.1 → 0.25.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.
- package/README.md +3 -3
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +189 -189
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/btravers/amqp-contract/actions/workflows/ci.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/@amqp-contract/contract)
|
|
7
7
|
[](https://www.npmjs.com/package/@amqp-contract/contract)
|
|
8
|
-
[](https://www.typescriptlang.org/)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
|
|
11
11
|
📖 **[Full documentation →](https://btravers.github.io/amqp-contract/api/contract)**
|
|
@@ -99,10 +99,10 @@ const contract = defineContract({
|
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// Server handler returns the response value, not void:
|
|
102
|
-
// handlers: { calculate: ({ payload }) =>
|
|
102
|
+
// handlers: { calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }) }
|
|
103
103
|
//
|
|
104
104
|
// Client invokes with a required timeout:
|
|
105
|
-
// const result = await client.call("calculate", { a: 1, b: 2 }, { timeoutMs: 5_000 })
|
|
105
|
+
// const result = await client.call("calculate", { a: 1, b: 2 }, { timeoutMs: 5_000 });
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
**Benefits:**
|
package/dist/index.cjs
CHANGED
|
@@ -886,10 +886,10 @@ function defineContract(definition) {
|
|
|
886
886
|
* const contract = defineContract({ rpcs: { calculate } });
|
|
887
887
|
*
|
|
888
888
|
* // Server (worker): handler returns the typed response
|
|
889
|
-
* // handlers: { calculate: ({ payload }) =>
|
|
889
|
+
* // handlers: { calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }) }
|
|
890
890
|
*
|
|
891
891
|
* // Client: typed call with required timeout
|
|
892
|
-
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 })
|
|
892
|
+
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 });
|
|
893
893
|
* ```
|
|
894
894
|
*/
|
|
895
895
|
function defineRpc(queue, messages) {
|
package/dist/index.d.cts
CHANGED
|
@@ -2630,10 +2630,10 @@ declare function isBridgedPublisherConfig(value: unknown): value is BridgedPubli
|
|
|
2630
2630
|
* const contract = defineContract({ rpcs: { calculate } });
|
|
2631
2631
|
*
|
|
2632
2632
|
* // Server (worker): handler returns the typed response
|
|
2633
|
-
* // handlers: { calculate: ({ payload }) =>
|
|
2633
|
+
* // handlers: { calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }) }
|
|
2634
2634
|
*
|
|
2635
2635
|
* // Client: typed call with required timeout
|
|
2636
|
-
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 })
|
|
2636
|
+
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 });
|
|
2637
2637
|
* ```
|
|
2638
2638
|
*/
|
|
2639
2639
|
declare function defineRpc<TRequestMessage extends MessageDefinition, TResponseMessage extends MessageDefinition, TQueue extends QueueEntry>(queue: TQueue, messages: {
|
package/dist/index.d.mts
CHANGED
|
@@ -2630,10 +2630,10 @@ declare function isBridgedPublisherConfig(value: unknown): value is BridgedPubli
|
|
|
2630
2630
|
* const contract = defineContract({ rpcs: { calculate } });
|
|
2631
2631
|
*
|
|
2632
2632
|
* // Server (worker): handler returns the typed response
|
|
2633
|
-
* // handlers: { calculate: ({ payload }) =>
|
|
2633
|
+
* // handlers: { calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }) }
|
|
2634
2634
|
*
|
|
2635
2635
|
* // Client: typed call with required timeout
|
|
2636
|
-
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 })
|
|
2636
|
+
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 });
|
|
2637
2637
|
* ```
|
|
2638
2638
|
*/
|
|
2639
2639
|
declare function defineRpc<TRequestMessage extends MessageDefinition, TResponseMessage extends MessageDefinition, TQueue extends QueueEntry>(queue: TQueue, messages: {
|
package/dist/index.mjs
CHANGED
|
@@ -885,10 +885,10 @@ function defineContract(definition) {
|
|
|
885
885
|
* const contract = defineContract({ rpcs: { calculate } });
|
|
886
886
|
*
|
|
887
887
|
* // Server (worker): handler returns the typed response
|
|
888
|
-
* // handlers: { calculate: ({ payload }) =>
|
|
888
|
+
* // handlers: { calculate: ({ payload }) => okAsync({ sum: payload.a + payload.b }) }
|
|
889
889
|
*
|
|
890
890
|
* // Client: typed call with required timeout
|
|
891
|
-
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 })
|
|
891
|
+
* // const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 });
|
|
892
892
|
* ```
|
|
893
893
|
*/
|
|
894
894
|
function defineRpc(queue, messages) {
|