ad2app-lib 1.50.0 → 1.59.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.
@@ -9,7 +9,7 @@ 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.AdminSetOrganizationStatusDto = exports.UpdateAgencyDiscoverableDto = exports.AgencyAccessRequestDto = exports.AgencyDiscoverQueryDto = exports.SponsorCreatorDto = exports.UpdateGrantScopesDto = exports.AcceptGrantDto = exports.AcceptAgencyMemberInviteDto = exports.RedeemAgencyInviteDto = exports.InviteAgencyMemberDto = exports.CreateAgencyOrganizationDto = exports.AGENCY_ROSTER_METRICS_STATES = exports.AGENCY_ROSTER_NEEDS_ATTENTION_STATES = exports.AGENCY_ROSTER_ROW_STATES = exports.AGENCY_REQUEST_CODES = exports.CREATOR_ACCESS_GRANT_STATES = exports.AGENCY_ORGANIZATION_STATUSES = exports.isAgencyGrantScope = exports.AGENCY_GRANT_SCOPES = exports.AGENCY_ROUTE_PATHS = void 0;
12
+ exports.AdminSetOrganizationStatusDto = exports.UpdateAgencyDiscoverableDto = exports.AgencyAccessRequestDto = exports.AgencyDiscoverQueryDto = exports.SponsorCreatorDto = exports.ACTING_FOR_HEADER = exports.UpdateGrantScopesDto = exports.AcceptGrantDto = exports.AcceptAgencyMemberInviteDto = exports.RedeemAgencyInviteDto = exports.InviteAgencyMemberDto = exports.CreateAgencyOrganizationDto = exports.AGENCY_ROSTER_METRICS_STATES = exports.AGENCY_ROSTER_NEEDS_ATTENTION_STATES = exports.AGENCY_ROSTER_ROW_STATES = exports.AGENCY_REQUEST_CODES = exports.CREATOR_ACCESS_GRANT_ORIGINS = exports.CREATOR_ACCESS_GRANT_STATES = exports.AGENCY_ORGANIZATION_STATUSES = exports.AGENCY_ORGANIZATION_TYPES = exports.isGrantScope = exports.DELEGATION_SCOPES = exports.isAgencyGrantScope = exports.AGENCY_GRANT_SCOPES = exports.AGENCY_ROUTE_PATHS = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  // ── Cross-repo route constants ───────────────────────────────────────────────
15
15
  /**
@@ -61,6 +61,27 @@ exports.AGENCY_GRANT_SCOPES = [
61
61
  */
62
62
  const isAgencyGrantScope = (value) => exports.AGENCY_GRANT_SCOPES.includes(value);
63
63
  exports.isAgencyGrantScope = isAgencyGrantScope;
64
+ /**
65
+ * Delegation (spec 148 FR-017a): the one scope that reaches WRITES, and only
66
+ * the creator-side deal acts (apply, offer acts, materials, the deal thread).
67
+ *
68
+ * Kept OUT of AGENCY_GRANT_SCOPES on purpose: that list is what an
69
+ * organization may ASK for, and no organization ever asks for this. Only the
70
+ * creator adds it to `grantedScopes`, which makes it the one exception to
71
+ * "granted is a subset of requested". Publishing, contract signature,
72
+ * payouts, the settlement form and platforms stay unreachable through it.
73
+ */
74
+ exports.DELEGATION_SCOPES = ['deals'];
75
+ /** Narrowing guard over both sets; an unrecognised scope fails closed. */
76
+ const isGrantScope = (value) => (0, exports.isAgencyGrantScope)(value) || exports.DELEGATION_SCOPES.includes(value);
77
+ exports.isGrantScope = isGrantScope;
78
+ // ── Organization ─────────────────────────────────────────────────────────────
79
+ /**
80
+ * `'brand'` arrived with spec 148 (US2): one column, no enum table. A brand
81
+ * authors campaigns like an agency but has no roster; it is created only
82
+ * while the backend's brand door is open.
83
+ */
84
+ exports.AGENCY_ORGANIZATION_TYPES = ['agency', 'brand'];
64
85
  /**
65
86
  * `closed` was added by the 2026-09-21 requirements review (FR-004b).
66
87
  *
@@ -91,6 +112,12 @@ exports.CREATOR_ACCESS_GRANT_STATES = [
91
112
  'expired',
92
113
  'revoked',
93
114
  ];
115
+ /**
116
+ * `dealroom_application` (spec 148): created or widened when the creator
117
+ * applies to an open listing. The system revokes a grant of this origin, and
118
+ * only of this origin, when that deal ends.
119
+ */
120
+ exports.CREATOR_ACCESS_GRANT_ORIGINS = ['invite_link', 'agency_request', 'dealroom_application'];
94
121
  /**
95
122
  * Outcomes of discovery and requests that are not refusals of access, sent as
96
123
  * codes so the screen composes the sentence in the reader's language (FR-019,
@@ -171,6 +198,8 @@ exports.AGENCY_ROSTER_METRICS_STATES = [
171
198
  */
