firebase-functions 7.0.3 → 7.0.4

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.
@@ -19,7 +19,7 @@ import { tasks_exports } from "./providers/tasks.mjs";
19
19
  import { remoteConfig_exports } from "./providers/remoteConfig.mjs";
20
20
  import { testLab_exports } from "./providers/testLab.mjs";
21
21
  import { firestore_exports } from "./providers/firestore.mjs";
22
- import { dataconnect_exports } from "./providers/dataconnect.mjs";
22
+ import { dataconnect_exports } from "./providers/dataconnect/index.mjs";
23
23
 
24
24
  //#region src/v2/index.ts
25
25
  const app = { setEmulatedAdminApp: setApp };
@@ -0,0 +1,89 @@
1
+ import { initV2Endpoint } from "../../../runtime/manifest.mjs";
2
+ import { convertIfPresent, convertInvoker } from "../../../common/encoding.mjs";
3
+ import { withInit } from "../../../common/onInit.mjs";
4
+ import { withErrorHandler } from "../../../common/providers/https.mjs";
5
+ import { wrapTraceContext } from "../../trace.mjs";
6
+ import { getGlobalOptions, optionsToEndpoint } from "../../options.mjs";
7
+ import express from "express";
8
+ import fs from "fs";
9
+ import { ApolloServer } from "@apollo/server";
10
+ import { expressMiddleware } from "@as-integrations/express4";
11
+
12
+ //#region src/v2/providers/dataconnect/graphql.ts
13
+ const FIREBASE_AUTH_HEADER = "X-Firebase-Auth-Token";
14
+ /** @hidden */
15
+ async function initGraphqlServer(opts) {
16
+ if (!opts.schema && !opts.schemaFilePath || opts.schema && opts.schemaFilePath) {
17
+ throw new Error("Exactly one of 'schema' or 'schemaFilePath' must be provided.");
18
+ }
19
+ if (opts.schemaFilePath) {
20
+ opts.schema = fs.readFileSync(opts.schemaFilePath, "utf-8");
21
+ }
22
+ if (!opts.resolvers.query && !opts.resolvers.mutation) {
23
+ throw new Error("At least one query or mutation resolver must be provided.");
24
+ }
25
+ const apolloResolvers = {};
26
+ if (opts.resolvers.query) {
27
+ apolloResolvers.Query = opts.resolvers.query;
28
+ }
29
+ if (opts.resolvers.mutation) {
30
+ apolloResolvers.Mutation = opts.resolvers.mutation;
31
+ }
32
+ try {
33
+ const serverPromise = (async () => {
34
+ const app = express();
35
+ const server = new ApolloServer({
36
+ typeDefs: opts.schema,
37
+ resolvers: apolloResolvers
38
+ });
39
+ await server.start();
40
+ app.use(`/${opts.path ?? "graphql"}`, express.json(), expressMiddleware(server, { context: ({ req }) => Promise.resolve({ auth: { token: req.header(FIREBASE_AUTH_HEADER) } }) }));
41
+ return app;
42
+ })();
43
+ return serverPromise;
44
+ } catch (e) {
45
+ if (e instanceof Error) {
46
+ throw new Error("Error initializing GraphQL server: " + e.message);
47
+ } else {
48
+ throw e;
49
+ }
50
+ }
51
+ }
52
+ /**
53
+ * @hidden
54
+ * Handles HTTPS GraphQL requests.
55
+ * @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
56
+ * @returns {HttpsFunction} A function you can export and deploy.
57
+ */
58
+ function onGraphRequest(opts) {
59
+ let serverPromise = null;
60
+ const handler = wrapTraceContext(withInit(withErrorHandler(async (req, res) => {
61
+ serverPromise = serverPromise ?? initGraphqlServer(opts);
62
+ const app = await serverPromise;
63
+ app(req, res);
64
+ })));
65
+ const globalOpts = getGlobalOptions();
66
+ const baseOpts = optionsToEndpoint(globalOpts);
67
+ const specificOpts = optionsToEndpoint(opts);
68
+ const endpoint = {
69
+ ...initV2Endpoint(globalOpts, opts),
70
+ platform: "gcfv2",
71
+ ...baseOpts,
72
+ ...specificOpts,
73
+ labels: {
74
+ ...baseOpts?.labels,
75
+ ...specificOpts?.labels
76
+ },
77
+ dataConnectGraphqlTrigger: {}
78
+ };
79
+ convertIfPresent(endpoint.dataConnectGraphqlTrigger, globalOpts, "invoker", "invoker", convertInvoker);
80
+ convertIfPresent(endpoint.dataConnectGraphqlTrigger, opts, "invoker", "invoker", convertInvoker);
81
+ if (opts.schemaFilePath) {
82
+ endpoint.dataConnectGraphqlTrigger.schemaFilePath = opts.schemaFilePath;
83
+ }
84
+ handler.__endpoint = endpoint;
85
+ return handler;
86
+ }
87
+
88
+ //#endregion
89
+ export { initGraphqlServer, onGraphRequest };
@@ -1,20 +1,14 @@
1
- import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
- import { initV2Endpoint } from "../../runtime/manifest.mjs";
3
- import { convertIfPresent, convertInvoker } from "../../common/encoding.mjs";
4
- import { withInit } from "../../common/onInit.mjs";
5
- import { withErrorHandler } from "../../common/providers/https.mjs";
6
- import { normalizePath } from "../../common/utilities/path.mjs";
7
- import { wrapTraceContext } from "../trace.mjs";
8
- import { getGlobalOptions, optionsToEndpoint } from "../options.mjs";
9
- import { PathPattern } from "../../common/utilities/path-pattern.mjs";
10
- import express from "express";
11
- import fs from "fs";
1
+ import { __export } from "../../../_virtual/rolldown_runtime.mjs";
2
+ import { initV2Endpoint } from "../../../runtime/manifest.mjs";
3
+ import { withInit } from "../../../common/onInit.mjs";
4
+ import { normalizePath } from "../../../common/utilities/path.mjs";
5
+ import { wrapTraceContext } from "../../trace.mjs";
6
+ import { getGlobalOptions, optionsToEndpoint } from "../../options.mjs";
7
+ import { PathPattern } from "../../../common/utilities/path-pattern.mjs";
12
8
 
