@phygitallabs/phygital-consent 1.0.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.
@@ -0,0 +1,26 @@
1
+ export enum MediaType {
2
+ IMAGE = "image",
3
+ VIDEO = "video",
4
+ }
5
+
6
+ export type DateTimeNumber = number;
7
+
8
+ export interface Media {
9
+ url: string;
10
+ type: MediaType | string;
11
+ thumbnail_url?: string;
12
+ }
13
+
14
+ export enum EntityStatus {
15
+ ACTIVE = "Active",
16
+ INACTIVE = "Inactive",
17
+ }
18
+
19
+ export interface CommonModel {
20
+ id: string;
21
+ status: EntityStatus;
22
+ created_at: DateTimeNumber;
23
+ updated_at: DateTimeNumber;
24
+ created_by?: string;
25
+ updated_by?: string;
26
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Types aligned with Phygital Consent API (NCS) Swagger 2.0
3
+ */
4
+
5
+ export type ConsentStatus = "ACCEPTED" | "REJECTED";
6
+
7
+ export type PolicyType = "ACCOUNT_REGISTER" | "COOKIE_PREFERENCE";
8
+
9
+ export type PolicyStatus = "ACTIVE" | "INACTIVE";
10
+
11
+ /** Document within a policy (e.g. Terms of Service, Privacy Policy) */
12
+ export interface PolicyDocument {
13
+ name?: string;
14
+ version?: string;
15
+ effective_date?: string;
16
+ last_updated?: string;
17
+ meta_data?: Record<string, unknown>;
18
+ }
19
+
20
+ export interface PolicyPreference {
21
+ id?: string;
22
+ name?: string;
23
+ description?: string;
24
+ is_mandatory?: boolean;
25
+ }
26
+
27
+ export interface PolicyDetailDTO {
28
+ id?: string;
29
+ name?: string;
30
+ description?: string;
31
+ type?: PolicyType;
32
+ documents?: PolicyDocument[];
33
+ preferences?: PolicyPreference[];
34
+ version?: string;
35
+ meta_data?: Record<string, unknown>;
36
+ created_at?: string;
37
+ updated_at?: string;
38
+ status?: PolicyStatus;
39
+ }
40
+
41
+ export interface ConsentLogDetailDTO {
42
+ id?: string;
43
+ user_id?: string;
44
+ device_uid?: string;
45
+ policy_id?: string;
46
+ policy?: PolicyDetailDTO;
47
+ selected_preferences?: string[];
48
+ status?: ConsentStatus;
49
+ created_at?: string;
50
+ }
51
+
52
+ /** Create user consent (account register) – body for POST /consent/v1/user-id */
53
+ export interface CreateUserConsentUpsertDTO {
54
+ user_id?: string;
55
+ device_id?: string;
56
+ selected_preferences?: string[];
57
+ status: ConsentStatus;
58
+ }
59
+
60
+ /** Create device cookie consent – body for POST /consent/v1/cookies/device-id */
61
+ export interface CreateDeviceCookieConsentUpsertDTO {
62
+ device_id: string;
63
+ selected_preferences?: string[];
64
+ status: ConsentStatus;
65
+ }
66
+
67
+ // --- Request params ---
68
+
69
+ export interface GetManyConsentParams {
70
+ /** Filter by policy type */
71
+ type?: PolicyType;
72
+ }
73
+
74
+ export interface GetConsentByIdParams {
75
+ id: string;
76
+ }
77
+
78
+ export interface GetLatestConsentByUserIdParams {
79
+ user_id: string;
80
+ }
81
+
82
+ export interface GetLatestCookieConsentByDeviceIdParams {
83
+ device_id: string;
84
+ }
85
+
86
+ // --- Response types (API returns single DTO or array) ---
87
+
88
+ export type GetManyConsentResponse = ConsentLogDetailDTO[];
89
+
90
+ export type GetConsentByIdResponse = ConsentLogDetailDTO;
91
+
92
+ export type GetLatestConsentByUserIdResponse = ConsentLogDetailDTO;
93
+
94
+ export type GetLatestCookieConsentByDeviceIdResponse = ConsentLogDetailDTO;
95
+
96
+ export type CreateUserConsentResponse = ConsentLogDetailDTO;
97
+
98
+ export type CreateDeviceCookieConsentResponse = ConsentLogDetailDTO;
99
+
100
+ export interface HealthResponse {
101
+ status?: string;
102
+ [key: string]: unknown;
103
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./common";
2
+ export * from "./pagination";
3
+ export * from "./consent";
@@ -0,0 +1,30 @@
1
+ export interface PaginationRequest {
2
+ page?: number;
3
+ limit?: number;
4
+ total?: number;
5
+ next_cursor?: string;
6
+ order_by?: string;
7
+ order_direction?: "desc" | "asc";
8
+ search?: string;
9
+ cursor?: string;
10
+ start_time?: number;
11
+ end_time?: number;
12
+ }
13
+
14
+ export interface PaginationResponse {
15
+ order_by: string;
16
+ order_direction: string;
17
+ limit: number;
18
+ page: number;
19
+ total: number;
20
+ }
21
+
22
+ export interface GetManyResponse<T> {
23
+ data: T[];
24
+ pagination: PaginationResponse;
25
+ }
26
+
27
+ export interface GetOneResponse<T> {
28
+ data: T;
29
+ error: string;
30
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2021", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "allowJs": false,
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+ "baseUrl": ".",
17
+ "paths": {
18
+ "@/hooks/*": ["src/hooks/*"],
19
+ "react": ["./node_modules/@types/react"]
20
+ },
21
+ /* Linting */
22
+ "strict": true,
23
+ "noUnusedLocals": true,
24
+ "noUnusedParameters": true,
25
+ "noFallthroughCasesInSwitch": true,
26
+ "outDir": "./dist",
27
+ "rootDir": ".",
28
+ "declaration": true,
29
+ "declarationMap": true,
30
+ "sourceMap": true
31
+ },
32
+ "exclude": ["node_modules", "dist"],
33
+ "include": ["."]
34
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,20 @@
1
+ /* eslint-disable import/no-default-export */
2
+ /* eslint-disable import/no-extraneous-dependencies */
3
+ import type { Options } from "tsup";
4
+ import { defineConfig } from "tsup";
5
+
6
+ export default defineConfig((options: Options) => ({
7
+ entry: ["index.ts"],
8
+ banner: {
9
+ js: "'use client'",
10
+ },
11
+ format: ["esm", "cjs"],
12
+ outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".js" }),
13
+ dts: true,
14
+ clean: true,
15
+ external: ["react", "axios", "@tanstack/react-query", "@tanstack/react-query-devtools"],
16
+ sourcemap: true,
17
+ minify: true,
18
+ injectStyle: true,
19
+ ...options,
20
+ }));