172
199
  class CreateAgencyOrganizationDto {
173
200
  constructor(data) {
201
+ this.type = data?.type;
202
+ this.paymentMethodId = data?.paymentMethodId;
174
203
  this.name = data?.name ?? '';
175
204
  this.website = data?.website;
176
205
  this.registryId = data?.registryId ?? '';
@@ -203,6 +232,17 @@ __decorate([
203
232
  (0, class_validator_1.IsEmail)(),
204
233
  __metadata("design:type", String)
205
234
  ], CreateAgencyOrganizationDto.prototype, "contactEmail", void 0);
235
+ __decorate([
236
+ (0, class_validator_1.IsOptional)(),
237
+ (0, class_validator_1.IsIn)(exports.AGENCY_ORGANIZATION_TYPES),
238
+ __metadata("design:type", String)
239
+ ], CreateAgencyOrganizationDto.prototype, "type", void 0);
240
+ __decorate([
241
+ (0, class_validator_1.IsOptional)(),
242
+ (0, class_validator_1.IsString)(),
243
+ (0, class_validator_1.Matches)(/^pm_[A-Za-z0-9]{1,200}$/),
244
+ __metadata("design:type", String)
245
+ ], CreateAgencyOrganizationDto.prototype, "paymentMethodId", void 0);
206
246
  class InviteAgencyMemberDto {
207
247
  constructor(data) {
208
248
  this.email = data?.email ?? '';
@@ -265,19 +305,46 @@ __decorate([
265
305
  (0, class_validator_1.IsIn)(exports.AGENCY_GRANT_SCOPES, { each: true }),
266
306
  __metadata("design:type", Array)
267
307
  ], AcceptGrantDto.prototype, "scopes", void 0);
268
- /** The creator narrowing or widening a live grant — the only other write path. */
308
+ /**
309
+ * The creator narrowing or widening a live grant — the only other write path.
310
+ *
311
+ * `scopes` are the READS only; `deals` is never one of them (it stays out of
312
+ * AGENCY_GRANT_SCOPES). Delegation (spec 148 FR-017a) is its own field, so the
313
+ * data-access screen, which saves reads, can never drop it by omission:
314
+ *
315
+ * - `deals` absent ⇒ delegation unchanged (a reads-only save keeps `deals`);
316
+ * - `deals: true` ⇒ added, `deals: false` ⇒ removed;
317
+ * - `scopes` may be left out when `deals` is sent ⇒ the reads stay as they are.
318
+ */
269
319
  class UpdateGrantScopesDto {
270
320
  constructor(data) {
271
- this.scopes = data?.scopes ?? [];
321
+ // Undefined when not given (never []): class-transformer builds the body
322
+ // with an empty construct, and a default would make `{ deals: true }` fail.
323
+ if (data?.scopes !== undefined)
324
+ this.scopes = data.scopes;
325
+ if (data?.deals !== undefined)
326
+ this.deals = data.deals;
272
327
  }
273
328
  }
274
329
  exports.UpdateGrantScopesDto = UpdateGrantScopesDto;
275
330
  __decorate([
331
+ (0, class_validator_1.ValidateIf)((dto) => dto.deals === undefined || dto.scopes !== undefined),
276
332
  (0, class_validator_1.IsArray)(),
277
333
  (0, class_validator_1.ArrayNotEmpty)(),
278
334
  (0, class_validator_1.IsIn)(exports.AGENCY_GRANT_SCOPES, { each: true }),
279
335
  __metadata("design:type", Array)
280
336
  ], UpdateGrantScopesDto.prototype, "scopes", void 0);
337
+ __decorate([
338
+ (0, class_validator_1.IsOptional)(),
339
+ (0, class_validator_1.IsBoolean)(),
340
+ __metadata("design:type", Boolean)
341
+ ], UpdateGrantScopesDto.prototype, "deals", void 0);
342
+ /**
343
+ * Spec 148 US8: the header a delegate names the creator with on the
344
+ * creator-side deal routes (`X-Acting-For: <creatorUserId>`). Every other
345
+ * route refuses a request that carries it (`dealroom-delegate-forbidden`).
346
+ */
347
+ exports.ACTING_FOR_HEADER = 'x-acting-for';
281
348
  class SponsorCreatorDto {
282
349
  constructor(data) {
283
350
  this.tier = data?.tier ?? 'starter';