firebase-mcp 0.2.0 → 0.3.1

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.
Files changed (166) hide show
  1. package/README.md +6 -11
  2. package/dist/cli/index.js +9 -9
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/config/index.d.ts +39 -47
  5. package/dist/config/index.d.ts.map +1 -1
  6. package/dist/config/index.js +46 -37
  7. package/dist/config/index.js.map +1 -1
  8. package/dist/firebase/index.d.ts +9 -18
  9. package/dist/firebase/index.d.ts.map +1 -1
  10. package/dist/firebase/index.js +28 -30
  11. package/dist/firebase/index.js.map +1 -1
  12. package/dist/project/index.d.ts +17 -0
  13. package/dist/project/index.d.ts.map +1 -0
  14. package/dist/project/index.js +38 -0
  15. package/dist/project/index.js.map +1 -0
  16. package/dist/server/index.d.ts +13 -19
  17. package/dist/server/index.d.ts.map +1 -1
  18. package/dist/server/index.js +93 -47
  19. package/dist/server/index.js.map +1 -1
  20. package/dist/task/index.d.ts +53 -0
  21. package/dist/task/index.d.ts.map +1 -0
  22. package/dist/task/index.js +177 -0
  23. package/dist/task/index.js.map +1 -0
  24. package/dist/tools/auth/index.d.ts +3 -2
  25. package/dist/tools/auth/index.d.ts.map +1 -1
  26. package/dist/tools/auth/index.js +3 -2
  27. package/dist/tools/auth/index.js.map +1 -1
  28. package/dist/tools/auth/operations/get_user.d.ts +21 -0
  29. package/dist/tools/auth/operations/get_user.d.ts.map +1 -0
  30. package/dist/tools/auth/{get_user.js → operations/get_user.js} +30 -21
  31. package/dist/tools/auth/operations/get_user.js.map +1 -0
  32. package/dist/tools/auth/operations/list_users.d.ts +19 -0
  33. package/dist/tools/auth/operations/list_users.d.ts.map +1 -0
  34. package/dist/tools/auth/{list_users.js → operations/list_users.js} +20 -12
  35. package/dist/tools/auth/operations/list_users.js.map +1 -0
  36. package/dist/tools/auth/tool.d.ts +15 -0
  37. package/dist/tools/auth/tool.d.ts.map +1 -0
  38. package/dist/tools/auth/tool.js +72 -0
  39. package/dist/tools/auth/tool.js.map +1 -0
  40. package/dist/tools/config/get_config.d.ts +6 -0
  41. package/dist/tools/config/get_config.d.ts.map +1 -0
  42. package/dist/tools/config/get_config.js +31 -0
  43. package/dist/tools/config/get_config.js.map +1 -0
  44. package/dist/tools/config/index.d.ts +3 -0
  45. package/dist/tools/config/index.d.ts.map +1 -0
  46. package/dist/tools/config/index.js +19 -0
  47. package/dist/tools/config/index.js.map +1 -0
  48. package/dist/tools/config/reload_config.d.ts +8 -0
  49. package/dist/tools/config/reload_config.d.ts.map +1 -0
  50. package/dist/tools/config/reload_config.js +44 -0
  51. package/dist/tools/config/reload_config.js.map +1 -0
  52. package/dist/tools/firestore/index.d.ts +13 -11
  53. package/dist/tools/firestore/index.d.ts.map +1 -1
  54. package/dist/tools/firestore/index.js +13 -11
  55. package/dist/tools/firestore/index.js.map +1 -1
  56. package/dist/tools/firestore/operations/aggregate_collection.d.ts +29 -0
  57. package/dist/tools/firestore/operations/aggregate_collection.d.ts.map +1 -0
  58. package/dist/tools/firestore/{aggregate_collection.js → operations/aggregate_collection.js} +27 -16
  59. package/dist/tools/firestore/operations/aggregate_collection.js.map +1 -0
  60. package/dist/tools/firestore/operations/count_documents.d.ts +20 -0
  61. package/dist/tools/firestore/operations/count_documents.d.ts.map +1 -0
  62. package/dist/tools/firestore/{count_documents.js → operations/count_documents.js} +27 -16
  63. package/dist/tools/firestore/operations/count_documents.js.map +1 -0
  64. package/dist/tools/firestore/operations/distinct_values.d.ts +59 -0
  65. package/dist/tools/firestore/operations/distinct_values.d.ts.map +1 -0
  66. package/dist/tools/firestore/operations/distinct_values.js +173 -0
  67. package/dist/tools/firestore/operations/distinct_values.js.map +1 -0
  68. package/dist/tools/firestore/operations/get_collection_schema.d.ts +25 -0
  69. package/dist/tools/firestore/operations/get_collection_schema.d.ts.map +1 -0
  70. package/dist/tools/firestore/{get_collection_schema.js → operations/get_collection_schema.js} +28 -19
  71. package/dist/tools/firestore/operations/get_collection_schema.js.map +1 -0
  72. package/dist/tools/firestore/operations/get_document.d.ts +26 -0
  73. package/dist/tools/firestore/operations/get_document.d.ts.map +1 -0
  74. package/dist/tools/firestore/operations/get_document.js +82 -0
  75. package/dist/tools/firestore/operations/get_document.js.map +1 -0
  76. package/dist/tools/firestore/operations/get_many_documents.d.ts +27 -0
  77. package/dist/tools/firestore/operations/get_many_documents.d.ts.map +1 -0
  78. package/dist/tools/firestore/{get_many_documents.js → operations/get_many_documents.js} +37 -27
  79. package/dist/tools/firestore/operations/get_many_documents.js.map +1 -0
  80. package/dist/tools/firestore/operations/list_collections.d.ts +19 -0
  81. package/dist/tools/firestore/operations/list_collections.d.ts.map +1 -0
  82. package/dist/tools/firestore/{list_collections.js → operations/list_collections.js} +30 -22
  83. package/dist/tools/firestore/operations/list_collections.js.map +1 -0
  84. package/dist/tools/firestore/operations/list_documents.d.ts +19 -0
  85. package/dist/tools/firestore/operations/list_documents.d.ts.map +1 -0
  86. package/dist/tools/firestore/operations/list_documents.js +60 -0
  87. package/dist/tools/firestore/operations/list_documents.js.map +1 -0
  88. package/dist/tools/firestore/{list_indexes.d.ts → operations/list_indexes.d.ts} +7 -11
  89. package/dist/tools/firestore/operations/list_indexes.d.ts.map +1 -0
  90. package/dist/tools/firestore/{list_indexes.js → operations/list_indexes.js} +22 -22
  91. package/dist/tools/firestore/operations/list_indexes.js.map +1 -0
  92. package/dist/tools/firestore/operations/query_collection.d.ts +28 -0
  93. package/dist/tools/firestore/operations/query_collection.d.ts.map +1 -0
  94. package/dist/tools/firestore/{query_collection.js → operations/query_collection.js} +30 -28
  95. package/dist/tools/firestore/operations/query_collection.js.map +1 -0
  96. package/dist/tools/firestore/operations/query_collection_group.d.ts +28 -0
  97. package/dist/tools/firestore/operations/query_collection_group.d.ts.map +1 -0
  98. package/dist/tools/firestore/{query_collection_group.js → operations/query_collection_group.js} +25 -25
  99. package/dist/tools/firestore/operations/query_collection_group.js.map +1 -0
  100. package/dist/tools/firestore/operations/read_collections.d.ts +38 -0
  101. package/dist/tools/firestore/operations/read_collections.d.ts.map +1 -0
  102. package/dist/tools/firestore/{read_collections.js → operations/read_collections.js} +33 -34
  103. package/dist/tools/firestore/operations/read_collections.js.map +1 -0
  104. package/dist/tools/firestore/tool.d.ts +89 -0
  105. package/dist/tools/firestore/tool.d.ts.map +1 -0
  106. package/dist/tools/firestore/tool.js +243 -0
  107. package/dist/tools/firestore/tool.js.map +1 -0
  108. package/dist/tools/firestore/utils/paths.d.ts +14 -0
  109. package/dist/tools/firestore/utils/paths.d.ts.map +1 -0
  110. package/dist/tools/firestore/utils/paths.js +39 -0
  111. package/dist/tools/firestore/utils/paths.js.map +1 -0
  112. package/dist/tools/firestore/utils/types.d.ts.map +1 -0
  113. package/dist/tools/firestore/{types.js → utils/types.js} +1 -1
  114. package/dist/tools/firestore/utils/types.js.map +1 -0
  115. package/dist/tools/index.d.ts +9 -103
  116. package/dist/tools/index.d.ts.map +1 -1
  117. package/dist/tools/index.js +77 -79
  118. package/dist/tools/index.js.map +1 -1
  119. package/package.json +3 -5
  120. package/dist/access/index.d.ts +0 -23
  121. package/dist/access/index.d.ts.map +0 -1
  122. package/dist/access/index.js +0 -35
  123. package/dist/access/index.js.map +0 -1
  124. package/dist/tools/auth/get_user.d.ts +0 -27
  125. package/dist/tools/auth/get_user.d.ts.map +0 -1
  126. package/dist/tools/auth/get_user.js.map +0 -1
  127. package/dist/tools/auth/list_users.d.ts +0 -23
  128. package/dist/tools/auth/list_users.d.ts.map +0 -1
  129. package/dist/tools/auth/list_users.js.map +0 -1
  130. package/dist/tools/firestore/aggregate_collection.d.ts +0 -34
  131. package/dist/tools/firestore/aggregate_collection.d.ts.map +0 -1
  132. package/dist/tools/firestore/aggregate_collection.js.map +0 -1
  133. package/dist/tools/firestore/count_documents.d.ts +0 -25
  134. package/dist/tools/firestore/count_documents.d.ts.map +0 -1
  135. package/dist/tools/firestore/count_documents.js.map +0 -1
  136. package/dist/tools/firestore/get_collection_schema.d.ts +0 -30
  137. package/dist/tools/firestore/get_collection_schema.d.ts.map +0 -1
  138. package/dist/tools/firestore/get_collection_schema.js.map +0 -1
  139. package/dist/tools/firestore/get_document.d.ts +0 -32
  140. package/dist/tools/firestore/get_document.d.ts.map +0 -1
  141. package/dist/tools/firestore/get_document.js +0 -62
  142. package/dist/tools/firestore/get_document.js.map +0 -1
  143. package/dist/tools/firestore/get_many_documents.d.ts +0 -33
  144. package/dist/tools/firestore/get_many_documents.d.ts.map +0 -1
  145. package/dist/tools/firestore/get_many_documents.js.map +0 -1
  146. package/dist/tools/firestore/list_collections.d.ts +0 -24
  147. package/dist/tools/firestore/list_collections.d.ts.map +0 -1
  148. package/dist/tools/firestore/list_collections.js.map +0 -1
  149. package/dist/tools/firestore/list_documents.d.ts +0 -24
  150. package/dist/tools/firestore/list_documents.d.ts.map +0 -1
  151. package/dist/tools/firestore/list_documents.js +0 -60
  152. package/dist/tools/firestore/list_documents.js.map +0 -1
  153. package/dist/tools/firestore/list_indexes.d.ts.map +0 -1
  154. package/dist/tools/firestore/list_indexes.js.map +0 -1
  155. package/dist/tools/firestore/query_collection.d.ts +0 -34
  156. package/dist/tools/firestore/query_collection.d.ts.map +0 -1
  157. package/dist/tools/firestore/query_collection.js.map +0 -1
  158. package/dist/tools/firestore/query_collection_group.d.ts +0 -34
  159. package/dist/tools/firestore/query_collection_group.d.ts.map +0 -1
  160. package/dist/tools/firestore/query_collection_group.js.map +0 -1
  161. package/dist/tools/firestore/read_collections.d.ts +0 -44
  162. package/dist/tools/firestore/read_collections.d.ts.map +0 -1
  163. package/dist/tools/firestore/read_collections.js.map +0 -1
  164. package/dist/tools/firestore/types.d.ts.map +0 -1
  165. package/dist/tools/firestore/types.js.map +0 -1
  166. /package/dist/tools/firestore/{types.d.ts → utils/types.d.ts} +0 -0
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readCollection = exports.readCollectionDefinition = exports.READ_COLLECTION = exports.FirestoreReadError = void 0;
4
- const effect_1 = require("effect");
5
- const access_1 = require("../../access");
6
- const config_1 = require("../../config");
7
- const firebase_1 = require("../../firebase");
8
- const types_1 = require("./types");
9
- class FirestoreReadError extends effect_1.Data.TaggedError('FirestoreReadError') {
4
+ const task_1 = require("../../../task");
5
+ const paths_1 = require("../utils/paths");
6
+ const types_1 = require("../utils/types");
7
+ class FirestoreReadError extends Error {
8
+ cause;
9
+ _tag = 'FirestoreReadError';
10
+ constructor(message, cause) {
11
+ super(message);
12
+ this.cause = cause;
13
+ this.name = 'FirestoreReadError';
14
+ }
10
15
  }
11
16
  exports.FirestoreReadError = FirestoreReadError;
12
17
  exports.READ_COLLECTION = 'read_collection';
@@ -37,32 +42,32 @@ exports.readCollectionDefinition = {
37
42
  type: 'string',
38
43
  description: 'Document ID to start after for pagination. Use the nextPageCursor value returned from a previous call.',
39
44
  },
45
+ projectId: {
46
+ type: 'string',
47
+ description: 'Project key as defined in firebase-mcp.json',
48
+ },
40
49
  },
