lazypock 0.19.2 → 0.20.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 +36 -0
- package/dist/index.cjs +905 -674
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +232 -82
- package/dist/index.d.ts +232 -82
- package/dist/index.global.js +904 -674
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +904 -674
- package/dist/index.js.map +1 -1
- package/package.json +19 -2
- package/src/auth.ts +29 -0
- package/src/collection/auth.ts +289 -0
- package/src/collection/index.ts +754 -0
- package/src/collection/paths.ts +21 -0
- package/src/collection/query.ts +111 -0
- package/src/collection/realtime.ts +141 -0
- package/src/collection/session.ts +76 -0
- package/src/collections.ts +18 -52
- package/src/expand.ts +286 -0
- package/src/files.ts +15 -2
- package/src/filter.ts +2 -2
- package/src/http.ts +37 -6
- package/src/index.ts +12 -0
- package/src/lazypock.ts +65 -71
- package/src/mail.ts +290 -0
- package/src/paginate.ts +111 -0
- package/src/projection.ts +139 -0
- package/src/query-params.ts +74 -0
- package/src/realtime.ts +6 -0
- package/src/types.ts +1 -1
- package/src/collection.ts +0 -1412
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>;
|
|
@@ -518,6 +518,19 @@ declare class AuthStore {
|
|
|
518
518
|
* @param model The authenticated user record, or null for superusers.
|
|
519
519
|
*/
|
|
520
520
|
set(token: string, model: AuthModel | null): void;
|
|
521
|
+
/**
|
|
522
|
+
* Replace the cached auth model **without** touching the token, its recorded
|
|
523
|
+
* expiry, or the refresh token.
|
|
524
|
+
*
|
|
525
|
+
* Use this when a read refreshes the identity record (e.g. `me()`, or the
|
|
526
|
+
* server echoing the record back). Routing that through {@link set} would
|
|
527
|
+
* overwrite the access token's real `expiresIn` with the 7-day fallback TTL,
|
|
528
|
+
* so `isExpired` stays false long past the real 15-minute lifetime and the
|
|
529
|
+
* proactive refresh never fires — every request then pays a 401 + retry.
|
|
530
|
+
*
|
|
531
|
+
* @param model The authenticated user record, or null for superusers.
|
|
532
|
+
*/
|
|
533
|
+
setModel(model: AuthModel | null): void;
|
|
521
534
|
/**
|
|
522
535
|
* Record a complete auth response: token, model, refresh token and the access
|
|
523
536
|
* token's real lifetime.
|
|
@@ -589,6 +602,11 @@ declare class HttpClient {
|
|
|
589
602
|
*
|
|
590
603
|
* A network failure keeps the session (the next request can retry); only a refusal
|
|
591
604
|
* by the server ends it.
|
|
605
|
+
*
|
|
606
|
+
* `fetcher` is the per-request `options.fetch` override, so a caller (or a test)
|
|
607
|
+
* that injected its own transport also intercepts the refresh. Falling back to
|
|
608
|
+
* the global fetch here meant those callers — React Native and the test suite —
|
|
609
|
+
* silently did not cover this path at all.
|
|
592
610
|
*/
|
|
593
611
|
private refreshAuth;
|
|
594
612
|
/** The store's current session, in the shape the old refresh returned. */
|
|
@@ -643,6 +661,15 @@ declare class HttpClient {
|
|
|
643
661
|
* @param options Optional request options.
|
|
644
662
|
*/
|
|
645
663
|
post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T | null>;
|
|
664
|
+
/**
|
|
665
|
+
* HTTP PUT — a full replacement. Used where the server models a resource as a
|
|
666
|
+
* complete unit rather than a set of patches (e.g. a mail template, which only
|
|
667
|
+
* exists once all three of its parts do).
|
|
668
|
+
* @param path URL path.
|
|
669
|
+
* @param body Request body.
|
|
670
|
+
* @param options Optional request options.
|
|
671
|
+
*/
|
|
672
|
+
put<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T | null>;
|
|
646
673
|
/**
|
|
647
674
|
* HTTP PATCH.
|
|
648
675
|
* @param path URL path.
|
|
@@ -784,6 +811,14 @@ interface CollectionSchema {
|
|
|
784
811
|
options?: Record<string, unknown>;
|
|
785
812
|
}
|
|
786
813
|
|
|
814
|
+
/**
|
|
815
|
+
* Resolves a collection schema by name or id. Supplied by
|
|
816
|
+
* {@link LazypockClient} so a service can follow relation fields into their
|
|
817
|
+
* target collection — needed to tell a nested relation (`owner.manager`)
|
|
818
|
+
* apart from a field selection (`owner.name`).
|
|
819
|
+
*/
|
|
820
|
+
type SchemaResolver = (nameOrId: string) => CollectionSchema | undefined;
|
|
821
|
+
|
|
787
822
|
/** A single configured OAuth2 provider, as returned by `auth-methods`. */
|
|
788
823
|
interface AuthProviderInfo {
|
|
789
824
|
/** Provider identifier (e.g. `"google"`, `"github"`). */
|
|
@@ -901,23 +936,17 @@ type RealtimeCallback = (e: RealtimeMessage) => void;
|
|
|
901
936
|
* `expand` and any extra keys are forwarded to the server channel join
|
|
902
937
|
* payload (available to `onRealtimeSubscribeRequest` hooks). `headers` is
|
|
903
938
|
* accepted for PocketBase signature compatibility but has no effect over
|
|
904
|
-
*
|
|
939
|
+
* the SSE connection — it is not forwarded.
|
|
905
940
|
*/
|
|
906
941
|
interface RealtimeSubscribeOptions {
|
|
907
942
|
/** Fields to expand on the subscribed records (server join payload). */
|
|
908
943
|
expand?: string;
|
|
909
|
-
/** Accepted for PocketBase parity; not sent over the
|
|
944
|
+
/** Accepted for PocketBase parity; not sent over the SSE connection. */
|
|
910
945
|
headers?: Record<string, string>;
|
|
911
946
|
/** Any extra keys are forwarded verbatim to the server join payload. */
|
|
912
947
|
[key: string]: unknown;
|
|
913
948
|
}
|
|
914
|
-
|
|
915
|
-
* Resolves a collection schema by name or id. Supplied by
|
|
916
|
-
* {@link LazypockClient} so a service can follow relation fields into their
|
|
917
|
-
* target collection — needed to tell a nested relation (`owner.manager`)
|
|
918
|
-
* apart from a field selection (`owner.name`).
|
|
919
|
-
*/
|
|
920
|
-
type SchemaResolver = (nameOrId: string) => CollectionSchema | undefined;
|
|
949
|
+
|
|
921
950
|
/**
|
|
922
951
|
* Typed CRUD service for a single dynamic collection.
|
|
923
952
|
* Get an instance via {@link LazypockClient.collection}.
|
|
@@ -952,16 +981,20 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
|
|
|
952
981
|
private fieldsPreset?;
|
|
953
982
|
/** @internal */
|
|
954
983
|
constructor(http: HttpClient, collectionName: string, authStore?: AuthStore, realtime?: RealtimeService, schema?: CollectionSchema, schemaResolver?: SchemaResolver);
|
|
955
|
-
private encodeId;
|
|
956
984
|
/**
|
|
957
|
-
*
|
|
985
|
+
* A copy of this service with the given overrides applied.
|
|
958
986
|
*
|
|
959
|
-
*
|
|
960
|
-
*
|
|
987
|
+
* Every field is listed exactly once, so a new service-level field can't be
|
|
988
|
+
* silently dropped by `select()` or `withSchema()`.
|
|
961
989
|
*/
|
|
990
|
+
private derive;
|
|
991
|
+
/** The records endpoint for this collection. */
|
|
962
992
|
private recordsPath;
|
|
963
993
|
/** The collection's own endpoint, which is where its auth routes live. */
|
|
964
994
|
private collectionPath;
|
|
995
|
+
private encodeId;
|
|
996
|
+
/** What the auth routes need: transport, collection name, session store. */
|
|
997
|
+
private sessionContext;
|
|
965
998
|
/**
|
|
966
999
|
* Project list/read responses to the given fields (PocketBase `fields`
|
|
967
1000
|
* param). Field names are type-checked when this service is typed
|
|
@@ -974,10 +1007,10 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
|
|
|
974
1007
|
* const t = await client.collection("posts").select("id", "title").getList();
|
|
975
1008
|
* // GET /api/posts?fields=id,title
|
|
976
1009
|
*
|
|
977
|
-
* // All visible fields (implicit system keys id/created/updated
|
|
1010
|
+
* // All visible fields (implicit system keys id/created/updated/... are
|
|
978
1011
|
* // kept; hidden fields are excluded via the projection)
|
|
979
1012
|
* const all = await client.collection("posts").select("*").getList();
|
|
980
|
-
* // GET /api/posts?fields=id,created,updated,collectionId,collectionName,title,published
|
|
1013
|
+
* // GET /api/posts?fields=id,created,updated,collectionId,collectionName,title,published,... (schema known)
|
|
981
1014
|
* ```
|
|
982
1015
|
*
|
|
983
1016
|
* When no schema is known, the default (no `select()` call) sends no
|
|
@@ -1008,6 +1041,10 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
|
|
|
1008
1041
|
* default returns every non-password field, including the system keys).
|
|
1009
1042
|
*/
|
|
1010
1043
|
visibleFields(): string | undefined;
|
|
1044
|
+
/** Service state that query building needs. */
|
|
1045
|
+
private queryContext;
|
|
1046
|
+
/** Context for the schema-aware expand helpers. */
|
|
1047
|
+
private expandContext;
|
|
1011
1048
|
/**
|
|
1012
1049
|
* Start a type-checked filter expression. The field name is suggested
|
|
1013
1050
|
* from the collection's key set and the value is checked against the
|
|
@@ -1018,7 +1055,7 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
|
|
|
1018
1055
|
* await posts.getList(1, 20, {
|
|
1019
1056
|
* filter: q("title").contains("x").and(q("published").eq(true)),
|
|
1020
1057
|
* });
|
|
1021
|
-
* // → filter=(title ~ '
|
|
1058
|
+
* // → filter=(title ~ 'x' && published = true)
|
|
1022
1059
|
*
|
|
1023
1060
|
* // PocketBase `?` array operators (multi-select / multi-relation):
|
|
1024
1061
|
* posts.getList(1, 20, { filter: q("tags").anyEq("news") });
|
|
@@ -1037,69 +1074,6 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
|
|
|
1037
1074
|
* `filter: (w) => w("title").contains("x")` type-checks field names inline.
|
|
1038
1075
|
*/
|
|
1039
1076
|
private resolveFilter;
|
|
1040
|
-
/**
|
|
1041
|
-
* Resolve the leading relation chain of an expand token against the
|
|
1042
|
-
* (optionally schema-aware) collection graph.
|
|
1043
|
-
*
|
|
1044
|
-
* Walks `segments` from this collection: each segment that is a relation
|
|
1045
|
-
* advances to its target collection. Stops at the first non-relation
|
|
1046
|
-
* segment or when the target schema is unknown.
|
|
1047
|
-
*
|
|
1048
|
-
* @returns `depth` — how many leading segments are relations; and
|
|
1049
|
-
* `canInspect` — whether the schema at `depth` is known (so the next
|
|
1050
|
-
* segment can be classified as a field selection vs a nested relation).
|
|
1051
|
-
*/
|
|
1052
|
-
private resolveRelationChain;
|
|
1053
|
-
/** Follow a relation field to its target collection, if resolvable. */
|
|
1054
|
-
private resolveTargetCollection;
|
|
1055
|
-
/** Warn once when an expand field is not a relation (schema known). */
|
|
1056
|
-
private warnNonRelation;
|
|
1057
|
-
/**
|
|
1058
|
-
* Validate and normalise a caller's `expand` string.
|
|
1059
|
-
*
|
|
1060
|
-
* PocketBase only expands *relations*: a dotted token like `author.user`
|
|
1061
|
-
* walks into the related record. Callers often use a dotted token to mean
|
|
1062
|
-
* "only these fields of the expanded record" (`owner.name,owner.email`),
|
|
1063
|
-
* which PocketBase silently drops. When the trailing segment is not a
|
|
1064
|
-
* relation — resolved from the schema graph — the token is rewritten as a
|
|
1065
|
-
* field selection:
|
|
1066
|
-
*
|
|
1067
|
-
* ```
|
|
1068
|
-
* expand: 'owner.name,owner.email'
|
|
1069
|
-
* → expand=owner&fields=<base>,expand.owner.name,expand.owner.email
|
|
1070
|
-
* ```
|
|
1071
|
-
*
|
|
1072
|
-
* Tokens whose whole path is relations keep their existing nested-expand
|
|
1073
|
-
* behaviour. Without a schema the two are indistinguishable, so a lone
|
|
1074
|
-
* dotted token stays a nested expand (with a warning) while two or more
|
|
1075
|
-
* dotted tokens sharing the same relation are treated as field selection.
|
|
1076
|
-
*/
|
|
1077
|
-
private normalizeExpand;
|
|
1078
|
-
/**
|
|
1079
|
-
* Keep only the requested leaf fields on `record.expand.<relation>`.
|
|
1080
|
-
*
|
|
1081
|
-
* Mirrors PocketBase's server-side `fields=expand.<rel>.<field>` projection
|
|
1082
|
-
* for servers that don't support it (the LazyPock server), so field
|
|
1083
|
-
* selection behaves the same against both. A no-op when the server already
|
|
1084
|
-
* narrowed the record. Multi-relations are narrowed element-wise.
|
|
1085
|
-
*/
|
|
1086
|
-
private applyExpandNarrowing;
|
|
1087
|
-
/**
|
|
1088
|
-
* Merge the expand-preserving selectors into the base field projection.
|
|
1089
|
-
*
|
|
1090
|
-
* Both servers are kept happy at once:
|
|
1091
|
-
* - PocketBase drops the whole `expand` payload unless an `expand.<key>`
|
|
1092
|
-
* entry is present in `fields`;
|
|
1093
|
-
* - the LazyPock server projects first (strict, top-level only) and then
|
|
1094
|
-
* expands, so the relation *field* itself must be present in `fields`.
|
|
1095
|
-
*
|
|
1096
|
-
* We therefore add both the relation field (`cate`) and the
|
|
1097
|
-
* `expand.<key>` entry. When no projection is active, no `fields` param is
|
|
1098
|
-
* sent at all — a value like `*` plus other tokens is not a wildcard on
|
|
1099
|
-
* the LazyPock server (it is a strict take, yielding empty records) and
|
|
1100
|
-
* the server keeps `expand` by default when `fields` is absent.
|
|
1101
|
-
*/
|
|
1102
|
-
private mergeExpandFields;
|
|
1103
1077
|
/**
|
|
1104
1078
|
* Fetch a paginated list of records (PocketBase `getList`).
|
|
1105
1079
|
*
|
|
@@ -1111,7 +1085,8 @@ declare class CollectionService<T = ApiRecord, TData = never, TFields = T, TExpa
|
|
|
1111
1085
|
expand?: ExpandObj<E, TExpand>;
|
|
1112
1086
|
}> | null>;
|
|
1113
1087
|
/**
|
|
1114
|
-
* Fetch all records at once (auto-paginates; `batch` defaults to and is
|
|
1088
|
+
* Fetch all records at once (auto-paginates; `batch` defaults to and is
|
|
1089
|
+
* capped at 500, the server max `perPage`). Mirrors PocketBase's
|
|
1115
1090
|
* `pb.collection(name).getFullList()`.
|
|
1116
1091
|
*
|
|
1117
1092
|
* @param options Query params (`sort`, `filter`, `batch`, etc.) + request options.
|
|
@@ -1529,6 +1504,180 @@ declare class CollectionsService {
|
|
|
1529
1504
|
unsubscribe(): void;
|
|
1530
1505
|
}
|
|
1531
1506
|
|
|
1507
|
+
/** The three parts a mail template is made of. */
|
|
1508
|
+
type MailPart = "subject" | "html" | "text";
|
|
1509
|
+
/**
|
|
1510
|
+
* Which layer a template body came from, newest first.
|
|
1511
|
+
*
|
|
1512
|
+
* - `database` — saved through the API (or Studio), the one in effect
|
|
1513
|
+
* - `file` — a file in the deployment's template directory
|
|
1514
|
+
* - `builtin` — shipped with the server
|
|
1515
|
+
*
|
|
1516
|
+
* Reported because an edit that is in effect and one that is not look identical
|
|
1517
|
+
* otherwise.
|
|
1518
|
+
*/
|
|
1519
|
+
type MailTemplateLayer = "database" | "file" | "builtin";
|
|
1520
|
+
/** The template context handed to a send or a preview. */
|
|
1521
|
+
type MailAssigns = Record<string, unknown>;
|
|
1522
|
+
/** A template as the server resolves it. */
|
|
1523
|
+
interface MailTemplate {
|
|
1524
|
+
/** The template name, e.g. `verification` or `receipt`. */
|
|
1525
|
+
name: string;
|
|
1526
|
+
/** The strongest layer across the three parts (`database` wins over `file`). */
|
|
1527
|
+
source: MailTemplateLayer;
|
|
1528
|
+
/** The layer each part resolved from. */
|
|
1529
|
+
parts: Record<MailPart, MailTemplateLayer>;
|
|
1530
|
+
/** The subject, as a template. */
|
|
1531
|
+
subject: string;
|
|
1532
|
+
/** The HTML body. */
|
|
1533
|
+
html: string;
|
|
1534
|
+
/** The plain-text alternative. */
|
|
1535
|
+
text: string;
|
|
1536
|
+
}
|
|
1537
|
+
/** The bodies of one template. All three parts are required. */
|
|
1538
|
+
interface MailTemplateParts {
|
|
1539
|
+
subject: string;
|
|
1540
|
+
html: string;
|
|
1541
|
+
text: string;
|
|
1542
|
+
}
|
|
1543
|
+
/** One message to queue. */
|
|
1544
|
+
type MailMessage = {
|
|
1545
|
+
/** The recipient's address. */
|
|
1546
|
+
to: string;
|
|
1547
|
+
/** The recipient's display name, rendered as `name`. */
|
|
1548
|
+
toName?: string;
|
|
1549
|
+
/** A built-in or deployment-saved template name. */
|
|
1550
|
+
template: string;
|
|
1551
|
+
/** The template context. */
|
|
1552
|
+
assigns?: MailAssigns;
|
|
1553
|
+
} | {
|
|
1554
|
+
/** The recipient's address. */
|
|
1555
|
+
to: string;
|
|
1556
|
+
/** The recipient's display name. */
|
|
1557
|
+
toName?: string;
|
|
1558
|
+
/** A raw subject, instead of a template. */
|
|
1559
|
+
subject: string;
|
|
1560
|
+
/** The HTML body (required when `text` is omitted). */
|
|
1561
|
+
html?: string;
|
|
1562
|
+
/** The plain-text body (required when `html` is omitted). Derived from the HTML when omitted. */
|
|
1563
|
+
text?: string;
|
|
1564
|
+
};
|
|
1565
|
+
/** What `send()` answers: the queued job, not a delivery. */
|
|
1566
|
+
interface MailSendResult {
|
|
1567
|
+
queued: boolean;
|
|
1568
|
+
/** The job id — follow it in `GET /api/logs` for delivery failures. */
|
|
1569
|
+
id: string;
|
|
1570
|
+
}
|
|
1571
|
+
/** A draft to render in place of the stored parts. Nothing is saved or sent. */
|
|
1572
|
+
interface MailPreviewDraft {
|
|
1573
|
+
/** The template context. `name` and `app_name` are filled in when absent. */
|
|
1574
|
+
assigns?: MailAssigns;
|
|
1575
|
+
/** The recipient display name that `name` renders as. */
|
|
1576
|
+
toName?: string;
|
|
1577
|
+
/** A draft subject to render instead of the stored one. */
|
|
1578
|
+
subject?: string;
|
|
1579
|
+
/** A draft HTML body to render instead of the stored one. */
|
|
1580
|
+
html?: string;
|
|
1581
|
+
/** A draft text body to render instead of the stored one. */
|
|
1582
|
+
text?: string;
|
|
1583
|
+
}
|
|
1584
|
+
/** The rendered result of a preview. */
|
|
1585
|
+
interface MailPreviewResult {
|
|
1586
|
+
name: string;
|
|
1587
|
+
subject: string;
|
|
1588
|
+
html: string;
|
|
1589
|
+
text: string;
|
|
1590
|
+
}
|
|
1591
|
+
/** What `deleteTemplate()` answers: how many stored parts went away. */
|
|
1592
|
+
interface MailTemplateDeleteResult {
|
|
1593
|
+
name: string;
|
|
1594
|
+
/** `0` when the template had never been saved (it was already at its default). */
|
|
1595
|
+
deleted: number;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Service for application email.
|
|
1599
|
+
* Access via {@link LazypockClient.mail}.
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```ts
|
|
1603
|
+
* await client.mail.send({ to: 'ada@example.com', template: 'verification', assigns: { token: '…' } });
|
|
1604
|
+
* ```
|
|
1605
|
+
*/
|
|
1606
|
+
declare class MailService {
|
|
1607
|
+
private http;
|
|
1608
|
+
constructor(http: HttpClient);
|
|
1609
|
+
/**
|
|
1610
|
+
* Queue one message for delivery.
|
|
1611
|
+
*
|
|
1612
|
+
* Either a `template` or a `subject` with a body. The type requires one of
|
|
1613
|
+
* them — a message with neither does not compile — while the server refuses a
|
|
1614
|
+
* message that carries both, and a template with a raw body.
|
|
1615
|
+
*
|
|
1616
|
+
* The address is shape-checked server-side; the SMTP server remains the
|
|
1617
|
+
* authority on whether it exists.
|
|
1618
|
+
*
|
|
1619
|
+
* @param message The template or raw message to send.
|
|
1620
|
+
* @param options Optional request options (signal, custom fetch).
|
|
1621
|
+
* @returns The queued job (`{ queued: true, id }`).
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```ts
|
|
1625
|
+
* // A template
|
|
1626
|
+
* await client.mail.send({ to: 'ada@example.com', template: 'receipt', assigns: { total: 42 } });
|
|
1627
|
+
*
|
|
1628
|
+
* // A raw message
|
|
1629
|
+
* await client.mail.send({ to: 'ada@example.com', subject: 'Hello', text: 'Hi there' });
|
|
1630
|
+
* ```
|
|
1631
|
+
*/
|
|
1632
|
+
send(message: MailMessage, options?: RequestOptions): Promise<MailSendResult>;
|
|
1633
|
+
/**
|
|
1634
|
+
* List every template the server can send, with the body each part
|
|
1635
|
+
* currently resolves to and the layer it came from (superuser).
|
|
1636
|
+
*
|
|
1637
|
+
* Unpaginated: there are as many templates as the deployment defined, not
|
|
1638
|
+
* as many as it has sent.
|
|
1639
|
+
*/
|
|
1640
|
+
listTemplates(options?: RequestOptions): Promise<MailTemplate[]>;
|
|
1641
|
+
/** Fetch one template by name (superuser). */
|
|
1642
|
+
getTemplate(name: string, options?: RequestOptions): Promise<MailTemplate>;
|
|
1643
|
+
/**
|
|
1644
|
+
* Save all three parts of a template, replacing whatever was stored for them.
|
|
1645
|
+
*
|
|
1646
|
+
* All three at once rather than one at a time: a template is only allowed to
|
|
1647
|
+
* exist once it is complete, so a part-at-a-time write could leave a subject
|
|
1648
|
+
* saved against a body that does not parse. The server parses the bodies
|
|
1649
|
+
* before storing them, so a syntax error is a rejected save rather than a
|
|
1650
|
+
* queued email that fails where nobody is watching (superuser).
|
|
1651
|
+
*/
|
|
1652
|
+
saveTemplate(name: string, parts: MailTemplateParts, options?: RequestOptions): Promise<MailTemplate>;
|
|
1653
|
+
/**
|
|
1654
|
+
* Remove the stored bodies, so the template falls back to its file or its
|
|
1655
|
+
* built-in (superuser).
|
|
1656
|
+
*
|
|
1657
|
+
* Deleting one that was never saved succeeds with `deleted: 0` — it is
|
|
1658
|
+
* already at its default — but an unknown *name* is a 404, so a typo cannot
|
|
1659
|
+
* look like a reset that worked.
|
|
1660
|
+
*/
|
|
1661
|
+
deleteTemplate(name: string, options?: RequestOptions): Promise<MailTemplateDeleteResult>;
|
|
1662
|
+
/**
|
|
1663
|
+
* Render a template the way a send would, without storing or sending
|
|
1664
|
+
* anything (superuser).
|
|
1665
|
+
*
|
|
1666
|
+
* Any of `subject`/`html`/`text` given in `draft` is rendered in place of the
|
|
1667
|
+
* stored part, which is what makes this useful while a body is still being
|
|
1668
|
+
* written. A draft over a name the server does not know is previewed as the
|
|
1669
|
+
* new template it is being written as, so such a draft has to arrive
|
|
1670
|
+
* complete (all three parts).
|
|
1671
|
+
*
|
|
1672
|
+
* Previews share one auto-cancellation key (`POST /mail/templates/<name>/preview`),
|
|
1673
|
+
* so a newer preview aborts an older one: the older promise rejects with an
|
|
1674
|
+
* `ApiError` whose `isAbort` is `true`. That is what an editor wants when a
|
|
1675
|
+
* keystroke supersedes the last render, but pass `{ requestKey: null }` to
|
|
1676
|
+
* keep every preview if you would rather have them all.
|
|
1677
|
+
*/
|
|
1678
|
+
preview(name: string, draft?: MailPreviewDraft, options?: RequestOptions): Promise<MailPreviewResult>;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1532
1681
|
/** Format a raw collection name into a valid TS identifier (PascalCase). */
|
|
1533
1682
|
declare function collectionTypeName(name: string): string;
|
|
1534
1683
|
/**
|
|
@@ -1617,6 +1766,7 @@ declare class LazypockClient {
|
|
|
1617
1766
|
readonly realtime: RealtimeService;
|
|
1618
1767
|
readonly collections: CollectionsService;
|
|
1619
1768
|
readonly files: FilesService;
|
|
1769
|
+
readonly mail: MailService;
|
|
1620
1770
|
private collectionCache;
|
|
1621
1771
|
private schemaByName?;
|
|
1622
1772
|
private schemaById?;
|
|
@@ -1766,4 +1916,4 @@ declare class TypedClient<TCollections extends LazypockCollections = LazypockCol
|
|
|
1766
1916
|
*/
|
|
1767
1917
|
declare function createClient<TCollections extends LazypockCollections = LazypockCollections>(options: LazypockClientOptions): TypedClient<TCollections>;
|
|
1768
1918
|
|
|
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 };
|
|
1919
|
+
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 };
|