@umituz/react-native-firebase 1.13.49 → 1.13.51
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/scripts/cli-handlers.d.ts +27 -0
- package/dist/scripts/cli-handlers.d.ts.map +1 -0
- package/dist/scripts/cli-handlers.js +125 -0
- package/dist/scripts/cli-handlers.js.map +1 -0
- package/dist/scripts/cli-parser.d.ts +25 -0
- package/dist/scripts/cli-parser.d.ts.map +1 -0
- package/dist/scripts/cli-parser.js +101 -0
- package/dist/scripts/cli-parser.js.map +1 -0
- package/dist/scripts/cli.js +20 -155
- package/dist/scripts/cli.js.map +1 -1
- package/dist/scripts/firestore-operations.d.ts +18 -0
- package/dist/scripts/firestore-operations.d.ts.map +1 -0
- package/dist/scripts/firestore-operations.js +88 -0
- package/dist/scripts/firestore-operations.js.map +1 -0
- package/dist/scripts/firestore-queries.d.ts +27 -0
- package/dist/scripts/firestore-queries.d.ts.map +1 -0
- package/dist/scripts/firestore-queries.js +77 -0
- package/dist/scripts/firestore-queries.js.map +1 -0
- package/dist/scripts/firestore-seeding.d.ts +21 -0
- package/dist/scripts/firestore-seeding.d.ts.map +1 -0
- package/dist/scripts/firestore-seeding.js +67 -0
- package/dist/scripts/firestore-seeding.js.map +1 -0
- package/dist/scripts/firestore.d.ts +3 -48
- package/dist/scripts/firestore.d.ts.map +1 -1
- package/dist/scripts/firestore.js +16 -210
- package/dist/scripts/firestore.js.map +1 -1
- package/dist/scripts/user-commands.d.ts +33 -0
- package/dist/scripts/user-commands.d.ts.map +1 -0
- package/dist/scripts/user-commands.js +113 -0
- package/dist/scripts/user-commands.js.map +1 -0
- package/dist/scripts/user-formatters.d.ts +10 -0
- package/dist/scripts/user-formatters.d.ts.map +1 -0
- package/dist/scripts/user-formatters.js +55 -0
- package/dist/scripts/user-formatters.js.map +1 -0
- package/dist/scripts/user-queries.d.ts +42 -0
- package/dist/scripts/user-queries.d.ts.map +1 -0
- package/dist/scripts/user-queries.js +125 -0
- package/dist/scripts/user-queries.js.map +1 -0
- package/dist/scripts/user.d.ts +3 -67
- package/dist/scripts/user.d.ts.map +1 -1
- package/dist/scripts/user.js +15 -272
- package/dist/scripts/user.js.map +1 -1
- package/package.json +1 -1
- package/scripts/cli-handlers.ts +170 -0
- package/scripts/cli-parser.ts +82 -0
- package/scripts/cli.ts +27 -193
- package/scripts/firestore-operations.ts +111 -0
- package/scripts/firestore-queries.ts +97 -0
- package/scripts/firestore-seeding.ts +87 -0
- package/scripts/firestore.ts +20 -275
- package/scripts/user-commands.ts +104 -0
- package/scripts/user-formatters.ts +55 -0
- package/scripts/user-queries.ts +185 -0
- package/scripts/user.ts +19 -326
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Admin CLI Command Handlers
|
|
3
|
+
* Individual command implementations
|
|
4
|
+
*/
|
|
5
|
+
import * as admin from "firebase-admin";
|
|
6
|
+
import type { CLIOptions } from "./cli-parser";
|
|
7
|
+
/**
|
|
8
|
+
* Handle read-user command
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleReadUser(db: admin.firestore.Firestore, args: string[], options: CLIOptions): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Handle init-credits command
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleInitCredits(db: admin.firestore.Firestore, args: string[], options: CLIOptions): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Handle set-credits command
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleSetCredits(db: admin.firestore.Firestore, args: string[], options: CLIOptions): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Handle list-users command
|
|
21
|
+
*/
|
|
22
|
+
export declare function handleListUsers(db: admin.firestore.Firestore, args: string[], options: CLIOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Handle credits-summary command
|
|
25
|
+
*/
|
|
26
|
+
export declare function handleCreditsSummary(db: admin.firestore.Firestore, options: CLIOptions): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=cli-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-handlers.d.ts","sourceRoot":"","sources":["../../scripts/cli-handlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW/C;;GAEG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Firebase Admin CLI Command Handlers
|
|
4
|
+
* Individual command implementations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.handleReadUser = handleReadUser;
|
|
8
|
+
exports.handleInitCredits = handleInitCredits;
|
|
9
|
+
exports.handleSetCredits = handleSetCredits;
|
|
10
|
+
exports.handleListUsers = handleListUsers;
|
|
11
|
+
exports.handleCreditsSummary = handleCreditsSummary;
|
|
12
|
+
const user_1 = require("./user");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
/**
|
|
15
|
+
* Handle read-user command
|
|
16
|
+
*/
|
|
17
|
+
async function handleReadUser(db, args, options) {
|
|
18
|
+
const userId = args[0];
|
|
19
|
+
if (!userId) {
|
|
20
|
+
console.error("❌ Error: userId is required");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
(0, utils_1.printHeader)(`📖 READ USER: ${userId}`);
|
|
24
|
+
const userData = await (0, user_1.getUserData)(db, userId, {
|
|
25
|
+
creditsCollection: options.creditsCollection,
|
|
26
|
+
});
|
|
27
|
+
(0, user_1.printUserData)(userData);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handle init-credits command
|
|
31
|
+
*/
|
|
32
|
+
async function handleInitCredits(db, args, options) {
|
|
33
|
+
const userId = args[0];
|
|
34
|
+
if (!userId) {
|
|
35
|
+
console.error("❌ Error: userId is required");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
(0, utils_1.printHeader)(`💰 INIT CREDITS: ${userId}`);
|
|
39
|
+
console.log(`Collection: ${options.creditsCollection}`);
|
|
40
|
+
console.log(`Limits: Text=${options.textLimit}, Image=${options.imageLimit}\n`);
|
|
41
|
+
const existing = await (0, user_1.getUserData)(db, userId, {
|
|
42
|
+
creditsCollection: options.creditsCollection,
|
|
43
|
+
});
|
|
44
|
+
if (existing.credits) {
|
|
45
|
+
console.log("⚠️ Credits already exist:");
|
|
46
|
+
console.log(` Text: ${existing.credits.text}`);
|
|
47
|
+
console.log(` Image: ${existing.credits.image}`);
|
|
48
|
+
console.log("\n Use 'set-credits' to overwrite.");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const credits = await (0, user_1.initializeUserCredits)(db, userId, {
|
|
52
|
+
collectionName: options.creditsCollection,
|
|
53
|
+
textLimit: options.textLimit,
|
|
54
|
+
imageLimit: options.imageLimit,
|
|
55
|
+
});
|
|
56
|
+
console.log("✅ Credits initialized:");
|
|
57
|
+
console.log(` Text: ${credits.text}`);
|
|
58
|
+
console.log(` Image: ${credits.image}`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handle set-credits command
|
|
62
|
+
*/
|
|
63
|
+
async function handleSetCredits(db, args, options) {
|
|
64
|
+
const userId = args[0];
|
|
65
|
+
const text = parseInt(args[1]);
|
|
66
|
+
const image = parseInt(args[2]);
|
|
67
|
+
if (!userId || isNaN(text) || isNaN(image)) {
|
|
68
|
+
console.error("❌ Error: Usage: set-credits <userId> <text> <image>");
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
(0, utils_1.printHeader)(`💰 SET CREDITS: ${userId}`);
|
|
72
|
+
console.log(`Setting: Text=${text}, Image=${image}\n`);
|
|
73
|
+
await (0, user_1.setUserCredits)(db, userId, { text, image }, options.creditsCollection);
|
|
74
|
+
console.log("✅ Credits set successfully!");
|
|
75
|
+
const updated = await (0, user_1.getUserData)(db, userId, {
|
|
76
|
+
creditsCollection: options.creditsCollection,
|
|
77
|
+
});
|
|
78
|
+
(0, user_1.printUserData)(updated);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Handle list-users command
|
|
82
|
+
*/
|
|
83
|
+
async function handleListUsers(db, args, options) {
|
|
84
|
+
const limit = parseInt(args[0]) || 100;
|
|
85
|
+
(0, utils_1.printHeader)("👥 USERS WITH CREDITS");
|
|
86
|
+
const users = await (0, user_1.listUsersWithCredits)(db, {
|
|
87
|
+
creditsCollection: options.creditsCollection,
|
|
88
|
+
limit,
|
|
89
|
+
});
|
|
90
|
+
console.log(`Found ${users.length} users:\n`);
|
|
91
|
+
(0, utils_1.printSeparator)("-", 80);
|
|
92
|
+
console.log("ID".padEnd(30) +
|
|
93
|
+
"Name".padEnd(20) +
|
|
94
|
+
"Text".padEnd(10) +
|
|
95
|
+
"Image".padEnd(10) +
|
|
96
|
+
"Anon");
|
|
97
|
+
(0, utils_1.printSeparator)("-", 80);
|
|
98
|
+
users.forEach((u) => {
|
|
99
|
+
const text = u.credits?.text ?? "-";
|
|
100
|
+
const image = u.credits?.image ?? "-";
|
|
101
|
+
console.log(u.userId.substring(0, 28).padEnd(30) +
|
|
102
|
+
(u.displayName || "-").substring(0, 18).padEnd(20) +
|
|
103
|
+
String(text).padEnd(10) +
|
|
104
|
+
String(image).padEnd(10) +
|
|
105
|
+
(u.isAnonymous ? "Yes" : "No"));
|
|
106
|
+
});
|
|
107
|
+
(0, utils_1.printSeparator)("-", 80);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Handle credits-summary command
|
|
111
|
+
*/
|
|
112
|
+
async function handleCreditsSummary(db, options) {
|
|
113
|
+
(0, utils_1.printHeader)("📊 CREDITS SUMMARY");
|
|
114
|
+
const summary = await (0, user_1.getCreditsSummary)(db, options.creditsCollection);
|
|
115
|
+
console.log(`Total Users: ${summary.totalUsers}`);
|
|
116
|
+
console.log(`With Credits: ${summary.usersWithCredits}`);
|
|
117
|
+
console.log(`Zero Credits: ${summary.usersWithZeroCredits}`);
|
|
118
|
+
console.log();
|
|
119
|
+
console.log("Total Credits Across All Users:");
|
|
120
|
+
console.log(` Text: ${summary.totalText}`);
|
|
121
|
+
console.log(` Image: ${summary.totalImage}`);
|
|
122
|
+
console.log(` Video: ${summary.totalVideo}`);
|
|
123
|
+
console.log(` Audio: ${summary.totalAudio}`);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=cli-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-handlers.js","sourceRoot":"","sources":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C,GAAG,CAAC,oBAAoB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Admin CLI Parser
|
|
3
|
+
* Command line argument parsing utilities
|
|
4
|
+
*/
|
|
5
|
+
export interface CLIOptions {
|
|
6
|
+
serviceAccountPath: string;
|
|
7
|
+
projectId?: string;
|
|
8
|
+
creditsCollection: string;
|
|
9
|
+
textLimit: number;
|
|
10
|
+
imageLimit: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ParsedArgs {
|
|
13
|
+
command: string;
|
|
14
|
+
args: string[];
|
|
15
|
+
options: CLIOptions;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parse command line arguments
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseArgs(): ParsedArgs;
|
|
21
|
+
/**
|
|
22
|
+
* Get project ID from options or service account
|
|
23
|
+
*/
|
|
24
|
+
export declare function getProjectId(options: CLIOptions): string;
|
|
25
|
+
//# sourceMappingURL=cli-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.d.ts","sourceRoot":"","sources":["../../scripts/cli-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,UAAU;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,UAAU,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,UAAU,CAyCtC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAUxD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Firebase Admin CLI Parser
|
|
4
|
+
* Command line argument parsing utilities
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.parseArgs = parseArgs;
|
|
41
|
+
exports.getProjectId = getProjectId;
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
/**
|
|
45
|
+
* Parse command line arguments
|
|
46
|
+
*/
|
|
47
|
+
function parseArgs() {
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
const command = args[0] || "help";
|
|
50
|
+
const commandArgs = [];
|
|
51
|
+
const options = {
|
|
52
|
+
serviceAccountPath: "./firebase-service-account.json",
|
|
53
|
+
creditsCollection: "user_credits",
|
|
54
|
+
textLimit: 100,
|
|
55
|
+
imageLimit: 100,
|
|
56
|
+
};
|
|
57
|
+
let i = 1;
|
|
58
|
+
while (i < args.length) {
|
|
59
|
+
const arg = args[i];
|
|
60
|
+
if (arg.startsWith("--")) {
|
|
61
|
+
const key = arg.slice(2);
|
|
62
|
+
const value = args[++i];
|
|
63
|
+
switch (key) {
|
|
64
|
+
case "service-account":
|
|
65
|
+
options.serviceAccountPath = value;
|
|
66
|
+
break;
|
|
67
|
+
case "project-id":
|
|
68
|
+
options.projectId = value;
|
|
69
|
+
break;
|
|
70
|
+
case "credits-collection":
|
|
71
|
+
options.creditsCollection = value;
|
|
72
|
+
break;
|
|
73
|
+
case "text-limit":
|
|
74
|
+
options.textLimit = parseInt(value) || 100;
|
|
75
|
+
break;
|
|
76
|
+
case "image-limit":
|
|
77
|
+
options.imageLimit = parseInt(value) || 100;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
commandArgs.push(arg);
|
|
83
|
+
}
|
|
84
|
+
i++;
|
|
85
|
+
}
|
|
86
|
+
return { command, args: commandArgs, options };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get project ID from options or service account
|
|
90
|
+
*/
|
|
91
|
+
function getProjectId(options) {
|
|
92
|
+
if (options.projectId)
|
|
93
|
+
return options.projectId;
|
|
94
|
+
const saPath = path.resolve(process.cwd(), options.serviceAccountPath);
|
|
95
|
+
if (fs.existsSync(saPath)) {
|
|
96
|
+
const sa = JSON.parse(fs.readFileSync(saPath, "utf8"));
|
|
97
|
+
return sa.project_id;
|
|
98
|
+
}
|
|
99
|
+
throw new Error("Project ID not found. Use --project-id or ensure service account file exists.");
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=cli-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.js","sourceRoot":"","sources":["../../scripts/cli-parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBH,8BAyCC;AAKD,oCAUC;AA5ED,2CAA6B;AAC7B,uCAAyB;AAgBzB;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;IAClC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,OAAO,GAAe;QAC1B,kBAAkB,EAAE,iCAAiC;QACrD,iBAAiB,EAAE,cAAc;QACjC,SAAS,EAAE,GAAG;QACd,UAAU,EAAE,GAAG;KAChB,CAAC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AC,CAAC;IACvE,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACvD,OAAO,EAAE,CAAC,UAAU,CAAC;IACvB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;AACnG,CAAC"}
|
package/dist/scripts/cli.js
CHANGED
|
@@ -56,65 +56,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
56
56
|
})();
|
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
const path = __importStar(require("path"));
|
|
59
|
-
const fs = __importStar(require("fs"));
|
|
60
59
|
const init_1 = require("./init");
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
const command = args[0] || "help";
|
|
66
|
-
const commandArgs = [];
|
|
67
|
-
const options = {
|
|
68
|
-
serviceAccountPath: "./firebase-service-account.json",
|
|
69
|
-
creditsCollection: "user_credits",
|
|
70
|
-
textLimit: 100,
|
|
71
|
-
imageLimit: 100,
|
|
72
|
-
};
|
|
73
|
-
let i = 1;
|
|
74
|
-
while (i < args.length) {
|
|
75
|
-
const arg = args[i];
|
|
76
|
-
if (arg.startsWith("--")) {
|
|
77
|
-
const key = arg.slice(2);
|
|
78
|
-
const value = args[++i];
|
|
79
|
-
switch (key) {
|
|
80
|
-
case "service-account":
|
|
81
|
-
options.serviceAccountPath = value;
|
|
82
|
-
break;
|
|
83
|
-
case "project-id":
|
|
84
|
-
options.projectId = value;
|
|
85
|
-
break;
|
|
86
|
-
case "credits-collection":
|
|
87
|
-
options.creditsCollection = value;
|
|
88
|
-
break;
|
|
89
|
-
case "text-limit":
|
|
90
|
-
options.textLimit = parseInt(value) || 100;
|
|
91
|
-
break;
|
|
92
|
-
case "image-limit":
|
|
93
|
-
options.imageLimit = parseInt(value) || 100;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
commandArgs.push(arg);
|
|
99
|
-
}
|
|
100
|
-
i++;
|
|
101
|
-
}
|
|
102
|
-
return { command, args: commandArgs, options };
|
|
103
|
-
}
|
|
104
|
-
function getProjectId(options) {
|
|
105
|
-
if (options.projectId)
|
|
106
|
-
return options.projectId;
|
|
107
|
-
const saPath = path.resolve(process.cwd(), options.serviceAccountPath);
|
|
108
|
-
if (fs.existsSync(saPath)) {
|
|
109
|
-
const sa = JSON.parse(fs.readFileSync(saPath, "utf8"));
|
|
110
|
-
return sa.project_id;
|
|
111
|
-
}
|
|
112
|
-
throw new Error("Project ID not found. Use --project-id or ensure service account file exists.");
|
|
113
|
-
}
|
|
114
|
-
async function main() {
|
|
115
|
-
const { command, args, options } = parseArgs();
|
|
116
|
-
if (command === "help") {
|
|
117
|
-
console.log(`
|
|
60
|
+
const cli_parser_1 = require("./cli-parser");
|
|
61
|
+
const cli_handlers_1 = require("./cli-handlers");
|
|
62
|
+
function printHelp() {
|
|
63
|
+
console.log(`
|
|
118
64
|
Firebase Admin CLI
|
|
119
65
|
|
|
120
66
|
Commands:
|
|
@@ -138,10 +84,15 @@ Examples:
|
|
|
138
84
|
npx ts-node cli.ts list-users --limit 50
|
|
139
85
|
npx ts-node cli.ts credits-summary
|
|
140
86
|
`);
|
|
87
|
+
}
|
|
88
|
+
async function main() {
|
|
89
|
+
const { command, args, options } = (0, cli_parser_1.parseArgs)();
|
|
90
|
+
if (command === "help") {
|
|
91
|
+
printHelp();
|
|
141
92
|
process.exit(0);
|
|
142
93
|
}
|
|
143
94
|
try {
|
|
144
|
-
const projectId = getProjectId(options);
|
|
95
|
+
const projectId = (0, cli_parser_1.getProjectId)(options);
|
|
145
96
|
const saPath = path.resolve(process.cwd(), options.serviceAccountPath);
|
|
146
97
|
const app = (0, init_1.initFirebaseAdmin)({
|
|
147
98
|
serviceAccountPath: saPath,
|
|
@@ -149,107 +100,21 @@ Examples:
|
|
|
149
100
|
});
|
|
150
101
|
const db = (0, init_1.getFirestoreAdmin)(app);
|
|
151
102
|
switch (command) {
|
|
152
|
-
case "read-user":
|
|
153
|
-
|
|
154
|
-
if (!userId) {
|
|
155
|
-
console.error("❌ Error: userId is required");
|
|
156
|
-
process.exit(1);
|
|
157
|
-
}
|
|
158
|
-
(0, utils_1.printHeader)(`📖 READ USER: ${userId}`);
|
|
159
|
-
const userData = await (0, user_1.getUserData)(db, userId, {
|
|
160
|
-
creditsCollection: options.creditsCollection,
|
|
161
|
-
});
|
|
162
|
-
(0, user_1.printUserData)(userData);
|
|
103
|
+
case "read-user":
|
|
104
|
+
await (0, cli_handlers_1.handleReadUser)(db, args, options);
|
|
163
105
|
break;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const userId = args[0];
|
|
167
|
-
if (!userId) {
|
|
168
|
-
console.error("❌ Error: userId is required");
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
(0, utils_1.printHeader)(`💰 INIT CREDITS: ${userId}`);
|
|
172
|
-
console.log(`Collection: ${options.creditsCollection}`);
|
|
173
|
-
console.log(`Limits: Text=${options.textLimit}, Image=${options.imageLimit}\n`);
|
|
174
|
-
const existing = await (0, user_1.getUserData)(db, userId, {
|
|
175
|
-
creditsCollection: options.creditsCollection,
|
|
176
|
-
});
|
|
177
|
-
if (existing.credits) {
|
|
178
|
-
console.log("⚠️ Credits already exist:");
|
|
179
|
-
console.log(` Text: ${existing.credits.text}`);
|
|
180
|
-
console.log(` Image: ${existing.credits.image}`);
|
|
181
|
-
console.log("\n Use 'set-credits' to overwrite.");
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
const credits = await (0, user_1.initializeUserCredits)(db, userId, {
|
|
185
|
-
collectionName: options.creditsCollection,
|
|
186
|
-
textLimit: options.textLimit,
|
|
187
|
-
imageLimit: options.imageLimit,
|
|
188
|
-
});
|
|
189
|
-
console.log("✅ Credits initialized:");
|
|
190
|
-
console.log(` Text: ${credits.text}`);
|
|
191
|
-
console.log(` Image: ${credits.image}`);
|
|
106
|
+
case "init-credits":
|
|
107
|
+
await (0, cli_handlers_1.handleInitCredits)(db, args, options);
|
|
192
108
|
break;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const userId = args[0];
|
|
196
|
-
const text = parseInt(args[1]);
|
|
197
|
-
const image = parseInt(args[2]);
|
|
198
|
-
if (!userId || isNaN(text) || isNaN(image)) {
|
|
199
|
-
console.error("❌ Error: Usage: set-credits <userId> <text> <image>");
|
|
200
|
-
process.exit(1);
|
|
201
|
-
}
|
|
202
|
-
(0, utils_1.printHeader)(`💰 SET CREDITS: ${userId}`);
|
|
203
|
-
console.log(`Setting: Text=${text}, Image=${image}\n`);
|
|
204
|
-
await (0, user_1.setUserCredits)(db, userId, { text, image }, options.creditsCollection);
|
|
205
|
-
console.log("✅ Credits set successfully!");
|
|
206
|
-
const updated = await (0, user_1.getUserData)(db, userId, {
|
|
207
|
-
creditsCollection: options.creditsCollection,
|
|
208
|
-
});
|
|
209
|
-
(0, user_1.printUserData)(updated);
|
|
109
|
+
case "set-credits":
|
|
110
|
+
await (0, cli_handlers_1.handleSetCredits)(db, args, options);
|
|
210
111
|
break;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const limit = parseInt(args[0]) || 100;
|
|
214
|
-
(0, utils_1.printHeader)("👥 USERS WITH CREDITS");
|
|
215
|
-
const users = await (0, user_1.listUsersWithCredits)(db, {
|
|
216
|
-
creditsCollection: options.creditsCollection,
|
|
217
|
-
limit,
|
|
218
|
-
});
|
|
219
|
-
console.log(`Found ${users.length} users:\n`);
|
|
220
|
-
(0, utils_1.printSeparator)("-", 80);
|
|
221
|
-
console.log("ID".padEnd(30) +
|
|
222
|
-
"Name".padEnd(20) +
|
|
223
|
-
"Text".padEnd(10) +
|
|
224
|
-
"Image".padEnd(10) +
|
|
225
|
-
"Anon");
|
|
226
|
-
(0, utils_1.printSeparator)("-", 80);
|
|
227
|
-
users.forEach((u) => {
|
|
228
|
-
const text = u.credits?.text ?? "-";
|
|
229
|
-
const image = u.credits?.image ?? "-";
|
|
230
|
-
console.log(u.userId.substring(0, 28).padEnd(30) +
|
|
231
|
-
(u.displayName || "-").substring(0, 18).padEnd(20) +
|
|
232
|
-
String(text).padEnd(10) +
|
|
233
|
-
String(image).padEnd(10) +
|
|
234
|
-
(u.isAnonymous ? "Yes" : "No"));
|
|
235
|
-
});
|
|
236
|
-
(0, utils_1.printSeparator)("-", 80);
|
|
112
|
+
case "list-users":
|
|
113
|
+
await (0, cli_handlers_1.handleListUsers)(db, args, options);
|
|
237
114
|
break;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
(0, utils_1.printHeader)("📊 CREDITS SUMMARY");
|
|
241
|
-
const summary = await (0, user_1.getCreditsSummary)(db, options.creditsCollection);
|
|
242
|
-
console.log(`Total Users: ${summary.totalUsers}`);
|
|
243
|
-
console.log(`With Credits: ${summary.usersWithCredits}`);
|
|
244
|
-
console.log(`Zero Credits: ${summary.usersWithZeroCredits}`);
|
|
245
|
-
console.log();
|
|
246
|
-
console.log("Total Credits Across All Users:");
|
|
247
|
-
console.log(` Text: ${summary.totalText}`);
|
|
248
|
-
console.log(` Image: ${summary.totalImage}`);
|
|
249
|
-
console.log(` Video: ${summary.totalVideo}`);
|
|
250
|
-
console.log(` Audio: ${summary.totalAudio}`);
|
|
115
|
+
case "credits-summary":
|
|
116
|
+
await (0, cli_handlers_1.handleCreditsSummary)(db, options);
|
|
251
117
|
break;
|
|
252
|
-
}
|
|
253
118
|
default:
|
|
254
119
|
console.error(`❌ Unknown command: ${command}`);
|
|
255
120
|
console.log("Run with 'help' for available commands.");
|
package/dist/scripts/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../scripts/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;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MAAM,IAAA,+BAAgB,EAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC1C,MAAM;YAER,KAAK,YAAY;gBACf,MAAM,IAAA,8BAAe,EAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBACzC,MAAM;YAER,KAAK,iBAAiB;gBACpB,MAAM,IAAA,mCAAoB,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBACxC,MAAM;YAER;gBACE,OAAO,CAAC,KAAK,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;gBAC/C,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;QAED,IAAA,yBAAkB,GAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Admin Firestore Operations
|
|
3
|
+
* Delete operations for Firestore data
|
|
4
|
+
*/
|
|
5
|
+
import * as admin from "firebase-admin";
|
|
6
|
+
/**
|
|
7
|
+
* Delete collection in batches
|
|
8
|
+
*/
|
|
9
|
+
export declare function deleteCollection(db: admin.firestore.Firestore, collectionPath: string, onProgress?: (deleted: number) => void): Promise<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Delete user subcollection for all users
|
|
12
|
+
*/
|
|
13
|
+
export declare function deleteUserSubcollection(db: admin.firestore.Firestore, subcollectionName: string, onProgress?: (deleted: number) => void): Promise<number>;
|
|
14
|
+
/**
|
|
15
|
+
* Delete all Firestore data
|
|
16
|
+
*/
|
|
17
|
+
export declare function deleteAllData(db: admin.firestore.Firestore, onProgress?: (collection: string, deleted: number) => void): Promise<number>;
|
|
18
|
+
//# sourceMappingURL=firestore-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-operations.d.ts","sourceRoot":"","sources":["../../scripts/firestore-operations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAIxC;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,cAAc,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACrC,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,iBAAiB,EAAE,MAAM,EACzB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACrC,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,EAC7B,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GACzD,OAAO,CAAC,MAAM,CAAC,CAkCjB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Firebase Admin Firestore Operations
|
|
4
|
+
* Delete operations for Firestore data
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.deleteCollection = deleteCollection;
|
|
8
|
+
exports.deleteUserSubcollection = deleteUserSubcollection;
|
|
9
|
+
exports.deleteAllData = deleteAllData;
|
|
10
|
+
const BATCH_SIZE = 500;
|
|
11
|
+
/**
|
|
12
|
+
* Delete collection in batches
|
|
13
|
+
*/
|
|
14
|
+
async function deleteCollection(db, collectionPath, onProgress) {
|
|
15
|
+
let totalDeleted = 0;
|
|
16
|
+
let hasMore = true;
|
|
17
|
+
while (hasMore) {
|
|
18
|
+
const snapshot = await db
|
|
19
|
+
.collection(collectionPath)
|
|
20
|
+
.orderBy("__name__")
|
|
21
|
+
.limit(BATCH_SIZE)
|
|
22
|
+
.get();
|
|
23
|
+
if (snapshot.empty) {
|
|
24
|
+
hasMore = false;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const batch = db.batch();
|
|
28
|
+
snapshot.docs.forEach((doc) => batch.delete(doc.ref));
|
|
29
|
+
await batch.commit();
|
|
30
|
+
totalDeleted += snapshot.docs.length;
|
|
31
|
+
onProgress?.(totalDeleted);
|
|
32
|
+
}
|
|
33
|
+
return totalDeleted;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Delete user subcollection for all users
|
|
37
|
+
*/
|
|
38
|
+
async function deleteUserSubcollection(db, subcollectionName, onProgress) {
|
|
39
|
+
let totalDeleted = 0;
|
|
40
|
+
const usersSnapshot = await db.collection("users").get();
|
|
41
|
+
for (const userDoc of usersSnapshot.docs) {
|
|
42
|
+
const subcollectionRef = userDoc.ref.collection(subcollectionName);
|
|
43
|
+
const subcollectionSnapshot = await subcollectionRef.get();
|
|
44
|
+
if (!subcollectionSnapshot.empty) {
|
|
45
|
+
const batch = db.batch();
|
|
46
|
+
subcollectionSnapshot.docs.forEach((doc) => batch.delete(doc.ref));
|
|
47
|
+
await batch.commit();
|
|
48
|
+
totalDeleted += subcollectionSnapshot.docs.length;
|
|
49
|
+
onProgress?.(totalDeleted);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return totalDeleted;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Delete all Firestore data
|
|
56
|
+
*/
|
|
57
|
+
async function deleteAllData(db, onProgress) {
|
|
58
|
+
let totalDeleted = 0;
|
|
59
|
+
const collections = await db.listCollections();
|
|
60
|
+
for (const collection of collections) {
|
|
61
|
+
const snapshot = await collection.get();
|
|
62
|
+
// Delete subcollections first for users collection
|
|
63
|
+
if (collection.id === "users") {
|
|
64
|
+
for (const doc of snapshot.docs) {
|
|
65
|
+
const subcollections = await doc.ref.listCollections();
|
|
66
|
+
for (const subcollection of subcollections) {
|
|
67
|
+
const subSnapshot = await subcollection.get();
|
|
68
|
+
if (!subSnapshot.empty) {
|
|
69
|
+
const batch = db.batch();
|
|
70
|
+
subSnapshot.docs.forEach((subDoc) => batch.delete(subDoc.ref));
|
|
71
|
+
await batch.commit();
|
|
72
|
+
totalDeleted += subSnapshot.docs.length;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Delete main collection documents
|
|
78
|
+
if (!snapshot.empty) {
|
|
79
|
+
const batch = db.batch();
|
|
80
|
+
snapshot.docs.forEach((doc) => batch.delete(doc.ref));
|
|
81
|
+
await batch.commit();
|
|
82
|
+
totalDeleted += snapshot.docs.length;
|
|
83
|
+
onProgress?.(collection.id, totalDeleted);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return totalDeleted;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=firestore-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-operations.js","sourceRoot":"","sources":["../../scripts/firestore-operations.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AASH,4CA6BC;AAKD,0DAsBC;AAKD,sCAqCC;AAvGD,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;GAEG;AACI,KAAK,UAAU,gBAAgB,CACpC,EAA6B,EAC7B,cAAsB,EACtB,UAAsC;IAEtC,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,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