@tolki/ts 1.1.0 → 1.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.
- package/README.md +123 -10
- package/dist/routes.d.ts +4 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +9 -4
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -861,7 +861,9 @@ export interface PostSummaryResource {
|
|
|
861
861
|
|
|
862
862
|
A backed enum's `->value` publishes its `{Name}Type`, and its `->name` publishes its `{Name}Kind`. A unit enum's `->name` publishes its `{Name}Type`, because its values are its case names.
|
|
863
863
|
|
|
864
|
-
A case you write out can send only its own value, so it publishes that value: `PostStatus::Published->value` publishes `1`, and `PostStatus::Published->name` publishes `'Published'`. A ternary between two cases publishes both values. `PostStatus::from($value)->value` publishes `PostStatusType`, and after `PostStatus::tryFrom()`, `?->value` publishes `PostStatusType | null`. A method you call on a case publishes its return type.
|
|
864
|
+
A case you write out can send only its own value, so it publishes that value: `PostStatus::Published->value` publishes `1`, and `PostStatus::Published->name` publishes `'Published'`. A ternary between two cases publishes both values. Beside a read of the same enum, the alias already holds a case's value, so the value is left out: `$draft ? PostStatus::Draft->value : $this->status->value` publishes `PostStatusType`, not `0 | PostStatusType`. `PostStatus::from($value)->value` publishes `PostStatusType`, and after `PostStatus::tryFrom()`, `?->value` publishes `PostStatusType | null`. A method you call on a case publishes its return type.
|
|
865
|
+
|
|
866
|
+
A `->value` or `->name` read off a method call, `$this->m()`, `$this::m()`, `self::m()`, `static::m()` or `parent::m()`, publishes the value or name of each case that method returns, when neither its return type nor a `@return` tag names a class, as with no return type or `mixed`. When `draft(): mixed` returns `PostStatus::Draft`, `$this->draft()->value` publishes `0`. A method declared `: PostStatus`, or documented `@return PostStatus`, keeps the alias, so the read publishes `PostStatusType`. A `null` the method returns is left out, as it is for any `->` read, so `->value` off a method returning `$draft ? PostStatus::Draft : null` publishes `0`, and `?->value` publishes `0 | null`. A method with no return type that can end without returning a value leaves the read `unknown`.
|
|
865
867
|
|
|
866
868
|
In an API resource, `PostStatus::cases()` publishes a list of the alias. A map over the cases publishes what its callback reads from each case, with or without a type hint:
|
|
867
869
|
|
|
@@ -1067,6 +1069,22 @@ A unit enum publishes each case name as its value, so `values` returns its case
|
|
|
1067
1069
|
|
|
1068
1070
|
`values` and `keys` read the `_cases` list, so they need `enums.metadata_enabled` and return an empty array without it. `defineEnum()` doesn't add `values` or `keys` to the enum. An enum that publishes its own `values()` or `keys()` static method keeps that published value under the name, so `Status.values` is the static method's published output while `values(Status)` returns the case values.
|
|
1069
1071
|
|
|
1072
|
+
### Bundling
|
|
1073
|
+
|
|
1074
|
+
An enum nobody uses drops out of your bundle in Vite (Rolldown), Rollup, webpack and Rspack, because `defineEnum` and the other runtime utilities are marked as free of side effects, except `from`, which throws on an unknown value and is always kept.
|
|
1075
|
+
|
|
1076
|
+
esbuild doesn't follow that mark across files, so it keeps the call unless the call site says it is safe to remove:
|
|
1077
|
+
|
|
1078
|
+
```typescript
|
|
1079
|
+
export const Status = /* @__PURE__ */ defineEnum({
|
|
1080
|
+
Active: "active",
|
|
1081
|
+
Inactive: "inactive",
|
|
1082
|
+
_cases: ["Active", "Inactive"],
|
|
1083
|
+
});
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
Rspack also needs the call-site form when the same module derives a list from the enum, such as `export const STATUSES = /* @__PURE__ */ values(Status)`. [Bundling and Tree-Shaking](https://tolki.abe.dev/tree-shaking.html) lists every bundler.
|
|
1087
|
+
|
|
1070
1088
|
### Vite Plugin
|
|
1071
1089
|
|
|
1072
1090
|
The `@tolki/ts` package ships a Vite plugin that republishes enums and routes automatically during development. See the [Vite Plugin documentation](https://tolki.abe.dev/ts/vite-plugin.html).
|
|
@@ -1669,7 +1687,9 @@ A custom cast without [`#[TsType]`](https://tolki.abe.dev/ts/custom-types.html)
|
|
|
1669
1687
|
- **A bare `array` or `object`, on a cast without the interface**: `get()`'s type, where `get()` returns a value object or an array shape. `?object` and `array|object` work the same way. Over a scalar `get()`, a bare `array` publishes `unknown[] | Record<string, unknown>`.
|
|
1670
1688
|
- **Any other declared type**: that type, such as `string`.
|
|
1671
1689
|
|
|
1672
|
-
Laravel calls `get()` for a `NULL` column too, so a nullable column cast to a class whose `get()` declares a non-null return type publishes no `| null`. For a `coordinate_data` column that may be `NULL`, cast with a `get()` that always returns a `Coordinate`, the model publishes `coordinate_data: { lat: number; lng: number }`. Laravel sends a `null` from `get()` without calling `serialize()`, so a `get()` that declares a nullable return type, or returns `null` itself, adds `| null` to the `serialize()` type.
|
|
1690
|
+
Laravel calls `get()` for a `NULL` column too, so a nullable column cast to a class whose `get()` declares a non-null return type publishes no `| null`. For a `coordinate_data` column that may be `NULL`, cast with a `get()` that always returns a `Coordinate`, the model publishes `coordinate_data: { lat: number; lng: number }`. Laravel sends a `null` from `get()` without calling `serialize()`, so on a nullable column, a `get()` that declares a nullable return type, or returns `null` itself, adds `| null` to the `serialize()` type.
|
|
1691
|
+
|
|
1692
|
+
A `NOT NULL` column never holds a `NULL`, so it publishes the `serialize()` type alone. With a cast whose `get()` returns `?CarbonImmutable` and whose `serialize()` returns `string`, a `NOT NULL` `opens_at` column publishes `opens_at: string`, and a nullable `closes_at` column publishes `closes_at: string | null`. A `Castable` that names the cast publishes the same way, and a `null` that `serialize()` itself declares or returns stays on either column. A `get()` that turns a stored value into `null`, such as an empty string, still sends that `null` from a `NOT NULL` column, which the type leaves out. Type such a column with [`#[TsCasts]`](#tscasts).
|
|
1673
1693
|
|
|
1674
1694
|
When `get()`'s native type is missing or vague, such as a bare `array`, the `@return` docblock sets the type, so `@return list<LegDto>` publishes a list of `LegDto`'s public properties, the shape `json_encode()` writes. A `@return` that names a model, such as `list<User>`, or another class that doesn't publish as an inline shape keeps `unknown[]`. A `get()` that declares neither publishes `unknown`.
|
|
1675
1695
|
|
|
@@ -1846,7 +1866,7 @@ A column or accessor typed as a backed or unit enum publishes in two ways:
|
|
|
1846
1866
|
- **The main interface**: `User` uses the enum's `{Enum}Type` union, which is how Laravel serializes the enum when it converts a model to JSON.
|
|
1847
1867
|
- **A parallel `Resource` interface**: `{Model}Resource` types the same property as [`AsEnum<typeof Enum>`](https://tolki.abe.dev/ts/enums.html#type-reference), and the split template adds `{Model}MutatorsResource` for accessors and `{Model}AllResource`. `AsEnum` is the shape you get once the raw value is a full enum instance, either from `Status.from(user.status)` or from an API resource that serialized the enum with [`EnumResource`](https://tolki.abe.dev/ts/enum-api-resource.html).
|
|
1848
1868
|
|
|
1849
|
-
A property is rewritten only when its type is a single enum or a list of one, either optionally `| null`. A list becomes `AsEnum<typeof Enum>[]`. A shape, or a union with other types, keeps its own type.
|
|
1869
|
+
A property is rewritten only when its type is a single enum or a list of one, either optionally `| null`. A list becomes `AsEnum<typeof Enum>[]`. A shape, or a union with other types, keeps its own type. An accessor that returns an enum's `->value` or `->name` keeps the enum's alias in `{Model}Resource` and `{Model}MutatorsResource`, because it sends the scalar, not the enum. Only an accessor that returns the enum itself takes `AsEnum<typeof Enum>`.
|
|
1850
1870
|
|
|
1851
1871
|
This helper resolves the raw `role` value into the type `UserResource` declares:
|
|
1852
1872
|
|
|
@@ -3043,6 +3063,10 @@ App\Http\Resources\PostResource: The value on line 31 leaves out `$this->opaqueT
|
|
|
3043
3063
|
|
|
3044
3064
|
Give the method a return type or a `@return` docblock, and its value joins the union again. An inline [`@var`](#typing-a-variable-with-var) that types the variable also removes the warning. `--quiet` hides every warning.
|
|
3045
3065
|
|
|
3066
|
+
Once the value is typed, an empty `[]` beside a list publishes the list alone. With `opaqueTags()` declared `@return list<string>`, `tags` publishes `string[]`.
|
|
3067
|
+
|
|
3068
|
+
A `@return` docblock that types the key, on `toArray()` or on a method it spreads, also types the value left out. The docblock's type takes that value's place beside the values the body types. Under `score: int|string|null`, a `score` whose body types `number | null` and leaves one more value out publishes `number | null | string`. `ts:publish` prints no warning for a value the docblock types. A value it doesn't type, such as one under a `mixed` entry or under a key the docblock doesn't name, still warns. [Return Branches and `@return` Shapes](#return-branches-and-return-shapes) shows an example.
|
|
3069
|
+
|
|
3046
3070
|
`ts:publish` doesn't analyze a class again while the [generation cache](https://tolki.abe.dev/ts/generating-cache.html) holds it. A class the cache serves prints none of these warnings, nor the first-class callable warning above, so run `php artisan ts:publish --fresh` to see every one.
|
|
3047
3071
|
|
|
3048
3072
|
### Method Calls, Variables, and Collections
|
|
@@ -4178,7 +4202,7 @@ A variable that starts from `parent::toArray($request)` works the same way. See
|
|
|
4178
4202
|
|
|
4179
4203
|
#### Trait Method Spread
|
|
4180
4204
|
|
|
4181
|
-
Spread a trait method's return into `toArray()` with `...$this->method()`. Its body publishes the same types it would in `toArray()`, and its `@return array{...}` docblock types
|
|
4205
|
+
Spread a trait method's return into `toArray()` with `...$this->method()`. Its body publishes the same types it would in `toArray()`, and its `@return array{...}` docblock types what the body can't:
|
|
4182
4206
|
|
|
4183
4207
|
```php
|
|
4184
4208
|
trait IncludesMorphValue
|
|
@@ -4257,6 +4281,27 @@ trait IncludesExtras
|
|
|
4257
4281
|
|
|
4258
4282
|
A key the body can't type, and that neither the `@return` docblock nor `#[TsCasts]` covers, publishes `unknown`.
|
|
4259
4283
|
|
|
4284
|
+
Keys follow PHP's order, so a later write replaces an earlier one with the same name, whether a key or a spread writes it. Here the resource wraps a value object whose `title` is a `string`, and the second spread replaces the `author` that `credited()` returns:
|
|
4285
|
+
|
|
4286
|
+
```php
|
|
4287
|
+
public function toArray(Request $request): array
|
|
4288
|
+
{
|
|
4289
|
+
return [
|
|
4290
|
+
'byline' => [
|
|
4291
|
+
...$this->credited(),
|
|
4292
|
+
...['author' => $this->resource->title],
|
|
4293
|
+
],
|
|
4294
|
+
];
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
private function credited(): array
|
|
4298
|
+
{
|
|
4299
|
+
return ['id' => 1, 'author' => $this->resource->author];
|
|
4300
|
+
}
|
|
4301
|
+
```
|
|
4302
|
+
|
|
4303
|
+
The property publishes `byline: { id: number; author: string }`. When a spread always writes a key but the package can't type its value, the key publishes `unknown`, not the type it replaced. A spread of a local that sets the key only inside an `if` may leave the earlier value in place, so the key publishes both types. A merge is the exception, because Laravel never lets a merged key replace a key written before the merge, or a key written after the merge replace the merged one. See [Merge Operations](#merge-operations).
|
|
4304
|
+
|
|
4260
4305
|
Trait spreads carry through inheritance. When a parent resource spreads a trait method and a child spreads `...parent::toArray($request)`, the child gets the keys the trait contributed.
|
|
4261
4306
|
|
|
4262
4307
|
#### Bare Method-Call Return
|
|
@@ -4542,12 +4587,67 @@ export interface PostPermissionsResource {
|
|
|
4542
4587
|
|
|
4543
4588
|
Both forms of `@return` count:
|
|
4544
4589
|
|
|
4545
|
-
- **An `array{...}` shape**: each key gets its own type, and a key written `key?:` also becomes optional. A string or number literal type, such as `'draft'|'live'` or `1|2|3`, publishes as written.
|
|
4546
|
-
- **`array<string, V>`**: `V`
|
|
4590
|
+
- **An `array{...}` shape**: each key gets its own type, and a key written `key?:` also becomes optional. A string or number literal type, such as `'draft'|'live'` or `1|2|3`, publishes as written. It also narrows a body type that admits every literal it lists, so `label: 'early'|'late'` over a `string` column publishes `label: 'early' | 'late'`.
|
|
4591
|
+
- **`array<string, V>`**: `V` is the entry for every key, and types each one as a shape's entry would.
|
|
4547
4592
|
|
|
4548
4593
|
`toArray()`'s own `@return array{...}` fills keys the same way.
|
|
4549
4594
|
|
|
4550
|
-
|
|
4595
|
+
Apart from the literal narrowing above, the body wins wherever it's specific, so a stale `@return` can't overwrite a type the package already knows. The docblock types what the body can't, at any depth:
|
|
4596
|
+
|
|
4597
|
+
- a key the body left vague, such as `unknown`, `unknown[]`, or `Record<string, unknown>`
|
|
4598
|
+
- a member or a list element the body couldn't type, inside a key it did type
|
|
4599
|
+
- a value the body [left out of a union](#values-left-out-of-a-union), beside the values it typed
|
|
4600
|
+
- an [interpolated key's](#interpolated-keys) value that the body left `unknown | undefined`
|
|
4601
|
+
|
|
4602
|
+
It keeps any `| null` the body found, and it doesn't add what the body proves Laravel never sends. An entry that only adds `| null` to the body's type, as `label` does below, publishes the body's type. A shape inside a key keeps the keys the body writes: a docblock key the body never writes is left out, unless the docblock marks it `key?:` or the array may hold keys the package can't name, such as a spread of an array with no element type.
|
|
4603
|
+
|
|
4604
|
+
This resource wraps a `ContactSheet` value object, as [Resources That Wrap Other Classes](#resources-that-wrap-other-classes) describes. Its `contacts` property lists `MailRecipient` objects, whose `name` is a `?string`. Its `extras` property is an `array` with no element type, `hint` has no type, and `title` is a `?string`:
|
|
4605
|
+
|
|
4606
|
+
```php
|
|
4607
|
+
/**
|
|
4608
|
+
* @property-read ContactSheet $resource
|
|
4609
|
+
*/
|
|
4610
|
+
class ContactSheetResource extends JsonResource
|
|
4611
|
+
{
|
|
4612
|
+
/**
|
|
4613
|
+
* @return array{
|
|
4614
|
+
* rows: list<array{name: string|null, locale: string}>,
|
|
4615
|
+
* summary: array{label: string|null, count: int|null}
|
|
4616
|
+
* }
|
|
4617
|
+
*/
|
|
4618
|
+
public function toArray(Request $request): array
|
|
4619
|
+
{
|
|
4620
|
+
$sheet = $this->resource;
|
|
4621
|
+
|
|
4622
|
+
return [
|
|
4623
|
+
'rows' => array_map(
|
|
4624
|
+
fn (MailRecipient $r) => [
|
|
4625
|
+
...$sheet->extras,
|
|
4626
|
+
'name' => $r->name,
|
|
4627
|
+
],
|
|
4628
|
+
$sheet->contacts,
|
|
4629
|
+
),
|
|
4630
|
+
'summary' => [
|
|
4631
|
+
'label' => (string) $sheet->title,
|
|
4632
|
+
'count' => $sheet->title !== null
|
|
4633
|
+
? $sheet->hint
|
|
4634
|
+
: null,
|
|
4635
|
+
],
|
|
4636
|
+
];
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
```
|
|
4640
|
+
|
|
4641
|
+
Each row takes `locale` from the docblock, because the spread may hold it. `label` keeps the body's `string`, since `(string)` never sends `null`, and `count` takes the docblock's `number` in place of `$sheet->hint`:
|
|
4642
|
+
|
|
4643
|
+
```typescript
|
|
4644
|
+
export interface ContactSheetResource {
|
|
4645
|
+
rows: { name: string | null; locale: string }[];
|
|
4646
|
+
summary: { label: string; count: number | null };
|
|
4647
|
+
}
|
|
4648
|
+
```
|
|
4649
|
+
|
|
4650
|
+
Where a key's value has a different shape on each path, each shape stays its own member of the union, and the docblock adds keys only to a shape that may hold them. Under the same entry as `rows`, a row that one path builds as `['name' => $r->name]`, and another builds with `...$sheet->extras`, publishes `({ name: string | null } | { name: string | null; locale: string })[]`.
|
|
4551
4651
|
|
|
4552
4652
|
A shape value that names a model, an enum, or an API resource keeps it at any depth, and the file imports it. Here `tags` is a nullable column cast to `'array'`, which publishes `unknown[] | null` on its own, and `json_decode()` returns a value the package can't type:
|
|
4553
4653
|
|
|
@@ -4579,7 +4679,7 @@ export interface PostExtrasResource {
|
|
|
4579
4679
|
}
|
|
4580
4680
|
```
|
|
4581
4681
|
|
|
4582
|
-
A spread method's
|
|
4682
|
+
A key that a spread method's `@return` fills because the body left it vague keeps its classes only when you spread the method at the top level of `toArray()`. Spread inside a nested array, as in `'meta' => [...$this->extras()]`, each model, enum, or API resource such a fill names publishes `unknown`. Type such a key with `#[TsCasts]` and an `import`. A key the body typed keeps its classes wherever you spread the method.
|
|
4583
4683
|
|
|
4584
4684
|
A name that isn't a PHP class, such as a type you declare only in TypeScript, publishes as written in a spread method's `@return`. In `toArray()`'s own `@return`, the key stays `unknown`, so type it with `#[TsCasts]`.
|
|
4585
4685
|
|
|
@@ -5800,7 +5900,7 @@ export interface PostScheduled {
|
|
|
5800
5900
|
}
|
|
5801
5901
|
```
|
|
5802
5902
|
|
|
5803
|
-
The body still wins wherever it types a value. The docblock only
|
|
5903
|
+
The body still wins wherever it types a value, so a stale `@return` can't overwrite a type the body already found. The docblock types only what the body can't, at any depth, such as a key the body left `unknown`, a member inside a key it typed, or a value it left out of a union. It follows the same rules as an [API resource's `@return`](https://tolki.abe.dev/ts/api-resources.html#return-branches-and-return-shapes). A `key?:` entry in the docblock makes that key optional.
|
|
5804
5904
|
|
|
5805
5905
|
A spread helper that builds its keys by interpolation, such as `"{$name}_tag"`, adds an index signature to the interface, for example ``[key: `${string}_tag`]: string | undefined``. When the helper's body can't type the values, its `@return array<string, V>` docblock types them. [Interpolated Keys](https://tolki.abe.dev/ts/api-resources.html#interpolated-keys) on the API Resources page describes how the event's `#[TsCasts]` and `extends` clause then apply.
|
|
5806
5906
|
|
|
@@ -8761,6 +8861,19 @@ export const store = annotateRequestPayload<StorePostRequest>()(
|
|
|
8761
8861
|
);
|
|
8762
8862
|
```
|
|
8763
8863
|
|
|
8864
|
+
### Bundling
|
|
8865
|
+
|
|
8866
|
+
A route nobody uses drops out of your bundle: `defineRoute`, `getRouteDefaults` and the other runtime helpers are marked as free of side effects, except `setRouteDefaults`, `addRouteDefault` and `resetRouteDefaults`, which change shared state and are always kept. A plain `export const index = defineRoute({...})` drops in Vite (Rolldown), Rollup, webpack and Rspack. esbuild keeps it unless the call site is marked:
|
|
8867
|
+
|
|
8868
|
+
```typescript
|
|
8869
|
+
export const index = /* @__PURE__ */ defineRoute({
|
|
8870
|
+
url: "/users",
|
|
8871
|
+
methods: ["get"],
|
|
8872
|
+
});
|
|
8873
|
+
```
|
|
8874
|
+
|
|
8875
|
+
The curried shapes, `annotatePageProps<T>()(defineRoute({...}))` and `annotateRequestPayload<T>()(defineRoute({...}))`, drop in Rollup and Rspack as they are. Rolldown, esbuild and webpack need `/* @__PURE__ */` before each call: the outer one and the inner `defineRoute`. [Bundling and Tree-Shaking](https://tolki.abe.dev/tree-shaking.html) lists every bundler.
|
|
8876
|
+
|
|
8764
8877
|
### Filtering & Excluding Routes
|
|
8765
8878
|
|
|
8766
8879
|
These settings leave routes out of the published output:
|
|
@@ -9406,7 +9519,7 @@ Outside those cases, `analyze()` runs the same inference that resources, broadca
|
|
|
9406
9519
|
|
|
9407
9520
|
`analyze()` and `ts:publish` both type the patterns these docs describe, including [a local you write more than once](https://tolki.abe.dev/ts/api-resources.html#local-variables-and-narrowing). Anything else, such as an expression neither can follow or a local that a reference can write, comes back `unknown` rather than a guess.
|
|
9408
9521
|
|
|
9409
|
-
Two cases don't widen to `unknown`. [A conditional's default that can't be typed](https://tolki.abe.dev/ts/api-resources.html#passing-a-default-argument) leaves the value's own type in place. [A union member that can't be typed is left out](https://tolki.abe.dev/ts/api-resources.html#values-left-out-of-a-union), whether it's a ternary or `?:` arm or a value that a parameter's writes join. So `$cond ? $untypable : null` publishes `null`.
|
|
9522
|
+
Two cases don't widen to `unknown`. [A conditional's default that can't be typed](https://tolki.abe.dev/ts/api-resources.html#passing-a-default-argument) leaves the value's own type in place. [A union member that can't be typed is left out](https://tolki.abe.dev/ts/api-resources.html#values-left-out-of-a-union), whether it's a ternary or `?:` arm or a value that a parameter's writes join. So `$cond ? $untypable : null` publishes `null`. Where the method's `@return` types the key that holds it, the docblock's type takes the left-out value's place beside the `null`, as [Values Left Out of a Union](https://tolki.abe.dev/ts/api-resources.html#values-left-out-of-a-union) describes.
|
|
9410
9523
|
|
|
9411
9524
|
### Configuration Reference
|
|
9412
9525
|
|
package/dist/routes.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export declare function annotateRequestPayload<TRequestPayload>(): <TMethods ext
|
|
|
45
45
|
* the caller doesn't provide them. Mirrors Laravel's `URL::defaults()`.
|
|
46
46
|
* Accepts a static object or a factory function for lazy evaluation.
|
|
47
47
|
*
|
|
48
|
+
* @sideEffects state - Replaces the module-level route defaults.
|
|
48
49
|
* @param defaults - A record of parameter names to default values, or a factory function.
|
|
49
50
|
*/
|
|
50
51
|
export declare function setRouteDefaults(defaults: Record<string, string | number | boolean> | (() => Record<string, string | number | boolean>)): void;
|
|
@@ -53,6 +54,7 @@ export declare function setRouteDefaults(defaults: Record<string, string | numbe
|
|
|
53
54
|
*
|
|
54
55
|
* If a default already exists for the given parameter name, it is overwritten.
|
|
55
56
|
*
|
|
57
|
+
* @sideEffects state - Updates the module-level route defaults.
|
|
56
58
|
* @param key - The parameter name.
|
|
57
59
|
* @param value - The default value.
|
|
58
60
|
*/
|
|
@@ -65,6 +67,8 @@ export declare function addRouteDefault(key: string, value: string | number | bo
|
|
|
65
67
|
export declare function getRouteDefaults(): Record<string, string | number | boolean>;
|
|
66
68
|
/**
|
|
67
69
|
* Reset route defaults to an empty object (useful for testing).
|
|
70
|
+
*
|
|
71
|
+
* @sideEffects state - Clears the module-level route defaults.
|
|
68
72
|
*/
|
|
69
73
|
export declare function resetRouteDefaults(): void;
|
|
70
74
|
/**
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACpB,MAAM,cAAc,CAAC;AAYtB,YAAY,EACR,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,GACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACpB,MAAM,cAAc,CAAC;AAYtB,YAAY,EACR,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,GACpB,CAAC;AAEF;;;;;;;;;;;;;;;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;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AA8YD;;;;;;;;;GASG;AAEH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GAC5B,iBAAiB,CAWnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,WAAW,CACvB,KAAK,CAAC,QAAQ,SAAS,SAAS,MAAM,EAAE,EACxC,KAAK,CAAC,KAAK,SAAS,SAAS,YAAY,EAAE,GAAG,SAAS,EAAE,EACzD,KAAK,CAAC,UAAU,SAAS,kBAAkB,GAAG,SAAS,GAAG,SAAS,EAEnE,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,GACrD,iBAAiB,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,CAkGhD"}
|
package/dist/routes.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { isArray as e, isBoolean as t, isFunction as n, isNull as r, isNumber as i, isObject as a, isString as o, isUndefined as s } from "@tolki/utils";
|
|
2
2
|
// src/routes.ts
|
|
3
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3
4
|
function c() {
|
|
4
|
-
return function(e) {
|
|
5
|
+
return /* @__NO_SIDE_EFFECTS__ */ function(e) {
|
|
5
6
|
return e;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
9
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
10
|
function l() {
|
|
9
|
-
return function(e) {
|
|
11
|
+
return /* @__NO_SIDE_EFFECTS__ */ function(e) {
|
|
10
12
|
return e;
|
|
11
13
|
};
|
|
12
14
|
}
|
|
@@ -21,6 +23,7 @@ function p(e, t) {
|
|
|
21
23
|
[e]: t
|
|
22
24
|
});
|
|
23
25
|
}
|
|
26
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
24
27
|
function m() {
|
|
25
28
|
return { ...d() };
|
|
26
29
|
}
|
|
@@ -160,6 +163,7 @@ function S(e, t) {
|
|
|
160
163
|
}
|
|
161
164
|
};
|
|
162
165
|
}
|
|
166
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
163
167
|
function C(e, t) {
|
|
164
168
|
let n = t?.mergeQuery ? "mergeQuery" : "_query", r = t?.[n] ?? {};
|
|
165
169
|
return {
|
|
@@ -170,6 +174,7 @@ function C(e, t) {
|
|
|
170
174
|
}
|
|
171
175
|
};
|
|
172
176
|
}
|
|
177
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
173
178
|
function w(e) {
|
|
174
179
|
let t = e.args ?? [], n = e.methods[0] ?? "get", r = (...r) => {
|
|
175
180
|
let [i, a] = y(r, t);
|
|
@@ -189,13 +194,13 @@ function w(e) {
|
|
|
189
194
|
return x(b(e.url, i, t, a), n);
|
|
190
195
|
} });
|
|
191
196
|
let a = n !== "get" && n !== "post", s = (...r) => {
|
|
192
|
-
let [i, o] = y(r, t), s = a ? C(n, o) : o;
|
|
197
|
+
let [i, o] = y(r, t), s = a ? /* @__PURE__ */ C(n, o) : o;
|
|
193
198
|
return S(b(e.url, i, t, s), n);
|
|
194
199
|
};
|
|
195
200
|
for (let n of e.methods) {
|
|
196
201
|
let r = n !== "get" && n !== "post";
|
|
197
202
|
Object.assign(s, { [n]: (...i) => {
|
|
198
|
-
let [a, o] = y(i, t), s = r ? C(n, o) : o;
|
|
203
|
+
let [a, o] = y(i, t), s = r ? /* @__PURE__ */ C(n, o) : o;
|
|
199
204
|
return S(b(e.url, a, t, s), n);
|
|
200
205
|
} });
|
|
201
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAC;AACrE,OAAO,EAEH,KAAK,MAAM,EAGd,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM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AAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CA4PR"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -5,10 +5,11 @@ import { promisify as r } from "node:util";
|
|
|
5
5
|
import { escapeShellArg as i, escapeWindowsShellArg as a } from "@tolki/utils";
|
|
6
6
|
import { normalizePath as o } from "vite";
|
|
7
7
|
// src/vite-plugin.ts
|
|
8
|
-
var s = r(e);
|
|
8
|
+
var s = /* @__PURE__ */ r(e);
|
|
9
9
|
function c(e) {
|
|
10
10
|
return process.platform === "win32" ? a(e) : i(e);
|
|
11
11
|
}
|
|
12
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
12
13
|
function l(e = {}) {
|
|
13
14
|
let { command: r = "php artisan ts:publish", filename: i = "laravel-ts-collected-files.json", directory: a = "resources/js/types/data/", runOnDevStart: l = !1, runOnBuildStart: u = !0, reload: d = !0, failOnError: f, sourceCommand: p, onBuildOnlyFunctional: m = !0, quiet: h = !0 } = e, g = p === !1 ? !1 : p ?? `${r} --source={file}`, _, v, y = /* @__PURE__ */ new Map(), b = "", x = !1, S = [], C = "[laravel-ts-publish]", w = async () => {
|
|
14
15
|
y.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A set of TypeScript utilities for the Laravel TypeScript Publish PHP package.",
|
|
5
5
|
"author": "Abraham Arango <https://github.com/abetwothree>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"tolki"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tolki/enum": "^1.2.
|
|
43
|
-
"@tolki/
|
|
44
|
-
"@tolki/
|
|
42
|
+
"@tolki/enum": "^1.2.1",
|
|
43
|
+
"@tolki/utils": "^1.6.4",
|
|
44
|
+
"@tolki/types": "^1.12.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"vite": "^8.3.5"
|