firebase-tools-with-isolate 15.13.0 → 15.14.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.
@@ -14,6 +14,8 @@ exports.hasUnoptimizedImage = hasUnoptimizedImage;
14
14
  exports.isUsingMiddleware = isUsingMiddleware;
15
15
  exports.isUsingImageOptimization = isUsingImageOptimization;
16
16
  exports.isUsingNextImageInAppDirectory = isUsingNextImageInAppDirectory;
17
+ exports.isUsingNextImageInServerComponent = isUsingNextImageInServerComponent;
18
+ exports.isUsingNextImageInClientComponent = isUsingNextImageInClientComponent;
17
19
  exports.isUsingAppDirectory = isUsingAppDirectory;
18
20
  exports.allDependencyNames = allDependencyNames;
19
21
  exports.getMiddlewareMatcherRegexes = getMiddlewareMatcherRegexes;
@@ -100,23 +102,33 @@ async function hasUnoptimizedImage(sourceDir, distDir) {
100
102
  }
101
103
  async function isUsingMiddleware(dir, isDevMode) {
102
104
  if (isDevMode) {
103
- const [middlewareJs, middlewareTs] = await Promise.all([
105
+ const middlewareFiles = await Promise.all([
104
106
  (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "middleware.js")),
105
107
  (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "middleware.ts")),
108
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "proxy.js")),
109
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "proxy.ts")),
110
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "middleware.js")),
111
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "middleware.ts")),
112
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "proxy.js")),
113
+ (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "src", "proxy.ts")),
106
114
  ]);
107
- return middlewareJs || middlewareTs;
115
+ return middlewareFiles.some((file) => file);
108
116
  }
109
117
  else {
110
118
  const middlewareManifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, "server", constants_1.MIDDLEWARE_MANIFEST));
119
+ if (middlewareManifest.version === 3) {
120
+ const functionsConfigManifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, "server", constants_1.FUNCTIONS_CONFIG_MANIFEST)).catch(() => undefined);
121
+ if ((functionsConfigManifest?.functions?.["/_middleware"]?.matchers || [])?.length > 0) {
122
+ return true;
123
+ }
124
+ }
111
125
  return Object.keys(middlewareManifest.middleware).length > 0;
112
126
  }
113
127
  }
