@davidmashadow/ss-ecommerce-types 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.
- package/README.md +74 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/types/api.types.d.ts +30 -0
- package/dist/types/api.types.d.ts.map +1 -0
- package/dist/types/api.types.js +33 -0
- package/dist/types/api.types.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/product.types.d.ts +5 -0
- package/dist/types/product.types.d.ts.map +1 -0
- package/dist/types/product.types.js +3 -0
- package/dist/types/product.types.js.map +1 -0
- package/dist/types/traffic.types.d.ts +13 -0
- package/dist/types/traffic.types.d.ts.map +1 -0
- package/dist/types/traffic.types.js +3 -0
- package/dist/types/traffic.types.js.map +1 -0
- package/dist/types/user.types.d.ts +20 -0
- package/dist/types/user.types.d.ts.map +1 -0
- package/dist/types/user.types.js +3 -0
- package/dist/types/user.types.js.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @your-org/shared-types
|
|
2
|
+
|
|
3
|
+
Shared TypeScript types and empty constants for backend and frontend applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @your-org/shared-types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
User,
|
|
16
|
+
EMPTY_USER,
|
|
17
|
+
ApiResponse,
|
|
18
|
+
createEmptyApiResponse
|
|
19
|
+
} from '@your-org/shared-types';
|
|
20
|
+
|
|
21
|
+
// Use types
|
|
22
|
+
const user: User = {
|
|
23
|
+
id: '123',
|
|
24
|
+
email: 'test@example.com',
|
|
25
|
+
firstName: 'John',
|
|
26
|
+
lastName: 'Doe',
|
|
27
|
+
createdAt: new Date(),
|
|
28
|
+
updatedAt: new Date(),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Use empty constants for initialization
|
|
32
|
+
const emptyUser = { ...EMPTY_USER };
|
|
33
|
+
|
|
34
|
+
// Use generic API response
|
|
35
|
+
const response: ApiResponse<User> = createEmptyApiResponse<User>();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Install dependencies
|
|
42
|
+
npm install
|
|
43
|
+
|
|
44
|
+
# Build
|
|
45
|
+
npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Publishing
|
|
49
|
+
|
|
50
|
+
1. Update the package name in `package.json` (replace `@your-org` with your npm org/username)
|
|
51
|
+
2. Login to npm: `npm login`
|
|
52
|
+
3. Publish: `npm publish --access public`
|
|
53
|
+
|
|
54
|
+
## Project Structure
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
src/
|
|
58
|
+
├── index.ts # Main entry point
|
|
59
|
+
└── types/
|
|
60
|
+
├── index.ts # Types barrel export
|
|
61
|
+
├── user.types.ts # User related types & constants
|
|
62
|
+
└── api.types.ts # API related types & constants
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Adding New Types
|
|
66
|
+
|
|
67
|
+
1. Create a new file in `src/types/` (e.g., `product.types.ts`)
|
|
68
|
+
2. Define your interfaces and empty constants
|
|
69
|
+
3. Export from `src/types/index.ts`
|
|
70
|
+
4. Run `npm run build` to compile
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for shared-types package
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { User, EMPTY_USER, ApiResponse } from '@your-org/shared-types';
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API related types and empty constants
|
|
3
|
+
*/
|
|
4
|
+
export interface ApiResponse<T> {
|
|
5
|
+
success: boolean;
|
|
6
|
+
data: T | null;
|
|
7
|
+
error: ApiError | null;
|
|
8
|
+
meta: ApiMeta;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiError {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
details: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface ApiMeta {
|
|
16
|
+
timestamp: string;
|
|
17
|
+
requestId: string;
|
|
18
|
+
pagination: Pagination | null;
|
|
19
|
+
}
|
|
20
|
+
export interface Pagination {
|
|
21
|
+
page: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
total: number;
|
|
24
|
+
totalPages: number;
|
|
25
|
+
}
|
|
26
|
+
export declare const EMPTY_PAGINATION: Pagination;
|
|
27
|
+
export declare const EMPTY_API_META: ApiMeta;
|
|
28
|
+
export declare const EMPTY_API_ERROR: ApiError;
|
|
29
|
+
export declare function createEmptyApiResponse<T>(): ApiResponse<T>;
|
|
30
|
+
//# sourceMappingURL=api.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../../src/types/api.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,OAAO;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACtB;AAID,eAAO,MAAM,gBAAgB,EAAE,UAK9B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OAI5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAO1D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API related types and empty constants
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EMPTY_API_ERROR = exports.EMPTY_API_META = exports.EMPTY_PAGINATION = void 0;
|
|
7
|
+
exports.createEmptyApiResponse = createEmptyApiResponse;
|
|
8
|
+
// ============ EMPTY CONSTANTS ============
|
|
9
|
+
exports.EMPTY_PAGINATION = {
|
|
10
|
+
page: 0,
|
|
11
|
+
limit: 0,
|
|
12
|
+
total: 0,
|
|
13
|
+
totalPages: 0,
|
|
14
|
+
};
|
|
15
|
+
exports.EMPTY_API_META = {
|
|
16
|
+
timestamp: '',
|
|
17
|
+
requestId: '',
|
|
18
|
+
pagination: null,
|
|
19
|
+
};
|
|
20
|
+
exports.EMPTY_API_ERROR = {
|
|
21
|
+
code: '',
|
|
22
|
+
message: '',
|
|
23
|
+
details: {},
|
|
24
|
+
};
|
|
25
|
+
function createEmptyApiResponse() {
|
|
26
|
+
return {
|
|
27
|
+
success: false,
|
|
28
|
+
data: null,
|
|
29
|
+
error: null,
|
|
30
|
+
meta: exports.EMPTY_API_META,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=api.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.types.js","sourceRoot":"","sources":["../../src/types/api.types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAmDH,wDAOC;AA5BD,4CAA4C;AAE/B,QAAA,gBAAgB,GAAe;IACxC,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAC;CAChB,CAAC;AAEW,QAAA,cAAc,GAAY;IACnC,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,IAAI;CACnB,CAAC;AAEW,QAAA,eAAe,GAAa;IACrC,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;CACd,CAAC;AAEF,SAAgB,sBAAsB;IAClC,OAAO;QACH,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,sBAAc;KACvB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./user.types"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.types.d.ts","sourceRoot":"","sources":["../../src/types/product.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.types.js","sourceRoot":"","sources":["../../src/types/product.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traffic.types.d.ts","sourceRoot":"","sources":["../../src/types/traffic.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,UAAU,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traffic.types.js","sourceRoot":"","sources":["../../src/types/traffic.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IStaticImage } from "./product.types";
|
|
2
|
+
import type { IIpDetails } from "./traffic.types";
|
|
3
|
+
export interface IUser {
|
|
4
|
+
_id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
surname?: string;
|
|
7
|
+
email: string;
|
|
8
|
+
phoneNumber: string;
|
|
9
|
+
password: string;
|
|
10
|
+
profileImage: IStaticImage[];
|
|
11
|
+
role: ['ROLE_USER'] | ['ROLE_ADMIN'];
|
|
12
|
+
isActivated: boolean;
|
|
13
|
+
activationType: 'email' | 'phone';
|
|
14
|
+
activationKey?: string;
|
|
15
|
+
activationCode?: string;
|
|
16
|
+
details: IIpDetails;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=user.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.types.d.ts","sourceRoot":"","sources":["../../src/types/user.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,KAAK;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,GAAG,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.types.js","sourceRoot":"","sources":["../../src/types/user.types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@davidmashadow/ss-ecommerce-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Shared TypeScript types and empty constants for ss e-commerce backend and frontend",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^5.7.3"
|
|
30
|
+
}
|
|
31
|
+
}
|