ad2app-lib 1.49.0 → 1.50.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.
@@ -120,6 +120,17 @@ export declare const EVENTS: {
120
120
  readonly AGENCY_CAMPAIGN_MILESTONE_CONFIRMED: "agency_campaign_milestone_confirmed";
121
121
  readonly AGENCY_THREAD_STARTED: "agency_thread_started";
122
122
  readonly AGENCY_THREAD_MESSAGE_SENT: "agency_thread_message_sent";
123
+ readonly AGENCY_POT_APPLIED: "agency_pot_applied";
124
+ readonly AGENCY_POT_APPLICATION_DECIDED: "agency_pot_application_decided";
125
+ readonly AGENCY_POT_REFILLED: "agency_pot_refilled";
126
+ readonly AGENCY_POT_MOVED: "agency_pot_moved";
127
+ readonly AGENCY_POT_PUBLISH_TIME_CONFIRMED: "agency_pot_publish_time_confirmed";
128
+ readonly AGENCY_POT_PUBLISHED: "agency_pot_published";
129
+ readonly AGENCY_POT_BONUS_HELD: "agency_pot_bonus_held";
130
+ readonly AGENCY_POT_BONUS_DECIDED: "agency_pot_bonus_decided";
131
+ readonly AGENCY_POT_REMOVAL_DECIDED: "agency_pot_removal_decided";
132
+ readonly AGENCY_POT_EXPORTED: "agency_pot_exported";
133
+ readonly AGENCY_POT_FILE_UPLOADED: "agency_pot_file_uploaded";
123
134
  };
124
135
  export type EventName = (typeof EVENTS)[keyof typeof EVENTS];
125
136
  /** Which email program a send belongs to (spec 120). Wire values — do not rename. */
@@ -628,6 +639,27 @@ export interface EventProperties {
628
639
  [EVENTS.AGENCY_THREAD_MESSAGE_SENT]: AgencyEventProperties & {
629
640
  thread_id: string;
630
641
  };
642
+ [EVENTS.AGENCY_POT_APPLIED]: AgencyCampaignEventProperties;
643
+ [EVENTS.AGENCY_POT_APPLICATION_DECIDED]: AgencyCampaignEventProperties & {
644
+ action: 'accept' | 'decline';
645
+ };
646
+ [EVENTS.AGENCY_POT_REFILLED]: AgencyCampaignEventProperties;
647
+ [EVENTS.AGENCY_POT_MOVED]: AgencyCampaignEventProperties;
648
+ [EVENTS.AGENCY_POT_PUBLISH_TIME_CONFIRMED]: AgencyCampaignEventProperties;
649
+ [EVENTS.AGENCY_POT_PUBLISHED]: AgencyCampaignEventProperties;
650
+ [EVENTS.AGENCY_POT_BONUS_HELD]: AgencyCampaignEventProperties & {
651
+ reason: 'jump' | 'paid_delivery';
652
+ };
653
+ [EVENTS.AGENCY_POT_BONUS_DECIDED]: AgencyCampaignEventProperties & {
654
+ action: 'approve' | 'cap' | 'message';
655
+ };
656
+ [EVENTS.AGENCY_POT_REMOVAL_DECIDED]: AgencyCampaignEventProperties & {
657
+ decision: 'keep_base' | 'withhold_base';
658
+ };
659
+ [EVENTS.AGENCY_POT_EXPORTED]: AgencyCampaignEventProperties & {
660
+ format: 'csv' | 'xlsx' | 'report';
661
+ };
662
+ [EVENTS.AGENCY_POT_FILE_UPLOADED]: AgencyCampaignEventProperties;
631
663
  }
632
664
  /** Canonical person property keys (set via identify / $set). */
