@cookiemunch/sdk 0.14.2 → 0.15.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.
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ import type { ConformanceReport } from './executor-conformance.js';
20
20
  * This package's version, sent in the default User-Agent. Cloudflare answers a request with
21
21
  * no recognisable User-Agent with `403 error code: 1010`; a test pins this to package.json.
22
22
  */
23
- export declare const SDK_VERSION = "0.14.2";
23
+ export declare const SDK_VERSION = "0.15.1";
24
24
  export interface CookieMunchOptions {
25
25
  apiKey: string;
26
26
  /** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
@@ -138,7 +138,8 @@ export interface ProvisionRequestV2 {
138
138
  secretKey?: string;
139
139
  cookieConsent?: boolean;
140
140
  executor?: boolean;
141
- frontendApiHost?: string;
141
+ frontendApiHost?: string; /** Atlas's one-call connect (step `atlas.connect`): the connection holds Atlas's narrow key, never `secretKey`. */
142
+ connect?: boolean;
142
143
  };
143
144
  forumulate?: {
144
145
  org?: string;
@@ -573,6 +574,8 @@ export interface CookiePreset {
573
574
  }>;
574
575
  applied: boolean;
575
576
  declared: string[];
577
+ /** An applied preset: names the site was seen writing under the vendor's prefixes that nothing declares. */
578
+ incomplete?: string[];
576
579
  manifest: CookiePresetManifest;
577
580
  }
578
581
  /** What applying a preset declared. */
@@ -587,10 +590,16 @@ export interface CookiePresetResult {
587
590
  reason: string;
588
591
  }>;
589
592
  note?: string;
590
- /** Rows filed under a category this site has switched off (`cookies[<name>].category`). */
593
+ /**
594
+ * Rows filed under a category this site has switched off (`cookies[<name>].category`); `preset_incomplete`
595
+ * (observed `names` under the vendor's prefixes the preset does not declare); `lifetime_default` (a referral
596
+ * preset's default lifetime: send `cookieDays`, or Referalli `programHandle`/`orgToken`).
597
+ */
591
598
  warnings?: Array<{
592
599
  field: string;
593
600
  reason: string;
601
+ code?: string;
602
+ names?: string[];
594
603
  }>;
595
604
  /** With `warnings`: a body for `sites.patchConfig` that fixes them; apply the preset again after. */
596
605
  suggestedConfigPatch?: Record<string, unknown>;
@@ -2143,6 +2152,12 @@ export interface PolicyOptions {
2143
2152
  effectiveDate?: string;
2144
2153
  /** Override the jurisdictions the policy addresses. */
2145
2154
  jurisdictions?: string[];
2155
+ /** `cookies`: only the cookie table section (needs no contact email). */
2156
+ fragment?: 'cookies';
2157
+ /** With `fragment: 'cookies'`: Markdown (default) or escaped HTML tables. */
2158
+ format?: 'markdown' | 'html';
2159
+ /** The text's language; the policy is written in English only (`en`). */
2160
+ lang?: string;
2146
2161
  }