41
- required: ['collection'],
50
+ required: ['collection', 'projectId'],
42
51
  },
43
52
  };
44
- const readCollection = (input) => effect_1.Effect.gen(function* () {
45
- const access = yield* access_1.AccessService;
46
- yield* access.check(input.collection);
47
- const { config } = yield* config_1.ConfigService;
48
- const { firestore } = yield* firebase_1.FirebaseService;
49
- const maxLimit = config.firestore.maxCollectionReadSize;
53
+ const readCollection = (ctx, input) => task_1.Task.gen(function* () {
54
+ const err = (0, paths_1.collectionPathError)(input.collection);
55
+ if (err) {
56
+ return yield* task_1.Task.fail(new FirestoreReadError(err));
57
+ }
58
+ yield* ctx.checkAccess(input.collection);
59
+ const db = ctx.firestore();
60
+ const maxLimit = ctx.config.firestore.maxCollectionReadSize;
50
61
  const limit = Math.min(input.limit ?? maxLimit, maxLimit);
51
62
  const cursorSnap = input.startAfter
52
- ? yield* effect_1.Effect.tryPromise({
53
- try: () => firestore()
54
- .collection(input.collection)
55
- .doc(input.startAfter)
56
- .get(),
57
- catch: (cause) => new FirestoreReadError({
58
- message: `Failed to fetch cursor document: ${input.startAfter}`,
59
- cause,
60
- }),
63
+ ? yield* task_1.Task.attempt({
64
+ try: () => db.collection(input.collection).doc(input.startAfter).get(),
65
+ catch: (cause) => new FirestoreReadError(`Failed to fetch cursor document: ${input.startAfter}`, cause),
61
66
  })
62
67
  : null;
63
- const snapshot = yield* effect_1.Effect.tryPromise({
68
+ const snapshot = yield* task_1.Task.attempt({
64
69
  try: () => {
65
- let query = firestore().collection(input.collection);
70
+ let query = db.collection(input.collection);
66
71
  if (input.select?.length) {
67
72
  query = query.select(...input.select);
68
73
  }
@@ -71,19 +76,13 @@ const readCollection = (input) => effect_1.Effect.gen(function* () {
71
76
  }
72
77
  return query.limit(limit).get();
73
78
  },
74
- catch: (cause) => new FirestoreReadError({
75
- message: `Failed to read collection: ${input.collection}`,
76
- cause,
77
- }),
79
+ catch: (cause) => new FirestoreReadError(`Failed to read collection: ${input.collection}`, cause),
78
80
  });
79
81
  const documents = snapshot.docs.map(types_1.normalizeDocument);
80
82
  if (documents.length === 0 && input.includePhantoms) {
81
- const refs = yield* effect_1.Effect.tryPromise({
82
- try: () => firestore().collection(input.collection).listDocuments(),
83
- catch: (cause) => new FirestoreReadError({
84
- message: `Failed to list phantom documents in: ${input.collection}`,
85
- cause,
86
- }),
83
+ const refs = yield* task_1.Task.attempt({
84
+ try: () => db.collection(input.collection).listDocuments(),
85
+ catch: (cause) => new FirestoreReadError(`Failed to list phantom documents in: ${input.collection}`, cause),
87
86
  });
88
87
  const phantoms = refs.map((ref) => ({ id: ref.id, path: ref.path }));
89
88
  return { documents, phantoms };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read_collections.js","sourceRoot":"","sources":["../../../../src/tools/firestore/operations/read_collections.ts"],"names":[],"mappings":";;;AAGA,wCAAqC;AACrC,0CAAqD;AACrD,0CAAmD;AAEnD,MAAa,kBAAmB,SAAQ,KAAK;IAEL;IAD7B,IAAI,GAAG,oBAA6B,CAAC;IAC9C,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,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,kBAAkB,CACpB,8BAA8B,KAAK,CAAC,UAAU,EAAE,EAChD,KAAK,CACN;KACJ,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;IAEvD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAI,CAAC,OAAO,CAAC;YAC/B,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE;YAC1D,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,kBAAkB,CACpB,wCAAwC,KAAK,CAAC,UAAU,EAAE,EAC1D,KAAK,CACN;SACJ,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACrE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,cAAc,GAClB,SAAS,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAEzE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;AACvC,CAAC,CAAC,CAAC;AAjEQ,QAAA,cAAc,kBAiEtB"}
@@ -0,0 +1,89 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { ProjectContext } from '../../project';
3
+ import { Task } from '../../task';
4
+ declare const READ_OPERATIONS: readonly ["list_collections", "list_documents", "read_collection", "get_document", "get_many_documents", "query_collection", "query_collection_group", "count_documents", "aggregate_collection", "get_collection_schema", "list_indexes", "distinct_values"];
5
+ type ReadOperations = (typeof READ_OPERATIONS)[number];
6
+ export declare class UnknownFirestoreOperationError extends Error {
7
+ readonly operation: string;
8
+ readonly _tag: "UnknownFirestoreOperationError";
9
+ constructor(operation: string);
10
+ }
11
+ export declare const FIRESTORE_READ: "firestore_read";
12
+ export declare const firestoreReadDefinition: Tool;
13
+ export declare const dispatchFirestoreRead: (ctx: ProjectContext, operation: ReadOperations | (string & {}), args: unknown) => Task<{
14
+ collection: string;
15
+ result: FirebaseFirestore.AggregateSpecData<{
16
+ [k: string]: FirebaseFirestore.AggregateField<number>;
17
+ }>;
18
+ } | {
19
+ fields: string | string[];
20
+ totalDocsFetched: number;
21
+ values: {
22
+ value: (string | null) | Record<string, string[] | (string | null)>;
23
+ count: number;
24
+ collectionCount?: number;
25
+ collections?: string[];
26
+ }[];
27
+ byCollection: Record<string, {
28
+ value: (string | null) | Record<string, string | null>;
29
+ count: number;
30
+ }[]>;
31
+ } | {
32
+ fields: string | string[];
33
+ totalDocsFetched: number;
34
+ values: {
35
+ value: (string | null) | Record<string, string[] | (string | null)>;
36
+ count: number;
37
+ collectionCount?: number;
38
+ collections?: string[];
39
+ }[];
40
+ byCollection?: undefined;
41
+ } | {
42
+ collection: string;
43
+ count: number;
44
+ } | {
45
+ collection: string;
46
+ totalSampled: number;
47
+ sampleStrategy: string;
48
+ fields: Record<string, import("./operations/get_collection_schema").FieldSchema>;
49
+ } | {
50
+ collections: string[];
51
+ id: string;
52
+ path: string;
53
+ data: unknown;
54
+ } | {
55
+ id: string;
56
+ path: string;
57
+ }[] | {
58
+ total: number;
59
+ indexes: Record<string, {
60
+ collectionGroup: string;
61
+ queryScope: "COLLECTION" | "COLLECTION_GROUP";
62
+ fields: {
63
+ arrayConfig?: "CONTAINS" | undefined;
64
+ order?: "ASCENDING" | "DESCENDING" | undefined;
65
+ field: string;
66
+ }[];
67
+ state: "READY" | "CREATING" | "NEEDS_REPAIR";
68
+ }[]>;
69
+ } | {
70
+ documents: {
71
+ id: string;
72
+ path: string;
73
+ data: unknown;
74
+ }[];
75
+ nextPageCursor: string | null;
76
+ } | {
77
+ documents: {
78
+ id: string;
79
+ path: string;
80
+ data: unknown;
81
+ }[];
82
+ phantoms: {
83
+ id: string;
84
+ path: string;
85
+ }[];
86
+ nextPageCursor?: undefined;
87
+ }, import("../../project").AccessDeniedError | import("./operations/aggregate_collection").FirestoreAggregateError | import("./operations/distinct_values").FirestoreDistinctValuesError | import("./operations/count_documents").FirestoreCountError | import("./operations/get_collection_schema").FirestoreSchemaError | import("./operations/get_document").FirestoreGetError | import("./operations/get_document").DocumentNotFoundError | import("./operations/get_many_documents").FirestoreGetManyError | import("./operations/list_collections").FirestoreListCollectionsError | import("./operations/list_documents").FirestoreListDocumentsError | import("./operations/list_indexes").FirestoreListIndexesError | import("./operations/query_collection").FirestoreQueryError | import("./operations/query_collection_group").FirestoreCollectionGroupQueryError | import("./operations/read_collections").FirestoreReadError | UnknownFirestoreOperationError>;
88
+ export {};
89
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAuDlC,QAAA,MAAM,eAAe,+PAaX,CAAC;AAEX,KAAK,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,qBAAa,8BAA+B,SAAQ,KAAK;IAE3C,QAAQ,CAAC,SAAS,EAAE,MAAM;IADtC,QAAQ,CAAC,IAAI,EAAG,gCAAgC,CAAU;gBACrC,SAAS,EAAE,MAAM;CAIvC;AAED,eAAO,MAAM,cAAc,EAAG,gBAAyB,CAAC;AAqBxD,eAAO,MAAM,uBAAuB,EAAE,IA+JrC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,KAAK,cAAc,EACnB,WAAW,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACzC,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26BAmCd,CAAC"}
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dispatchFirestoreRead = exports.firestoreReadDefinition = exports.FIRESTORE_READ = exports.UnknownFirestoreOperationError = void 0;
4
+ const task_1 = require("../../task");
5
+ const aggregate_collection_1 = require("./operations/aggregate_collection");
6
+ const distinct_values_1 = require("./operations/distinct_values");
7
+ const count_documents_1 = require("./operations/count_documents");
8
+ const get_collection_schema_1 = require("./operations/get_collection_schema");
9
+ const get_document_1 = require("./operations/get_document");
10
+ const get_many_documents_1 = require("./operations/get_many_documents");
11
+ const list_collections_1 = require("./operations/list_collections");
12
+ const list_documents_1 = require("./operations/list_documents");
13
+ const list_indexes_1 = require("./operations/list_indexes");
14
+ const query_collection_1 = require("./operations/query_collection");
15
+ const query_collection_group_1 = require("./operations/query_collection_group");
16
+ const read_collections_1 = require("./operations/read_collections");
17
+ const types_1 = require("./utils/types");
18
+ const READ_OPERATIONS = [
19
+ list_collections_1.LIST_COLLECTIONS,
20
+ list_documents_1.LIST_DOCUMENTS,
21
+ read_collections_1.READ_COLLECTION,
22
+ get_document_1.GET_DOCUMENT,
23
+ get_many_documents_1.GET_MANY_DOCUMENTS,
24
+ query_collection_1.QUERY_COLLECTION,
25
+ query_collection_group_1.QUERY_COLLECTION_GROUP,
26
+ count_documents_1.COUNT_DOCUMENTS,
27
+ aggregate_collection_1.AGGREGATE_COLLECTION,
28
+ get_collection_schema_1.GET_COLLECTION_SCHEMA,
29
+ list_indexes_1.LIST_INDEXES,
30
+ distinct_values_1.DISTINCT_VALUES,
31
+ ];
32
+ class UnknownFirestoreOperationError extends Error {
33
+ operation;
34
+ _tag = 'UnknownFirestoreOperationError';
35
+ constructor(operation) {
36
+ super(`Unknown firestore_read operation: ${operation}`);
37
+ this.operation = operation;
38
+ this.name = 'UnknownFirestoreOperationError';
39
+ }
40
+ }
41
+ exports.UnknownFirestoreOperationError = UnknownFirestoreOperationError;
42
+ exports.FIRESTORE_READ = 'firestore_read';
43
+ const DISTINCT_VALUES_DESCRIPTION = [
44
+ '- distinct_values: Count occurrences of each unique value (or value combination) of one or more fields.',
45
+ ' Source: collection(ODD segments) OR collectionId(single name — queries across ALL subcollections with that name, like query_collection_group).',
46
+ ' Fields: field(single field name) OR fields([array of field names] — each result value becomes an object keyed by field name).',
47
+ ' groupByFields?([subset of fields] — use only these as the identity/grouping key;',
48
+ ' remaining fields become label arrays of unique values seen per group,',
49
+ ' e.g. groupByFields:["cashier"] with fields:["cashier","cashierNm"] groups by cashier ID',
50
+ ' while collecting all cashierNm variants as a label — useful when a display name varies across collections but the ID is stable).',
51
+ ' filters?[].',
52
+ ' groupByPathSegment?(integer — when using collectionId, extracts this segment from the parent collection path as the byCollection key,',
53
+ ' e.g. 2 turns "shared/stores_data/ABC123/data/purchase_orders" into "ABC123").',
54
+ ' minCollections?(integer or "all" — only return values present in at least this many distinct collection buckets;',
55
+ ' "all" means present in every bucket found without knowing the count upfront;',
56
+ ' operates on the groupByFields key so label variation across buckets does not cause missed matches;',
57
+ ' all values are annotated with collectionCount and collections[] regardless).',
58
+ ' Fetches all matching docs internally (up to maxBatchFetchSize).',
59
+ ' Returns values[] sorted by count desc. When using collectionId, also returns byCollection{} broken down by parent collection (or extracted segment).',
60
+ ].join(' ');
61
+ exports.firestoreReadDefinition = {
62
+ name: exports.FIRESTORE_READ,
63
+ description: 'Read from Firebase Firestore. Use the operation field to select what to do.',
64
+ inputSchema: {
65
+ type: 'object',
66
+ required: ['operation', 'projectId'],
67
+ properties: {
68
+ operation: {
69
+ type: 'string',
70
+ enum: [...READ_OPERATIONS],
71
+ description: [
72
+ 'Firestore paths alternate between collections (odd segments) and documents (even segments).',
73
+ 'Collection path examples: "users", "stores/ABC/orders". Document path examples: "users/123", "stores/ABC/orders/456".',
74
+ 'Operations that take `collection` require an ODD-segment path. Operations that take `path` require an EVEN-segment path.',
75
+ 'Passing the wrong path type returns a clear error with a suggested fix.',
76
+ '',
77
+ 'The Firestore operation to perform:',
78
+ '- list_collections: List root collections, or subcollections of a document. Args: path?(EVEN segments — document path, e.g. "stores/ABC"), includeCounts?(bool). Returns collection paths (ODD segments) → use with list_documents or read_collection.',
79
+ '- list_documents: List all doc IDs including phantoms. Always includes subcollections per doc. Args: collection(ODD segments). Returns document paths (EVEN segments) with collections[] → use with get_document or list_collections.',
80
+ '- read_collection: Read documents from a collection. Args: collection(ODD segments), limit?, select?[], startAfter?(doc ID), includePhantoms?(bool)',
81
+ '- get_document: Fetch a single document by path. Args: path(EVEN segments, e.g. "users/123"), select?[]',
82
+ '- get_many_documents: Batch-fetch documents. Args: paths?[](each EVEN segments) OR (collection(ODD segments) + ids[]); select?[]',
83
+ '- query_collection: Query with filters/ordering/pagination. Args: collection(ODD segments), filters?[], orderBy?[], limit?, select?[], startAfter?(doc ID)',
84
+ '- query_collection_group: Query across all subcollections with the same name. Args: collectionId(single name, no slashes), filters?[], orderBy?[], limit?, select?[], startAfter?(full doc path)',
85
+ '- count_documents: Server-side count without fetching docs. Args: collection(ODD segments), filters?[]',
86
+ '- aggregate_collection: Server-side sum/avg/count aggregations. Args: collection(ODD segments), aggregations[]{alias,type,field?}, filters?[]',
87
+ '- get_collection_schema: Infer field types by sampling docs. Args: collection(ODD segments), sampleSize?(default 20)',
88
+ '- list_indexes: List composite indexes. Args: collectionGroup?(filter by name), includeNotReady?(bool)',
89
+ DISTINCT_VALUES_DESCRIPTION,
90
+ ].join('\n'),
91
+ },
92
+ projectId: {
93
+ type: 'string',
94
+ description: 'Project key as defined in firebase-mcp.json',
95
+ },
96
+ path: {
97
+ type: 'string',
98
+ description: "Document path for get_document (e.g. 'users/123') or optional document path for list_collections subcollections",
99
+ },
100
+ collection: {
101
+ type: 'string',
102
+ description: "Collection path (e.g. 'users' or 'users/123/posts')",
103
+ },
104
+ collectionId: {
105
+ type: 'string',
106
+ description: "Collection name for query_collection_group (e.g. 'orders')",
107
+ },
108
+ paths: {
109
+ type: 'array',
110
+ items: { type: 'string' },
111
+ description: "Full document paths for get_many_documents (e.g. ['users/123', 'orders/456'])",
112
+ },
113
+ ids: {
114
+ type: 'array',
115
+ items: { type: 'string' },
116
+ description: 'Document IDs within the collection field for get_many_documents',
117
+ },
118
+ filters: {
119
+ type: 'array',
120
+ items: types_1.FILTER_SCHEMA_ITEM,
121
+ description: 'Where-clause filters',
122
+ },
123
+ orderBy: {
124
+ type: 'array',
125
+ items: types_1.ORDER_BY_SCHEMA_ITEM,
126
+ description: 'Ordering of results',
127
+ },
128
+ limit: {
129
+ type: 'number',
130
+ description: 'Max number of documents to return',
131
+ },
132
+ select: {
133
+ type: 'array',
134
+ items: { type: 'string' },
135
+ description: 'Field paths to return. Omit for all fields.',
136
+ },
137
+ startAfter: {
138
+ type: 'string',
139
+ description: 'Pagination cursor: doc ID for query_collection/read_collection, full doc path for query_collection_group',
140
+ },
141
+ aggregations: {
142
+ type: 'array',
143
+ items: {
144
+ type: 'object',
145
+ properties: {
146
+ alias: {
147
+ type: 'string',
148
+ description: 'Key name for this result in the response',
149
+ },
150
+ type: {
151
+ type: 'string',
152
+ enum: ['sum', 'avg', 'count'],
153
+ description: '"sum" and "avg" require a field; "count" does not',
154
+ },
155
+ field: {
156
+ type: 'string',
157
+ description: 'Field path to aggregate (required for sum/avg)',
158
+ },
159
+ },
160
+ required: ['alias', 'type'],
161
+ },
162
+ description: 'Aggregations for aggregate_collection',
163
+ },
164
+ includeCounts: {
165
+ type: 'boolean',
166
+ description: 'list_collections: include document count per collection',
167
+ },
168
+ includePhantoms: {
169
+ type: 'boolean',
170
+ description: 'read_collection: fall back to listDocuments() when the collection returns no docs',
171
+ },
172
+ includeNotReady: {
173
+ type: 'boolean',
174
+ description: 'list_indexes: include indexes still being created or needing repair',
175
+ },
176
+ sampleSize: {
177
+ type: 'number',
178
+ description: 'get_collection_schema: number of documents to sample (default 20)',
179
+ },
180
+ collectionGroup: {
181
+ type: 'string',
182
+ description: 'list_indexes: filter results to a specific collection group name',
183
+ },
184
+ field: {
185
+ type: 'string',
186
+ description: 'distinct_values: single field name to count unique values for. Use fields[] for multi-field grouping.',
187
+ },
188
+ fields: {
189
+ type: 'array',
190
+ items: { type: 'string' },
191
+ description: 'distinct_values: multiple field names to fetch. Each result value is an object keyed by field name. Use groupByFields to group on a subset.',
192
+ },
193
+ groupByFields: {
194
+ type: 'array',
195
+ items: { type: 'string' },
196
+ description: 'distinct_values: subset of fields[] to use as the grouping/identity key. Remaining fields are collected as label arrays (unique values seen per group). Allows minCollections to operate on a stable ID field even when a display name varies across collections.',
197
+ },
198
+ groupByPathSegment: {
199
+ type: 'number',
200
+ description: 'distinct_values with collectionId: 0-based index of the path segment to use as the byCollection key instead of the full path (e.g. 2 extracts "ABC123" from "shared/stores_data/ABC123/data/purchase_orders")',
201
+ },
202
+ minCollections: {
203
+ type: ['number', 'string'],
204
+ description: 'distinct_values with collectionId: only return values that appear in at least this many distinct collection buckets. Pass a number (e.g. 2) or "all" to mean "present in every collection bucket found" — useful for "users in every store" without needing to know the store count upfront. All returned values are annotated with collectionCount and collections[] regardless.',
205
+ },
206
+ },
207
+ },
208
+ };
209
+ const dispatchFirestoreRead = (ctx, operation, args) => {
210
+ const a = args;
211
+ return task_1.Task.gen(function* () {
212
+ switch (operation) {
213
+ case list_collections_1.LIST_COLLECTIONS:
214
+ return yield* (0, list_collections_1.listCollections)(ctx, a);
215
+ case list_documents_1.LIST_DOCUMENTS:
216
+ return yield* (0, list_documents_1.listDocuments)(ctx, a);
217
+ case read_collections_1.READ_COLLECTION:
218
+ return yield* (0, read_collections_1.readCollection)(ctx, a);
219
+ case get_document_1.GET_DOCUMENT:
220
+ return yield* (0, get_document_1.getDocument)(ctx, a);
221
+ case get_many_documents_1.GET_MANY_DOCUMENTS:
222
+ return yield* (0, get_many_documents_1.getManyDocuments)(ctx, a);
223
+ case query_collection_1.QUERY_COLLECTION:
224
+ return yield* (0, query_collection_1.queryCollection)(ctx, a);
225
+ case query_collection_group_1.QUERY_COLLECTION_GROUP:
226
+ return yield* (0, query_collection_group_1.queryCollectionGroup)(ctx, a);
227
+ case count_documents_1.COUNT_DOCUMENTS:
228
+ return yield* (0, count_documents_1.countDocuments)(ctx, a);
229
+ case aggregate_collection_1.AGGREGATE_COLLECTION:
230
+ return yield* (0, aggregate_collection_1.aggregateCollection)(ctx, a);
231
+ case get_collection_schema_1.GET_COLLECTION_SCHEMA:
232
+ return yield* (0, get_collection_schema_1.getCollectionSchema)(ctx, a);
233
+ case list_indexes_1.LIST_INDEXES:
234
+ return yield* (0, list_indexes_1.listIndexes)(ctx, a);
235
+ case distinct_values_1.DISTINCT_VALUES:
236
+ return yield* (0, distinct_values_1.distinctValues)(ctx, a);
237
+ default:
238
+ return yield* task_1.Task.fail(new UnknownFirestoreOperationError(String(operation)));
239
+ }
240
+ });
241
+ };
242
+ exports.dispatchFirestoreRead = dispatchFirestoreRead;
243
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/tools/firestore/tool.ts"],"names":[],"mappings":";;;AAGA,qCAAkC;AAClC,4EAI2C;AAC3C,kEAIsC;AACtC,kEAIsC;AACtC,8EAI4C;AAC5C,4DAAuF;AACvF,wEAIyC;AACzC,oEAIuC;AACvC,gEAIqC;AACrC,4DAAuF;AACvF,oEAIuC;AACvC,gFAI6C;AAC7C,oEAIuC;AACvC,yCAAyE;AAEzE,MAAM,eAAe,GAAG;IACtB,mCAAgB;IAChB,+BA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,CAAC,IAAA,2CAAmB,EAAC,GAAG,EAAE,CAA4B,CAAC,CAAC;YACvE,KAAK,2BAAY;gBACf,OAAO,KAAK,CAAC,CAAC,IAAA,0BAAW,EAAC,GAAG,EAAE,CAAoB,CAAC,CAAC;YACvD,KAAK,iCAAe;gBAClB,OAAO,KAAK,CAAC,CAAC,IAAA,gCAAc,EAAC,GAAG,EAAE,CAAuB,CAAC,CAAC;YAC7D;gBACE,OAAO,KAAK,CAAC,CAAC,WAAI,CAAC,IAAI,CACrB,IAAI,8BAA8B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CACtD,CAAC;QACN,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAtCW,QAAA,qBAAqB,yBAsChC"}
@@ -0,0 +1,14 @@
1
+ export declare function segmentCount(path: string): number;
2
+ /**
3
+ * Returns an error message if `path` is not a valid collection path
4
+ * (collection paths have an odd number of segments: "users", "users/123/posts").
5
+ * Returns null if the path is valid.
6
+ */
7
+ export declare function collectionPathError(path: string): string | null;
8
+ /**
9
+ * Returns an error message if `path` is not a valid document path
10
+ * (document paths have an even number of segments: "users/123", "stores/ABC/orders/456").
11
+ * Returns null if the path is valid.
12
+ */
13
+ export declare function documentPathError(path: string): string | null;
14
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/tools/firestore/utils/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW/D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW7D"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.segmentCount = segmentCount;
4
+ exports.collectionPathError = collectionPathError;
5
+ exports.documentPathError = documentPathError;
6
+ function segmentCount(path) {
7
+ return path.split('/').filter(Boolean).length;
8
+ }
9
+ /**
10
+ * Returns an error message if `path` is not a valid collection path
11
+ * (collection paths have an odd number of segments: "users", "users/123/posts").
12
+ * Returns null if the path is valid.
13
+ */
14
+ function collectionPathError(path) {
15
+ const n = segmentCount(path);
16
+ if (n % 2 === 0) {
17
+ return (`"${path}" has ${n} path segments, which makes it a document path. ` +
18
+ `A collection path must have an odd number of segments ` +
19
+ `(e.g. "users" or "users/123/posts"). ` +
20
+ `Did you mean to use get_document or list_collections instead?`);
21
+ }
22
+ return null;
23
+ }
24
+ /**
25
+ * Returns an error message if `path` is not a valid document path
26
+ * (document paths have an even number of segments: "users/123", "stores/ABC/orders/456").
27
+ * Returns null if the path is valid.
28
+ */
29
+ function documentPathError(path) {
30
+ const n = segmentCount(path);
31
+ if (n % 2 !== 0) {
32
+ return (`"${path}" has ${n} path segments, which makes it a collection path. ` +
33
+ `A document path must have an even number of segments ` +
34
+ `(e.g. "users/123" or "stores/ABC/orders/456"). ` +
35
+ `Did you mean to use list_documents or read_collection instead?`);
36
+ }
37
+ return null;
38
+ }
39
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../src/tools/firestore/utils/paths.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAOD,kDAWC;AAOD,8CAWC;AAtCD,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,CACL,IAAI,IAAI,SAAS,CAAC,kDAAkD;YACpE,wDAAwD;YACxD,uCAAuC;YACvC,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,CACL,IAAI,IAAI,SAAS,CAAC,oDAAoD;YACtE,uDAAuD;YACvD,iDAAiD;YACjD,gEAAgE,CACjE,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/tools/firestore/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,eAAe,EAAE,aAAa,EAW1C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAerB,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;CAWvB,CAAC;AAEX,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,eAAO,MAAM,iBAAiB,GAC5B,KAAK,KAAK,CAAC,SAAS,CAAC,qBAAqB,GAAG,KAAK,CAAC,SAAS,CAAC,gBAAgB;;;;CAK7E,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeDocument = exports.ORDER_BY_SCHEMA_ITEM = exports.FILTER_SCHEMA_ITEM = exports.VALID_OPERATORS = void 0;
4
- const normalize_1 = require("../normalize");
4
+ const normalize_1 = require("../../normalize");
5
5
  exports.VALID_OPERATORS = [
6
6
  '<',
7
7
  '<=',
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/tools/firestore/utils/types.ts"],"names":[],"mappings":";;;AAOA,+CAAiD;AAEpC,QAAA,eAAe,GAAoB;IAC9C,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,gBAAgB;IAChB,oBAAoB;IACpB,IAAI;IACJ,QAAQ;CACT,CAAC;AAEW,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;QACjE,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,uBAAe;YACrB,WAAW,EAAE,qBAAqB;SACnC;QACD,KAAK,EAAE;YACL,WAAW,EACT,qGAAqG;SACxG;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC;CAChC,CAAC;AAEE,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE;QAC3D,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;YACrB,WAAW,EAAE,iCAAiC;SAC/C;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,CAAC;CACX,CAAC;AAaJ,MAAM,iBAAiB,GAAG,CAC/B,GAA6E,EAC7E,EAAE,CAAC,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