@dereekb/firebase 13.2.2 → 13.3.1

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 (135) hide show
  1. package/index.cjs.js +12893 -4062
  2. package/index.esm.js +12872 -4065
  3. package/package.json +5 -5
  4. package/src/lib/client/error/error.d.ts +18 -3
  5. package/src/lib/client/firestore/array.d.ts +16 -3
  6. package/src/lib/client/firestore/driver.accessor.batch.d.ts +35 -4
  7. package/src/lib/client/firestore/driver.accessor.create.d.ts +15 -0
  8. package/src/lib/client/firestore/driver.accessor.d.ts +15 -0
  9. package/src/lib/client/firestore/driver.accessor.default.d.ts +32 -0
  10. package/src/lib/client/firestore/driver.accessor.transaction.d.ts +35 -4
  11. package/src/lib/client/firestore/driver.d.ts +16 -0
  12. package/src/lib/client/firestore/driver.query.d.ts +36 -0
  13. package/src/lib/client/firestore/firestore.d.ts +11 -1
  14. package/src/lib/client/firestore/increment.d.ts +12 -3
  15. package/src/lib/client/function/development.function.factory.d.ts +27 -2
  16. package/src/lib/client/function/error.d.ts +27 -0
  17. package/src/lib/client/function/function.callable.d.ts +50 -5
  18. package/src/lib/client/function/function.factory.d.ts +70 -4
  19. package/src/lib/client/function/model.function.factory.d.ts +64 -9
  20. package/src/lib/client/storage/driver.accessor.d.ts +93 -0
  21. package/src/lib/client/storage/driver.d.ts +15 -0
  22. package/src/lib/client/storage/storage.d.ts +10 -1
  23. package/src/lib/common/auth/auth.context.d.ts +17 -2
  24. package/src/lib/common/auth/auth.d.ts +38 -9
  25. package/src/lib/common/auth/auth.error.d.ts +25 -0
  26. package/src/lib/common/auth/auth.server.error.d.ts +6 -2
  27. package/src/lib/common/development/function.d.ts +17 -6
  28. package/src/lib/common/development/function.schedule.d.ts +30 -1
  29. package/src/lib/common/firestore/accessor/accessor.wrap.modify.d.ts +36 -12
  30. package/src/lib/common/firestore/accessor/array.d.ts +14 -4
  31. package/src/lib/common/firestore/accessor/document.d.ts +77 -2
  32. package/src/lib/common/firestore/accessor/increment.d.ts +15 -3
  33. package/src/lib/common/firestore/collection/collection.d.ts +22 -4
  34. package/src/lib/common/firestore/collection/collection.util.d.ts +12 -2
  35. package/src/lib/common/firestore/driver/accessor.d.ts +28 -1
  36. package/src/lib/common/firestore/driver/batch.d.ts +6 -4
  37. package/src/lib/common/firestore/driver/driver.d.ts +18 -1
  38. package/src/lib/common/firestore/driver/query.d.ts +20 -1
  39. package/src/lib/common/firestore/driver/query.handler.d.ts +23 -0
  40. package/src/lib/common/firestore/driver/transaction.d.ts +18 -6
  41. package/src/lib/common/firestore/error.d.ts +16 -4
  42. package/src/lib/common/firestore/query/iterator.d.ts +11 -0
  43. package/src/lib/common/firestore/reference.d.ts +11 -6
  44. package/src/lib/common/firestore/snapshot/snapshot.d.ts +4 -0
  45. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +263 -63
  46. package/src/lib/common/firestore/types.d.ts +39 -1
  47. package/src/lib/common/firestore/util/id.batch.d.ts +55 -3
  48. package/src/lib/common/function/action.d.ts +35 -0
  49. package/src/lib/common/model/context.d.ts +11 -1
  50. package/src/lib/common/model/function.d.ts +45 -9
  51. package/src/lib/common/model/model/model.loader.d.ts +37 -0
  52. package/src/lib/common/model/model/model.param.d.ts +24 -2
  53. package/src/lib/common/model/model.service.d.ts +126 -4
  54. package/src/lib/common/model/permission/permission.context.d.ts +15 -0
  55. package/src/lib/common/model/permission/permission.d.ts +16 -0
  56. package/src/lib/common/model/permission/permission.service.d.ts +24 -1
  57. package/src/lib/common/model/permission/permission.service.grant.d.ts +72 -28
  58. package/src/lib/common/model/permission/permission.service.role.d.ts +15 -0
  59. package/src/lib/common/storage/accessor/path.model.d.ts +25 -8
  60. package/src/lib/common/storage/context.d.ts +23 -6
  61. package/src/lib/common/storage/driver/accessor.d.ts +15 -4
  62. package/src/lib/common/storage/driver/accessor.iterate.d.ts +31 -8
  63. package/src/lib/common/storage/driver/accessor.util.d.ts +13 -6
  64. package/src/lib/common/storage/driver/driver.d.ts +10 -1
  65. package/src/lib/common/storage/driver/error.d.ts +16 -0
  66. package/src/lib/common/storage/driver/list.d.ts +30 -0
  67. package/src/lib/common/storage/storage.d.ts +76 -19
  68. package/src/lib/common/storage/types.d.ts +23 -5
  69. package/src/lib/model/index.d.ts +1 -0
  70. package/src/lib/model/notification/notification.action.d.ts +8 -0
  71. package/src/lib/model/notification/notification.api.d.ts +26 -0
  72. package/src/lib/model/notification/notification.api.error.d.ts +15 -0
  73. package/src/lib/model/notification/notification.api.util.d.ts +27 -12
  74. package/src/lib/model/notification/notification.config.d.ts +193 -64
  75. package/src/lib/model/notification/notification.create.d.ts +62 -13
  76. package/src/lib/model/notification/notification.create.task.d.ts +25 -4
  77. package/src/lib/model/notification/notification.d.ts +258 -99
  78. package/src/lib/model/notification/notification.details.d.ts +66 -18
  79. package/src/lib/model/notification/notification.id.d.ts +90 -12
  80. package/src/lib/model/notification/notification.item.d.ts +57 -16
  81. package/src/lib/model/notification/notification.message.d.ts +84 -18
  82. package/src/lib/model/notification/notification.query.d.ts +21 -24
  83. package/src/lib/model/notification/notification.send.d.ts +38 -5
  84. package/src/lib/model/notification/notification.task.d.ts +87 -16
  85. package/src/lib/model/notification/notification.task.subtask.d.ts +42 -13
  86. package/src/lib/model/notification/notification.util.d.ts +68 -18
  87. package/src/lib/model/oidcmodel/index.d.ts +8 -0
  88. package/src/lib/model/oidcmodel/oidcmodel.action.d.ts +37 -0
  89. package/src/lib/model/oidcmodel/oidcmodel.api.d.ts +131 -0
  90. package/src/lib/model/oidcmodel/oidcmodel.d.ts +114 -0
  91. package/src/lib/model/oidcmodel/oidcmodel.data.d.ts +17 -0
  92. package/src/lib/model/oidcmodel/oidcmodel.id.d.ts +18 -0
  93. package/src/lib/model/oidcmodel/oidcmodel.interaction.d.ts +40 -0
  94. package/src/lib/model/oidcmodel/oidcmodel.interaction.oauth.d.ts +73 -0
  95. package/src/lib/model/oidcmodel/oidcmodel.query.d.ts +21 -0
  96. package/src/lib/model/storagefile/storagefile.action.d.ts +47 -0
  97. package/src/lib/model/storagefile/storagefile.api.d.ts +54 -4
  98. package/src/lib/model/storagefile/storagefile.create.d.ts +40 -3
  99. package/src/lib/model/storagefile/storagefile.d.ts +153 -16
  100. package/src/lib/model/storagefile/storagefile.file.d.ts +22 -7
  101. package/src/lib/model/storagefile/storagefile.group.d.ts +30 -1
  102. package/src/lib/model/storagefile/storagefile.group.processing.d.ts +20 -2
  103. package/src/lib/model/storagefile/storagefile.id.d.ts +44 -5
  104. package/src/lib/model/storagefile/storagefile.permission.d.ts +23 -4
  105. package/src/lib/model/storagefile/storagefile.query.d.ts +63 -11
  106. package/src/lib/model/storagefile/storagefile.task.d.ts +47 -4
  107. package/src/lib/model/storagefile/storagefile.upload.claims.d.ts +21 -4
  108. package/src/lib/model/storagefile/storagefile.upload.d.ts +41 -9
  109. package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +112 -20
  110. package/src/lib/model/storagefile/storagefile.util.d.ts +66 -3
  111. package/src/lib/model/system/system.action.d.ts +25 -0
  112. package/src/lib/model/system/system.d.ts +80 -4
  113. package/src/lib/model/user.d.ts +8 -2
  114. package/test/index.cjs.js +11168 -3295
  115. package/test/index.esm.js +11176 -3303
  116. package/test/package.json +6 -6
  117. package/test/src/lib/client/firebase.authorized.d.ts +18 -0
  118. package/test/src/lib/client/firebase.d.ts +60 -0
  119. package/test/src/lib/common/firebase.instance.d.ts +21 -0
  120. package/test/src/lib/common/firestore/firestore.d.ts +40 -0
  121. package/test/src/lib/common/firestore/firestore.instance.d.ts +16 -0
  122. package/test/src/lib/common/firestore/test.driver.accessor.d.ts +39 -2
  123. package/test/src/lib/common/firestore/test.driver.utility.d.ts +8 -2
  124. package/test/src/lib/common/firestore/test.iterator.d.ts +7 -2
  125. package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +29 -1
  126. package/test/src/lib/common/mock/mock.item.d.ts +219 -5
  127. package/test/src/lib/common/mock/mock.item.id.d.ts +6 -0
  128. package/test/src/lib/common/mock/mock.item.query.d.ts +12 -0
  129. package/test/src/lib/common/mock/mock.item.service.d.ts +60 -0
  130. package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +28 -1
  131. package/test/src/lib/common/storage/storage.d.ts +30 -0
  132. package/test/src/lib/common/storage/storage.instance.d.ts +22 -0
  133. package/test/src/lib/common/storage/test.driver.accessor.d.ts +7 -2
  134. package/index.cjs.js.map +0 -1
  135. package/index.esm.js.map +0 -1
