@justscale/core 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +19 -38
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -4,7 +4,7 @@ The foundation every JustScale app sits on. `@justscale/core` is the DI containe
4
4
 
5
5
  The distinguishing idea: **composition is validated at compile time.** A missing dependency is a type error, not a runtime crash. You get that by describing services, controllers, and features as values with typed dependency tokens and letting `build()` check the graph.
6
6
 
7
- Full docs: [justscale.sh](https://justscale.sh) — start at [overview/philosophy](https://justscale.sh/overview/philosophy).
7
+ Full docs: [justscale.sh](https://justscale.sh) — start at [overview/philosophy](https://justscale.sh/docs/overview/philosophy).
8
8
 
9
9
  ## Install
10
10
 
@@ -47,7 +47,7 @@ Real apps usually declare per-environment config through `createEnvironment` + a
47
47
 
48
48
  ## Primitives
49
49
 
50
- ### Services — [justscale.sh/fundamentals/services](https://justscale.sh/fundamentals/services)
50
+ ### Services — [justscale.sh/docs/fundamentals/services](https://justscale.sh/docs/fundamentals/services)
51
51
 
52
52
  ```ts
53
53
  class UserService extends defineService({
@@ -63,7 +63,7 @@ class UserService extends defineService({
63
63
 
64
64
  Abstract tokens (`defineAbstract`) let services declare "I need _something_ that implements this interface" without naming a concrete class. Bind a concrete implementation at compose time with `bindService(AbstractToken, ConcreteService)`. Same pattern for repositories via `bindRepository(ModelRepository.of(User), UserRepository)`.
65
65
 
66
- ### Controllers — [justscale.sh/fundamentals/controllers](https://justscale.sh/fundamentals/controllers)
66
+ ### Controllers — [justscale.sh/docs/fundamentals/controllers](https://justscale.sh/docs/fundamentals/controllers)
67
67
 
68
68
  ```ts
69
69
  createController({
@@ -75,9 +75,9 @@ createController({
75
75
  });
76
76
  ```
77
77
 
78
- Controllers are DI units that hold routes. Route factories come from transport packages — `Get`/`Post`/... from `@justscale/http`, `Ws` from `@justscale/websocket`, `SSE` from `@justscale/sse`, `Cli` from `@justscale/core/cli`, `Procedure` from contracts — and all flow through the same `.use(middleware).guard(...).handle(...)` pipeline with per-route typing.
78
+ Controllers are DI units that hold routes. Route factories come from transport packages — `Get`/`Post`/... from `@justscale/http`, `Cli` from `@justscale/core/cli` — and all flow through the same `.use(middleware).guard(...).handle(...)` pipeline with per-route typing. Additional transports (WebSocket, SSE, RPC) graduate from `next` as those packages settle.
79
79
 
80
- ### Features — [justscale.sh/fundamentals/features](https://justscale.sh/fundamentals/features)
80
+ ### Features — [justscale.sh/docs/fundamentals/features](https://justscale.sh/docs/fundamentals/features)
81
81
 
82
82
  ```ts
83
83
  export const AuthFeature = createFeatureBuilder()
@@ -88,22 +88,6 @@ export const AuthFeature = createFeatureBuilder()
88
88
 
89
89
  Features are shippable capability bundles: a named package of services + controllers + config requirements that other apps consume via `.add(AuthFeature)`. `.requires(...)` bubbles DI requirements up to whoever adds the feature — the requirement is checked at their `build()`, not yours.
90
90
 
91
- ### Contracts — [justscale.sh/rpc](https://justscale.sh/rpc/overview)
92
-
93
- ```ts
94
- import { defineContract, rpc } from '@justscale/core/contract';
95
-
96
- class UserContract extends defineContract({
97
- protocol: 'grpc',
98
- serviceName: 'user.UserService',
99
- methods: {
100
- getUser: rpc(GetUserRequestSchema, UserSchema),
101
- },
102
- }) {}
103
- ```
104
-
105
- Contracts describe a typed set of methods independent of transport. A controller implements a contract via `createController.implements(UserContract, ...)`; the same implementation can be served over gRPC (`@justscale/rpc`), in-process, or routed across cluster nodes. Contracts also act as DI tokens — injecting `UserContract` gets you a client that resolves locally when bound, remotely otherwise.
106
-
107
91
  ## Composition
108
92
 
109
93
  ### `JustScale()`
@@ -118,14 +102,13 @@ JustScale()
118
102
 
119
103
  The builder is the unit of composition. Every `.add()` contributes services, controllers, features, or bindings into a scope. `.build()` returns a validated `BuiltApp` with `.serve()`, `.match()`, `.run()`, and friends.
120
104
 
121
- ### Sub-apps — [justscale.sh/advanced/plugins](https://justscale.sh/advanced/plugins)
105
+ ### Sub-apps
122
106
 
123
107
  ```ts
124
108
  const AdminSubApp = JustScale()
125
109
  .requires(CatalogService)
126
110
  .requires(InventoryService)
127
111
  .add(AdminController)
128
- .add(OpenApiFeature)
129
112
  .build();
130
113
 
131
114
  const Shop = JustScale()
@@ -140,9 +123,9 @@ A `JustScale()` compilation unit with `.requires(...)` is a sub-app. Mounting it
140
123
 
141
124
  ### `AbstractContainer`
142
125
 
143
- Reflection on a scope. Inject `AbstractContainer` into a service or controller and you get a typed view of the controllers/services/features bound to that scope. `@justscale/feature-openapi` uses it to emit a per-scope OpenAPI spec add the feature to a sub-app and the spec covers just that sub-app.
126
+ Reflection on a scope. Inject `AbstractContainer` into a service or controller and you get a typed view of the controllers/services/features bound to that scope. Useful for per-scope introspection (e.g. generating an OpenAPI spec scoped to a single sub-app).
144
127
 
145
- ## Durable processes — [justscale.sh/processes/signals](https://justscale.sh/processes/signals)
128
+ ## Durable processes — [justscale.sh/docs/processes/signals](https://justscale.sh/docs/processes/signals)
146
129
 
147
130
  ```ts
148
131
  import { createProcess, signal, race, delay } from '@justscale/core/process';
@@ -167,9 +150,9 @@ const orderFulfillment = createProcess({
167
150
  });
168
151
  ```
169
152
 
170
- Durable processes survive restarts. Their state is serialized through the `Processable` protocol, timers and signals resume transparently, and the compiler (via `@justscale/typescript`'s `ptsc`) rewrites the handler into a safely resumable shape. The runtime is transport-agnostic — signals can fire from HTTP, CLI, WS, cluster, anywhere.
153
+ Durable processes survive restarts. Their state is serialized through the `Processable` protocol, timers and signals resume transparently, and the compiler (via `@justscale/typescript`'s `ptsc`) rewrites the handler into a safely resumable shape. The runtime is transport-agnostic — signals can fire from HTTP, CLI, cluster, anywhere.
171
154
 
172
- ## Models — [justscale.sh/models/overview](https://justscale.sh/models/overview)
155
+ ## Models — [justscale.sh/docs/models/overview](https://justscale.sh/docs/models/overview)
173
156
 
174
157
  ```ts
175
158
  import { defineModel, field } from '@justscale/core/models';
@@ -191,15 +174,15 @@ References (`field.ref(OtherModel)`) are first-class values, not string IDs. Con
191
174
 
192
175
  ## Distributed primitives
193
176
 
194
- ### Locks — [justscale.sh/fundamentals/locks](https://justscale.sh/fundamentals/locks)
177
+ ### Locks — [justscale.sh/docs/fundamentals/locks](https://justscale.sh/docs/fundamentals/locks)
195
178
 
196
179
  Abstract lock API with an `acquire(key, opts)` signature that returns a disposable guard — integrates with the `using` statement for auto-release. The default provider is in-memory (good for tests). `@justscale/postgres` provides a Postgres advisory-lock backend that coordinates across instances, so locks survive being held from different processes hitting the same database.
197
180
 
198
- ### Channels — [justscale.sh/fundamentals/channels](https://justscale.sh/fundamentals/channels)
181
+ ### Channels — [justscale.sh/docs/fundamentals/channels](https://justscale.sh/docs/fundamentals/channels)
199
182
 
200
183
  Typed pub/sub with async iterables. `createChannels({ ... })` declares a set of named channels with per-message schemas; subscribers consume via `for await` on a subscription. The default `MemoryChannelBackend` works for a single process; `@justscale/postgres`'s `createPostgresChannelBackend` fans messages out over `LISTEN/NOTIFY` so multiple app instances pointed at the same database all see each publish. Message encoding goes through the `Processable` protocol so domain values (model refs, dates, decimals) survive the round-trip.
201
184
 
202
- ## Configuration — [justscale.sh/configuration/overview](https://justscale.sh/configuration/overview)
185
+ ## Configuration — [justscale.sh/docs/configuration/overview](https://justscale.sh/docs/configuration/overview)
203
186
 
204
187
  ```ts
205
188
  import { defineConfigPartial, createConfig, Config } from '@justscale/core';
@@ -233,7 +216,7 @@ Everything beyond the bare `@justscale/core` import lives behind a subpath so yo
233
216
  - `@justscale/core/memory` — in-memory adapter implementations (tests / prototyping)
234
217
  - `@justscale/core/middleware`, `/logger`, `/lifecycle`, `/plugin` — narrower slices of the bare surface
235
218
 
236
- ## `just` CLI — [justscale.sh/cli/usage](https://justscale.sh/cli/usage)
219
+ ## `just` CLI — [justscale.sh/docs/cli/usage](https://justscale.sh/docs/cli/usage)
237
220
 
238
221
  Installing this package installs the `just` binary:
239
222
 
@@ -249,13 +232,11 @@ just install <plugin> # install a JustScale plugin package
249
232
 
250
233
  ## Observability
251
234
 
252
- Services and controllers run under an async context with request tracing, scope management, and pluggable instrumentation. `registerInstrumentation` lets OpenTelemetry / Datadog / custom collectors subscribe without the app code having to know; `@justscale/feature-otel` is a ready-made wiring.
235
+ Services and controllers run under an async context with request tracing, scope management, and pluggable instrumentation. `registerInstrumentation` lets OpenTelemetry / Datadog / custom collectors subscribe without the app code having to know.
253
236
 
254
237
  ## More
255
238
 
256
- - [Quick start](https://justscale.sh/overview/quick-start)
257
- - [Core philosophy](https://justscale.sh/overview/philosophy)
258
- - [Repository pattern](https://justscale.sh/repositories/overview)
259
- - [Cluster overview](https://justscale.sh/cluster/overview)
260
- - [Permissions](https://justscale.sh/features/permissions)
261
- - [OpenAPI](https://justscale.sh/techniques/openapi)
239
+ - [Quick start](https://justscale.sh/docs/overview/quick-start)
240
+ - [Core philosophy](https://justscale.sh/docs/overview/philosophy)
241
+ - [Repository pattern](https://justscale.sh/docs/repositories/overview)
242
+ - [Cluster overview](https://justscale.sh/docs/cluster/overview)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justscale/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Type-safe dependency injection, services, and controllers for JustScale",
5
5
  "author": "JustScale",
6
6
  "license": "MIT",
@@ -184,9 +184,9 @@
184
184
  "weakrefset": "^0.2.2"
185
185
  },
186
186
  "peerDependencies": {
187
- "esbuild": "^0.27.0",
187
+ "esbuild": "^0.28.0",
188
188
  "zod": "^4.3.6",
189
- "@justscale/typescript": "6.0.0"
189
+ "@justscale/typescript": "0.1.1"
190
190
  },
191
191
  "peerDependenciesMeta": {
192
192
  "@justscale/typescript": {
@@ -197,8 +197,8 @@
197
197
  }
198
198
  },
199
199
  "devDependencies": {
200
- "esbuild": "^0.27.7",
201
- "@justscale/typescript": "6.0.0"
200
+ "esbuild": "^0.28.0",
201
+ "@justscale/typescript": "0.1.1"
202
202
  },
203
203
  "scripts": {
204
204
  "build": "ptsc -b tsconfig.build.json",