13
- //#region src/v2/providers/dataconnect.ts
9
+ //#region src/v2/providers/dataconnect/index.ts
14
10
  var dataconnect_exports = /* @__PURE__ */ __export({
15
- initGraphqlServer: () => initGraphqlServer,
16
11
  mutationExecutedEventType: () => mutationExecutedEventType,
17
- onGraphRequest: () => onGraphRequest,
18
12
  onMutationExecuted: () => onMutationExecuted
19
13
  });
20
14
  /** @internal */
@@ -131,81 +125,6 @@ function onOperation(eventType, mutationOrOpts, handler) {
131
125
  func.__endpoint = makeEndpoint(eventType, opts, servicePattern, connectorPattern, operationPattern);
132
126
  return func;
133
127
  }
134
- /** @hidden */
135
- async function initGraphqlServer(opts) {
136
- if (!opts.schema && !opts.schemaFilePath || opts.schema && opts.schemaFilePath) {
137
- throw new Error("Exactly one of 'schema' or 'schemaFilePath' must be provided.");
138
- }
139
- if (opts.schemaFilePath) {
140
- opts.schema = fs.readFileSync(opts.schemaFilePath, "utf-8");
141
- }
142
- if (!opts.resolvers.query && !opts.resolvers.mutation) {
143
- throw new Error("At least one query or mutation resolver must be provided.");
144
- }
145
- const apolloResolvers = {};
146
- if (opts.resolvers.query) {
147
- apolloResolvers.Query = opts.resolvers.query;
148
- }
149
- if (opts.resolvers.mutation) {
150
- apolloResolvers.Mutation = opts.resolvers.mutation;
151
- }
152
- try {
153
- const { ApolloServer } = await import("@apollo/server");
154
- const { expressMiddleware } = await import("@as-integrations/express4");
155
- const serverPromise$1 = (async () => {
156
- const app = express();
157
- const server = new ApolloServer({
158
- typeDefs: opts.schema,
159
- resolvers: apolloResolvers
160
- });
161
- await server.start();
162
- app.use(`/${opts.path ?? "graphql"}`, express.json(), expressMiddleware(server));
163
- return app;
164
- })();
165
- return serverPromise$1;
166
- } catch (e) {
167
- if (e instanceof Error) {
168
- throw new Error("Error initializing GraphQL server: " + e.message);
169
- } else {
170
- throw e;
171
- }
172
- }
173
- }
174
- let serverPromise = null;
175
- /**
176
- * @hidden
177
- * Handles HTTPS GraphQL requests.
178
- * @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
179
- * @returns {HttpsFunction} A function you can export and deploy.
180
- */
181
- function onGraphRequest(opts) {
182
- const handler = wrapTraceContext(withInit(withErrorHandler(async (req, res) => {
183
- serverPromise = serverPromise ?? initGraphqlServer(opts);
184
- const app = await serverPromise;
185
- app(req, res);
186
- })));
187
- const globalOpts = getGlobalOptions();
188
- const baseOpts = optionsToEndpoint(globalOpts);
189
- const specificOpts = optionsToEndpoint(opts);
190
- const endpoint = {
191
- ...initV2Endpoint(globalOpts, opts),
192
- platform: "gcfv2",
193
- ...baseOpts,
194
- ...specificOpts,
195
- labels: {
196
- ...baseOpts?.labels,
197
- ...specificOpts?.labels
198
- },
199
- dataConnectGraphqlTrigger: {}
200
- };
201
- convertIfPresent(endpoint.dataConnectGraphqlTrigger, globalOpts, "invoker", "invoker", convertInvoker);
202
- convertIfPresent(endpoint.dataConnectGraphqlTrigger, opts, "invoker", "invoker", convertInvoker);
203
- if (opts.schemaFilePath) {
204
- endpoint.dataConnectGraphqlTrigger.schemaFilePath = opts.schemaFilePath;
205
- }
206
- handler.__endpoint = endpoint;
207
- return handler;
208
- }
209
128
 
