@dereekb/firebase-server 13.41.0 → 13.43.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 (37) hide show
  1. package/calcom/package.json +10 -10
  2. package/discord/package.json +10 -10
  3. package/index.esm.js +4 -13
  4. package/mailgun/package.json +9 -9
  5. package/mcp/index.esm.js +21 -33
  6. package/mcp/package.json +11 -11
  7. package/mcp/src/lib/service/mcp.manifest.d.ts +22 -0
  8. package/model/index.esm.js +18376 -13330
  9. package/model/package.json +9 -9
  10. package/model/src/lib/calendar/calendar.action.server.d.ts +123 -0
  11. package/model/src/lib/calendar/calendar.error.d.ts +22 -0
  12. package/model/src/lib/calendar/calendar.module.d.ts +69 -0
  13. package/model/src/lib/calendar/calendar.task.service.handler.d.ts +52 -0
  14. package/model/src/lib/calendar/index.d.ts +4 -0
  15. package/model/src/lib/formspace/formspace.action.server.d.ts +192 -0
  16. package/model/src/lib/formspace/formspace.error.d.ts +91 -0
  17. package/model/src/lib/formspace/formspace.module.d.ts +57 -0
  18. package/model/src/lib/formspace/formspace.task.service.handler.d.ts +97 -0
  19. package/model/src/lib/formspace/formspace.upload.initializer.d.ts +89 -0
  20. package/model/src/lib/formspace/formspace.validation.d.ts +174 -0
  21. package/model/src/lib/formspace/index.d.ts +6 -0
  22. package/model/src/lib/index.d.ts +2 -0
  23. package/model/src/lib/mailgun/index.d.ts +1 -0
  24. package/model/src/lib/mailgun/notification.send.service.mailgun.attachment.d.ts +40 -0
  25. package/model/src/lib/storagefile/storagefile.action.server.d.ts +11 -4
  26. package/model/src/lib/storagefile/storagefile.mcp.d.ts +38 -0
  27. package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +16 -0
  28. package/model/src/lib/system/index.d.ts +1 -0
  29. package/model/src/lib/system/system.scheduler.d.ts +144 -0
  30. package/oidc/index.esm.js +2 -2
  31. package/oidc/package.json +10 -10
  32. package/package.json +12 -12
  33. package/src/lib/storage/driver.accessor.d.ts +1 -1
  34. package/test/index.esm.js +2 -2
  35. package/test/package.json +11 -11
  36. package/twilio/package.json +8 -8
  37. package/zoho/package.json +10 -10
