@c15t/node-sdk 3.0.0-alpha.3 → 3.0.0-alpha.4

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.
@@ -1,730 +1,137 @@
1
- import type { CheckConsentOutput, CheckConsentQuery, GetSubjectOutput, GetSubjectQuery, InitOutput, ListSubjectsOutput, ListSubjectsQuery, PatchSubjectFullInput, PatchSubjectOutput, PostSubjectInput, PostSubjectOutput, StatusOutput } from '@c15t/schema/types';
2
- import type { C15TClientOptions, FetchOptions, ResponseContext } from './types.js';
3
- /**
4
- * C15T Client for interacting with the consent management API
5
- *
6
- * @example
7
- * ```typescript
8
- * const client = new C15TClient({
9
- * baseUrl: 'https://api.example.com',
10
- * token: 'your-auth-token',
11
- * });
12
- *
13
- * // Check API status
14
- * const statusResponse = await client.status();
15
- *
16
- * // Initialize consent manager
17
- * const initResponse = await client.init();
18
- *
19
- * // Create a subject with consent
20
- * const subject = await client.createSubject({
21
- * type: 'new',
22
- * subjectId: 'sub_123',
23
- * consents: { analytics: true },
24
- * });
25
- * ```
26
- */
27
- export declare class C15TClient {
1
+ import type { ConsentPolicyType, ExperimentSummaryOutput, GetSubjectOutput, InitOutput, LegalDocumentCurrentOutput, LegalDocumentPolicyType, ListSubjectsOutput, PatchSubjectOutput, PostSubjectOutput, StatusOutput } from '@c15t/schema/types';
2
+ import type { C15tCheckConsentInput, C15tCheckConsentOutput, C15tCreateSubjectInput, C15tExperimentSummaryRequest, C15tGetSubjectRequest, C15tIdentifySubjectInput, C15tInitRequest, C15tManifestRequest, C15tManifestResult, C15tPublishLegalDocumentInput } from './contract.js';
3
+ import type { C15tCallOptions, C15tClientOptions } from './options.js';
4
+ import type { C15tResult } from './result.js';
5
+ /** `subjects` methods available without an API key. */
6
+ export interface C15tPublicSubjects {
28
7
  /**
29
- * Internal fetcher context
30
- */
31
- private context;
32
- /**
33
- * Creates a new C15T client instance
34
- *
35
- * @param options - Client configuration options
36
- * @throws {TypeError} If baseUrl is invalid or not provided (and no env var)
37
- */
38
- constructor(options?: C15TClientOptions);
39
- /**
40
- * Get API status
8
+ * Reads a subject and its consents.
41
9
  *
42
- * @param options - Optional fetch options
43
- * @returns Status response with version and client info
10
+ * @param id - Subject id, such as `sub_2jv6z8n4q9`.
11
+ * @param request - Optional filter by policy type.
44
12
  */
45
- status(options?: FetchOptions<StatusOutput>): Promise<ResponseContext<StatusOutput>>;
13
+ get: (id: string, request?: C15tGetSubjectRequest, options?: C15tCallOptions) => Promise<C15tResult<GetSubjectOutput, 'DATABASE_ERROR' | 'NOT_FOUND'>>;
46
14
  /**
47
- * Initialize consent manager
15
+ * Records a consent, creating the subject if it does not exist.
16
+ * Retried submissions resolve to the same consent.
48
17
  *
49
- * @param options - Optional fetch options
50
- * @returns Init response with jurisdiction, location, translations, branding
18
+ * @param input - The consent. `type` selects which fields apply.
51
19
  */
52
- init(options?: FetchOptions<InitOutput>): Promise<ResponseContext<InitOutput>>;
20
+ create: (input: C15tCreateSubjectInput, options?: C15tCallOptions) => Promise<C15tResult<PostSubjectOutput, 'CHOICE_OUT_OF_SCOPE' | 'CHOICE_PREFERENCE_MISMATCH' | 'CONFLICT' | 'DATABASE_ERROR' | 'INPUT_VALIDATION_FAILED' | 'POLICY_SNAPSHOT_EXPIRED' | 'POLICY_SNAPSHOT_INVALID' | 'POLICY_SNAPSHOT_REQUIRED' | 'PURPOSE_NOT_ALLOWED' | 'STALE_POLICY' | 'SUBJECT_CONFLICT'>>;
53
21
  /**
54
- * Create a new subject with consent preferences
22
+ * Links a subject to your own user id, so `consents.check` and
23
+ * `subjects.list` can find it. Call it after the visitor signs in.
55
24
  *
56
- * @param input - Subject creation input
57
- * @param options - Optional fetch options
58
- * @returns Created subject response
25
+ * @param id - Subject id from the visitor's browser.
26
+ * @param input - Your user id and, optionally, who issued it.
59
27
  */
60
- createSubject(input: PostSubjectInput, options?: FetchOptions<PostSubjectOutput, PostSubjectInput>): Promise<ResponseContext<PostSubjectOutput>>;
61
- /**
62
- * Get a subject by ID
63
- *
64
- * @param id - Subject ID
65
- * @param query - Optional query parameters
66
- * @param options - Optional fetch options
67
- * @returns Subject data response
68
- */
69
- getSubject(id: string, query?: GetSubjectQuery, options?: FetchOptions<GetSubjectOutput, never, GetSubjectQuery>): Promise<ResponseContext<GetSubjectOutput>>;
28
+ identify: (id: string, input: C15tIdentifySubjectInput, options?: C15tCallOptions) => Promise<C15tResult<PatchSubjectOutput, 'DATABASE_ERROR' | 'EXTERNAL_ID_REQUIRED' | 'NOT_FOUND'>>;
29
+ }
30
+ /** `subjects` methods on a client with an API key. */
31
+ export interface C15tSubjects extends C15tPublicSubjects {
70
32
  /**
71
- * Update a subject (link external ID or update preferences)
72
- *
73
- * @param id - Subject ID
74
- * @param input - Patch input with externalId or other fields
75
- * @param options - Optional fetch options
76
- * @returns Updated subject response
33
+ * Lists every subject linked to one of your user ids, with their consents.
34
+ * Needs an API key.
77
35
  */
78
- patchSubject(id: string, input: Omit<PatchSubjectFullInput, 'id'>, options?: FetchOptions<PatchSubjectOutput, Omit<PatchSubjectFullInput, 'id'>>): Promise<ResponseContext<PatchSubjectOutput>>;
36
+ list: (query: {
37
+ readonly externalId: string;
38
+ }, options?: C15tCallOptions) => Promise<C15tResult<ListSubjectsOutput, 'DATABASE_ERROR' | 'EXTERNAL_ID_REQUIRED' | 'UNAUTHORIZED'>>;
39
+ }
40
+ /** `consents` methods. */
41
+ export interface C15tConsents {
79
42
  /**
80
- * List subjects with optional filtering
43
+ * Reports whether a user has consented to each policy type. Every
44
+ * requested type appears in `results`, consented or not.
81
45
  *
82
- * @param query - Query parameters for filtering
83
- * @param options - Optional fetch options
84
- * @returns List of subjects
46
+ * @example
47
+ * ```ts
48
+ * const result = await c15t.consents.check({
49
+ * externalId: user.id,
50
+ * types: ['marketing_communications'],
51
+ * });
52
+ * if (result.ok && result.data.results.marketing_communications.hasConsent) {
53
+ * await sendNewsletter(user);
54
+ * }
55
+ * ```
85
56
  */
86
- listSubjects(query?: ListSubjectsQuery, options?: FetchOptions<ListSubjectsOutput, never, ListSubjectsQuery>): Promise<ResponseContext<ListSubjectsOutput>>;
57
+ check: <const Types extends readonly [ConsentPolicyType, ...ConsentPolicyType[]]>(input: C15tCheckConsentInput<Types>, options?: C15tCallOptions) => Promise<C15tResult<C15tCheckConsentOutput<Types[number]>, 'DATABASE_ERROR' | 'EXTERNAL_ID_REQUIRED' | 'TYPE_REQUIRED'>>;
58
+ }
59
+ /** `experiments` methods. Need an API key. */
60
+ export interface C15tExperiments {
87
61
  /**
88
- * Check consent status for an external ID
62
+ * Counts choices per arm of a banner experiment, by action and surface,
63
+ * with the median time to decision.
89
64
  *
90
- * @param query - Query parameters (externalId required)
91
- * @param options - Optional fetch options
92
- * @returns Consent check response
65
+ * @param id - Experiment id, as configured on the client.
93
66
  */
94
- checkConsent(query: CheckConsentQuery, options?: FetchOptions<CheckConsentOutput, never, CheckConsentQuery>): Promise<ResponseContext<CheckConsentOutput>>;
67
+ summary: (id: string, request?: C15tExperimentSummaryRequest, options?: C15tCallOptions) => Promise<C15tResult<ExperimentSummaryOutput, 'DATABASE_ERROR' | 'INPUT_VALIDATION_FAILED' | 'UNAUTHORIZED'>>;
68
+ }
69
+ /** `legalDocuments` methods. Need an API key. */
70
+ export interface C15tLegalDocuments {
95
71
  /**
96
- * Make a custom API request to any endpoint
72
+ * Publishes a legal document release as the current version, so new
73
+ * consents record it. Call it from the job that ships the document.
97
74
  *
98
- * @param path - API endpoint path
99
- * @param options - Fetch options
100
- * @returns Response context
101
- */
102
- $fetch<ResponseType, BodyType = unknown, QueryType = unknown>(path: string, options?: FetchOptions<ResponseType, BodyType, QueryType>): Promise<ResponseContext<ResponseType>>;
103
- /**
104
- * Namespaced access to consent endpoints
75
+ * @param type - Document type, such as `privacy_policy` or
76
+ * `terms_and_conditions_b2b`.
105
77
  */
106
- consent: {
107
- /**
108
- * Check consent status for an external ID
109
- */
110
- check: (query: CheckConsentQuery, options?: FetchOptions<CheckConsentOutput, never, CheckConsentQuery>) => Promise<ResponseContext<{
111
- results: {
112
- [x: string]: {
113
- hasConsent: boolean;
114
- isLatestPolicy: boolean;
115
- };
116
- };
117
- }>>;
118
- };
78
+ publish: (type: LegalDocumentPolicyType, input: C15tPublishLegalDocumentInput, options?: C15tCallOptions) => Promise<C15tResult<LegalDocumentCurrentOutput, 'CONFLICT' | 'DATABASE_ERROR' | 'INPUT_VALIDATION_FAILED' | 'UNAUTHORIZED'>>;
79
+ }
80
+ /**
81
+ * A client created without an API key: the routes the backend serves
82
+ * without one.
83
+ */
84
+ export interface C15tPublicClient {
85
+ /** Backend version and the request context it saw. */
86
+ status: (options?: C15tCallOptions) => Promise<C15tResult<StatusOutput, 'SERVICE_UNAVAILABLE'>>;
119
87
  /**
120
- * Namespaced access to subject endpoints
88
+ * Resolves the consent banner for a visitor: jurisdiction, translations,
89
+ * policies. Pass the visitor's context when calling from a server.
121
90
  */
122
- subjects: {
123
- /**
124
- * Create a new subject
125
- */
126
- create: (input: PostSubjectInput, options?: FetchOptions<PostSubjectOutput, PostSubjectInput>) => Promise<ResponseContext<{
127
- appliedPreferences?: {
128
- [x: string]: boolean;
129
- } | undefined;
130
- consentId: string;
131
- domain: string;
132
- domainId: string;
133
- givenAt: Date;
134
- metadata?: {
135
- [x: string]: unknown;
136
- } | undefined;
137
- subjectId: string;
138
- type: string;
139
- uiSource?: string | undefined;
140
- }>>;
141
- /**
142
- * Get a subject by ID
143
- */
144
- get: (id: string, query?: GetSubjectQuery, options?: FetchOptions<GetSubjectOutput, never, GetSubjectQuery>) => Promise<ResponseContext<{
145
- consents: {
146
- choice?: {
147
- categories: {
148
- experience?: {
149
- basis: {
150
- fingerprint: string;
151
- kind: "choice-v1";
152
- } | {
153
- kind: "legacy-v2";
154
- materialFingerprint?: string | undefined;
155
- };
156
- confirmedAt: number;
157
- value: boolean;
158
- } | undefined;
159
- functionality?: {
160
- basis: {
161
- fingerprint: string;
162
- kind: "choice-v1";
163
- } | {
164
- kind: "legacy-v2";
165
- materialFingerprint?: string | undefined;
166
- };
167
- confirmedAt: number;
168
- value: boolean;
169
- } | undefined;
170
- marketing?: {
171
- basis: {
172
- fingerprint: string;
173
- kind: "choice-v1";
174
- } | {
175
- kind: "legacy-v2";
176
- materialFingerprint?: string | undefined;
177
- };
178
- confirmedAt: number;
179
- value: boolean;
180
- } | undefined;
181
- measurement?: {
182
- basis: {
183
- fingerprint: string;
184
- kind: "choice-v1";
185
- } | {
186
- kind: "legacy-v2";
187
- materialFingerprint?: string | undefined;
188
- };
189
- confirmedAt: number;
190
- value: boolean;
191
- } | undefined;
192
- };
193
- version: 3;
194
- } | null | undefined;
195
- givenAt: Date;
196
- id: string;
197
- isLatestPolicy: boolean;
198
- policyEffectiveDate?: Date | undefined;
199
- policyHash?: string | undefined;
200
- policyId?: string | undefined;
201
- policyVersion?: string | undefined;
202
- preferences?: {
203
- [x: string]: boolean;
204
- } | undefined;
205
- type: string;
206
- vendorChoice?: {
207
- confirmedAt: number;
208
- grants: {
209
- [x: string]: boolean;
210
- };
211
- version: 1;
212
- } | null | undefined;
213
- }[];
214
- isValid: boolean;
215
- privacyDirectives?: {
216
- authority: "api" | "subject";
217
- categories: ("experience" | "functionality" | "marketing" | "measurement")[];
218
- id: string;
219
- recordedAt: number;
220
- signalHeader: boolean | null;
221
- source: "gpc";
222
- }[] | undefined;
223
- subject: {
224
- createdAt?: Date | undefined;
225
- externalId?: string | undefined;
226
- id: string;
227
- identityProvider?: string | undefined;
228
- };
229
- subjectChoice?: {
230
- categories: {
231
- experience?: {
232
- basis: {
233
- fingerprint: string;
234
- kind: "choice-v1";
235
- } | {
236
- kind: "legacy-v2";
237
- materialFingerprint?: string | undefined;
238
- };
239
- confirmedAt: number;
240
- value: boolean;
241
- } | undefined;
242
- functionality?: {
243
- basis: {
244
- fingerprint: string;
245
- kind: "choice-v1";
246
- } | {
247
- kind: "legacy-v2";
248
- materialFingerprint?: string | undefined;
249
- };
250
- confirmedAt: number;
251
- value: boolean;
252
- } | undefined;
253
- marketing?: {
254
- basis: {
255
- fingerprint: string;
256
- kind: "choice-v1";
257
- } | {
258
- kind: "legacy-v2";
259
- materialFingerprint?: string | undefined;
260
- };
261
- confirmedAt: number;
262
- value: boolean;
263
- } | undefined;
264
- measurement?: {
265
- basis: {
266
- fingerprint: string;
267
- kind: "choice-v1";
268
- } | {
269
- kind: "legacy-v2";
270
- materialFingerprint?: string | undefined;
271
- };
272
- confirmedAt: number;
273
- value: boolean;
274
- } | undefined;
275
- };
276
- version: 3;
277
- } | null | undefined;
278
- subjectVendorChoice?: {
279
- confirmedAt: number;
280
- grants: {
281
- [x: string]: boolean;
282
- };
283
- version: 1;
284
- } | null | undefined;
285
- }>>;
286
- /**
287
- * List subjects
288
- */
289
- list: (query?: ListSubjectsQuery, options?: FetchOptions<ListSubjectsOutput, never, ListSubjectsQuery>) => Promise<ResponseContext<{
290
- subjects: {
291
- consents: {
292
- choice?: {
293
- categories: {
294
- experience?: {
295
- basis: {
296
- fingerprint: string;
297
- kind: "choice-v1";
298
- } | {
299
- kind: "legacy-v2";
300
- materialFingerprint?: string | undefined;
301
- };
302
- confirmedAt: number;
303
- value: boolean;
304
- } | undefined;
305
- functionality?: {
306
- basis: {
307
- fingerprint: string;
308
- kind: "choice-v1";
309
- } | {
310
- kind: "legacy-v2";
311
- materialFingerprint?: string | undefined;
312
- };
313
- confirmedAt: number;
314
- value: boolean;
315
- } | undefined;
316
- marketing?: {
317
- basis: {
318
- fingerprint: string;
319
- kind: "choice-v1";
320
- } | {
321
- kind: "legacy-v2";
322
- materialFingerprint?: string | undefined;
323
- };
324
- confirmedAt: number;
325
- value: boolean;
326
- } | undefined;
327
- measurement?: {
328
- basis: {
329
- fingerprint: string;
330
- kind: "choice-v1";
331
- } | {
332
- kind: "legacy-v2";
333
- materialFingerprint?: string | undefined;
334
- };
335
- confirmedAt: number;
336
- value: boolean;
337
- } | undefined;
338
- };
339
- version: 3;
340
- } | null | undefined;
341
- givenAt: Date;
342
- id: string;
343
- isLatestPolicy: boolean;
344
- policyEffectiveDate?: Date | undefined;
345
- policyHash?: string | undefined;
346
- policyId?: string | undefined;
347
- policyVersion?: string | undefined;
348
- preferences?: {
349
- [x: string]: boolean;
350
- } | undefined;
351
- type: string;
352
- vendorChoice?: {
353
- confirmedAt: number;
354
- grants: {
355
- [x: string]: boolean;
356
- };
357
- version: 1;
358
- } | null | undefined;
359
- }[];
360
- createdAt: Date;
361
- externalId: string;
362
- id: string;
363
- }[];
364
- }>>;
365
- /**
366
- * Update a subject
367
- */
368
- patch: (id: string, input: Omit<PatchSubjectFullInput, 'id'>, options?: FetchOptions<PatchSubjectOutput, Omit<PatchSubjectFullInput, 'id'>>) => Promise<ResponseContext<{
369
- subject: {
370
- externalId: string;
371
- id: string;
372
- };
373
- success: boolean;
374
- }>>;
375
- };
91
+ init: (request?: C15tInitRequest, options?: C15tCallOptions) => Promise<C15tResult<InitOutput>>;
376
92
  /**
377
- * Namespaced access to meta endpoints
93
+ * Fetches the consent manifest, the cacheable configuration `init` is
94
+ * resolved from. Pass the `etag` you hold as `ifNoneMatch` to skip
95
+ * downloading an unchanged manifest.
378
96
  */
379
- meta: {
380
- /**
381
- * Initialize consent manager
382
- */
383
- init: (options?: FetchOptions<InitOutput>) => Promise<ResponseContext<{
384
- branding: "c15t" | "consent" | "inth" | "none";
385
- cmpId?: number | undefined;
386
- customVendors?: {
387
- cookieMaxAgeSeconds?: number | undefined;
388
- dataCategories?: number[] | undefined;
389
- dataRetentionDays?: number | undefined;
390
- description?: string | undefined;
391
- features?: number[] | undefined;
392
- id: string | number;
393
- legIntPurposes?: number[] | undefined;
394
- name: string;
395
- privacyPolicyUrl: string;
396
- purposes: number[];
397
- specialFeatures?: number[] | undefined;
398
- usesCookies?: boolean | undefined;
399
- usesNonCookieAccess?: boolean | undefined;
400
- }[] | undefined;
401
- gvl?: {
402
- dataCategories?: {
403
- [x: string]: {
404
- description: string;
405
- id: number;
406
- name: string;
407
- };
408
- } | undefined;
409
- features: {
410
- [x: string]: {
411
- description: string;
412
- descriptionLegal?: string | undefined;
413
- id: number;
414
- illustrations: string[];
415
- name: string;
416
- };
417
- };
418
- gvlSpecificationVersion: number;
419
- lastUpdated: string;
420
- purposes: {
421
- [x: string]: {
422
- description: string;
423
- descriptionLegal?: string | undefined;
424
- id: number;
425
- illustrations: string[];
426
- name: string;
427
- };
428
- };
429
- specialFeatures: {
430
- [x: string]: {
431
- description: string;
432
- descriptionLegal?: string | undefined;
433
- id: number;
434
- illustrations: string[];
435
- name: string;
436
- };
437
- };
438
- specialPurposes: {
439
- [x: string]: {
440
- description: string;
441
- descriptionLegal?: string | undefined;
442
- id: number;
443
- illustrations: string[];
444
- name: string;
445
- };
446
- };
447
- stacks: {
448
- [x: string]: {
449
- description: string;
450
- id: number;
451
- name: string;
452
- purposes: number[];
453
- specialFeatures: number[];
454
- };
455
- };
456
- tcfPolicyVersion: number;
457
- vendorListVersion: number;
458
- vendors: {
459
- [x: string]: {
460
- cookieMaxAgeSeconds: number | null;
461
- cookieRefresh: boolean;
462
- dataCategories?: number[] | undefined;
463
- dataRetention?: {
464
- purposes?: {
465
- [x: string]: number;
466
- } | undefined;
467
- specialPurposes?: {
468
- [x: string]: number;
469
- } | undefined;
470
- stdRetention?: number | undefined;
471
- } | undefined;
472
- deletedDate?: string | undefined;
473
- deviceStorageDisclosureUrl?: string | undefined;
474
- features: number[];
475
- flexiblePurposes: number[];
476
- id: number;
477
- legIntPurposes: number[];
478
- name: string;
479
- overflow?: {
480
- httpGetLimit: number;
481
- } | undefined;
482
- purposes: number[];
483
- specialFeatures: number[];
484
- specialPurposes: number[];
485
- urls: {
486
- langId: string;
487
- legIntClaim?: string | undefined;
488
- privacy?: string | undefined;
489
- }[];
490
- usesCookies: boolean;
491
- usesNonCookieAccess: boolean;
492
- };
493
- };
494
- } | null | undefined;
495
- gvlReference?: {
496
- context?: {
497
- country?: string | undefined;
498
- gpc?: boolean | undefined;
499
- region?: string | undefined;
500
- } | undefined;
501
- format?: "init" | undefined;
502
- language: string;
503
- summary?: {
504
- items: string[];
505
- vendorCount: number;
506
- } | undefined;
507
- url: string;
508
- vendorListVersion: number;
509
- } | undefined;
510
- jurisdiction: "APPI" | "AU" | "BR" | "CCPA" | "CH" | "GDPR" | "NONE" | "PIPA" | "PIPEDA" | "QC_LAW25" | "UK_GDPR";
511
- location: {
512
- countryCode: string | null;
513
- regionCode: string | null;
514
- };
515
- policyResolution: {
516
- policy: null;
517
- status: "unconfigured";
518
- version: 1;
519
- } | {
520
- policy: null;
521
- status: "no-match";
522
- version: 1;
523
- } | {
524
- policy: null;
525
- reason: "insufficient-inputs" | "invalid-configuration" | "invalid-payload" | "transport" | "unsupported-contract";
526
- status: "failed";
527
- version: 1;
528
- } | {
529
- fingerprints: {
530
- choice: string;
531
- legacyMaterial?: string | undefined;
532
- notice: string;
533
- policy: string;
534
- };
535
- matchedBy: "country" | "default" | "fallback" | "region";
536
- policy: {
537
- actions: {
538
- allowed: ("accept" | "customize" | "dismiss" | "reject")[];
539
- equivalent: ("accept" | "customize" | "dismiss" | "reject")[][];
540
- required: ("accept" | "customize" | "dismiss" | "reject")[];
541
- };
542
- copyRevision: string | null;
543
- i18n?: {
544
- language?: string | undefined;
545
- messageProfile?: string | undefined;
546
- } | undefined;
547
- id: string;
548
- model: "iab" | "none" | "opt-in" | "opt-out";
549
- preselectedCategories: ("experience" | "functionality" | "marketing" | "measurement")[];
550
- privacySignals: {
551
- gpc: {
552
- denyCategories: ("experience" | "functionality" | "marketing" | "measurement")[];
553
- };
554
- };
555
- prompt: "choice" | "none" | "notice";
556
- proof: {
557
- storeIp: boolean;
558
- storeLanguage: boolean;
559
- storeUserAgent: boolean;
560
- };
561
- rights: ("disclosure" | "opt-out" | "preferences")[];
562
- scope: ("experience" | "functionality" | "marketing" | "measurement")[];
563
- scopeMode: "permissive" | "strict";
564
- validity: {
565
- choiceMs: number;
566
- noticeMs: number;
567
- };
568
- };
569
- policyId: string;
570
- status: "matched";
571
- version: 1;
572
- };
573
- policySnapshotToken?: string | undefined;
574
- resolvedPrivacySignals?: {
575
- gpc?: boolean | undefined;
576
- } | undefined;
577
- translations: {
578
- language: string;
579
- translations: {
580
- common: {
581
- acceptAll: string;
582
- acknowledge?: string | undefined;
583
- customize: string;
584
- dismiss?: string | undefined;
585
- rejectAll: string;
586
- save: string;
587
- };
588
- consentManagerDialog: {
589
- description: string;
590
- title: string;
591
- vendors?: {
592
- disabledByCategory?: string | undefined;
593
- privacyPolicy?: string | undefined;
594
- switchLabel?: string | undefined;
595
- title?: string | undefined;
596
- } | undefined;
597
- };
598
- consentTypes: {
599
- experience: {
600
- description: string;
601
- title: string;
602
- };
603
- functionality: {
604
- description: string;
605
- title: string;
606
- };
607
- marketing: {
608
- description: string;
609
- title: string;
610
- };
611
- measurement: {
612
- description: string;
613
- title: string;
614
- };
615
- necessary: {
616
- description: string;
617
- title: string;
618
- };
619
- };
620
- cookieBanner: {
621
- description: string;
622
- title: string;
623
- noticeDescription?: string | undefined;
624
- noticeTitle?: string | undefined;
625
- };
626
- frame: {
627
- actionButton: string;
628
- title: string;
629
- };
630
- legalLinks: {
631
- cookiePolicy: string;
632
- privacyPolicy: string;
633
- termsOfService: string;
634
- };
635
- rights?: {
636
- optOut?: string | undefined;
637
- preferences?: string | undefined;
638
- } | undefined;
639
- } | {
640
- common: {
641
- acceptAll?: string | undefined;
642
- acknowledge?: string | undefined;
643
- customize?: string | undefined;
644
- dismiss?: string | undefined;
645
- rejectAll?: string | undefined;
646
- save?: string | undefined;
647
- };
648
- consentManagerDialog: {
649
- description?: string | undefined;
650
- title?: string | undefined;
651
- vendors?: {
652
- disabledByCategory?: string | undefined;
653
- privacyPolicy?: string | undefined;
654
- switchLabel?: string | undefined;
655
- title?: string | undefined;
656
- } | undefined;
657
- };
658
- consentTypes: {
659
- experience?: {
660
- description?: string | undefined;
661
- title?: string | undefined;
662
- } | undefined;
663
- functionality?: {
664
- description?: string | undefined;
665
- title?: string | undefined;
666
- } | undefined;
667
- marketing?: {
668
- description?: string | undefined;
669
- title?: string | undefined;
670
- } | undefined;
671
- measurement?: {
672
- description?: string | undefined;
673
- title?: string | undefined;
674
- } | undefined;
675
- necessary?: {
676
- description?: string | undefined;
677
- title?: string | undefined;
678
- } | undefined;
679
- };
680
- cookieBanner: {
681
- description?: string | undefined;
682
- title?: string | undefined;
683
- noticeDescription?: string | undefined;
684
- noticeTitle?: string | undefined;
685
- };
686
- frame?: {
687
- actionButton?: string | undefined;
688
- title?: string | undefined;
689
- } | undefined;
690
- legalLinks?: {
691
- cookiePolicy?: string | undefined;
692
- privacyPolicy?: string | undefined;
693
- termsOfService?: string | undefined;
694
- } | undefined;
695
- rights?: {
696
- optOut?: string | undefined;
697
- preferences?: string | undefined;
698
- } | undefined;
699
- };
700
- };
701
- vendorListVersion?: string | undefined;
702
- vendors?: {
703
- category: import("@c15t/schema/shared").VendorCategoryCondition;
704
- description?: string | undefined;
705
- disabled?: boolean | undefined;
706
- homepageUrl?: string | undefined;
707
- id: string;
708
- legalName?: string | undefined;
709
- name: string;
710
- privacyPolicyUrl: string;
711
- }[] | undefined;
712
- }>>;
713
- /**
714
- * Get API status
715
- */
716
- status: (options?: FetchOptions<StatusOutput>) => Promise<ResponseContext<{
717
- client: {
718
- acceptLanguage: string | null;
719
- ip: string | null;
720
- region: {
721
- countryCode: string | null;
722
- regionCode: string | null;
723
- };
724
- userAgent: string | null;
725
- };
726
- timestamp: Date;
727
- version: string;
728
- }>>;
729
- };
97
+ manifest: (request?: C15tManifestRequest, options?: C15tCallOptions) => Promise<C15tResult<C15tManifestResult>>;
98
+ readonly subjects: C15tPublicSubjects;
99
+ readonly consents: C15tConsents;
730
100
  }
101
+ /** A client created with an API key. */
102
+ export interface C15tClient extends C15tPublicClient {
103
+ readonly subjects: C15tSubjects;
104
+ readonly experiments: C15tExperiments;
105
+ readonly legalDocuments: C15tLegalDocuments;
106
+ }
107
+ /**
108
+ * Creates a client for a hosted or self-hosted c15t backend.
109
+ *
110
+ * Methods resolve to `{ ok: true, data }` or `{ ok: false, error }` and never
111
+ * reject. Methods that need an API key exist only on a client created with
112
+ * one.
113
+ *
114
+ * @param options - Backend URL, optional API key, transport settings.
115
+ * @returns A client. Its type depends on whether `apiKey` was passed.
116
+ * @throws {C15tConfigurationError} When an option is invalid. Every problem
117
+ * is reported at once.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * import { createC15tClient } from '@c15t/node-sdk';
122
+ *
123
+ * const c15t = createC15tClient({
124
+ * baseUrl: 'https://consent.example.com/api/c15t',
125
+ * apiKey: process.env.C15T_API_KEY!,
126
+ * });
127
+ *
128
+ * const result = await c15t.subjects.list({ externalId: 'user_123' });
129
+ * ```
130
+ */
131
+ export declare function createC15tClient(options: C15tClientOptions & {
132
+ readonly apiKey: string;
133
+ }): C15tClient;
134
+ export declare function createC15tClient(options: C15tClientOptions & {
135
+ readonly apiKey?: undefined;
136
+ }): C15tPublicClient;
137
+ export declare function createC15tClient(options: C15tClientOptions): C15tClient | C15tPublicClient;