@orieljs/framework 0.1.0-alpha.1 → 0.1.0-alpha.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.
@@ -379,6 +379,8 @@ interface Router {
379
379
  match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | string): Route;
380
380
  redirect(from: string, to: string, status?: number): Route;
381
381
  view(uri: string, view: string, data?: Record<string, unknown>): Route;
382
+ /** Route.inertia('/about', 'About', props): a GET route that renders an Inertia page (Laravel's Route::inertia). */
383
+ inertia(uri: string, component: string, props?: Record<string, unknown>): Route;
382
384
  resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void;
383
385
  apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void;
384
386
  fallback(action: RouteAction): Route;
@@ -414,6 +416,15 @@ interface RouteModelResolver {
414
416
  resolveExplicit(model: Class<unknown>, value: string, field?: string): Promise<unknown>;
415
417
  }
416
418
  declare const RouteModelResolver: Token<RouteModelResolver>;
419
+ /**
420
+ * Route name → parameters, for the typed route() and redirect().route() helpers. Empty until `oriel route:types`
421
+ * augments it (types/routes.d.ts); while it is empty any string is accepted. The contracts themselves keep taking
422
+ * strings: the framework builds route names at run time.
423
+ */
424
+ interface RouteList {
425
+ }
426
+ /** A route name: the generated ones, or any string before `oriel route:types` has run. */
427
+ type RouteName = [keyof RouteList] extends [never] ? string : Extract<keyof RouteList, string>;
417
428
  interface UrlGenerator {
418
429
  to(path: string, query?: Record<string, unknown>, absolute?: boolean): string;
419
430
  route(name: string, parameters?: unknown, absolute?: boolean): string;
@@ -1124,38 +1135,99 @@ interface FilesystemManager extends Filesystem {
1124
1135
  }
1125
1136
  declare const FilesystemManager: Token<FilesystemManager>;
1126
1137
 
1127
- /** The Inertia page object (protocol v2). */
1138
+ /** Infinite-scroll metadata for one prop (page.scrollProps[path]). */
1139
+ interface InertiaScrollProp {
1140
+ pageName: string;
1141
+ previousPage: string | number | null;
1142
+ nextPage: string | number | null;
1143
+ currentPage: string | number | null;
1144
+ reset: boolean;
1145
+ }
1146
+ /** A once prop the client keeps between visits (page.onceProps[key]). `expiresAt` is epoch milliseconds. */
1147
+ interface InertiaOnceProp {
1148
+ prop: string;
1149
+ expiresAt: number | null;
1150
+ }
1151
+ /**
1152
+ * The Inertia page object (protocol v3, @inertiajs/core 3.x). Only component, props, url and version are always
1153
+ * present; the other fields are left out when empty or false.
1154
+ */
1128
1155
  interface InertiaPage {
1129
1156
  component: string;
1130
1157
  props: Record<string, unknown>;
1158
+ /** Path and query, never absolute: '/posts?page=2'. */
1131
1159
  url: string;
1132
- version: string | null;
1133
- encryptHistory?: boolean;
1134
- clearHistory?: boolean;
1160
+ /** '' when the app has no asset version. */
1161
+ version: string;
1162
+ sharedProps?: string[];
1135
1163
  mergeProps?: string[];
1164
+ prependProps?: string[];
1165
+ deepMergeProps?: string[];
1166
+ /** '<prop path>.<key field>', e.g. 'posts.data.id'. */
1167
+ matchPropsOn?: string[];
1168
+ /** Group name → prop paths loaded after the first render. */
1136
1169
  deferredProps?: Record<string, string[]>;
1170
+ rescuedProps?: string[];
1171
+ scrollProps?: Record<string, InertiaScrollProp>;
1172
+ onceProps?: Record<string, InertiaOnceProp>;
1173
+ clearHistory?: true;
1174
+ encryptHistory?: true;
1175
+ flash?: Record<string, unknown>;
1176
+ preserveFragment?: true;
1137
1177
  }
1138
1178
  interface InertiaResponse extends Responsable {
1139
1179
  with(key: string | Record<string, unknown>, value?: unknown): this;
1140
1180
  withViewData(key: string | Record<string, unknown>, value?: unknown): this;
1181
+ rootView(view: string): this;
1182
+ /** Flash data for the next page (page.flash), stored in the session. */
1183
+ flash(key: string | Record<string, unknown>, value?: unknown): this;
1141
1184
  }
1142
1185
  type PropCallback<T = unknown> = () => T | Promise<T>;
1186
+ /** The SSR result spliced into the root view: the `head` tags and the rendered `body`. */
1187
+ interface InertiaSsrResponse {
1188
+ head: string;
1189
+ body: string;
1190
+ }
1191
+ /** Sends a page to the SSR server. Resolves to undefined when SSR is off, unreachable or failing. */
1192
+ interface InertiaSsrGateway {
1193
+ dispatch(page: InertiaPage): Promise<InertiaSsrResponse | undefined>;
1194
+ }
1195
+ declare const InertiaSsrGateway: Token<InertiaSsrGateway>;
1143
1196
  interface InertiaFactory {
1144
1197
  render(component: string, props?: Record<string, unknown>): InertiaResponse;
1145
1198
  share(key: string | Record<string, unknown>, value?: unknown): void;
1199
+ /** A shared once prop: sent on the first visit, then kept by the client. */
1200
+ shareOnce(key: string, callback: PropCallback): void;
1146
1201
  getShared(key?: string): unknown;
1147
- version(version: string | (() => string | Promise<string>)): void;
1202
+ flushShared(): void;
1203
+ version(version: string | null | (() => string | null | Promise<string | null>)): void;
1204
+ getVersion(): Promise<string>;
1205
+ setRootView(view: string): void;
1148
1206
  /** Only evaluated on partial reloads that ask for it. */
1149
1207
  optional<T>(callback: PropCallback<T>): unknown;
1150
1208
  /** Loaded in a follow-up request after the first render. */
1151
1209
  defer<T>(callback: PropCallback<T>, group?: string): unknown;
1152
1210
  /** Always included, even in partial reloads. */
1153
1211
  always<T>(value: T | PropCallback<T>): unknown;
1154
- /** Merged with the existing client-side value instead of replacing it. */
1212
+ /** Appended to the existing client-side value instead of replacing it. */
1155
1213
  merge<T>(value: T | PropCallback<T>): unknown;
1156
- /** 409 + X-Inertia-Location for external redirects. */
1214
+ /** Deep-merged with the existing client-side value. */
1215
+ deepMerge<T>(value: T | PropCallback<T>): unknown;
1216
+ /** Resolved once, then remembered by the client. */
1217
+ once<T>(callback: PropCallback<T>): unknown;
1218
+ /** Infinite scroll over a paginator: merged page by page, with scroll metadata. */
1219
+ scroll<T>(value: T | PropCallback<T>, wrapper?: string): unknown;
1220
+ /** Flash data for the next page (page.flash), stored in the session. */
1221
+ flash(key: string | Record<string, unknown>, value?: unknown): this;
1222
+ encryptHistory(encrypt?: boolean): void;
1223
+ /** The next page tells the client to clear its encrypted history. */
1224
+ clearHistory(): void;
1225
+ /** The next page keeps the URL fragment of the request that redirected to it. */
1226
+ preserveFragment(): void;
1227
+ /** 409 + X-Inertia-Location for Inertia requests, a plain 302 otherwise. */
1157
1228
  location(url: string): Response;
1158
- setRootView(view: string): void;
1229
+ /** Redirect back (Inertia.flash('saved', true).back()). */
1230
+ back(fallback?: string, status?: number): RedirectResponse;
1159
1231
  }
1160
1232
  declare const InertiaFactory: Token<InertiaFactory>;
1161
1233
 
@@ -1209,4 +1281,4 @@ interface LiveManager {
1209
1281
  }
1210
1282
  declare const LiveManager: Token<LiveManager>;
1211
1283
 
1212
- export { type AbilityCallback, type Abstract, type ActionMethods, type Address, Application, type Arrayable, type Attachment, AuthFactory, type Authenticatable, type AuthenticationError, type Batch, BatchRepository, type BodyInit, BusDispatcher, CacheManager, type CacheRepository, type Class, ClassRegistry, type ClosureCommand, type Command, type CommandContext, type Concrete, type ConfigCallbacks, ConfigRepository, ConsoleKernel, Container, type Content, type ControllerAction, type Cookie, CookieJar, type Credentials, CurrentRoute, type DatabaseConnection, DatabaseManager, type DriverName, Encrypter, type Enumerable, type Envelope, type ErrorKind, EventDispatcher, ExceptionCallbacks, ExceptionHandler, type ExceptionsConfigurator, type Factory, type FailedJob, FailedJobProvider, type Filesystem, FilesystemManager, Gate, type Guard, Hasher, type HeadersInit, type Htmlable, HttpKernel, HttpRequest, InertiaFactory, type InertiaPage, type InertiaResponse, type Job, type Jsonable, type Listener, type ListenerClass, type LiveEffects, LiveManager, type LiveSnapshot, type LiveUpdateRequest, type LiveUpdateResponse, type Lock, type LogLevel, LogManager, type Logger, MailManager, type MailRecipient, type MailTransport, type Mailable, type Mailer, type MessageBag, type Middleware, MiddlewareCallbacks, type MiddlewareClass, type MiddlewareConfigurator, type MiddlewareReference, type ModelInstance, type ModelNotFoundError, type ModelStatic, type MustVerifyEmail, type Next, type Notifiable, type Notification, type NotificationChannel, NotificationDispatcher, type Operator, type OptionValue, type OrielError, type OutgoingMessage, PasswordBroker, type PasswordStatus, type PendingBatch, type PendingBatchOptions, type PendingChain, type PendingMail, type Pipe, type PipeClosure, type PipeNext, type Pipeline, PipelineFactory, type PropCallback, type PutOptions, type QueryBuilder, type Queue, type QueueJob, QueueManager, type QueuePayload, type RedirectResponse, Redirector, type ResourceOptions, type Responsable, ResponseFactory, type Route, type RouteAction, type RouteClosure, RouteModelResolver, type RouteRegistrar, Router, RoutingPaths, type Row, type RuleCallback, type Rules, Schedule, type ScheduledEvent, type SentMessage, type ServiceProvider, type ServiceProviderClass, Session, type SessionHandler, type ShouldQueue, type StatefulGuard, type Token, type UploadedFile, UrlGenerator, type UserProvider, type ValidationError, ValidationFactory, type ValidationRule, type Validator, type View, ViewFactory, token };
1284
+ export { type AbilityCallback, type Abstract, type ActionMethods, type Address, Application, type Arrayable, type Attachment, AuthFactory, type Authenticatable, type AuthenticationError, type Batch, BatchRepository, type BodyInit, BusDispatcher, CacheManager, type CacheRepository, type Class, ClassRegistry, type ClosureCommand, type Command, type CommandContext, type Concrete, type ConfigCallbacks, ConfigRepository, ConsoleKernel, Container, type Content, type ControllerAction, type Cookie, CookieJar, type Credentials, CurrentRoute, type DatabaseConnection, DatabaseManager, type DriverName, Encrypter, type Enumerable, type Envelope, type ErrorKind, EventDispatcher, ExceptionCallbacks, ExceptionHandler, type ExceptionsConfigurator, type Factory, type FailedJob, FailedJobProvider, type Filesystem, FilesystemManager, Gate, type Guard, Hasher, type HeadersInit, type Htmlable, HttpKernel, HttpRequest, InertiaFactory, type InertiaOnceProp, type InertiaPage, type InertiaResponse, type InertiaScrollProp, InertiaSsrGateway, type InertiaSsrResponse, type Job, type Jsonable, type Listener, type ListenerClass, type LiveEffects, LiveManager, type LiveSnapshot, type LiveUpdateRequest, type LiveUpdateResponse, type Lock, type LogLevel, LogManager, type Logger, MailManager, type MailRecipient, type MailTransport, type Mailable, type Mailer, type MessageBag, type Middleware, MiddlewareCallbacks, type MiddlewareClass, type MiddlewareConfigurator, type MiddlewareReference, type ModelInstance, type ModelNotFoundError, type ModelStatic, type MustVerifyEmail, type Next, type Notifiable, type Notification, type NotificationChannel, NotificationDispatcher, type Operator, type OptionValue, type OrielError, type OutgoingMessage, PasswordBroker, type PasswordStatus, type PendingBatch, type PendingBatchOptions, type PendingChain, type PendingMail, type Pipe, type PipeClosure, type PipeNext, type Pipeline, PipelineFactory, type PropCallback, type PutOptions, type QueryBuilder, type Queue, type QueueJob, QueueManager, type QueuePayload, type RedirectResponse, Redirector, type ResourceOptions, type Responsable, ResponseFactory, type Route, type RouteAction, type RouteClosure, type RouteList, RouteModelResolver, type RouteName, type RouteRegistrar, Router, RoutingPaths, type Row, type RuleCallback, type Rules, Schedule, type ScheduledEvent, type SentMessage, type ServiceProvider, type ServiceProviderClass, Session, type SessionHandler, type ShouldQueue, type StatefulGuard, type Token, type UploadedFile, UrlGenerator, type UserProvider, type ValidationError, ValidationFactory, type ValidationRule, type Validator, type View, ViewFactory, token };
package/dist/contracts.js CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  HttpKernel,
23
23
  HttpRequest,
24
24
  InertiaFactory,
25
+ InertiaSsrGateway,
25
26
  LiveManager,
26
27
  LogManager,
27
28
  MailManager,
@@ -41,7 +42,7 @@ import {
41
42
  ValidationFactory,
42
43
  ViewFactory,
43
44
  token
44
- } from "./chunk-K6MAA3RM.js";
45
+ } from "./chunk-3ZRPBRAE.js";
45
46
  export {
46
47
  Application,
47
48
  AuthFactory,
@@ -66,6 +67,7 @@ export {
66
67
  HttpKernel,
67
68
  HttpRequest,
68
69
  InertiaFactory,
70
+ InertiaSsrGateway,
69
71
  LiveManager,
70
72
  LogManager,
71
73
  MailManager,