@aglyn/tenant-data-admin 1.0.0-beta.284 → 1.0.0-beta.285
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/package.json +7 -7
- package/src/lib/server/ad-audience-sync-run.d.ts +63 -6
- package/src/lib/server/ad-audience-sync-run.js +289 -124
- package/src/lib/server/ad-audience-sync-run.js.map +1 -1
- package/src/lib/server/ad-audience-sync.d.ts +115 -2
- package/src/lib/server/ad-audience-sync.js +203 -25
- package/src/lib/server/ad-audience-sync.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/tenant-data-admin",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.285",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-util-email": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-util-fbserver": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-util-first-touch": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.285",
|
|
29
|
+
"@aglyn/shared-util-email": "1.0.0-beta.285",
|
|
30
|
+
"@aglyn/shared-util-fbserver": "1.0.0-beta.285",
|
|
31
|
+
"@aglyn/shared-util-first-touch": "1.0.0-beta.285",
|
|
32
|
+
"@aglyn/shared-util-http": "1.0.0-beta.285",
|
|
33
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.285",
|
|
34
34
|
"@msgpack/msgpack": "^3.1.3",
|
|
35
35
|
"@swc/helpers": "0.5.23",
|
|
36
36
|
"sharp": "^0.35.5",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { type AdAudienceAccount, type AdAudienceConfig, type AdAudienceExclusion, type AdAudienceProvider } from './ad-audience-sync';
|
|
17
|
+
import { type AdAudienceAccount, type AdAudienceConfig, type AdAudienceExclusion, type AdAudienceProvider, type AdAudienceStage } from './ad-audience-sync';
|
|
18
18
|
/**
|
|
19
19
|
* THE ACCOUNT-HOLDER AD AUDIENCE (AGL-3780) — reading, sending, recording.
|
|
20
20
|
*
|
|
@@ -31,9 +31,16 @@ import { type AdAudienceAccount, type AdAudienceConfig, type AdAudienceExclusion
|
|
|
31
31
|
* the only way to take it out of a Google list or a LinkedIn segment is the
|
|
32
32
|
* hash this sync sent it under. Admin-SDK only; no client rule opens either.
|
|
33
33
|
* No address is stored, and neither addresses nor hashes are ever logged.
|
|
34
|
+
*
|
|
35
|
+
* A STAGE list (AGL-4072) keeps the same two things under its own document,
|
|
36
|
+
* `adAudienceSync/{provider}--{stage}`, so each stage has its own ledger, its
|
|
37
|
+
* own diff and its own shrink guard, and nothing one list does can touch what
|
|
38
|
+
* another was sent.
|
|
34
39
|
*/
|
|
35
40
|
export declare const AD_AUDIENCE_SYNC_COLLECTION = "adAudienceSync";
|
|
36
41
|
export declare const AD_AUDIENCE_MEMBERS_SUBCOLLECTION = "members";
|
|
42
|
+
/** The ledger document of one list: the provider's own, or `{provider}--{stage}`. */
|
|
43
|
+
export declare function adAudienceLedgerId(provider: AdAudienceProvider, stage?: AdAudienceStage | null): string;
|
|
37
44
|
/** The Auth page reader, as `listUsersAcrossPools` answers it. */
|
|
38
45
|
export type ListUsersPage = (pageSize: number, pageToken?: string) => Promise<{
|
|
39
46
|
users: Array<{
|
|
@@ -43,6 +50,13 @@ export type ListUsersPage = (pageSize: number, pageToken?: string) => Promise<{
|
|
|
43
50
|
emailVerified: boolean;
|
|
44
51
|
disabled: boolean;
|
|
45
52
|
customClaims?: Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* Only `creationTime` is read. `lastSignInTime` and `lastRefreshTime`
|
|
55
|
+
* are never activity: a silent re-sign-in moves both with nobody there.
|
|
56
|
+
*/
|
|
57
|
+
metadata?: {
|
|
58
|
+
creationTime?: string;
|
|
59
|
+
};
|
|
46
60
|
};
|
|
47
61
|
}>;
|
|
48
62
|
nextPageToken: string | null | undefined;
|
|
@@ -53,6 +67,16 @@ export interface AdAudienceReadDeps {
|
|
|
53
67
|
/** The account-ban list's answer for these addresses, lowercased. */
|
|
54
68
|
bannedEmails: (emails: readonly string[]) => Promise<Set<string>>;
|
|
55
69
|
now: number;
|
|
70
|
+
/**
|
|
71
|
+
* The operator's own domains. Only narrows whose recent activity is read:
|
|
72
|
+
* an internal account is in no list, so its change log is not looked at.
|
|
73
|
+
*/
|
|
74
|
+
internalDomains?: readonly string[];
|
|
75
|
+
/**
|
|
76
|
+
* The newest real activity of one account since `sinceMs`, or null. The
|
|
77
|
+
* Firestore reader `readRecentActivityAtMs` unless a spec passes its own.
|
|
78
|
+
*/
|
|
79
|
+
recentActivity?: (uid: string, sinceMs: number) => Promise<number | null>;
|
|
56
80
|
}
|
|
57
81
|
/** A number for each reason; never a person. */
|
|
58
82
|
export type ExclusionCounts = Record<AdAudienceExclusion, number>;
|
|
@@ -65,17 +89,39 @@ export interface AdAudienceSelection {
|
|
|
65
89
|
billing: number;
|
|
66
90
|
signup: number;
|
|
67
91
|
};
|
|
92
|
+
/** The eligible accounts in each stage (AGL-4072). */
|
|
93
|
+
stages: Record<AdAudienceStage, AdAudienceAccount[]>;
|
|
68
94
|
}
|
|
69
|
-
/** Every account, with the facts eligibility
|
|
95
|
+
/** Every account, with the facts eligibility and the stage lists read. */
|
|
70
96
|
export declare function readAdAudienceAccounts(deps: AdAudienceReadDeps): Promise<{
|
|
71
97
|
accounts: AdAudienceAccount[];
|
|
72
98
|
}>;
|
|
73
|
-
/**
|
|
74
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The newest thing one account DID since `sinceMs`, or null when nothing was
|
|
101
|
+
* recorded. Two signals, both read through collection-group indexes that
|
|
102
|
+
* already exist for the staff activity feed and the AI job list:
|
|
103
|
+
*
|
|
104
|
+
* - **Change-log entries** under the account's id, on any site's or
|
|
105
|
+
* workspace's log (`hosts/{id}/activity`, `orgs/{id}/activity`): page
|
|
106
|
+
* edits, publishes, form and CRM actions, settings. Entries the platform
|
|
107
|
+
* writes under the person's id without them acting
|
|
108
|
+
* (`isRealActivityAction`) are skipped.
|
|
109
|
+
* - **AI jobs the account started** (`orgs/{id}/aiJobs` by `createdBy`). The
|
|
110
|
+
* start only: a job's later updates are the platform's.
|
|
111
|
+
*
|
|
112
|
+
* Firebase's sign-in and token-refresh times, and the device "last seen"
|
|
113
|
+
* stamps, are never read: a silent re-sign-in moves them with nobody there.
|
|
114
|
+
*/
|
|
115
|
+
export declare function readRecentActivityAtMs(db: FirebaseFirestore.Firestore, uid: string, sinceMs: number): Promise<number | null>;
|
|
116
|
+
/** The eligible accounts, the counts of everyone left out, and each stage. */
|
|
117
|
+
export declare function selectAdAudience(accounts: readonly AdAudienceAccount[], internalDomains: readonly string[], now?: number): AdAudienceSelection;
|
|
75
118
|
/** The set one provider should hold. Two addresses may share a hash. */
|
|
76
119
|
export declare function providerHashes(provider: AdAudienceProvider, eligible: readonly AdAudienceAccount[]): string[];
|
|
77
|
-
/**
|
|
78
|
-
|
|
120
|
+
/**
|
|
121
|
+
* What one list was last sent: the provider's all-holders list, or with
|
|
122
|
+
* `stage` that stage's list, each from its own ledger.
|
|
123
|
+
*/
|
|
124
|
+
export declare function readSentHashes(firestore: FirebaseFirestore.Firestore, provider: AdAudienceProvider, stage?: AdAudienceStage | null): Promise<string[]>;
|
|
79
125
|
export type AudienceFetch = (url: string, init: {
|
|
80
126
|
method: string;
|
|
81
127
|
headers: Record<string, string>;
|
|
@@ -103,6 +149,16 @@ export interface ProviderReport {
|
|
|
103
149
|
/** For `failed`: the provider's status and message, never a payload. */
|
|
104
150
|
error?: string;
|
|
105
151
|
}
|
|
152
|
+
/** One stage's list on every provider (AGL-4072). */
|
|
153
|
+
export interface StageReport {
|
|
154
|
+
/**
|
|
155
|
+
* The eligible accounts in the stage. Counted for every stage on every
|
|
156
|
+
* run, whether or not any of its lists is configured, so the report says
|
|
157
|
+
* when a stage is big enough to be worth a list.
|
|
158
|
+
*/
|
|
159
|
+
eligible: number;
|
|
160
|
+
providers: Record<AdAudienceProvider, ProviderReport>;
|
|
161
|
+
}
|
|
106
162
|
export interface AdAudienceSyncReport {
|
|
107
163
|
dryRun: boolean;
|
|
108
164
|
flagOn: boolean;
|
|
@@ -114,6 +170,7 @@ export interface AdAudienceSyncReport {
|
|
|
114
170
|
signup: number;
|
|
115
171
|
};
|
|
116
172
|
providers: Record<AdAudienceProvider, ProviderReport>;
|
|
173
|
+
stages: Record<AdAudienceStage, StageReport>;
|
|
117
174
|
}
|
|
118
175
|
export interface AdAudienceRunOptions {
|
|
119
176
|
/** Report what would change and send nothing. */
|