@distilled.cloud/temporal 1.0.0-rc.13 → 1.0.0-rc.15
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/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +3 -3
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -6
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/temporal.d.ts +1 -1
- package/lib/services/temporal.d.ts.map +1 -1
- package/lib/services/temporal.js +247 -681
- package/lib/services/temporal.js.map +1 -1
- package/package.json +12 -10
- package/src/credentials.ts +7 -8
- package/src/errors.ts +1 -1
- package/src/index.ts +1 -5
- package/src/protocol.ts +25 -31
- package/src/retry.ts +2 -8
- package/src/services/temporal.ts +1698 -2511
- package/lib/response-validation.test.d.ts +0 -6
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -33
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -49
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/temporal",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.15",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/alchemy-run/distilled",
|
|
7
8
|
"directory": "packages/temporal"
|
|
8
9
|
},
|
|
9
|
-
"license": "Apache-2.0",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"sideEffects": false,
|
|
12
10
|
"files": [
|
|
13
11
|
"lib",
|
|
14
12
|
"src"
|
|
15
13
|
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./lib/index.d.ts",
|
|
@@ -64,20 +64,22 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
67
|
+
"@distilled.cloud/core": "1.0.0-rc.15"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/node": "26.2.0",
|
|
72
|
-
"@effect/platform-bun": "^4.0.0"
|
|
70
|
+
"@types/node": "26.2.0"
|
|
73
71
|
},
|
|
74
72
|
"peerDependencies": {
|
|
75
73
|
"effect": "^4.0.0"
|
|
76
74
|
},
|
|
75
|
+
"distilled": {
|
|
76
|
+
"generatedAt": "2026-10-06",
|
|
77
|
+
"specUpdatedAt": "2026-10-06"
|
|
78
|
+
},
|
|
77
79
|
"scripts": {
|
|
78
80
|
"build": "tsc -b",
|
|
79
|
-
"convert": "bun scripts/convert.ts",
|
|
80
|
-
"generate": "bun scripts/convert.ts && bun scripts/generate.ts",
|
|
81
|
+
"convert": "node --conditions=bun scripts/convert.ts",
|
|
82
|
+
"generate": "node --conditions=bun scripts/convert.ts && node --conditions=bun scripts/generate.ts",
|
|
81
83
|
"typecheck": "tsc -p tsconfig.json",
|
|
82
84
|
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-temporal",
|
|
83
85
|
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-temporal"
|
package/src/credentials.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
1
2
|
/**
|
|
2
3
|
* Temporal credentials — hand-written.
|
|
3
4
|
*
|
|
@@ -15,7 +16,6 @@ import * as Context from "effect/Context";
|
|
|
15
16
|
import * as Effect from "effect/Effect";
|
|
16
17
|
import * as Layer from "effect/Layer";
|
|
17
18
|
import * as Redacted from "effect/Redacted";
|
|
18
|
-
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
19
19
|
|
|
20
20
|
/** Default Temporal frontend HTTP listen address (`grpcPort + 10`). */
|
|
21
21
|
export const DEFAULT_API_BASE_URL = "http://localhost:7243";
|
|
@@ -25,20 +25,19 @@ export interface Config {
|
|
|
25
25
|
readonly apiBaseUrl: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export class Credentials extends Context.Service<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
>()("TemporalCredentials") {}
|
|
28
|
+
export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
29
|
+
"TemporalCredentials",
|
|
30
|
+
) {}
|
|
32
31
|
|
|
33
|
-
/** Layer from a
|
|
32
|
+
/** Layer from a redacted API key + optional base URL. */
|
|
34
33
|
export const fromApiKey = (config: {
|
|
35
|
-
readonly apiKey: string
|
|
34
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
36
35
|
readonly apiBaseUrl?: string;
|
|
37
36
|
}): Layer.Layer<Credentials> =>
|
|
38
37
|
Layer.succeed(
|
|
39
38
|
Credentials,
|
|
40
39
|
Effect.succeed({
|
|
41
|
-
apiKey:
|
|
40
|
+
apiKey: config.apiKey,
|
|
42
41
|
apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
43
42
|
}),
|
|
44
43
|
);
|
package/src/errors.ts
CHANGED
|
@@ -27,8 +27,8 @@ export {
|
|
|
27
27
|
} from "@distilled.cloud/core/errors";
|
|
28
28
|
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
29
29
|
|
|
30
|
-
import * as Schema from "effect/Schema";
|
|
31
30
|
import * as Category from "@distilled.cloud/core/category";
|
|
31
|
+
import * as Schema from "effect/Schema";
|
|
32
32
|
|
|
33
33
|
/** Unknown Temporal error — returned when nothing else matches the failure. */
|
|
34
34
|
export class UnknownTemporalError extends Schema.TaggedError<UnknownTemporalError>()(
|
package/src/index.ts
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
export * from "./credentials.ts";
|
|
16
16
|
export * from "./errors.ts";
|
|
17
17
|
export * as T from "./traits.ts";
|
|
18
|
-
export {
|
|
19
|
-
TemporalProtocol,
|
|
20
|
-
type TemporalOpError,
|
|
21
|
-
type TemporalOpContext,
|
|
22
|
-
} from "./protocol.ts";
|
|
18
|
+
export { TemporalProtocol, type TemporalOpError, type TemporalOpContext } from "./protocol.ts";
|
|
23
19
|
export { paginateCursor } from "./pagination.ts";
|
|
24
20
|
export * as Retry from "./retry.ts";
|
|
25
21
|
export * as Services from "./services/index.ts";
|
package/src/protocol.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
2
|
+
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
3
|
+
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
1
4
|
/**
|
|
2
5
|
* TemporalProtocol — hand-written.
|
|
3
6
|
*
|
|
@@ -16,13 +19,10 @@
|
|
|
16
19
|
* HTTP-status classes, then {@link UnknownTemporalError}.
|
|
17
20
|
*/
|
|
18
21
|
import * as Effect from "effect/Effect";
|
|
19
|
-
import type * as Layer from "effect/Layer";
|
|
20
|
-
import * as Redacted from "effect/Redacted";
|
|
21
22
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
22
23
|
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
23
|
-
import type * as
|
|
24
|
-
import
|
|
25
|
-
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
24
|
+
import type * as Layer from "effect/Layer";
|
|
25
|
+
import * as Redacted from "effect/Redacted";
|
|
26
26
|
import { Credentials, type Config } from "./credentials.ts";
|
|
27
27
|
import { UnknownTemporalError, TemporalParseError } from "./errors.ts";
|
|
28
28
|
|
|
@@ -42,30 +42,24 @@ export type TemporalOpError =
|
|
|
42
42
|
/** Context (requirements) shared by every generated Temporal operation. */
|
|
43
43
|
export type TemporalOpContext = Credentials | HttpClient.HttpClient;
|
|
44
44
|
|
|
45
|
-
export const TemporalProtocol: Layer.Layer<API.Protocol> =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
export const TemporalProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
|
|
46
|
+
// The Credentials service holds an effect — resolving it here (per
|
|
47
|
+
// request, on the calling fiber) picks up context-provided credentials.
|
|
48
|
+
credentials: Effect.gen(function* () {
|
|
49
|
+
const resolve = yield* Credentials;
|
|
50
|
+
return yield* resolve;
|
|
51
|
+
}),
|
|
52
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
53
|
+
headers: (creds) => ({
|
|
54
|
+
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
55
|
+
}),
|
|
56
|
+
// Temporal's google.rpc.Status error body is `{ code?, message, details? }`
|
|
57
|
+
// — the factory's default lenient envelope covers it.
|
|
58
|
+
unknownError: ({ code, message, body }) =>
|
|
59
|
+
new UnknownTemporalError({
|
|
60
|
+
code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
|
|
61
|
+
message,
|
|
62
|
+
body,
|
|
56
63
|
}),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
unknownError: ({ code, message, body }) =>
|
|
60
|
-
new UnknownTemporalError({
|
|
61
|
-
code:
|
|
62
|
-
typeof code === "string"
|
|
63
|
-
? code
|
|
64
|
-
: code !== undefined
|
|
65
|
-
? String(code)
|
|
66
|
-
: undefined,
|
|
67
|
-
message,
|
|
68
|
-
body,
|
|
69
|
-
}),
|
|
70
|
-
parseError: ({ body, cause }) => new TemporalParseError({ body, cause }),
|
|
71
|
-
});
|
|
64
|
+
parseError: ({ body, cause }) => new TemporalParseError({ body, cause }),
|
|
65
|
+
});
|
package/src/retry.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Policy, throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
|
|
1
2
|
/**
|
|
2
3
|
* Temporal retry configuration.
|
|
3
4
|
*
|
|
@@ -16,11 +17,6 @@
|
|
|
16
17
|
import * as Context from "effect/Context";
|
|
17
18
|
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Layer from "effect/Layer";
|
|
19
|
-
import {
|
|
20
|
-
type Policy,
|
|
21
|
-
throttlingFactory,
|
|
22
|
-
transientFactory,
|
|
23
|
-
} from "@distilled.cloud/core/retry";
|
|
24
20
|
|
|
25
21
|
export {
|
|
26
22
|
type Options,
|
|
@@ -43,9 +39,7 @@ export const policy = (optionsOrFactory: Policy) =>
|
|
|
43
39
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
44
40
|
|
|
45
41
|
/** Disables all automatic retries. */
|
|
46
|
-
export const none = Effect.provide(
|
|
47
|
-
Layer.succeed(Retry, { while: () => false }),
|
|
48
|
-
);
|
|
42
|
+
export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
|
|
49
43
|
|
|
50
44
|
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
51
45
|
export const throttling = policy(throttlingFactory);
|