lazypock 0.19.1 → 0.20.0

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.d.cts CHANGED
@@ -126,7 +126,7 @@ interface ListResult<T = ApiRecord> {
126
126
  totalPages: number;
127
127
  }
128
128
  /** HTTP method supported by the client. */
129
- type Method = "GET" | "POST" | "PATCH" | "DELETE";
129
+ type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
130
130
  interface RequestOptions {
131
131
  /** Search/filter params */
132
132
  params?: Record<string, string>;
@@ -643,6 +643,15 @@ declare class HttpClient {
643
643
  * @param options Optional request options.
644
644
  */
645
645
  post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T | null>;
646
+ /**
647
+ * HTTP PUT — a full replacement. Used where the server models a resource as a
648
+ * complete unit rather than a set of patches (e.g. a mail template, which only
649
+ * exists once all three of its parts do).
650
+ * @param path URL path.
651
+ * @param body Request body.
652
+ * @param options Optional request options.
653
+ */
654
+ put<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T | null>;
646
655
  /**
647
656
  * HTTP PATCH.
648
657
  * @param path URL path.
@@ -1111,7 +1120,7 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
1111
1120
  expand?: ExpandObj<E, TExpand>;
1112
1121
  }> | null>;
1113
1122
  /**
1114
- * Fetch all records at once (auto-paginates). Mirrors PocketBase's
1123
+ * Fetch all records at once (auto-paginates; `batch` defaults to and is capped at 500, the server max `perPage`). Mirrors PocketBase's
1115
1124
  * `pb.collection(name).getFullList()`.
1116
1125
  *
1117
1126
  * @param options Query params (`sort`, `filter`, `batch`, etc.) + request options.
@@ -1529,6 +1538,180 @@ declare class CollectionsService {
1529
1538
  unsubscribe(): void;
1530
1539
  }
1531
1540
 
1541
+ /** The three parts a mail template is made of. */
1542
+ type MailPart = "subject" | "html" | "text";
1543
+ /**
1544
+ * Which layer a template body came from, newest first.
1545
+ *
1546
+ * - `database` — saved through the API (or Studio), the one in effect
1547
+ * - `file` — a file in the deployment's template directory
1548
+ * - `builtin` — shipped with the server
1549
+ *
1550
+ * Reported because an edit that is in effect and one that is not look identical
1551
+ * otherwise.
1552
+ */
1553
+ type MailTemplateLayer = "database" | "file" | "builtin";
1554
+ /** The template context handed to a send or a preview. */
1555
+ type MailAssigns = Record<string, unknown>;
1556
+ /** A template as the server resolves it. */
1557
+ interface MailTemplate {
1558
+ /** The template name, e.g. `verification` or `receipt`. */
1559
+ name: string;
1560
+ /** The strongest layer across the three parts (`database` wins over `file`). */
1561
+ source: MailTemplateLayer;
1562
+ /** The layer each part resolved from. */
1563
+ parts: Record<MailPart, MailTemplateLayer>;
1564
+ /** The subject, as a template. */
1565
+ subject: string;
1566
+ /** The HTML body. */
1567
+ html: string;
1568
+ /** The plain-text alternative. */
1569
+ text: string;
1570
+ }
1571
+ /** The bodies of one template. All three parts are required. */
1572
+ interface MailTemplateParts {
1573
+ subject: string;
1574
+ html: string;
1575
+ text: string;
1576
+ }
1577
+ /** One message to queue. */
1578
+ type MailMessage = {
1579
+ /** The recipient's address. */
1580
+ to: string;
1581
+ /** The recipient's display name, rendered as `name`. */
1582
+ toName?: string;
1583
+ /** A built-in or deployment-saved template name. */
1584
+ template: string;
1585
+ /** The template context. */
1586
+ assigns?: MailAssigns;
1587
+ } | {
1588
+ /** The recipient's address. */
1589
+ to: string;
1590
+ /** The recipient's display name. */
1591
+ toName?: string;
1592
+ /** A raw subject, instead of a template. */
1593
+ subject: string;
1594
+ /** The HTML body (required when `text` is omitted). */
1595
+ html?: string;
1596
+ /** The plain-text body (required when `html` is omitted). Derived from the HTML when omitted. */
1597
+ text?: string;
1598
+ };
1599
+ /** What `send()` answers: the queued job, not a delivery. */
1600
+ interface MailSendResult {
1601
+ queued: boolean;
1602
+ /** The job id — follow it in `GET /api/logs` for delivery failures. */
1603
+ id: string;
1604
+ }
1605
+ /** A draft to render in place of the stored parts. Nothing is saved or sent. */
1606
+ interface MailPreviewDraft {
1607
+ /** The template context. `name` and `app_name` are filled in when absent. */
1608
+ assigns?: MailAssigns;
1609
+ /** The recipient display name that `name` renders as. */
1610
+ toName?: string;
1611
+ /** A draft subject to render instead of the stored one. */
1612
+ subject?: string;
1613
+ /** A draft HTML body to render instead of the stored one. */
1614
+ html?: string;
1615
+ /** A draft text body to render instead of the stored one. */
1616
+ text?: string;
1617
+ }
1618
+ /** The rendered result of a preview. */
1619
+ interface MailPreviewResult {
1620
+ name: string;
1621
+ subject: string;
1622
+ html: string;
1623
+ text: string;
1624
+ }
1625
+ /** What `deleteTemplate()` answers: how many stored parts went away. */
1626
+ interface MailTemplateDeleteResult {
1627
+ name: string;
1628
+ /** `0` when the template had never been saved (it was already at its default). */
1629
+ deleted: number;
1630
+ }
1631
+ /**
1632
+ * Service for application email.
1633
+ * Access via {@link LazypockClient.mail}.
1634
+ *
1635
+ * @example
1636
+ * ```ts
1637
+ * await client.mail.send({ to: 'ada@example.com', template: 'verification', assigns: { token: '…' } });
1638
+ * ```
1639
+ */
1640
+ declare class MailService {
1641
+ private http;
1642
+ constructor(http: HttpClient);
1643
+ /**
1644
+ * Queue one message for delivery.
1645
+ *
1646
+ * Either a `template` or a `subject` with a body. The type requires one of
1647
+ * them — a message with neither does not compile — while the server refuses a
1648
+ * message that carries both, and a template with a raw body.
1649
+ *
1650
+ * The address is shape-checked server-side; the SMTP server remains the
1651
+ * authority on whether it exists.
1652
+ *
1653
+ * @param message The template or raw message to send.
1654
+ * @param options Optional request options (signal, custom fetch).
1655
+ * @returns The queued job (`{ queued: true, id }`).
1656
+ *
1657
+ * @example
1658
+ * ```ts
1659
+ * // A template
1660
+ * await client.mail.send({ to: 'ada@example.com', template: 'receipt', assigns: { total: 42 } });
1661
+ *
1662
+ * // A raw message
1663
+ * await client.mail.send({ to: 'ada@example.com', subject: 'Hello', text: 'Hi there' });
1664
+ * ```
1665
+ */
1666
+ send(message: MailMessage, options?: RequestOptions): Promise<MailSendResult>;
1667
+ /**
1668
+ * List every template the server can send, with the body each part
1669
+ * currently resolves to and the layer it came from (superuser).
1670
+ *
1671
+ * Unpaginated: there are as many templates as the deployment defined, not
1672
+ * as many as it has sent.
1673
+ */
1674
+ listTemplates(options?: RequestOptions): Promise<MailTemplate[]>;
1675
+ /** Fetch one template by name (superuser). */
1676
+ getTemplate(name: string, options?: RequestOptions): Promise<MailTemplate>;
1677
+ /**
1678
+ * Save all three parts of a template, replacing whatever was stored for them.
1679
+ *
1680
+ * All three at once rather than one at a time: a template is only allowed to
1681
+ * exist once it is complete, so a part-at-a-time write could leave a subject
1682
+ * saved against a body that does not parse. The server parses the bodies
1683
+ * before storing them, so a syntax error is a rejected save rather than a
1684
+ * queued email that fails where nobody is watching (superuser).
1685
+ */
1686
+ saveTemplate(name: string, parts: MailTemplateParts, options?: RequestOptions): Promise<MailTemplate>;
1687
+ /**
1688
+ * Remove the stored bodies, so the template falls back to its file or its
1689
+ * built-in (superuser).
1690
+ *
1691
+ * Deleting one that was never saved succeeds with `deleted: 0` — it is
1692
+ * already at its default — but an unknown *name* is a 404, so a typo cannot
1693
+ * look like a reset that worked.
1694
+ */
1695
+ deleteTemplate(name: string, options?: RequestOptions): Promise<MailTemplateDeleteResult>;
1696
+ /**
1697
+ * Render a template the way a send would, without storing or sending
1698
+ * anything (superuser).
1699
+ *
1700
+ * Any of `subject`/`html`/`text` given in `draft` is rendered in place of the
1701
+ * stored part, which is what makes this useful while a body is still being
1702
+ * written. A draft over a name the server does not know is previewed as the
1703
+ * new template it is being written as, so such a draft has to arrive
1704
+ * complete (all three parts).
1705
+ *
1706
+ * Previews share one auto-cancellation key (`POST /mail/templates/<name>/preview`),
1707
+ * so a newer preview aborts an older one: the older promise rejects with an
1708
+ * `ApiError` whose `isAbort` is `true`. That is what an editor wants when a
1709
+ * keystroke supersedes the last render, but pass `{ requestKey: null }` to
1710
+ * keep every preview if you would rather have them all.
1711
+ */
1712
+ preview(name: string, draft?: MailPreviewDraft, options?: RequestOptions): Promise<MailPreviewResult>;
1713
+ }
1714
+
1532
1715
  /** Format a raw collection name into a valid TS identifier (PascalCase). */
1533
1716
  declare function collectionTypeName(name: string): string;
1534
1717
  /**
@@ -1617,6 +1800,7 @@ declare class LazypockClient {
1617
1800
  readonly realtime: RealtimeService;
1618
1801
  readonly collections: CollectionsService;
1619
1802
  readonly files: FilesService;
1803
+ readonly mail: MailService;
1620
1804
  private collectionCache;
1621
1805
  private schemaByName?;
1622
1806
  private schemaById?;
@@ -1766,4 +1950,4 @@ declare class TypedClient<TCollections extends LazypockCollections = LazypockCol
1766
1950
  */
1767
1951
  declare function createClient<TCollections extends LazypockCollections = LazypockCollections>(options: LazypockClientOptions): TypedClient<TCollections>;
1768
1952
 
1769
- export { ApiError, type ApiRecord, type AuthMethodsList, type AuthModel, type AuthProviderInfo, AuthStore, type CollectionSchema, CollectionService, type CollectionsMessage, CollectionsService, type CreateData, type ExpandString, type FieldKey, type FileRecord, FilesService, FilterBuilder, FilterExpr, type FilterInput, type FilterOp, type FilterScalar, type FilterString, type FilterWhere, type FilterableKey, HttpClient, LazypockClient, type LazypockClientOptions, type LazypockCollections, type ListOptions, type ListResult, type OAuth2AuthCodeOptions, type OAuth2Meta, type OAuth2Options, type OAuth2PopupOptions, type ReadOptions, type RealtimeCallback, type RealtimeMessage, RealtimeService, type RealtimeSubscribeOptions, type RecordAuth, type RecordShape, type RequestOptions, type SchemaField, type SortString, type StorageAdapter, type SystemFields, TypedClient, type UpdateData, collectionTypeName, createClient, fieldTypeKind, fieldTypeScriptType, generateTypes, getFileUrl, getScaleUrl, getThumbUrl, getVariantUrl, schemaFieldType, sseUrlFromBaseUrl };
1953
+ export { ApiError, type ApiRecord, type AuthMethodsList, type AuthModel, type AuthProviderInfo, AuthStore, type CollectionSchema, CollectionService, type CollectionsMessage, CollectionsService, type CreateData, type ExpandString, type FieldKey, type FileRecord, FilesService, FilterBuilder, FilterExpr, type FilterInput, type FilterOp, type FilterScalar, type FilterString, type FilterWhere, type FilterableKey, HttpClient, LazypockClient, type LazypockClientOptions, type LazypockCollections, type ListOptions, type ListResult, type MailAssigns, type MailMessage, type MailPart, type MailPreviewDraft, type MailPreviewResult, type MailSendResult, MailService, type MailTemplate, type MailTemplateDeleteResult, type MailTemplateLayer, type MailTemplateParts, type OAuth2AuthCodeOptions, type OAuth2Meta, type OAuth2Options, type OAuth2PopupOptions, type ReadOptions, type RealtimeCallback, type RealtimeMessage, RealtimeService, type RealtimeSubscribeOptions, type RecordAuth, type RecordShape, type RequestOptions, type SchemaField, type SortString, type StorageAdapter, type SystemFields, TypedClient, type UpdateData, collectionTypeName, createClient, fieldTypeKind, fieldTypeScriptType, generateTypes, getFileUrl, getScaleUrl, getThumbUrl, getVariantUrl, schemaFieldType, sseUrlFromBaseUrl };
package/dist/index.d.ts CHANGED
@@ -126,7 +126,7 @@ interface ListResult<T = ApiRecord> {
126
126
  totalPages: number;
127
127
  }
128
128
  /** HTTP method supported by the client. */
129
- type Method = "GET" | "POST" | "PATCH" | "DELETE";
129
+ type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
130
130
  interface RequestOptions {
131
131
  /** Search/filter params */
132
132
  params?: Record<string, string>;
@@ -643,6 +643,15 @@ declare class HttpClient {
643
643
  * @param options Optional request options.
644
644
  */
645
645
  post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T | null>;
646
+ /**
647
+ * HTTP PUT — a full replacement. Used where the server models a resource as a
648
+ * complete unit rather than a set of patches (e.g. a mail template, which only
649
+ * exists once all three of its parts do).
650
+ * @param path URL path.
651
+ * @param body Request body.
652
+ * @param options Optional request options.
653
+ */
654
+ put<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T | null>;
646
655
  /**
647
656
  * HTTP PATCH.
648
657
  * @param path URL path.
@@ -1111,7 +1120,7 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
1111
1120
  expand?: ExpandObj<E, TExpand>;
1112
1121
  }> | null>;
1113
1122
  /**
1114
- * Fetch all records at once (auto-paginates). Mirrors PocketBase's
1123
+ * Fetch all records at once (auto-paginates; `batch` defaults to and is capped at 500, the server max `perPage`). Mirrors PocketBase's
1115
1124
  * `pb.collection(name).getFullList()`.
1116
1125
  *
1117
1126
  * @param options Query params (`sort`, `filter`, `batch`, etc.) + request options.
@@ -1529,6 +1538,180 @@ declare class CollectionsService {
1529
1538
  unsubscribe(): void;
1530
1539
  }
1531
1540
 
1541
+ /** The three parts a mail template is made of. */
1542
+ type MailPart = "subject" | "html" | "text";
1543
+ /**
1544
+ * Which layer a template body came from, newest first.
1545
+ *
1546
+ * - `database` — saved through the API (or Studio), the one in effect
1547
+ * - `file` — a file in the deployment's template directory
1548
+ * - `builtin` — shipped with the server
1549
+ *
1550
+ * Reported because an edit that is in effect and one that is not look identical
1551
+ * otherwise.
1552
+ */
1553
+ type MailTemplateLayer = "database" | "file" | "builtin";
1554
+ /** The template context handed to a send or a preview. */
1555
+ type MailAssigns = Record<string, unknown>;
1556
+ /** A template as the server resolves it. */
1557
+ interface MailTemplate {
1558
+ /** The template name, e.g. `verification` or `receipt`. */
1559
+ name: string;
1560
+ /** The strongest layer across the three parts (`database` wins over `file`). */
1561
+ source: MailTemplateLayer;
1562
+ /** The layer each part resolved from. */
1563
+ parts: Record<MailPart, MailTemplateLayer>;
1564
+ /** The subject, as a template. */
1565
+ subject: string;
1566
+ /** The HTML body. */
1567
+ html: string;
1568
+ /** The plain-text alternative. */
1569
+ text: string;
1570
+ }
1571
+ /** The bodies of one template. All three parts are required. */
1572
+ interface MailTemplateParts {
1573
+ subject: string;
1574
+ html: string;
1575
+ text: string;
1576
+ }
1577
+ /** One message to queue. */
1578
+ type MailMessage = {
1579
+ /** The recipient's address. */
1580
+ to: string;
1581
+ /** The recipient's display name, rendered as `name`. */
1582
+ toName?: string;
1583
+ /** A built-in or deployment-saved template name. */
1584
+ template: string;
1585
+ /** The template context. */
1586
+ assigns?: MailAssigns;
1587
+ } | {
1588
+ /** The recipient's address. */
1589
+ to: string;
1590
+ /** The recipient's display name. */
1591
+ toName?: string;
1592
+ /** A raw subject, instead of a template. */
1593
+ subject: string;
1594
+ /** The HTML body (required when `text` is omitted). */
1595
+ html?: string;
1596
+ /** The plain-text body (required when `html` is omitted). Derived from the HTML when omitted. */
1597
+ text?: string;
1598
+ };
1599
+ /** What `send()` answers: the queued job, not a delivery. */
1600
+ interface MailSendResult {
1601
+ queued: boolean;
1602
+ /** The job id — follow it in `GET /api/logs` for delivery failures. */
1603
+ id: string;
1604
+ }
1605
+ /** A draft to render in place of the stored parts. Nothing is saved or sent. */
1606
+ interface MailPreviewDraft {
1607
+ /** The template context. `name` and `app_name` are filled in when absent. */
1608
+ assigns?: MailAssigns;
1609
+ /** The recipient display name that `name` renders as. */
1610
+ toName?: string;
1611
+ /** A draft subject to render instead of the stored one. */
1612
+ subject?: string;
1613
+ /** A draft HTML body to render instead of the stored one. */
1614
+ html?: string;
1615
+ /** A draft text body to render instead of the stored one. */
1616
+ text?: string;
1617
+ }
1618
+ /** The rendered result of a preview. */
1619
+ interface MailPreviewResult {
1620
+ name: string;
1621
+ subject: string;
1622
+ html: string;
1623
+ text: string;
1624
+ }
1625
+ /** What `deleteTemplate()` answers: how many stored parts went away. */
1626
+ interface MailTemplateDeleteResult {
1627
+ name: string;
1628
+ /** `0` when the template had never been saved (it was already at its default). */
1629
+ deleted: number;
1630
+ }
1631
+ /**
1632
+ * Service for application email.
1633
+ * Access via {@link LazypockClient.mail}.
1634
+ *
1635
+ * @example
1636
+ * ```ts
1637
+ * await client.mail.send({ to: 'ada@example.com', template: 'verification', assigns: { token: '…' } });
1638
+ * ```
1639
+ */
1640
+ declare class MailService {
1641
+ private http;
1642
+ constructor(http: HttpClient);
1643
+ /**
1644
+ * Queue one message for delivery.
1645
+ *
1646
+ * Either a `template` or a `subject` with a body. The type requires one of
1647
+ * them — a message with neither does not compile — while the server refuses a
1648
+ * message that carries both, and a template with a raw body.
1649
+ *
1650
+ * The address is shape-checked server-side; the SMTP server remains the
1651
+ * authority on whether it exists.
1652
+ *
1653
+ * @param message The template or raw message to send.
1654
+ * @param options Optional request options (signal, custom fetch).
1655
+ * @returns The queued job (`{ queued: true, id }`).
1656
+ *
1657
+ * @example
1658
+ * ```ts
1659
+ * // A template
1660
+ * await client.mail.send({ to: 'ada@example.com', template: 'receipt', assigns: { total: 42 } });
1661
+ *
1662
+ * // A raw message
1663
+ * await client.mail.send({ to: 'ada@example.com', subject: 'Hello', text: 'Hi there' });
1664
+ * ```
1665
+ */
1666
+ send(message: MailMessage, options?: RequestOptions): Promise<MailSendResult>;
1667
+ /**
1668
+ * List every template the server can send, with the body each part
1669
+ * currently resolves to and the layer it came from (superuser).
1670
+ *
1671
+ * Unpaginated: there are as many templates as the deployment defined, not
1672
+ * as many as it has sent.
1673
+ */
1674
+ listTemplates(options?: RequestOptions): Promise<MailTemplate[]>;
1675
+ /** Fetch one template by name (superuser). */
1676
+ getTemplate(name: string, options?: RequestOptions): Promise<MailTemplate>;
1677
+ /**
1678
+ * Save all three parts of a template, replacing whatever was stored for them.
1679
+ *
1680
+ * All three at once rather than one at a time: a template is only allowed to
1681
+ * exist once it is complete, so a part-at-a-time write could leave a subject
1682
+ * saved against a body that does not parse. The server parses the bodies
1683
+ * before storing them, so a syntax error is a rejected save rather than a
1684
+ * queued email that fails where nobody is watching (superuser).
1685
+ */
1686
+ saveTemplate(name: string, parts: MailTemplateParts, options?: RequestOptions): Promise<MailTemplate>;
1687
+ /**
1688
+ * Remove the stored bodies, so the template falls back to its file or its
1689
+ * built-in (superuser).
1690
+ *
1691
+ * Deleting one that was never saved succeeds with `deleted: 0` — it is
1692
+ * already at its default — but an unknown *name* is a 404, so a typo cannot
1693
+ * look like a reset that worked.
1694
+ */
1695
+ deleteTemplate(name: string, options?: RequestOptions): Promise<MailTemplateDeleteResult>;
1696
+ /**
1697
+ * Render a template the way a send would, without storing or sending
1698
+ * anything (superuser).
1699
+ *
1700
+ * Any of `subject`/`html`/`text` given in `draft` is rendered in place of the
1701
+ * stored part, which is what makes this useful while a body is still being
1702
+ * written. A draft over a name the server does not know is previewed as the
1703
+ * new template it is being written as, so such a draft has to arrive
1704
+ * complete (all three parts).
1705
+ *
1706
+ * Previews share one auto-cancellation key (`POST /mail/templates/<name>/preview`),
1707
+ * so a newer preview aborts an older one: the older promise rejects with an
1708
+ * `ApiError` whose `isAbort` is `true`. That is what an editor wants when a
1709
+ * keystroke supersedes the last render, but pass `{ requestKey: null }` to
1710
+ * keep every preview if you would rather have them all.
1711
+ */
1712
+ preview(name: string, draft?: MailPreviewDraft, options?: RequestOptions): Promise<MailPreviewResult>;
1713
+ }
1714
+
1532
1715
  /** Format a raw collection name into a valid TS identifier (PascalCase). */
1533
1716
  declare function collectionTypeName(name: string): string;
1534
1717
  /**
@@ -1617,6 +1800,7 @@ declare class LazypockClient {
1617
1800
  readonly realtime: RealtimeService;
1618
1801
  readonly collections: CollectionsService;
1619
1802
  readonly files: FilesService;
1803
+ readonly mail: MailService;
1620
1804
  private collectionCache;
1621
1805
  private schemaByName?;
1622
1806
  private schemaById?;
@@ -1766,4 +1950,4 @@ declare class TypedClient<TCollections extends LazypockCollections = LazypockCol
1766
1950
  */
1767
1951
  declare function createClient<TCollections extends LazypockCollections = LazypockCollections>(options: LazypockClientOptions): TypedClient<TCollections>;
1768
1952
 
1769
- export { ApiError, type ApiRecord, type AuthMethodsList, type AuthModel, type AuthProviderInfo, AuthStore, type CollectionSchema, CollectionService, type CollectionsMessage, CollectionsService, type CreateData, type ExpandString, type FieldKey, type FileRecord, FilesService, FilterBuilder, FilterExpr, type FilterInput, type FilterOp, type FilterScalar, type FilterString, type FilterWhere, type FilterableKey, HttpClient, LazypockClient, type LazypockClientOptions, type LazypockCollections, type ListOptions, type ListResult, type OAuth2AuthCodeOptions, type OAuth2Meta, type OAuth2Options, type OAuth2PopupOptions, type ReadOptions, type RealtimeCallback, type RealtimeMessage, RealtimeService, type RealtimeSubscribeOptions, type RecordAuth, type RecordShape, type RequestOptions, type SchemaField, type SortString, type StorageAdapter, type SystemFields, TypedClient, type UpdateData, collectionTypeName, createClient, fieldTypeKind, fieldTypeScriptType, generateTypes, getFileUrl, getScaleUrl, getThumbUrl, getVariantUrl, schemaFieldType, sseUrlFromBaseUrl };
1953
+ export { ApiError, type ApiRecord, type AuthMethodsList, type AuthModel, type AuthProviderInfo, AuthStore, type CollectionSchema, CollectionService, type CollectionsMessage, CollectionsService, type CreateData, type ExpandString, type FieldKey, type FileRecord, FilesService, FilterBuilder, FilterExpr, type FilterInput, type FilterOp, type FilterScalar, type FilterString, type FilterWhere, type FilterableKey, HttpClient, LazypockClient, type LazypockClientOptions, type LazypockCollections, type ListOptions, type ListResult, type MailAssigns, type MailMessage, type MailPart, type MailPreviewDraft, type MailPreviewResult, type MailSendResult, MailService, type MailTemplate, type MailTemplateDeleteResult, type MailTemplateLayer, type MailTemplateParts, type OAuth2AuthCodeOptions, type OAuth2Meta, type OAuth2Options, type OAuth2PopupOptions, type ReadOptions, type RealtimeCallback, type RealtimeMessage, RealtimeService, type RealtimeSubscribeOptions, type RecordAuth, type RecordShape, type RequestOptions, type SchemaField, type SortString, type StorageAdapter, type SystemFields, TypedClient, type UpdateData, collectionTypeName, createClient, fieldTypeKind, fieldTypeScriptType, generateTypes, getFileUrl, getScaleUrl, getThumbUrl, getVariantUrl, schemaFieldType, sseUrlFromBaseUrl };
@@ -30,6 +30,7 @@ var Lazypock = (() => {
30
30
  FilterExpr: () => FilterExpr,
31
31
  HttpClient: () => HttpClient,
32
32
  LazypockClient: () => LazypockClient,
33
+ MailService: () => MailService,
33
34
  RealtimeService: () => RealtimeService,
34
35
  TypedClient: () => TypedClient,
35
36
  collectionTypeName: () => collectionTypeName,
@@ -393,6 +394,17 @@ var Lazypock = (() => {
393
394
  post(path, body, options) {
394
395
  return this.request("POST", path, body, options);
395
396
  }
397
+ /**
398
+ * HTTP PUT — a full replacement. Used where the server models a resource as a
399
+ * complete unit rather than a set of patches (e.g. a mail template, which only
400
+ * exists once all three of its parts do).
401
+ * @param path URL path.
402
+ * @param body Request body.
403
+ * @param options Optional request options.
404
+ */
405
+ put(path, body, options) {
406
+ return this.request("PUT", path, body, options);
407
+ }
396
408
  /**
397
409
  * HTTP PATCH.
398
410
  * @param path URL path.
@@ -943,6 +955,11 @@ var Lazypock = (() => {
943
955
  }
944
956
 
945
957
  // src/collection.ts
958
+ var MAX_PER_PAGE = 500;
959
+ function clampBatch(batch) {
960
+ if (!Number.isFinite(batch)) return MAX_PER_PAGE;
961
+ return Math.min(Math.max(1, Math.floor(batch)), MAX_PER_PAGE);
962
+ }
946
963
  function stableStringify(value) {
947
964
  const seen = /* @__PURE__ */ new Set();
948
965
  const sort = (v) => {
@@ -1439,13 +1456,14 @@ var Lazypock = (() => {
1439
1456
  return result;
1440
1457
  }
1441
1458
  /**
1442
- * Fetch all records at once (auto-paginates). Mirrors PocketBase's
1459
+ * Fetch all records at once (auto-paginates; `batch` defaults to and is capped at 500, the server max `perPage`). Mirrors PocketBase's
1443
1460
  * `pb.collection(name).getFullList()`.
1444
1461
  *
1445
1462
  * @param options Query params (`sort`, `filter`, `batch`, etc.) + request options.
1446
1463
  */
1447
1464
  async getFullList(options) {
1448
- const { batch = 1e3, ...rest } = options ?? {};
1465
+ const { batch: requestedBatch = MAX_PER_PAGE, ...rest } = options ?? {};
1466
+ const batch = clampBatch(requestedBatch);
1449
1467
  if (typeof rest.filter === "function") {
1450
1468
  rest.filter = this.resolveFilter(rest.filter);
1451
1469
  }
@@ -2338,7 +2356,8 @@ var Lazypock = (() => {
2338
2356
  */
2339
2357
  async getFullList(options) {
2340
2358
  if (!this.http) return [];
2341
- const { batch = 1e3, ...rest } = options ?? {};
2359
+ const { batch: requestedBatch = MAX_PER_PAGE, ...rest } = options ?? {};
2360
+ const batch = clampBatch(requestedBatch);
2342
2361
  const {
2343
2362
  requestKey: reqKey,
2344
2363
  singleFlight: _singleFlight,
@@ -2457,6 +2476,147 @@ var Lazypock = (() => {
2457
2476
  return "update";
2458
2477
  }
2459
2478
 
2479
+ // src/mail.ts
2480
+ function templatePath(name) {
2481
+ return "/mail/templates/" + encodeURIComponent(name.trim());
2482
+ }
2483
+ var MailService = class {
2484
+ constructor(http) {
2485
+ this.http = http;
2486
+ }
2487
+ /**
2488
+ * Queue one message for delivery.
2489
+ *
2490
+ * Either a `template` or a `subject` with a body. The type requires one of
2491
+ * them — a message with neither does not compile — while the server refuses a
2492
+ * message that carries both, and a template with a raw body.
2493
+ *
2494
+ * The address is shape-checked server-side; the SMTP server remains the
2495
+ * authority on whether it exists.
2496
+ *
2497
+ * @param message The template or raw message to send.
2498
+ * @param options Optional request options (signal, custom fetch).
2499
+ * @returns The queued job (`{ queued: true, id }`).
2500
+ *
2501
+ * @example
2502
+ * ```ts
2503
+ * // A template
2504
+ * await client.mail.send({ to: 'ada@example.com', template: 'receipt', assigns: { total: 42 } });
2505
+ *
2506
+ * // A raw message
2507
+ * await client.mail.send({ to: 'ada@example.com', subject: 'Hello', text: 'Hi there' });
2508
+ * ```
2509
+ */
2510
+ async send(message, options) {
2511
+ const body = "template" in message ? {
2512
+ to: message.to,
2513
+ toName: message.toName,
2514
+ template: message.template,
2515
+ assigns: message.assigns
2516
+ } : {
2517
+ to: message.to,
2518
+ toName: message.toName,
2519
+ subject: message.subject,
2520
+ html: message.html,
2521
+ text: message.text
2522
+ };
2523
+ const data = await this.http.request("POST", "/mail", body, options);
2524
+ return data ?? { queued: false, id: "" };
2525
+ }
2526
+ /**
2527
+ * List every template the server can send, with the body each part
2528
+ * currently resolves to and the layer it came from (superuser).
2529
+ *
2530
+ * Unpaginated: there are as many templates as the deployment defined, not
2531
+ * as many as it has sent.
2532
+ */
2533
+ async listTemplates(options) {
2534
+ const data = await this.http.request(
2535
+ "GET",
2536
+ "/mail/templates",
2537
+ void 0,
2538
+ options
2539
+ );
2540
+ return data?.items ?? [];
2541
+ }
2542
+ /** Fetch one template by name (superuser). */
2543
+ async getTemplate(name, options) {
2544
+ const data = await this.http.request(
2545
+ "GET",
2546
+ templatePath(name),
2547
+ void 0,
2548
+ options
2549
+ );
2550
+ return data;
2551
+ }
2552
+ /**
2553
+ * Save all three parts of a template, replacing whatever was stored for them.
2554
+ *
2555
+ * All three at once rather than one at a time: a template is only allowed to
2556
+ * exist once it is complete, so a part-at-a-time write could leave a subject
2557
+ * saved against a body that does not parse. The server parses the bodies
2558
+ * before storing them, so a syntax error is a rejected save rather than a
2559
+ * queued email that fails where nobody is watching (superuser).
2560
+ */
2561
+ async saveTemplate(name, parts, options) {
2562
+ const data = await this.http.put(
2563
+ templatePath(name),
2564
+ { subject: parts.subject, html: parts.html, text: parts.text },
2565
+ options
2566
+ );
2567
+ return data;
2568
+ }
2569
+ /**
2570
+ * Remove the stored bodies, so the template falls back to its file or its
2571
+ * built-in (superuser).
2572
+ *
2573
+ * Deleting one that was never saved succeeds with `deleted: 0` — it is
2574
+ * already at its default — but an unknown *name* is a 404, so a typo cannot
2575
+ * look like a reset that worked.
2576
+ */
2577
+ async deleteTemplate(name, options) {
2578
+ const data = await this.http.request(
2579
+ "DELETE",
2580
+ templatePath(name),
2581
+ void 0,
2582
+ options
2583
+ );
2584
+ return data ?? { name: name.trim(), deleted: 0 };
2585
+ }
2586
+ /**
2587
+ * Render a template the way a send would, without storing or sending
2588
+ * anything (superuser).
2589
+ *
2590
+ * Any of `subject`/`html`/`text` given in `draft` is rendered in place of the
2591
+ * stored part, which is what makes this useful while a body is still being
2592
+ * written. A draft over a name the server does not know is previewed as the
2593
+ * new template it is being written as, so such a draft has to arrive
2594
+ * complete (all three parts).
2595
+ *
2596
+ * Previews share one auto-cancellation key (`POST /mail/templates/<name>/preview`),
2597
+ * so a newer preview aborts an older one: the older promise rejects with an
2598
+ * `ApiError` whose `isAbort` is `true`. That is what an editor wants when a
2599
+ * keystroke supersedes the last render, but pass `{ requestKey: null }` to
2600
+ * keep every preview if you would rather have them all.
2601
+ */
2602
+ async preview(name, draft, options) {
2603
+ const body = {
2604
+ assigns: draft?.assigns,
2605
+ toName: draft?.toName,
2606
+ subject: draft?.subject,
2607
+ html: draft?.html,
2608
+ text: draft?.text
2609
+ };
2610
+ const data = await this.http.request(
2611
+ "POST",
2612
+ templatePath(name) + "/preview",
2613
+ body,
2614
+ options
2615
+ );
2616
+ return data;
2617
+ }
2618
+ };
2619
+
2460
2620
  // src/typegen.ts
2461
2621
  function fieldTypeScriptType(field, fallback = "unknown") {
2462
2622
  const opts = field.options ?? {};
@@ -2828,6 +2988,7 @@ ${opts.body}
2828
2988
  this.authStore.onChange(() => this.realtime.refresh());
2829
2989
  this.authReady.then(() => this.realtime.refresh());
2830
2990
  this.files = new FilesService(this.http);
2991
+ this.mail = new MailService(this.http);
2831
2992
  this.collections = new CollectionsService(this.http, this.realtime);
2832
2993
  if (options.types?.schemas) {
2833
2994
  this.schemaByName = new Map(