@@ -0,0 +1,131 @@
1
+ import { type Type } from 'arktype';
2
+ import { type TargetModelParams, type OnCallCreateModelResult } from '../../common';
3
+ import { type InferredTargetModelParams } from '../../common/model/model/model.param';
4
+ import { type ModelFirebaseCrudFunction, type FirebaseFunctionTypeConfigMap, type ModelFirebaseCrudFunctionConfigMap, type ModelFirebaseFunctionMap, type ModelFirebaseCreateFunction, type ModelFirebaseDeleteFunction, type ModelFirebaseUpdateFunction } from '../../client';
5
+ import { type WebsiteUrlWithPrefix, type Maybe } from '@dereekb/util';
6
+ import { type OidcEntryClientId } from './oidcmodel.id';
7
+ import { type OidcModelTypes } from './oidcmodel';
8
+ import { type OidcRedirectUri, type OidcTokenEndpointAuthMethod } from './oidcmodel.interaction';
9
+ /**
10
+ * Fields that can be changed on an existing OIDC client.
11
+ *
12
+ * Does NOT include `token_endpoint_auth_method` — that is immutable after creation.
13
+ */
14
+ export interface UpdateOidcClientFieldParams {
15
+ readonly client_name: string;
16
+ readonly redirect_uris: OidcRedirectUri[];
17
+ readonly logo_uri?: Maybe<WebsiteUrlWithPrefix>;
18
+ readonly client_uri?: Maybe<WebsiteUrlWithPrefix>;
19
+ }
20
+ export declare const updateOidcClientFieldParamsType: Type<UpdateOidcClientFieldParams>;
21
+ export declare const createOidcClientFieldParamsType: import("arktype/internal/variants/object.ts").ObjectType<{
22
+ readonly client_name: string;
23
+ readonly redirect_uris: OidcRedirectUri[];
24
+ readonly logo_uri?: Maybe<string>;
25
+ readonly client_uri?: Maybe<string>;
26
+ token_endpoint_auth_method: "client_secret_basic" | "client_secret_post" | "client_secret_jwt" | "private_key_jwt";
27
+ }, {}>;
28
+ /**
29
+ * Parameters for registering a new OAuth client for the target entity.
30
+ *
31
+ * If no target model is provided, assumes the current user.
32
+ *
33
+ * The server generates `client_id` and `client_secret` and creates the adapter entry.
34
+ *
35
+ * Extends {@link UpdateOidcClientFieldParams} with `token_endpoint_auth_method` which is immutable after creation.
36
+ */
37
+ export interface CreateOidcClientParams extends UpdateOidcClientFieldParams, InferredTargetModelParams {
38
+ readonly token_endpoint_auth_method: OidcTokenEndpointAuthMethod;
39
+ /**
40
+ * URL where the client's public JSON Web Key Set can be fetched.
41
+ *
42
+ * Used with `private_key_jwt` authentication so the provider can retrieve
43
+ * the client's public keys to verify `client_assertion` JWTs.
44
+ * The client manages key rotation at this URL independently.
45
+ */
46
+ readonly jwks_uri?: WebsiteUrlWithPrefix;
47
+ }
48
+ export declare const createOidcClientParamsType: Type<CreateOidcClientParams>;
49
+ /**
50
+ * Result of creating a new OAuth client.
51
+ *
52
+ * Includes the generated `client_secret` in plaintext — this is the only time
53
+ * it is returned to the caller.
54
+ */
55
+ export interface CreateOidcClientResult extends OnCallCreateModelResult {
56
+ readonly client_id: OidcEntryClientId;
57
+ readonly client_secret: string;
58
+ }
59
+ /**
60
+ * Parameters for updating an existing OAuth client.
61
+ *
62
+ * Uses {@link UpdateOidcClientFieldParams} — `token_endpoint_auth_method` is immutable.
63
+ */
64
+ export interface UpdateOidcClientParams extends UpdateOidcClientFieldParams, TargetModelParams {
65
+ }
66
+ export declare const updateOidcClientParamsType: Type<UpdateOidcClientParams>;
67
+ export type RotateOidcClientSecretParams = TargetModelParams;
68
+ export declare const rotateOidcClientSecretParamsType: Type<RotateOidcClientSecretParams>;
69
+ export type RotateOidcClientSecretResult = Pick<CreateOidcClientResult, 'client_id' | 'client_secret'>;
70
+ /**
71
+ * Parameters for revoking/deleting an OAuth client.
72
+ */
73
+ export type DeleteOidcClientParams = TargetModelParams;
74
+ export declare const deleteOidcClientParamsType: Type<DeleteOidcClientParams>;
75
+ /**
76
+ * Custom (non-CRUD) function type map for OIDC.
77
+ */
78
+ export type OidcModelFunctionTypeMap = {};
79
+ export declare const oidcFunctionTypeConfigMap: FirebaseFunctionTypeConfigMap<OidcModelFunctionTypeMap>;
80
+ /**
81
+ * CRUD function configuration map for the OIDC client model.
82
+ *
83
+ * Uses `oidcEntry` as the key, matching the adapter collection identity.
84
+ */
85
+ export type OidcModelCrudFunctionsConfig = {
86
+ readonly oidcEntry: {
87
+ create: {
88
+ client: [CreateOidcClientParams, CreateOidcClientResult];
89
+ };
90
+ update: {
91
+ client: UpdateOidcClientParams;
92
+ rotateClientSecret: [RotateOidcClientSecretParams, RotateOidcClientSecretResult];
93
+ };
94
+ delete: {
95
+ client: DeleteOidcClientParams;
96
+ };
97
+ };
98
+ };
99
+ export declare const oidcModelCrudFunctionsConfig: ModelFirebaseCrudFunctionConfigMap<OidcModelCrudFunctionsConfig, OidcModelTypes>;
100
+ /**
101
+ * Abstract class defining all callable OIDC cloud functions.
102
+ *
103
+ * Implement this in your app module to wire up the function endpoints.
104
+ */
105
+ export declare abstract class OidcModelFunctions implements ModelFirebaseFunctionMap<OidcModelFunctionTypeMap, OidcModelCrudFunctionsConfig> {
106
+ abstract oidcEntry: {
107
+ createOidcEntry: {
108
+ client: ModelFirebaseCreateFunction<CreateOidcClientParams, CreateOidcClientResult>;
109
+ };
110
+ updateOidcEntry: {
111
+ client: ModelFirebaseCrudFunction<UpdateOidcClientParams>;
112
+ rotateClientSecret: ModelFirebaseUpdateFunction<RotateOidcClientSecretParams, RotateOidcClientSecretResult>;
113
+ };
114
+ deleteOidcEntry: {
115
+ client: ModelFirebaseDeleteFunction<DeleteOidcClientParams>;
116
+ };
117
+ };
118
+ }
119
+ /**
120
+ * Client-side callable function map factory for OIDC client CRUD operations.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const functions = oidcFunctionMap(callableFactory);
125
+ * const result = await functions.oidcEntry.createOidcEntry.create({
126
+ * client_name: 'My App',
127
+ * redirect_uris: ['https://myapp.com/callback']
128
+ * });
129
+ * ```
130
+ */
131
+ export declare const oidcModelFunctionMap: import("../..").ModelFirebaseFunctionMapFactory<OidcModelFunctionTypeMap, OidcModelCrudFunctionsConfig>;
@@ -0,0 +1,114 @@
1
+ import { type JsonSerializableObject, type Maybe } from '@dereekb/util';
2
+ import { AbstractFirestoreDocument, type CollectionReference, type FirestoreCollection, type FirestoreContext, type FirebaseAuthOwnershipKey } from '../../common';
3
+ import { type GrantedDeleteRole, type GrantedReadRole, type GrantedUpdateRole } from '@dereekb/model';
4
+ /**
5
+ * Union of model identity types used in the OIDC function map.
6
+ */
7
+ export type OidcModelTypes = typeof oidcEntryIdentity;
8
+ /**
9
+ * Abstract class providing access to all oidc-related Firestore collections.
10
+ *
11
+ * Implementations provide concrete collection instances wired to a specific {@link FirestoreContext}.
12
+ * Used by both client and server code to access oidc model documents.
13
+ *
14
+ * @see `OidcModelServerActions` in `@dereekb/firebase-server/oidc` for server-side action processing
15
+ */
16
+ export declare abstract class OidcModelFirestoreCollections {
17
+ abstract readonly oidcEntryCollection: OidcEntryFirestoreCollection;
18
+ }
19
+ /**
20
+ * Firestore model identity for {@link OidcEntry} documents.
21
+ *
22
+ * Collection name: `oidcEntry`, short code: `oidc_e`.
23
+ */
24
+ export declare const oidcEntryIdentity: import("../..").RootFirestoreModelIdentity<"oidcEntry", "oidc_e">;
25
+ /**
26
+ * Known oidc-provider model types stored in the adapter collection.
27
+ *
28
+ * Used as the discriminator in the {@link OidcEntry.type} field.
29
+ */
30
+ export type OidcEntryType = 'Session' | 'AccessToken' | 'AuthorizationCode' | 'RefreshToken' | 'DeviceCode' | 'ClientCredentials' | 'Client' | 'InitialAccessToken' | 'RegistrationAccessToken' | 'Interaction' | 'ReplayDetection' | 'PushedAuthorizationRequest' | 'Grant' | 'BackchannelAuthenticationRequest' | (string & {});
31
+ /**
32
+ * Type value for Client adapter entries.
33
+ */
34
+ export declare const OIDC_ENTRY_CLIENT_TYPE: OidcEntryType;
35
+ /**
36
+ * oidc-provider adapter entry stored in Firestore.
37
+ *
38
+ * All oidc-provider model types (Session, AccessToken, Client, etc.) are stored in a single collection,
39
+ * discriminated by the {@link type} field. The full oidc-provider payload is serialized as JSON in
40
+ * the {@link payload} field. Sensitive fields within the payload (e.g. `client_secret`) may be
41
+ * selectively encrypted at rest.
42
+ *
43
+ * The {@link o} ownership field enables Firestore security rules to restrict reads to the owning user
44
+ * (used primarily for Client entries so users can query their own registered OAuth clients).
45
+ */
46
+ export interface OidcEntry {
47
+ /**
48
+ * The oidc-provider model type (e.g., 'Session', 'AccessToken', 'Client').
49
+ */
50
+ type: string;
51
+ /**
52
+ * Serialized JSON of the full oidc-provider AdapterPayload.
53
+ *
54
+ * The payload structure varies by model type. Sensitive fields may be
55
+ * selectively encrypted (prefixed with `$`) when encryption is configured.
56
+ */
57
+ payload: JsonSerializableObject;
58
+ /**
59
+ * Ownership key for Firestore security rules.
60
+ *
61
+ * Set to the Firebase Auth UID of the user who created this entry.
62
+ * Used primarily on Client entries to allow users to query their own OAuth clients.
63
+ */
64
+ o?: Maybe<FirebaseAuthOwnershipKey>;
65
+ /**
66
+ * User identifier. Extracted from the payload for indexed queries.
67
+ */
68
+ uid?: Maybe<string>;
69
+ /**
70
+ * Grant identifier for revocation support. Extracted from the payload for indexed queries.
71
+ */
72
+ grantId?: Maybe<string>;
73
+ /**
74
+ * User code for device flow. Extracted from the payload for indexed queries.
75
+ */
76
+ userCode?: Maybe<string>;
77
+ /**
78
+ * Epoch timestamp when this entry was consumed. Extracted from the payload for indexed queries.
79
+ */
80
+ consumed?: Maybe<number>;
81
+ /**
82
+ * When this entry expires.
83
+ */
84
+ expiresAt?: Maybe<Date>;
85
+ }
86
+ export type OidcEntryRoles = GrantedReadRole | GrantedUpdateRole | GrantedDeleteRole;
87
+ /**
88
+ * Firestore document wrapper for {@link OidcEntry}.
89
+ */
90
+ export declare class OidcEntryDocument extends AbstractFirestoreDocument<OidcEntry, OidcEntryDocument, typeof oidcEntryIdentity> {
91
+ get modelIdentity(): import("../..").RootFirestoreModelIdentity<"oidcEntry", "oidc_e">;
92
+ }
93
+ /**
94
+ * Firestore snapshot converter for {@link OidcEntry} documents.
95
+ */
96
+ export declare const oidcEntryConverter: import("../..").SnapshotConverterFunctions<OidcEntry, Partial<import("@dereekb/util").ReplaceType<OidcEntry, import("@dereekb/util").MaybeMap<object>, any>>>;
97
+ /**
98
+ * Typed Firestore collection for {@link OidcEntry} documents.
99
+ */
100
+ export type OidcEntryFirestoreCollection = FirestoreCollection<OidcEntry, OidcEntryDocument>;
101
+ /**
102
+ * Configuration for creating an {@link OidcEntryFirestoreCollection}.
103
+ */
104
+ export interface OidcEntryFirestoreCollectionConfig {
105
+ readonly firestoreContext: FirestoreContext;
106
+ }
107
+ /**
108
+ * Returns the Firestore {@link CollectionReference} for {@link OidcEntry} documents.
109
+ */
110
+ export declare function oidcEntryCollectionReference(context: FirestoreContext): CollectionReference<OidcEntry>;
111
+ /**
112
+ * Creates an {@link OidcEntryFirestoreCollection} from the given configuration.
113
+ */
114
+ export declare function oidcEntryFirestoreCollection(config: OidcEntryFirestoreCollectionConfig): OidcEntryFirestoreCollection;
@@ -0,0 +1,17 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type OidcEntryClientId } from './oidcmodel.id';
3
+ import { type OidcRedirectUri } from './oidcmodel.interaction';
4
+ /**
5
+ * Corresponds with readable content from a OidcEntry's payload.
6
+ */
7
+ export interface OidcEntryOAuthClientPayloadData {
8
+ readonly client_id: OidcEntryClientId;
9
+ readonly client_name?: Maybe<string>;
10
+ readonly redirect_uris: OidcRedirectUri[];
11
+ readonly grant_types: string[];
12
+ readonly response_types?: Maybe<string[]>;
13
+ readonly token_endpoint_auth_method?: Maybe<string>;
14
+ readonly logo_uri?: Maybe<string>;
15
+ readonly client_uri?: Maybe<string>;
16
+ readonly created_at?: string;
17
+ }
@@ -0,0 +1,18 @@
1
+ import { type FirestoreModelId, type FirestoreModelKey } from '../../common';
2
+ /**
3
+ * Document ID for an OidcEntry.
4
+ *
5
+ * NOTE: This id may include dashes or underscores, so this type is not compatable with TwoWayFlatFirestoreModelKey usage.
6
+ *
7
+ * The ID is assigned by the oidc-provider library and varies by model type
8
+ * (e.g., opaque token string for AccessToken, random string for Session).
9
+ */
10
+ export type OidcEntryId = FirestoreModelId;
11
+ /**
12
+ * Full Firestore model key path for an OidcEntry document.
13
+ */
14
+ export type OidcEntryKey = FirestoreModelKey;
15
+ /**
16
+ * Unique client identifier for an OIDC client registration.
17
+ */
18
+ export type OidcEntryClientId = string;
@@ -0,0 +1,40 @@
1
+ import { type LabeledValue, type LabeledValueWithDescription } from '@dereekb/util';
2
+ /**
3
+ * Unique identifier for an oidc-provider interaction session, not to be confused with a Firebase UID/Auth User Identifier.
4
+ *
5
+ * Generated by the provider when user interaction is needed (login/consent).
6
+ * Used to look up the interaction session via cookies and to build
7
+ * backend interaction endpoint URLs (e.g., `/interaction/${uid}/login`).
8
+ */
9
+ export type OidcInteractionUid = string;
10
+ /**
11
+ * Base type for OIDC scope string unions.
12
+ *
13
+ * Applications define their own scope union extending this type to get
14
+ * compile-time validation of scope names throughout the delegate and config.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * type MyScopes = 'openid' | 'profile' | 'email';
19
+ * ```
20
+ */
21
+ export type OidcScope = string;
22
+ /**
23
+ * Scope details with a human-readable label and description.
24
+ */
25
+ export type OidcScopeDetails<T extends OidcScope = OidcScope> = LabeledValueWithDescription<T>;
26
+ /**
27
+ * A redirect URI registered to an OIDC client.
28
+ *
29
+ * Must be a valid absolute URL (e.g. `https://myapp.example.com/callback`).
30
+ */
31
+ export type OidcRedirectUri = string;
32
+ /**
33
+ * Supported values for `token_endpoint_auth_method` when creating an OIDC client.
34
+ */
35
+ export type OidcTokenEndpointAuthMethod = 'client_secret_basic' | 'client_secret_post' | 'client_secret_jwt' | 'private_key_jwt';
36
+ export declare const PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD: OidcTokenEndpointAuthMethod;
37
+ /**
38
+ * All available token endpoint auth method options with display labels.
39
+ */
40
+ export declare const ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHOD_OPTIONS: LabeledValue<OidcTokenEndpointAuthMethod>[];
@@ -0,0 +1,73 @@
1
+ import { type Maybe, type SpaceSeparatedString, type WebsiteUrlWithPrefix } from '@dereekb/util';
2
+ import { type FirebaseAuthIdToken } from '../../common/auth/auth';
3
+ import { type OidcEntryClientId } from './oidcmodel.id';
4
+ import { type OidcScope } from './oidcmodel.interaction';
5
+ /**
6
+ * Request body sent by the frontend to complete a login interaction.
7
+ *
8
+ * Posted to `POST /interaction/:uid/login` by the frontend after
9
+ * the user authenticates via Firebase.
10
+ */
11
+ export interface OAuthInteractionLoginRequest {
12
+ /**
13
+ * Firebase Auth ID token.
14
+ *
15
+ * The backend verifies this token via `admin.auth().verifyIdToken()` and
16
+ * uses the decoded UID as the `accountId` for the oidc-provider login result.
17
+ */
18
+ readonly idToken: FirebaseAuthIdToken;
19
+ }
20
+ /**
21
+ * Space-separated string of scopes requested by the client.
22
+ */
23
+ export type OAuthInteractionScopes<T extends OidcScope = OidcScope> = SpaceSeparatedString<T>;
24
+ /**
25
+ * Details about oauth client and interaction.
26
+ */
27
+ export interface OAuthInteractionLoginDetails<T extends OidcScope = OidcScope> {
28
+ readonly client_id: OidcEntryClientId;
29
+ readonly client_name?: Maybe<string>;
30
+ readonly logo_uri?: Maybe<string>;
31
+ readonly client_uri?: Maybe<string>;
32
+ readonly scopes: OAuthInteractionScopes<T>;
33
+ }
34
+ /**
35
+ * Response from the server after a successful interaction submission.
36
+ *
37
+ * The server returns a redirect URL that the client should navigate to
38
+ * in order to complete the OIDC flow.
39
+ */
40
+ export interface OAuthInteractionLoginResponse {
41
+ readonly redirectTo: WebsiteUrlWithPrefix;
42
+ }
43
+ /**
44
+ * Request body sent by the frontend to complete a consent interaction.
45
+ *
46
+ * Posted to `POST /interaction/:uid/consent` by the frontend after
47
+ * the user approves or denies the requested scopes/claims.
48
+ */
49
+ export interface OAuthInteractionConsentRequest {
50
+ /**
51
+ * Firebase Auth ID token.
52
+ *
53
+ * The backend verifies this token to confirm the caller is the
54
+ * same user who completed the login interaction.
55
+ */
56
+ readonly idToken: FirebaseAuthIdToken;
57
+ /**
58
+ * Whether the user approved the consent.
59
+ *
60
+ * When `true`, the backend grants missing scopes/claims and completes the interaction.
61
+ * When `false`, the backend returns `access_denied` to the OAuth client.
62
+ */
63
+ readonly approved: boolean;
64
+ }
65
+ /**
66
+ * Response from the server after a successful interaction submission.
67
+ *
68
+ * The server returns a redirect URL that the client should navigate to
69
+ * in order to complete the OIDC flow.
70
+ */
71
+ export interface OAuthInteractionConsentResponse {
72
+ readonly redirectTo: WebsiteUrlWithPrefix;
73
+ }
@@ -0,0 +1,21 @@
1
+ import { type FirebaseAuthOwnershipKey, type FirestoreQueryConstraint } from '../../common';
2
+ /**
3
+ * Query for OidcEntry documents with a specific type.
4
+ */
5
+ export declare function oidcEntriesWithTypeQuery(type: string): FirestoreQueryConstraint[];
6
+ /**
7
+ * Query for OidcEntry documents with a specific type and userCode.
8
+ */
9
+ export declare function oidcEntriesByUserCodeQuery(type: string, userCode: string): FirestoreQueryConstraint[];
10
+ /**
11
+ * Query for OidcEntry documents with a specific type and uid.
12
+ */
13
+ export declare function oidcEntriesByUidQuery(type: string, uid: string): FirestoreQueryConstraint[];
14
+ /**
15
+ * Query for OidcEntry documents with a specific type and grantId.
16
+ */
17
+ export declare function oidcEntriesByGrantIdQuery(type: string, grantId: string): FirestoreQueryConstraint[];
18
+ /**
19
+ * Query for OidcEntry Client documents owned by a specific user.
20
+ */
21
+ export declare function oidcClientEntriesByOwnerQuery(ownershipKey: FirebaseAuthOwnershipKey): FirestoreQueryConstraint[];
@@ -1,14 +1,61 @@
1
1
  import { type AsyncFirebaseFunctionDeleteAction, type FirebaseFunctionDeleteAction, type AsyncFirebaseFunctionCreateAction, type AsyncFirebaseFunctionUpdateAction, type FirebaseFunctionCreateAction, type FirebaseFunctionUpdateAction } from '../../common';