633
665
  export declare const PERSON_PROPS: {
@@ -194,6 +194,18 @@ exports.EVENTS = {
194
194
  // Threads (175 US8). Never the message body: a conversation is not analytics.
195
195
  AGENCY_THREAD_STARTED: 'agency_thread_started',
196
196
  AGENCY_THREAD_MESSAGE_SENT: 'agency_thread_message_sent',
197
+ // Pot campaigns (175 US9). Never an amount: the pot's economics are the agency's.
198
+ AGENCY_POT_APPLIED: 'agency_pot_applied',
199
+ AGENCY_POT_APPLICATION_DECIDED: 'agency_pot_application_decided',
200
+ AGENCY_POT_REFILLED: 'agency_pot_refilled',
201
+ AGENCY_POT_MOVED: 'agency_pot_moved',
202
+ AGENCY_POT_PUBLISH_TIME_CONFIRMED: 'agency_pot_publish_time_confirmed',
203
+ AGENCY_POT_PUBLISHED: 'agency_pot_published',
204
+ AGENCY_POT_BONUS_HELD: 'agency_pot_bonus_held',
205
+ AGENCY_POT_BONUS_DECIDED: 'agency_pot_bonus_decided',
206
+ AGENCY_POT_REMOVAL_DECIDED: 'agency_pot_removal_decided',
207
+ AGENCY_POT_EXPORTED: 'agency_pot_exported',
208
+ AGENCY_POT_FILE_UPLOADED: 'agency_pot_file_uploaded',
197
209
  };
198
210
  /**
199
211
  * Canonical email event property KEYS (spec 120 T001). Emitters and tests
@@ -1,6 +1,7 @@
1
1
  import { I_MediaStage } from './I_Media';
2
2
  import { I_OfferStatus } from './I_Offer';
3
3
  import { type I_AgencyGrantScope } from './agency';
4
+ import { PotFields, type I_AgencyPotView, type I_CampaignFile, type I_CreatorPotView, type I_DisclosureCheck } from './agency-pots';
4
5
  /**
5
6
  * The campaign loop (spec 175 US7) — an organization runs a campaign with the
6
7
  * creators on its roster or in the directory.
@@ -37,6 +38,13 @@ export declare const isCampaignPlacement: (platform: string, placement: string)
37
38
  /** The creator's own setting. The agency reads it and can never set it. */
38
39
  export declare const SETTLEMENT_FORMS: readonly ["invoice", "contract", "barter"];
39
40
  export type SettlementForm = (typeof SETTLEMENT_FORMS)[number];
41
+ /**
42
+ * An offer campaign negotiates one price per creator (US7); a pot campaign pays
43
+ * from one pot on each creator's own terms (US9). Chosen at creation, fixed once
44
+ * the first creator is invited (FR-030).
45
+ */
46
+ export declare const AGENCY_CAMPAIGN_KINDS: readonly ["offer", "pot"];
47
+ export type AgencyCampaignKind = (typeof AGENCY_CAMPAIGN_KINDS)[number];
40
48
  export declare const AGENCY_CAMPAIGN_MEMBER_STATES: readonly ["invited", "joined", "declined", "left", "removed"];
41
49
  export type AgencyCampaignMemberState = (typeof AGENCY_CAMPAIGN_MEMBER_STATES)[number];
42
50
  /** The offer statuses the agency loop writes. `draft`, `deleted` and `alternativeSuggested` are legacy-only. */
@@ -68,7 +76,7 @@ export type AgencyMilestoneKind = (typeof AGENCY_MILESTONE_KINDS)[number];
68
76
  /** A milestone may wait on one rule: every ACTIVE offer at a status, or every active creator's latest material at a stage. */
69
77
  export declare const AGENCY_MILESTONE_OFFER_RULES: readonly [I_OfferStatus.CONFIRMED];
70
78
  export declare const AGENCY_MILESTONE_MEDIA_RULES: readonly [I_MediaStage.UPLOADED, I_MediaStage.ACCEPTED];
71
- export declare const AGENCY_CAMPAIGN_EVENT_KINDS: readonly ["invited", "joined", "declined", "left", "removed", "offer_sent", "offer_countered", "offer_accepted", "offer_confirmed", "offer_rejected", "offer_withdrawn", "material_uploaded", "material_approved", "material_changes_asked", "material_rejected", "published", "milestone_confirmed"];
79
+ export declare const AGENCY_CAMPAIGN_EVENT_KINDS: readonly ["invited", "joined", "declined", "left", "removed", "offer_sent", "offer_countered", "offer_accepted", "offer_confirmed", "offer_rejected", "offer_withdrawn", "material_uploaded", "material_approved", "material_changes_asked", "material_rejected", "published", "milestone_confirmed", "pot_applied", "pot_application_withdrawn", "pot_accepted", "pot_declined", "pot_released", "pot_refilled", "pot_moved", "pot_deadline_moved", "pot_publish_time_set", "pot_publish_time_confirmed", "pot_publish_refused", "pot_published", "pot_counted", "pot_frozen", "pot_bonus_held", "pot_bonus_approved", "pot_bonus_capped", "pot_bonus_message", "pot_kept", "pot_broken", "pot_removal_decided", "caption_edited", "file_uploaded", "file_removed"];
72
80
  export type AgencyCampaignEventKind = (typeof AGENCY_CAMPAIGN_EVENT_KINDS)[number];
73
81
  /** Refusal codes the frontend owes its own copy for. */
74
82
  export declare const AGENCY_CAMPAIGN_CODES: {
@@ -131,6 +139,10 @@ export interface I_AgencyMaterial {
131
139
  uploadedAt: string;
132
140
  /** The note sent with a change request or a rejection of THIS version. */
133
141
  note: string | null;
142
+ /** The post's caption, uploaded with the material (US9, FR-032); the creator may edit it until publication. Optional: 1.49 backends omit it. */
143
+ caption?: string | null;
144
+ /** `checkDisclosure(caption)`, returned with every read (FR-040); null without a caption. Optional: 1.49 backends omit it. */
145
+ disclosure?: I_DisclosureCheck | null;
134
146
  }
135
147
  export interface I_AgencyMilestone {
136
148
  id: string;
@@ -148,8 +160,12 @@ export interface I_AgencyMilestone {
148
160
  export interface I_AgencyCampaignEvent {
149
161
  kind: AgencyCampaignEventKind;
150
162
  side: CampaignSide;
163
+ /** Done by ad2app itself (the daily pot job), not by a person on that side. */
164
+ byAd2app?: true;
151
165
  at: string;
152
166
  price?: I_Money;
167
+ /** A pot act's amount: a refill, a move, a reserved guarantee, an accrued bonus. */
168
+ amount?: I_Money;
153
169
  note?: string;
154
170
  }
155
171
  export interface I_CampaignCreatorIdentity {
@@ -194,6 +210,8 @@ export interface I_AgencyCampaignPipeline {
194
210
  export interface I_AgencyCampaignCard {
195
211
  id: string;
196
212
  name: string;
213
+ /** Absent from 1.49 backends: read as 'offer'. */
214
+ kind?: AgencyCampaignKind;
197
215
  isDraft: boolean;
198
216
  liveByAt: string | null;
199
217
  draftDueAt: string | null;
@@ -205,6 +223,10 @@ export interface I_AgencyCampaignCard {
205
223
  export interface I_AgencyCampaign {
206
224
  id: string;
207
225
  name: string;
226
+ /** Absent from 1.49 backends: read as 'offer'. */
227
+ kind?: AgencyCampaignKind;
228
+ /** Set on a pot campaign; the pot board itself is `GET /agency/campaigns/:id/pot/board`. */
229
+ pot?: I_AgencyPotView | null;
208
230
  isDraft: boolean;
209
231
  brief: I_AgencyCampaignBrief;
210
232
  members: I_AgencyCampaignMemberRow[];
@@ -225,6 +247,8 @@ export interface I_AgencyCampaignAttention {
225
247
  counterOffers: number;
226
248
  materialsToReview: number;
227
249
  milestonesReady: number;
250
+ /** US9: applications to answer, held bonuses to decide, and posts taken down after the bonus window. */
251
+ potDecisions?: number;
228
252
  total: number;
229
253
  }
230
254
  /** `GET /agency/panel` (FR-022). */
@@ -264,11 +288,17 @@ export interface I_CreatorCampaignView {
264
288
  id: string;
265
289
  name: string;
266
290
  };
291
+ /** `kind` is absent from 1.49 backends: read as 'offer'. */
267
292
  campaign: {
268
293
  id: string;
269
294
  name: string;
270
295
  brief: I_AgencyCampaignBrief;
296
+ kind?: AgencyCampaignKind;
271
297
  };
298
+ /** Set on a pot campaign: the creator's own terms, earnings and the two-valued availability, nothing pot-level (SC-016). */
299
+ pot?: I_CreatorPotView | null;
300
+ /** The agency's files for the campaign (FR-039): every one is for its creators; opened through a signed read. */
301
+ files?: I_CampaignFile[];
272
302
  creatorBrief: string | null;
273
303
  /** The access request folded into the invitation, while it is open. */
274
304
  requestedScopes: I_AgencyGrantScope[];
@@ -299,8 +329,8 @@ export interface I_SignedRead {
299
329
  url: string;
300
330
  expiresAt: string;
301
331
  }
302
- /** The brief's fields, shared by create and update. All optional on the wire. */
303
- declare class AgencyCampaignBriefFields {
332
+ /** The brief's fields, shared by create and update. All optional on the wire. The pot's fields ride along (US9). */
333
+ declare class AgencyCampaignBriefFields extends PotFields {
304
334
  text?: string;
305
335
  deliverables?: I_CampaignDeliverable[];
306
336
  draftDueAt?: string | null;
@@ -312,12 +342,16 @@ declare class AgencyCampaignBriefFields {
312
342
  }
313
343
  export declare class CreateAgencyCampaignDto extends AgencyCampaignBriefFields {
314
344
  name: string;
345
+ /** Absent = an offer campaign (US7). */
346
+ kind?: AgencyCampaignKind;
315
347
  constructor(data?: Partial<CreateAgencyCampaignDto>);
316
348
  }
317
349
  export declare class UpdateAgencyCampaignDto extends AgencyCampaignBriefFields {
318
350
  name?: string;
319
351
  /** Setting false publishes the draft; the brief text must then be present (FR-025). */
320
352
  isDraft?: boolean;
353
+ /** Switch offer ↔ pot; refused once the first creator is invited (FR-030). */
354
+ kind?: AgencyCampaignKind;
321
355
  constructor(data?: Partial<UpdateAgencyCampaignDto>);
322
356
  }
323
357
  export declare class InviteCampaignCreatorDto {
@@ -370,6 +404,8 @@ export declare class PrepareMaterialUploadDto {
370
404
  }
371
405
  export declare class ConfirmMaterialUploadDto {
372
406
  uploadId: string;
407
+ /** The post's caption, sent with the material on a pot campaign (FR-032). */
408
+ caption?: string;
373
409
  constructor(data?: Partial<ConfirmMaterialUploadDto>);
374
410
  }
375
411
  export declare class CreateAgencyMilestoneDto {
@@ -9,11 +9,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UpdateSettlementFormDto = exports.CreateAgencyMilestoneDto = exports.ConfirmMaterialUploadDto = exports.PrepareMaterialUploadDto = exports.MATERIAL_CONTENT_TYPE = exports.MATERIAL_IMAGE_TYPES = exports.MATERIAL_MAX_BYTES = exports.JoinCampaignDto = exports.CampaignMaterialActDto = exports.CampaignOfferActDto = exports.SendCampaignOfferDto = exports.InviteCampaignCreatorDto = exports.UpdateAgencyCampaignDto = exports.CreateAgencyCampaignDto = exports.AGENCY_CAMPAIGN_CODES = exports.AGENCY_CAMPAIGN_EVENT_KINDS = exports.AGENCY_MILESTONE_MEDIA_RULES = exports.AGENCY_MILESTONE_OFFER_RULES = exports.AGENCY_MILESTONE_KINDS = exports.AGENCY_CAMPAIGN_STEPS = exports.AGENCY_MATERIAL_ACTIONS = exports.AGENCY_OFFER_ACTIONS = exports.AGENCY_OFFER_STATUSES = exports.AGENCY_CAMPAIGN_MEMBER_STATES = exports.SETTLEMENT_FORMS = exports.isCampaignPlacement = exports.CAMPAIGN_PLATFORMS = exports.CAMPAIGN_PLACEMENTS = void 0;
12
+ exports.UpdateSettlementFormDto = exports.CreateAgencyMilestoneDto = exports.ConfirmMaterialUploadDto = exports.PrepareMaterialUploadDto = exports.MATERIAL_CONTENT_TYPE = exports.MATERIAL_IMAGE_TYPES = exports.MATERIAL_MAX_BYTES = exports.JoinCampaignDto = exports.CampaignMaterialActDto = exports.CampaignOfferActDto = exports.SendCampaignOfferDto = exports.InviteCampaignCreatorDto = exports.UpdateAgencyCampaignDto = exports.CreateAgencyCampaignDto = exports.AGENCY_CAMPAIGN_CODES = exports.AGENCY_CAMPAIGN_EVENT_KINDS = exports.AGENCY_MILESTONE_MEDIA_RULES = exports.AGENCY_MILESTONE_OFFER_RULES = exports.AGENCY_MILESTONE_KINDS = exports.AGENCY_CAMPAIGN_STEPS = exports.AGENCY_MATERIAL_ACTIONS = exports.AGENCY_OFFER_ACTIONS = exports.AGENCY_OFFER_STATUSES = exports.AGENCY_CAMPAIGN_MEMBER_STATES = exports.AGENCY_CAMPAIGN_KINDS = exports.SETTLEMENT_FORMS = exports.isCampaignPlacement = exports.CAMPAIGN_PLATFORMS = exports.CAMPAIGN_PLACEMENTS = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const I_Media_1 = require("./I_Media");
15
15
  const I_Offer_1 = require("./I_Offer");
16
16
  const agency_1 = require("./agency");
17
+ const agency_pots_1 = require("./agency-pots");
17
18
  /**
18
19
  * The campaign loop (spec 175 US7) — an organization runs a campaign with the
19
20
  * creators on its roster or in the directory.
@@ -52,6 +53,12 @@ exports.isCampaignPlacement = isCampaignPlacement;
52
53
  /** The creator's own setting. The agency reads it and can never set it. */
53
54
  exports.SETTLEMENT_FORMS = ['invoice', 'contract', 'barter'];
54
55
  // ── States ───────────────────────────────────────────────────────────────────
56
+ /**
57
+ * An offer campaign negotiates one price per creator (US7); a pot campaign pays
58
+ * from one pot on each creator's own terms (US9). Chosen at creation, fixed once
59
+ * the first creator is invited (FR-030).
60
+ */
61
+ exports.AGENCY_CAMPAIGN_KINDS = ['offer', 'pot'];
55
62
  exports.AGENCY_CAMPAIGN_MEMBER_STATES = ['invited', 'joined', 'declined', 'left', 'removed'];
56
63
  /** The offer statuses the agency loop writes. `draft`, `deleted` and `alternativeSuggested` are legacy-only. */
57
64
  exports.AGENCY_OFFER_STATUSES = [
@@ -110,6 +117,32 @@ exports.AGENCY_CAMPAIGN_EVENT_KINDS = [
110
117
  'material_rejected',
111
118
  'published',
112
119
  'milestone_confirmed',
120
+ // US9: the pot. Every money act carries its amount (FR-021, FR-033).
121
+ 'pot_applied',
122
+ 'pot_application_withdrawn',
123
+ 'pot_accepted',
124
+ 'pot_declined',
125
+ 'pot_released',
126
+ 'pot_refilled',
127
+ 'pot_moved',
128
+ 'pot_deadline_moved',
129
+ 'pot_publish_time_set',
130
+ 'pot_publish_time_confirmed',
131
+ /** Zernio refused the post at scheduling; `note` carries its reason. */
132
+ 'pot_publish_refused',
133
+ 'pot_published',
134
+ 'pot_counted',
135
+ 'pot_frozen',
136
+ 'pot_bonus_held',
137
+ 'pot_bonus_approved',
138
+ 'pot_bonus_capped',
139
+ 'pot_bonus_message',
140
+ 'pot_kept',
141
+ 'pot_broken',
142
+ 'pot_removal_decided',
143
+ 'caption_edited',
144
+ 'file_uploaded',
145
+ 'file_removed',
113
146
  ];
114
147
  /** Refusal codes the frontend owes its own copy for. */
115
148
  exports.AGENCY_CAMPAIGN_CODES = {
@@ -132,9 +165,10 @@ exports.AGENCY_CAMPAIGN_CODES = {
132
165
  // linked lib carries its own copy whose metadata the backend's ValidationPipe
133
166
  // never reads. `deliverables` is an array of plain objects checked item by
134
167
  // item in the service against CAMPAIGN_PLACEMENTS — the pair is the rule.
135
- /** The brief's fields, shared by create and update. All optional on the wire. */
136
- class AgencyCampaignBriefFields {
168
+ /** The brief's fields, shared by create and update. All optional on the wire. The pot's fields ride along (US9). */
169
+ class AgencyCampaignBriefFields extends agency_pots_1.PotFields {
137
170
  assignBrief(data) {
171
+ this.assignPot(data);
138
172
  this.text = data?.text;
139
173
  this.deliverables = data?.deliverables;
140
174
  this.draftDueAt = data?.draftDueAt;
@@ -191,6 +225,7 @@ class CreateAgencyCampaignDto extends AgencyCampaignBriefFields {
191
225
  constructor(data) {
192
226
  super();
193
227
  this.name = data?.name ?? '';
228
+ this.kind = data?.kind;
194
229
  this.assignBrief(data);
195
230
  }
196
231
  }
@@ -201,11 +236,17 @@ __decorate([
201
236
  (0, class_validator_1.MaxLength)(128),
202
237
  __metadata("design:type", String)
203
238
  ], CreateAgencyCampaignDto.prototype, "name", void 0);
239
+ __decorate([
240
+ (0, class_validator_1.IsOptional)(),
241
+ (0, class_validator_1.IsIn)(exports.AGENCY_CAMPAIGN_KINDS),
242
+ __metadata("design:type", String)
243
+ ], CreateAgencyCampaignDto.prototype, "kind", void 0);
204
244
  class UpdateAgencyCampaignDto extends AgencyCampaignBriefFields {
205
245
  constructor(data) {
206
246
  super();
207
247
  this.name = data?.name;
208
248
  this.isDraft = data?.isDraft;
249
+ this.kind = data?.kind;
209
250
  this.assignBrief(data);
210
251
  }
211
252
  }
@@ -222,6 +263,11 @@ __decorate([
222
263
  (0, class_validator_1.IsBoolean)(),
223
264
  __metadata("design:type", Boolean)
224
265
  ], UpdateAgencyCampaignDto.prototype, "isDraft", void 0);
266
+ __decorate([
267
+ (0, class_validator_1.IsOptional)(),
268
+ (0, class_validator_1.IsIn)(exports.AGENCY_CAMPAIGN_KINDS),
269
+ __metadata("design:type", String)
270
+ ], UpdateAgencyCampaignDto.prototype, "kind", void 0);
225
271
  class InviteCampaignCreatorDto {
226
272
  constructor(data) {
227
273
  this.creatorUserId = data?.creatorUserId ?? '';
@@ -361,6 +407,7 @@ __decorate([
361
407
  class ConfirmMaterialUploadDto {
362
408
  constructor(data) {
363
409
  this.uploadId = data?.uploadId ?? '';
410
+ this.caption = data?.caption;
364
411
  }
365
412
  }
366
413
  exports.ConfirmMaterialUploadDto = ConfirmMaterialUploadDto;
@@ -370,6 +417,12 @@ __decorate([
370
417
  (0, class_validator_1.MaxLength)(512),
371
418
  __metadata("design:type", String)
372
419
  ], ConfirmMaterialUploadDto.prototype, "uploadId", void 0);
420
+ __decorate([
421
+ (0, class_validator_1.IsOptional)(),
422
+ (0, class_validator_1.IsString)(),
423
+ (0, class_validator_1.MaxLength)(2200),
424
+ __metadata("design:type", String)
425
+ ], ConfirmMaterialUploadDto.prototype, "caption", void 0);
373
426
  class CreateAgencyMilestoneDto {
374
427
  constructor(data) {
375
428
  this.kind = data?.kind ?? 'custom';