2147
2162
  export interface AdPersonalizationInput {
2148
2163
  enabled: boolean;
@@ -2309,6 +2324,12 @@ export interface DsarExecutor {
2309
2324
  requireApproval?: boolean;
2310
2325
  /** Made with `verify: 'defer'` and no probe has passed yet: not planned into requests, not alerted on. Absent: active. */
2311
2326
  state?: 'awaiting_first_probe';
2327
+ /** The last conformance run (`testExecutor` with `conformance: true`): rule counts and when (epoch ms). Null until one runs. */
2328
+ lastConformance?: {
2329
+ passed: number;
2330
+ failed: number;
2331
+ at: number;
2332
+ } | null;
2312
2333
  /** On create only: the completion secret, shown this once. */
2313
2334
  completionSecret?: string;
2314
2335
  }
@@ -2410,6 +2431,8 @@ export interface ExecutorPresets {
2410
2431
  title: string;
2411
2432
  latestVersion: number;
2412
2433
  defaultSystem?: string;
2434
+ /** Presets of one family (cm-standard) a connection may move between in place: `updateExecutor(id, { preset })`. */
2435
+ family?: string;
2413
2436
  params: Array<{
2414
2437
  name: string;
2415
2438
  required: boolean;
@@ -2521,6 +2544,12 @@ export interface DsarExecutorPatch {
2521
2544
  orchestrator?: 1 | 2;
2522
2545
  /** Park its erasures for approval; false stops parking new ones (parked ones still wait). */
2523
2546
  requireApproval?: boolean;
2547
+ /**
2548
+ * Another preset of the same family (cm-standard-v1 → cm-standard-v2) moves the connection in place, keeping its
2549
+ * id, credentials and history; any other preset change is 409 immutable_field.
2550
+ */
2551
+ preset?: ExecutorPresetName;
2552
+ presetVersion?: number;
2524
2553
  }
2525
2554
  /** One entry in a fulfilment task's status history. */
2526
2555
  export interface DsarTaskEvent {
@@ -2680,12 +2709,14 @@ export interface CookieMunchClient {
2680
2709
  /**
2681
2710
  * Create a sibling organisation owned by the same account — for a separate business of
2682
2711
  * your own. Needs an unscoped key. Not reseller provisioning, which is for your customers.
2712
+ * `inheritFrom` copies another of the account's orgs' data controller and mail provider (unverified until tested).
2683
2713
  */
2684
2714
  create(name: string, opts?: {
2685
2715
  mintKey?: boolean;
2686
2716
  keyScopes?: string[];
2687
2717
  keyExpiresInDays?: number;
2688
2718
  keyOwner?: string;
2719
+ inheritFrom?: string;
2689
2720
  } & ResourceTagsInput): Promise<{
2690
2721
  org: {
2691
2722
  id: string;
@@ -2694,6 +2725,11 @@ export interface CookieMunchClient {
2694
2725
  };
2695
2726
  apiKey?: string;
2696
2727
  keyError?: string;
2728
+ inherited?: {
2729
+ controller: boolean;
2730
+ mailProvider: boolean;
2731
+ };
2732
+ warnings?: string[];
2697
2733
  }>;
2698
2734
  /** Hard-delete a SANDBOX organisation of this account (created with metadata.stack_sandbox). Anything else: 403 not_a_sandbox. */
2699
2735
  deleteSandbox(id: string): Promise<SandboxPurge>;
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ async function exchangeOperatorToken(input) {
88
88
  }
89
89
 
90
90
  // src/index.ts
91
- var SDK_VERSION = "0.14.2";
91
+ var SDK_VERSION = "0.15.1";
92
92
  var CookieMunchApiError = class extends Error {
93
93
  constructor(status, message, code, body) {
94
94
  super(message);
@@ -103,6 +103,12 @@ function metaQs(o) {
103
103
  const parts = Object.entries(o?.metadata ?? {}).map(([k, v]) => `metadata%5B${encodeURIComponent(k)}%5D=${encodeURIComponent(v)}`);
104
104
  return parts.length ? `?${parts.join("&")}` : "";
105
105
  }
106
+ function unwrapList(version, body) {
107
+ if (!version || version < "2026-11-03" || !body || typeof body !== "object" || Array.isArray(body)) return body;
108
+ const o = body;
109
+ const keys = Object.keys(o);
110
+ return Array.isArray(o.data) && keys.every((k) => k === "data" || k === "next") ? o.data : body;
111
+ }
106
112
  function qs(query) {
107
113
  if (!query) return "";
108
114
  const parts = [];
@@ -146,7 +152,7 @@ function createCookieMunch(opts) {
146
152
  if (res.status === 204) return void 0;
147
153
  if (raw) return res.text();
148
154
  const contentType = res.headers.get("content-type") ?? "";
149
- return contentType.includes("application/json") ? res.json() : res.text();
155
+ return contentType.includes("application/json") ? unwrapList(res.headers.get("cookiemunch-version"), await res.json()) : res.text();
150
156
  }
151
157
  const get = (p) => request("GET", p);
152
158
  async function requestBytes(path) {
@@ -222,7 +228,7 @@ function createCookieMunch(opts) {
222
228
  ab: (cbid) => get(`/sites/${enc(cbid)}/ab`),
223
229
  policy: (cbid, o) => request(
224
230
  "GET",
225
- `/sites/${enc(cbid)}/policy${qs({ contactEmail: o?.contactEmail, effectiveDate: o?.effectiveDate, jurisdictions: o?.jurisdictions?.join(",") })}`,
231
+ `/sites/${enc(cbid)}/policy${qs({ contactEmail: o?.contactEmail, effectiveDate: o?.effectiveDate, jurisdictions: o?.jurisdictions?.join(","), fragment: o?.fragment, format: o?.format, lang: o?.lang })}`,
226
232
  void 0,
227
233
  true
228
234
  ),