@getuserfeedback/protocol 0.2.1 → 0.2.2
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/dist/host/command-dispatch.d.ts.map +1 -1
- package/dist/host/command-dispatch.js +5 -9
- package/dist/host/command-envelope.d.ts +10 -0
- package/dist/host/command-envelope.d.ts.map +1 -0
- package/dist/host/command-envelope.js +21 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-dispatch.d.ts","sourceRoot":"","sources":["../../src/host/command-dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,SAAS,MAAM,CAAC,GAC5D,CAAC,SAAS,oBAAoB,GAC7B,CAAC,GACD,KAAK,GACN,KAAK,CAAC;AAET,KAAK,eAAe,GAAG;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,KACvC,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"command-dispatch.d.ts","sourceRoot":"","sources":["../../src/host/command-dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,SAAS,MAAM,CAAC,GAC5D,CAAC,SAAS,oBAAoB,GAC7B,CAAC,GACD,KAAK,GACN,KAAK,CAAC;AAET,KAAK,eAAe,GAAG;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,KACvC,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAapE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { createCommandEnvelope } from "./command-envelope.js";
|
|
1
2
|
import { waitForCommandSettlement } from "./command-settlement.js";
|
|
2
|
-
import { createCommandRequestId } from "./request-id.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a dispatch function that wraps a command payload in an envelope,
|
|
5
5
|
* pushes it into the queue, and returns a promise that settles when the
|
|
@@ -15,16 +15,12 @@ import { createCommandRequestId } from "./request-id.js";
|
|
|
15
15
|
*/
|
|
16
16
|
export const createCommandDispatch = (push) => {
|
|
17
17
|
return async (input, options) => {
|
|
18
|
-
const
|
|
19
|
-
const idempotencyKey = resolveIdempotencyKey(options?.idempotencyKey);
|
|
20
|
-
const envelope = {
|
|
21
|
-
version: "1",
|
|
22
|
-
requestId,
|
|
23
|
-
idempotencyKey: idempotencyKey ?? requestId,
|
|
18
|
+
const envelope = createCommandEnvelope({
|
|
24
19
|
command: input,
|
|
25
|
-
|
|
20
|
+
idempotencyKey: resolveIdempotencyKey(options?.idempotencyKey) ?? undefined,
|
|
21
|
+
});
|
|
26
22
|
push(envelope);
|
|
27
|
-
await waitForCommandSettlement({ requestId });
|
|
23
|
+
await waitForCommandSettlement({ requestId: envelope.requestId });
|
|
28
24
|
};
|
|
29
25
|
};
|
|
30
26
|
const resolveIdempotencyKey = (value) => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClientMeta, CommandEnvelope, PublicCommandPayload } from "./sdk-types.js";
|
|
2
|
+
export type CreateCommandEnvelopeInput = {
|
|
3
|
+
command: PublicCommandPayload;
|
|
4
|
+
requestId?: string | undefined;
|
|
5
|
+
idempotencyKey?: string | undefined;
|
|
6
|
+
instanceId?: string | undefined;
|
|
7
|
+
clientMeta?: ClientMeta | undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const createCommandEnvelope: (input: CreateCommandEnvelopeInput) => CommandEnvelope;
|
|
10
|
+
//# sourceMappingURL=command-envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-envelope.d.ts","sourceRoot":"","sources":["../../src/host/command-envelope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,0BAA0B,GAAG;IACxC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACpC,CAAC;AAUF,eAAO,MAAM,qBAAqB,GACjC,OAAO,0BAA0B,KAC/B,eAeF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createCommandRequestId } from "./request-id.js";
|
|
2
|
+
const normalizeOptionalString = (value) => {
|
|
3
|
+
if (value === undefined) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
const normalized = value.trim();
|
|
7
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
8
|
+
};
|
|
9
|
+
export const createCommandEnvelope = (input) => {
|
|
10
|
+
const requestId = normalizeOptionalString(input.requestId) ?? createCommandRequestId();
|
|
11
|
+
const idempotencyKey = normalizeOptionalString(input.idempotencyKey) ?? requestId;
|
|
12
|
+
const instanceId = normalizeOptionalString(input.instanceId);
|
|
13
|
+
return {
|
|
14
|
+
version: "1",
|
|
15
|
+
command: input.command,
|
|
16
|
+
requestId,
|
|
17
|
+
idempotencyKey,
|
|
18
|
+
...(instanceId !== undefined ? { instanceId } : {}),
|
|
19
|
+
...(input.clientMeta !== undefined ? { clientMeta: input.clientMeta } : {}),
|
|
20
|
+
};
|
|
21
|
+
};
|
package/dist/host/index.d.ts
CHANGED
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/host/index.js
CHANGED