Skip to content

Commit 8ec6d63

Browse files
authored
feat: wrap method now accepts resource as override in Context object. (#61)
1 parent fe15850 commit 8ec6d63

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ export type EventContextOptions = {
4242
* Default is 'UNAUTHENTICATED'.
4343
*/
4444
authType?: 'ADMIN' | 'USER' | 'UNAUTHENTICATED';
45+
46+
/** Resource is a standard format for defining a resource (google.rpc.context.AttributeContext.Resource).
47+
* In Cloud Functions, it is the resource that triggered the function - such as a storage bucket.
48+
*/
49+
resource?: {
50+
service: string;
51+
name: string;
52+
type?: string;
53+
labels?: {
54+
[tag: string]: string;
55+
};
56+
};
4557
};
4658

4759
/** Fields of the callable context that can be overridden/customized. */
@@ -138,7 +150,7 @@ export function wrap<T>(
138150
};
139151
} else {
140152
_checkOptionValidity(
141-
['eventId', 'timestamp', 'params', 'auth', 'authType'],
153+
['eventId', 'timestamp', 'params', 'auth', 'authType', 'resource'],
142154
options
143155
);
144156
const defaultContext = _makeDefaultContext(cloudFunction, options);

0 commit comments

Comments
 (0)