@adport/provider-microsoft 0.9.0 → 0.10.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.
package/dist/index.js CHANGED
@@ -1309,14 +1309,14 @@ var expression = z9.object({ operator: z9.enum(["BeginsWith", "Contains", "Equal
1309
1309
  var event = z9.object({ action: expression.optional(), category: expression.optional(), label: expression.optional(), value: z9.object({ operator: z9.enum(["Equals", "GreaterThan", "LessThan"]), amount: z9.number() }).optional() }).refine((value) => Object.values(value).some((value2) => value2 !== void 0), "At least one complete event condition is required");
1310
1310
  var url2 = z9.object({ operator: expression.shape.operator, expression: z9.string().min(1).max(1e3) });
1311
1311
  var revenue = z9.discriminatedUnion("type", [z9.object({ type: z9.literal("NoValue") }), z9.object({ type: z9.literal("FixedValue"), value: z9.number().nonnegative(), currency: z9.string().regex(/^[A-Z]{3}$/).optional() }), z9.object({ type: z9.literal("VariableValue"), value: z9.number().nonnegative().optional(), currency: z9.string().regex(/^[A-Z]{3}$/).optional() })]);
1312
- var common = z9.object({ name: name2, goal_category: category, status: z9.enum(["Active", "Paused"]).default("Paused"), exclude_from_bidding: z9.boolean().default(true), count_type: z9.enum(["All", "Unique"]).default("All"), conversion_window_minutes: z9.number().int().min(1).max(129600).default(43200), revenue: revenue.default({ type: "NoValue" }), expected_auto_tagging_enabled: z9.boolean() });
1312
+ var common = z9.object({ name: name2, goal_category: category, status: z9.enum(["Active", "Paused"]).default("Paused"), exclude_from_bidding: z9.boolean().default(true), count_type: z9.enum(["All", "Unique"]).default("All"), conversion_window_minutes: z9.number().int().min(1).max(129600).default(43200), revenue: revenue.default({ type: "NoValue" }), enhanced_conversions_enabled: z9.boolean().optional().describe("IsEnhancedConversionsEnabled; Microsoft accepts true only once one goal in the account has it enabled in the web UI"), expected_auto_tagging_enabled: z9.boolean() });
1313
1313
  var create2 = z9.object({ goal: z9.discriminatedUnion("type", [common.extend({ type: z9.literal("OfflineConversion"), is_externally_attributed: z9.boolean().default(false) }), common.extend({ type: z9.literal("Url"), tag_id: microsoftId, url_rule: url2 }), common.extend({ type: z9.literal("Event"), tag_id: microsoftId, event_conditions: event })]) });
1314
- var update3 = z9.object({ goal_id: microsoftId, goal_type: supportedType, expected_snapshot_hash: z9.string().regex(/^[a-f0-9]{64}$/), name: name2.optional(), goal_category: category.optional(), status: z9.enum(["Active", "Paused"]).optional(), exclude_from_bidding: z9.boolean().optional(), count_type: z9.enum(["All", "Unique"]).optional(), conversion_window_minutes: z9.number().int().min(1).max(129600).optional(), revenue: revenue.optional(), is_externally_attributed: z9.boolean().optional(), url_rule: url2.optional(), event_conditions: event.optional() }).refine((value) => Object.entries(value).some(([key, value2]) => !["goal_id", "goal_type", "expected_snapshot_hash"].includes(key) && value2 !== void 0), "Supply an editable field");
1314
+ var update3 = z9.object({ goal_id: microsoftId, goal_type: supportedType, expected_snapshot_hash: z9.string().regex(/^[a-f0-9]{64}$/), name: name2.optional(), goal_category: category.optional(), status: z9.enum(["Active", "Paused"]).optional(), exclude_from_bidding: z9.boolean().optional(), count_type: z9.enum(["All", "Unique"]).optional(), conversion_window_minutes: z9.number().int().min(1).max(129600).optional(), revenue: revenue.optional(), enhanced_conversions_enabled: z9.boolean().optional().describe("IsEnhancedConversionsEnabled; Microsoft accepts true only once one goal in the account has it enabled in the web UI"), is_externally_attributed: z9.boolean().optional(), url_rule: url2.optional(), event_conditions: event.optional() }).refine((value) => Object.entries(value).some(([key, value2]) => !["goal_id", "goal_type", "expected_snapshot_hash"].includes(key) && value2 !== void 0), "Supply an editable field");
1315
1315
  var createTag = z9.object({ name: name2, description: z9.string().min(1).max(1e3).optional(), expected_customer_id: microsoftId.describe("native_customer_id from microsoft_linked_uet_tags") });
1316
1316
  var view = z9.object({ account_id: microsoftId, goal: z9.record(z9.string(), z9.unknown()), auto_tagging_enabled: z9.boolean().describe("MSCLKIDAutoTaggingEnabled on the selected account, separate from the goal Scope"), auto_tagging_scope: z9.literal("Account"), snapshot_hash: z9.string().regex(/^[a-f0-9]{64}$/) });
1317
1317
  var additional = "GoalCategory, IsExternallyAttributed, IsAutoGoal, IsEnhancedConversionsEnabled, ViewThroughConversionWindowInMinutes, AttributionModelType, ApplicationDownloadGoal";
1318
1318
  var pairs = [["ActionExpression", "ActionOperator", "action"], ["CategoryExpression", "CategoryOperator", "category"], ["LabelExpression", "LabelOperator", "label"], ["Value", "ValueOperator", "value"]];
1319
- var notes2 = ["Microsoft automatically enables MSCLKIDAutoTaggingEnabled when adding or updating this goal, including paused goals. This tool does not install a UET tag or send conversion events.", "Account scope is fixed. Native Deleted status is internal-only; no permanent goal-deletion operation is exposed. Use Paused to stop tracking.", "Goal snapshots detect changed configuration before submission; Microsoft provides no atomic compare-and-set. Conversion settings can affect reporting and automated bidding."];
1319
+ var notes2 = ["Microsoft automatically enables MSCLKIDAutoTaggingEnabled when adding or updating this goal, including paused goals. This tool does not install a UET tag or send conversion events.", "Account scope is fixed. Native Deleted status is internal-only; no permanent goal-deletion operation is exposed. Use Paused to stop tracking.", "Goal snapshots detect changed configuration before submission; Microsoft provides no atomic compare-and-set. Conversion settings can affect reporting and automated bidding.", "Enhanced conversions match hashed customer data sent with UET or offline conversions. Microsoft rejects IsEnhancedConversionsEnabled=true until one goal in the account has it enabled in the web UI."];
1320
1320
  function canonical(value) {
1321
1321
  return Array.isArray(value) ? value.map(canonical) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, value2]) => [key, canonical(value2)])) : value;
1322
1322
  }
