@cookiemunch/sdk 0.11.0 → 0.12.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.d.ts CHANGED
@@ -14,13 +14,13 @@ export * from './consent-sync.js';
14
14
  export * from './executor-conformance.js';
15
15
  export * from './token-exchange.js';
16
16
  export type * from './fd-consent.js';
17
- import type { CategoryRegistry, Identity, AccountOrgs, Site, SiteCreate, SiteConfig, SiteUpdate, SiteUpdateResult, IntegrationHealthReport, HealthWaiver, HealthWaiverInput, ProvisionRequest, ProvisionResult, PartnerLink, PartnerLinkCreate, PartnerCatalogEntry, ConsentDay, ConsentLogRow, RangeQuery, LogQuery, DsarRequest, DsarCreate, DsarCase, DsarCaseCreate, DsarCaseReceipt, DsarSettings, SubjectCard, IntegrationConnect, IntegrationConnectResult, DsarStatus, ScoredVendor, VendorInput, VendorRecord, RiskScore, RopaEntry, RopaInput, SignedReceipt, PreferenceRecord } from './types.js';
17
+ import type { CategoryRegistry, Identity, AccountOrgs, Site, SiteCreate, SiteConfig, SiteUpdate, SiteUpdateResult, IntegrationHealthReport, HealthWaiver, HealthWaiverInput, ProvisionRequest, ProvisionResult, PartnerLink, PartnerLinkCreate, PartnerCatalogEntry, ConsentDay, ConsentLogRow, RangeQuery, LogQuery, DsarRequest, DsarCreate, DsarCase, DsarCaseCreate, DsarCaseReceipt, DsarSettings, DsarSettingsInput, SubjectCard, IntegrationConnect, IntegrationConnectResult, DsarStatus, ScoredVendor, VendorInput, VendorRecord, RiskScore, RopaEntry, RopaInput, SignedReceipt, PreferenceRecord } from './types.js';
18
18
  import type { ConformanceReport } from './executor-conformance.js';
19
19
  /**
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.11.0";
23
+ export declare const SDK_VERSION = "0.12.0";
24
24
  export interface CookieMunchOptions {
25
25
  apiKey: string;
26
26
  /** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
@@ -334,6 +334,51 @@ export interface DeclaredCookie extends DeclaredCookieInput {
334
334
  source?: 'import';
335
335
  /** The vendor whose preset declared it. */
336
336
  vendor?: string;
337
+ /** The `purposes` languages that are machine translations (sites.translateCookies); absent = all human-written. */
338
+ machinePurposes?: string[];
339
+ }
340
+ /** GET/PUT/DELETE /v1/sites/:cbid/translation — the site's own translation account. Never the key. */
341
+ export interface TranslationConnection {
342
+ cbid: string;
343
+ connected: boolean;
344
+ provider: 'deepl' | 'google' | null;
345
+ keyLast4: string | null;
346
+ /** First 12 hex of SHA-256(key). */
347
+ keyFingerprint: string | null;
348
+ connectedAt: number | null;
349
+ /** On connect only: whether the key was checked with the provider first. */
350
+ verified?: boolean;
351
+ }
352
+ /** POST /v1/sites/:cbid/cookies/translate */
353
+ export interface CookieTranslateResult {
354
+ dryRun: boolean;
355
+ provider: 'deepl' | 'google' | null;
356
+ languages: string[];
357
+ /** Languages the provider cannot translate into. Reported, not a failure. */
358
+ unsupported: Array<{
359
+ language: string;
360
+ reason: string;
361
+ }>;
362
+ /** Languages whose provider call failed; nothing was stored for them. */
363
+ failed: Array<{
364
+ language: string;
365
+ error: string;
366
+ }>;
367
+ characters: number;
368
+ translated: number;
369
+ rows: number;
370
+ /** `text` is absent on a dry run. */
371
+ changes: Array<{
372
+ name: string;
373
+ language: string;
374
+ source: string;
375
+ text?: string;
376
+ }>;
377
+ skipped: Array<{
378
+ name: string;
379
+ language: string;
380
+ reason: string;
381
+ }>;
337
382
  }
338
383
  /** A platform whose cookies and storage a preset declares. */
