clefbase 1.3.7 → 1.3.9

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.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * clefbase — Firebase-style SDK for Clefbase / Cleforyx
4
4
  *
5
5
  * @example
6
- * import { initClefbase, getDatabase, getAuth, getStorage, getHosting } from "clefbase";
6
+ * import { initClefbase, getDatabase, getAuth, getStorage, getHosting, FieldValue } from "clefbase";
7
7
  *
8
8
  * const app = initClefbase({
9
9
  * serverUrl: "https://api.cleforyx.com",
@@ -12,13 +12,35 @@
12
12
  * adminSecret: "...", // only needed for hosting
13
13
  * });
14
14
  *
15
- * const db = getDatabase(app);
16
- * const auth = getAuth(app);
17
- * const storage = getStorage(app);
18
- * const hosting = getHosting(app);
15
+ * const db = getDatabase(app);
16
+ *
17
+ * // FieldValue sentinels
18
+ * await db.collection("posts").doc("p1").update({
19
+ * views: FieldValue.increment(1),
20
+ * score: FieldValue.decrement(0.5),
21
+ * publishedAt: FieldValue.serverTimestamp(),
22
+ * draft: FieldValue.deleteField(),
23
+ * tags: FieldValue.arrayUnion("featured"),
24
+ * oldTags: FieldValue.arrayRemove("wip"),
25
+ * });
26
+ *
27
+ * // Batch writes
28
+ * const batch = db.batch();
29
+ * batch.update(db.collection("counters").doc("hits"), { n: FieldValue.increment(1) });
30
+ * batch.delete(db.collection("sessions").doc("expired"));
31
+ * await batch.commit();
32
+ *
33
+ * // Transactions
34
+ * await db.runTransaction(async (tx) => {
35
+ * const wallet = await tx.get(db.collection("wallets").doc(uid));
36
+ * tx.update(db.collection("wallets").doc(uid), { balance: (wallet?.balance as number ?? 0) + 10 });
37
+ * });
38
+ *
39
+ * // Collection-group queries
40
+ * const allComments = await db.collectionGroup("comments").where({ approved: true }).getDocs();
19
41
  */
20
42
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.ClefbaseError = exports.SiteReference = exports.ClefbaseHosting = exports.BucketReference = exports.StorageReference = exports.ClefbaseStorage = exports.Auth = exports.Query = exports.DocumentReference = exports.CollectionReference = exports.Database = exports.getHosting = exports.getStorage = exports.getAuth = exports.getDatabase = exports.getApp = exports.initClefbase = exports.ClefbaseApp = void 0;
43
+ exports.ClefbaseError = exports.FieldValueSentinel = exports.FieldValue = exports.SiteReference = exports.ClefbaseHosting = exports.EmailVerificationCard = exports.BucketReference = exports.StorageReference = exports.ClefbaseStorage = exports.Auth = exports.runTransaction = exports.Transaction = exports.WriteBatch = exports.Query = exports.DocumentReference = exports.CollectionGroup = exports.CollectionReference = exports.Database = exports.getHosting = exports.getStorage = exports.getAuth = exports.getDatabase = exports.getApp = exports.initClefbase = exports.ClefbaseApp = void 0;
22
44
  // ─── App ──────────────────────────────────────────────────────────────────────
23
45
  var app_1 = require("./app");
24
46
  Object.defineProperty(exports, "ClefbaseApp", { enumerable: true, get: function () { return app_1.ClefbaseApp; } });
@@ -32,8 +54,12 @@ Object.defineProperty(exports, "getHosting", { enumerable: true, get: function (
32
54
  var db_1 = require("./db");
33
55
  Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return db_1.Database; } });
34
56
  Object.defineProperty(exports, "CollectionReference", { enumerable: true, get: function () { return db_1.CollectionReference; } });
57
+ Object.defineProperty(exports, "CollectionGroup", { enumerable: true, get: function () { return db_1.CollectionGroup; } });
35
58
  Object.defineProperty(exports, "DocumentReference", { enumerable: true, get: function () { return db_1.DocumentReference; } });
36
59
  Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return db_1.Query; } });
60
+ Object.defineProperty(exports, "WriteBatch", { enumerable: true, get: function () { return db_1.WriteBatch; } });
61
+ Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return db_1.Transaction; } });
62
+ Object.defineProperty(exports, "runTransaction", { enumerable: true, get: function () { return db_1.runTransaction; } });
37
63
  // ─── Auth ─────────────────────────────────────────────────────────────────────