@@ -1415,8 +1415,8 @@ var MicrosoftConversionService = class extends MicrosoftNativeService {
1415
1415
  if (existing.some((goal) => typeof goal.Name === "string" && goal.Name.toLowerCase() === value2.name.toLowerCase())) throw new AdportError10("INVALID_INPUT", "microsoft: conversion goal name already exists; do not replay creation");
1416
1416
  if ("tag_id" in value2) await this.tag(account, value2.tag_id);
1417
1417
  const status2 = guard.forcePausedCreation ? "Paused" : value2.status;
1418
- const fields3 = { Type: value2.type, Scope: "Account", Name: value2.name, Status: status2, GoalCategory: value2.goal_category, ExcludeFromBidding: value2.exclude_from_bidding, CountType: value2.count_type, ConversionWindowInMinutes: value2.conversion_window_minutes, Revenue: wireRevenue(value2.revenue), ...value2.type === "OfflineConversion" ? { IsExternallyAttributed: value2.is_externally_attributed } : { TagId: value2.tag_id }, ...value2.type === "Url" ? { UrlExpression: value2.url_rule.expression, UrlOperator: value2.url_rule.operator } : value2.type === "Event" ? eventFields(value2.event_conditions) : {} };
1419
- return { summary: `Create Microsoft ${value2.type} goal "${value2.name}"`, changes: [`+ account-scoped conversion goal ${JSON.stringify(fields3)}`, `MSCLKIDAutoTaggingEnabled ${enabled} \u2192 true (native side effect)`], fieldChanges: [{ field: "Name", before: "(new)", after: value2.name }, { field: "Status", before: "(new)", after: status2 }, { field: "MSCLKIDAutoTaggingEnabled", before: String(enabled), after: "true" }], notes: notes2, coercions: status2 !== value2.status ? ["Status coerced to Paused by policy (paused_creation)"] : [], budgetDeltas: [], execute: async () => {
1418
+ const fields3 = { Type: value2.type, Scope: "Account", Name: value2.name, Status: status2, GoalCategory: value2.goal_category, ExcludeFromBidding: value2.exclude_from_bidding, CountType: value2.count_type, ConversionWindowInMinutes: value2.conversion_window_minutes, Revenue: wireRevenue(value2.revenue), ...value2.enhanced_conversions_enabled !== void 0 ? { IsEnhancedConversionsEnabled: value2.enhanced_conversions_enabled } : {}, ...value2.type === "OfflineConversion" ? { IsExternallyAttributed: value2.is_externally_attributed } : { TagId: value2.tag_id }, ...value2.type === "Url" ? { UrlExpression: value2.url_rule.expression, UrlOperator: value2.url_rule.operator } : value2.type === "Event" ? eventFields(value2.event_conditions) : {} };
1419
+ return { summary: `Create Microsoft ${value2.type} goal "${value2.name}"`, changes: [`+ account-scoped conversion goal ${JSON.stringify(fields3)}`, `MSCLKIDAutoTaggingEnabled ${enabled} \u2192 true (native side effect)`], fieldChanges: [{ field: "Name", before: "(new)", after: value2.name }, { field: "Status", before: "(new)", after: status2 }, ...value2.enhanced_conversions_enabled !== void 0 ? [{ field: "IsEnhancedConversionsEnabled", before: "(new)", after: String(value2.enhanced_conversions_enabled) }] : [], { field: "MSCLKIDAutoTaggingEnabled", before: String(enabled), after: "true" }], notes: notes2, coercions: status2 !== value2.status ? ["Status coerced to Paused by policy (paused_creation)"] : [], budgetDeltas: [], execute: async () => {
1420
1420
  const result = await this.request(account, "ConversionGoals", { ConversionGoals: [fields3] });
1421
1421
  const ids = Array.isArray(result.ConversionGoalIds) ? result.ConversionGoalIds.filter((value3) => value3 !== null).map(microsoftNativeId) : [];
1422
1422
  if (ids.length !== 1 || existing.some((goal) => microsoftNativeId(goal.Id) === ids[0])) throw new AdportError10("PROVIDER_ERROR", "microsoft: conversion-goal creation receipt mismatch; reconcile before retrying", { resourceIds: ids });
@@ -1428,7 +1428,7 @@ var MicrosoftConversionService = class extends MicrosoftNativeService {
1428
1428
  if (current.snapshot_hash !== value.expected_snapshot_hash) throw new AdportError10("INVALID_INPUT", "microsoft: conversion-goal snapshot changed; read fresh context and request a new preview");
1429
1429
  if (value.url_rule && value.goal_type !== "Url" || value.event_conditions && value.goal_type !== "Event" || value.is_externally_attributed !== void 0 && value.goal_type !== "OfflineConversion") throw new AdportError10("INVALID_INPUT", "microsoft: conversion-goal subtype fields mismatch");
1430
1430
  const fields2 = {};
1431
- for (const [key, field] of [["name", "Name"], ["goal_category", "GoalCategory"], ["status", "Status"], ["exclude_from_bidding", "ExcludeFromBidding"], ["count_type", "CountType"], ["conversion_window_minutes", "ConversionWindowInMinutes"], ["is_externally_attributed", "IsExternallyAttributed"]]) if (value[key] !== void 0 && value[key] !== current.goal[field]) fields2[field] = value[key];
1431
+ for (const [key, field] of [["name", "Name"], ["goal_category", "GoalCategory"], ["status", "Status"], ["exclude_from_bidding", "ExcludeFromBidding"], ["count_type", "CountType"], ["conversion_window_minutes", "ConversionWindowInMinutes"], ["enhanced_conversions_enabled", "IsEnhancedConversionsEnabled"], ["is_externally_attributed", "IsExternallyAttributed"]]) if (value[key] !== void 0 && value[key] !== current.goal[field]) fields2[field] = value[key];
1432
1432
  if (value.revenue) fields2.Revenue = wireRevenue(value.revenue);
1433
1433
  if (value.url_rule) Object.assign(fields2, { UrlExpression: value.url_rule.expression, UrlOperator: value.url_rule.operator });
1434
1434
  if (value.event_conditions) Object.assign(fields2, eventFields(value.event_conditions));