lazypock 0.8.1 → 0.8.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.
- package/dist/{chunk-BJQUGPKE.js → chunk-V2XSEOWF.js} +16 -4
- package/dist/{chunk-BJQUGPKE.js.map → chunk-V2XSEOWF.js.map} +1 -1
- package/dist/cli.cjs +15 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.global.js +15 -3
- package/dist/cli.global.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +27 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +27 -8
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen.ts +24 -3
- package/src/http.ts +21 -7
package/dist/index.global.js
CHANGED
|
@@ -103,10 +103,9 @@ var Lazypock = (() => {
|
|
|
103
103
|
}
|
|
104
104
|
const data = await res.json();
|
|
105
105
|
if (data && typeof data.token === "string") {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
);
|
|
106
|
+
const record = data["record"];
|
|
107
|
+
const model = record && typeof record === "object" ? record : null;
|
|
108
|
+
this.authStore.set(data.token, model);
|
|
110
109
|
return data;
|
|
111
110
|
}
|
|
112
111
|
return null;
|
|
@@ -272,7 +271,15 @@ var Lazypock = (() => {
|
|
|
272
271
|
if (bodyText) {
|
|
273
272
|
data = JSON.parse(bodyText);
|
|
274
273
|
}
|
|
275
|
-
} catch {
|
|
274
|
+
} catch (err) {
|
|
275
|
+
if (isAbortError(err)) {
|
|
276
|
+
throw new ApiError(
|
|
277
|
+
"The request was aborted (most likely auto-cancelled by a newer request with the same requestKey)",
|
|
278
|
+
{},
|
|
279
|
+
0,
|
|
280
|
+
true
|
|
281
|
+
);
|
|
282
|
+
}
|
|
276
283
|
}
|
|
277
284
|
if (!res.ok) {
|
|
278
285
|
throw new ApiError(
|
|
@@ -1552,8 +1559,19 @@ export class TypedClient extends LazypockClient {
|
|
|
1552
1559
|
//
|
|
1553
1560
|
// create()/update() take the collection's *CreateData \u2014 the read model
|
|
1554
1561
|
// omits password/hidden fields, but the write model carries them.
|
|
1555
|
-
|
|
1556
|
-
|
|
1562
|
+
// T extends string (rather than keyof LazypockCollections) with a conditional
|
|
1563
|
+
// return type, so the IDE suggests collection names AND unknown/dynamic names
|
|
1564
|
+
// still resolve to the untyped service \u2014 a studio that manages
|
|
1565
|
+
// user-created collections must be able to call collection(someString).
|
|
1566
|
+
//
|
|
1567
|
+
// create()/update() take the collection's *CreateData \u2014 the read model
|
|
1568
|
+
// omits password/hidden fields, but the write model carries them.
|
|
1569
|
+
override collection<T extends string>(name: T): T extends keyof LazypockCollections
|
|
1570
|
+
? CollectionService<LazypockCollections[T], LazypockCreateData[T]>
|
|
1571
|
+
: CollectionService<unknown> {
|
|
1572
|
+
return super.collection(name) as T extends keyof LazypockCollections
|
|
1573
|
+
? CollectionService<LazypockCollections[T], LazypockCreateData[T]>
|
|
1574
|
+
: CollectionService<unknown>;
|
|
1557
1575
|
}
|
|
1558
1576
|
}
|
|
1559
1577
|
`);
|
|
@@ -1577,7 +1595,8 @@ ${opts.body}
|
|
|
1577
1595
|
function createDataMemberLine(f) {
|
|
1578
1596
|
if (f.type === "autodate") return "";
|
|
1579
1597
|
const key = fieldKey(f.name);
|
|
1580
|
-
const
|
|
1598
|
+
const serverDefaulted = f.options?.defaultValue !== void 0 || f.system && (f.name === "verified" || f.name === "emailVisibility");
|
|
1599
|
+
const req = f.required && !serverDefaulted ? "" : "?";
|
|
1581
1600
|
const type = f.type === "password" ? "string" : fieldTypeScriptType(f);
|
|
1582
1601
|
if (type === "never") return "";
|
|
1583
1602
|
return ` ${JSON.stringify(key)}${req}: ${type};`;
|