2
2
  import { type StorageFileGroupDocument, type StorageFileDocument } from './storagefile';
3
+ /**
4
+ * @module storagefile.action
5
+ *
6
+ * Type aliases for StorageFile and StorageFileGroup server action functions.
7
+ *
8
+ * These connect API parameter types to their target document types, following the same
9
+ * pattern as notification actions. See `@dereekb/firebase-server/model` for the
10
+ * server-side action service implementations.
11
+ *
12
+ * @template P - the API parameter type for the action
13
+ */
14
+ /**
15
+ * Synchronous create action targeting a {@link StorageFileDocument}.
16
+ */
3
17
  export type StorageFileCreateAction<P extends object> = FirebaseFunctionCreateAction<P, StorageFileDocument>;
18
+ /**
19
+ * Async create action targeting a {@link StorageFileDocument}.
20
+ */
4
21
  export type AsyncStorageFileCreateAction<P extends object> = AsyncFirebaseFunctionCreateAction<P, StorageFileDocument>;
22
+ /**
23
+ * Synchronous update action targeting a {@link StorageFileDocument}.
24
+ */
5
25
  export type StorageFileUpdateAction<P extends object> = FirebaseFunctionUpdateAction<P, StorageFileDocument>;
26
+ /**
27
+ * Async update action targeting a {@link StorageFileDocument}.
28
+ */
6
29
  export type AsyncStorageFileUpdateAction<P extends object> = AsyncFirebaseFunctionUpdateAction<P, StorageFileDocument>;