38
64
  var auth_1 = require("./auth");
39
65
  Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return auth_1.Auth; } });
@@ -42,10 +68,17 @@ var storage_1 = require("./storage");
42
68
  Object.defineProperty(exports, "ClefbaseStorage", { enumerable: true, get: function () { return storage_1.ClefbaseStorage; } });
43
69
  Object.defineProperty(exports, "StorageReference", { enumerable: true, get: function () { return storage_1.StorageReference; } });
44
70
  Object.defineProperty(exports, "BucketReference", { enumerable: true, get: function () { return storage_1.BucketReference; } });
71
+ // ─── Auth UI components (React) ───────────────────────────────────────────────
72
+ var EmailVerificationCard_1 = require("./react/EmailVerificationCard");
73
+ Object.defineProperty(exports, "EmailVerificationCard", { enumerable: true, get: function () { return EmailVerificationCard_1.EmailVerificationCard; } });
45
74
  // ─── Hosting ──────────────────────────────────────────────────────────────────
46
75
  var hosting_1 = require("./hosting");
47
76
  Object.defineProperty(exports, "ClefbaseHosting", { enumerable: true, get: function () { return hosting_1.ClefbaseHosting; } });
48
77
  Object.defineProperty(exports, "SiteReference", { enumerable: true, get: function () { return hosting_1.SiteReference; } });
78
+ // ─── FieldValue ───────────────────────────────────────────────────────────────
79
+ var field_value_1 = require("./field_value");
80
+ Object.defineProperty(exports, "FieldValue", { enumerable: true, get: function () { return field_value_1.FieldValue; } });
81
+ Object.defineProperty(exports, "FieldValueSentinel", { enumerable: true, get: function () { return field_value_1.FieldValueSentinel; } });
49
82
  var types_1 = require("./types");
50
83
  Object.defineProperty(exports, "ClefbaseError", { enumerable: true, get: function () { return types_1.ClefbaseError; } });
