@dereekb/firebase-server 13.43.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/calcom/index.esm.js +57 -96
  2. package/calcom/package.json +11 -11
  3. package/discord/index.esm.js +48 -74
  4. package/discord/package.json +11 -11
  5. package/index.esm.js +336 -583
  6. package/mailgun/index.esm.js +20 -32
  7. package/mailgun/package.json +9 -9
  8. package/mcp/index.esm.js +131 -185
  9. package/mcp/package.json +14 -14
  10. package/model/index.esm.js +699 -692
  11. package/model/package.json +14 -14
  12. package/model/src/lib/formspace/formspace.action.server.d.ts +79 -5
  13. package/model/src/lib/formspace/formspace.error.d.ts +21 -0
  14. package/model/src/lib/formspace/formspace.task.service.handler.d.ts +3 -2
  15. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +3 -3
  16. package/oidc/index.esm.js +144 -251
  17. package/oidc/package.json +14 -14
  18. package/package.json +24 -24
  19. package/src/lib/function/type.d.ts +0 -9
  20. package/src/lib/nest/app.d.ts +0 -4
  21. package/src/lib/nest/development/development.app.function.d.ts +2 -2
  22. package/src/lib/nest/model/analytics.handler.d.ts +0 -8
  23. package/src/lib/nest/model/api.details.d.ts +0 -8
  24. package/src/lib/nest/nest.provider.d.ts +0 -8
  25. package/test/index.esm.js +239 -395
  26. package/test/package.json +17 -17
  27. package/test/src/lib/firebase/firebase.admin.auth.d.ts +4 -25
  28. package/test/src/lib/firebase/firebase.admin.nest.d.ts +0 -4
  29. package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +7 -7
  30. package/test/src/lib/firebase/firebase.function.d.ts +20 -81
  31. package/test/src/lib/firebase/firebase.test.d.ts +0 -9
  32. package/twilio/index.esm.js +11 -14
  33. package/twilio/package.json +8 -8
  34. package/zoho/index.esm.js +72 -132
  35. package/zoho/package.json +12 -12
  36. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +0 -10
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/model",
3
- "version": "13.43.0",
3
+ "version": "14.0.0",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
- "@dereekb/analytics": "13.43.0",
7
- "@dereekb/date": "13.43.0",
8
- "@dereekb/firebase": "13.43.0",
9
- "@dereekb/firebase-server": "13.43.0",
10
- "@dereekb/model": "13.43.0",
11
- "@dereekb/nestjs": "13.43.0",
12
- "@dereekb/rxjs": "13.43.0",
13
- "@dereekb/util": "13.43.0",
14
- "@nestjs/common": "^11.1.19",
15
- "@nestjs/config": "^4.0.4",
16
- "archiver": "^7.0.1",
6
+ "@dereekb/analytics": "14.0.0",
7
+ "@dereekb/date": "14.0.0",
8
+ "@dereekb/firebase": "14.0.0",
9
+ "@dereekb/firebase-server": "14.0.0",
10
+ "@dereekb/model": "14.0.0",
11
+ "@dereekb/nestjs": "14.0.0",
12
+ "@dereekb/rxjs": "14.0.0",
13
+ "@dereekb/util": "14.0.0",
14
+ "@nestjs/common": "^12.0.1",
15
+ "@nestjs/config": "^12.0.0",
16
+ "archiver": "^8.0.0",
17
17
  "date-fns": "^4.1.0",
18
18
  "express": "^5.2.1",
19
- "firebase-functions": "^7.2.5",
19
+ "firebase-functions": "^7.3.2",
20
20
  "make-error": "^1.3.6",
21
21
  "@cantoo/pdf-lib": "^2.6.5",
22
- "sharp": "0.35.2"
22
+ "sharp": "0.35.4"
23
23
  },