30
+ /**
31
+ * Synchronous delete action targeting a {@link StorageFileDocument}.
32
+ */
7
33
  export type StorageFileDeleteAction<P extends object> = FirebaseFunctionDeleteAction<P, StorageFileDocument>;
34
+ /**
35
+ * Async delete action targeting a {@link StorageFileDocument}.
36
+ */
8
37
  export type AsyncStorageFileDeleteAction<P extends object> = AsyncFirebaseFunctionDeleteAction<P, StorageFileDocument>;
38
+ /**
39
+ * Synchronous create action targeting a {@link StorageFileGroupDocument}.
40
+ */
9
41
  export type StorageFileGroupCreateAction<P extends object> = FirebaseFunctionCreateAction<P, StorageFileGroupDocument>;
42
+ /**
43
+ * Async create action targeting a {@link StorageFileGroupDocument}.
44
+ */
10
45
  export type AsyncStorageFileGroupCreateAction<P extends object> = AsyncFirebaseFunctionCreateAction<P, StorageFileGroupDocument>;
46
+ /**
47
+ * Synchronous update action targeting a {@link StorageFileGroupDocument}.
48
+ */
11
49
  export type StorageFileGroupUpdateAction<P extends object> = FirebaseFunctionUpdateAction<P, StorageFileGroupDocument>;
