lazypock 0.14.0 → 0.16.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/README.md +16 -5
- package/dist/cli.cjs +21 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.global.js +21 -1
- package/dist/cli.global.js.map +1 -1
- package/dist/cli.js +21 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +98 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -5
- package/dist/index.d.ts +68 -5
- package/dist/index.global.js +98 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/cli.ts +26 -1
- package/src/collection.ts +136 -2
- package/src/index.ts +2 -0
- package/src/lazypock.ts +4 -0
- package/src/types.ts +32 -4
package/dist/index.cjs
CHANGED
|
@@ -990,6 +990,17 @@ var CollectionService = class _CollectionService {
|
|
|
990
990
|
where(field) {
|
|
991
991
|
return new FilterBuilder(field);
|
|
992
992
|
}
|
|
993
|
+
/**
|
|
994
|
+
* Resolve a `filter` callback into a concrete string / {@link FilterExpr}.
|
|
995
|
+
* The callback receives this collection's typed `where` helper, so
|
|
996
|
+
* `filter: (w) => w("title").contains("x")` type-checks field names inline.
|
|
997
|
+
*/
|
|
998
|
+
resolveFilter(filter) {
|
|
999
|
+
if (typeof filter !== "function") {
|
|
1000
|
+
return filter;
|
|
1001
|
+
}
|
|
1002
|
+
return filter((field) => this.where(field));
|
|
1003
|
+
}
|
|
993
1004
|
/**
|
|
994
1005
|
* Resolve the leading relation chain of an expand token against the
|
|
995
1006
|
* (optionally schema-aware) collection graph.
|
|
@@ -1239,6 +1250,11 @@ var CollectionService = class _CollectionService {
|
|
|
1239
1250
|
if (Array.isArray(queryParams.expand)) {
|
|
1240
1251
|
queryParams.expand = queryParams.expand.join(",");
|
|
1241
1252
|
}
|
|
1253
|
+
if (typeof queryParams.filter === "function") {
|
|
1254
|
+
queryParams.filter = this.resolveFilter(
|
|
1255
|
+
queryParams.filter
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1242
1258
|
const expandInfo = this.normalizeExpand(
|
|
1243
1259
|
typeof queryParams.expand === "string" ? queryParams.expand : void 0
|
|
1244
1260
|
);
|
|
@@ -1286,6 +1302,9 @@ var CollectionService = class _CollectionService {
|
|
|
1286
1302
|
*/
|
|
1287
1303
|
async getFullList(options) {
|
|
1288
1304
|
const { batch = 1e3, ...rest } = options ?? {};
|
|
1305
|
+
if (typeof rest.filter === "function") {
|
|
1306
|
+
rest.filter = this.resolveFilter(rest.filter);
|
|
1307
|
+
}
|
|
1289
1308
|
const effectiveKey = typeof rest.requestKey === "string" ? rest.requestKey : `getFullList:${this.collectionName}:${stableStringify(rest)}`;
|
|
1290
1309
|
const items = [];
|
|
1291
1310
|
let page = 1;
|
|
@@ -1537,6 +1556,85 @@ var CollectionService = class _CollectionService {
|
|
|
1537
1556
|
authMethods(options) {
|
|
1538
1557
|
return this.listAuthMethods(options);
|
|
1539
1558
|
}
|
|
1559
|
+
// ── Email / Verification / Password Reset (PocketBase parity) ──
|
|
1560
|
+
/**
|
|
1561
|
+
* Send a password reset email to the given address (PocketBase
|
|
1562
|
+
* `requestPasswordReset`). The backend always answers 204 to avoid
|
|
1563
|
+
* revealing whether the address exists.
|
|
1564
|
+
*/
|
|
1565
|
+
async requestPasswordReset(email, options) {
|
|
1566
|
+
await this.http.post(
|
|
1567
|
+
"/" + this.encodeId(this.collectionName) + "/request-password-reset",
|
|
1568
|
+
{ email },
|
|
1569
|
+
options
|
|
1570
|
+
);
|
|
1571
|
+
return true;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Confirm a password reset (PocketBase `confirmPasswordReset`).
|
|
1575
|
+
*
|
|
1576
|
+
* @param passwordResetToken The token emailed by `requestPasswordReset`.
|
|
1577
|
+
* @param password The new password (min 8 chars server-side).
|
|
1578
|
+
* @param passwordConfirm Must equal `password`.
|
|
1579
|
+
*/
|
|
1580
|
+
async confirmPasswordReset(passwordResetToken, password, passwordConfirm, options) {
|
|
1581
|
+
await this.http.post(
|
|
1582
|
+
"/" + this.encodeId(this.collectionName) + "/confirm-password-reset",
|
|
1583
|
+
{ token: passwordResetToken, password, passwordConfirm },
|
|
1584
|
+
options
|
|
1585
|
+
);
|
|
1586
|
+
return true;
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Send a verification email to the given address (PocketBase
|
|
1590
|
+
* `requestVerification`). The backend always answers 204 to avoid
|
|
1591
|
+
* revealing whether the address exists.
|
|
1592
|
+
*/
|
|
1593
|
+
async requestVerification(email, options) {
|
|
1594
|
+
await this.http.post(
|
|
1595
|
+
"/" + this.encodeId(this.collectionName) + "/request-verification",
|
|
1596
|
+
{ email },
|
|
1597
|
+
options
|
|
1598
|
+
);
|
|
1599
|
+
return true;
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* Confirm an email verification (PocketBase `confirmVerification`).
|
|
1603
|
+
* Resolves with the verified auth record.
|
|
1604
|
+
*/
|
|
1605
|
+
async confirmVerification(verificationToken, options) {
|
|
1606
|
+
const data = await this.http.post(
|
|
1607
|
+
"/" + this.encodeId(this.collectionName) + "/confirm-verification",
|
|
1608
|
+
{ token: verificationToken },
|
|
1609
|
+
options
|
|
1610
|
+
);
|
|
1611
|
+
return data?.record ?? null;
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Send an email-change confirmation email to a new address (PocketBase
|
|
1615
|
+
* `requestEmailChange`). Requires an authenticated auth-collection user.
|
|
1616
|
+
*/
|
|
1617
|
+
async requestEmailChange(newEmail, options) {
|
|
1618
|
+
await this.http.post(
|
|
1619
|
+
"/" + this.encodeId(this.collectionName) + "/request-email-change",
|
|
1620
|
+
{ newEmail },
|
|
1621
|
+
options
|
|
1622
|
+
);
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Confirm an email change (PocketBase `confirmEmailChange`). Requires the
|
|
1627
|
+
* currently authenticated user's password. Resolves with the updated auth
|
|
1628
|
+
* record.
|
|
1629
|
+
*/
|
|
1630
|
+
async confirmEmailChange(emailChangeToken, password, options) {
|
|
1631
|
+
const data = await this.http.post(
|
|
1632
|
+
"/" + this.encodeId(this.collectionName) + "/confirm-email-change",
|
|
1633
|
+
{ token: emailChangeToken, password },
|
|
1634
|
+
options
|
|
1635
|
+
);
|
|
1636
|
+
return data?.record ?? null;
|
|
1637
|
+
}
|
|
1540
1638
|
/**
|
|
1541
1639
|
* Sign in with an OAuth2 provider (PocketBase `authWithOAuth2` parity).
|
|
1542
1640
|
*
|