@mxpicture/gcp-functions-backend 2.1.34 → 2.1.35
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/dist/api/BackendBaseApi.d.ts +35 -13
- package/dist/api/BackendBaseApi.d.ts.map +1 -1
- package/dist/api/BackendBaseApi.js +36 -13
- package/dist/api/BackendBaseApi.js.map +1 -1
- package/dist/api/BackendCrudApi.d.ts +5 -5
- package/dist/api/BackendCrudApi.d.ts.map +1 -1
- package/dist/api/BackendCrudApi.js +6 -2
- package/dist/api/BackendCrudApi.js.map +1 -1
- package/dist/api/BackendDefaultApi.d.ts +17 -8
- package/dist/api/BackendDefaultApi.d.ts.map +1 -1
- package/dist/api/BackendDefaultApi.js +19 -6
- package/dist/api/BackendDefaultApi.js.map +1 -1
- package/dist/api/BackendStoreApi.d.ts +1 -1
- package/dist/api/BackendStoreApi.d.ts.map +1 -1
- package/dist/api/BackendStoreApi.js.map +1 -1
- package/dist/api/IBackendApi.d.ts +22 -0
- package/dist/api/IBackendApi.d.ts.map +1 -1
- package/dist/factory/IBackendFactory.d.ts +39 -1
- package/dist/factory/IBackendFactory.d.ts.map +1 -1
- package/dist/factory/IBackendFactory.js +35 -0
- package/dist/factory/IBackendFactory.js.map +1 -1
- package/dist/factory/IBackendStoreFactory.d.ts +37 -1
- package/dist/factory/IBackendStoreFactory.d.ts.map +1 -1
- package/dist/factory/IBackendStoreFactory.js +34 -0
- package/dist/factory/IBackendStoreFactory.js.map +1 -1
- package/dist/firebase/FirebaseTaskHandler.d.ts +13 -6
- package/dist/firebase/FirebaseTaskHandler.d.ts.map +1 -1
- package/dist/firebase/FirebaseTaskHandler.js +13 -6
- package/dist/firebase/FirebaseTaskHandler.js.map +1 -1
- package/dist/firebase/FirebaseTaskQueueHandler.d.ts +23 -20
- package/dist/firebase/FirebaseTaskQueueHandler.d.ts.map +1 -1
- package/dist/firebase/FirebaseTaskQueueHandler.js +23 -20
- package/dist/firebase/FirebaseTaskQueueHandler.js.map +1 -1
- package/dist/firebase/firebase.express.d.ts +16 -8
- package/dist/firebase/firebase.express.d.ts.map +1 -1
- package/dist/firebase/firebase.express.js +16 -8
- package/dist/firebase/firebase.express.js.map +1 -1
- package/dist/firebase/firebase.tasks.d.ts +31 -0
- package/dist/firebase/firebase.tasks.d.ts.map +1 -1
- package/dist/firebase/firebase.tasks.js +31 -0
- package/dist/firebase/firebase.tasks.js.map +1 -1
- package/dist/function/CompositeBackendFunction.d.ts +33 -2
- package/dist/function/CompositeBackendFunction.d.ts.map +1 -1
- package/dist/function/CompositeBackendFunction.js +31 -1
- package/dist/function/CompositeBackendFunction.js.map +1 -1
- package/dist/function/IBackendFunction.d.ts +48 -23
- package/dist/function/IBackendFunction.d.ts.map +1 -1
- package/dist/function/IBackendFunction.js +39 -22
- package/dist/function/IBackendFunction.js.map +1 -1
- package/dist/store/Store.d.ts +21 -2
- package/dist/store/Store.d.ts.map +1 -1
- package/dist/store/Store.js +22 -3
- package/dist/store/Store.js.map +1 -1
- package/dist/types/types.env.d.ts +2 -1
- package/dist/types/types.env.d.ts.map +1 -1
- package/dist/types/types.tasks.d.ts +30 -1
- package/dist/types/types.tasks.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -4,13 +4,49 @@ import type { Validation } from "../validation/Validation.js";
|
|
|
4
4
|
import type { BackendStoreApi } from "../api/BackendStoreApi.js";
|
|
5
5
|
import { IBackendFactory } from "./IBackendFactory.js";
|
|
6
6
|
import type { IBackendFunction } from "../function/IBackendFunction.js";
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Factory that extends {@link IBackendFactory} with a {@link Store} and an
|
|
9
|
+
* {@link IBackendFunction} wrapper, suitable for store-backed CRUD APIs.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Adds two lazily-constructed singletons:
|
|
13
|
+
*
|
|
14
|
+
* - {@link store} — the persistence layer used by the API.
|
|
15
|
+
* - {@link func} — the cloud-function wrapper that exposes the API as an HTTPS endpoint.
|
|
16
|
+
*
|
|
17
|
+
* `api()` is overridden so the store is injected into the API on first use.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam STORE_DOC - The shape stored in {@link Store}.
|
|
20
|
+
* @typeParam DTO - The shape returned to callers (extends `STORE_DOC`).
|
|
21
|
+
* @typeParam INPUT_DTO - The shape accepted on write operations.
|
|
22
|
+
* @typeParam API - The concrete store-backed API class produced by the factory.
|
|
23
|
+
* @typeParam FUNC - The function wrapper class produced by the factory.
|
|
24
|
+
* @typeParam SIDE_EFFECTS - Type of side-effect payloads supported by the API.
|
|
25
|
+
* @typeParam VAL - The validation implementation used by the API.
|
|
26
|
+
* @typeParam STORE - The store implementation used for persistence.
|
|
27
|
+
*/
|
|
28
|
+
export declare abstract class IBackendStoreFactory<STORE_DOC extends DocumentKeyAdmin, DTO extends STORE_DOC, INPUT_DTO extends DocumentData, API extends BackendStoreApi<STORE_DOC, DTO, INPUT_DTO, SIDE_EFFECTS, STORE, VAL>, FUNC extends IBackendFunction<STORE_DOC, DTO, INPUT_DTO, SIDE_EFFECTS, API>, SIDE_EFFECTS extends DocumentData = DocumentData, VAL extends Validation<INPUT_DTO> = Validation<INPUT_DTO>, STORE extends Store<STORE_DOC> = Store<STORE_DOC>> extends IBackendFactory<DTO, INPUT_DTO, API, SIDE_EFFECTS, VAL> {
|
|
8
29
|
protected _func: FUNC | null;
|
|
9
30
|
protected _store: STORE | null;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the API, ensuring a store has been injected.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* If the underlying API doesn't yet have a store, this method injects the
|
|
36
|
+
* factory-managed {@link store} into it.
|
|
37
|
+
*/
|
|
10
38
|
api(): API;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the function wrapper, constructing it on first call and caching afterwards.
|
|
41
|
+
*/
|
|
11
42
|
func(): FUNC;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the store, constructing it on first call and caching afterwards.
|
|
45
|
+
*/
|
|
12
46
|
store(): STORE;
|
|
47
|
+
/** Subclass hook: build a fresh function wrapper. Called at most once per factory. */
|
|
13
48
|
protected abstract _createFunc(): FUNC;
|
|
49
|
+
/** Subclass hook: build a fresh store instance. Called at most once per factory. */
|
|
14
50
|
protected abstract _createStore(): STORE;
|
|
15
51
|
}
|
|
16
52
|
//# sourceMappingURL=IBackendStoreFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IBackendStoreFactory.d.ts","sourceRoot":"","sources":["../../src/factory/IBackendStoreFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,8BAAsB,oBAAoB,CACxC,SAAS,SAAS,gBAAgB,EAClC,GAAG,SAAS,SAAS,EACrB,GAAG,SAAS,eAAe,
|
|
1
|
+
{"version":3,"file":"IBackendStoreFactory.d.ts","sourceRoot":"","sources":["../../src/factory/IBackendStoreFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BAAsB,oBAAoB,CACxC,SAAS,SAAS,gBAAgB,EAClC,GAAG,SAAS,SAAS,EACrB,SAAS,SAAS,YAAY,EAC9B,GAAG,SAAS,eAAe,CACzB,SAAS,EACT,GAAG,EACH,SAAS,EACT,YAAY,EACZ,KAAK,EACL,GAAG,CACJ,EACD,IAAI,SAAS,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC,EAC3E,YAAY,SAAS,YAAY,GAAG,YAAY,EAChD,GAAG,SAAS,UAAU,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,EACzD,KAAK,SAAS,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CACjD,SAAQ,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC;IAC/D,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAQ;IACpC,SAAS,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,CAAQ;IAEtC;;;;;;OAMG;IACa,GAAG,IAAI,GAAG;IAU1B;;OAEG;IACI,IAAI,IAAI,IAAI;IAInB;;OAEG;IACI,KAAK,IAAI,KAAK;IAIrB,sFAAsF;IACtF,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,IAAI;IACtC,oFAAoF;IACpF,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,KAAK;CACzC"}
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import { IBackendFactory } from "./IBackendFactory.js";
|
|
2
|
+
/**
|
|
3
|
+
* Factory that extends {@link IBackendFactory} with a {@link Store} and an
|
|
4
|
+
* {@link IBackendFunction} wrapper, suitable for store-backed CRUD APIs.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Adds two lazily-constructed singletons:
|
|
8
|
+
*
|
|
9
|
+
* - {@link store} — the persistence layer used by the API.
|
|
10
|
+
* - {@link func} — the cloud-function wrapper that exposes the API as an HTTPS endpoint.
|
|
11
|
+
*
|
|
12
|
+
* `api()` is overridden so the store is injected into the API on first use.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam STORE_DOC - The shape stored in {@link Store}.
|
|
15
|
+
* @typeParam DTO - The shape returned to callers (extends `STORE_DOC`).
|
|
16
|
+
* @typeParam INPUT_DTO - The shape accepted on write operations.
|
|
17
|
+
* @typeParam API - The concrete store-backed API class produced by the factory.
|
|
18
|
+
* @typeParam FUNC - The function wrapper class produced by the factory.
|
|
19
|
+
* @typeParam SIDE_EFFECTS - Type of side-effect payloads supported by the API.
|
|
20
|
+
* @typeParam VAL - The validation implementation used by the API.
|
|
21
|
+
* @typeParam STORE - The store implementation used for persistence.
|
|
22
|
+
*/
|
|
2
23
|
export class IBackendStoreFactory extends IBackendFactory {
|
|
3
24
|
_func = null;
|
|
4
25
|
_store = null;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the API, ensuring a store has been injected.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* If the underlying API doesn't yet have a store, this method injects the
|
|
31
|
+
* factory-managed {@link store} into it.
|
|
32
|
+
*/
|
|
5
33
|
api() {
|
|
6
34
|
const a = super.api();
|
|
7
35
|
try {
|
|
@@ -12,9 +40,15 @@ export class IBackendStoreFactory extends IBackendFactory {
|
|
|
12
40
|
}
|
|
13
41
|
return a;
|
|
14
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the function wrapper, constructing it on first call and caching afterwards.
|
|
45
|
+
*/
|
|
15
46
|
func() {
|
|
16
47
|
return (this._func ??= this._createFunc().useApi(this.api()));
|
|
17
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the store, constructing it on first call and caching afterwards.
|
|
51
|
+
*/
|
|
18
52
|
store() {
|
|
19
53
|
return (this._store ??= this._createStore());
|
|
20
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IBackendStoreFactory.js","sourceRoot":"","sources":["../../src/factory/IBackendStoreFactory.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,MAAM,OAAgB,
|
|
1
|
+
{"version":3,"file":"IBackendStoreFactory.js","sourceRoot":"","sources":["../../src/factory/IBackendStoreFactory.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAgB,oBAgBpB,SAAQ,eAAuD;IACrD,KAAK,GAAgB,IAAI,CAAC;IAC1B,MAAM,GAAiB,IAAI,CAAC;IAEtC;;;;;;OAMG;IACa,GAAG;QACjB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC;YACH,CAAC,CAAC,KAAK,EAAE,CAAC;QACZ,CAAC;QAAC,MAAM,CAAC;YACP,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAED;;OAEG;IACI,IAAI;QACT,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,KAAK;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC/C,CAAC;CAMF"}
|
|
@@ -19,20 +19,27 @@ export declare class FirebaseTaskHandler {
|
|
|
19
19
|
* @param env - Environment configuration containing `projectId`, `region`, and `serviceAccount`.
|
|
20
20
|
*/
|
|
21
21
|
constructor(env: FirebaseEnv);
|
|
22
|
+
/**
|
|
23
|
+
* Returns a cached {@link FirebaseTaskQueueHandler} for the given queue ID,
|
|
24
|
+
* constructing a new one on first access.
|
|
25
|
+
*
|
|
26
|
+
* @param queueId - The Cloud Tasks queue identifier.
|
|
27
|
+
* @returns A handler scoped to the named queue.
|
|
28
|
+
*/
|
|
22
29
|
queue(queueId: string): FirebaseTaskQueueHandler;
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
31
|
+
* Reschedules a task by deleting it (if present) and re-creating it.
|
|
25
32
|
*
|
|
26
|
-
* @param p - Task parameters including the
|
|
27
|
-
*
|
|
33
|
+
* @param p - Task parameters including the queue ID, target URL, schedule time,
|
|
34
|
+
* and optional `taskId` to delete before re-creating.
|
|
28
35
|
* @returns The created task's resource name.
|
|
29
36
|
*/
|
|
30
37
|
reschedule(p: FirebaseTaskParams): Promise<FirebaseTaskScheduleResult>;
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Schedules a new Cloud Task on the queue named by `p.queueId`.
|
|
33
40
|
*
|
|
34
|
-
* @param p - Task parameters:
|
|
35
|
-
*
|
|
41
|
+
* @param p - Task parameters: queue ID, target URL, schedule time, and
|
|
42
|
+
* optional payload / task ID.
|
|
36
43
|
* @returns The created task's resource name.
|
|
37
44
|
*/
|
|
38
45
|
schedule(p: FirebaseTaskParams): Promise<FirebaseTaskScheduleResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseTaskHandler.d.ts","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EACV,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAUX,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW;IATtD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAC3D;IAEZ;;;;OAIG;gBACmC,GAAG,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"FirebaseTaskHandler.d.ts","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EACV,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAUX,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW;IATtD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAC3D;IAEZ;;;;OAIG;gBACmC,GAAG,EAAE,WAAW;IAItD;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,wBAAwB;IASvD;;;;;;OAMG;IACU,UAAU,CACrB,CAAC,EAAE,kBAAkB,GACpB,OAAO,CAAC,0BAA0B,CAAC;IAItC;;;;;;OAMG;IACU,QAAQ,CACnB,CAAC,EAAE,kBAAkB,GACpB,OAAO,CAAC,0BAA0B,CAAC;CAGvC"}
|
|
@@ -20,6 +20,13 @@ export class FirebaseTaskHandler {
|
|
|
20
20
|
this.env = env;
|
|
21
21
|
this.tasksClient = new CloudTasksClient();
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns a cached {@link FirebaseTaskQueueHandler} for the given queue ID,
|
|
25
|
+
* constructing a new one on first access.
|
|
26
|
+
*
|
|
27
|
+
* @param queueId - The Cloud Tasks queue identifier.
|
|
28
|
+
* @returns A handler scoped to the named queue.
|
|
29
|
+
*/
|
|
23
30
|
queue(queueId) {
|
|
24
31
|
let found = this.queueHandlers.get(queueId);
|
|
25
32
|
if (!found) {
|
|
@@ -29,20 +36,20 @@ export class FirebaseTaskHandler {
|
|
|
29
36
|
return found;
|
|
30
37
|
}
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Reschedules a task by deleting it (if present) and re-creating it.
|
|
33
40
|
*
|
|
34
|
-
* @param p - Task parameters including the
|
|
35
|
-
*
|
|
41
|
+
* @param p - Task parameters including the queue ID, target URL, schedule time,
|
|
42
|
+
* and optional `taskId` to delete before re-creating.
|
|
36
43
|
* @returns The created task's resource name.
|
|
37
44
|
*/
|
|
38
45
|
async reschedule(p) {
|
|
39
46
|
return await this.queue(p.queueId).reschedule(p);
|
|
40
47
|
}
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
49
|
+
* Schedules a new Cloud Task on the queue named by `p.queueId`.
|
|
43
50
|
*
|
|
44
|
-
* @param p - Task parameters:
|
|
45
|
-
*
|
|
51
|
+
* @param p - Task parameters: queue ID, target URL, schedule time, and
|
|
52
|
+
* optional payload / task ID.
|
|
46
53
|
* @returns The created task's resource name.
|
|
47
54
|
*/
|
|
48
55
|
async schedule(p) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseTaskHandler.js","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAMvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAUQ;IATnB,WAAW,CAAmB;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B,CAAqB;QAErB,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -2,74 +2,77 @@ import type { CloudTasksClient } from "@google-cloud/tasks";
|
|
|
2
2
|
import type { FirebaseTask, FirebaseTaskQueueParams, FirebaseTaskScheduleResult } from "../types/types.tasks.js";
|
|
3
3
|
import type { FirebaseEnv } from "../types/types.env.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Per-queue wrapper around Google Cloud Tasks.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Manages tasks within a single queue. Task payloads are sent as base64-encoded
|
|
9
|
+
* JSON via `POST` with OIDC authentication. Build via {@link FirebaseTaskHandler.queue}
|
|
10
|
+
* rather than calling the constructor directly.
|
|
10
11
|
*/
|
|
11
12
|
export declare class FirebaseTaskQueueHandler {
|
|
12
13
|
readonly queueId: string;
|
|
13
14
|
protected readonly tasksClient: CloudTasksClient;
|
|
14
15
|
protected readonly env: FirebaseEnv;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new queue-scoped task handler.
|
|
18
|
+
*
|
|
19
|
+
* @param queueId - The Cloud Tasks queue identifier this handler is bound to.
|
|
20
|
+
* @param tasksClient - The underlying {@link CloudTasksClient}.
|
|
21
|
+
* @param env - GCP environment (project, region, service account).
|
|
22
|
+
*/
|
|
15
23
|
constructor(queueId: string, tasksClient: CloudTasksClient, env: FirebaseEnv);
|
|
16
24
|
/**
|
|
17
|
-
*
|
|
25
|
+
* Reschedules a task by deleting any existing task with the same `taskId`,
|
|
26
|
+
* then re-creating it via {@link schedule}.
|
|
18
27
|
*
|
|
19
|
-
* @param p - Task parameters
|
|
20
|
-
* @param scheduleTime - The new schedule timestamp.
|
|
28
|
+
* @param p - Task parameters; `taskId` selects the existing task to delete.
|
|
21
29
|
* @returns The created task's resource name.
|
|
22
30
|
*/
|
|
23
31
|
reschedule(p: FirebaseTaskQueueParams): Promise<FirebaseTaskScheduleResult>;
|
|
24
32
|
/**
|
|
25
|
-
*
|
|
33
|
+
* Creates a new Cloud Task on this queue.
|
|
26
34
|
*
|
|
27
|
-
* @param p - Task parameters: target URL,
|
|
28
|
-
*
|
|
35
|
+
* @param p - Task parameters: target URL, schedule time, and optional
|
|
36
|
+
* payload / task ID. A random task ID is generated when omitted.
|
|
29
37
|
* @returns The created task's resource name.
|
|
30
38
|
*/
|
|
31
39
|
schedule(p: FirebaseTaskQueueParams): Promise<FirebaseTaskScheduleResult>;
|
|
32
40
|
/**
|
|
33
|
-
*
|
|
41
|
+
* Lists all tasks currently scheduled on this queue.
|
|
34
42
|
*
|
|
35
43
|
* @returns An array of tasks with parsed `nameParts`.
|
|
36
44
|
*/
|
|
37
45
|
getTasks(): Promise<FirebaseTask[]>;
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* Retrieves a single task on this queue by ID.
|
|
40
48
|
*
|
|
41
49
|
* @param taskId - The task identifier.
|
|
42
50
|
* @returns The task with parsed `nameParts`.
|
|
43
51
|
*/
|
|
44
52
|
getTask(taskId: string): Promise<FirebaseTask>;
|
|
45
53
|
/**
|
|
46
|
-
*
|
|
54
|
+
* Deletes a task on this queue by ID.
|
|
47
55
|
*
|
|
48
|
-
* @param queueId - The queue identifier.
|
|
49
56
|
* @param taskId - The task identifier.
|
|
50
|
-
* @returns The task with parsed `nameParts`.
|
|
51
57
|
*/
|
|
52
58
|
deleteTask(taskId: string): Promise<void>;
|
|
53
59
|
/**
|
|
54
|
-
*
|
|
60
|
+
* Checks whether a task is currently scheduled on this queue.
|
|
55
61
|
*
|
|
56
|
-
* @param queueId - The queue identifier.
|
|
57
62
|
* @param taskId - The task identifier.
|
|
58
63
|
* @returns `true` if the task exists, `false` otherwise.
|
|
59
64
|
*/
|
|
60
65
|
isScheduled(taskId: string): Promise<boolean>;
|
|
61
66
|
/**
|
|
62
|
-
*
|
|
67
|
+
* Builds the fully-qualified Cloud Tasks task resource path for this queue.
|
|
63
68
|
*
|
|
64
|
-
* @param queueId - The queue identifier.
|
|
65
69
|
* @param taskId - The task identifier.
|
|
66
70
|
* @returns The resource path string.
|
|
67
71
|
*/
|
|
68
72
|
taskPath(taskId: string): string;
|
|
69
73
|
/**
|
|
70
|
-
*
|
|
74
|
+
* Builds the fully-qualified Cloud Tasks queue resource path for this queue.
|
|
71
75
|
*
|
|
72
|
-
* @param queueId - The queue identifier.
|
|
73
76
|
* @returns The resource path string.
|
|
74
77
|
*/
|
|
75
78
|
queuePath(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseTaskQueueHandler.d.ts","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskQueueHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzD
|
|
1
|
+
{"version":3,"file":"FirebaseTaskQueueHandler.d.ts","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskQueueHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;;;;;GAOG;AACH,qBAAa,wBAAwB;aASjB,OAAO,EAAE,MAAM;IAC/B,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,gBAAgB;IAChD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW;IAVrC;;;;;;OAMG;gBAEe,OAAO,EAAE,MAAM,EACZ,WAAW,EAAE,gBAAgB,EAC7B,GAAG,EAAE,WAAW;IAGrC;;;;;;OAMG;IACU,UAAU,CACrB,CAAC,EAAE,uBAAuB,GACzB,OAAO,CAAC,0BAA0B,CAAC;IAgBtC;;;;;;OAMG;IACU,QAAQ,CACnB,CAAC,EAAE,uBAAuB,GACzB,OAAO,CAAC,0BAA0B,CAAC;IAiCtC;;;;OAIG;IACU,QAAQ,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAOhD;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAS3D;;;;OAIG;IACU,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD;;;;;OAKG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1D;;;;;OAKG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IASvC;;;;OAIG;IACI,SAAS,IAAI,MAAM;IAQ1B,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY;CAOhE"}
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import * as uuid from "short-uuid";
|
|
2
2
|
import { fromTaskName } from "./firebase.tasks.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Per-queue wrapper around Google Cloud Tasks.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Manages tasks within a single queue. Task payloads are sent as base64-encoded
|
|
8
|
+
* JSON via `POST` with OIDC authentication. Build via {@link FirebaseTaskHandler.queue}
|
|
9
|
+
* rather than calling the constructor directly.
|
|
9
10
|
*/
|
|
10
11
|
export class FirebaseTaskQueueHandler {
|
|
11
12
|
queueId;
|
|
12
13
|
tasksClient;
|
|
13
14
|
env;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new queue-scoped task handler.
|
|
17
|
+
*
|
|
18
|
+
* @param queueId - The Cloud Tasks queue identifier this handler is bound to.
|
|
19
|
+
* @param tasksClient - The underlying {@link CloudTasksClient}.
|
|
20
|
+
* @param env - GCP environment (project, region, service account).
|
|
21
|
+
*/
|
|
14
22
|
constructor(queueId, tasksClient, env) {
|
|
15
23
|
this.queueId = queueId;
|
|
16
24
|
this.tasksClient = tasksClient;
|
|
17
25
|
this.env = env;
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
|
-
*
|
|
28
|
+
* Reschedules a task by deleting any existing task with the same `taskId`,
|
|
29
|
+
* then re-creating it via {@link schedule}.
|
|
21
30
|
*
|
|
22
|
-
* @param p - Task parameters
|
|
23
|
-
* @param scheduleTime - The new schedule timestamp.
|
|
31
|
+
* @param p - Task parameters; `taskId` selects the existing task to delete.
|
|
24
32
|
* @returns The created task's resource name.
|
|
25
33
|
*/
|
|
26
34
|
async reschedule(p) {
|
|
@@ -39,10 +47,10 @@ export class FirebaseTaskQueueHandler {
|
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
|
-
*
|
|
50
|
+
* Creates a new Cloud Task on this queue.
|
|
43
51
|
*
|
|
44
|
-
* @param p - Task parameters: target URL,
|
|
45
|
-
*
|
|
52
|
+
* @param p - Task parameters: target URL, schedule time, and optional
|
|
53
|
+
* payload / task ID. A random task ID is generated when omitted.
|
|
46
54
|
* @returns The created task's resource name.
|
|
47
55
|
*/
|
|
48
56
|
async schedule(p) {
|
|
@@ -75,7 +83,7 @@ export class FirebaseTaskQueueHandler {
|
|
|
75
83
|
return { name: task.name ?? null };
|
|
76
84
|
}
|
|
77
85
|
/**
|
|
78
|
-
*
|
|
86
|
+
* Lists all tasks currently scheduled on this queue.
|
|
79
87
|
*
|
|
80
88
|
* @returns An array of tasks with parsed `nameParts`.
|
|
81
89
|
*/
|
|
@@ -84,7 +92,7 @@ export class FirebaseTaskQueueHandler {
|
|
|
84
92
|
return tasks.map((task) => this.mapTaskFromFirebase(task));
|
|
85
93
|
}
|
|
86
94
|
/**
|
|
87
|
-
*
|
|
95
|
+
* Retrieves a single task on this queue by ID.
|
|
88
96
|
*
|
|
89
97
|
* @param taskId - The task identifier.
|
|
90
98
|
* @returns The task with parsed `nameParts`.
|
|
@@ -96,20 +104,17 @@ export class FirebaseTaskQueueHandler {
|
|
|
96
104
|
return this.mapTaskFromFirebase(task);
|
|
97
105
|
}
|
|
98
106
|
/**
|
|
99
|
-
*
|
|
107
|
+
* Deletes a task on this queue by ID.
|
|
100
108
|
*
|
|
101
|
-
* @param queueId - The queue identifier.
|
|
102
109
|
* @param taskId - The task identifier.
|
|
103
|
-
* @returns The task with parsed `nameParts`.
|
|
104
110
|
*/
|
|
105
111
|
async deleteTask(taskId) {
|
|
106
112
|
const name = this.taskPath(taskId);
|
|
107
113
|
await this.tasksClient.deleteTask({ name });
|
|
108
114
|
}
|
|
109
115
|
/**
|
|
110
|
-
*
|
|
116
|
+
* Checks whether a task is currently scheduled on this queue.
|
|
111
117
|
*
|
|
112
|
-
* @param queueId - The queue identifier.
|
|
113
118
|
* @param taskId - The task identifier.
|
|
114
119
|
* @returns `true` if the task exists, `false` otherwise.
|
|
115
120
|
*/
|
|
@@ -123,9 +128,8 @@ export class FirebaseTaskQueueHandler {
|
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
130
|
/**
|
|
126
|
-
*
|
|
131
|
+
* Builds the fully-qualified Cloud Tasks task resource path for this queue.
|
|
127
132
|
*
|
|
128
|
-
* @param queueId - The queue identifier.
|
|
129
133
|
* @param taskId - The task identifier.
|
|
130
134
|
* @returns The resource path string.
|
|
131
135
|
*/
|
|
@@ -133,9 +137,8 @@ export class FirebaseTaskQueueHandler {
|
|
|
133
137
|
return this.tasksClient.taskPath(this.env.projectId, this.env.region, this.queueId, taskId);
|
|
134
138
|
}
|
|
135
139
|
/**
|
|
136
|
-
*
|
|
140
|
+
* Builds the fully-qualified Cloud Tasks queue resource path for this queue.
|
|
137
141
|
*
|
|
138
|
-
* @param queueId - The queue identifier.
|
|
139
142
|
* @returns The resource path string.
|
|
140
143
|
*/
|
|
141
144
|
queuePath() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseTaskQueueHandler.js","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskQueueHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"FirebaseTaskQueueHandler.js","sourceRoot":"","sources":["../../src/firebase/FirebaseTaskQueueHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,OAAO,wBAAwB;IASjB;IACG;IACA;IAVrB;;;;;;OAMG;IACH,YACkB,OAAe,EACZ,WAA6B,EAC7B,GAAgB;QAFnB,YAAO,GAAP,OAAO,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAkB;QAC7B,QAAG,GAAH,GAAG,CAAa;IAClC,CAAC;IAEJ;;;;;;OAMG;IACI,KAAK,CAAC,UAAU,CACrB,CAA0B;QAE1B,IAAI,CAAC;YACH,IAAI,CAAC,CAAC,MAAM;gBACV,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;oBAChC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;iBAC9B,CAAC,CAAC;QACP,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC;YACzB,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,OAAO,EAAE,CAAC,CAAC,SAAS;YACpB,YAAY,EAAE,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QACd,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAC/B,IAAI,CAAC,GAAG,CAAC,SAAS,EAClB,IAAI,CAAC,GAAG,CAAC,MAAM,EACf,IAAI,CAAC,OAAO,CACb,CAAC;IACJ,CAAC;IAES,mBAAmB,CAAC,IAAkB;QAC9C,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,OAAO,MAAM,CAAC;QAChC,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,KAAK;YAAE,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -28,17 +28,25 @@ declare global {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare const checkFirebaseAuth: ExpressAuthHandler;
|
|
30
30
|
/**
|
|
31
|
-
* Express middleware that verifies Google OIDC bearer tokens for
|
|
31
|
+
* Builds an Express middleware that verifies Google OIDC bearer tokens for
|
|
32
|
+
* service-to-service authentication.
|
|
32
33
|
*
|
|
33
34
|
* @remarks
|
|
34
|
-
*
|
|
35
|
-
* The token audience is read from the `INTERNAL_FUNCTION_URL` environment variable.
|
|
36
|
-
* An optional `ALLOWED_CALLER_SA_EMAIL` environment variable can restrict access to
|
|
37
|
-
* a single service account.
|
|
35
|
+
* The returned middleware:
|
|
38
36
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
37
|
+
* - Allows only `POST`; other methods receive a `405` response.
|
|
38
|
+
* - Reads the expected audience from `audience` or, when omitted, the
|
|
39
|
+
* `INTERNAL_FUNCTION_URL` environment variable.
|
|
40
|
+
* - When `routes` is provided, the audience is augmented per-request with the
|
|
41
|
+
* matching `/<route>` suffix so multi-route functions verify against the
|
|
42
|
+
* exact URL Cloud Scheduler / Cloud Tasks used.
|
|
43
|
+
* - When `ALLOWED_CALLER_SA_EMAIL` is set, only that service account is
|
|
44
|
+
* accepted as the calling identity.
|
|
45
|
+
*
|
|
46
|
+
* @param audience - Override for the expected OIDC audience.
|
|
47
|
+
* @param routes - Optional list of valid route names used to refine the audience per request.
|
|
48
|
+
* @returns An Express middleware that populates `req.auth` on success and
|
|
49
|
+
* responds with `401` / `403` / `405` on failure.
|
|
42
50
|
*/
|
|
43
51
|
export declare const buildCheckServiceAuth: (audience?: string | null, routes?: string[] | null) => ExpressAuthHandler;
|
|
44
52
|
//# sourceMappingURL=firebase.express.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.express.d.ts","sourceRoot":"","sources":["../../src/firebase/firebase.express.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE;gBACL,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,OAAO,CAAC,EAAE,OAAO,CAAC;gBAClB,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,cAAc,CAAC;aACxB,CAAC;SACH;KACF;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAgB/B,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"firebase.express.d.ts","sourceRoot":"","sources":["../../src/firebase/firebase.express.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE;gBACL,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,OAAO,CAAC,EAAE,OAAO,CAAC;gBAClB,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,cAAc,CAAC;aACxB,CAAC;SACH;KACF;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAgB/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,qBAAqB,GAChC,WAAW,MAAM,GAAG,IAAI,EACxB,SAAS,MAAM,EAAE,GAAG,IAAI,KACvB,kBA0DF,CAAC"}
|
|
@@ -29,17 +29,25 @@ export const checkFirebaseAuth = async (req, _res, next) => {
|
|
|
29
29
|
next();
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
|
-
* Express middleware that verifies Google OIDC bearer tokens for
|
|
32
|
+
* Builds an Express middleware that verifies Google OIDC bearer tokens for
|
|
33
|
+
* service-to-service authentication.
|
|
33
34
|
*
|
|
34
35
|
* @remarks
|
|
35
|
-
*
|
|
36
|
-
* The token audience is read from the `INTERNAL_FUNCTION_URL` environment variable.
|
|
37
|
-
* An optional `ALLOWED_CALLER_SA_EMAIL` environment variable can restrict access to
|
|
38
|
-
* a single service account.
|
|
36
|
+
* The returned middleware:
|
|
39
37
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
38
|
+
* - Allows only `POST`; other methods receive a `405` response.
|
|
39
|
+
* - Reads the expected audience from `audience` or, when omitted, the
|
|
40
|
+
* `INTERNAL_FUNCTION_URL` environment variable.
|
|
41
|
+
* - When `routes` is provided, the audience is augmented per-request with the
|
|
42
|
+
* matching `/<route>` suffix so multi-route functions verify against the
|
|
43
|
+
* exact URL Cloud Scheduler / Cloud Tasks used.
|
|
44
|
+
* - When `ALLOWED_CALLER_SA_EMAIL` is set, only that service account is
|
|
45
|
+
* accepted as the calling identity.
|
|
46
|
+
*
|
|
47
|
+
* @param audience - Override for the expected OIDC audience.
|
|
48
|
+
* @param routes - Optional list of valid route names used to refine the audience per request.
|
|
49
|
+
* @returns An Express middleware that populates `req.auth` on success and
|
|
50
|
+
* responds with `401` / `403` / `405` on failure.
|
|
43
51
|
*/
|
|
44
52
|
export const buildCheckServiceAuth = (audience, routes) => {
|
|
45
53
|
const aud = audience?.substring(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.express.js","sourceRoot":"","sources":["../../src/firebase/firebase.express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AAiBnE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAuB,KAAK,EACxD,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,EAAE;IACF,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACrD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QACxE,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC;AACT,CAAC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"firebase.express.js","sourceRoot":"","sources":["../../src/firebase/firebase.express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAuB,MAAM,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C;gBAC7C,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACvD,CAAC;YAED,wEAAwE;YACxE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;YAC1D,IAAI,aAAa,IAAI,OAAO,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;gBACrD,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;gBAC1D,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACpE,CAAC;YAED,GAAG,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;YACnD,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAAC;YAClD,MAAM,OAAO,GACX,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACzE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,iBAAiB,OAAO,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import type { FirebaseQueueFqName, FirebaseTaskDurationParams, FirebaseTaskFqName, FirebaseTaskName, FirebaseTaskTimestamp } from "../types/types.tasks.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pattern matching a fully-qualified Cloud Tasks task resource path.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Capture groups (in order): project ID, region, queue ID, task ID.
|
|
7
|
+
* Used by {@link fromTaskPath}.
|
|
8
|
+
*/
|
|
2
9
|
export declare const taskPathRegex: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* Pattern matching a fully-qualified Cloud Tasks queue resource path.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Capture groups (in order): project ID, region, queue ID. Used by {@link fromQueuePath}.
|
|
15
|
+
*/
|
|
3
16
|
export declare const queuePathRegex: RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* Pattern matching the short `<queueId>-<taskId>` form used as a friendly task name.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Used by {@link fromTaskName} and {@link toTaskName}.
|
|
22
|
+
*/
|
|
4
23
|
export declare const taskNameRegex: RegExp;
|
|
5
24
|
/**
|
|
6
25
|
* Compute a Cloud Tasks schedule timestamp from a duration specification or an absolute `Date`.
|
|
@@ -30,6 +49,18 @@ export declare const fromTaskPath: (path: string) => FirebaseTaskFqName | null;
|
|
|
30
49
|
* @returns The parsed parts, or `null` if the path does not match the expected format.
|
|
31
50
|
*/
|
|
32
51
|
export declare const fromQueuePath: (path: string) => FirebaseQueueFqName | null;
|
|
52
|
+
/**
|
|
53
|
+
* Parses a short `<queueId>-<taskId>` task name into its parts.
|
|
54
|
+
*
|
|
55
|
+
* @param name - The short task name to parse.
|
|
56
|
+
* @returns The parsed parts, or `null` if `name` does not match {@link taskNameRegex}.
|
|
57
|
+
*/
|
|
33
58
|
export declare const fromTaskName: (name: string) => FirebaseTaskName | null;
|
|
59
|
+
/**
|
|
60
|
+
* Formats a {@link FirebaseTaskName} back into its short `<queueId>-<taskId>` string form.
|
|
61
|
+
*
|
|
62
|
+
* @param name - The task name parts.
|
|
63
|
+
* @returns The joined `<queueId>-<taskId>` string.
|
|
64
|
+
*/
|
|
34
65
|
export declare const toTaskName: (name: FirebaseTaskName) => string;
|
|
35
66
|
//# sourceMappingURL=firebase.tasks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.tasks.d.ts","sourceRoot":"","sources":["../../src/firebase/firebase.tasks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,aAAa,QACsF,CAAC;AAEjH,eAAO,MAAM,cAAc,QAC4D,CAAC;AAExF,eAAO,MAAM,aAAa,QAAsC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAChC,eAAe,0BAA0B,GAAG,IAAI,KAC/C,qBAuBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,kBAAkB,GAAG,IAShE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,mBAAmB,GAAG,IAQlE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,gBAAgB,GAAG,IAO9D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,gBAAgB,KAAG,MAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"firebase.tasks.d.ts","sourceRoot":"","sources":["../../src/firebase/firebase.tasks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,QACsF,CAAC;AAEjH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAC4D,CAAC;AAExF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAsC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAChC,eAAe,0BAA0B,GAAG,IAAI,KAC/C,qBAuBF,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