@@ -0,0 +1,144 @@
1
+ import { type FirestoreDocument, type SchedulerSystemStateRead, type SystemState, type SystemStateFirestoreCollectionLike, type SystemStateStoredData } from '@dereekb/firebase';
2
+ import { type Getter, type Hours, type Maybe } from '@dereekb/util';
3
+ /**
4
+ * Configuration for a single gate evaluation.
5
+ */
6
+ export interface SchedulerSystemStateGateConfig {
7
+ /**
8
+ * Run every Nth hour of the day.
9
+ *
10
+ * Matched by modulo against the hour-of-day, so only divisors of 24 divide the day evenly. See
11
+ * `isNthHourOfDay()` in `@dereekb/firebase`.
12
+ */
13
+ readonly everyNHours: Hours;
14
+ }
15
+ /**
16
+ * The outcome of a {@link SchedulerSystemStateAccessor.checkAndClaim} call.
17
+ *
18
+ * Extends {@link SchedulerSystemStateRead}, so past the pass/fail answer it is also the read the
19
+ * decision was made from: the same `now`, the same hour-of-day, and the same bound predicates. That
20
+ * is what lets a single hourly claim fan out into per-task sub-gates without a second read or a
21
+ * second clock —
22
+ *
23
+ * ```ts
24
+ * const gate = await schedulerSystemState.checkAndClaim({ everyNHours: 1 });
25
+ *
26
+ * if (!gate.claimed) {
27
+ * return;
28
+ * }
29
+ *
30
+ * await hourlyWork();
31
+ *
32
+ * if (gate.isNthHourOfDay(3)) {
33
+ * await everyThreeHoursWork();
34
+ * }
35
+ * ```
36
+ *
37
+ * NOTE: this is an object, so it is ALWAYS truthy. `if (await checkAndClaim(...))` always passes —
38
+ * branch on {@link SchedulerSystemStateClaim.claimed}.
39
+ *
40
+ * The inherited {@link SchedulerSystemStateRead} members describe the state as it was read BEFORE
41
+ * the claim was stamped, deliberately: `lastRunAt` is the previous claim, `hasRunInCurrentHour` is
42
+ * false on a successful claim, and `isOpen()` still answers for the other intervals this hour rather
43
+ * than reporting closed against the claim this very call just wrote.
44
+ */
45
+ export interface SchedulerSystemStateClaim extends SchedulerSystemStateRead {
46
+ /**
47
+ * The interval the claim was evaluated for.
48
+ */
49
+ readonly everyNHours: Hours;
50
+ /**
51
+ * Whether THIS call claimed the hour, and so whether the caller may run its work.
52
+ */
53
+ readonly claimed: boolean;
54
+ /**
55
+ * The moment stamped as the new `lat`, or null when the gate was closed and nothing was written.
56
+ *
57
+ * Always equal to {@link SchedulerSystemStateRead.now} when {@link claimed} is true.
58
+ */
59
+ readonly claimedAt: Maybe<Date>;
60
+ }
61
+ /**
62
+ * Reads and claims the scheduler's hourly run gate.
63
+ */
64
+ export interface SchedulerSystemStateAccessor {
65
+ /**
66
+ * Reads the gate state without claiming it.
67
+ *
68
+ * @returns The state, which can be evaluated against any number of intervals.
69
+ */
70
+ read(): Promise<SchedulerSystemStateRead>;
71
+ /**
72
+ * Reads, evaluates the gate for the given interval, and CLAIMS the hour, in one transaction.
73
+ *
74
+ * The claim is stamped BEFORE this resolves, deliberately: a crash or a function timeout in the
75
+ * caller's work must still cost the whole window. Otherwise the hourly cron degrades into an
76
+ * hourly retry loop against work that is already failing.
77
+ *
78
+ * Remember that one gate is one `lat`. Two callers with different `everyNHours` sharing the
79
+ * document will have whichever one passes first claim the hour for BOTH — the second gets
80
+ * `claimed: false` even if its own interval matched. That is the intended semantics of a single
81
+ * gate, but it is the thing a future second caller will trip over. Prefer claiming ONCE at the top
82
+ * of the schedule function and sub-gating the individual tasks off the returned
83
+ * {@link SchedulerSystemStateClaim}.
84
+ *
85
+ * @param config - The interval to evaluate.
86
+ * @returns The claim outcome, which also carries the read it was decided from.
87
+ */
88
+ checkAndClaim(config: SchedulerSystemStateGateConfig): Promise<SchedulerSystemStateClaim>;
89
+ }
90
+ /**
91
+ * Configuration for {@link schedulerSystemStateAccessorFactory}.
92
+ */
93
+ export interface SchedulerSystemStateAccessorFactoryConfig {
94
+ /**
95
+ * Clock used to evaluate the gate and to stamp `lat`. Defaults to the current time.
96
+ *
97
+ * Overriding it is what lets a test place "now" at a specific hour-of-day — the gate is a
98
+ * modulo against the hour, so there is otherwise no way to exercise a non-matching hour without
99
+ * waiting for one.
100
+ */
101
+ readonly nowFactory?: Maybe<Getter<Date>>;
102
+ }
103
+ /**
104
+ * Creates a {@link SchedulerSystemStateAccessor} for a SystemState collection.
105
+ */
106
+ export type SchedulerSystemStateAccessorFactory = <D extends FirestoreDocument<SystemState<SystemStateStoredData>>>(systemStateCollection: SystemStateFirestoreCollectionLike<SystemStateStoredData, D>) => SchedulerSystemStateAccessor;
107
+ /**
108
+ * Creates a {@link SchedulerSystemStateAccessorFactory}, the Firestore-backed half of the scheduler's
109
+ * hourly run gate.
110
+ *
111
+ * The gate answers "should the scheduler run its Nth-hour body during this hour?" for the app as a
112
+ * whole, off the single `lat` on the `sys/scheduler` document. Claim it ONCE at the top of a
113
+ * schedule function; the individual tasks it guards carry no throttle of their own and sub-gate off
114
+ * the returned {@link SchedulerSystemStateClaim} instead.
115
+ *
116
+ * The collection MUST have `schedulerSystemDataConverter` registered under
117
+ * {@link SCHEDULER_SYSTEM_STATE_TYPE}. Without it the collection falls back to the pass-through
118
+ * converter and `lat` reads back as a raw Firestore `Timestamp`, which no hour comparison can match —
119
+ * so the gate would silently open on every call. {@link SchedulerSystemStateAccessor.read} and
120
+ * `checkAndClaim` throw on that rather than let it through.
121
+ *
122
+ * @param config - The clock override, if any.
123
+ * @returns A factory producing an accessor over a given SystemState collection.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const schedulerSystemState = schedulerSystemStateAccessorFactory()(systemStateCollection);
128
+ *
129
+ * export const hourlySchedule: MyScheduleFunction = async (request) => {
130
+ * const gate = await schedulerSystemState.checkAndClaim({ everyNHours: 1 });
131
+ *
132
+ * if (!gate.claimed) {
133
+ * return;
134
+ * }
135
+ *
136
+ * await hourlyWork();
137
+ *
138
+ * if (gate.isNthHourOfDay(3)) {
139
+ * await everyThreeHoursWork();
140
+ * }
141
+ * };
142
+ * ```
143
+ */
144
+ export declare function schedulerSystemStateAccessorFactory(config?: Maybe<SchedulerSystemStateAccessorFactoryConfig>): SchedulerSystemStateAccessorFactory;
package/oidc/index.esm.js CHANGED
@@ -3625,7 +3625,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
3625
3625
  * @returns The union of config-level and profile-level admin-only scopes.
