@karlroigus/api-contracts 0.0.0-stage → 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,157 @@
1
+ export interface Translations {
2
+ en: string;
3
+ et?: string;
4
+ [key: string]: string | undefined;
5
+ }
6
+ export interface ProductDB {
7
+ id: number;
8
+ name: Translations;
9
+ description: Translations | null;
10
+ price: number;
11
+ image_url: string | null;
12
+ category_id: number | null;
13
+ stock: number;
14
+ is_active: boolean;
15
+ skin_feel: Translations | null;
16
+ aroma: Translations | null;
17
+ key_ingredients: Translations | null;
18
+ created_at: Date;
19
+ updated_at: Date;
20
+ }
21
+ export interface Product {
22
+ id: number;
23
+ name: string;
24
+ description: string | null;
25
+ price: number;
26
+ image_url: string | null;
27
+ category_id: number | null;
28
+ stock: number;
29
+ is_active: boolean;
30
+ skin_feel: string | null;
31
+ aroma: string | null;
32
+ key_ingredients: string | null;
33
+ created_at: Date;
34
+ updated_at: Date;
35
+ }
36
+ export interface ProductWithCategory extends Product {
37
+ category_name: string | null;
38
+ }
39
+ export interface ProductAdmin extends Omit<ProductDB, 'name' | 'description'> {
40
+ name: Translations;
41
+ description: Translations | null;
42
+ category_name?: string;
43
+ }
44
+ export interface ProductInput {
45
+ name: Translations;
46
+ description?: Translations | null;
47
+ price: number;
48
+ image_url?: string | null;
49
+ category_id?: number | null;
50
+ stock?: number;
51
+ is_active?: boolean;
52
+ skin_feel?: Translations | null;
53
+ aroma?: Translations | null;
54
+ key_ingredients?: Translations | null;
55
+ }
56
+ export interface CategoryDB {
57
+ id: number;
58
+ name: Translations;
59
+ description: Translations | null;
60
+ image_url: string | null;
61
+ created_at: Date;
62
+ }
63
+ export interface Category {
64
+ id: number;
65
+ name: string;
66
+ description: string | null;
67
+ image_url: string | null;
68
+ created_at: Date;
69
+ }
70
+ export interface CategoryAdmin extends CategoryDB {
71
+ }
72
+ export interface CategoryInput {
73
+ name: Translations;
74
+ description?: Translations | null;
75
+ image_url?: string | null;
76
+ }
77
+ export interface Order {
78
+ id: number;
79
+ customer_email: string;
80
+ customer_name: string;
81
+ customer_phone: string | null;
82
+ shipping_address: string;
83
+ status: string;
84
+ total: number;
85
+ stripe_payment_id: string | null;
86
+ notes: string | null;
87
+ created_at: Date;
88
+ updated_at: Date;
89
+ }
90
+ export interface OrderItem {
91
+ id: number;
92
+ order_id: number;
93
+ product_id: number | null;
94
+ quantity: number;
95
+ price_at_purchase: number;
96
+ }
97
+ export interface OrderItemWithProduct extends OrderItem {
98
+ product_name: string | null;
99
+ product_image_url: string | null;
100
+ }
101
+ export interface OrderWithItems extends Order {
102
+ items: OrderItemWithProduct[];
103
+ }
104
+ export interface CreateOrderData {
105
+ customer_email: string;
106
+ customer_name: string;
107
+ customer_phone?: string;
108
+ shipping_address: string;
109
+ notes?: string;
110
+ items: {
111
+ product_id: number;
112
+ quantity: number;
113
+ price_at_purchase: number;
114
+ }[];
115
+ }
116
+ export interface TokenPayload {
117
+ sub: number;
118
+ email: string;
119
+ role: string;
120
+ }
121
+ export interface AdminLoginResponse {
122
+ token: string;
123
+ user: {
124
+ id: number;
125
+ email: string;
126
+ role: string;
127
+ };
128
+ }
129
+ export interface AdminStatsResponse {
130
+ totalOrders: number;
131
+ pendingOrders: number;
132
+ completedOrders: number;
133
+ totalRevenue: number;
134
+ totalProducts: number;
135
+ activeProducts: number;
136
+ totalCategories: number;
137
+ }
138
+ export type CreateOrderResponse = OrderWithItems;
139
+ export interface StripeCheckoutResponse {
140
+ sessionId: string;
141
+ url: string;
142
+ orderData: {
143
+ session_id: string;
144
+ items: {
145
+ product_id: number;
146
+ quantity: number;
147
+ price_at_purchase: number;
148
+ }[];
149
+ customer_email: string;
150
+ customer_name: string;
151
+ customer_phone?: string;
152
+ shipping_address: string;
153
+ notes?: string;
154
+ total: number;
155
+ };
156
+ }
157
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot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,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACb;AAID,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF;AAED,MAAM,WAAW,kBAAkB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE;YACN,UAAU,EAAE,MAAM,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC;YACjB,iBAAiB,EAAE,MAAM,CAAC;SAC1B,EAAE,CAAC;QACJ,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;CACF"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
- "name": "@karlroigus/api-contracts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@karlroigus/api-contracts",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "tsc"
8
+ },
9
+ "devDependencies": {
10
+ "typescript": "5.3.3"
11
+ }
12
+ }
package/src/index.ts ADDED
@@ -0,0 +1,184 @@
1
+ export interface Translations {
2
+ en: string;
3
+ et?: string;
4
+ [key: string]: string | undefined;
5
+ }
6
+
7
+ // ─── Products ───
8
+
9
+ export interface ProductDB {
10
+ id: number;
11
+ name: Translations;
12
+ description: Translations | null;
13
+ price: number;
14
+ image_url: string | null;
15
+ category_id: number | null;
16
+ stock: number;
17
+ is_active: boolean;
18
+ skin_feel: Translations | null;
19
+ aroma: Translations | null;
20
+ key_ingredients: Translations | null;
21
+ created_at: Date;
22
+ updated_at: Date;
23
+ }
24
+
25
+ export interface Product {
26
+ id: number;
27
+ name: string;
28
+ description: string | null;
29
+ price: number;
30
+ image_url: string | null;
31
+ category_id: number | null;
32
+ stock: number;
33
+ is_active: boolean;
34
+ skin_feel: string | null;
35
+ aroma: string | null;
36
+ key_ingredients: string | null;
37
+ created_at: Date;
38
+ updated_at: Date;
39
+ }
40
+
41
+ export interface ProductWithCategory extends Product {
42
+ category_name: string | null;
43
+ }
44
+
45
+ export interface ProductAdmin extends Omit<ProductDB, 'name' | 'description'> {
46
+ name: Translations;
47
+ description: Translations | null;
48
+ category_name?: string;
49
+ }
50
+
51
+ export interface ProductInput {
52
+ name: Translations;
53
+ description?: Translations | null;
54
+ price: number;
55
+ image_url?: string | null;
56
+ category_id?: number | null;
57
+ stock?: number;
58
+ is_active?: boolean;
59
+ skin_feel?: Translations | null;
60
+ aroma?: Translations | null;
61
+ key_ingredients?: Translations | null;
62
+ }
63
+
64
+ // ─── Categories ───
65
+
66
+ export interface CategoryDB {
67
+ id: number;
68
+ name: Translations;
69
+ description: Translations | null;
70
+ image_url: string | null;
71
+ created_at: Date;
72
+ }
73
+
74
+ export interface Category {
75
+ id: number;
76
+ name: string;
77
+ description: string | null;
78
+ image_url: string | null;
79
+ created_at: Date;
80
+ }
81
+
82
+ export interface CategoryAdmin extends CategoryDB {}
83
+
84
+ export interface CategoryInput {
85
+ name: Translations;
86
+ description?: Translations | null;
87
+ image_url?: string | null;
88
+ }
89
+
90
+ // ─── Orders ───
91
+
92
+ export interface Order {
93
+ id: number;
94
+ customer_email: string;
95
+ customer_name: string;
96
+ customer_phone: string | null;
97
+ shipping_address: string;
98
+ status: string;
99
+ total: number;
100
+ stripe_payment_id: string | null;
101
+ notes: string | null;
102
+ created_at: Date;
103
+ updated_at: Date;
104
+ }
105
+
106
+ export interface OrderItem {
107
+ id: number;
108
+ order_id: number;
109
+ product_id: number | null;
110
+ quantity: number;
111
+ price_at_purchase: number;
112
+ }
113
+
114
+ export interface OrderItemWithProduct extends OrderItem {
115
+ product_name: string | null;
116
+ product_image_url: string | null;
117
+ }
118
+
119
+ export interface OrderWithItems extends Order {
120
+ items: OrderItemWithProduct[];
121
+ }
122
+
123
+ export interface CreateOrderData {
124
+ customer_email: string;
125
+ customer_name: string;
126
+ customer_phone?: string;
127
+ shipping_address: string;
128
+ notes?: string;
129
+ items: {
130
+ product_id: number;
131
+ quantity: number;
132
+ price_at_purchase: number;
133
+ }[];
134
+ }
135
+
136
+ // ─── Auth ───
137
+
138
+ export interface TokenPayload {
139
+ sub: number;
140
+ email: string;
141
+ role: string;
142
+ }
143
+
144
+ // ─── API Responses ───
145
+
146
+ export interface AdminLoginResponse {
147
+ token: string;
148
+ user: {
149
+ id: number;
150
+ email: string;
151
+ role: string;
152
+ };
153
+ }
154
+
155
+ export interface AdminStatsResponse {
156
+ totalOrders: number;
157
+ pendingOrders: number;
158
+ completedOrders: number;
159
+ totalRevenue: number;
160
+ totalProducts: number;
161
+ activeProducts: number;
162
+ totalCategories: number;
163
+ }
164
+
165
+ export type CreateOrderResponse = OrderWithItems;
166
+
167
+ export interface StripeCheckoutResponse {
168
+ sessionId: string;
169
+ url: string;
170
+ orderData: {
171
+ session_id: string;
172
+ items: {
173
+ product_id: number;
174
+ quantity: number;
175
+ price_at_purchase: number;
176
+ }[];
177
+ customer_email: string;
178
+ customer_name: string;
179
+ customer_phone?: string;
180
+ shipping_address: string;
181
+ notes?: string;
182
+ total: number;
183
+ };
184
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "lib": ["ES2022"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.