50
+ /**
51
+ * Async update action targeting a {@link StorageFileGroupDocument}.
52
+ */
12
53
  export type AsyncStorageFileGroupUpdateAction<P extends object> = AsyncFirebaseFunctionUpdateAction<P, StorageFileGroupDocument>;
54
+ /**
55
+ * Synchronous delete action targeting a {@link StorageFileGroupDocument}.
56
+ */
13
57
  export type StorageFileGroupDeleteAction<P extends object> = FirebaseFunctionDeleteAction<P, StorageFileGroupDocument>;
58
+ /**
59
+ * Async delete action targeting a {@link StorageFileGroupDocument}.
60
+ */
14
61
  export type AsyncStorageFileGroupDeleteAction<P extends object> = AsyncFirebaseFunctionDeleteAction<P, StorageFileGroupDocument>;
@@ -7,13 +7,18 @@ import { type ContentDispositionString, type ContentTypeMimeType, type Maybe, ty
7
7
  import { type StorageFileId } from './storagefile.id';
8
8
  import { type SendNotificationResult } from '../notification/notification.api';
9
9
  /**
10
- * Used for directly create a new StorageFile.
10
+ * Parameters for directly creating a new StorageFile document (no upload initialization).
11
+ *
12
+ * Typically used server-side or for testing. Validated with {@link createStorageFileParamsType}.
11
13
  */
12
14
  export interface CreateStorageFileParams {
13
15
  }
14
16
  export declare const createStorageFileParamsType: Type<CreateStorageFileParams>;
15
17
  /**
16
- * Initializes all StorageFiles in the uploads folder.
18
+ * Parameters for batch-initializing all files found in the uploads folder.
19
+ *
20
+ * Scans the uploads folder (or a custom path) and runs the upload determination/initialization
21
+ * pipeline for each file found. Validated with {@link initializeAllStorageFilesFromUploadsParamsType}.
17
22
  */
18
23
  export interface InitializeAllStorageFilesFromUploadsParams {
19
24
  readonly maxFilesToInitialize?: Maybe<number>;
@@ -21,13 +26,19 @@ export interface InitializeAllStorageFilesFromUploadsParams {
21
26
  readonly overrideUploadsFolderPath?: Maybe<StorageSlashPath>;
22
27
  }
23
28
  export declare const initializeAllStorageFilesFromUploadsParamsType: Type<InitializeAllStorageFilesFromUploadsParams>;
29
+ /**
30
+ * Result of batch upload initialization, reporting visit and success/failure counts.
31
+ */
24
32
  export interface InitializeAllStorageFilesFromUploadsResult extends OnCallCreateModelResult {
25
33
  readonly filesVisited: number;
26
34
  readonly initializationsSuccessCount: number;
27
35
  readonly initializationsFailureCount: number;
28
36
  }
29
37
  /**
30
- * Initializes a StorageFile from the document at the given path.
38
+ * Parameters for initializing a single StorageFile from an uploaded file at a specific storage path.
39
+ *
40
+ * The file is run through the upload type determination pipeline and, if matched,
41
+ * creates a corresponding StorageFile document. Validated with {@link initializeStorageFileFromUploadParamsType}.
31
42
  */
32
43
  export interface InitializeStorageFileFromUploadParams extends Pick<StoragePath, 'pathString'> {
33
44
  readonly bucketId?: Maybe<StorageBucketId>;
@@ -35,6 +46,12 @@ export interface InitializeStorageFileFromUploadParams extends Pick<StoragePath,
35
46
  readonly expediteProcessing?: boolean;
36
47
  }
37
48
  export declare const initializeStorageFileFromUploadParamsType: Type<InitializeStorageFileFromUploadParams>;
49
+ /**
50
+ * Parameters for triggering processing of a specific StorageFile.
51
+ *
52
+ * Supports various modes: immediate processing, retry checking, force restart,
53
+ * and reprocessing already-successful files. Validated with {@link processStorageFileParamsType}.
54
+ */
38
55
  export interface ProcessStorageFileParams extends TargetModelParams {
39
56
  readonly runImmediately?: Maybe<boolean>;
40
57
  readonly checkRetryProcessing?: Maybe<boolean>;
@@ -76,6 +93,12 @@ export interface DeleteAllQueuedStorageFilesResult {
76
93
  readonly storageFilesDeleted: number;
77
94
  readonly storageFilesFailedDeleting: number;
78
95
  }
96
+ /**
97
+ * Parameters for generating a signed download URL for a StorageFile.
98
+ *
99
+ * Supports custom expiration, content disposition, and content type overrides.
100
+ * Admin downloads (`asAdmin`) allow longer expiration times. Validated with {@link downloadStorageFileParamsType}.
101
+ */
79
102
  export interface DownloadStorageFileParams extends TargetModelParams {
80
103
  readonly expiresAt?: Maybe<Date>;
81
104
  readonly expiresIn?: Maybe<Milliseconds>;
@@ -160,8 +183,20 @@ export interface InitializeAllApplicableStorageFileGroupsResult {
160
183
  readonly storageFileGroupsFailed: number;
161
184
  readonly storageFileGroupsAlreadyInitialized: number;
162
185
  }
186
+ /**
187
+ * Custom (non-CRUD) function type map for StorageFile. Currently empty — all operations use CRUD functions.
188
+ */
163
189
  export type StorageFileFunctionTypeMap = {};
164
190
  export declare const storageFileFunctionTypeConfigMap: FirebaseFunctionTypeConfigMap<StorageFileFunctionTypeMap>;
191
+ /**
192
+ * CRUD function configuration map for the StorageFile model family.
193
+ *
194
+ * Defines all callable cloud function endpoints for StorageFile and StorageFileGroup,
195
+ * including creation (direct, from upload, batch), processing, sync, download, and deletion.
196
+ *
197
+ * Used by {@link StorageFileFunctions} and {@link storageFileFunctionMap} to generate
198
+ * typed callable function references.
199
+ */
165
200
  export type StorageFileModelCrudFunctionsConfig = {
166
201
  readonly storageFile: {
167
202
  create: {
@@ -181,7 +216,7 @@ export type StorageFileModelCrudFunctionsConfig = {
181
216
  _: DeleteStorageFileParams;
182
217
  };
183
218
  };
184
- storageFileGroup: {
219
+ readonly storageFileGroup: {
185
220
  update: {
186
221
  _: UpdateStorageFileGroupParams;
187
222
  regenerateContent: [RegenerateStorageFileGroupContentParams, RegenerateStorageFileGroupContentResult];
@@ -189,6 +224,12 @@ export type StorageFileModelCrudFunctionsConfig = {
189
224
  };
190
225
  };
191
226
  export declare const storageFileModelCrudFunctionsConfig: ModelFirebaseCrudFunctionConfigMap<StorageFileModelCrudFunctionsConfig, StorageFileTypes>;
227
+ /**
228
+ * Abstract class defining all callable StorageFile cloud functions.
229
+ *
230
+ * Implement this in your app module to wire up the function endpoints.
231
+ * Use {@link storageFileFunctionMap} to create a client-side callable map.
232
+ */
192
233
  export declare abstract class StorageFileFunctions implements ModelFirebaseFunctionMap<StorageFileFunctionTypeMap, StorageFileModelCrudFunctionsConfig> {
193
234
  abstract storageFile: {
194
235
  createStorageFile: {
@@ -215,4 +256,13 @@ export declare abstract class StorageFileFunctions implements ModelFirebaseFunct
215
256
  };
216
257
  };
217
258
  }
259
+ /**
260
+ * Client-side callable function map factory for all StorageFile and StorageFileGroup CRUD operations.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * const functions = storageFileFunctionMap(callableFactory);
265
+ * const result = await functions.storageFile.createStorageFile.fromUpload({ pathString: 'uploads/u/123/avatar.png' });
266
+ * ```
267
+ */
218
268
  export declare const storageFileFunctionMap: import("../..").ModelFirebaseFunctionMapFactory<StorageFileFunctionTypeMap, StorageFileModelCrudFunctionsConfig>;