24
24
  "exports": {
25
25
  "./package.json": "./package.json",
@@ -1,4 +1,4 @@
1
- import { type AppFormSpaceTypeConfigServiceRef, type DeleteFormSpaceParams, type ExpireAllExpiredFormSpacesParams, type ExpireAllExpiredFormSpacesResult, type FirestoreContextReference, type FormSpaceDocument, type FormSpaceFirestoreCollections, type FormSpaceId, type NotificationFirestoreCollections, type ProcessAllQueuedFormSpacesParams, type ProcessAllQueuedFormSpacesResult, type RemoveFormSpaceFileParams, type StorageFileFirestoreCollections, type SubmitFormSpaceParams, type SubmitFormSpaceResult, type CreateFormSpaceParams, type UpdateFormSpaceParams } from '@dereekb/firebase';
1
+ import { type AppFormSpaceTypeConfigServiceRef, type DeleteFormSpaceParams, type ExpireAllExpiredFormSpacesParams, type ExpireAllExpiredFormSpacesResult, type FirebaseAuthUserId, type FirestoreContextReference, type FormSpaceDocument, type FormSpaceFirestoreCollections, type FormSpaceId, type LockFormSpaceParams, type NotificationFirestoreCollections, type ProcessAllQueuedFormSpacesParams, type ProcessAllQueuedFormSpacesResult, type RemoveFormSpaceFileParams, type ReopenFormSpaceParams, type StorageFileFirestoreCollections, type SubmitFormSpaceParams, type SubmitFormSpaceResult, type CreateFormSpaceParams, type UpdateFormSpaceParams } from '@dereekb/firebase';
2
2
  import { type FirebaseServerActionsContext, type FirebaseServerAuthServiceRef } from '@dereekb/firebase-server';
3
3
  import { type Maybe, type Milliseconds } from '@dereekb/util';
4
4
  import { type TransformAndValidateFunctionResult } from '@dereekb/model';
@@ -69,6 +69,26 @@ export interface RemoveFormSpaceFileActionInput {
69
69
  */
70
70
  readonly uid: Maybe<string>;
71
71
  }
72
+ /**
73
+ * Extra input for {@link FormSpaceServerActions.reopenFormSpace}, supplied by the callable rather than by the
74
+ * caller: WHO reopened is recorded on `rby`, so it can never be a value in the request body.
75
+ */
76
+ export interface ReopenFormSpaceActionInput {
77
+ /**
78
+ * The uid of the caller.
79
+ */
80
+ readonly uid?: Maybe<FirebaseAuthUserId>;
81
+ }
82
+ /**
83
+ * Extra input for {@link FormSpaceServerActions.lockFormSpace}, on the same terms: `lby` records who made
84
+ * the submission final.
85
+ */
86
+ export interface LockFormSpaceActionInput {
87
+ /**
88
+ * The uid of the caller.
89
+ */
90
+ readonly uid?: Maybe<FirebaseAuthUserId>;
91
+ }
72
92
  /**
73
93
  * The server actions for the FormSpace model.
74
94
  *
@@ -78,6 +98,8 @@ export declare abstract class FormSpaceServerActions {
78
98
  abstract createFormSpace(params: CreateFormSpaceParams): Promise<TransformAndValidateFunctionResult<CreateFormSpaceParams, (input: CreateFormSpaceActionInput) => Promise<FormSpaceDocument>>>;
79
99
  abstract updateFormSpace(params: UpdateFormSpaceParams): Promise<TransformAndValidateFunctionResult<UpdateFormSpaceParams, (formSpaceDocument: FormSpaceDocument) => Promise<FormSpaceDocument>>>;
80
100
  abstract submitFormSpace(params: SubmitFormSpaceParams): Promise<TransformAndValidateFunctionResult<SubmitFormSpaceParams, (formSpaceDocument: FormSpaceDocument) => Promise<SubmitFormSpaceResult>>>;
101
+ abstract reopenFormSpace(params: ReopenFormSpaceParams): Promise<TransformAndValidateFunctionResult<ReopenFormSpaceParams, (formSpaceDocument: FormSpaceDocument, input: ReopenFormSpaceActionInput) => Promise<FormSpaceDocument>>>;
102
+ abstract lockFormSpace(params: LockFormSpaceParams): Promise<TransformAndValidateFunctionResult<LockFormSpaceParams, (formSpaceDocument: FormSpaceDocument, input: LockFormSpaceActionInput) => Promise<FormSpaceDocument>>>;
81
103
  abstract removeFormSpaceFile(params: RemoveFormSpaceFileParams): Promise<TransformAndValidateFunctionResult<RemoveFormSpaceFileParams, (formSpaceDocument: FormSpaceDocument, input: RemoveFormSpaceFileActionInput) => Promise<FormSpaceDocument>>>;
82
104
  abstract deleteFormSpace(params: DeleteFormSpaceParams): Promise<TransformAndValidateFunctionResult<DeleteFormSpaceParams, (formSpaceDocument: FormSpaceDocument) => Promise<void>>>;
83
105
  abstract processAllQueuedFormSpaces(params: ProcessAllQueuedFormSpacesParams): Promise<TransformAndValidateFunctionResult<ProcessAllQueuedFormSpacesParams, () => Promise<ProcessAllQueuedFormSpacesResult>>>;
@@ -119,10 +141,48 @@ export declare function updateFormSpaceFactory(context: FormSpaceServerActionsCo
119
141
  * would hold the lock across the whole handler. A crash in between leaves the space in
120
142
  * QUEUED_FOR_PROCESSING with no task, which {@link processAllQueuedFormSpacesFactory} is the backstop for.
121
143
  *
144
+ * Also serves a RESUBMISSION after a reopen, unchanged: the space is a draft again, so the same editable
145
+ * check and the same submit blockers apply. The only difference is that the task is keyed by the space's
146
+ * reopen count, so it gets a document and a checkpoint flow of its own instead of colliding with the
147
+ * finished task of the attempt before it.
148
+ *
122
149
  * @param context - The FormSpace server actions context.
123
150
  * @returns An async transform-and-validate function that submits a FormSpace.
124
151
  */
125
152
  export declare function submitFormSpaceFactory(context: FormSpaceServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<SubmitFormSpaceParams, (formSpaceDocument: FormSpaceDocument) => Promise<SubmitFormSpaceResult>, object, unknown>;
153
+ /**
154
+ * Factory for the `reopenFormSpace` action.
155
+ *
156
+ * The inverse of `submitFormSpace`, and deliberately NOT a widening of `isFormSpaceEditable`: it restores
157
+ * every condition that predicate tests instead, so update, upload, `removeFile` and a resubmit all come
158
+ * back with no further change anywhere.
159
+ *
160
+ * The reopen task story is handled by KEYING rather than cleanup. The superseded attempt's task document is
161
+ * left where it is: it is either already done and waiting for the notification cleanup sweep, or still
162
+ * pending and about to be fenced off by its own handler, which compares the count it was created with
163
+ * against the space's. Deleting it here would mean reaching into a Notification subcollection whose parent
164
+ * this action cannot reconstruct once the task's own cleanup has nulled `pn` — for no gain, since the
165
+ * resubmission keys a document of its own either way.
166
+ *
167
+ * @param context - The FormSpace server actions context.
168
+ * @returns An async transform-and-validate function that reopens a submitted FormSpace.
169
+ */
170
+ export declare function reopenFormSpaceFactory(context: FormSpaceServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<ReopenFormSpaceParams, (formSpaceDocument: FormSpaceDocument, input: ReopenFormSpaceActionInput) => Promise<FormSpaceDocument>, object, unknown>;
171
+ /**
172
+ * Factory for the `lockFormSpace` action.
173
+ *
174
+ * Not a state transition. The space stays exactly where it is and its processing is untouched; the only
175
+ * thing that moves is `lat`, brought forward to now so every reopen predicate answers false from here on.
176
+ *
177
+ * Accepts a reopened DRAFT as well as a SUBMITTED space — locking a draft that has been submitted before is
178
+ * how a reviewer says "the next submission is the last one", and it survives the resubmit because
179
+ * {@link submitFormSpaceTemplate} only writes `lat` for a space that has never been submitted. A space with
180
+ * no submission at all is the one case refused.
181
+ *
182
+ * @param context - The FormSpace server actions context.
183
+ * @returns An async transform-and-validate function that locks a FormSpace's submission.
184
+ */
185
+ export declare function lockFormSpaceFactory(context: FormSpaceServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<LockFormSpaceParams, (formSpaceDocument: FormSpaceDocument, input: LockFormSpaceActionInput) => Promise<FormSpaceDocument>, object, unknown>;
126
186
  /**
127
187
  * Factory for the `removeFormSpaceFile` action.
128
188
  *
@@ -144,16 +204,30 @@ export declare function submitFormSpaceFactory(context: FormSpaceServerActionsCo
144
204
  */
145
205
  export declare function removeFormSpaceFileFactory(context: FormSpaceServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<RemoveFormSpaceFileParams, (formSpaceDocument: FormSpaceDocument, input: RemoveFormSpaceFileActionInput) => Promise<FormSpaceDocument>, object, unknown>;
146
206
  /**
147
- * Creates (or re-runs) the unique submission task for a FormSpace and records its key on `pn`.
207
+ * Input for the function {@link _queueFormSpaceForProcessingFactory} returns.
208
+ */
209
+ export interface QueueFormSpaceForProcessingInput {
210
+ readonly formSpaceDocument: FormSpaceDocument;
211
+ /**
212
+ * The space's reopen count — the submission ATTEMPT to key the task by. Defaults to 0.
213
+ *
214
+ * Getting this wrong is not cosmetic: a resubmission keyed to attempt 0 resolves to the finished task of
215
+ * the first submission, which `createOrRunUniqueNotificationDocument` leaves exactly as it found it.
216
+ */
217
+ readonly reopenCount?: Maybe<number>;
218
+ readonly runImmediately?: Maybe<boolean>;
219
+ }
220
+ /**
221
+ * Creates (or re-runs) the unique submission task for one ATTEMPT of a FormSpace and records its key on `pn`.
148
222
  *
149
223
  * Shared by `submitFormSpace` and the queued backstop sweep, which is what makes the backstop safe to run
150
- * against a space whose task already exists: the task is unique per space, so a second attempt resolves to
151
- * the same document rather than racing a second processor.
224
+ * against a space whose task already exists: the task is unique per attempt, so a second call for the same
225
+ * attempt resolves to the same document rather than racing a second processor.
152
226
  *
153
227
  * @param context - The FormSpace server actions context.
154
228
  * @returns Queues one FormSpace, reporting the task key and whether this call created it.
155
229
  */
156
- export declare function _queueFormSpaceForProcessingFactory(context: FormSpaceServerActionsContext): (formSpaceDocument: FormSpaceDocument, runImmediately?: Maybe<boolean>) => Promise<SubmitFormSpaceResult>;
230
+ export declare function _queueFormSpaceForProcessingFactory(context: FormSpaceServerActionsContext): (input: QueueFormSpaceForProcessingInput) => Promise<SubmitFormSpaceResult>;
157
231
  /**
158
232
  * Factory for the `deleteFormSpace` action.
159
233
  *
@@ -12,6 +12,27 @@ export declare function formSpaceTypeNotRegisteredError(formSpaceType: FormSpace
12
12
  * @returns A precondition-conflict HttpsError with the FORM_SPACE_NOT_EDITABLE error code.
13
13
  */
14
14
  export declare function formSpaceNotEditableError(): import("firebase-functions/https").HttpsError;
15
+ /**
16
+ * Creates an error indicating the FormSpace has never been submitted, so there is no submission to lock.
17
+ *
18
+ * @returns A precondition-conflict HttpsError with the FORM_SPACE_NOT_SUBMITTED error code.
19
+ */
20
+ export declare function formSpaceNotSubmittedError(): import("firebase-functions/https").HttpsError;
21
+ /**
22
+ * Creates an error indicating the FormSpace's submission is final, so it cannot be reopened.
23
+ *
24
+ * @returns A precondition-conflict HttpsError with the FORM_SPACE_NOT_REOPENABLE error code.
25
+ */
26
+ export declare function formSpaceNotReopenableError(): import("firebase-functions/https").HttpsError;
27
+ /**
28
+ * Creates an error indicating the FormSpace's submission is being processed right now.
29
+ *
30
+ * Deliberately separate from {@link formSpaceNotReopenableError}: this one clears on its own, and telling
31
+ * a caller their submission is final when the processor is simply mid-run would be wrong.
32
+ *
33
+ * @returns A precondition-conflict HttpsError with the FORM_SPACE_PROCESSING_IN_PROGRESS error code.
34
+ */
35
+ export declare function formSpaceProcessingInProgressError(): import("firebase-functions/https").HttpsError;
15
36
  /**
16
37
  * Creates an error indicating a required upload slot is still empty at submission time.
17
38
  *
@@ -27,8 +27,9 @@ export interface FormSpaceSubmissionSubtaskInput<M extends FormSpaceSubmissionSu
27
27
  /**
28
28
  * Loads the FormSpace, memoized for the duration of one task run.
29
29
  *
30
- * A getter rather than the value: a processor whose first checkpoint never touches the form data should
31
- * not pay for a read, and a processor that touches it in three checkpoints should pay for one.
30
+ * Still a getter rather than the value, so a processor reads it the same way whether or not the handler
31
+ * happened to have it already. It resolves the snapshot the run's attempt fence was checked against, so
32
+ * every checkpoint in one run sees one consistent space.
32
33
  */
33
34
  readonly loadFormSpace: Getter<Promise<FormSpace>>;
34
35
  }
@@ -3,7 +3,7 @@ import { type NotificationTaskServiceTaskHandlerConfig } from '../notification/n
3
3
  import { type PromiseOrValue, type Maybe } from '@dereekb/util';
4
4
  import { type StorageFileQueueForDeleteTime } from './storagefile.util';
5
5
  import { type NotificationTaskSubtaskCleanupInstructions, type NotificationTaskSubtaskFlowEntry, type NotificationTaskSubtaskInput, type NotificationTaskSubtaskNotificationTaskHandlerConfig, type NotificationTaskSubtaskProcessorConfig } from '../notification/notification.task.subtask.handler';
6
- import archiver from 'archiver';
6
+ import { type Archiver, type ArchiverOptions } from 'archiver';
7
7
  /**
8
8
  * Input for a purpose-specific storage file processing subtask.
9
9
  *
@@ -132,9 +132,9 @@ export interface StorageFileGroupStorageFileZipConfigureZipArchiverOptionsInput
132
132
  readonly input: StorageFileProcessingPurposeSubtaskInput<StorageFileGroupZipStorageFileProcessingSubtaskMetadata, StorageFileGroupZipStorageFileProcessingSubtask>;
133
133
  readonly storageFileGroup: StorageFileGroup;
134
134
  }
135
- export type StorageFileGroupStorageFileZipConfigureZipArchiverOptionsFunction = (input: StorageFileGroupStorageFileZipConfigureZipArchiverOptionsInput) => PromiseOrValue<archiver.ArchiverOptions>;
135
+ export type StorageFileGroupStorageFileZipConfigureZipArchiverOptionsFunction = (input: StorageFileGroupStorageFileZipConfigureZipArchiverOptionsInput) => PromiseOrValue<ArchiverOptions>;
136
136
  export interface StorageFileGroupStorageFileZipFinalizeArchiveInput extends StorageFileGroupStorageFileZipConfigureZipArchiverOptionsInput {
137
- readonly archive: archiver.Archiver;
137
+ readonly archive: Archiver;
138
138
  }
139
139
  export type StorageFileGroupStorageFileZipFinalizeArchiveFunction = (input: StorageFileGroupStorageFileZipFinalizeArchiveInput) => Promise<void>;
140
140
  export interface StorageFileGroupStorageFileZipFileDisplayNameFunctionInput {