Skip to content

Commit 78f1b43

Browse files
committed
jsr dependencies
1 parent 08cb827 commit 78f1b43

File tree

7 files changed

+89
-37
lines changed

7 files changed

+89
-37
lines changed

service/deno.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@nats-io/services",
3+
"version": "3.0.0-1",
4+
"exports": {
5+
".": "./mod.ts",
6+
"./internal": "./internal_mod.ts"
7+
},
8+
"publish": {
9+
"include": [
10+
"./**/*"
11+
],
12+
"exclude": [
13+
"./**/tests"
14+
]
15+
},
16+
"imports": {
17+
"jsr:@nats-io/nats-core": "jsr:@nats-io/[email protected]"
18+
}
19+
}

service/internal_mod.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {
1+
import type {
22
NatsConnection,
33
RequestManyOptions,
4-
} from "../nats-base-client/core.ts";
4+
} from "jsr:@nats-io/nats-core@3.0.0-14";
55
import { ServiceImpl } from "./service.ts";
66
import { ServiceClientImpl } from "./serviceclient.ts";
7-
import { Service, ServiceClient, ServiceConfig } from "./types.ts";
7+
import type { Service, ServiceClient, ServiceConfig } from "./types.ts";
88

99
export type {
1010
Endpoint,

service/service.ts

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
1414
*/
15-
import { deferred, nanos } from "../nats-base-client/util.ts";
16-
import type { Deferred } from "../nats-base-client/util.ts";
17-
import { headers } from "../nats-base-client/headers.ts";
18-
import { JSONCodec } from "../nats-base-client/codec.ts";
19-
import { nuid } from "../nats-base-client/nuid.ts";
20-
import { QueuedIteratorImpl } from "../nats-base-client/queued_iterator.ts";
21-
import { validateName } from "../jetstream/jsutil.ts";
22-
import { parseSemVer } from "../nats-base-client/semver.ts";
23-
import { Empty } from "../nats-base-client/encoders.ts";
2415
import {
16+
deferred,
17+
Empty,
18+
headers,
19+
JSONCodec,
20+
nanos,
21+
nuid,
22+
parseSemVer,
23+
QueuedIteratorImpl,
24+
} from "jsr:@nats-io/[email protected]/internal";
25+
import type {
26+
Deferred,
2527
Msg,
2628
MsgHdrs,
2729
Nanos,
@@ -32,27 +34,58 @@ import {
3234
QueuedIterator,
3335
ReviverFn,
3436
Sub,
35-
} from "../nats-base-client/core.ts";
37+
} from "jsr:@nats-io/[email protected]/internal";
38+
3639
import {
40+
ServiceError,
41+
ServiceErrorCodeHeader,
42+
ServiceErrorHeader,
43+
ServiceResponseType,
44+
ServiceVerb,
45+
} from "./types.ts";
46+
47+
import type {
3748
Endpoint,
3849
EndpointInfo,
3950
EndpointOptions,
4051
NamedEndpointStats,
4152
Service,
4253
ServiceConfig,
43-
ServiceError,
44-
ServiceErrorCodeHeader,
45-
ServiceErrorHeader,
4654
ServiceGroup,
4755
ServiceHandler,
4856
ServiceIdentity,
4957
ServiceInfo,
5058
ServiceMsg,
51-
ServiceResponseType,
5259
ServiceStats,
53-
ServiceVerb,
5460
} from "./types.ts";
5561

62+
function validateName(context: string, name = "") {
63+
if (name === "") {
64+
throw Error(`${context} name required`);
65+
}
66+
const m = validName(name);
67+
if (m.length) {
68+
throw new Error(`invalid ${context} name - ${context} name ${m}`);
69+
}
70+
}
71+
72+
function validName(name = ""): string {
73+
if (name === "") {
74+
throw Error(`name required`);
75+
}
76+
const RE = /^[-\w]+$/g;
77+
const m = name.match(RE);
78+
if (m === null) {
79+
for (const c of name.split("")) {
80+
const mm = c.match(RE);
81+
if (mm === null) {
82+
return `cannot contain '${c}'`;
83+
}
84+
}
85+
}
86+
return "";
87+
}
88+
5689
/**
5790
* Services have common backplane subject pattern:
5891
*

service/serviceclient.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
1414
*/
15-
import { Empty } from "../nats-base-client/encoders.ts";
16-
import { JSONCodec } from "../nats-base-client/codec.ts";
17-
import { QueuedIteratorImpl } from "../nats-base-client/queued_iterator.ts";
18-
import { RequestStrategy } from "../nats-base-client/core.ts";
15+
import {
16+
Empty,
17+
JSONCodec,
18+
QueuedIteratorImpl,
19+
RequestStrategy,
20+
} from "jsr:@nats-io/[email protected]/internal";
1921

2022
import type {
2123
NatsConnection,
2224
QueuedIterator,
2325
RequestManyOptions,
24-
} from "../nats-base-client/mod.ts";
26+
} from "jsr:@nats-io/nats-[email protected]/internal";
2527

