import { R as ForjaClientConfig, t as ForjaClient } from "../client-DYqmXlE_.cjs"; import { EnvironmentProviders, InjectionToken, Signal } from "@angular/core"; //#region src/angular/provider.d.ts /** * Angular injection token for the {@link ForjaClient} instance. * * You don't need to use this directly — use {@link provideForja} and * {@link injectForja} instead. */ export declare const FORJA_CLIENT: InjectionToken; /** * Provide the Forja SDK client to Angular's dependency injection system. * * Call this in your application's `providers` array (typically in `app.config.ts`) * to make the {@link ForjaClient} available via {@link injectForja}. * * @param config - API connection settings. * @param config.baseUrl - Full URL to the Forja API (e.g. `https://cms.example.com/api/v1`). * @param config.apiKey - API key with at least `Read` permission. * @param config.siteId - UUID of the site to query. * @returns Angular environment providers to include in your app config. * * @example * ```typescript * // app.config.ts * import { provideForja } from '@forjacms/client/angular'; * * export const appConfig: ApplicationConfig = { * providers: [ * provideForja({ * baseUrl: environment.cmsApiUrl, * apiKey: environment.cmsApiKey, * siteId: environment.cmsSiteId, * }), * ], * }; * ``` */ export declare function provideForja(config: ForjaClientConfig): EnvironmentProviders; /** * Inject the {@link ForjaClient} instance from Angular's DI system. * * Must be called in an injection context (component constructor, `inject()` call, * or factory function). Requires {@link provideForja} to be configured in the * application's providers. * * @returns The configured {@link ForjaClient} instance. * @throws If called outside an injection context or without {@link provideForja}. * * @example * ```typescript * import { Component } from '@angular/core'; * import { injectForja, forjaResource } from '@forjacms/client/angular'; * * @Component({ * template: ` * @if (blogs.isLoading()) {

Loading...

} * @for (blog of blogs.value()?.data ?? []; track blog.id) { *

{{ blog.slug }}

* } * `, * }) * export class BlogListComponent { * private forja = injectForja(); * blogs = forjaResource(() => this.forja.blogs.listPublished({ page: 1 })); * } * ``` */ export declare function injectForja(): ForjaClient; //#endregion //#region src/angular/resource.d.ts /** * A reactive resource that wraps an async operation with Angular signals. * * Provides `value`, `isLoading`, and `error` signals for template binding, * plus a `reload()` method to re-execute the loader. * * @typeParam T - The type of the resolved value. */ interface ForjaResource { /** The resolved value, or `undefined` while loading or after an error. */ readonly value: Signal; /** `true` while the loader is executing. */ readonly isLoading: Signal; /** The error if the loader rejected, or `null` on success. */ readonly error: Signal; /** Re-execute the loader, resetting `isLoading` and clearing `error`. */ readonly reload: () => void; } /** * Create a signal-based resource from an async loader function. * * Immediately invokes the loader and exposes the result via Angular signals. * Use in Angular components to bind async SDK calls to templates without * manual subscribe/unsubscribe boilerplate. * * @typeParam T - The type returned by the loader promise. * @param loader - A function that returns a `Promise`. Called immediately and on each `reload()`. * @returns A {@link ForjaResource} with reactive `value`, `isLoading`, and `error` signals. * * @example * ```typescript * import { Component } from '@angular/core'; * import { injectForja, forjaResource } from '@forjacms/client/angular'; * * @Component({ * template: ` * @if (blogs.isLoading()) { *

Loading...

* } @else if (blogs.error()) { *

Error: {{ blogs.error()!.message }}

* } @else { * @for (blog of blogs.value()!.data; track blog.id) { *
{{ blog.slug }}
* } * } * * `, * }) * export class BlogListComponent { * private forja = injectForja(); * blogs = forjaResource(() => this.forja.blogs.listPublished({ page: 1 })); * } * ``` * * @example * ```typescript * // Fetch a single resource * const blog = forjaResource(() => forja.blogs.getBySlug('my-post')); * * // Access in template * // blog.value()?.localizations[0]?.title * // blog.isLoading() * // blog.error()?.message * ``` */ export declare function forjaResource(loader: () => Promise): ForjaResource; //#endregion export type { ForjaResource };