339
384
  export type CookiePresetVendor = 'atlas' | 'forumulate' | 'chatly' | 'cookiemunch' | 'referalli' | 'firstpromoter' | 'partnerstack' | 'tapfiliate' | 'impact'
@@ -708,6 +753,33 @@ export interface ConfigChange {
708
753
  export interface PutConfigOptions {
709
754
  keep?: 'unspecified';
710
755
  }
756
+ /** What `POST /v1/dsar?dryRun=1` would do: nothing was filed, and no connected system was contacted. */
757
+ export interface DsarCreateDryRun {
758
+ dryRun: true;
759
+ /** The connections auto-planning would open a task on once the request is verified. */
760
+ plan: Array<{
761
+ id: string;
762
+ system: string;
763
+ preset?: string;
764
+ op: 'export' | 'erase' | 'optOut';
765
+ reached: true;
766
+ requireApproval?: true;
767
+ }>;
768
+ skipped: Array<{
769
+ system: string;
770
+ reason: string;
771
+ }>;
772
+ status: 'received';
773
+ verificationRequired: true;
774
+ /** The deadline it would get (epoch ms). */
775
+ dueAt: number;
776
+ /** On a processor site: the controller it would be forwarded to (`plan` and `skipped` are then empty). */
777
+ forwardTo?: {
778
+ controllerId: string;
779
+ name: string;
780
+ kind: 'cookiemunch' | 'webhook' | 'refer';
781
+ };
782
+ }
711
783
  /** What a config write would do (`?dryRun=1`) — nothing is saved. */
712
784
  export interface ConfigDryRun {
713
785
  dryRun: true;
@@ -2766,6 +2838,30 @@ export interface CookieMunchClient {
2766
2838
  }, opts?: {
2767
2839
  dryRun?: boolean;
2768
2840
  }): Promise<CookieSuggestionsDeclared>;
2841
+ /** The site's own translation account (DeepL or Google) for translateCookies. Never the key. */
2842
+ translation(cbid: string): Promise<TranslationConnection>;
2843
+ /**
2844
+ * Connect the site's own DeepL or Google Cloud Translation key (stored sealed, never returned).
2845
+ * `verify` checks it with the provider first, sending no text.
2846
+ */
2847
+ connectTranslation(cbid: string, input: {
2848
+ provider: 'deepl' | 'google';
2849
+ key: string;
2850
+ }, opts?: {
2851
+ verify?: boolean;
2852
+ }): Promise<TranslationConnection>;
2853
+ /** Disconnect it; translations already stored stay. */
2854
+ disconnectTranslation(cbid: string): Promise<TranslationConnection>;
2855
+ /**
2856
+ * Machine-translate the missing `purposes` of the site's own declarations on its connected
2857
+ * account. Never overwrites text a row has. `dryRun` lists the changes and calls no provider.
2858
+ */
2859
+ translateCookies(cbid: string, input?: {
2860
+ languages?: string[];
2861
+ names?: string[];
2862
+ }, opts?: {
2863
+ dryRun?: boolean;
2864
+ }): Promise<CookieTranslateResult>;
2769
2865
  /** Remove every declaration a vendor preset made. */
2770
2866
  removeCookiePreset(cbid: string, vendor: CookiePresetVendor | (string & {}), opts?: {
2771
2867
  dryRun?: boolean;
@@ -2886,8 +2982,17 @@ export interface CookieMunchClient {
2886
2982
  * wrapped as `{ request }`, so `create(...).request.id` is what you pass here.
2887
2983
  */
2888
2984
  get(id: string): Promise<DsarRequest>;
2889
- /** `skipped`: connections scoped to another property (or to one, when the request names none), never planned for it. */
2890
- create(input: DsarCreate & ResourceTagsInput): Promise<{
2985
+ /**
2986
+ * `skipped`: connections scoped to another property (or to one, when the request names none), never planned for it.
2987
+ * `{ dryRun: true }` files nothing and contacts no connected system: it answers which connections the request would
2988
+ * reach once verified (`plan`) and which it would skip.
2989
+ */
2990
+ create(input: DsarCreate & ResourceTagsInput, opts: {
2991
+ dryRun: true;
2992
+ }): Promise<DsarCreateDryRun>;
2993
+ create(input: DsarCreate & ResourceTagsInput, opts?: {
2994
+ dryRun?: false;
2995
+ }): Promise<{
2891
2996
  request: DsarRequest;
2892
2997
  consent?: {
2893
2998
  count: number;
@@ -2933,7 +3038,7 @@ export interface CookieMunchClient {
2933
3038
  /** Requests carrying one X-Trace-Id (`GET /v1/dsar?trace=`). */
2934
3039
  listByTrace(trace: string): Promise<DsarRequest[]>;
2935
3040
  /** Requests with one origin (`GET /v1/dsar?origin=`): `account_deletion`, those a person's own account deletion opened. */
2936
- listByOrigin(origin: 'account_deletion'): Promise<DsarRequest[]>;
3041
+ listByOrigin(origin: 'account_deletion' | 'processor_forward'): Promise<DsarRequest[]>;
2937
3042
  /**
2938
3043
  * Open a case fanned out to every connected system (POST /v1/dsar/requests). `opts.idempotencyKey`
2939
3044
  * (16–128 chars) makes a retry answer the same case; `opts.trace` passes your X-Trace-Id on.
@@ -3592,9 +3697,7 @@ export interface CookieMunchClient {
3592
3697
  /** A site's rights-request settings: graceDays (0–30; 7 for a new site, 0 until set for one that existed before). Requires dsar:read / dsar:write. */
3593
3698
  dsarSettings: {
3594
3699
  get(cbid: string): Promise<DsarSettings>;
3595
- set(cbid: string, input: {
3596
- graceDays: number;
3597
- }): Promise<DsarSettings>;
3700
+ set(cbid: string, input: DsarSettingsInput): Promise<DsarSettings>;
3598
3701
  };
3599
3702
  /** Cards for support, CRM and helpdesk sidebars (dsar:read), and one-call identity-provider connect (dsar:write). */
3600
3703
  integrations: {
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.11.0";
91
+ var SDK_VERSION = "0.12.0";
92
92
  var CookieMunchApiError = class extends Error {
93
93
  constructor(status, message, code, body) {
94
94
  super(message);
@@ -243,6 +243,10 @@ function createCookieMunch(opts) {
243
243
  importCookieManifest: (cbid, input, o) => request("PUT", `/sites/${enc(cbid)}/cookies/presets/custom${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
244
244
  cookieSuggestions: (cbid) => get(`/sites/${enc(cbid)}/cookies/suggestions`),
245
245
  declareCookieSuggestions: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/cookies/suggestions/declare${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input ?? {}),
246
+ translation: (cbid) => get(`/sites/${enc(cbid)}/translation`),
247
+ connectTranslation: (cbid, input, o) => request("PUT", `/sites/${enc(cbid)}/translation${qs({ verify: o?.verify ? "1" : void 0 })}`, input),
248
+ disconnectTranslation: (cbid) => request("DELETE", `/sites/${enc(cbid)}/translation`),
249
+ translateCookies: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/cookies/translate${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input ?? {}),
246
250
  removeCookiePreset: (cbid, vendor, o) => request("DELETE", `/sites/${enc(cbid)}/cookies/presets/${enc(vendor)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`),
247
251
  deleteObservedCookie: (async (cbid, name, o) => {
248
252
  const out = await request("DELETE", `/sites/${enc(cbid)}/observed-cookies/${enc(name)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`);
@@ -298,7 +302,7 @@ function createCookieMunch(opts) {
298
302
  dsar: {
299
303
  list: () => get("/dsar"),
300
304
  get: (id) => get(`/dsar/${enc(id)}`),
301
- create: (input) => request("POST", "/dsar", input),
305
+ create: ((input, o) => request("POST", `/dsar${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input)),
302
306
  advance: (id, toStatus, opts2) => request("POST", `/dsar/${enc(id)}/advance`, { toStatus, ...opts2?.messageToSubject !== void 0 ? { messageToSubject: opts2.messageToSubject } : {} }),
303
307
  response: (id) => request("GET", `/dsar/${enc(id)}/response`, void 0, true),
304
308
  erase: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/erase`, { cbid, stamp }),