51
84
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,iFAAiF;AACjF,6BAQe;AAPb,kGAAA,WAAW,OAAA;AACX,mGAAA,YAAY,OAAA;AACZ,6FAAA,MAAM,OAAA;AACN,kGAAA,WAAW,OAAA;AACX,8FAAA,OAAO,OAAA;AACP,iGAAA,UAAU,OAAA;AACV,iGAAA,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ACjF,qCAA2D;AAAlD,0GAAA,eAAe,OAAA;AAAE,wGAAA,aAAa,OAAA;AAWvC,iFAAiF;AACjF,6CAA+D;AAAtD,yGAAA,UAAU,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAiBvC,iCAAwC;AAA/B,sGAAA,aAAa,OAAA"}
@@ -0,0 +1,18 @@
1
+ import type { Auth } from "../auth";
2
+ export interface EmailVerificationCardProps {
3
+ /** Instance of the Clefbase Auth service. */
4
+ auth: Auth;
5
+ /** Optional callback after a successful verification check. */
6
+ onVerified?: () => void;
7
+ /** Optional callback when the verification email is successfully sent. */
8
+ onSent?: () => void;
9
+ /** Optional callback when an error occurs. */
10
+ onError?: (err: Error) => void;
11
+ /** Allows customizing the wording shown on the card. */
12
+ title?: string;
13
+ description?: string;
14
+ buttonText?: string;
15
+ resendText?: string;
16
+ }
17
+ export declare function EmailVerificationCard({ auth, onVerified, onSent, onError, title, description, buttonText, resendText, }: EmailVerificationCardProps): import("react/jsx-runtime").JSX.Element | null;
18
+ //# sourceMappingURL=EmailVerificationCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailVerificationCard.d.ts","sourceRoot":"","sources":["../../src/react/EmailVerificationCard.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,WAAW,0BAA0B;IACzC,6CAA6C;IAC7C,IAAI,EAAE,IAAI,CAAC;IACX,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAA2B,EAC3B,WAA2E,EAC3E,UAAwC,EACxC,UAAsF,GACvF,EAAE,0BAA0B,kDAwE5B"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailVerificationCard = EmailVerificationCard;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ function EmailVerificationCard({ auth, onVerified, onSent, onError, title = "Verify your email", description = "Please verify your email address to continue using the app.", buttonText = "Resend verification email", resendText = "If you already verified, click the button again to refresh your status.", }) {
7
+ const [user, setUser] = (0, react_1.useState)(auth.currentUser);
8
+ const [status, setStatus] = (0, react_1.useState)("idle");
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ (0, react_1.useEffect)(() => {
11
+ const unsub = auth.onAuthStateChanged((u) => {
12
+ setUser(u);
13
+ if (u && u.emailVerified) {
14
+ onVerified?.();
15
+ }
16
+ });
17
+ return unsub;
18
+ }, [auth, onVerified]);
19
+ const disabled = (0, react_1.useMemo)(() => status === "sending" || !user, [status, user]);
20
+ if (!user || user.emailVerified)
21
+ return null;
22
+ const handleSend = async () => {
23
+ setStatus("sending");
24
+ setError(null);
25
+ try {
26
+ await auth.sendEmailVerification();
27
+ setStatus("sent");
28
+ onSent?.();
29
+ }
30
+ catch (err) {
31
+ const message = err?.message ?? "Failed to send verification email.";
32
+ setError(message);
33
+ setStatus("error");
34
+ onError?.(err);
35
+ }
36
+ };
37
+ return ((0, jsx_runtime_1.jsx)("div", { style: { border: "1px solid rgba(148, 163, 184, 0.4)", borderRadius: 12, padding: 18, background: "rgba(255, 255, 255, 0.9)", boxShadow: "0 12px 28px rgba(15, 23, 42, 0.08)" }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { margin: 0, fontSize: 18, fontWeight: 600, color: "#0f172a" }, children: title }), (0, jsx_runtime_1.jsx)("p", { style: { margin: "6px 0 0", fontSize: 13, color: "#334155" }, children: description })] }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleSend, disabled: disabled, style: {
38
+ appearance: "none",
39
+ border: "none",
40
+ borderRadius: 10,
41
+ padding: "10px 14px",
42
+ fontSize: 13,
43
+ fontWeight: 600,
44
+ color: "#fff",
45
+ background: "linear-gradient(90deg, #2563eb, #14b8a6)",
46
+ cursor: disabled ? "not-allowed" : "pointer",
47
+ opacity: disabled ? 0.6 : 1,
48
+ }, children: status === "sending" ? "Sending…" : buttonText }), status === "sent" && ((0, jsx_runtime_1.jsx)("p", { style: { margin: 0, fontSize: 12, color: "#16a34a" }, children: "Verification email sent. Please check your inbox." })), status === "error" && error && ((0, jsx_runtime_1.jsx)("p", { style: { margin: 0, fontSize: 12, color: "#b91c1c" }, children: error })), (0, jsx_runtime_1.jsx)("p", { style: { margin: 0, fontSize: 12, color: "#64748b" }, children: resendText })] }) }));
49
+ }
50
+ //# sourceMappingURL=EmailVerificationCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailVerificationCard.js","sourceRoot":"","sources":["../../src/react/EmailVerificationCard.tsx"],"names":[],"mappings":";;AAmBA,sDAiFC;;AApGD,iCAA4D;AAmB5D,SAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,UAAU,EACV,MAAM,EACN,OAAO,EACP,KAAK,GAAG,mBAAmB,EAC3B,WAAW,GAAG,6DAA6D,EAC3E,UAAU,GAAG,2BAA2B,EACxC,UAAU,GAAG,yEAAyE,GAC3D;IAC3B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,g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CAC9B,8BAAG,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,YAAG,KAAK,GAAK,CACrE,EACD,8BAAG,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,YAAG,UAAU,GAAK,IACrE,GACF,CACP,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clefbase",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Firebase-style SDK and CLI for Clefbase — database, auth, storage, and hosting",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,11 @@
17
17
  "require": "./dist/react/StorageImage.js",
18
18
  "import": "./dist/react/StorageImage.js",
19
19
  "types": "./dist/react/StorageImage.d.ts"
20
+ },
21
+ "./react/EmailVerificationCard": {
22
+ "require": "./dist/react/EmailVerificationCard.js",
23
+ "import": "./dist/react/EmailVerificationCard.js",
24
+ "types": "./dist/react/EmailVerificationCard.d.ts"
20
25
  }
21
26
  },
22
27
  "files": [