3626
3626
  */ function adminOnlyScopesForOidcProviderConfig(providerConfig) {
3627
3627
  var _providerConfig_adminOnlyScopes, _providerConfig_providerProfiles;
3628
- return new Set(_to_consumable_array$5((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array$5(adminOnlyScopesForOidcProviderProfiles((_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : []))));
3628
+ return new Set(_to_consumable_array$5((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array$5(Array.from(adminOnlyScopesForOidcProviderProfiles((_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : [])))));
3629
3629
  }
3630
3630
 
3631
3631
  /**
@@ -6571,7 +6571,7 @@ var OidcInteractionController_1;
6571
6571
  effectiveOIDCScopes = resolveEffectiveSubset({
6572
6572
  missing: missingOIDCScope,
6573
6573
  requestedSubset: body.grantedOIDCScopes,
6574
- alwaysGranted: _to_consumable_array$1(ALWAYS_GRANTED_OIDC_SCOPES).concat(_to_consumable_array$1(clientRequiredScopes)),
6574
+ alwaysGranted: _to_consumable_array$1(ALWAYS_GRANTED_OIDC_SCOPES).concat(_to_consumable_array$1(Array.from(clientRequiredScopes))),
6575
6575
  alreadyEncountered: encounteredOIDCScopes
6576
6576
  });
6577
6577
  // Scopes the existing Grant already holds (granted, minus any it rejected). Nothing here revokes
package/oidc/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/oidc",
3
- "version": "13.41.0",
3
+ "version": "13.43.0",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
- "@dereekb/analytics": "13.41.0",
7
- "@dereekb/date": "13.41.0",
8
- "@dereekb/firebase": "13.41.0",
9
- "@dereekb/firebase-server": "13.41.0",
10
- "@dereekb/model": "13.41.0",
11
- "@dereekb/nestjs": "13.41.0",
12
- "@dereekb/rxjs": "13.41.0",
13
- "@dereekb/util": "13.41.0",
14
- "@dereekb/zoho": "13.41.0",
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
+ "@dereekb/zoho": "13.43.0",
15
15
  "@nestjs/common": "^11.1.19",
16
16
  "@nestjs/config": "^4.0.4",
17
17
  "express": "^5.2.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server",
3
- "version": "13.41.0",
3
+ "version": "13.43.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -58,17 +58,17 @@
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@cantoo/pdf-lib": "^2.6.5",
61
- "@dereekb/analytics": "13.41.0",
62
- "@dereekb/calcom": "13.41.0",
63
- "@dereekb/date": "13.41.0",
64
- "@dereekb/dbx-core": "13.41.0",
65
- "@dereekb/discord": "13.41.0",
66
- "@dereekb/firebase": "13.41.0",
67
- "@dereekb/model": "13.41.0",
68
- "@dereekb/nestjs": "13.41.0",
69
- "@dereekb/rxjs": "13.41.0",
70
- "@dereekb/util": "13.41.0",
71
- "@dereekb/zoho": "13.41.0",
61
+ "@dereekb/analytics": "13.43.0",
62
+ "@dereekb/calcom": "13.43.0",
63
+ "@dereekb/date": "13.43.0",
64
+ "@dereekb/dbx-core": "13.43.0",
65
+ "@dereekb/discord": "13.43.0",
66
+ "@dereekb/firebase": "13.43.0",
67
+ "@dereekb/model": "13.43.0",
68
+ "@dereekb/nestjs": "13.43.0",
69
+ "@dereekb/rxjs": "13.43.0",
70
+ "@dereekb/util": "13.43.0",
71
+ "@dereekb/zoho": "13.43.0",
72
72
  "@google-cloud/firestore": "^7.11.6",
73
73
  "@google-cloud/storage": "^7.19.0",
74
74
  "@modelcontextprotocol/node": "2.0.0",
@@ -20,7 +20,7 @@ export declare function googleCloudStorageFileForStorageFilePath(storage: Google
20
20
  /**
21
21
  * Server-side file accessor type that guarantees stream operations are available.
22
22
  */
23
- export type GoogleCloudStorageAccessorFile = FirebaseStorageAccessorFile<GoogleCloudFile> & Required<Pick<FirebaseStorageAccessorFile<GoogleCloudFile>, 'uploadStream' | 'getStream'>>;
23
+ export type GoogleCloudStorageAccessorFile = FirebaseStorageAccessorFile<GoogleCloudFile> & Required<Pick<FirebaseStorageAccessorFile<GoogleCloudFile>, 'uploadStream' | 'getStream' | 'getPublicUrl'>>;
24
24
  /**
25
25
  * Converts Google Cloud Storage {@link FileMetadata} into the normalized {@link StorageMetadata} format.
26
26
  *
package/test/index.esm.js CHANGED
@@ -4952,7 +4952,7 @@ function _ts_generator$1(thisArg, body) {
4952
4952
  }
4953
4953
  }
4954
4954
  function cookieHeader() {
4955
- return _to_consumable_array(cookieJar.values()).join('; ');
4955
+ return Array.from(cookieJar.values()).join('; ');
4956
4956
  }
4957
4957
  return {
4958
4958
  collectCookies: collectCookies,
@@ -4990,7 +4990,7 @@ function _ts_generator$1(thisArg, body) {
4990
4990
  accountService = nestApp.get(OidcAccountService);
4991
4991
  providerConfig = accountService.providerConfig;
4992
4992
  providerProfiles = (_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : [];
4993
- adminOnlyScopes = new Set(_to_consumable_array((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array(adminOnlyScopesForOidcProviderProfiles(providerProfiles))));
4993
+ adminOnlyScopes = new Set(_to_consumable_array((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array(Array.from(adminOnlyScopesForOidcProviderProfiles(providerProfiles)))));
4994
4994
  profileGatedScopes = assignmentOnlyScopesForOidcProviderProfiles(providerProfiles);
4995
4995
  result = Object.keys(providerConfig.claims).filter(function(scope) {
4996
4996
  return !adminOnlyScopes.has(scope) && !profileGatedScopes.has(scope);
package/test/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/test",
3
- "version": "13.41.0",
3
+ "version": "13.43.0",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
- "@dereekb/analytics": "13.41.0",
7
- "@dereekb/date": "13.41.0",
8
- "@dereekb/firebase": "13.41.0",
9
- "@dereekb/firebase-server": "13.41.0",
10
- "@dereekb/firebase-server/oidc": "13.41.0",
11
- "@dereekb/model": "13.41.0",
12
- "@dereekb/nestjs": "13.41.0",
13
- "@dereekb/rxjs": "13.41.0",
14
- "@dereekb/util": "13.41.0",
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/firebase-server/oidc": "13.43.0",
11
+ "@dereekb/model": "13.43.0",
12
+ "@dereekb/nestjs": "13.43.0",
13
+ "@dereekb/rxjs": "13.43.0",
14
+ "@dereekb/util": "13.43.0",
15
15
  "@google-cloud/firestore": "^7.11.6",
16
16
  "@google-cloud/storage": "^7.19.0",
17
17
  "@nestjs/common": "^11.1.19",
@@ -24,7 +24,7 @@
24
24
  "supertest": "^7.2.2"
25
25
  },
26
26
  "devDependencies": {
27
- "@dereekb/nestjs": "13.41.0"
27
+ "@dereekb/nestjs": "13.43.0"
28
28
  },
29
29
  "exports": {
30
30
  "./package.json": "./package.json",
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/twilio",
3
- "version": "13.41.0",
3
+ "version": "13.43.0",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
- "@dereekb/date": "13.41.0",
7
- "@dereekb/firebase": "13.41.0",
8
- "@dereekb/firebase-server": "13.41.0",
9
- "@dereekb/model": "13.41.0",
10
- "@dereekb/nestjs": "13.41.0",
11
- "@dereekb/rxjs": "13.41.0",
12
- "@dereekb/util": "13.41.0"
6
+ "@dereekb/date": "13.43.0",
7
+ "@dereekb/firebase": "13.43.0",
8
+ "@dereekb/firebase-server": "13.43.0",
9
+ "@dereekb/model": "13.43.0",
10
+ "@dereekb/nestjs": "13.43.0",
11
+ "@dereekb/rxjs": "13.43.0",
12
+ "@dereekb/util": "13.43.0"
13
13
  },
14
14
  "exports": {
15
15
  "./package.json": "./package.json",
package/zoho/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/zoho",
3
- "version": "13.41.0",
3
+ "version": "13.43.0",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
- "@dereekb/analytics": "13.41.0",
7
- "@dereekb/date": "13.41.0",
8
- "@dereekb/model": "13.41.0",
9
- "@dereekb/nestjs": "13.41.0",
10
- "@dereekb/rxjs": "13.41.0",
11
- "@dereekb/firebase": "13.41.0",
12
- "@dereekb/firebase-server": "13.41.0",
13
- "@dereekb/util": "13.41.0",
14
- "@dereekb/zoho": "13.41.0",
6
+ "@dereekb/analytics": "13.43.0",
7
+ "@dereekb/date": "13.43.0",
8
+ "@dereekb/model": "13.43.0",
9
+ "@dereekb/nestjs": "13.43.0",
10
+ "@dereekb/rxjs": "13.43.0",
11
+ "@dereekb/firebase": "13.43.0",
12
+ "@dereekb/firebase-server": "13.43.0",
13
+ "@dereekb/util": "13.43.0",
14
+ "@dereekb/zoho": "13.43.0",
15
15
  "@nestjs/common": "^11.1.19",
16
16
  "@nestjs/config": "^4.0.4",
17
17
  "express": "^5.2.1"