@zerotal/arch 1.7.4 → 1.7.5
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/CHANGELOG.md +34 -2
- package/README.md +4 -2
- package/docs/about.md +16 -16
- package/docs/admin/actions.md +9 -9
- package/docs/admin/auth.md +2 -2
- package/docs/admin/dashboard.md +5 -5
- package/docs/admin/extending-ui.md +12 -12
- package/docs/admin/extending.md +16 -7
- package/docs/admin/forms.md +4 -4
- package/docs/admin/index.md +2 -2
- package/docs/admin/operations.md +9 -9
- package/docs/admin/resources.md +3 -3
- package/docs/admin/structure.md +6 -6
- package/docs/admin/tables.md +8 -8
- package/docs/admin/testing.md +4 -4
- package/docs/ai.md +118 -11
- package/docs/application.md +12 -12
- package/docs/arch.md +25 -3
- package/docs/assets.md +11 -11
- package/docs/audit.md +13 -13
- package/docs/authentication.md +39 -39
- package/docs/authorization.md +13 -13
- package/docs/broadcasting/channels.md +2 -2
- package/docs/broadcasting/client.md +2 -2
- package/docs/broadcasting/events.md +9 -10
- package/docs/broadcasting/index.md +1 -1
- package/docs/broadcasting/testing.md +5 -5
- package/docs/cache.md +15 -13
- package/docs/carbon.md +35 -35
- package/docs/changelog.md +105 -1
- package/docs/client/index.md +13 -13
- package/docs/commands.md +4 -4
- package/docs/components.md +116 -115
- package/docs/config-system.md +4 -4
- package/docs/container.md +27 -27
- package/docs/context.md +27 -27
- package/docs/contributing.md +28 -0
- package/docs/controllers.md +10 -10
- package/docs/conventions.md +23 -15
- package/docs/cookies.md +3 -3
- package/docs/csrf.md +6 -6
- package/docs/database.md +22 -17
- package/docs/deployment.md +2 -2
- package/docs/devtools.md +16 -16
- package/docs/email-verification.md +8 -8
- package/docs/encryption.md +7 -7
- package/docs/errors.md +6 -6
- package/docs/events.md +12 -11
- package/docs/flow/components.md +32 -32
- package/docs/flow/decorators.md +18 -18
- package/docs/flow/events.md +16 -16
- package/docs/flow/forms.md +17 -17
- package/docs/flow/icons.md +5 -5
- package/docs/flow/index.md +20 -20
- package/docs/flow/layouts.md +35 -35
- package/docs/flow/lifecycle.md +16 -16
- package/docs/flow/models.md +9 -9
- package/docs/flow/pagination.md +8 -8
- package/docs/flow/performance.md +7 -7
- package/docs/flow/references.md +3 -3
- package/docs/flow/routing.md +26 -26
- package/docs/flow/testing.md +20 -20
- package/docs/getting-started.md +18 -13
- package/docs/health.md +17 -8
- package/docs/helpers.md +17 -17
- package/docs/i18n.md +10 -10
- package/docs/inertia/devtools.md +4 -4
- package/docs/inertia/index.md +6 -6
- package/docs/inertia/props.md +21 -21
- package/docs/inertia/rendering.md +9 -9
- package/docs/inertia/ssr.md +2 -2
- package/docs/lifecycle.md +2 -2
- package/docs/lock.md +11 -11
- package/docs/logger.md +12 -12
- package/docs/media.md +22 -22
- package/docs/middleware.md +17 -17
- package/docs/migrations.md +13 -13
- package/docs/monitor.md +6 -6
- package/docs/notifications.md +24 -24
- package/docs/orm/casts.md +14 -14
- package/docs/orm/factories.md +8 -8
- package/docs/orm/index.md +22 -20
- package/docs/orm/lifecycle.md +13 -13
- package/docs/orm/queries.md +28 -28
- package/docs/orm/relationships.md +16 -16
- package/docs/orm/serialization.md +11 -11
- package/docs/package-development.md +10 -10
- package/docs/pagination.md +14 -14
- package/docs/password-reset.md +6 -6
- package/docs/providers.md +11 -11
- package/docs/query-builder.md +18 -18
- package/docs/queue.md +14 -12
- package/docs/rate-limiting.md +6 -6
- package/docs/responses.md +14 -14
- package/docs/roles-and-2fa.md +9 -9
- package/docs/routing.md +44 -44
- package/docs/scaffolding.md +1 -1
- package/docs/scheduler.md +10 -10
- package/docs/seeding.md +6 -6
- package/docs/session.md +16 -14
- package/docs/social.md +14 -14
- package/docs/storage.md +25 -13
- package/docs/structure.md +2 -2
- package/docs/support-policy.md +23 -10
- package/docs/telemetry.md +12 -12
- package/docs/tenancy.md +34 -40
- package/docs/testing/browser.md +6 -6
- package/docs/testing/console.md +3 -3
- package/docs/testing/database.md +10 -10
- package/docs/testing/flow-browser.md +6 -6
- package/docs/testing/http.md +12 -12
- package/docs/testing/index.md +3 -3
- package/docs/testing/mocking.md +8 -8
- package/docs/upgrade.md +1 -1
- package/docs/validator.md +19 -19
- package/docs/view.md +14 -14
- package/package.json +4 -4
- package/src/index.ts +25 -1
- package/src/tools/searchDocs.ts +7 -0
package/docs/client/index.md
CHANGED
|
@@ -10,7 +10,7 @@ looking up an address. `@zerotal/client` is the outbound HTTP client — a thin,
|
|
|
10
10
|
expressive wrapper over `fetch` that adds what every real integration ends up
|
|
11
11
|
needing anyway and that is tedious to get right by hand.
|
|
12
12
|
|
|
13
|
-
```ts
|
|
13
|
+
```ts fragment
|
|
14
14
|
import { Client } from "@zerotal/client";
|
|
15
15
|
|
|
16
16
|
const charge = await Client.post("https://api.stripe.com/v1/charges", {
|
|
@@ -71,7 +71,7 @@ otherwise. A 2xx returns; anything else throws, which [Errors](#errors) covers.
|
|
|
71
71
|
|
|
72
72
|
### Query parameters
|
|
73
73
|
|
|
74
|
-
```ts
|
|
74
|
+
```ts fragment
|
|
75
75
|
await Client.get("https://api.example.com/v1/charges", undefined, {
|
|
76
76
|
query: { limit: 25, status: "succeeded", created: { gte: 1_700_000_000 } },
|
|
77
77
|
});
|
|
@@ -87,7 +87,7 @@ A plain object or array is JSON-encoded with the matching `Content-Type`. Anythi
|
|
|
87
87
|
a raw string — passes straight through, so the runtime sets the header itself
|
|
88
88
|
(including multipart boundaries):
|
|
89
89
|
|
|
90
|
-
```ts
|
|
90
|
+
```ts fragment
|
|
91
91
|
// Form-encoded, which several gateways still require
|
|
92
92
|
await Client.post(
|
|
93
93
|
"https://api.example.com/v1/charges",
|
|
@@ -99,7 +99,7 @@ await Client.post(
|
|
|
99
99
|
|
|
100
100
|
Per request, merged over the client's defaults:
|
|
101
101
|
|
|
102
|
-
```ts
|
|
102
|
+
```ts fragment
|
|
103
103
|
await Client.post("https://api.example.com/v1/messages", payload, {
|
|
104
104
|
headers: { "Idempotency-Key": crypto.randomUUID() },
|
|
105
105
|
});
|
|
@@ -125,7 +125,7 @@ export default ClientConfig({
|
|
|
125
125
|
A `token` may also be a function, including an async one, which is how credentials
|
|
126
126
|
that expire are handled — it is resolved per request:
|
|
127
127
|
|
|
128
|
-
```ts
|
|
128
|
+
```ts fragment
|
|
129
129
|
export default ClientConfig({
|
|
130
130
|
token: async () => await currentAccessToken(),
|
|
131
131
|
});
|
|
@@ -136,7 +136,7 @@ Change it at runtime with `setToken(token)`, or pass `null` to clear it. Its typ
|
|
|
136
136
|
|
|
137
137
|
For an API that wants something other than a bearer token, set the header directly:
|
|
138
138
|
|
|
139
|
-
```ts
|
|
139
|
+
```ts fragment
|
|
140
140
|
export default ClientConfig({
|
|
141
141
|
headers: { "X-Api-Key": env("PARTNER_API_KEY", "") },
|
|
142
142
|
});
|
|
@@ -147,7 +147,7 @@ export default ClientConfig({
|
|
|
147
147
|
`onUnauthorized` receives the error and a `retry` function, so a token can be
|
|
148
148
|
refreshed and the original request replayed once:
|
|
149
149
|
|
|
150
|
-
```ts
|
|
150
|
+
```ts fragment
|
|
151
151
|
export default ClientConfig({
|
|
152
152
|
onUnauthorized: async (error, retry) => retry({ Authorization: `Bearer ${await refresh()}` }),
|
|
153
153
|
});
|
|
@@ -158,7 +158,7 @@ export default ClientConfig({
|
|
|
158
158
|
There is no timeout by default, because the right one depends on the upstream. Set a
|
|
159
159
|
default and override per request:
|
|
160
160
|
|
|
161
|
-
```ts
|
|
161
|
+
```ts fragment
|
|
162
162
|
export default ClientConfig({ timeout: 10_000 });
|
|
163
163
|
|
|
164
164
|
// This one is slow and we accept that
|
|
@@ -174,7 +174,7 @@ A network blip or a `503` is worth trying again; a `422` never is. `retry` retri
|
|
|
174
174
|
idempotent requests on network errors, 5xx and 429 with exponential backoff, and
|
|
175
175
|
honours a `Retry-After` header when the server sends one:
|
|
176
176
|
|
|
177
|
-
```ts
|
|
177
|
+
```ts fragment
|
|
178
178
|
export default ClientConfig({ retry: 2 });
|
|
179
179
|
|
|
180
180
|
await Client.post("https://api.example.com/v1/charges", body, { retry: false });
|
|
@@ -189,7 +189,7 @@ statuses qualify.
|
|
|
189
189
|
|
|
190
190
|
A non-2xx throws `ApiClientError`, carrying what you need to decide what happened:
|
|
191
191
|
|
|
192
|
-
```ts
|
|
192
|
+
```ts fragment
|
|
193
193
|
import { ApiClientError } from "@zerotal/client";
|
|
194
194
|
|
|
195
195
|
try {
|
|
@@ -219,7 +219,7 @@ everything queued behind it. A `CircuitBreaker` stops after a threshold of
|
|
|
219
219
|
consecutive failures, fails fast for a cooldown, then lets a single request through
|
|
220
220
|
to test the water:
|
|
221
221
|
|
|
222
|
-
```ts
|
|
222
|
+
```ts fragment
|
|
223
223
|
export default ClientConfig({
|
|
224
224
|
circuitBreaker: { threshold: 5, cooldownMs: 30_000 },
|
|
225
225
|
});
|
|
@@ -237,7 +237,7 @@ to the same upstream and should trip together.
|
|
|
237
237
|
|
|
238
238
|
Upload with `FormData`; download by asking for the body you want:
|
|
239
239
|
|
|
240
|
-
```ts
|
|
240
|
+
```ts fragment
|
|
241
241
|
const form = new FormData();
|
|
242
242
|
form.append("file", Bun.file("./invoice.pdf"));
|
|
243
243
|
await Client.post("https://api.example.com/v1/documents", form);
|
|
@@ -255,7 +255,7 @@ const pdf = await Client.get("https://api.example.com/v1/documents/doc_1", undef
|
|
|
255
255
|
`onResponse` runs after every 2xx with the `ResponseContext`. Both take one function
|
|
256
256
|
or an array:
|
|
257
257
|
|
|
258
|
-
```ts
|
|
258
|
+
```ts fragment
|
|
259
259
|
export default ClientConfig({
|
|
260
260
|
onRequest: (config) => {
|
|
261
261
|
config.headers["X-Request-Id"] = crypto.randomUUID();
|
package/docs/commands.md
CHANGED
|
@@ -72,7 +72,7 @@ signature's first token is the name; `{arg}` is required, `{arg?}` optional,
|
|
|
72
72
|
`{arg=default}` has a default, `{--flag}` is a boolean flag, and `{--flag=}` /
|
|
73
73
|
`{--flag=default}` is a string flag.
|
|
74
74
|
|
|
75
|
-
```typescript
|
|
75
|
+
```typescript fragment
|
|
76
76
|
// in a service provider or bootstrap script
|
|
77
77
|
const runner = app.container.tryMake("commands");
|
|
78
78
|
|
|
@@ -110,7 +110,7 @@ so it wins a name collision. The directory is configurable via
|
|
|
110
110
|
|
|
111
111
|
To register a folder from somewhere else, call `discover()` yourself:
|
|
112
112
|
|
|
113
|
-
```typescript
|
|
113
|
+
```typescript fragment
|
|
114
114
|
// in a service provider or bootstrap script
|
|
115
115
|
await runner.discover("./vendor/acme/commands");
|
|
116
116
|
```
|
|
@@ -124,7 +124,7 @@ returns the list of registered names.
|
|
|
124
124
|
The `Command` base class provides coloured output helpers and interactive
|
|
125
125
|
prompts. The prompts read from stdin and only work on a real TTY:
|
|
126
126
|
|
|
127
|
-
```typescript
|
|
127
|
+
```typescript fragment
|
|
128
128
|
// inside a command's run()
|
|
129
129
|
this.info("Success"); // green
|
|
130
130
|
this.warn("Heads up"); // yellow
|
|
@@ -291,7 +291,7 @@ Dev processes
|
|
|
291
291
|
Your app has the last word. `app.dev.disable` removes a process by name, and
|
|
292
292
|
registering the same name again replaces it rather than adding a second tab:
|
|
293
293
|
|
|
294
|
-
```ts
|
|
294
|
+
```ts fragment
|
|
295
295
|
// config/app.ts
|
|
296
296
|
export default AppConfig({
|
|
297
297
|
dev: {
|