210
129
  //#endregion
211
- export { dataconnect_exports, initGraphqlServer, mutationExecutedEventType, onGraphRequest, onMutationExecuted };
130
+ export { dataconnect_exports, mutationExecutedEventType, onMutationExecuted };
package/lib/v2/index.js CHANGED
@@ -19,7 +19,7 @@ const require_v2_providers_tasks = require('./providers/tasks.js');
19
19
  const require_v2_providers_remoteConfig = require('./providers/remoteConfig.js');
20
20
  const require_v2_providers_testLab = require('./providers/testLab.js');
21
21
  const require_v2_providers_firestore = require('./providers/firestore.js');
22
- const require_v2_providers_dataconnect = require('./providers/dataconnect.js');
22
+ const require_v2_providers_dataconnect_index = require('./providers/dataconnect/index.js');
23
23
 
24
24
  //#region src/v2/index.ts
25
25
  const app = { setEmulatedAdminApp: require_common_app.setApp };
@@ -43,7 +43,7 @@ Object.defineProperty(exports, 'database', {
43
43
  Object.defineProperty(exports, 'dataconnect', {
44
44
  enumerable: true,
45
45
  get: function () {
46
- return require_v2_providers_dataconnect.dataconnect_exports;
46
+ return require_v2_providers_dataconnect_index.dataconnect_exports;
47
47
  }
48
48
  });
49
49
  Object.defineProperty(exports, 'eventarc', {
@@ -0,0 +1,58 @@
1
+ import express from "express";
2
+ import type { GraphQLResolveInfo } from "graphql";
3
+ import { HttpsFunction, HttpsOptions } from "../https";
4
+ /** @hidden */
5
+ export declare function initGraphqlServer(opts: GraphqlServerOptions): Promise<express.Express>;
6
+ /**
7
+ * @hidden
8
+ * Handles HTTPS GraphQL requests.
9
+ * @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
10
+ * @returns {HttpsFunction} A function you can export and deploy.
11
+ */
12
+ export declare function onGraphRequest(opts: GraphqlServerOptions): HttpsFunction;
13
+ /**
14
+ * @hidden
15
+ * Options for configuring the GraphQL server.
16
+ */
17
+ export interface GraphqlServerOptions extends Omit<HttpsOptions, "cors"> {
18
+ /**
19
+ * A valid SDL string that represents the GraphQL server's schema.
20
+ * Either `schema` or `schemaFilePath` is required.
21
+ */
22
+ schema?: string;
23
+ /**
24
+ * A relative file path from the Firebase project directory to a valid GraphQL schema.
25
+ * Either `schema` or `schemaFilePath` is required.
26
+ */
27
+ schemaFilePath?: string;
28
+ /**
29
+ * The path where the GraphQL server will be served on the Cloud Run function.
30
+ * e.g. https://...run.app/{path}
31
+ * If no path is provided, "graphql" is used as the default.
32
+ */
33
+ path?: string;
34
+ /** A map of functions that populate data for individual GraphQL schema fields. */
35
+ resolvers: GraphqlResolvers;
36
+ }
37
+ /**
38
+ * @hidden
39
+ * Per-request context state shared by all resolvers in a particular query.
40
+ */
41
+ export interface FirebaseContext {
42
+ auth: {
43
+ /** The token attached to the `X-Firebase-Auth-Token` in the request, if present. */
44
+ token?: string;
45
+ };
46
+ }
47
+ /**
48
+ * @hidden
49
+ * Resolver functions that populate data for individual GraphQL schema fields.
50
+ */
51
+ export interface GraphqlResolvers {
52
+ query?: {
53
+ [resolver: string]: (parent: unknown, args: Record<string, unknown>, context: FirebaseContext, info: GraphQLResolveInfo) => unknown;
54
+ };
55
+ mutation?: {
56
+ [key: string]: (parent: unknown, args: Record<string, unknown>, context: FirebaseContext, info: GraphQLResolveInfo) => unknown;
57
+ };
58
+ }
@@ -0,0 +1,95 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
2
+ const require_runtime_manifest = require('../../../runtime/manifest.js');
3
+ const require_common_encoding = require('../../../common/encoding.js');
4
+ const require_common_onInit = require('../../../common/onInit.js');
5
+ const require_common_providers_https = require('../../../common/providers/https.js');
6
+ const require_v2_trace = require('../../trace.js');
7
+ const require_v2_options = require('../../options.js');
8
+ let express = require("express");
9
+ express = require_rolldown_runtime.__toESM(express);
10
+ let fs = require("fs");
11
+ fs = require_rolldown_runtime.__toESM(fs);
12
+ let __apollo_server = require("@apollo/server");
13
+ __apollo_server = require_rolldown_runtime.__toESM(__apollo_server);
14
+ let __as_integrations_express4 = require("@as-integrations/express4");
15
+ __as_integrations_express4 = require_rolldown_runtime.__toESM(__as_integrations_express4);
16
+
17
+ //#region src/v2/providers/dataconnect/graphql.ts
18
+ const FIREBASE_AUTH_HEADER = "X-Firebase-Auth-Token";
19
+ /** @hidden */
20
+ async function initGraphqlServer(opts) {
21
+ if (!opts.schema && !opts.schemaFilePath || opts.schema && opts.schemaFilePath) {
22
+ throw new Error("Exactly one of 'schema' or 'schemaFilePath' must be provided.");
23
+ }
24
+ if (opts.schemaFilePath) {
25
+ opts.schema = fs.default.readFileSync(opts.schemaFilePath, "utf-8");
26
+ }
27
+ if (!opts.resolvers.query && !opts.resolvers.mutation) {
28
+ throw new Error("At least one query or mutation resolver must be provided.");
29
+ }
30
+ const apolloResolvers = {};
31
+ if (opts.resolvers.query) {
32
+ apolloResolvers.Query = opts.resolvers.query;
33
+ }
34
+ if (opts.resolvers.mutation) {
35
+ apolloResolvers.Mutation = opts.resolvers.mutation;
36
+ }
37
+ try {
38
+ const serverPromise = (async () => {
39
+ const app = (0, express.default)();
40
+ const server = new __apollo_server.ApolloServer({
41
+ typeDefs: opts.schema,
42
+ resolvers: apolloResolvers
43
+ });
44
+ await server.start();
45
+ app.use(`/${opts.path ?? "graphql"}`, express.default.json(), (0, __as_integrations_express4.expressMiddleware)(server, { context: ({ req }) => Promise.resolve({ auth: { token: req.header(FIREBASE_AUTH_HEADER) } }) }));
46
+ return app;
47
+ })();
48
+ return serverPromise;
49
+ } catch (e) {
50
+ if (e instanceof Error) {
51
+ throw new Error("Error initializing GraphQL server: " + e.message);
52
+ } else {
53
+ throw e;
54
+ }
55
+ }
56
+ }
57
+ /**
58
+ * @hidden
59
+ * Handles HTTPS GraphQL requests.
60
+ * @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
61
+ * @returns {HttpsFunction} A function you can export and deploy.
62
+ */
63
+ function onGraphRequest(opts) {
64
+ let serverPromise = null;
65
+ const handler = require_v2_trace.wrapTraceContext(require_common_onInit.withInit(require_common_providers_https.withErrorHandler(async (req, res) => {
66
+ serverPromise = serverPromise ?? initGraphqlServer(opts);
67
+ const app = await serverPromise;
68
+ app(req, res);
69
+ })));
70
+ const globalOpts = require_v2_options.getGlobalOptions();
71
+ const baseOpts = require_v2_options.optionsToEndpoint(globalOpts);
72
+ const specificOpts = require_v2_options.optionsToEndpoint(opts);
73
+ const endpoint = {
74
+ ...require_runtime_manifest.initV2Endpoint(globalOpts, opts),
75
+ platform: "gcfv2",
76
+ ...baseOpts,
77
+ ...specificOpts,
78
+ labels: {
79
+ ...baseOpts?.labels,
80
+ ...specificOpts?.labels
81
+ },
82
+ dataConnectGraphqlTrigger: {}
83
+ };
84
+ require_common_encoding.convertIfPresent(endpoint.dataConnectGraphqlTrigger, globalOpts, "invoker", "invoker", require_common_encoding.convertInvoker);
85
+ require_common_encoding.convertIfPresent(endpoint.dataConnectGraphqlTrigger, opts, "invoker", "invoker", require_common_encoding.convertInvoker);
86
+ if (opts.schemaFilePath) {
87
+ endpoint.dataConnectGraphqlTrigger.schemaFilePath = opts.schemaFilePath;
88
+ }
89
+ handler.__endpoint = endpoint;
90
+ return handler;
91
+ }
92
+
93
+ //#endregion
94
+ exports.initGraphqlServer = initGraphqlServer;
95
+ exports.onGraphRequest = onGraphRequest;
@@ -1,11 +1,8 @@
1
- import express from "express";
2
- import type { GraphQLResolveInfo } from "graphql";
3
- import { HttpsFunction, HttpsOptions } from "./https";
4
- import { CloudEvent, CloudFunction } from "../core";
5
- import { ParamsOf, VarName } from "../../common/params";
6
- import { EventHandlerOptions, SupportedRegion } from "../options";
7
- import { Expression } from "../../params";
8
- import { ResetValue } from "../../common/options";
1
+ import { CloudEvent, CloudFunction } from "../../core";
2
+ import { ParamsOf, VarName } from "../../../common/params";
3
+ import { EventHandlerOptions, SupportedRegion } from "../../options";
4
+ import { Expression } from "../../../params";
5
+ import { ResetValue } from "../../../common/options";
9
6
  /** @hidden */
10
7
  export interface SourceLocation {
11
8
  line: number;
@@ -96,60 +93,3 @@ export declare function onMutationExecuted<Mutation extends string, Variables =
96
93
  * @param handler - Event handler which is run every time a mutation is executed.
97
94
  */
98
95
  export declare function onMutationExecuted<Options extends OperationOptions, Variables = unknown, ResponseData = unknown>(opts: Options, handler: (event: DataConnectEvent<MutationEventData<Variables, ResponseData>, DataConnectParams<Options>>) => unknown | Promise<unknown>): CloudFunction<DataConnectEvent<MutationEventData<Variables, ResponseData>, DataConnectParams<Options>>>;
99
- /** @hidden */
100
- export declare function initGraphqlServer(opts: GraphqlServerOptions): Promise<express.Express>;
101
- /**
102
- * @hidden
103
- * Handles HTTPS GraphQL requests.
104
- * @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
105
- * @returns {HttpsFunction} A function you can export and deploy.
106
- */
107
- export declare function onGraphRequest(opts: GraphqlServerOptions): HttpsFunction;
108
- /**
109
- * @hidden
110
- * Options for configuring the GraphQL server.
111
- */
112
- export interface GraphqlServerOptions extends Omit<HttpsOptions, "cors"> {
113
- /**
114
- * A valid SDL string that represents the GraphQL server's schema.
115
- * Either `schema` or `schemaFilePath` is required.
116
- */
117
- schema?: string;
118
- /**
119
- * A relative file path from the Firebase project directory to a valid GraphQL schema.
120
- * Either `schema` or `schemaFilePath` is required.
121
- */
122
- schemaFilePath?: string;
123
- /**
124
- * The path where the GraphQL server will be served on the Cloud Run function.
125
- * e.g. https://...run.app/{path}
126
- * If no path is provided, "graphql" is used as the default.
127
- */
128
- path?: string;
129
- /** A map of functions that populate data for individual GraphQL schema fields. */
130
- resolvers: GraphqlResolvers;
131
- }
132
- /**
133
- * @hidden
134
- * Per-request context state shared by all resolvers in a particular query.
135
- */
136
- export interface FirebaseContext {
137
- auth?: {
138
- /** The UID of the Firebase user that made the request, if present. */
139
- uid?: string;
140
- /** The token attached to the `X-Firebase-Auth-Token` in the request, if present. */
141
- token?: string;
142
- };
143
- }
144
- /**
145
- * @hidden
146
- * Resolver functions that populate data for individual GraphQL schema fields.
147
- */
148
- export interface GraphqlResolvers {
149
- query?: {
150
- [resolver: string]: (parent: unknown, args: Record<string, unknown>, context: FirebaseContext, info: GraphQLResolveInfo) => unknown;
151
- };
152
- mutation?: {
153
- [key: string]: (parent: unknown, args: Record<string, unknown>, context: FirebaseContext, info: GraphQLResolveInfo) => unknown;
154
- };
155
- }
@@ -1,22 +1,14 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
2
- const require_runtime_manifest = require('../../runtime/manifest.js');
3
- const require_common_encoding = require('../../common/encoding.js');
4
- const require_common_onInit = require('../../common/onInit.js');
5
- const require_common_providers_https = require('../../common/providers/https.js');
6
- const require_common_utilities_path = require('../../common/utilities/path.js');
7
- const require_v2_trace = require('../trace.js');
8
- const require_v2_options = require('../options.js');
9
- const require_common_utilities_path_pattern = require('../../common/utilities/path-pattern.js');
10
- let express = require("express");
11
- express = require_rolldown_runtime.__toESM(express);
12
- let fs = require("fs");
13
- fs = require_rolldown_runtime.__toESM(fs);
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
2
+ const require_runtime_manifest = require('../../../runtime/manifest.js');
3
+ const require_common_onInit = require('../../../common/onInit.js');
4
+ const require_common_utilities_path = require('../../../common/utilities/path.js');
5
+ const require_v2_trace = require('../../trace.js');
6
+ const require_v2_options = require('../../options.js');
7
+ const require_common_utilities_path_pattern = require('../../../common/utilities/path-pattern.js');
14
8
 
15
- //#region src/v2/providers/dataconnect.ts
9
+ //#region src/v2/providers/dataconnect/index.ts
16
10
  var dataconnect_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
17
- initGraphqlServer: () => initGraphqlServer,
18
11
  mutationExecutedEventType: () => mutationExecutedEventType,
19
- onGraphRequest: () => onGraphRequest,
20
12
  onMutationExecuted: () => onMutationExecuted
21
13
  });
22
14
  /** @internal */
@@ -133,81 +125,6 @@ function onOperation(eventType, mutationOrOpts, handler) {
133
125
  func.__endpoint = makeEndpoint(eventType, opts, servicePattern, connectorPattern, operationPattern);
134
126
  return func;
135
127
  }
136
- /** @hidden */
137
- async function initGraphqlServer(opts) {
138
- if (!opts.schema && !opts.schemaFilePath || opts.schema && opts.schemaFilePath) {
139
- throw new Error("Exactly one of 'schema' or 'schemaFilePath' must be provided.");
140
- }
141
- if (opts.schemaFilePath) {
142
- opts.schema = fs.default.readFileSync(opts.schemaFilePath, "utf-8");
143
- }
144
- if (!opts.resolvers.query && !opts.resolvers.mutation) {
145
- throw new Error("At least one query or mutation resolver must be provided.");
146
- }
147
- const apolloResolvers = {};
148
- if (opts.resolvers.query) {
149
- apolloResolvers.Query = opts.resolvers.query;
150
- }
151
- if (opts.resolvers.mutation) {
152
- apolloResolvers.Mutation = opts.resolvers.mutation;
153
- }
154
- try {
155
- const { ApolloServer } = await import("@apollo/server");
156
- const { expressMiddleware } = await import("@as-integrations/express4");
157
- const serverPromise$1 = (async () => {
158
- const app = (0, express.default)();
159
- const server = new ApolloServer({
160
- typeDefs: opts.schema,
161
- resolvers: apolloResolvers
162
- });
163
- await server.start();
164
- app.use(`/${opts.path ?? "graphql"}`, express.default.json(), expressMiddleware(server));
165
- return app;
166
- })();
167
- return serverPromise$1;
168
- } catch (e) {
169
- if (e instanceof Error) {
170
- throw new Error("Error initializing GraphQL server: " + e.message);
171
- } else {
172
- throw e;
173
- }
174
- }
175
- }
176
- let serverPromise = null;
177
- /**
178
- * @hidden
179
- * Handles HTTPS GraphQL requests.
180
- * @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
181
- * @returns {HttpsFunction} A function you can export and deploy.
182
- */
183
- function onGraphRequest(opts) {
184
- const handler = require_v2_trace.wrapTraceContext(require_common_onInit.withInit(require_common_providers_https.withErrorHandler(async (req, res) => {
185
- serverPromise = serverPromise ?? initGraphqlServer(opts);
186
- const app = await serverPromise;
187
- app(req, res);
188
- })));
189
- const globalOpts = require_v2_options.getGlobalOptions();
190
- const baseOpts = require_v2_options.optionsToEndpoint(globalOpts);
191
- const specificOpts = require_v2_options.optionsToEndpoint(opts);
192
- const endpoint = {
193
- ...require_runtime_manifest.initV2Endpoint(globalOpts, opts),
194
- platform: "gcfv2",
195
- ...baseOpts,
196
- ...specificOpts,
197
- labels: {
198
- ...baseOpts?.labels,
199
- ...specificOpts?.labels
200
- },
201
- dataConnectGraphqlTrigger: {}
202
- };
203
- require_common_encoding.convertIfPresent(endpoint.dataConnectGraphqlTrigger, globalOpts, "invoker", "invoker", require_common_encoding.convertInvoker);
204
- require_common_encoding.convertIfPresent(endpoint.dataConnectGraphqlTrigger, opts, "invoker", "invoker", require_common_encoding.convertInvoker);
205
- if (opts.schemaFilePath) {
206
- endpoint.dataConnectGraphqlTrigger.schemaFilePath = opts.schemaFilePath;
207
- }
208
- handler.__endpoint = endpoint;
209
- return handler;
210
- }
211
128
 
212
129
  //#endregion
213
130
  Object.defineProperty(exports, 'dataconnect_exports', {
@@ -216,7 +133,5 @@ Object.defineProperty(exports, 'dataconnect_exports', {
216
133
  return dataconnect_exports;
217
134
  }
218
135
  });
219
- exports.initGraphqlServer = initGraphqlServer;
220
136
  exports.mutationExecutedEventType = mutationExecutedEventType;
221
- exports.onGraphRequest = onGraphRequest;
222
137
  exports.onMutationExecuted = onMutationExecuted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-functions",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "description": "Firebase SDK for Cloud Functions",
5
5
  "keywords": [
6
6
  "firebase",
@@ -199,9 +199,14 @@
199
199
  "require": "./lib/v2/providers/firestore.js"
200
200
  },
201
201
  "./dataconnect": {
202
- "types": "./lib/v2/providers/dataconnect.d.ts",
203
- "import": "./lib/esm/v2/providers/dataconnect.mjs",
204
- "require": "./lib/v2/providers/dataconnect.js"
202
+ "types": "./lib/v2/providers/dataconnect/index.d.ts",
203
+ "import": "./lib/esm/v2/providers/dataconnect/index.mjs",
204
+ "require": "./lib/v2/providers/dataconnect/index.js"
205
+ },
206
+ "./dataconnect/graphql": {
207
+ "types": "./lib/v2/providers/dataconnect/graphql.d.ts",
208
+ "import": "./lib/esm/v2/providers/dataconnect/graphql.mjs",
209
+ "require": "./lib/v2/providers/dataconnect/graphql.js"
205
210
  },
206
211
  "./v2": {
207
212
  "types": "./lib/v2/index.d.ts",
@@ -299,9 +304,14 @@
299
304
  "require": "./lib/v2/providers/firestore.js"
300
305
  },
301
306
  "./v2/dataconnect": {
302
- "types": "./lib/v2/providers/dataconnect.d.ts",
303
- "import": "./lib/esm/v2/providers/dataconnect.mjs",
304
- "require": "./lib/v2/providers/dataconnect.js"
307
+ "types": "./lib/v2/providers/dataconnect/index.d.ts",
308
+ "import": "./lib/esm/v2/providers/dataconnect/index.mjs",
309
+ "require": "./lib/v2/providers/dataconnect/index.js"
310
+ },
311
+ "./v2/dataconnect/graphql": {
312
+ "types": "./lib/v2/providers/dataconnect/graphql.d.ts",
313
+ "import": "./lib/esm/v2/providers/dataconnect/graphql.mjs",
314
+ "require": "./lib/v2/providers/dataconnect/graphql.js"
305
315
  }
306
316
  },
307
317
  "typesVersions": {
@@ -403,7 +413,10 @@
403
413
  "lib/v2/providers/firestore"
404
414
  ],
405
415
  "dataconnect": [
406
- "lib/v2/providers/dataconnect"
416
+ "lib/v2/providers/dataconnect/index"
417
+ ],
418
+ "dataconnect/graphql": [
419
+ "lib/v2/providers/dataconnect/graphql"
407
420
  ],
408
421
  "v2": [
409
422
  "lib/v2/index"
@@ -466,7 +479,10 @@
466
479
  "lib/v2/providers/firestore"
467
480
  ],
468
481
  "v2/dataconnect": [
469
- "lib/v2/providers/dataconnect"
482
+ "lib/v2/providers/dataconnect/index"
483
+ ],
484
+ "v2/dataconnect/graphql": [
485
+ "lib/v2/providers/dataconnect/graphql"
470
486
  ],
471
487
  "*": [
472
488
  "lib/v2/index.d.ts"
@@ -559,6 +575,7 @@
559
575
  "peerDependencies": {
560
576
  "@apollo/server": "^5.2.0",
561
577
  "@as-integrations/express4": "^1.1.2",
578
+ "graphql": "^16.12.0",
562
579
  "firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0"
563
580
  },
564
581
  "peerDependenciesMeta": {
@@ -567,6 +584,9 @@
567
584
  },
568
585
  "@as-integrations/express4": {
569
586
  "optional": true
587
+ },
588
+ "graphql": {
589
+ "optional": true
570
590
  }
571
591
  },
572
592
  "engines": {