114
128
  async function isUsingImageOptimization(projectDir, distDir) {
115
129
  let isNextImageImported = await usesNextImage(projectDir, distDir);
116
130
  if (!isNextImageImported && isUsingAppDirectory((0, path_1.join)(projectDir, distDir))) {
117
- if (await isUsingNextImageInAppDirectory(projectDir, distDir)) {
118
- isNextImageImported = true;
119
- }
131
+ isNextImageImported = await isUsingNextImageInAppDirectory(projectDir, distDir);
120
132
  }
121
133
  if (isNextImageImported) {
122
134
  const imagesManifest = await (0, utils_1.readJSON)((0, path_1.join)(projectDir, distDir, constants_1.IMAGES_MANIFEST));
@@ -124,7 +136,11 @@ async function isUsingImageOptimization(projectDir, distDir) {
124
136
  }
125
137
  return false;
126
138
  }
127
- async function isUsingNextImageInAppDirectory(projectDir, nextDir) {
139
+ async function isUsingNextImageInAppDirectory(projectDir, distDir) {
140
+ return ((await isUsingNextImageInServerComponent(projectDir, distDir)) ||
141
+ isUsingNextImageInClientComponent(projectDir, distDir));
142
+ }
143
+ async function isUsingNextImageInServerComponent(projectDir, nextDir) {
128
144
  const nextImagePath = ["node_modules", "next", "dist", "client", "image"];
129
145
  const nextImageString = utils_2.IS_WINDOWS
130
146
  ?
@@ -139,6 +155,16 @@ async function isUsingNextImageInAppDirectory(projectDir, nextDir) {
139
155
  }
140
156
  return false;
141
157
  }
158
+ async function isUsingNextImageInClientComponent(projectDir, distDir) {
159
+ const htmlFiles = await (0, glob_1.glob)((0, path_1.join)(projectDir, distDir, "server", "app", "**", "*.html"));
160
+ for (const filepath of htmlFiles) {
161
+ const contents = await (0, promises_1.readFile)(filepath, "utf-8");
162
+ if (contents.includes('data-nimg="')) {
163
+ return true;
164
+ }
165
+ }
166
+ return false;
167
+ }
142
168
  function isUsingAppDirectory(dir) {
143
169
  const appPathRoutesManifestPath = (0, path_1.join)(dir, constants_1.APP_PATH_ROUTES_MANIFEST);
144
170
  return (0, fsutils_1.fileExistsSync)(appPathRoutesManifestPath);
@@ -149,16 +175,28 @@ function allDependencyNames(mod) {
149
175
  const dependencyNames = Object.keys(mod.dependencies).reduce((acc, it) => [...acc, it, ...allDependencyNames(mod.dependencies[it])], []);
150
176
  return dependencyNames;
151
177
  }
152
- function getMiddlewareMatcherRegexes(middlewareManifest) {
178
+ function getMiddlewareMatcherRegexes(middlewareManifest, functionsConfigManifest) {
153
179
  const middlewareObjectValues = Object.values(middlewareManifest.middleware);
154
- let middlewareMatchers;
180
+ const middlewareMatchers = [];
155
181
  if (middlewareManifest.version === 1) {
156
- middlewareMatchers = middlewareObjectValues.map((page) => ({ regexp: page.regexp }));
182
+ middlewareMatchers.push(...middlewareObjectValues.map((page) => ({
183
+ regexp: page.regexp,
184
+ })));
157
185
  }
158
- else {
159
- middlewareMatchers = middlewareObjectValues
186
+ else if (middlewareManifest.version === 2) {
187
+ middlewareMatchers.push(...middlewareObjectValues
160
188
  .map((page) => page.matchers)
161
- .flat();
189
+ .flat());
190
+ }
191
+ else if (middlewareManifest.version === 3) {
192
+ if (functionsConfigManifest?.functions?.["/_middleware"]) {
193
+ middlewareMatchers.push(...(functionsConfigManifest.functions["/_middleware"].matchers || []));
194
+ }
195
+ else {
196
+ middlewareMatchers.push(...middlewareObjectValues
197
+ .map((page) => page.matchers)
198
+ .flat());
199
+ }
162
200
  }
163
201
  return middlewareMatchers.map((matcher) => new RegExp(matcher.regexp));
164
202
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONVERTABLE_EVENTS = exports.DATACONNECT_EVENT = exports.FIREALERTS_EVENT = exports.FIRESTORE_EVENTS = exports.TEST_LAB_EVENT = exports.REMOTE_CONFIG_EVENT = exports.DATABASE_EVENTS = exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
3
+ exports.AI_LOGIC_TRIGGERS_TO_EVENTS = exports.AI_LOGIC_EVENTS_TO_TRIGGER = exports.CONVERTABLE_EVENTS = exports.DATACONNECT_EVENT = exports.FIREALERTS_EVENT = exports.FIRESTORE_EVENTS = exports.TEST_LAB_EVENT = exports.REMOTE_CONFIG_EVENT = exports.DATABASE_EVENTS = exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
4
+ const ailogic_1 = require("../../deploy/functions/services/ailogic");
4
5
  exports.PUBSUB_PUBLISH_EVENT = "google.cloud.pubsub.topic.v1.messagePublished";
5
6
  exports.STORAGE_EVENTS = [
6
7
  "google.cloud.storage.object.v1.finalized",
@@ -35,3 +36,11 @@ exports.CONVERTABLE_EVENTS = {
35
36
  "google.cloud.firestore.document.v1.deleted": "google.cloud.firestore.document.v1.deleted.withAuthContext",
36
37
  "google.cloud.firestore.document.v1.written": "google.cloud.firestore.document.v1.written.withAuthContext",
37
38
  };
39
+ exports.AI_LOGIC_EVENTS_TO_TRIGGER = {
40
+ [ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT]: "before-generate-content",
41
+ [ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT]: "after-generate-content",
42
+ };
43
+ exports.AI_LOGIC_TRIGGERS_TO_EVENTS = {
44
+ "before-generate-content": ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT,
45
+ "after-generate-content": ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT,
46
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.client = exports.AI_LOGIC_TRIGGERS_TO_EVENTS = exports.AI_LOGIC_EVENTS_TO_TRIGGER = exports.API_VERSION = void 0;
3
+ exports.client = exports.AI_LOGIC_TRIGGERS_TO_EVENTS = exports.AI_LOGIC_EVENTS_TO_TRIGGER = exports.AI_LOGIC_AFTER_GENERATE_CONTENT = exports.AI_LOGIC_BEFORE_GENERATE_CONTENT = exports.API_VERSION = void 0;
4
4
  exports.createTrigger = createTrigger;
5
5
  exports.getTrigger = getTrigger;
6
6
  exports.updateTrigger = updateTrigger;
@@ -10,15 +10,16 @@ exports.upsertBlockingFunction = upsertBlockingFunction;
10
10
  exports.deleteBlockingFunction = deleteBlockingFunction;
11
11
  const apiv2_1 = require("../apiv2");
12
12
  const api_1 = require("../api");
13
- const ailogic_1 = require("../deploy/functions/services/ailogic");
14
13
  exports.API_VERSION = "v1beta";
14
+ exports.AI_LOGIC_BEFORE_GENERATE_CONTENT = "google.firebase.ailogic.v1.beforeGenerate";
15
+ exports.AI_LOGIC_AFTER_GENERATE_CONTENT = "google.firebase.ailogic.v1.afterGenerate";
15
16
  exports.AI_LOGIC_EVENTS_TO_TRIGGER = {
16
- [ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT]: "before-generate-content",
17
- [ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT]: "after-generate-content",
17
+ [exports.AI_LOGIC_BEFORE_GENERATE_CONTENT]: "before-generate-content",
18
+ [exports.AI_LOGIC_AFTER_GENERATE_CONTENT]: "after-generate-content",
18
19
  };
19
20
  exports.AI_LOGIC_TRIGGERS_TO_EVENTS = {
20
- "before-generate-content": ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT,
21
- "after-generate-content": ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT,
21
+ "before-generate-content": exports.AI_LOGIC_BEFORE_GENERATE_CONTENT,
22
+ "after-generate-content": exports.AI_LOGIC_AFTER_GENERATE_CONTENT,
22
23
  };
23
24
  exports.client = new apiv2_1.Client({
24
25
  urlPrefix: (0, api_1.aiLogicProxyOrigin)(),
package/lib/mcp/index.js CHANGED
@@ -133,6 +133,7 @@ class FirebaseMcpServer {
133
133
  if (this.detectedFeatures?.length)
134
134
  return this.detectedFeatures;
135
135
  this.logger.debug("detecting active features of Firebase MCP server...");
136
+ await this.detectProjectRoot();
136
137
  const projectId = (await this.getProjectId()) || "";
137
138
  const accountEmail = await this.getAuthenticatedUser();
138
139
  const isBillingEnabled = projectId ? await this.safeCheckBillingEnabled(projectId) : false;