@mathrunet/masamune_firebase_workflow_marketing 3.8.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/CHANGELOG.md +361 -0
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/assets/fonts/NotoSans-Bold.ttf +1439 -0
- package/assets/fonts/NotoSans-Regular.ttf +1439 -0
- package/assets/fonts/NotoSans.ttf +0 -0
- package/assets/fonts/NotoSansJP-Bold.ttf +0 -0
- package/assets/fonts/NotoSansJP-Regular.ttf +0 -0
- package/assets/fonts/NotoSansKR-Bold.ttf +1439 -0
- package/assets/fonts/NotoSansKR-Regular.ttf +1439 -0
- package/assets/fonts/NotoSansKR.ttf +0 -0
- package/assets/fonts/NotoSansSC-Bold.ttf +1439 -0
- package/assets/fonts/NotoSansSC-Regular.ttf +1439 -0
- package/assets/fonts/NotoSansSC.ttf +0 -0
- package/dist/clients/app_store_client.d.ts +54 -0
- package/dist/clients/app_store_client.js +280 -0
- package/dist/clients/app_store_client.js.map +1 -0
- package/dist/clients/firebase_analytics_client.d.ts +67 -0
- package/dist/clients/firebase_analytics_client.js +411 -0
- package/dist/clients/firebase_analytics_client.js.map +1 -0
- package/dist/clients/github_content_client.d.ts +83 -0
- package/dist/clients/github_content_client.js +443 -0
- package/dist/clients/github_content_client.js.map +1 -0
- package/dist/clients/google_play_client.d.ts +49 -0
- package/dist/clients/google_play_client.js +275 -0
- package/dist/clients/google_play_client.js.map +1 -0
- package/dist/functions/analyze_github_init.d.ts +37 -0
- package/dist/functions/analyze_github_init.js +299 -0
- package/dist/functions/analyze_github_init.js.map +1 -0
- package/dist/functions/analyze_github_process.d.ts +25 -0
- package/dist/functions/analyze_github_process.js +268 -0
- package/dist/functions/analyze_github_process.js.map +1 -0
- package/dist/functions/analyze_github_summary.d.ts +32 -0
- package/dist/functions/analyze_github_summary.js +270 -0
- package/dist/functions/analyze_github_summary.js.map +1 -0
- package/dist/functions/analyze_market_research.d.ts +40 -0
- package/dist/functions/analyze_market_research.js +346 -0
- package/dist/functions/analyze_market_research.js.map +1 -0
- package/dist/functions/analyze_marketing_data.d.ts +96 -0
- package/dist/functions/analyze_marketing_data.js +990 -0
- package/dist/functions/analyze_marketing_data.js.map +1 -0
- package/dist/functions/collect_from_app_store.d.ts +25 -0
- package/dist/functions/collect_from_app_store.js +148 -0
- package/dist/functions/collect_from_app_store.js.map +1 -0
- package/dist/functions/collect_from_firebase_analytics.d.ts +25 -0
- package/dist/functions/collect_from_firebase_analytics.js +142 -0
- package/dist/functions/collect_from_firebase_analytics.js.map +1 -0
- package/dist/functions/collect_from_google_play_console.d.ts +25 -0
- package/dist/functions/collect_from_google_play_console.js +142 -0
- package/dist/functions/collect_from_google_play_console.js.map +1 -0
- package/dist/functions/generate_marketing_markdown.d.ts +89 -0
- package/dist/functions/generate_marketing_markdown.js +653 -0
- package/dist/functions/generate_marketing_markdown.js.map +1 -0
- package/dist/functions/generate_marketing_pdf.d.ts +25 -0
- package/dist/functions/generate_marketing_pdf.js +175 -0
- package/dist/functions/generate_marketing_pdf.js.map +1 -0
- package/dist/functions/research_market.d.ts +56 -0
- package/dist/functions/research_market.js +434 -0
- package/dist/functions/research_market.js.map +1 -0
- package/dist/functions.d.ts +571 -0
- package/dist/functions.js +648 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/de_DE.d.ts +5 -0
- package/dist/locales/de_DE.js +111 -0
- package/dist/locales/de_DE.js.map +1 -0
- package/dist/locales/en.d.ts +5 -0
- package/dist/locales/en.js +111 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es_ES.d.ts +5 -0
- package/dist/locales/es_ES.js +111 -0
- package/dist/locales/es_ES.js.map +1 -0
- package/dist/locales/fr_FR.d.ts +5 -0
- package/dist/locales/fr_FR.js +111 -0
- package/dist/locales/fr_FR.js.map +1 -0
- package/dist/locales/id_ID.d.ts +5 -0
- package/dist/locales/id_ID.js +111 -0
- package/dist/locales/id_ID.js.map +1 -0
- package/dist/locales/index.d.ts +59 -0
- package/dist/locales/index.js +155 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/locales/ja.d.ts +5 -0
- package/dist/locales/ja.js +111 -0
- package/dist/locales/ja.js.map +1 -0
- package/dist/locales/ko_KR.d.ts +5 -0
- package/dist/locales/ko_KR.js +111 -0
- package/dist/locales/ko_KR.js.map +1 -0
- package/dist/locales/pt_PT.d.ts +5 -0
- package/dist/locales/pt_PT.js +111 -0
- package/dist/locales/pt_PT.js.map +1 -0
- package/dist/locales/ru_RU.d.ts +5 -0
- package/dist/locales/ru_RU.js +111 -0
- package/dist/locales/ru_RU.js.map +1 -0
- package/dist/locales/types.d.ts +105 -0
- package/dist/locales/types.js +8 -0
- package/dist/locales/types.js.map +1 -0
- package/dist/locales/zh_CN.d.ts +5 -0
- package/dist/locales/zh_CN.js +111 -0
- package/dist/locales/zh_CN.js.map +1 -0
- package/dist/models/app_store_data.d.ts +87 -0
- package/dist/models/app_store_data.js +8 -0
- package/dist/models/app_store_data.js.map +1 -0
- package/dist/models/chart_data.d.ts +104 -0
- package/dist/models/chart_data.js +8 -0
- package/dist/models/chart_data.js.map +1 -0
- package/dist/models/common.d.ts +42 -0
- package/dist/models/common.js +8 -0
- package/dist/models/common.js.map +1 -0
- package/dist/models/firebase_analytics_data.d.ts +134 -0
- package/dist/models/firebase_analytics_data.js +8 -0
- package/dist/models/firebase_analytics_data.js.map +1 -0
- package/dist/models/github_analysis_data.d.ts +266 -0
- package/dist/models/github_analysis_data.js +101 -0
- package/dist/models/github_analysis_data.js.map +1 -0
- package/dist/models/google_play_data.d.ts +115 -0
- package/dist/models/google_play_data.js +8 -0
- package/dist/models/google_play_data.js.map +1 -0
- package/dist/models/index.d.ts +14 -0
- package/dist/models/index.js +36 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/market_research_data.d.ts +259 -0
- package/dist/models/market_research_data.js +8 -0
- package/dist/models/market_research_data.js.map +1 -0
- package/dist/models/marketing_analysis_data.d.ts +200 -0
- package/dist/models/marketing_analysis_data.js +8 -0
- package/dist/models/marketing_analysis_data.js.map +1 -0
- package/dist/models/pdf_data.d.ts +112 -0
- package/dist/models/pdf_data.js +8 -0
- package/dist/models/pdf_data.js.map +1 -0
- package/dist/services/chart_service.d.ts +54 -0
- package/dist/services/chart_service.js +436 -0
- package/dist/services/chart_service.js.map +1 -0
- package/dist/services/github_analysis_service.d.ts +73 -0
- package/dist/services/github_analysis_service.js +488 -0
- package/dist/services/github_analysis_service.js.map +1 -0
- package/dist/services/pdf_service.d.ts +112 -0
- package/dist/services/pdf_service.js +1397 -0
- package/dist/services/pdf_service.js.map +1 -0
- package/dist/utils/github_analysis_storage.d.ts +88 -0
- package/dist/utils/github_analysis_storage.js +154 -0
- package/dist/utils/github_analysis_storage.js.map +1 -0
- package/package.json +64 -0
- package/scripts/cleanup_test_data.ts +304 -0
- package/scripts/list_test_data.ts +85 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
/**
|
|
3
|
+
* Cleanup Test Data Script
|
|
4
|
+
*
|
|
5
|
+
* Deletes all test data from Firestore and Storage.
|
|
6
|
+
* This includes:
|
|
7
|
+
* - All documents with IDs starting with 'test-' in workflow collections
|
|
8
|
+
* - All subcollections (like 'usage') under those documents
|
|
9
|
+
* - All Storage files under reports/test-*
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* npx ts-node scripts/cleanup_test_data.ts
|
|
13
|
+
*
|
|
14
|
+
* Or add to package.json scripts:
|
|
15
|
+
* "cleanup": "ts-node scripts/cleanup_test_data.ts"
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as admin from "firebase-admin";
|
|
19
|
+
import * as path from "path";
|
|
20
|
+
import "@mathrunet/masamune";
|
|
21
|
+
|
|
22
|
+
// Service account path
|
|
23
|
+
const serviceAccountPath = path.resolve(__dirname, "../test/mathru-net-39425d37638c.json");
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Recursively delete all documents in a collection.
|
|
27
|
+
*/
|
|
28
|
+
async function deleteCollection(
|
|
29
|
+
firestore: admin.firestore.Firestore,
|
|
30
|
+
collectionPath: string,
|
|
31
|
+
batchSize: number = 100
|
|
32
|
+
): Promise<number> {
|
|
33
|
+
const collectionRef = firestore.collection(collectionPath);
|
|
34
|
+
let deletedCount = 0;
|
|
35
|
+
|
|
36
|
+
let query = collectionRef.limit(batchSize);
|
|
37
|
+
let snapshot = await query.load();
|
|
38
|
+
|
|
39
|
+
while (!snapshot.empty) {
|
|
40
|
+
const batch = firestore.batch();
|
|
41
|
+
|
|
42
|
+
for (const doc of snapshot.docs) {
|
|
43
|
+
// First, recursively delete subcollections
|
|
44
|
+
const subcollections = await doc.ref.listCollections();
|
|
45
|
+
for (const subcollection of subcollections) {
|
|
46
|
+
deletedCount += await deleteCollection(
|
|
47
|
+
firestore,
|
|
48
|
+
`${collectionPath}/${doc.id}/${subcollection.id}`,
|
|
49
|
+
batchSize
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
batch.delete(doc.ref);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await batch.commit();
|
|
56
|
+
deletedCount += snapshot.size;
|
|
57
|
+
snapshot = await query.load();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return deletedCount;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Delete test documents from a collection (IDs starting with 'test-').
|
|
65
|
+
*/
|
|
66
|
+
async function deleteTestDocuments(
|
|
67
|
+
firestore: admin.firestore.Firestore,
|
|
68
|
+
collectionPath: string
|
|
69
|
+
): Promise<number> {
|
|
70
|
+
const collectionRef = firestore.collection(collectionPath);
|
|
71
|
+
let deletedCount = 0;
|
|
72
|
+
|
|
73
|
+
// Query documents with IDs starting with 'test-'
|
|
74
|
+
const snapshot = await collectionRef
|
|
75
|
+
.where(admin.firestore.FieldPath.documentId(), ">=", "test-")
|
|
76
|
+
.where(admin.firestore.FieldPath.documentId(), "<", "test-\uf8ff")
|
|
77
|
+
.load();
|
|
78
|
+
|
|
79
|
+
if (snapshot.empty) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log(` Found ${snapshot.size} test documents in ${collectionPath}`);
|
|
84
|
+
|
|
85
|
+
for (const doc of snapshot.docs) {
|
|
86
|
+
// First, recursively delete subcollections
|
|
87
|
+
const subcollections = await doc.ref.listCollections();
|
|
88
|
+
for (const subcollection of subcollections) {
|
|
89
|
+
const subPath = `${collectionPath}/${doc.id}/${subcollection.id}`;
|
|
90
|
+
console.log(` Deleting subcollection: ${subPath}`);
|
|
91
|
+
const subDeleted = await deleteCollection(firestore, subPath);
|
|
92
|
+
console.log(` Deleted ${subDeleted} documents`);
|
|
93
|
+
deletedCount += subDeleted;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Then delete the document itself
|
|
97
|
+
await doc.ref.delete();
|
|
98
|
+
console.log(` Deleted document: ${doc.id}`);
|
|
99
|
+
deletedCount++;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return deletedCount;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Delete orphaned subcollections under test documents.
|
|
107
|
+
* This handles the case where parent documents don't exist but subcollections do.
|
|
108
|
+
*/
|
|
109
|
+
async function deleteOrphanedTestSubcollections(
|
|
110
|
+
firestore: admin.firestore.Firestore,
|
|
111
|
+
collectionPath: string,
|
|
112
|
+
subcollectionName: string
|
|
113
|
+
): Promise<number> {
|
|
114
|
+
let deletedCount = 0;
|
|
115
|
+
|
|
116
|
+
// Query using collection group to find all subcollections with the given name
|
|
117
|
+
const collectionGroup = firestore.collectionGroup(subcollectionName);
|
|
118
|
+
const snapshot = await collectionGroup.load();
|
|
119
|
+
|
|
120
|
+
if (snapshot.empty) {
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Filter to only those under test documents in the specified collection
|
|
125
|
+
const prefix = `${collectionPath}/test-`;
|
|
126
|
+
const testDocs = snapshot.docs.filter(doc => doc.ref.path.startsWith(prefix));
|
|
127
|
+
|
|
128
|
+
if (testDocs.length === 0) {
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(` Found ${testDocs.length} orphaned ${subcollectionName} documents`);
|
|
133
|
+
|
|
134
|
+
// Group by parent document to delete efficiently
|
|
135
|
+
const parentPaths = new Set<string>();
|
|
136
|
+
for (const doc of testDocs) {
|
|
137
|
+
// Get parent document path
|
|
138
|
+
const parentPath = doc.ref.parent.parent?.path;
|
|
139
|
+
if (parentPath && parentPath.startsWith(prefix.slice(0, -1))) {
|
|
140
|
+
parentPaths.add(parentPath);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Delete the document
|
|
144
|
+
await doc.ref.delete();
|
|
145
|
+
deletedCount++;
|
|
146
|
+
console.log(` Deleted: ${doc.ref.path}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Try to delete parent documents (they might be virtual)
|
|
150
|
+
for (const parentPath of parentPaths) {
|
|
151
|
+
try {
|
|
152
|
+
await firestore.doc(parentPath).delete();
|
|
153
|
+
console.log(` Deleted parent: ${parentPath}`);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
// Ignore errors (parent might not exist)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return deletedCount;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Delete test files from Storage (reports).
|
|
164
|
+
*/
|
|
165
|
+
async function deleteTestStorageFiles(bucket: any): Promise<number> {
|
|
166
|
+
let deletedCount = 0;
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const [files] = await bucket.getFiles({ prefix: "reports/" });
|
|
170
|
+
|
|
171
|
+
const testFiles = files.filter((file: any) => {
|
|
172
|
+
const parts = file.name.split("/");
|
|
173
|
+
return parts.length >= 2 && parts[1].startsWith("test-");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (testFiles.length === 0) {
|
|
177
|
+
console.log(" No test files found in Storage (reports)");
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
console.log(` Found ${testFiles.length} test files in Storage (reports)`);
|
|
182
|
+
|
|
183
|
+
for (const file of testFiles) {
|
|
184
|
+
await file.delete();
|
|
185
|
+
console.log(` Deleted: ${file.name}`);
|
|
186
|
+
deletedCount++;
|
|
187
|
+
}
|
|
188
|
+
} catch (error: any) {
|
|
189
|
+
console.warn(` Warning: Could not delete Storage files: ${error.message}`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return deletedCount;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Delete test GitHub analysis files from Storage.
|
|
197
|
+
* Path format: assets/{projectId}/github_analysis.json
|
|
198
|
+
*/
|
|
199
|
+
async function deleteTestGitHubAnalysisFiles(bucket: any): Promise<number> {
|
|
200
|
+
let deletedCount = 0;
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
const [files] = await bucket.getFiles({ prefix: "assets/" });
|
|
204
|
+
|
|
205
|
+
const testFiles = files.filter((file: any) => {
|
|
206
|
+
const parts = file.name.split("/");
|
|
207
|
+
// Path format: assets/{projectId}/github_analysis.json
|
|
208
|
+
return parts.length >= 2 && parts[1].startsWith("test-");
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
if (testFiles.length === 0) {
|
|
212
|
+
console.log(" No test files found in Storage (assets)");
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
console.log(` Found ${testFiles.length} test files in Storage (assets)`);
|
|
217
|
+
|
|
218
|
+
for (const file of testFiles) {
|
|
219
|
+
await file.delete();
|
|
220
|
+
console.log(` Deleted: ${file.name}`);
|
|
221
|
+
deletedCount++;
|
|
222
|
+
}
|
|
223
|
+
} catch (error: any) {
|
|
224
|
+
console.warn(` Warning: Could not delete GitHub analysis files: ${error.message}`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return deletedCount;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Main cleanup function.
|
|
232
|
+
*/
|
|
233
|
+
async function main(): Promise<void> {
|
|
234
|
+
console.log("========================================");
|
|
235
|
+
console.log("Test Data Cleanup Script");
|
|
236
|
+
console.log("========================================\n");
|
|
237
|
+
|
|
238
|
+
// Initialize Firebase Admin
|
|
239
|
+
if (admin.apps.length === 0) {
|
|
240
|
+
admin.initializeApp({
|
|
241
|
+
credential: admin.credential.cert(serviceAccountPath),
|
|
242
|
+
projectId: "mathru-net",
|
|
243
|
+
storageBucket: "mathru-net.appspot.com",
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const firestore = admin.firestore();
|
|
248
|
+
const storage = admin.storage().bucket("mathru-net.appspot.com");
|
|
249
|
+
|
|
250
|
+
let totalDeleted = 0;
|
|
251
|
+
|
|
252
|
+
// Collections to clean up (in order of dependency)
|
|
253
|
+
const collections = [
|
|
254
|
+
"plugins/workflow/action",
|
|
255
|
+
"plugins/workflow/task",
|
|
256
|
+
"plugins/workflow/project",
|
|
257
|
+
"plugins/workflow/organization",
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
// Clean up Firestore test documents
|
|
261
|
+
console.log("Cleaning up Firestore test documents...\n");
|
|
262
|
+
for (const collectionPath of collections) {
|
|
263
|
+
console.log(`Processing: ${collectionPath}`);
|
|
264
|
+
const deleted = await deleteTestDocuments(firestore, collectionPath);
|
|
265
|
+
console.log(` Total deleted: ${deleted}\n`);
|
|
266
|
+
totalDeleted += deleted;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Clean up orphaned subcollections (usage under organization)
|
|
270
|
+
console.log("Cleaning up orphaned subcollections...\n");
|
|
271
|
+
console.log("Processing: plugins/workflow/organization/*/usage");
|
|
272
|
+
const orphanedUsageDeleted = await deleteOrphanedTestSubcollections(
|
|
273
|
+
firestore,
|
|
274
|
+
"plugins/workflow/organization",
|
|
275
|
+
"usage"
|
|
276
|
+
);
|
|
277
|
+
console.log(` Total deleted: ${orphanedUsageDeleted}\n`);
|
|
278
|
+
totalDeleted += orphanedUsageDeleted;
|
|
279
|
+
|
|
280
|
+
// Clean up Storage test files (reports)
|
|
281
|
+
console.log("Cleaning up Storage test files (reports)...");
|
|
282
|
+
const storageDeleted = await deleteTestStorageFiles(storage);
|
|
283
|
+
console.log(` Total deleted: ${storageDeleted}\n`);
|
|
284
|
+
totalDeleted += storageDeleted;
|
|
285
|
+
|
|
286
|
+
// Clean up Storage test files (GitHub analysis)
|
|
287
|
+
console.log("Cleaning up Storage test files (assets)...");
|
|
288
|
+
const githubAnalysisDeleted = await deleteTestGitHubAnalysisFiles(storage);
|
|
289
|
+
console.log(` Total deleted: ${githubAnalysisDeleted}\n`);
|
|
290
|
+
totalDeleted += githubAnalysisDeleted;
|
|
291
|
+
|
|
292
|
+
console.log("========================================");
|
|
293
|
+
console.log(`Cleanup Complete! Total deleted: ${totalDeleted} items`);
|
|
294
|
+
console.log("========================================\n");
|
|
295
|
+
|
|
296
|
+
// Exit
|
|
297
|
+
process.exit(0);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Run the script
|
|
301
|
+
main().catch((error) => {
|
|
302
|
+
console.error("Cleanup failed:", error);
|
|
303
|
+
process.exit(1);
|
|
304
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
/**
|
|
3
|
+
* List Test Data Script
|
|
4
|
+
*
|
|
5
|
+
* Lists all documents in the workflow collections to check what test data exists.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as admin from "firebase-admin";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
import "@mathrunet/masamune";
|
|
11
|
+
|
|
12
|
+
const serviceAccountPath = path.resolve(__dirname, "../test/mathru-net-39425d37638c.json");
|
|
13
|
+
|
|
14
|
+
async function main(): Promise<void> {
|
|
15
|
+
console.log("========================================");
|
|
16
|
+
console.log("List Test Data Script");
|
|
17
|
+
console.log("========================================\n");
|
|
18
|
+
|
|
19
|
+
if (admin.apps.length === 0) {
|
|
20
|
+
admin.initializeApp({
|
|
21
|
+
credential: admin.credential.cert(serviceAccountPath),
|
|
22
|
+
projectId: "mathru-net",
|
|
23
|
+
storageBucket: "mathru-net.appspot.com",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const firestore = admin.firestore();
|
|
28
|
+
|
|
29
|
+
const collections = [
|
|
30
|
+
"plugins/workflow/organization",
|
|
31
|
+
"plugins/workflow/project",
|
|
32
|
+
"plugins/workflow/task",
|
|
33
|
+
"plugins/workflow/action",
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
for (const collectionPath of collections) {
|
|
37
|
+
console.log(`\n=== ${collectionPath} ===`);
|
|
38
|
+
const snapshot = await firestore.collection(collectionPath).load();
|
|
39
|
+
console.log(`Total documents: ${snapshot.size}`);
|
|
40
|
+
|
|
41
|
+
// List test documents
|
|
42
|
+
const testDocs = snapshot.docs.filter(doc => doc.id.startsWith("test-"));
|
|
43
|
+
console.log(`Test documents (starting with 'test-'): ${testDocs.length}`);
|
|
44
|
+
|
|
45
|
+
if (testDocs.length > 0 && testDocs.length <= 20) {
|
|
46
|
+
testDocs.forEach(doc => {
|
|
47
|
+
console.log(` - ${doc.id}`);
|
|
48
|
+
});
|
|
49
|
+
} else if (testDocs.length > 20) {
|
|
50
|
+
testDocs.slice(0, 20).forEach(doc => {
|
|
51
|
+
console.log(` - ${doc.id}`);
|
|
52
|
+
});
|
|
53
|
+
console.log(` ... and ${testDocs.length - 20} more`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Check for subcollections on test docs
|
|
57
|
+
for (const doc of testDocs.slice(0, 5)) {
|
|
58
|
+
const subcollections = await doc.ref.listCollections();
|
|
59
|
+
if (subcollections.length > 0) {
|
|
60
|
+
console.log(` ${doc.id} has subcollections: ${subcollections.map(s => s.id).join(", ")}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Check Storage
|
|
66
|
+
console.log("\n=== Storage (reports/) ===");
|
|
67
|
+
const storage = admin.storage().bucket("mathru-net.appspot.com");
|
|
68
|
+
const [files] = await storage.getFiles({ prefix: "reports/" });
|
|
69
|
+
console.log(`Total files: ${files.length}`);
|
|
70
|
+
const testFiles = files.filter((f: any) => {
|
|
71
|
+
const parts = f.name.split("/");
|
|
72
|
+
return parts.length >= 2 && parts[1].startsWith("test-");
|
|
73
|
+
});
|
|
74
|
+
console.log(`Test files: ${testFiles.length}`);
|
|
75
|
+
if (testFiles.length > 0 && testFiles.length <= 10) {
|
|
76
|
+
testFiles.forEach((f: any) => console.log(` - ${f.name}`));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main().catch((error) => {
|
|
83
|
+
console.error("Error:", error);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|