@plinthjs/contracts 0.1.1 → 0.1.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/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -25
- package/dist/index.d.ts +25 -25
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA2BO,IAAM,OAAA,GAAU","file":"index.cjs","sourcesContent":["/**\n * `@plinthjs/contracts`
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA2BO,IAAM,OAAA,GAAU","file":"index.cjs","sourcesContent":["/**\n * `@plinthjs/contracts` - the interface-only foundation. This\n * package is zero-runtime and dependency-free: it exports the structural interfaces and type aliases\n * other Plinth packages depend on to decouple from one another. The only runtime export is\n * {@link VERSION}.\n */\n\nexport type { Arrayable, Jsonable, Objectable, Renderable } from './support'\nexport type { HasErrorBag, HasHttpStatus } from './http'\nexport type { HashOptions, Hasher } from './hashing'\nexport type { Encrypter } from './encryption'\nexport type {\n Authenticatable,\n Credentials,\n Guard,\n Rememberable,\n StatefulGuard,\n UserProvider,\n} from './auth'\nexport type { CacheRepository, CacheStore } from './cache'\nexport type { JobMiddleware, Queueable, QueueJob, ShouldQueue } from './queue'\nexport type { Mailer, MailableContract } from './mail'\nexport type { Disk } from './filesystem'\nexport type { Container, Identifier, Newable } from './container'\nexport type { Cast, CastEncrypter } from './casts'\n\n/** The Plinth version this build of `contracts` ships with. */\nexport const VERSION = '0.1.0'\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Core support contracts
|
|
2
|
+
* Core support contracts - the interfaces. These tiny,
|
|
3
3
|
* structural shapes let any value advertise that it can be turned into an array
|
|
4
4
|
* ({@link Arrayable}), serialized to JSON ({@link Jsonable}), or rendered to a string
|
|
5
5
|
* ({@link Renderable}) without coupling the consumer to a concrete type.
|
|
@@ -13,7 +13,7 @@ interface Arrayable<T = unknown> {
|
|
|
13
13
|
toArray(): T[];
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A value convertible to a plain keyed object
|
|
16
|
+
* A value convertible to a plain keyed object - following the conventional design
|
|
17
17
|
* object-shaped variant, for things that flatten to a record rather than a list.
|
|
18
18
|
*/
|
|
19
19
|
interface Objectable<T = unknown> {
|
|
@@ -21,7 +21,7 @@ interface Objectable<T = unknown> {
|
|
|
21
21
|
toObject(): Record<string, T>;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* A value convertible to a JSON-safe representation
|
|
24
|
+
* A value convertible to a JSON-safe representation - following the conventional design
|
|
25
25
|
* equivalent. Returns the value to be serialized (not the JSON string) so callers control encoding.
|
|
26
26
|
*/
|
|
27
27
|
interface Jsonable {
|
|
@@ -29,7 +29,7 @@ interface Jsonable {
|
|
|
29
29
|
toJSON(): unknown;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* A value that can render itself to a string
|
|
32
|
+
* A value that can render itself to a string - following the conventional design
|
|
33
33
|
* equivalent (e.g. a view or a mailable preview).
|
|
34
34
|
*/
|
|
35
35
|
interface Renderable {
|
|
@@ -38,13 +38,13 @@ interface Renderable {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* HTTP-renderable error contracts
|
|
41
|
+
* HTTP-renderable error contracts - the structural seams the HTTP `ExceptionHandler` reads to
|
|
42
42
|
* render a thrown error without coupling `@plinthjs/http` to the package that threw it. An error may
|
|
43
43
|
* carry an HTTP status ({@link HasHttpStatus}), a field/messages bag ({@link HasErrorBag}), or
|
|
44
44
|
* both; the two are kept separate so each can be implemented independently.
|
|
45
45
|
*/
|
|
46
46
|
/**
|
|
47
|
-
* An error carrying the HTTP status it should render as
|
|
47
|
+
* An error carrying the HTTP status it should render as - the seam the handler reads so a
|
|
48
48
|
* validation `422` or authorization `403` renders correctly without a direct dependency.
|
|
49
49
|
*/
|
|
50
50
|
interface HasHttpStatus {
|
|
@@ -52,7 +52,7 @@ interface HasHttpStatus {
|
|
|
52
52
|
readonly status: number;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* An error carrying a `field → messages` bag
|
|
55
|
+
* An error carrying a `field → messages` bag - the seam the handler surfaces as the JSON `errors`
|
|
56
56
|
* payload (e.g. from a validation failure). Mirrors the conventional `MessageBag`-shaped error output.
|
|
57
57
|
*/
|
|
58
58
|
interface HasErrorBag {
|
|
@@ -102,7 +102,7 @@ interface Encrypter {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Authentication contracts
|
|
105
|
+
* Authentication contracts - the interfaces.
|
|
106
106
|
* {@link Authenticatable} is a user that can be authenticated; {@link UserProvider} retrieves and
|
|
107
107
|
* validates users from storage; {@link Guard} reads who the current user is; {@link StatefulGuard}
|
|
108
108
|
* also logs them in and out across requests; {@link Rememberable} adds "remember me" persistence.
|
|
@@ -116,10 +116,10 @@ interface Authenticatable {
|
|
|
116
116
|
/** The hashed password used to validate credentials. */
|
|
117
117
|
getAuthPassword(): string;
|
|
118
118
|
}
|
|
119
|
-
/** Login credentials
|
|
119
|
+
/** Login credentials - typically `{ email, password }`. */
|
|
120
120
|
type Credentials = Record<string, unknown>;
|
|
121
121
|
/**
|
|
122
|
-
* A user that supports "remember me" persistence
|
|
122
|
+
* A user that supports "remember me" persistence - the remember-token methods on
|
|
123
123
|
* `Authenticatable`. Kept separate so a user can opt into it independently.
|
|
124
124
|
*/
|
|
125
125
|
interface Rememberable {
|
|
@@ -129,7 +129,7 @@ interface Rememberable {
|
|
|
129
129
|
setRememberToken(token: string): void;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* Retrieves and validates users from storage
|
|
132
|
+
* Retrieves and validates users from storage - following the conventional design
|
|
133
133
|
* equivalent. The seam between a guard and however users are persisted.
|
|
134
134
|
*/
|
|
135
135
|
interface UserProvider {
|
|
@@ -176,7 +176,7 @@ interface StatefulGuard extends Guard {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
|
-
* Cache contracts
|
|
179
|
+
* Cache contracts - the interfaces. {@link CacheStore} is the
|
|
180
180
|
* lowest layer (the swappable backend: array, file, Redis); {@link CacheRepository} is the
|
|
181
181
|
* user-facing superset that adds the ergonomic helpers (`remember`, `pull`, `has`) on top. Every
|
|
182
182
|
* method is async so a store may be backed by I/O, and TTLs are expressed in **seconds**. Values are generic over `unknown`.
|
|
@@ -219,7 +219,7 @@ interface CacheRepository extends CacheStore {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
|
-
* Queue contracts
|
|
222
|
+
* Queue contracts - the queueing and job interfaces. {@link ShouldQueue} is the marker that opts work into the queue; {@link QueueJob} is
|
|
223
223
|
* the unit of deferred work whose `handle()` a driver runs; {@link JobMiddleware} wraps that call
|
|
224
224
|
* with cross-cutting concerns. {@link Queueable} is the alias used where a queueable job is expected.
|
|
225
225
|
*/
|
|
@@ -229,29 +229,29 @@ interface CacheRepository extends CacheStore {
|
|
|
229
229
|
interface ShouldQueue {
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
|
-
* The unit of deferred work
|
|
232
|
+
* The unit of deferred work - the `ShouldQueue` +. A driver
|
|
233
233
|
* `await`s {@link QueueJob.handle}; an optional {@link QueueJob.tries} bounds attempts before the
|
|
234
234
|
* job is treated as failed, and {@link QueueJob.middleware} wraps the call to `handle`.
|
|
235
235
|
*/
|
|
236
236
|
interface QueueJob {
|
|
237
|
-
/** Run the job's work. The `handle()` equivalent
|
|
237
|
+
/** Run the job's work. The `handle()` equivalent - may be sync or async; drivers always await it. */
|
|
238
238
|
handle(): Promise<void> | void;
|
|
239
|
-
/** Maximum number of attempts before the job is treated as failed
|
|
239
|
+
/** Maximum number of attempts before the job is treated as failed - the `$tries` equivalent. */
|
|
240
240
|
tries?: number;
|
|
241
241
|
/** Return the middleware pipeline that wraps {@link QueueJob.handle}. The `middleware()` equivalent. */
|
|
242
242
|
middleware?(): JobMiddleware[];
|
|
243
243
|
}
|
|
244
|
-
/** Alias of {@link QueueJob}
|
|
244
|
+
/** Alias of {@link QueueJob} - used where a queueable job is expected (the `Queueable` concept). */
|
|
245
245
|
type Queueable = QueueJob;
|
|
246
246
|
/**
|
|
247
|
-
* One link in a job's middleware pipeline
|
|
247
|
+
* One link in a job's middleware pipeline - the job-middleware (`handle($job, $next)`)
|
|
248
248
|
* equivalent, expressed as a function. Awaiting `next()` runs the rest of the pipeline (and
|
|
249
249
|
* ultimately `handle`); skipping it short-circuits the job.
|
|
250
250
|
*/
|
|
251
251
|
type JobMiddleware = (job: QueueJob, next: () => Promise<void>) => Promise<void> | void;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
* Mail contracts
|
|
254
|
+
* Mail contracts - the interfaces. A {@link MailableContract}
|
|
255
255
|
* is a self-describing email that configures itself via `build()` and can `render()` itself; a
|
|
256
256
|
* {@link Mailer} dispatches one through whatever transport backs it. Kept transport-agnostic so the
|
|
257
257
|
* sender never cares which delivery mechanism is wired up.
|
|
@@ -283,7 +283,7 @@ interface Mailer {
|
|
|
283
283
|
* and relative to the disk root.
|
|
284
284
|
*/
|
|
285
285
|
/**
|
|
286
|
-
* The core filesystem surface
|
|
286
|
+
* The core filesystem surface - the common subset of what filesystems share.
|
|
287
287
|
* Every method is async so a driver may be backed by network or disk I/O.
|
|
288
288
|
*/
|
|
289
289
|
interface Disk {
|
|
@@ -307,7 +307,7 @@ interface Disk {
|
|
|
307
307
|
* JS has no reflection-based autowiring, so dependencies are wired via factory functions.
|
|
308
308
|
*/
|
|
309
309
|
/**
|
|
310
|
-
* A class constructor
|
|
310
|
+
* A class constructor - the seam a container can `new` directly. The constructor signature is
|
|
311
311
|
* intentionally open so any class is assignable.
|
|
312
312
|
*/
|
|
313
313
|
type Newable<T = unknown> = new (...args: any[]) => T;
|
|
@@ -321,7 +321,7 @@ type Identifier<T = unknown> = string | symbol | Newable<T>;
|
|
|
321
321
|
interface Container {
|
|
322
322
|
/** Register a binding from an identifier to a factory or constructable class. The `bind` equivalent. */
|
|
323
323
|
bind<T>(token: Identifier<T>, concrete?: Newable<T>): void;
|
|
324
|
-
/** Register a shared (singleton) binding
|
|
324
|
+
/** Register a shared (singleton) binding - resolved once, then cached. The `singleton` equivalent. */
|
|
325
325
|
singleton<T>(token: Identifier<T>, concrete?: Newable<T>): void;
|
|
326
326
|
/** Resolve an identifier to a concrete value. The `make` equivalent. */
|
|
327
327
|
make<T>(token: Identifier<T>): T;
|
|
@@ -336,7 +336,7 @@ interface Container {
|
|
|
336
336
|
* encrypting cast needs. The owning model is passed as `unknown` to keep this package decoupled.
|
|
337
337
|
*/
|
|
338
338
|
/**
|
|
339
|
-
* A custom attribute cast
|
|
339
|
+
* A custom attribute cast - the `CastsAttributes` equivalent. {@link Cast.get} runs on read,
|
|
340
340
|
* {@link Cast.set} on write. The `model` is the owning record, typed `unknown` so this contract
|
|
341
341
|
* stays free of any ORM dependency.
|
|
342
342
|
*/
|
|
@@ -347,7 +347,7 @@ interface Cast {
|
|
|
347
347
|
set(value: unknown, model: unknown): unknown;
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
|
-
* The minimal encrypt/decrypt surface an encrypting cast needs
|
|
350
|
+
* The minimal encrypt/decrypt surface an encrypting cast needs - a structural subset of the
|
|
351
351
|
* encryption `Encrypter`. Kept here so a cast can depend on it without importing the encrypter type.
|
|
352
352
|
*/
|
|
353
353
|
interface CastEncrypter {
|
|
@@ -358,7 +358,7 @@ interface CastEncrypter {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
/**
|
|
361
|
-
* `@plinthjs/contracts`
|
|
361
|
+
* `@plinthjs/contracts` - the interface-only foundation. This
|
|
362
362
|
* package is zero-runtime and dependency-free: it exports the structural interfaces and type aliases
|
|
363
363
|
* other Plinth packages depend on to decouple from one another. The only runtime export is
|
|
364
364
|
* {@link VERSION}.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Core support contracts
|
|
2
|
+
* Core support contracts - the interfaces. These tiny,
|
|
3
3
|
* structural shapes let any value advertise that it can be turned into an array
|
|
4
4
|
* ({@link Arrayable}), serialized to JSON ({@link Jsonable}), or rendered to a string
|
|
5
5
|
* ({@link Renderable}) without coupling the consumer to a concrete type.
|
|
@@ -13,7 +13,7 @@ interface Arrayable<T = unknown> {
|
|
|
13
13
|
toArray(): T[];
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A value convertible to a plain keyed object
|
|
16
|
+
* A value convertible to a plain keyed object - following the conventional design
|
|
17
17
|
* object-shaped variant, for things that flatten to a record rather than a list.
|
|
18
18
|
*/
|
|
19
19
|
interface Objectable<T = unknown> {
|
|
@@ -21,7 +21,7 @@ interface Objectable<T = unknown> {
|
|
|
21
21
|
toObject(): Record<string, T>;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* A value convertible to a JSON-safe representation
|
|
24
|
+
* A value convertible to a JSON-safe representation - following the conventional design
|
|
25
25
|
* equivalent. Returns the value to be serialized (not the JSON string) so callers control encoding.
|
|
26
26
|
*/
|
|
27
27
|
interface Jsonable {
|
|
@@ -29,7 +29,7 @@ interface Jsonable {
|
|
|
29
29
|
toJSON(): unknown;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* A value that can render itself to a string
|
|
32
|
+
* A value that can render itself to a string - following the conventional design
|
|
33
33
|
* equivalent (e.g. a view or a mailable preview).
|
|
34
34
|
*/
|
|
35
35
|
interface Renderable {
|
|
@@ -38,13 +38,13 @@ interface Renderable {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* HTTP-renderable error contracts
|
|
41
|
+
* HTTP-renderable error contracts - the structural seams the HTTP `ExceptionHandler` reads to
|
|
42
42
|
* render a thrown error without coupling `@plinthjs/http` to the package that threw it. An error may
|
|
43
43
|
* carry an HTTP status ({@link HasHttpStatus}), a field/messages bag ({@link HasErrorBag}), or
|
|
44
44
|
* both; the two are kept separate so each can be implemented independently.
|
|
45
45
|
*/
|
|
46
46
|
/**
|
|
47
|
-
* An error carrying the HTTP status it should render as
|
|
47
|
+
* An error carrying the HTTP status it should render as - the seam the handler reads so a
|
|
48
48
|
* validation `422` or authorization `403` renders correctly without a direct dependency.
|
|
49
49
|
*/
|
|
50
50
|
interface HasHttpStatus {
|
|
@@ -52,7 +52,7 @@ interface HasHttpStatus {
|
|
|
52
52
|
readonly status: number;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* An error carrying a `field → messages` bag
|
|
55
|
+
* An error carrying a `field → messages` bag - the seam the handler surfaces as the JSON `errors`
|
|
56
56
|
* payload (e.g. from a validation failure). Mirrors the conventional `MessageBag`-shaped error output.
|
|
57
57
|
*/
|
|
58
58
|
interface HasErrorBag {
|
|
@@ -102,7 +102,7 @@ interface Encrypter {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Authentication contracts
|
|
105
|
+
* Authentication contracts - the interfaces.
|
|
106
106
|
* {@link Authenticatable} is a user that can be authenticated; {@link UserProvider} retrieves and
|
|
107
107
|
* validates users from storage; {@link Guard} reads who the current user is; {@link StatefulGuard}
|
|
108
108
|
* also logs them in and out across requests; {@link Rememberable} adds "remember me" persistence.
|
|
@@ -116,10 +116,10 @@ interface Authenticatable {
|
|
|
116
116
|
/** The hashed password used to validate credentials. */
|
|
117
117
|
getAuthPassword(): string;
|
|
118
118
|
}
|
|
119
|
-
/** Login credentials
|
|
119
|
+
/** Login credentials - typically `{ email, password }`. */
|
|
120
120
|
type Credentials = Record<string, unknown>;
|
|
121
121
|
/**
|
|
122
|
-
* A user that supports "remember me" persistence
|
|
122
|
+
* A user that supports "remember me" persistence - the remember-token methods on
|
|
123
123
|
* `Authenticatable`. Kept separate so a user can opt into it independently.
|
|
124
124
|
*/
|
|
125
125
|
interface Rememberable {
|
|
@@ -129,7 +129,7 @@ interface Rememberable {
|
|
|
129
129
|
setRememberToken(token: string): void;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* Retrieves and validates users from storage
|
|
132
|
+
* Retrieves and validates users from storage - following the conventional design
|
|
133
133
|
* equivalent. The seam between a guard and however users are persisted.
|
|
134
134
|
*/
|
|
135
135
|
interface UserProvider {
|
|
@@ -176,7 +176,7 @@ interface StatefulGuard extends Guard {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
|
-
* Cache contracts
|
|
179
|
+
* Cache contracts - the interfaces. {@link CacheStore} is the
|
|
180
180
|
* lowest layer (the swappable backend: array, file, Redis); {@link CacheRepository} is the
|
|
181
181
|
* user-facing superset that adds the ergonomic helpers (`remember`, `pull`, `has`) on top. Every
|
|
182
182
|
* method is async so a store may be backed by I/O, and TTLs are expressed in **seconds**. Values are generic over `unknown`.
|
|
@@ -219,7 +219,7 @@ interface CacheRepository extends CacheStore {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
|
-
* Queue contracts
|
|
222
|
+
* Queue contracts - the queueing and job interfaces. {@link ShouldQueue} is the marker that opts work into the queue; {@link QueueJob} is
|
|
223
223
|
* the unit of deferred work whose `handle()` a driver runs; {@link JobMiddleware} wraps that call
|
|
224
224
|
* with cross-cutting concerns. {@link Queueable} is the alias used where a queueable job is expected.
|
|
225
225
|
*/
|
|
@@ -229,29 +229,29 @@ interface CacheRepository extends CacheStore {
|
|
|
229
229
|
interface ShouldQueue {
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
|
-
* The unit of deferred work
|
|
232
|
+
* The unit of deferred work - the `ShouldQueue` +. A driver
|
|
233
233
|
* `await`s {@link QueueJob.handle}; an optional {@link QueueJob.tries} bounds attempts before the
|
|
234
234
|
* job is treated as failed, and {@link QueueJob.middleware} wraps the call to `handle`.
|
|
235
235
|
*/
|
|
236
236
|
interface QueueJob {
|
|
237
|
-
/** Run the job's work. The `handle()` equivalent
|
|
237
|
+
/** Run the job's work. The `handle()` equivalent - may be sync or async; drivers always await it. */
|
|
238
238
|
handle(): Promise<void> | void;
|
|
239
|
-
/** Maximum number of attempts before the job is treated as failed
|
|
239
|
+
/** Maximum number of attempts before the job is treated as failed - the `$tries` equivalent. */
|
|
240
240
|
tries?: number;
|
|
241
241
|
/** Return the middleware pipeline that wraps {@link QueueJob.handle}. The `middleware()` equivalent. */
|
|
242
242
|
middleware?(): JobMiddleware[];
|
|
243
243
|
}
|
|
244
|
-
/** Alias of {@link QueueJob}
|
|
244
|
+
/** Alias of {@link QueueJob} - used where a queueable job is expected (the `Queueable` concept). */
|
|
245
245
|
type Queueable = QueueJob;
|
|
246
246
|
/**
|
|
247
|
-
* One link in a job's middleware pipeline
|
|
247
|
+
* One link in a job's middleware pipeline - the job-middleware (`handle($job, $next)`)
|
|
248
248
|
* equivalent, expressed as a function. Awaiting `next()` runs the rest of the pipeline (and
|
|
249
249
|
* ultimately `handle`); skipping it short-circuits the job.
|
|
250
250
|
*/
|
|
251
251
|
type JobMiddleware = (job: QueueJob, next: () => Promise<void>) => Promise<void> | void;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
* Mail contracts
|
|
254
|
+
* Mail contracts - the interfaces. A {@link MailableContract}
|
|
255
255
|
* is a self-describing email that configures itself via `build()` and can `render()` itself; a
|
|
256
256
|
* {@link Mailer} dispatches one through whatever transport backs it. Kept transport-agnostic so the
|
|
257
257
|
* sender never cares which delivery mechanism is wired up.
|
|
@@ -283,7 +283,7 @@ interface Mailer {
|
|
|
283
283
|
* and relative to the disk root.
|
|
284
284
|
*/
|
|
285
285
|
/**
|
|
286
|
-
* The core filesystem surface
|
|
286
|
+
* The core filesystem surface - the common subset of what filesystems share.
|
|
287
287
|
* Every method is async so a driver may be backed by network or disk I/O.
|
|
288
288
|
*/
|
|
289
289
|
interface Disk {
|
|
@@ -307,7 +307,7 @@ interface Disk {
|
|
|
307
307
|
* JS has no reflection-based autowiring, so dependencies are wired via factory functions.
|
|
308
308
|
*/
|
|
309
309
|
/**
|
|
310
|
-
* A class constructor
|
|
310
|
+
* A class constructor - the seam a container can `new` directly. The constructor signature is
|
|
311
311
|
* intentionally open so any class is assignable.
|
|
312
312
|
*/
|
|
313
313
|
type Newable<T = unknown> = new (...args: any[]) => T;
|
|
@@ -321,7 +321,7 @@ type Identifier<T = unknown> = string | symbol | Newable<T>;
|
|
|
321
321
|
interface Container {
|
|
322
322
|
/** Register a binding from an identifier to a factory or constructable class. The `bind` equivalent. */
|
|
323
323
|
bind<T>(token: Identifier<T>, concrete?: Newable<T>): void;
|
|
324
|
-
/** Register a shared (singleton) binding
|
|
324
|
+
/** Register a shared (singleton) binding - resolved once, then cached. The `singleton` equivalent. */
|
|
325
325
|
singleton<T>(token: Identifier<T>, concrete?: Newable<T>): void;
|
|
326
326
|
/** Resolve an identifier to a concrete value. The `make` equivalent. */
|
|
327
327
|
make<T>(token: Identifier<T>): T;
|
|
@@ -336,7 +336,7 @@ interface Container {
|
|
|
336
336
|
* encrypting cast needs. The owning model is passed as `unknown` to keep this package decoupled.
|
|
337
337
|
*/
|
|
338
338
|
/**
|
|
339
|
-
* A custom attribute cast
|
|
339
|
+
* A custom attribute cast - the `CastsAttributes` equivalent. {@link Cast.get} runs on read,
|
|
340
340
|
* {@link Cast.set} on write. The `model` is the owning record, typed `unknown` so this contract
|
|
341
341
|
* stays free of any ORM dependency.
|
|
342
342
|
*/
|
|
@@ -347,7 +347,7 @@ interface Cast {
|
|
|
347
347
|
set(value: unknown, model: unknown): unknown;
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
|
-
* The minimal encrypt/decrypt surface an encrypting cast needs
|
|
350
|
+
* The minimal encrypt/decrypt surface an encrypting cast needs - a structural subset of the
|
|
351
351
|
* encryption `Encrypter`. Kept here so a cast can depend on it without importing the encrypter type.
|
|
352
352
|
*/
|
|
353
353
|
interface CastEncrypter {
|
|
@@ -358,7 +358,7 @@ interface CastEncrypter {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
/**
|
|
361
|
-
* `@plinthjs/contracts`
|
|
361
|
+
* `@plinthjs/contracts` - the interface-only foundation. This
|
|
362
362
|
* package is zero-runtime and dependency-free: it exports the structural interfaces and type aliases
|
|
363
363
|
* other Plinth packages depend on to decouple from one another. The only runtime export is
|
|
364
364
|
* {@link VERSION}.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AA2BO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\n * `@plinthjs/contracts`
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AA2BO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\n * `@plinthjs/contracts` - the interface-only foundation. This\n * package is zero-runtime and dependency-free: it exports the structural interfaces and type aliases\n * other Plinth packages depend on to decouple from one another. The only runtime export is\n * {@link VERSION}.\n */\n\nexport type { Arrayable, Jsonable, Objectable, Renderable } from './support'\nexport type { HasErrorBag, HasHttpStatus } from './http'\nexport type { HashOptions, Hasher } from './hashing'\nexport type { Encrypter } from './encryption'\nexport type {\n Authenticatable,\n Credentials,\n Guard,\n Rememberable,\n StatefulGuard,\n UserProvider,\n} from './auth'\nexport type { CacheRepository, CacheStore } from './cache'\nexport type { JobMiddleware, Queueable, QueueJob, ShouldQueue } from './queue'\nexport type { Mailer, MailableContract } from './mail'\nexport type { Disk } from './filesystem'\nexport type { Container, Identifier, Newable } from './container'\nexport type { Cast, CastEncrypter } from './casts'\n\n/** The Plinth version this build of `contracts` ships with. */\nexport const VERSION = '0.1.0'\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plinthjs/contracts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Plinth contracts: the interface-only foundation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plinth",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"typescript",
|
|
9
9
|
"contracts"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/anilkumarthakur60/
|
|
11
|
+
"homepage": "https://github.com/anilkumarthakur60/plinthjs/tree/main/packages/contracts#readme",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/anilkumarthakur60/
|
|
13
|
+
"url": "https://github.com/anilkumarthakur60/plinthjs/issues"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/anilkumarthakur60/
|
|
17
|
+
"url": "git+https://github.com/anilkumarthakur60/plinthjs.git",
|
|
18
18
|
"directory": "packages/contracts"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|