Skip to content

Commit f743d02

Browse files
authoredJul 24, 2023
fix: add ./constants exports to separate client from core backend (#398)
1 parent 0dde2ff commit f743d02

File tree

10 files changed

+36
-23
lines changed

10 files changed

+36
-23
lines changed
 

‎packages/@eventual/client/src/base-http-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commandRpcPath, HttpMethod } from "@eventual/core";
1+
import { commandRpcPath, HttpMethod } from "@eventual/core/constants";
22
import { getRequestHandler } from "./request-handler/factory.js";
33
import {
44
BeforeRequest,

‎packages/@eventual/core/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.d.ts
33
node_modules
44
lib
5-
!internal/*
5+
!internal/*
6+
!constants/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Alias to the internal module for CJS imports.
3+
*/
4+
export * from "../lib/cjs/constants.js";

‎packages/@eventual/core/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"./internal": {
1010
"import": "./lib/esm/internal/index.js",
1111
"require": "./lib/cjs/internal/index.js"
12+
},
13+
"./constants": {
14+
"import": "./lib/esm/constants.js",
15+
"require": "./lib/cjs/constants.js"
1216
}
1317
},
1418
"main": "./lib/cjs/index.js",
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./http/command-rpc-path.js";
2+
export type * from "./http-method.js";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { AnyCommand } from "./command.js";
2+
3+
export function isDefaultNamespaceCommand<
4+
C extends Pick<AnyCommand, "name" | "namespace">
5+
>(command: C): command is C & { namespace: undefined } {
6+
return !command.namespace;
7+
}
8+
9+
/**
10+
* Formats the RPC Rest path for a command.
11+
*
12+
* rpc[/namespace]/name
13+
*/
14+
export function commandRpcPath(
15+
command: Pick<AnyCommand, "name" | "namespace">
16+
) {
17+
return `rpc${
18+
isDefaultNamespaceCommand(command) ? "" : `/${command.namespace}`
19+
}${command.name.startsWith("/") ? "" : "/"}${command.name}`;
20+
}

‎packages/@eventual/core/src/http/command.ts

-19
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@ import type { ServiceContext } from "../service.js";
77
import type { Middleware } from "./middleware.js";
88
import type { ParsePath } from "./path.js";
99

10-
export function isDefaultNamespaceCommand<
11-
C extends Pick<AnyCommand, "name" | "namespace">
12-
>(command: C): command is C & { namespace: undefined } {
13-
return !command.namespace;
14-
}
15-
16-
/**
17-
* Formats the RPC Rest path for a command.
18-
*
19-
* rpc[/namespace]/name
20-
*/
21-
export function commandRpcPath(
22-
command: Pick<AnyCommand, "name" | "namespace">
23-
) {
24-
return `rpc${
25-
isDefaultNamespaceCommand(command) ? "" : `/${command.namespace}`
26-
}${command.name.startsWith("/") ? "" : "/"}${command.name}`;
27-
}
28-
2910
export interface CommandContext {
3011
service: ServiceContext;
3112
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from "./api.js";
22
export * from "./command.js";
3+
export * from "./command-rpc-path.js";
34
export * from "./error.js";
45
export * from "./middleware.js";
56
export * from "./request-response.js";

‎packages/@eventual/core/src/internal/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function getEventualResource<Kind extends ResourceKind>(
7474
export function getEventualResources<Kind extends ResourceKind>(
7575
resourceKind: Kind
7676
): Map<string, ResourceOfKind<Kind>> {
77-
return globalThis._eventual.resources[resourceKind] ?? new Map();
77+
return (globalThis._eventual.resources[resourceKind] ??= new Map());
7878
}
7979

8080
/**

‎packages/@eventual/core/src/internal/open-api-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type openapi from "openapi3-ts";
2-
import { commandRpcPath } from "../http/command.js";
2+
import { commandRpcPath } from "../http/command-rpc-path.js";
33
import type { CommandSpec } from "./service-spec.js";
44

55
export interface OpenAPISpecOptions {

0 commit comments

Comments
 (0)
Please sign in to comment.