@dereekb/firebase-server 12.5.8 → 12.5.9
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/CHANGELOG.md +4 -0
- package/mailgun/package.json +1 -1
- package/model/package.json +1 -1
- package/model/src/lib/notification/index.d.ts +1 -0
- package/model/src/lib/notification/index.js +1 -0
- package/model/src/lib/notification/index.js.map +1 -1
- package/model/src/lib/notification/notification.task.subtask.handler.d.ts +215 -0
- package/model/src/lib/notification/notification.task.subtask.handler.js +256 -0
- package/model/src/lib/notification/notification.task.subtask.handler.js.map +1 -0
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +16 -89
- package/model/src/lib/storagefile/storagefile.task.service.handler.js +73 -264
- package/model/src/lib/storagefile/storagefile.task.service.handler.js.map +1 -1
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.js +4 -0
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.js.map +1 -1
- package/package.json +1 -1
- package/test/package.json +1 -1
- package/zoho/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.5.9](https://github.com/dereekb/dbx-components/compare/v12.5.8-dev...v12.5.9) (2025-11-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [12.5.8](https://github.com/dereekb/dbx-components/compare/v12.5.7-dev...v12.5.8) (2025-11-06)
|
|
6
10
|
|
|
7
11
|
|
package/mailgun/package.json
CHANGED
package/model/package.json
CHANGED
|
@@ -9,6 +9,7 @@ export * from './notification.send.service';
|
|
|
9
9
|
export * from './notification.send';
|
|
10
10
|
export * from './notification.task.service';
|
|
11
11
|
export * from './notification.task.service.handler';
|
|
12
|
+
export * from './notification.task.subtask.handler';
|
|
12
13
|
export * from './notification.error';
|
|
13
14
|
export * from './notification.expedite.service';
|
|
14
15
|
export * from './notification.util';
|
|
@@ -12,6 +12,7 @@ tslib_1.__exportStar(require("./notification.send.service"), exports);
|
|
|
12
12
|
tslib_1.__exportStar(require("./notification.send"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./notification.task.service"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./notification.task.service.handler"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./notification.task.subtask.handler"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./notification.error"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./notification.expedite.service"), exports);
|
|
17
18
|
tslib_1.__exportStar(require("./notification.util"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/notification/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C;AAC7C,4EAAkD;AAClD,wEAA8C;AAC9C,gEAAsC;AACtC,gEAAsC;AACtC,0FAAgE;AAChE,2EAAiD;AACjD,sEAA4C;AAC5C,8DAAoC;AACpC,sEAA4C;AAC5C,8EAAoD;AACpD,+DAAqC;AACrC,0EAAgD;AAChD,8DAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/notification/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C;AAC7C,4EAAkD;AAClD,wEAA8C;AAC9C,gEAAsC;AACtC,gEAAsC;AACtC,0FAAgE;AAChE,2EAAiD;AACjD,sEAA4C;AAC5C,8DAAoC;AACpC,sEAA4C;AAC5C,8EAAoD;AACpD,8EAAoD;AACpD,+DAAqC;AACrC,0EAAgD;AAChD,8DAAoC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { type NotificationTaskSubtaskTarget, type NotificationTask, type NotificationTaskServiceHandleNotificationTaskResult, type NotificationTaskSubtaskMetadata, type NotificationTaskSubtaskCheckpointString, type NotificationTaskSubtaskData, type NotificationTaskSubtaskCheckpoint, type NotificationTaskType } from '@dereekb/firebase';
|
|
2
|
+
import { type NotificationTaskServiceTaskHandlerConfig } from '../notification/notification.task.service.handler';
|
|
3
|
+
import { type Maybe, type MaybeSo, type Milliseconds, type PromiseOrValue } from '@dereekb/util';
|
|
4
|
+
import { BaseError } from 'make-error';
|
|
5
|
+
/**
|
|
6
|
+
* A NotificationTask with a set data value.
|
|
7
|
+
*/
|
|
8
|
+
export type NotificationTaskSubtaskInputTask<D extends NotificationTaskSubtaskData> = Omit<NotificationTask<D>, 'data'> & {
|
|
9
|
+
readonly data: MaybeSo<NotificationTask<D>['data']>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Input for a generic NotificationTaskSubtask
|
|
13
|
+
*/
|
|
14
|
+
export interface NotificationTaskSubtaskInput<D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> {
|
|
15
|
+
/**
|
|
16
|
+
* The retrieved target.
|
|
17
|
+
*/
|
|
18
|
+
readonly target: NotificationTaskSubtaskTarget;
|
|
19
|
+
/**
|
|
20
|
+
* The root NotificationTask.
|
|
21
|
+
*
|
|
22
|
+
* The data is always guranteed.
|
|
23
|
+
*/
|
|
24
|
+
readonly notificationTask: NotificationTaskSubtaskInputTask<D>;
|
|
25
|
+
/**
|
|
26
|
+
* List of completed subtasks.
|
|
27
|
+
*/
|
|
28
|
+
readonly completedSubtasks: S[];
|
|
29
|
+
/**
|
|
30
|
+
* The current metadata for the subtask.
|
|
31
|
+
*/
|
|
32
|
+
readonly subtaskData?: Maybe<M>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Result of a NotificationTaskSubtask.
|
|
36
|
+
*/
|
|
37
|
+
export type NotificationTaskSubtaskResult<M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = NotificationTaskServiceHandleNotificationTaskResult<M, S>;
|
|
38
|
+
/**
|
|
39
|
+
* A NotificationTaskSubtask is a function that handles a specific NotificationTaskSubtaskTarget subtask.
|
|
40
|
+
*/
|
|
41
|
+
export type NotificationTaskSubtask<I extends NotificationTaskSubtaskInput<D, M, S>, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = (input: I) => Promise<NotificationTaskSubtaskResult<M, S>>;
|
|
42
|
+
/**
|
|
43
|
+
* Similar to NotificationTaskServiceTaskHandlerFlowEntry, but used in NotificationTaskSubtaskProcessorConfig as part of the flow.
|
|
44
|
+
*/
|
|
45
|
+
export interface NotificationTaskSubtaskFlowEntry<I extends NotificationTaskSubtaskInput<D, M, S>, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> {
|
|
46
|
+
/**
|
|
47
|
+
* The subtask this flow entry represents.
|
|
48
|
+
*/
|
|
49
|
+
readonly subtask: S;
|
|
50
|
+
/**
|
|
51
|
+
* The subtask function
|
|
52
|
+
*/
|
|
53
|
+
readonly fn: NotificationTaskSubtask<I, D, M, S>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The base output cleanup configuration.
|
|
57
|
+
*/
|
|
58
|
+
export interface NotificationTaskSubtaskCleanupInstructions {
|
|
59
|
+
/**
|
|
60
|
+
* Whether or not the cleanup was successful. If false, the task will be delayed until the cleanup can be retried.
|
|
61
|
+
*
|
|
62
|
+
* Defaults to true.
|
|
63
|
+
*/
|
|
64
|
+
readonly cleanupSuccess?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* How long to delay the retry of the cleanup after cleanup fails.
|
|
67
|
+
*
|
|
68
|
+
* Ignored if cleanupSuccess is not false.
|
|
69
|
+
*/
|
|
70
|
+
readonly delayRetryUntil?: NotificationTaskServiceHandleNotificationTaskResult['delayUntil'];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Cleanup function for a NotificationTaskSubtask.
|
|
74
|
+
*
|
|
75
|
+
* This is called during the cleanup step.
|
|
76
|
+
*/
|
|
77
|
+
export type NotificationTaskSubtaskCleanupInstructionsFunction<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = (input: NotificationTaskSubtaskCleanupFunctionInput<I, D, M, S>) => CUI;
|
|
78
|
+
/**
|
|
79
|
+
* The actual cleanup function to execute using the input and instructions.
|
|
80
|
+
*/
|
|
81
|
+
export type NotificationTaskSubtaskCleanupFunction<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = (input: NotificationTaskSubtaskCleanupFunctionInput<I, D, M, S>, cleanupInstructions: CUI) => Promise<NotificationTaskServiceHandleNotificationTaskResult<D, NotificationTaskSubtaskCheckpoint>>;
|
|
82
|
+
/**
|
|
83
|
+
* The input function result may not include a target, and the notificationTask, completedSubtasks, and subtaskData properties are ignored.
|
|
84
|
+
*/
|
|
85
|
+
export type NotificationTaskSubtaskCleanupFunctionInput<I extends NotificationTaskSubtaskInput<D, M, S>, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = Omit<I, 'target' | 'completedSubtasks' | 'subtaskData'> & Partial<Pick<I, 'target'>>;
|
|
86
|
+
/**
|
|
87
|
+
* Similar to NotificationTaskServiceTaskHandlerConfig, but instead targets a specific NotificationTaskSubtaskTarget.
|
|
88
|
+
*
|
|
89
|
+
* The flows behave the same way.
|
|
90
|
+
*/
|
|
91
|
+
export interface NotificationTaskSubtaskProcessorConfig<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> {
|
|
92
|
+
/**
|
|
93
|
+
* The target this configuration is for.
|
|
94
|
+
*/
|
|
95
|
+
readonly target: NotificationTaskSubtaskTarget;
|
|
96
|
+
/**
|
|
97
|
+
* The order/flow of checkpoints and handler functions.
|
|
98
|
+
*
|
|
99
|
+
* When handling a notification task, if the checkpoint has already been completed then the entry will be skipped.
|
|
100
|
+
*/
|
|
101
|
+
readonly flow: NotificationTaskSubtaskFlowEntry<I, D, M, S>[];
|
|
102
|
+
/**
|
|
103
|
+
* Optional cleanup function for the subtask.
|
|
104
|
+
*
|
|
105
|
+
* If not provided, the default cleanup actions will take place.
|
|
106
|
+
*/
|
|
107
|
+
readonly cleanup?: NotificationTaskSubtaskCleanupInstructionsFunction<I, CUI, D, M, S>;
|
|
108
|
+
/**
|
|
109
|
+
* If true, then results returned by this processor will set "canRunNextCheckpoint" to true if it is undefined.
|
|
110
|
+
*/
|
|
111
|
+
readonly allowRunMultipleParts?: Maybe<boolean>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Generates input for a NotificationTaskSubtaskNotificationTaskHandler from the provided NotificationTask.
|
|
115
|
+
*
|
|
116
|
+
* Should throw an NotificationTaskSubTaskMissingRequiredDataTermination error if the NotificationTask is missing required data.
|
|
117
|
+
*/
|
|
118
|
+
export type NotificationTaskSubtaskNotificationTaskHandlerInputFunction<I extends NotificationTaskSubtaskInput<D, M, S>, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = (data: D, notificationTask: NotificationTask<D>) => PromiseOrValue<NotificationTaskSubtaskNotificationTaskHandlerInputFunctionResult<I, D, M, S>>;
|
|
119
|
+
/**
|
|
120
|
+
* The input function result may not include a target, and the notificationTask, completedSubtasks, and subtaskData properties are ignored.
|
|
121
|
+
*/
|
|
122
|
+
export type NotificationTaskSubtaskNotificationTaskHandlerInputFunctionResult<I extends NotificationTaskSubtaskInput<D, M, S>, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = Omit<I, 'target' | 'notificationTask' | 'completedSubtasks' | 'subtaskData'> & Partial<Pick<I, 'target'>>;
|
|
123
|
+
/**
|
|
124
|
+
* Function that builds the update metadata for a NotificationTaskSubtask.
|
|
125
|
+
*
|
|
126
|
+
* Updates to sfps and sd are ignored, as those should be managed by the processors/flow entries.
|
|
127
|
+
*/
|
|
128
|
+
export type NotificationTaskSubtaskNotificationTaskHandlerBuildUpdateMetadataFunction<I extends NotificationTaskSubtaskInput<D, M, S>, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = (baseUpdateMetadata: D, input: I) => PromiseOrValue<Omit<D, 'sfps' | 'sd'>>;
|
|
129
|
+
/**
|
|
130
|
+
* Configuration for notificationTaskSubtaskNotificationTaskHandler().
|
|
131
|
+
*/
|
|
132
|
+
export interface NotificationTaskSubtaskNotificationTaskHandlerFactoryConfig<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> {
|
|
133
|
+
/**
|
|
134
|
+
* A name for the subtask handler. Used for logging errors.
|
|
135
|
+
*/
|
|
136
|
+
readonly subtaskHandlerFunctionName: string;
|
|
137
|
+
/**
|
|
138
|
+
* The task type
|
|
139
|
+
*/
|
|
140
|
+
readonly taskType: NotificationTaskType;
|
|
141
|
+
/**
|
|
142
|
+
* Creates input for the NotificationTaskSubtaskNotificationTaskHandler from the provided NotificationTask.
|
|
143
|
+
*/
|
|
144
|
+
readonly inputFunction: NotificationTaskSubtaskNotificationTaskHandlerInputFunction<I, D, M, S>;
|
|
145
|
+
/**
|
|
146
|
+
* Configuration function for building/extending the update metadata for the NotificationTaskSubtaskNotificationTask.
|
|
147
|
+
*/
|
|
148
|
+
readonly buildUpdateMetadata?: NotificationTaskSubtaskNotificationTaskHandlerBuildUpdateMetadataFunction<I, D, M, S>;
|
|
149
|
+
/**
|
|
150
|
+
* The default cleanup instructions function.
|
|
151
|
+
*/
|
|
152
|
+
readonly defaultCleanup: NotificationTaskSubtaskCleanupInstructionsFunction<I, CUI, D, M, S>;
|
|
153
|
+
/**
|
|
154
|
+
* The cleanup function to execute using the input and instructions.
|
|
155
|
+
*/
|
|
156
|
+
readonly cleanupFunction: NotificationTaskSubtaskCleanupFunction<I, CUI, D, M, S>;
|
|
157
|
+
/**
|
|
158
|
+
* Sets the default max cleanup retry attempts for each processor.
|
|
159
|
+
*/
|
|
160
|
+
readonly defaultMaxCleanupRetryAttempts?: Maybe<number>;
|
|
161
|
+
/**
|
|
162
|
+
* Sets the default cleanup retry delay for each processor.
|
|
163
|
+
*/
|
|
164
|
+
readonly defaultCleanupRetryDelay?: Maybe<Milliseconds>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Creates a NotificationTaskServiceTaskHandlerConfig using the input config.
|
|
168
|
+
*/
|
|
169
|
+
export type NotificationTaskSubtaskNotificationTaskHandlerFactory<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> = (config: NotificationTaskSubtaskNotificationTaskHandlerConfig<I, CUI, D, M, S>) => NotificationTaskServiceTaskHandlerConfig<D, NotificationTaskSubtaskCheckpoint>;
|
|
170
|
+
/**
|
|
171
|
+
* Configuration for notificationTaskSubtaskNotificationTaskHandler().
|
|
172
|
+
*/
|
|
173
|
+
export interface NotificationTaskSubtaskNotificationTaskHandlerConfig<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString> {
|
|
174
|
+
/**
|
|
175
|
+
* List of all target values for the app. Used for verifying that all target values are handled.
|
|
176
|
+
*/
|
|
177
|
+
readonly validate?: NotificationTaskSubtaskTarget[];
|
|
178
|
+
/**
|
|
179
|
+
* List of handlers for NotificationTaskSubtaskTarget values.
|
|
180
|
+
*/
|
|
181
|
+
readonly processors: NotificationTaskSubtaskProcessorConfig<I, CUI, D, M, S>[];
|
|
182
|
+
/**
|
|
183
|
+
* The maximum number of times to delay the cleanup step of a NotificationTaskSubtaskNotificationTask.
|
|
184
|
+
*
|
|
185
|
+
* Defaults to DEFAULT_MAX_STORAGE_FILE_PROCESSING_CLEANUP_RETRY_ATTEMPTS.
|
|
186
|
+
*/
|
|
187
|
+
readonly maxCleanupRetryAttempts?: Maybe<number>;
|
|
188
|
+
/**
|
|
189
|
+
* The amount of time to delay the cleanup step of a NotificationTaskSubtaskNotificationTask.
|
|
190
|
+
*
|
|
191
|
+
* Defaults to DEFAULT_STORAGE_FILE_PROCESSING_CLEANUP_RETRY_DELAY.
|
|
192
|
+
*/
|
|
193
|
+
readonly cleanupRetryDelay?: Maybe<Milliseconds>;
|
|
194
|
+
/**
|
|
195
|
+
* The default value to use for allowRunMultipleParts if it is not specified, for each processor.
|
|
196
|
+
*/
|
|
197
|
+
readonly defaultAllowRunMultipleParts?: Maybe<boolean>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Creates a NotificationTaskSubtaskNotificationTaskHandlerFactory.
|
|
201
|
+
*/
|
|
202
|
+
export declare function notificationTaskSubtaskNotificationTaskHandlerFactory<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString>(factoryConfig: NotificationTaskSubtaskNotificationTaskHandlerFactoryConfig<I, CUI, D, M, S>): NotificationTaskSubtaskNotificationTaskHandlerFactory<I, CUI, D, M, S>;
|
|
203
|
+
/**
|
|
204
|
+
* Thrown when a subtask no longer has data available to continue processing.
|
|
205
|
+
*
|
|
206
|
+
* The subtask will be marked as immediately complete, and no cleanup will occur.
|
|
207
|
+
*
|
|
208
|
+
* This is useful in cases where the underlying models or data that the subtask rely on are deleted (and those models were also required for cleanup) so the task can be marked as complete without attempting cleanup.
|
|
209
|
+
*/
|
|
210
|
+
export declare class NotificationTaskSubTaskMissingRequiredDataTermination extends BaseError {
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Creates a NotificationTaskSubTaskMissingRequiredDataTermination.
|
|
214
|
+
*/
|
|
215
|
+
export declare function notificationTaskSubTaskMissingRequiredDataTermination(): NotificationTaskSubTaskMissingRequiredDataTermination;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationTaskSubTaskMissingRequiredDataTermination = void 0;
|
|
4
|
+
exports.notificationTaskSubtaskNotificationTaskHandlerFactory = notificationTaskSubtaskNotificationTaskHandlerFactory;
|
|
5
|
+
exports.notificationTaskSubTaskMissingRequiredDataTermination = notificationTaskSubTaskMissingRequiredDataTermination;
|
|
6
|
+
const firebase_1 = require("@dereekb/firebase");
|
|
7
|
+
const util_1 = require("@dereekb/util");
|
|
8
|
+
const make_error_1 = require("make-error");
|
|
9
|
+
const notification_task_service_util_1 = require("./notification.task.service.util");
|
|
10
|
+
/**
|
|
11
|
+
* Creates a NotificationTaskSubtaskNotificationTaskHandlerFactory.
|
|
12
|
+
*/
|
|
13
|
+
function notificationTaskSubtaskNotificationTaskHandlerFactory(factoryConfig) {
|
|
14
|
+
const { taskType, subtaskHandlerFunctionName: subtaskHandlerName, inputFunction, defaultCleanup, cleanupFunction, buildUpdateMetadata: inputBuildUpdateMetadata } = factoryConfig;
|
|
15
|
+
return (subtaskHandlerConfig) => {
|
|
16
|
+
const { processors: inputProcessors, maxCleanupRetryAttempts: inputMaxCleanupRetryAttempts, cleanupRetryDelay: inputCleanupRetryDelay, defaultAllowRunMultipleParts } = subtaskHandlerConfig;
|
|
17
|
+
const maxCleanupRetryAttempts = inputMaxCleanupRetryAttempts ?? firebase_1.DEFAULT_NOTIFICATION_TASK_SUBTASK_CLEANUP_RETRY_ATTEMPTS;
|
|
18
|
+
const cleanupRetryDelay = inputCleanupRetryDelay ?? firebase_1.DEFAULT_NOTIFICATION_TASK_SUBTASK_CLEANUP_RETRY_DELAY;
|
|
19
|
+
const buildUpdateMetadata = inputBuildUpdateMetadata ?? (() => undefined);
|
|
20
|
+
const processors = {};
|
|
21
|
+
inputProcessors.forEach((processorConfig) => {
|
|
22
|
+
const { target } = processorConfig;
|
|
23
|
+
processors[target] = processorFunctionForConfig(processorConfig);
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Structure is similar to notificationTaskService(), but contained to handle the subtasks.
|
|
27
|
+
*/
|
|
28
|
+
function processorFunctionForConfig(processorConfig) {
|
|
29
|
+
const { flow: inputFlows, cleanup, allowRunMultipleParts: processorAllowRunMultipleParts } = processorConfig;
|
|
30
|
+
const { included: subtaskFlows, excluded: nonSubtaskFlows } = (0, util_1.separateValues)(inputFlows, (x) => x.subtask != null);
|
|
31
|
+
const allowRunMultipleParts = processorAllowRunMultipleParts ?? defaultAllowRunMultipleParts;
|
|
32
|
+
if (inputFlows.length === 0) {
|
|
33
|
+
throw new Error(`${subtaskHandlerName}(): NotificationTaskSubtaskProcessorConfig must have at least one flow entry.`);
|
|
34
|
+
}
|
|
35
|
+
else if (nonSubtaskFlows.length > 1) {
|
|
36
|
+
throw new Error(`${subtaskHandlerName}(): NotificationTaskSubtaskProcessorConfig must not have more than one non-subtask flow.`);
|
|
37
|
+
}
|
|
38
|
+
const allKnownSubtasks = (0, util_1.unique)(inputFlows.map((x) => x.subtask));
|
|
39
|
+
return {
|
|
40
|
+
process: async (input) => {
|
|
41
|
+
const { notificationTask, completedSubtasks, subtaskData } = input;
|
|
42
|
+
let fn;
|
|
43
|
+
switch (completedSubtasks.length) {
|
|
44
|
+
case 0:
|
|
45
|
+
fn = (nonSubtaskFlows[0] ?? subtaskFlows[0])?.fn;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
const completedSubtasksSet = new Set(completedSubtasks);
|
|
49
|
+
/**
|
|
50
|
+
* Find the next flow function that hasn't had its checkpoint completed yet.
|
|
51
|
+
*/
|
|
52
|
+
const nextSubtask = subtaskFlows.find((x) => !completedSubtasksSet.has(x.subtask));
|
|
53
|
+
fn = nextSubtask?.fn;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
let result;
|
|
57
|
+
if (fn) {
|
|
58
|
+
/*
|
|
59
|
+
* This section is similar to handleNotificationTask() in notification.action.server.ts,
|
|
60
|
+
* but is modified to handle the subtasks. The main difference is the attempt count is maintained,
|
|
61
|
+
* and instead is available via the normal NotificationTask attempts details.
|
|
62
|
+
*/
|
|
63
|
+
const subtaskResult = await fn(input);
|
|
64
|
+
const { completion: subtaskCompletion, updateMetadata: subtaskUpdateMetadata, delayUntil, canRunNextCheckpoint } = subtaskResult;
|
|
65
|
+
let allSubtasksDone = false;
|
|
66
|
+
let sfps = completedSubtasks;
|
|
67
|
+
// update the task metadata to reflect the changes
|
|
68
|
+
switch (subtaskCompletion) {
|
|
69
|
+
case true:
|
|
70
|
+
allSubtasksDone = true;
|
|
71
|
+
break;
|
|
72
|
+
case false:
|
|
73
|
+
// remove any completions, if applicable
|
|
74
|
+
sfps = (0, notification_task_service_util_1.removeFromCompletionsArrayWithTaskResult)(sfps, subtaskResult);
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
sfps = (0, util_1.unique)([
|
|
78
|
+
...(0, notification_task_service_util_1.removeFromCompletionsArrayWithTaskResult)(sfps, subtaskResult), // remove any completions, if applicable
|
|
79
|
+
...(0, util_1.asArray)(subtaskCompletion)
|
|
80
|
+
]);
|
|
81
|
+
const completedSubtasksSet = new Set(sfps);
|
|
82
|
+
const incompleteSubtasks = allKnownSubtasks.filter((x) => !completedSubtasksSet.has(x));
|
|
83
|
+
allSubtasksDone = incompleteSubtasks.length === 0;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
// configure the update metadata result
|
|
87
|
+
const sd = {
|
|
88
|
+
...subtaskData,
|
|
89
|
+
...subtaskUpdateMetadata
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* This is updating the metadata for the NotificationTask, which has a nested data
|
|
93
|
+
*/
|
|
94
|
+
const baseUpdateMetadata = {
|
|
95
|
+
...notificationTask.data,
|
|
96
|
+
sfps,
|
|
97
|
+
sd
|
|
98
|
+
};
|
|
99
|
+
let updateMetadata = (await buildUpdateMetadata(baseUpdateMetadata, input));
|
|
100
|
+
if (updateMetadata) {
|
|
101
|
+
// inject sfps and sd back in
|
|
102
|
+
updateMetadata = {
|
|
103
|
+
...updateMetadata,
|
|
104
|
+
sfps,
|
|
105
|
+
sd
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
updateMetadata = baseUpdateMetadata;
|
|
110
|
+
}
|
|
111
|
+
const nextCanRunNextCheckpoint = canRunNextCheckpoint ?? allowRunMultipleParts;
|
|
112
|
+
result = {
|
|
113
|
+
completion: allSubtasksDone ? ['processing'] : (0, firebase_1.delayCompletion)(), // return processing until all subtasks are complete.
|
|
114
|
+
updateMetadata,
|
|
115
|
+
canRunNextCheckpoint: nextCanRunNextCheckpoint,
|
|
116
|
+
allCompletedSubTasks: sfps,
|
|
117
|
+
delayUntil // delay is passed through
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// no more subtasks to process, and no metadata changes. Mark as processing complete and continue.
|
|
122
|
+
result = (0, firebase_1.completeSubtaskProcessingAndScheduleCleanupTaskResult)();
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
},
|
|
126
|
+
cleanup
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function useInputDataFactory(fn) {
|
|
130
|
+
return async (notificationTask) => {
|
|
131
|
+
const { data } = notificationTask;
|
|
132
|
+
let result;
|
|
133
|
+
if (data) {
|
|
134
|
+
try {
|
|
135
|
+
const inputFunctionResult = await inputFunction(data, notificationTask);
|
|
136
|
+
result = await fn(notificationTask, inputFunctionResult, data);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
if (e instanceof NotificationTaskSubTaskMissingRequiredDataTermination) {
|
|
140
|
+
// Task is complete if the required data no longer exists. Nothing to cleanup.
|
|
141
|
+
result = (0, firebase_1.notificationTaskComplete)();
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
// rethrow the error
|
|
145
|
+
throw e;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Improperly configured task. Complete immediately.
|
|
151
|
+
result = (0, firebase_1.notificationTaskComplete)();
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const result = {
|
|
157
|
+
type: taskType,
|
|
158
|
+
flow: [
|
|
159
|
+
{
|
|
160
|
+
checkpoint: firebase_1.NOTIFICATION_TASK_SUBTASK_CHECKPOINT_PROCESSING,
|
|
161
|
+
fn: useInputDataFactory(async (notificationTask, inputFunctionResult, data) => {
|
|
162
|
+
let result;
|
|
163
|
+
const baseInput = {
|
|
164
|
+
...inputFunctionResult,
|
|
165
|
+
notificationTask
|
|
166
|
+
};
|
|
167
|
+
const { target } = baseInput;
|
|
168
|
+
if (target) {
|
|
169
|
+
const processor = processors[target];
|
|
170
|
+
if (processor) {
|
|
171
|
+
const { sd: subtaskData, sfps: completedSubtasks } = data;
|
|
172
|
+
const input = {
|
|
173
|
+
...baseInput,
|
|
174
|
+
target,
|
|
175
|
+
completedSubtasks: completedSubtasks ?? [],
|
|
176
|
+
subtaskData
|
|
177
|
+
};
|
|
178
|
+
result = await processor.process(input);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// processor is unknown. Complete the task.
|
|
182
|
+
result = (0, firebase_1.completeSubtaskProcessingAndScheduleCleanupTaskResult)();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
// target is unknown. Complete the task.
|
|
187
|
+
result = (0, firebase_1.completeSubtaskProcessingAndScheduleCleanupTaskResult)();
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
checkpoint: firebase_1.NOTIFICATION_TASK_SUBTASK_CHECKPOINT_CLEANUP,
|
|
194
|
+
fn: useInputDataFactory(async (notificationTask, inputFunctionResult, data) => {
|
|
195
|
+
let result;
|
|
196
|
+
let cleanupFunctionInput = {
|
|
197
|
+
...inputFunctionResult,
|
|
198
|
+
notificationTask
|
|
199
|
+
};
|
|
200
|
+
const { target } = cleanupFunctionInput;
|
|
201
|
+
let cleanupInstructions;
|
|
202
|
+
if (target) {
|
|
203
|
+
const processor = processors[target];
|
|
204
|
+
if (processor && processor.cleanup) {
|
|
205
|
+
const { sd: subtaskData, sfps: completedSubtasks } = data;
|
|
206
|
+
const input = {
|
|
207
|
+
...cleanupFunctionInput,
|
|
208
|
+
notificationTask,
|
|
209
|
+
completedSubtasks: completedSubtasks ?? [],
|
|
210
|
+
target,
|
|
211
|
+
subtaskData
|
|
212
|
+
};
|
|
213
|
+
cleanupInstructions = await processor.cleanup(input);
|
|
214
|
+
cleanupFunctionInput = input;
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// processor is unknown. Complete the task.
|
|
218
|
+
cleanupInstructions = defaultCleanup(cleanupFunctionInput);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
// target is unknown. Complete the task.
|
|
223
|
+
cleanupInstructions = defaultCleanup(cleanupFunctionInput);
|
|
224
|
+
}
|
|
225
|
+
if (cleanupInstructions.cleanupSuccess === false && notificationTask.currentCheckpointSendAttempts <= maxCleanupRetryAttempts) {
|
|
226
|
+
result = (0, firebase_1.notificationTaskDelayRetry)(cleanupInstructions.delayRetryUntil ?? cleanupRetryDelay);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
result = await cleanupFunction(cleanupFunctionInput, cleanupInstructions);
|
|
230
|
+
}
|
|
231
|
+
return result;
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
};
|
|
236
|
+
return result;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
// MARK: Internally Handled Errors
|
|
240
|
+
/**
|
|
241
|
+
* Thrown when a subtask no longer has data available to continue processing.
|
|
242
|
+
*
|
|
243
|
+
* The subtask will be marked as immediately complete, and no cleanup will occur.
|
|
244
|
+
*
|
|
245
|
+
* This is useful in cases where the underlying models or data that the subtask rely on are deleted (and those models were also required for cleanup) so the task can be marked as complete without attempting cleanup.
|
|
246
|
+
*/
|
|
247
|
+
class NotificationTaskSubTaskMissingRequiredDataTermination extends make_error_1.BaseError {
|
|
248
|
+
}
|
|
249
|
+
exports.NotificationTaskSubTaskMissingRequiredDataTermination = NotificationTaskSubTaskMissingRequiredDataTermination;
|
|
250
|
+
/**
|
|
251
|
+
* Creates a NotificationTaskSubTaskMissingRequiredDataTermination.
|
|
252
|
+
*/
|
|
253
|
+
function notificationTaskSubTaskMissingRequiredDataTermination() {
|
|
254
|
+
return new NotificationTaskSubTaskMissingRequiredDataTermination();
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=notification.task.subtask.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.task.subtask.handler.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/notification/notification.task.subtask.handler.ts"],"names":[],"mappings":";;;AAkPA,sHA8QC;AAeD,sHAEC;AAjhBD,gDAiB2B;AAE3B,wCAAkI;AAClI,2CAAuC;AACvC,qFAA4F;AA0N5F;;GAEG;AACH,SAAgB,qDAAqD,CACnE,aAA2F;IAE3F,MAAM,EAAE,QAAQ,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,GAAG,aAAa,CAAC;IAElL,OAAO,CAAC,oBAA2F,EAAE,EAAE;QACrG,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,GAAG,oBAAoB,CAAC;QAC7L,MAAM,uBAAuB,GAAG,4BAA4B,IAAI,mEAAwD,CAAC;QACzH,MAAM,iBAAiB,GAAG,sBAAsB,IAAI,gEAAqD,CAAC;QAE1G,MAAM,mBAAmB,GAAG,wBAAwB,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAS1E,MAAM,UAAU,GAA6F,EAAE,CAAC;QAEhH,eAAe,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;YACnC,UAAU,CAAC,MAAM,CAAC,GAAG,0BAA0B,CAAC,eAAe,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH;;WAEG;QACH,SAAS,0BAA0B,CAAC,eAAwE;YAC1G,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,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AK,IAAI,gBAAgB,CAAC,6BAA6B,IAAI,uBAAuB,EAAE,CAAC;4BAC9H,MAAM,GAAG,IAAA,qCAA0B,EAAC,mBAAmB,CAAC,eAAe,IAAI,iBAAiB,CAAC,CAAC;wBAChG,CAAC;6BAAM,CAAC;4BACN,MAAM,GAAG,MAAM,eAAe,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;wBAC5E,CAAC;wBAED,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC;iBACH;aACF;SACF,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,kCAAkC;AAClC;;;;;;GAMG;AACH,MAAa,qDAAsD,SAAQ,sBAAS;CAAG;AAAvF,sHAAuF;AAEvF;;GAEG;AACH,SAAgB,qDAAqD;IACnE,OAAO,IAAI,qDAAqD,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import { type StorageFileProcessingNotificationTaskData, type
|
|
1
|
+
import { type StorageFileProcessingNotificationTaskData, type StorageFilePurpose, type StorageFileProcessingSubtaskMetadata, type NotificationTaskServiceHandleNotificationTaskResult, type StorageFileProcessingSubtask, type StorageFileDocument, type StorageFile, type DocumentDataWithIdAndKey, StorageFileProcessingState, type StorageFileFirestoreCollections, type StoredFileReader, type FirebaseStorageAccessor } from '@dereekb/firebase';
|
|
2
2
|
import { type NotificationTaskServiceTaskHandlerConfig } from '../notification/notification.task.service.handler';
|
|
3
|
-
import { type Maybe
|
|
3
|
+
import { type Maybe } from '@dereekb/util';
|
|
4
4
|
import { type StorageFileQueueForDeleteTime } from './storagefile.util';
|
|
5
|
+
import { type NotificationTaskSubtaskCleanupInstructions, type NotificationTaskSubtaskFlowEntry, type NotificationTaskSubtaskInput, type NotificationTaskSubtaskNotificationTaskHandlerConfig, type NotificationTaskSubtaskProcessorConfig } from '../notification/notification.task.subtask.handler';
|
|
5
6
|
/**
|
|
6
7
|
* Input for a StorageFileProcessingPurposeSubtask.
|
|
7
8
|
*/
|
|
8
|
-
export interface StorageFileProcessingPurposeSubtaskInput<M extends StorageFileProcessingSubtaskMetadata = any, S extends StorageFileProcessingSubtask = StorageFileProcessingSubtask> {
|
|
9
|
-
/**
|
|
10
|
-
* The root NotificationTask.
|
|
11
|
-
*
|
|
12
|
-
* The data is always guranteed.
|
|
13
|
-
*/
|
|
14
|
-
readonly notificationTask: Omit<NotificationTask<StorageFileProcessingNotificationTaskData<M>>, 'data'> & Required<Pick<NotificationTask<StorageFileProcessingNotificationTaskData<M>>, 'data'>>;
|
|
9
|
+
export interface StorageFileProcessingPurposeSubtaskInput<M extends StorageFileProcessingSubtaskMetadata = any, S extends StorageFileProcessingSubtask = StorageFileProcessingSubtask> extends NotificationTaskSubtaskInput<StorageFileProcessingNotificationTaskData<M, S>, M, S> {
|
|
15
10
|
/**
|
|
16
11
|
* The retrieved purpose.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated use target instead.
|
|
17
14
|
*/
|
|
18
15
|
readonly purpose: StorageFilePurpose;
|
|
19
|
-
/**
|
|
20
|
-
* List of completed subtasks.
|
|
21
|
-
*/
|
|
22
|
-
readonly completedSubtasks: S[];
|
|
23
16
|
/**
|
|
24
17
|
* The associated StorageFileDocument.
|
|
25
18
|
*/
|
|
@@ -34,10 +27,6 @@ export interface StorageFileProcessingPurposeSubtaskInput<M extends StorageFileP
|
|
|
34
27
|
* The accessor for the uploaded file details.
|
|
35
28
|
*/
|
|
36
29
|
readonly fileDetailsAccessor: StoredFileReader;
|
|
37
|
-
/**
|
|
38
|
-
* The current metadata for the subtask.
|
|
39
|
-
*/
|
|
40
|
-
readonly subtaskData?: Maybe<M>;
|
|
41
30
|
}
|
|
42
31
|
/**
|
|
43
32
|
* Result of a StorageFileProcessingPurposeSubtask.
|
|
@@ -50,32 +39,11 @@ export type StorageFileProcessingPurposeSubtask<M extends StorageFileProcessingS
|
|
|
50
39
|
/**
|
|
51
40
|
* Similar to NotificationTaskServiceTaskHandlerFlowEntry, but used in StorageFileProcessingPurposeTaskProcessorConfig as part of the flow.
|
|
52
41
|
*/
|
|
53
|
-
export
|
|
54
|
-
/**
|
|
55
|
-
* The subtask this flow entry represents.
|
|
56
|
-
*/
|
|
57
|
-
readonly subtask: S;
|
|
58
|
-
/**
|
|
59
|
-
* The subtask function
|
|
60
|
-
*/
|
|
61
|
-
readonly fn: StorageFileProcessingPurposeSubtask<M, S>;
|
|
62
|
-
}
|
|
42
|
+
export type StorageFileProcessingPurposeSubtaskFlowEntry<M extends StorageFileProcessingSubtaskMetadata = any, S extends StorageFileProcessingSubtask = StorageFileProcessingSubtask> = NotificationTaskSubtaskFlowEntry<StorageFileProcessingPurposeSubtaskInput<M, S>, StorageFileProcessingNotificationTaskData<M, S>, M, S>;
|
|
63
43
|
/**
|
|
64
44
|
* The output cleanup configuration.
|
|
65
45
|
*/
|
|
66
|
-
export interface StorageFileProcessingPurposeSubtaskCleanupOutput {
|
|
67
|
-
/**
|
|
68
|
-
* Whether or not the cleanup was successful. If false, the task will be delayed until the cleanup can be retried.
|
|
69
|
-
*
|
|
70
|
-
* Defaults to true.
|
|
71
|
-
*/
|
|
72
|
-
readonly cleanupSuccess?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* How long to delay the retry of the cleanup after cleanup fails.
|
|
75
|
-
*
|
|
76
|
-
* Ignored if cleanupSuccess is not false.
|
|
77
|
-
*/
|
|
78
|
-
readonly delayRetryUntil?: NotificationTaskServiceHandleNotificationTaskResult['delayUntil'];
|
|
46
|
+
export interface StorageFileProcessingPurposeSubtaskCleanupOutput extends NotificationTaskSubtaskCleanupInstructions {
|
|
79
47
|
/**
|
|
80
48
|
* The next processing state for the StorageFile.
|
|
81
49
|
*
|
|
@@ -91,47 +59,22 @@ export interface StorageFileProcessingPurposeSubtaskCleanupOutput {
|
|
|
91
59
|
*/
|
|
92
60
|
readonly queueForDelete?: Maybe<false | StorageFileQueueForDeleteTime>;
|
|
93
61
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Cleanup function for a StorageFileProcessingPurposeSubtask.
|
|
96
|
-
*
|
|
97
|
-
* This is called during the cleanup step.
|
|
98
|
-
*/
|
|
99
|
-
export type StorageFileProcessingPurposeSubtaskCleanupFunction<M extends StorageFileProcessingSubtaskMetadata = any, S extends StorageFileProcessingSubtask = StorageFileProcessingSubtask> = (input: StorageFileProcessingPurposeSubtaskInput<M, S>) => PromiseOrValue<StorageFileProcessingPurposeSubtaskCleanupOutput>;
|
|
100
62
|
/**
|
|
101
63
|
* Similar to NotificationTaskServiceTaskHandlerConfig, but instead targets a specific StorageFilePurpose.
|
|
102
64
|
*
|
|
103
65
|
* The flows behave the same way.
|
|
104
66
|
*/
|
|
105
|
-
export
|
|
106
|
-
readonly purpose: StorageFilePurpose;
|
|
107
|
-
/**
|
|
108
|
-
* The order/flow of checkpoints and handler functions.
|
|
109
|
-
*
|
|
110
|
-
* When handling a notification task, if the checkpoint has already been completed then the entry will be skipped.
|
|
111
|
-
*/
|
|
112
|
-
readonly flow: StorageFileProcessingPurposeSubtaskFlowEntry<M, S>[];
|
|
113
|
-
/**
|
|
114
|
-
* Optional cleanup function for the subtask.
|
|
115
|
-
*
|
|
116
|
-
* If not provided, the default cleanup actions will take place, which is:
|
|
117
|
-
* - Set the StorageFileProcessingState to SUCCESS
|
|
118
|
-
* - Flag the StorageFile for deletion
|
|
119
|
-
*/
|
|
120
|
-
readonly cleanup?: StorageFileProcessingPurposeSubtaskCleanupFunction<M, S>;
|
|
121
|
-
/**
|
|
122
|
-
* If true, then results returned by this processor will set "canRunNextCheckpoint" to true if it is undefined.
|
|
123
|
-
*/
|
|
124
|
-
readonly allowRunMultipleParts?: Maybe<boolean>;
|
|
125
|
-
}
|
|
126
|
-
export interface StorageFileProcessingNotificationTaskHandlerConfig {
|
|
67
|
+
export type StorageFileProcessingPurposeSubtaskProcessorConfig<M extends StorageFileProcessingSubtaskMetadata = any, S extends StorageFileProcessingSubtask = StorageFileProcessingSubtask> = NotificationTaskSubtaskProcessorConfig<StorageFileProcessingPurposeSubtaskInput<M, S>, StorageFileProcessingPurposeSubtaskCleanupOutput, StorageFileProcessingNotificationTaskData<M, S>> | (Omit<NotificationTaskSubtaskProcessorConfig<StorageFileProcessingPurposeSubtaskInput<M, S>, StorageFileProcessingPurposeSubtaskCleanupOutput, StorageFileProcessingNotificationTaskData<M, S>>, 'target'> & {
|
|
127
68
|
/**
|
|
128
|
-
*
|
|
69
|
+
* @deprecated use target instead.
|
|
129
70
|
*/
|
|
130
|
-
readonly
|
|
71
|
+
readonly purpose?: Maybe<StorageFilePurpose>;
|
|
72
|
+
});
|
|
73
|
+
export interface StorageFileProcessingNotificationTaskHandlerConfig extends Omit<NotificationTaskSubtaskNotificationTaskHandlerConfig<StorageFileProcessingPurposeSubtaskInput, StorageFileProcessingPurposeSubtaskCleanupOutput, StorageFileProcessingNotificationTaskData>, 'processors'> {
|
|
131
74
|
/**
|
|
132
|
-
*
|
|
75
|
+
* The input processors.
|
|
133
76
|
*/
|
|
134
|
-
readonly processors: StorageFileProcessingPurposeSubtaskProcessorConfig
|
|
77
|
+
readonly processors: StorageFileProcessingPurposeSubtaskProcessorConfig[];
|
|
135
78
|
/**
|
|
136
79
|
* FirebaseStorageAccessor
|
|
137
80
|
*/
|
|
@@ -140,24 +83,8 @@ export interface StorageFileProcessingNotificationTaskHandlerConfig {
|
|
|
140
83
|
* Accessor for StorageFileDocument.
|
|
141
84
|
*/
|
|
142
85
|
readonly storageFileFirestoreCollections: StorageFileFirestoreCollections;
|
|
143
|
-
/**
|
|
144
|
-
* The maximum number of times to delay the cleanup step of a StorageFileProcessingNotificationTask.
|
|
145
|
-
*
|
|
146
|
-
* Defaults to DEFAULT_MAX_STORAGE_FILE_PROCESSING_CLEANUP_RETRY_ATTEMPTS.
|
|
147
|
-
*/
|
|
148
|
-
readonly maxCleanupRetryAttempts?: Maybe<number>;
|
|
149
|
-
/**
|
|
150
|
-
* The amount of time to delay the cleanup step of a StorageFileProcessingNotificationTask.
|
|
151
|
-
*
|
|
152
|
-
* Defaults to DEFAULT_STORAGE_FILE_PROCESSING_CLEANUP_RETRY_DELAY.
|
|
153
|
-
*/
|
|
154
|
-
readonly cleanupRetryDelay?: Maybe<Milliseconds>;
|
|
155
|
-
/**
|
|
156
|
-
* The default value to use for allowRunMultipleParts if it is not specified, for each processor.
|
|
157
|
-
*/
|
|
158
|
-
readonly defaultAllowRunMultipleParts?: Maybe<boolean>;
|
|
159
86
|
}
|
|
160
87
|
/**
|
|
161
88
|
* Creates a NotificationTaskServiceTaskHandlerConfig that handles the StorageFileProcessingNotificationTask.
|
|
162
89
|
*/
|
|
163
|
-
export declare function storageFileProcessingNotificationTaskHandler(config: StorageFileProcessingNotificationTaskHandlerConfig): NotificationTaskServiceTaskHandlerConfig<StorageFileProcessingNotificationTaskData
|
|
90
|
+
export declare function storageFileProcessingNotificationTaskHandler(config: StorageFileProcessingNotificationTaskHandlerConfig): NotificationTaskServiceTaskHandlerConfig<StorageFileProcessingNotificationTaskData>;
|
|
@@ -3,286 +3,95 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.storageFileProcessingNotificationTaskHandler = storageFileProcessingNotificationTaskHandler;
|
|
4
4
|
const firebase_1 = require("@dereekb/firebase");
|
|
5
5
|
const util_1 = require("@dereekb/util");
|
|
6
|
-
const make_error_1 = require("make-error");
|
|
7
|
-
const notification_task_service_util_1 = require("../notification/notification.task.service.util");
|
|
8
6
|
const storagefile_util_1 = require("./storagefile.util");
|
|
7
|
+
const notification_task_subtask_handler_1 = require("../notification/notification.task.subtask.handler");
|
|
9
8
|
/**
|
|
10
9
|
* Creates a NotificationTaskServiceTaskHandlerConfig that handles the StorageFileProcessingNotificationTask.
|
|
11
10
|
*/
|
|
12
11
|
function storageFileProcessingNotificationTaskHandler(config) {
|
|
13
|
-
const { processors: inputProcessors, storageAccessor, storageFileFirestoreCollections
|
|
12
|
+
const { processors: inputProcessors, storageAccessor, storageFileFirestoreCollections } = config;
|
|
14
13
|
const storageFileDocumentAccessor = storageFileFirestoreCollections.storageFileCollection.documentAccessor();
|
|
15
|
-
const maxCleanupRetryAttempts = inputMaxCleanupRetryAttempts ?? firebase_1.DEFAULT_MAX_STORAGE_FILE_PROCESSING_CLEANUP_RETRY_ATTEMPTS;
|
|
16
|
-
const cleanupRetryDelay = inputCleanupRetryDelay ?? firebase_1.DEFAULT_STORAGE_FILE_PROCESSING_CLEANUP_RETRY_DELAY;
|
|
17
14
|
const makeFileDetailsAccessor = (0, firebase_1.storedFileReaderFactory)();
|
|
18
|
-
|
|
19
|
-
inputProcessors.forEach((
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
// COMPAT: Sets target if unset and purpose is set. Use until purpose is removed.
|
|
16
|
+
inputProcessors.forEach((x) => {
|
|
17
|
+
if (!x.target) {
|
|
18
|
+
if (x.purpose) {
|
|
19
|
+
x.target = x.purpose;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
throw new Error('StorageFileProcessingPurposeSubtaskProcessorConfig must have a target or purpose.');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
22
25
|
});
|
|
23
|
-
function
|
|
24
|
-
return (0, firebase_1.notificationTaskPartiallyComplete)(['processing']);
|
|
25
|
-
}
|
|
26
|
-
function defaultCleanupOutput() {
|
|
26
|
+
function defaultCleanup() {
|
|
27
27
|
return {
|
|
28
28
|
cleanupSuccess: true,
|
|
29
29
|
nextProcessingState: firebase_1.StorageFileProcessingState.SUCCESS,
|
|
30
30
|
queueForDelete: true
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
else if (nonSubtaskFlows.length > 1) {
|
|
44
|
-
throw new Error('storageFileProcessingNotificationTaskHandler(): StorageFileProcessingPurposeSubtaskProcessorConfig must not have more than one non-subtask flow.');
|
|
45
|
-
}
|
|
46
|
-
const allKnownSubtasks = (0, util_1.unique)(inputFlows.map((x) => x.subtask));
|
|
47
|
-
return {
|
|
48
|
-
process: async (input) => {
|
|
49
|
-
const { notificationTask, completedSubtasks, subtaskData, purpose } = input;
|
|
50
|
-
let fn;
|
|
51
|
-
switch (completedSubtasks.length) {
|
|
52
|
-
case 0:
|
|
53
|
-
fn = (nonSubtaskFlows[0] ?? subtaskFlows[0])?.fn;
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
const completedSubtasksSet = new Set(completedSubtasks);
|
|
57
|
-
/**
|
|
58
|
-
* Find the next flow function that hasn't had its checkpoint completed yet.
|
|
59
|
-
*/
|
|
60
|
-
const nextSubtask = subtaskFlows.find((x) => !completedSubtasksSet.has(x.subtask));
|
|
61
|
-
fn = nextSubtask?.fn;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
let result;
|
|
65
|
-
if (fn) {
|
|
66
|
-
/*
|
|
67
|
-
* This section is similar to handleNotificationTask() in notification.action.server.ts,
|
|
68
|
-
* but is modified to handle the subtasks. The main difference is the attempt count is maintained,
|
|
69
|
-
* and instead is available via the normal NotificationTask attempts details.
|
|
70
|
-
*/
|
|
71
|
-
const subtaskResult = await fn(input);
|
|
72
|
-
const { completion: subtaskCompletion, updateMetadata: subtaskUpdateMetadata, delayUntil, canRunNextCheckpoint } = subtaskResult;
|
|
73
|
-
let allSubtasksDone = false;
|
|
74
|
-
let sfps = completedSubtasks;
|
|
75
|
-
// update the task metadata to reflect the changes
|
|
76
|
-
switch (subtaskCompletion) {
|
|
77
|
-
case true:
|
|
78
|
-
allSubtasksDone = true;
|
|
79
|
-
break;
|
|
80
|
-
case false:
|
|
81
|
-
// remove any completions, if applicable
|
|
82
|
-
sfps = (0, notification_task_service_util_1.removeFromCompletionsArrayWithTaskResult)(sfps, subtaskResult);
|
|
83
|
-
break;
|
|
84
|
-
default:
|
|
85
|
-
sfps = (0, util_1.unique)([
|
|
86
|
-
...(0, notification_task_service_util_1.removeFromCompletionsArrayWithTaskResult)(sfps, subtaskResult), // remove any completions, if applicable
|
|
87
|
-
...(0, util_1.asArray)(subtaskCompletion)
|
|
88
|
-
]);
|
|
89
|
-
const completedSubtasksSet = new Set(sfps);
|
|
90
|
-
const incompleteSubtasks = allKnownSubtasks.filter((x) => !completedSubtasksSet.has(x));
|
|
91
|
-
allSubtasksDone = incompleteSubtasks.length === 0;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* This is updating the metadata for the NotificationTask, which has a nested data
|
|
96
|
-
*/
|
|
97
|
-
const updateMetadata = {
|
|
98
|
-
...notificationTask.data,
|
|
99
|
-
// always re-copy the purpose/storagePath for the next run so StorageFile does not have to be reloaded
|
|
100
|
-
p: purpose,
|
|
101
|
-
storagePath: (0, firebase_1.copyStoragePath)(input.fileDetailsAccessor.input),
|
|
102
|
-
sfps,
|
|
103
|
-
sd: {
|
|
104
|
-
...subtaskData,
|
|
105
|
-
...subtaskUpdateMetadata
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const nextCanRunNextCheckpoint = canRunNextCheckpoint ?? allowRunMultipleParts;
|
|
109
|
-
result = {
|
|
110
|
-
completion: allSubtasksDone ? ['processing'] : (0, firebase_1.delayCompletion)(), // return processing until all subtasks are complete.
|
|
111
|
-
updateMetadata,
|
|
112
|
-
canRunNextCheckpoint: nextCanRunNextCheckpoint,
|
|
113
|
-
allCompletedSubTasks: sfps,
|
|
114
|
-
delayUntil // delay is passed through
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// no more subtasks to process, and no metadata changes. Mark as processing complete and continue.
|
|
119
|
-
result = completeProcessingAndScheduleCleanup();
|
|
33
|
+
return (0, notification_task_subtask_handler_1.notificationTaskSubtaskNotificationTaskHandlerFactory)({
|
|
34
|
+
taskType: firebase_1.STORAGE_FILE_PROCESSING_NOTIFICATION_TASK_TYPE,
|
|
35
|
+
subtaskHandlerFunctionName: 'storageFileProcessingNotificationTaskHandler',
|
|
36
|
+
inputFunction: async (data) => {
|
|
37
|
+
const storageFileDocument = await storageFileDocumentAccessor.loadDocumentForId(data.storageFile);
|
|
38
|
+
const loadStorageFile = (0, util_1.cachedGetter)(async () => {
|
|
39
|
+
const storageFile = await (0, firebase_1.getDocumentSnapshotData)(storageFileDocument, true);
|
|
40
|
+
if (!storageFile) {
|
|
41
|
+
throw (0, notification_task_subtask_handler_1.notificationTaskSubTaskMissingRequiredDataTermination)();
|
|
120
42
|
}
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const storageFileDocument = await storageFileDocumentAccessor.loadDocumentForId(data.storageFile);
|
|
128
|
-
const loadStorageFile = (0, util_1.cachedGetter)(async () => {
|
|
129
|
-
const storageFile = await (0, firebase_1.getDocumentSnapshotData)(storageFileDocument, true);
|
|
130
|
-
if (!storageFile) {
|
|
131
|
-
throw new StorageFileDocumentNoLongerAvailable();
|
|
43
|
+
return storageFile;
|
|
44
|
+
});
|
|
45
|
+
let purpose = data?.p;
|
|
46
|
+
if (!purpose) {
|
|
47
|
+
// attempt to load the purpose from the storage file, if it exists.
|
|
48
|
+
purpose = await loadStorageFile().then((x) => x.p);
|
|
132
49
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (!purpose) {
|
|
137
|
-
// attempt to load the purpose from the storage file, if it exists.
|
|
138
|
-
purpose = await loadStorageFile().then((x) => x.p);
|
|
139
|
-
}
|
|
140
|
-
let storagePath;
|
|
141
|
-
if (data.storagePath) {
|
|
142
|
-
storagePath = data.storagePath;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
storagePath = await loadStorageFile().then((x) => ({ bucketId: x.bucketId, pathString: x.pathString }));
|
|
146
|
-
}
|
|
147
|
-
const file = storageAccessor.file(storagePath);
|
|
148
|
-
const fileDetailsAccessor = makeFileDetailsAccessor(file);
|
|
149
|
-
return {
|
|
150
|
-
purpose,
|
|
151
|
-
loadStorageFile,
|
|
152
|
-
fileDetailsAccessor,
|
|
153
|
-
storageFileDocument
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
const result = {
|
|
157
|
-
type: firebase_1.STORAGE_FILE_PROCESSING_NOTIFICATION_TASK_TYPE,
|
|
158
|
-
flow: [
|
|
159
|
-
{
|
|
160
|
-
checkpoint: firebase_1.STORAGE_FILE_PROCESSING_NOTIFICATION_TASK_CHECKPOINT_PROCESSING,
|
|
161
|
-
fn: async (notificationTask) => {
|
|
162
|
-
const { data } = notificationTask;
|
|
163
|
-
let result;
|
|
164
|
-
if (data) {
|
|
165
|
-
try {
|
|
166
|
-
const { purpose, storageFileDocument, loadStorageFile, fileDetailsAccessor } = await _initializeWithTaskData(data);
|
|
167
|
-
if (purpose) {
|
|
168
|
-
const processor = processors[purpose];
|
|
169
|
-
if (processor) {
|
|
170
|
-
const { sd: subtaskData, sfps: completedSubtasks } = data;
|
|
171
|
-
const input = {
|
|
172
|
-
notificationTask: notificationTask,
|
|
173
|
-
completedSubtasks: completedSubtasks ?? [],
|
|
174
|
-
purpose,
|
|
175
|
-
subtaskData,
|
|
176
|
-
storageFileDocument,
|
|
177
|
-
fileDetailsAccessor,
|
|
178
|
-
loadStorageFile
|
|
179
|
-
};
|
|
180
|
-
result = await processor.process(input);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
// processor is unknown. Complete the task.
|
|
184
|
-
result = completeProcessingAndScheduleCleanup();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
// purpose is unknown. Complete the task.
|
|
189
|
-
result = completeProcessingAndScheduleCleanup();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
catch (e) {
|
|
193
|
-
if (e instanceof StorageFileDocumentNoLongerAvailable) {
|
|
194
|
-
// Catch loading the StorageFileDocument's data.
|
|
195
|
-
// Task is complete if the document no longer exists. Nothing to cleanup.
|
|
196
|
-
result = (0, firebase_1.notificationTaskComplete)();
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
// rethrow the error
|
|
200
|
-
throw e;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
// Improperly configured task. Complete immediately.
|
|
206
|
-
result = (0, firebase_1.notificationTaskComplete)();
|
|
207
|
-
}
|
|
208
|
-
return result;
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
checkpoint: firebase_1.STORAGE_FILE_PROCESSING_NOTIFICATION_TASK_CHECKPOINT_CLEANUP,
|
|
213
|
-
fn: async (notificationTask) => {
|
|
214
|
-
const { data } = notificationTask;
|
|
215
|
-
let result;
|
|
216
|
-
if (data) {
|
|
217
|
-
try {
|
|
218
|
-
const { purpose, storageFileDocument, loadStorageFile, fileDetailsAccessor } = await _initializeWithTaskData(data);
|
|
219
|
-
let cleanupOutput;
|
|
220
|
-
if (purpose) {
|
|
221
|
-
const processor = processors[purpose];
|
|
222
|
-
if (processor && processor.cleanup) {
|
|
223
|
-
const { sd: subtaskData, sfps: completedSubtasks } = data;
|
|
224
|
-
const input = {
|
|
225
|
-
notificationTask: notificationTask,
|
|
226
|
-
completedSubtasks: completedSubtasks ?? [],
|
|
227
|
-
purpose,
|
|
228
|
-
subtaskData,
|
|
229
|
-
storageFileDocument,
|
|
230
|
-
fileDetailsAccessor,
|
|
231
|
-
loadStorageFile
|
|
232
|
-
};
|
|
233
|
-
cleanupOutput = await processor.cleanup(input);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
// processor is unknown. Complete the task.
|
|
237
|
-
cleanupOutput = defaultCleanupOutput();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
// purpose is unknown. Complete the task.
|
|
242
|
-
cleanupOutput = defaultCleanupOutput();
|
|
243
|
-
}
|
|
244
|
-
if (cleanupOutput.cleanupSuccess === false && notificationTask.currentCheckpointSendAttempts <= maxCleanupRetryAttempts) {
|
|
245
|
-
result = (0, firebase_1.notificationTaskDelayRetry)(cleanupOutput.delayRetryUntil ?? cleanupRetryDelay);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
let updateTemplate = {
|
|
249
|
-
ps: cleanupOutput.nextProcessingState ?? firebase_1.StorageFileProcessingState.SUCCESS,
|
|
250
|
-
pcat: new Date(), // set new cleanup/completion date
|
|
251
|
-
pn: null // clear reference
|
|
252
|
-
};
|
|
253
|
-
if (cleanupOutput.queueForDelete != null && cleanupOutput.queueForDelete !== false) {
|
|
254
|
-
updateTemplate = {
|
|
255
|
-
...updateTemplate,
|
|
256
|
-
...(0, storagefile_util_1.markStorageFileForDeleteTemplate)(cleanupOutput.queueForDelete)
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
await storageFileDocument.update(updateTemplate);
|
|
260
|
-
result = (0, firebase_1.notificationTaskComplete)();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
catch (e) {
|
|
264
|
-
if (e instanceof StorageFileDocumentNoLongerAvailable) {
|
|
265
|
-
// Task is complete if the document no longer exists. Nothing to cleanup or act on.
|
|
266
|
-
result = (0, firebase_1.notificationTaskComplete)();
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
// rethrow the error
|
|
270
|
-
throw e;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
// Improperly configured task. Complete immediately.
|
|
276
|
-
result = (0, firebase_1.notificationTaskComplete)();
|
|
277
|
-
}
|
|
278
|
-
return result;
|
|
279
|
-
}
|
|
50
|
+
let storagePath;
|
|
51
|
+
if (data.storagePath) {
|
|
52
|
+
storagePath = data.storagePath;
|
|
280
53
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
54
|
+
else {
|
|
55
|
+
storagePath = await loadStorageFile().then((x) => ({ bucketId: x.bucketId, pathString: x.pathString }));
|
|
56
|
+
}
|
|
57
|
+
const file = storageAccessor.file(storagePath);
|
|
58
|
+
const fileDetailsAccessor = makeFileDetailsAccessor(file);
|
|
59
|
+
const input = {
|
|
60
|
+
purpose: purpose,
|
|
61
|
+
target: purpose,
|
|
62
|
+
loadStorageFile,
|
|
63
|
+
fileDetailsAccessor,
|
|
64
|
+
storageFileDocument
|
|
65
|
+
};
|
|
66
|
+
return input;
|
|
67
|
+
},
|
|
68
|
+
buildUpdateMetadata: (baseUpdateMetadata, input) => {
|
|
69
|
+
const { purpose } = input;
|
|
70
|
+
return {
|
|
71
|
+
...baseUpdateMetadata,
|
|
72
|
+
// always re-copy the purpose/storagePath for the next run so StorageFile does not have to be reloaded
|
|
73
|
+
p: purpose,
|
|
74
|
+
storagePath: (0, firebase_1.copyStoragePath)(input.fileDetailsAccessor.input)
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
defaultCleanup,
|
|
78
|
+
cleanupFunction: async function (input, cleanupInstructions) {
|
|
79
|
+
const { storageFileDocument } = input;
|
|
80
|
+
const { nextProcessingState, queueForDelete } = cleanupInstructions;
|
|
81
|
+
let updateTemplate = {
|
|
82
|
+
ps: nextProcessingState ?? firebase_1.StorageFileProcessingState.SUCCESS,
|
|
83
|
+
pcat: new Date(), // set new cleanup/completion date
|
|
84
|
+
pn: null // clear reference
|
|
85
|
+
};
|
|
86
|
+
if (queueForDelete != null && queueForDelete !== false) {
|
|
87
|
+
updateTemplate = {
|
|
88
|
+
...updateTemplate,
|
|
89
|
+
...(0, storagefile_util_1.markStorageFileForDeleteTemplate)(queueForDelete)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
await storageFileDocument.update(updateTemplate);
|
|
93
|
+
return (0, firebase_1.notificationTaskComplete)();
|
|
94
|
+
}
|
|
95
|
+
})(config); // COMPAT: remove once purpose is removed from StorageFileProcessingPurposeSubtaskProcessorConfig, and the types match.
|
|
287
96
|
}
|
|
288
97
|
//# sourceMappingURL=storagefile.task.service.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storagefile.task.service.handler.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/storagefile/storagefile.task.service.handler.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"storagefile.task.service.handler.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/storagefile/storagefile.task.service.handler.ts"],"names":[],"mappings":";;AAsHA,oGAoGC;AA1ND,gDAmB2B;AAE3B,wCAAyD;AACzD,yDAA0G;AAC1G,yGAAoZ;AA4FpZ;;GAEG;AACH,SAAgB,4CAA4C,CAAC,MAA0D;IACrH,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,+BAA+B,EAAE,GAAG,MAAM,CAAC;IACjG,MAAM,2BAA2B,GAAG,+BAA+B,CAAC,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC7G,MAAM,uBAAuB,GAAG,IAAA,kCAAuB,GAAE,CAAC;IAE1D,iFAAiF;IACjF,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5B,IAAI,CAAE,CAAS,CAAC,MAAM,EAAE,CAAC;YACvB,IAAK,CAAS,CAAC,OAAO,EAAE,CAAC;gBACtB,CAAS,CAAC,MAAM,GAAI,CAAS,CAAC,OAAO,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC;YACvG,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,SAAS,cAAc;QACrB,OAAO;YACL,cAAc,EAAE,IAAI;YACpB,mBAAmB,EAAE,qCAA0B,CAAC,OAAO;YACvD,cAAc,EAAE,IAAI;SACrB,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,yFAAqD,EAA4M;QACtQ,QAAQ,EAAE,yDAA8C;QACxD,0BAA0B,EAAE,8CAA8C;QAC1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mB;aACpB,CAAC;YAEF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,mBAAmB,EAAE,CAAC,kBAAkB,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;YAE1B,OAAO;gBACL,GAAG,kBAAkB;gBACrB,sGAAsG;gBACtG,CAAC,EAAE,OAAO;gBACV,WAAW,EAAE,IAAA,0BAAe,EAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC;aAC9D,CAAC;QACJ,CAAC;QACD,cAAc;QACd,eAAe,EAAE,KAAK,WAAW,KAAK,EAAE,mBAAqE;YAC3G,MAAM,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC;YACtC,MAAM,EAAE,mBAAmB,EAAE,cAAc,EAAE,GAAG,mBAAmB,CAAC;YAEpE,IAAI,cAAc,GAAyB;gBACzC,EAAE,EAAE,mBAAmB,IAAI,qCAA0B,CAAC,OAAO;gBAC7D,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,kCAAkC;gBACpD,EAAE,EAAE,IAAI,CAAC,kBAAkB;aAC5B,CAAC;YAEF,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;gBACvD,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,GAAG,IAAA,mDAAgC,EAAC,cAAc,CAAC;iBACpD,CAAC;YACJ,CAAC;YAED,MAAM,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACjD,OAAO,IAAA,mCAAwB,GAAE,CAAC;QACpC,CAAC;KACF,CAAC,CAAC,MAAa,CAAC,CAAC,CAAC,uHAAuH;AAC5I,CAAC"}
|
|
@@ -119,6 +119,10 @@ function storageFileInitializeFromUploadService(config) {
|
|
|
119
119
|
storageFileDocument = initializerResult.storageFileDocument;
|
|
120
120
|
flagPreviousForDelete = initializerResult.flagPreviousForDelete;
|
|
121
121
|
}
|
|
122
|
+
// sanitize the returned value, incase the result comes from a transaction
|
|
123
|
+
if (storageFileDocument) {
|
|
124
|
+
storageFileDocument = storageFileCollection.documentAccessor().loadDocumentFrom(storageFileDocument);
|
|
125
|
+
}
|
|
122
126
|
// set the metadata on the associated file
|
|
123
127
|
try {
|
|
124
128
|
const createdFile = storageService.file(createdFilePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storagefile.upload.service.initializer.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/storagefile/storagefile.upload.service.initializer.ts"],"names":[],"mappings":";;AAsFA,0JAMC;AAoED,
|
|
1
|
+
{"version":3,"file":"storagefile.upload.service.initializer.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/storagefile/storagefile.upload.service.initializer.ts"],"names":[],"mappings":";;AAsFA,0JAMC;AAoED,wFAwLC;AAxVD,gDAoB2B;AAC3B,wCAAsJ;AAEtJ,yDAAyG;AA+DzG,SAAgB,uEAAuE,CAAC,KAAc,EAAE,WAAmC;IACzI,OAAO;QACL,KAAK;QACL,gBAAgB,EAAE,IAAI;QACtB,WAAW;KACZ,CAAC;AACJ,CAAC;AAiED;;GAEG;AACH,SAAgB,sCAAsC,CAAC,MAAoD;IACzG,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iCAAiC,EAAE,sCAAsC,EAAE,0CAA0C,EAAE,GAAG,MAAM,CAAC;IAExP,MAAM,cAAc,GAAiC,EAAE,CAAC;IACxD,MAAM,YAAY,GAA0F,EAAE,CAAC;IAC/G,MAAM,sBAAsB,GAAG,IAAA,kCAAuB,GAAE,CAAC;IAEzD,IAAI,gBAAgB,EAAE,CAAC;QACrB,IAAA,oCAA6B,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAClE,CAAC;IAED,uBAAuB;IACvB,iBAAiB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACxC,MAAM,EAA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