2628
import { ServiceImpl } from "./service.ts";
27-
2829
import { ServiceVerb } from "./types.ts";
2930

3031
import type {

service/tests/service-check.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@
1414
*/
1515

1616
import { cli } from "https://deno.land/x/[email protected]/mod.ts";
17-
import { connect, StringCodec } from "../../src/mod.ts";
18-
import type { NatsConnection } from "../../src/mod.ts";
17+
import { connect, StringCodec } from "jsr:@nats-io/[email protected]";
18+
import type { NatsConnection } from "jsr:@nats-io/[email protected]";
19+
import { collect, parseSemVer } from "jsr:@nats-io/[email protected]/internal";
1920

2021
import type { ServiceIdentity, ServiceInfo, ServiceStats } from "../mod.ts";
21-
2222
import { ServiceError, ServiceResponseType, ServiceVerb, Svc } from "../mod.ts";
2323

24-
import { collect } from "../../nats-base-client/util.ts";
25-
import { ServiceClientImpl } from "../serviceclient.ts";
24+
import type { ServiceClientImpl } from "../serviceclient.ts";
2625
import Ajv from "npm:ajv";
2726
import type { JSONSchemaType, ValidateFunction } from "npm:ajv";
2827

29-
import { parseSemVer } from "../../nats-base-client/semver.ts";
30-
3128
const ajv = new Ajv();
3229

3330
const root = cli({

service/tests/service_test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
1414
*/
15-
import { cleanup, setup } from "../../tests/helpers/mod.ts";
15+
import { cleanup, setup } from "../../src/tests/helpers/mod.ts";
1616
import { ServiceImpl } from "../service.ts";
1717
import {
1818
assert,
@@ -22,10 +22,13 @@ import {
2222
assertRejects,
2323
assertThrows,
2424
fail,
25-
} from "https://deno.land/[email protected]/assert/mod.ts";
25+
} from "jsr:@std/assert";
2626

27-
import { collect, delay } from "../../nats-base-client/util.ts";
28-
import { NatsConnectionImpl } from "../../nats-base-client/nats.ts";
27+
import { collect, delay } from "jsr:@nats-io/[email protected]/internal";
28+
import type {
29+
NatsConnectionImpl,
30+
SubscriptionImpl,
31+
} from "jsr:@nats-io/[email protected]/internal";
2932
import type {
3033
EndpointInfo,
3134
Service,
@@ -57,7 +60,6 @@ import type {
5760
NatsError,
5861
QueuedIterator,
5962
} from "../../src/mod.ts";
60-
import { SubscriptionImpl } from "../../nats-base-client/protocol.ts";
6163

6264
Deno.test("service - control subject", () => {
6365
const test = (verb: ServiceVerb) => {

service/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
NatsError,
55
PublishOptions,
66
QueuedIterator,
7-
} from "../nats-base-client/core.ts";
7+
} from "jsr:@nats-io/nats-core@3.0.0-14";
88

99
export interface ServiceMsg extends Msg {
1010
respondError(

0 commit comments

Comments
 (0)