@c15t/node-sdk 2.2.0 → 3.0.0-alpha.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/README.md +2 -2
- package/dist/index.js +205 -179
- package/dist/testing.js +61 -45
- package/dist-types/client.d.ts +433 -232
- package/dist-types/endpoints/consent.d.ts +1 -1
- package/dist-types/endpoints/init.d.ts +1 -1
- package/dist-types/endpoints/status.d.ts +1 -1
- package/dist-types/endpoints/subjects.d.ts +4 -4
- package/dist-types/error.d.ts +1 -1
- package/dist-types/fetcher.d.ts +4 -4
- package/dist-types/headers.d.ts +1 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/testing.d.ts +5 -26
- package/dist-types/types.d.ts +4 -4
- package/dist-types/version.d.ts +1 -1
- package/package.json +24 -25
- package/readme.json +1 -1
- package/dist/index.cjs +0 -427
- package/dist/testing.cjs +0 -123
|
@@ -13,4 +13,4 @@ export declare const CONSENT_CHECK_PATH = "/consents/check";
|
|
|
13
13
|
* @param options - Optional fetch options
|
|
14
14
|
* @returns Consent check response
|
|
15
15
|
*/
|
|
16
|
-
export declare
|
|
16
|
+
export declare const checkConsent: (context: FetcherContext, query: CheckConsentQuery, options?: FetchOptions<CheckConsentOutput, never, CheckConsentQuery>) => Promise<ResponseContext<CheckConsentOutput>>;
|
|
@@ -12,4 +12,4 @@ export declare const INIT_PATH = "/init";
|
|
|
12
12
|
* @param options - Optional fetch options
|
|
13
13
|
* @returns Init response with jurisdiction, location, translations, branding
|
|
14
14
|
*/
|
|
15
|
-
export declare
|
|
15
|
+
export declare const init: (context: FetcherContext, options?: FetchOptions<InitOutput>) => Promise<ResponseContext<InitOutput>>;
|
|
@@ -12,4 +12,4 @@ export declare const STATUS_PATH = "/status";
|
|
|
12
12
|
* @param options - Optional fetch options
|
|
13
13
|
* @returns Status response
|
|
14
14
|
*/
|
|
15
|
-
export declare
|
|
15
|
+
export declare const status: (context: FetcherContext, options?: FetchOptions<StatusOutput>) => Promise<ResponseContext<StatusOutput>>;
|
|
@@ -13,7 +13,7 @@ export declare const SUBJECTS_PATH = "/subjects";
|
|
|
13
13
|
* @param options - Optional fetch options
|
|
14
14
|
* @returns Created subject response
|
|
15
15
|
*/
|
|
16
|
-
export declare
|
|
16
|
+
export declare const createSubject: (context: FetcherContext, input: PostSubjectInput, options?: FetchOptions<PostSubjectOutput, PostSubjectInput>) => Promise<ResponseContext<PostSubjectOutput>>;
|
|
17
17
|
/**
|
|
18
18
|
* Get a subject by ID
|
|
19
19
|
*
|
|
@@ -23,7 +23,7 @@ export declare function createSubject(context: FetcherContext, input: PostSubjec
|
|
|
23
23
|
* @param options - Optional fetch options
|
|
24
24
|
* @returns Subject data response
|
|
25
25
|
*/
|
|
26
|
-
export declare
|
|
26
|
+
export declare const getSubject: (context: FetcherContext, id: string, query?: GetSubjectQuery, options?: FetchOptions<GetSubjectOutput, never, GetSubjectQuery>) => Promise<ResponseContext<GetSubjectOutput>>;
|
|
27
27
|
/**
|
|
28
28
|
* Update a subject (link external ID or update preferences)
|
|
29
29
|
*
|
|
@@ -33,7 +33,7 @@ export declare function getSubject(context: FetcherContext, id: string, query?:
|
|
|
33
33
|
* @param options - Optional fetch options
|
|
34
34
|
* @returns Updated subject response
|
|
35
35
|
*/
|
|
36
|
-
export declare
|
|
36
|
+
export declare const patchSubject: (context: FetcherContext, id: string, input: Omit<PatchSubjectFullInput, 'id'>, options?: FetchOptions<PatchSubjectOutput, Omit<PatchSubjectFullInput, 'id'>>) => Promise<ResponseContext<PatchSubjectOutput>>;
|
|
37
37
|
/**
|
|
38
38
|
* List subjects with optional filtering
|
|
39
39
|
*
|
|
@@ -42,4 +42,4 @@ export declare function patchSubject(context: FetcherContext, id: string, input:
|
|
|
42
42
|
* @param options - Optional fetch options
|
|
43
43
|
* @returns List of subjects
|
|
44
44
|
*/
|
|
45
|
-
export declare
|
|
45
|
+
export declare const listSubjects: (context: FetcherContext, query?: ListSubjectsQuery, options?: FetchOptions<ListSubjectsOutput, never, ListSubjectsQuery>) => Promise<ResponseContext<ListSubjectsOutput>>;
|
package/dist-types/error.d.ts
CHANGED
package/dist-types/fetcher.d.ts
CHANGED
|
@@ -20,18 +20,18 @@ export interface FetcherContext {
|
|
|
20
20
|
/**
|
|
21
21
|
* Creates a response context object with Result-like helper methods
|
|
22
22
|
*/
|
|
23
|
-
export declare
|
|
23
|
+
export declare const createResponseContext: <T>(isSuccess: boolean, data?: T | null, error?: {
|
|
24
24
|
message: string;
|
|
25
25
|
status: number;
|
|
26
26
|
code?: string;
|
|
27
27
|
cause?: unknown;
|
|
28
28
|
details?: Record<string, unknown> | null;
|
|
29
|
-
} | null, response?: Response | null)
|
|
29
|
+
} | null, response?: Response | null) => ResponseContext<T>;
|
|
30
30
|
/**
|
|
31
31
|
* Resolves a URL path against the base URL
|
|
32
32
|
*/
|
|
33
|
-
export declare
|
|
33
|
+
export declare const resolveUrl: (baseUrl: string, path: string) => string;
|
|
34
34
|
/**
|
|
35
35
|
* Makes an HTTP request with retry logic
|
|
36
36
|
*/
|
|
37
|
-
export declare
|
|
37
|
+
export declare const fetcher: <ResponseType, BodyType = unknown, QueryType = unknown>(context: FetcherContext, path: string, options?: FetchOptions<ResponseType, BodyType, QueryType>) => Promise<ResponseContext<ResponseType>>;
|
package/dist-types/headers.d.ts
CHANGED
package/dist-types/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ import type { C15TClientOptions } from './types';
|
|
|
34
34
|
* });
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export declare
|
|
37
|
+
export declare const c15tClient: (options?: C15TClientOptions) => C15TClient;
|
|
38
38
|
export type { CheckConsentOutput, CheckConsentQuery, ConsentCheckResult, ConsentItem, GetSubjectInput, GetSubjectOutput, GetSubjectParams, GetSubjectQuery, InitOutput, ListSubjectsOutput, ListSubjectsQuery, PatchSubjectFullInput, PatchSubjectOutput, PostSubjectInput, PostSubjectOutput, StatusOutput, SubjectItem, } from '@c15t/schema/types';
|
|
39
39
|
export { C15TClient } from './client';
|
|
40
40
|
export { C15TError, isC15TError } from './error';
|
package/dist-types/testing.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ import type { ResponseContext } from './types';
|
|
|
31
31
|
* expect(response.data?.id).toBe('sub_123');
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare
|
|
34
|
+
export declare const createMockResponse: <T>(data: T, options?: {
|
|
35
35
|
ok?: boolean;
|
|
36
36
|
error?: {
|
|
37
37
|
message: string;
|
|
@@ -40,7 +40,7 @@ export declare function createMockResponse<T>(data: T, options?: {
|
|
|
40
40
|
details?: Record<string, unknown> | null;
|
|
41
41
|
};
|
|
42
42
|
response?: Response;
|
|
43
|
-
})
|
|
43
|
+
}) => ResponseContext<T>;
|
|
44
44
|
/**
|
|
45
45
|
* Creates a mock error ResponseContext for testing
|
|
46
46
|
*
|
|
@@ -58,12 +58,12 @@ export declare function createMockResponse<T>(data: T, options?: {
|
|
|
58
58
|
* expect(response.error?.status).toBe(404);
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
export declare
|
|
61
|
+
export declare const createMockErrorResponse: <T = unknown>(error: {
|
|
62
62
|
message: string;
|
|
63
63
|
status: number;
|
|
64
64
|
code?: string;
|
|
65
65
|
details?: Record<string, unknown> | null;
|
|
66
|
-
})
|
|
66
|
+
}) => ResponseContext<T>;
|
|
67
67
|
/**
|
|
68
68
|
* Type for mock method implementations
|
|
69
69
|
*/
|
|
@@ -103,28 +103,7 @@ export interface MockClientOverrides {
|
|
|
103
103
|
* const result = await mockClient.getSubject('sub_123');
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
|
-
export declare
|
|
107
|
-
status: () => Promise<ResponseContext<unknown>>;
|
|
108
|
-
init: () => Promise<ResponseContext<unknown>>;
|
|
109
|
-
checkConsent: (query: unknown) => Promise<ResponseContext<unknown>>;
|
|
110
|
-
createSubject: (input: unknown) => Promise<ResponseContext<unknown>>;
|
|
111
|
-
getSubject: (id: string) => Promise<ResponseContext<unknown>>;
|
|
112
|
-
patchSubject: (id: string, input: unknown) => Promise<ResponseContext<unknown>>;
|
|
113
|
-
listSubjects: (query?: unknown) => Promise<ResponseContext<unknown>>;
|
|
114
|
-
consent: {
|
|
115
|
-
check: (query: unknown) => Promise<ResponseContext<unknown>>;
|
|
116
|
-
};
|
|
117
|
-
subjects: {
|
|
118
|
-
create: (input: unknown) => Promise<ResponseContext<unknown>>;
|
|
119
|
-
get: (id: string) => Promise<ResponseContext<unknown>>;
|
|
120
|
-
patch: (id: string, input: unknown) => Promise<ResponseContext<unknown>>;
|
|
121
|
-
list: (query?: unknown) => Promise<ResponseContext<unknown>>;
|
|
122
|
-
};
|
|
123
|
-
meta: {
|
|
124
|
-
status: () => Promise<ResponseContext<unknown>>;
|
|
125
|
-
init: () => Promise<ResponseContext<unknown>>;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
106
|
+
export declare const createMockClient: (overrides?: MockClientOverrides) => any;
|
|
128
107
|
/**
|
|
129
108
|
* Type representing the mock client returned by createMockClient
|
|
130
109
|
*/
|
package/dist-types/types.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export interface ResponseContext<T = unknown> {
|
|
|
145
145
|
* const subject = (await client.getSubject('sub_123')).unwrap();
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
|
-
unwrap()
|
|
148
|
+
unwrap: () => T;
|
|
149
149
|
/**
|
|
150
150
|
* Unwraps the response data, returning a default value if the request failed.
|
|
151
151
|
*
|
|
@@ -157,7 +157,7 @@ export interface ResponseContext<T = unknown> {
|
|
|
157
157
|
* const subject = (await client.getSubject('sub_123')).unwrapOr(defaultSubject);
|
|
158
158
|
* ```
|
|
159
159
|
*/
|
|
160
|
-
unwrapOr(defaultValue: T)
|
|
160
|
+
unwrapOr: (defaultValue: T) => T;
|
|
161
161
|
/**
|
|
162
162
|
* Unwraps the response data, throwing a custom error message if the request failed.
|
|
163
163
|
*
|
|
@@ -170,7 +170,7 @@ export interface ResponseContext<T = unknown> {
|
|
|
170
170
|
* const subject = (await client.getSubject('sub_123')).expect('Subject not found');
|
|
171
171
|
* ```
|
|
172
172
|
*/
|
|
173
|
-
expect(message: string)
|
|
173
|
+
expect: (message: string) => T;
|
|
174
174
|
/**
|
|
175
175
|
* Maps the response data to a new value if successful.
|
|
176
176
|
*
|
|
@@ -182,7 +182,7 @@ export interface ResponseContext<T = unknown> {
|
|
|
182
182
|
* const name = (await client.getSubject('sub_123')).map(s => s.name);
|
|
183
183
|
* ```
|
|
184
184
|
*/
|
|
185
|
-
map<U>(fn: (data: T) => U)
|
|
185
|
+
map: <U>(fn: (data: T) => U) => ResponseContext<U>;
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
188
|
* Options for individual fetch requests
|
package/dist-types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "3.0.0-alpha.0";
|
package/package.json
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c15t/node-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"description": "Type-safe Node.js SDK for hosted and self-hosted c15t consent APIs, consent records, privacy preferences, and backend automation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"c15t",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"sdk",
|
|
7
|
+
"ccpa",
|
|
8
|
+
"cmp",
|
|
10
9
|
"consent",
|
|
11
10
|
"consent-api",
|
|
12
11
|
"consent-management",
|
|
13
|
-
"
|
|
12
|
+
"consent-records",
|
|
14
13
|
"gdpr",
|
|
15
|
-
"ccpa",
|
|
16
14
|
"lgpd",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
15
|
+
"node",
|
|
16
|
+
"nodejs",
|
|
17
|
+
"privacy",
|
|
18
|
+
"sdk",
|
|
20
19
|
"self-hosted-cmp",
|
|
21
|
-
"
|
|
20
|
+
"server-side",
|
|
21
|
+
"typescript"
|
|
22
22
|
],
|
|
23
23
|
"homepage": "https://c15t.com",
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/c15t/c15t/issues"
|
|
26
26
|
},
|
|
27
|
+
"license": "Apache-2.0",
|
|
27
28
|
"repository": {
|
|
28
29
|
"type": "git",
|
|
29
30
|
"url": "https://github.com/c15t/c15t.git",
|
|
30
31
|
"directory": "packages/node-sdk"
|
|
31
32
|
},
|
|
32
|
-
"
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"dist-types"
|
|
36
|
+
],
|
|
33
37
|
"type": "module",
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"types": "./dist-types/index.d.ts",
|
|
34
40
|
"exports": {
|
|
35
41
|
".": {
|
|
36
42
|
"types": "./dist-types/index.d.ts",
|
|
37
43
|
"import": "./dist/index.js",
|
|
38
|
-
"
|
|
44
|
+
"default": "./dist/index.js"
|
|
39
45
|
},
|
|
40
46
|
"./testing": {
|
|
41
47
|
"types": "./dist-types/testing.d.ts",
|
|
42
48
|
"import": "./dist/testing.js",
|
|
43
|
-
"
|
|
49
|
+
"default": "./dist/testing.js"
|
|
44
50
|
}
|
|
45
51
|
},
|
|
46
|
-
"main": "./dist/index.cjs",
|
|
47
|
-
"module": "./dist/index.js",
|
|
48
|
-
"types": "./dist-types/index.d.ts",
|
|
49
|
-
"files": [
|
|
50
|
-
"dist",
|
|
51
|
-
"dist-types"
|
|
52
|
-
],
|
|
53
52
|
"scripts": {
|
|
54
|
-
"prebuild": "genversion --esm --semi src/version.ts",
|
|
55
53
|
"build": "bun prebuild && rslib build && bun ../../scripts/normalize-dist-types.mjs",
|
|
56
54
|
"check-types": "bun prebuild && tsc --noEmit",
|
|
57
55
|
"check-types:test": "bun prebuild && tsc -p tsconfig.test.json",
|
|
58
56
|
"dev": "sh -c 'bun prebuild && rslib build --no-dts --no-clean && rslib build --watch --no-dts --no-clean'",
|
|
59
|
-
"fmt": "bun
|
|
60
|
-
"lint": "bun
|
|
57
|
+
"fmt": "bun oxfmt .",
|
|
58
|
+
"lint": "bun oxlint ./src",
|
|
59
|
+
"prebuild": "genversion --esm --semi src/version.ts",
|
|
61
60
|
"test": "bun prebuild && vitest run",
|
|
62
61
|
"test:watch": "bun prebuild && vitest"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@c15t/backend": "
|
|
64
|
+
"@c15t/backend": "3.0.0-alpha.0"
|
|
66
65
|
},
|
|
67
66
|
"devDependencies": {
|
|
68
67
|
"@c15t/typescript-config": "0.0.1",
|
|
@@ -76,6 +75,6 @@
|
|
|
76
75
|
"genversion": "3.2.0",
|
|
77
76
|
"kysely-pglite": "^0.6.1",
|
|
78
77
|
"msw": "^2.14.6",
|
|
79
|
-
"typescript": "7.0.
|
|
78
|
+
"typescript": "7.0.2"
|
|
80
79
|
}
|
|
81
80
|
}
|
package/readme.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"Comprehensive error handling and URL validation"
|
|
12
12
|
],
|
|
13
13
|
"prerequisites": [
|
|
14
|
-
"Node.js
|
|
14
|
+
"Node.js 20.19 or later",
|
|
15
15
|
"A hosted [c15t instance](https://inth.com) (free sign-up) or [self-hosted deployment](https://c15t.com/docs/self-host/quickstart)"
|
|
16
16
|
],
|
|
17
17
|
"manualInstallation": ["", "```bash\npnpm add @c15t/node-sdk\n```"],
|