@zssz-soft/common-api 0.0.1
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
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CommonApi
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.0.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build common-api
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd dist/common-api
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
40
|
+
```bash
|
|
41
|
+
npm publish
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Running unit tests
|
|
45
|
+
|
|
46
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ng test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Running end-to-end tests
|
|
53
|
+
|
|
54
|
+
For end-to-end (e2e) testing, run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ng e2e
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
61
|
+
|
|
62
|
+
## Additional Resources
|
|
63
|
+
|
|
64
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
var ActionEnum;
|
|
2
|
+
(function (ActionEnum) {
|
|
3
|
+
ActionEnum["ALL"] = "all";
|
|
4
|
+
ActionEnum["VIEW"] = "view";
|
|
5
|
+
ActionEnum["READ"] = "read";
|
|
6
|
+
ActionEnum["CREATE"] = "create";
|
|
7
|
+
ActionEnum["DELETE"] = "delete";
|
|
8
|
+
ActionEnum["SOME"] = "some";
|
|
9
|
+
ActionEnum["UPDATE"] = "update";
|
|
10
|
+
})(ActionEnum || (ActionEnum = {}));
|
|
11
|
+
|
|
12
|
+
var CurrencyEnum;
|
|
13
|
+
(function (CurrencyEnum) {
|
|
14
|
+
CurrencyEnum["HUF"] = "HUF";
|
|
15
|
+
CurrencyEnum["EUR"] = "EUR";
|
|
16
|
+
CurrencyEnum["USD"] = "USD";
|
|
17
|
+
})(CurrencyEnum || (CurrencyEnum = {}));
|
|
18
|
+
const currencies = [CurrencyEnum.HUF, CurrencyEnum.EUR, CurrencyEnum.USD];
|
|
19
|
+
|
|
20
|
+
const RoleNames = {
|
|
21
|
+
ADMIN: 'ADMIN',
|
|
22
|
+
EDITOR: 'EDITOR',
|
|
23
|
+
OWNER: 'OWNER',
|
|
24
|
+
USER: 'USER',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
class PermissionsService {
|
|
28
|
+
static permissions = [
|
|
29
|
+
{
|
|
30
|
+
label: 'App',
|
|
31
|
+
items: [
|
|
32
|
+
{
|
|
33
|
+
label: RoleNames.ADMIN,
|
|
34
|
+
value: RoleNames.ADMIN,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: RoleNames.USER,
|
|
38
|
+
value: RoleNames.USER,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
static addPermissions(permissions) {
|
|
44
|
+
PermissionsService.permissions.push(permissions);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Default pagination constants
|
|
50
|
+
*/
|
|
51
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
52
|
+
const MAX_PAGE_SIZE = 100;
|
|
53
|
+
/**
|
|
54
|
+
* Search constants
|
|
55
|
+
*/
|
|
56
|
+
const MIN_SEARCH_LENGTH = 3;
|
|
57
|
+
|
|
58
|
+
var QueryOperatorEnum;
|
|
59
|
+
(function (QueryOperatorEnum) {
|
|
60
|
+
QueryOperatorEnum["less"] = "<";
|
|
61
|
+
QueryOperatorEnum["lessEqual"] = "<=";
|
|
62
|
+
QueryOperatorEnum["equal"] = "==";
|
|
63
|
+
QueryOperatorEnum["notEqual"] = "!=";
|
|
64
|
+
QueryOperatorEnum["greaterEqual"] = ">=";
|
|
65
|
+
QueryOperatorEnum["greater"] = ">";
|
|
66
|
+
QueryOperatorEnum["arrayContains"] = "array-contains";
|
|
67
|
+
QueryOperatorEnum["in"] = "in";
|
|
68
|
+
QueryOperatorEnum["arrayContainsAny"] = "array-contains-any";
|
|
69
|
+
QueryOperatorEnum["notIn"] = "not-in";
|
|
70
|
+
})(QueryOperatorEnum || (QueryOperatorEnum = {}));
|
|
71
|
+
var QueryConstraintTypeEnum;
|
|
72
|
+
(function (QueryConstraintTypeEnum) {
|
|
73
|
+
QueryConstraintTypeEnum["where"] = "where";
|
|
74
|
+
QueryConstraintTypeEnum["orderBy"] = "orderBy";
|
|
75
|
+
QueryConstraintTypeEnum["limit"] = "limit";
|
|
76
|
+
QueryConstraintTypeEnum["limitToLast"] = "limitToLast";
|
|
77
|
+
QueryConstraintTypeEnum["startAt"] = "startAt";
|
|
78
|
+
QueryConstraintTypeEnum["startAfter"] = "startAfter";
|
|
79
|
+
QueryConstraintTypeEnum["endAt"] = "endAt";
|
|
80
|
+
QueryConstraintTypeEnum["endBefore"] = "endBefore";
|
|
81
|
+
})(QueryConstraintTypeEnum || (QueryConstraintTypeEnum = {}));
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Validates if a search term meets minimum length requirement
|
|
85
|
+
*/
|
|
86
|
+
function isValidSearchTerm(term) {
|
|
87
|
+
return !!term && term.trim().length >= MIN_SEARCH_LENGTH;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Normalizes a search term (trims and lowercases)
|
|
91
|
+
*/
|
|
92
|
+
function normalizeSearchTerm(term) {
|
|
93
|
+
return term.trim().toLowerCase();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var EntityTypeEnum;
|
|
97
|
+
(function (EntityTypeEnum) {
|
|
98
|
+
EntityTypeEnum["Document"] = "document";
|
|
99
|
+
EntityTypeEnum["Entity"] = "entity";
|
|
100
|
+
EntityTypeEnum["User"] = "user";
|
|
101
|
+
EntityTypeEnum["Role"] = "role";
|
|
102
|
+
})(EntityTypeEnum || (EntityTypeEnum = {}));
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Common types used across entities
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* User account status
|
|
109
|
+
*/
|
|
110
|
+
var UserStatus;
|
|
111
|
+
(function (UserStatus) {
|
|
112
|
+
UserStatus["ACTIVE"] = "ACTIVE";
|
|
113
|
+
UserStatus["INACTIVE"] = "INACTIVE";
|
|
114
|
+
UserStatus["SUSPENDED"] = "SUSPENDED";
|
|
115
|
+
UserStatus["PENDING"] = "PENDING";
|
|
116
|
+
})(UserStatus || (UserStatus = {}));
|
|
117
|
+
/**
|
|
118
|
+
* Common status enumeration
|
|
119
|
+
*/
|
|
120
|
+
var Status;
|
|
121
|
+
(function (Status) {
|
|
122
|
+
Status["ACTIVE"] = "ACTIVE";
|
|
123
|
+
Status["INACTIVE"] = "INACTIVE";
|
|
124
|
+
Status["PENDING"] = "PENDING";
|
|
125
|
+
Status["ARCHIVED"] = "ARCHIVED";
|
|
126
|
+
})(Status || (Status = {}));
|
|
127
|
+
/**
|
|
128
|
+
* User roles enumeration
|
|
129
|
+
*/
|
|
130
|
+
var UserRole;
|
|
131
|
+
(function (UserRole) {
|
|
132
|
+
UserRole["ADMIN"] = "ADMIN";
|
|
133
|
+
UserRole["USER"] = "USER";
|
|
134
|
+
UserRole["GUEST"] = "GUEST";
|
|
135
|
+
})(UserRole || (UserRole = {}));
|
|
136
|
+
/**
|
|
137
|
+
* Priority levels enumeration
|
|
138
|
+
*/
|
|
139
|
+
var Priority;
|
|
140
|
+
(function (Priority) {
|
|
141
|
+
Priority["LOW"] = "LOW";
|
|
142
|
+
Priority["MEDIUM"] = "MEDIUM";
|
|
143
|
+
Priority["HIGH"] = "HIGH";
|
|
144
|
+
Priority["URGENT"] = "URGENT";
|
|
145
|
+
})(Priority || (Priority = {}));
|
|
146
|
+
/**
|
|
147
|
+
* Common currency codes
|
|
148
|
+
*/
|
|
149
|
+
var CurrencyCode;
|
|
150
|
+
(function (CurrencyCode) {
|
|
151
|
+
CurrencyCode["USD"] = "USD";
|
|
152
|
+
CurrencyCode["EUR"] = "EUR";
|
|
153
|
+
CurrencyCode["GBP"] = "GBP";
|
|
154
|
+
CurrencyCode["HUF"] = "HUF";
|
|
155
|
+
})(CurrencyCode || (CurrencyCode = {}));
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
* Public API Surface of common-api
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Generated bundle index. Do not edit.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
export { ActionEnum, CurrencyCode, CurrencyEnum, DEFAULT_PAGE_SIZE, EntityTypeEnum, MAX_PAGE_SIZE, MIN_SEARCH_LENGTH, PermissionsService, Priority, QueryConstraintTypeEnum, QueryOperatorEnum, RoleNames, Status, UserRole, UserStatus, currencies, isValidSearchTerm, normalizeSearchTerm };
|
|
166
|
+
//# sourceMappingURL=zssz-soft-common-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zssz-soft-common-api.mjs","sources":["../../../projects/common-api/src/lib/action/action.ts","../../../projects/common-api/src/lib/currency/currency.ts","../../../projects/common-api/src/lib/role/role.ts","../../../projects/common-api/src/lib/permission/permissions.service.ts","../../../projects/common-api/src/lib/query/query.constants.ts","../../../projects/common-api/src/lib/query/query.enums.ts","../../../projects/common-api/src/lib/query/query.utils.ts","../../../projects/common-api/src/lib/search/search.ts","../../../projects/common-api/src/lib/types/common-types.ts","../../../projects/common-api/src/public-api.ts","../../../projects/common-api/src/zssz-soft-common-api.ts"],"sourcesContent":["export interface Action {\n name: string;\n}\n\nexport enum ActionEnum {\n ALL = 'all',\n VIEW = 'view',\n READ = 'read',\n CREATE = 'create',\n DELETE = 'delete',\n SOME = 'some',\n UPDATE = 'update',\n}\n","export enum CurrencyEnum {\n HUF = 'HUF',\n EUR = 'EUR',\n USD = 'USD',\n}\n\nexport const currencies: CurrencyEnum[] = [CurrencyEnum.HUF, CurrencyEnum.EUR, CurrencyEnum.USD];\n","export interface _Role {\n editable?: boolean;\n name: string;\n permissions: string[];\n}\n\nexport type Role = _Role;\n\nexport const RoleNames = {\n ADMIN: 'ADMIN',\n EDITOR: 'EDITOR',\n OWNER: 'OWNER',\n USER: 'USER',\n};\n","export interface SelectItem {\n label?: string;\n value: any;\n styleClass?: string;\n icon?: string;\n title?: string;\n disabled?: boolean;\n}\n\nexport interface SelectItemGroup {\n label: string;\n value?: any;\n items: SelectItem[];\n}\n\nimport { RoleNames } from '../role';\n\nexport abstract class PermissionsService {\n public static permissions: SelectItemGroup[] = [\n {\n label: 'App',\n items: [\n {\n label: RoleNames.ADMIN,\n value: RoleNames.ADMIN,\n },\n {\n label: RoleNames.USER,\n value: RoleNames.USER,\n },\n ],\n },\n ];\n\n public static addPermissions(permissions: SelectItemGroup): void {\n PermissionsService.permissions.push(permissions);\n }\n}\n","/**\n * Default pagination constants\n */\nexport const DEFAULT_PAGE_SIZE = 10;\nexport const MAX_PAGE_SIZE = 100;\n\n/**\n * Search constants\n */\nexport const MIN_SEARCH_LENGTH = 3;\n","export enum QueryOperatorEnum {\n less = '<',\n lessEqual = '<=',\n equal = '==',\n notEqual = '!=',\n greaterEqual = '>=',\n greater = '>',\n arrayContains = 'array-contains',\n in = 'in',\n arrayContainsAny = 'array-contains-any',\n notIn = 'not-in',\n}\n\nexport enum QueryConstraintTypeEnum {\n where = 'where',\n orderBy = 'orderBy',\n limit = 'limit',\n limitToLast = 'limitToLast',\n startAt = 'startAt',\n startAfter = 'startAfter',\n endAt = 'endAt',\n endBefore = 'endBefore',\n}\n","import { MIN_SEARCH_LENGTH } from './query.constants';\n\n/**\n * Validates if a search term meets minimum length requirement\n */\nexport function isValidSearchTerm(term: string | undefined | null): boolean {\n return !!term && term.trim().length >= MIN_SEARCH_LENGTH;\n}\n\n/**\n * Normalizes a search term (trims and lowercases)\n */\nexport function normalizeSearchTerm(term: string): string {\n return term.trim().toLowerCase();\n}\n","import { QueryConstraintTypeEnum, QueryOperatorEnum } from '../query';\n\nexport const enum EntityTypeEnum {\n Document = 'document',\n Entity = 'entity',\n User = 'user',\n Role = 'role',\n}\n\nexport interface Searchable {\n searchParameters: string[];\n}\n\nexport interface SearchParam {\n entityType: EntityTypeEnum;\n query: ParamItem<unknown>;\n}\n\nexport interface ParamItem<T> {\n field: string;\n queryConstraint: QueryConstraintTypeEnum;\n operation: QueryOperatorEnum;\n value: T;\n}\n\nexport type SearchParams = SearchParam[];\n","/**\n * Common types used across entities\n */\n\n/** Entity identifier type */\nexport type EntityId = string;\n\n/** User identifier type */\nexport type UserId = string;\n\n/** Email address type */\nexport type Email = string;\n\n/** Phone number type */\nexport type Phone = string;\n\n/** URL type */\nexport type Url = string;\n\n/** Money amount with currency */\nexport interface Money {\n amount: number;\n currency: string; // ISO 4217 currency code\n}\n\n/** Address information */\nexport interface Address {\n street: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string;\n}\n\n/** Date range */\nexport interface DateRange {\n startDate: Date;\n endDate: Date;\n}\n\n/**\n * User account status\n */\nexport enum UserStatus {\n ACTIVE = 'ACTIVE',\n INACTIVE = 'INACTIVE',\n SUSPENDED = 'SUSPENDED',\n PENDING = 'PENDING',\n}\n\n/**\n * Common status enumeration\n */\nexport enum Status {\n ACTIVE = 'ACTIVE',\n INACTIVE = 'INACTIVE',\n PENDING = 'PENDING',\n ARCHIVED = 'ARCHIVED',\n}\n\n/**\n * User roles enumeration\n */\nexport enum UserRole {\n ADMIN = 'ADMIN',\n USER = 'USER',\n GUEST = 'GUEST',\n}\n\n/**\n * Priority levels enumeration\n */\nexport enum Priority {\n LOW = 'LOW',\n MEDIUM = 'MEDIUM',\n HIGH = 'HIGH',\n URGENT = 'URGENT',\n}\n\n/**\n * Common currency codes\n */\nexport enum CurrencyCode {\n USD = 'USD',\n EUR = 'EUR',\n GBP = 'GBP',\n HUF = 'HUF',\n}\n","/*\n * Public API Surface of common-api\n */\n\nexport * from './lib/action';\nexport * from './lib/currency';\nexport * from './lib/deletable';\nexport * from './lib/identifiable';\nexport * from './lib/message';\nexport * from './lib/meta';\nexport * from './lib/pagination';\nexport * from './lib/permission';\nexport * from './lib/query';\nexport * from './lib/role';\nexport * from './lib/search';\nexport * from './lib/types';\nexport * from './lib/user';\nexport * from './lib/versionable';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IAIY;AAAZ,CAAA,UAAY,UAAU,EAAA;AACpB,IAAA,UAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,UAAA,CAAA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A,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACjB,CAAC,EAJW,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;AAMpB;;AAEG;IACS;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,QAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EALW,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;AAOpB;;AAEG;IACS;AAAZ,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EALW,YAAY,KAAZ,YAAY,GAAA,EAAA,CAAA,CAAA;;AClFxB;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zssz-soft/common-api",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Foundation types for the @zssz-soft library ecosystem",
|
|
5
|
+
"author": "zssz-soft",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zssz-soft/libraries.git",
|
|
10
|
+
"directory": "projects/common-api"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/zssz-soft/libraries/tree/main/projects/common-api",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/zssz-soft/libraries/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"angular",
|
|
18
|
+
"typescript",
|
|
19
|
+
"api",
|
|
20
|
+
"types"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@angular/common": "^21.0.0",
|
|
27
|
+
"@angular/core": "^21.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"tslib": "^2.3.0"
|
|
31
|
+
},
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"module": "fesm2022/zssz-soft-common-api.mjs",
|
|
34
|
+
"typings": "types/zssz-soft-common-api.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
"./package.json": {
|
|
37
|
+
"default": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./types/zssz-soft-common-api.d.ts",
|
|
41
|
+
"default": "./fesm2022/zssz-soft-common-api.mjs"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
interface Action {
|
|
2
|
+
name: string;
|
|
3
|
+
}
|
|
4
|
+
declare enum ActionEnum {
|
|
5
|
+
ALL = "all",
|
|
6
|
+
VIEW = "view",
|
|
7
|
+
READ = "read",
|
|
8
|
+
CREATE = "create",
|
|
9
|
+
DELETE = "delete",
|
|
10
|
+
SOME = "some",
|
|
11
|
+
UPDATE = "update"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare enum CurrencyEnum {
|
|
15
|
+
HUF = "HUF",
|
|
16
|
+
EUR = "EUR",
|
|
17
|
+
USD = "USD"
|
|
18
|
+
}
|
|
19
|
+
declare const currencies: CurrencyEnum[];
|
|
20
|
+
|
|
21
|
+
interface Deletable {
|
|
22
|
+
/** Soft delete flag */
|
|
23
|
+
isDeleted?: boolean;
|
|
24
|
+
/** Deletion */
|
|
25
|
+
deletedAt?: string;
|
|
26
|
+
/** Deleter user ID */
|
|
27
|
+
deletedBy?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Identifiable {
|
|
31
|
+
uid: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Message {
|
|
35
|
+
severity?: string;
|
|
36
|
+
summary?: string;
|
|
37
|
+
detail?: string;
|
|
38
|
+
id?: any;
|
|
39
|
+
key?: string;
|
|
40
|
+
life?: number;
|
|
41
|
+
sticky?: boolean;
|
|
42
|
+
closable?: boolean;
|
|
43
|
+
data?: any;
|
|
44
|
+
icon?: string;
|
|
45
|
+
contentStyleClass?: string;
|
|
46
|
+
styleClass?: string;
|
|
47
|
+
closeIcon?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface Meta {
|
|
51
|
+
/** Creation */
|
|
52
|
+
createdAt: string;
|
|
53
|
+
/** Last update */
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
/** Creator user ID */
|
|
56
|
+
createdBy?: string;
|
|
57
|
+
/** Last updater user ID */
|
|
58
|
+
updatedBy?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Cursor value for pagination - can be any field value or document snapshot
|
|
63
|
+
*/
|
|
64
|
+
type CursorValue = unknown;
|
|
65
|
+
/**
|
|
66
|
+
* Search options for text-based filtering
|
|
67
|
+
*/
|
|
68
|
+
interface SearchOptions {
|
|
69
|
+
/** The search term (minimum MIN_SEARCH_LENGTH characters) */
|
|
70
|
+
term: string;
|
|
71
|
+
/** Fields to search in */
|
|
72
|
+
fields: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Query options for database operations
|
|
76
|
+
*/
|
|
77
|
+
interface QueryOptions {
|
|
78
|
+
/** Filter conditions */
|
|
79
|
+
where?: QueryFilter[];
|
|
80
|
+
/** Sort order - required for cursor-based pagination */
|
|
81
|
+
orderBy?: QuerySort[];
|
|
82
|
+
/** Maximum number of results to return */
|
|
83
|
+
limit?: number;
|
|
84
|
+
/** Number of results to skip (offset-based pagination - less efficient) */
|
|
85
|
+
offset?: number;
|
|
86
|
+
/** Start results after this cursor value (cursor-based pagination) */
|
|
87
|
+
startAfter?: CursorValue;
|
|
88
|
+
/** Start results at this cursor value (inclusive) */
|
|
89
|
+
startAt?: CursorValue;
|
|
90
|
+
/** End results before this cursor value */
|
|
91
|
+
endBefore?: CursorValue;
|
|
92
|
+
/** End results at this cursor value (inclusive) */
|
|
93
|
+
endAt?: CursorValue;
|
|
94
|
+
/** Text search options */
|
|
95
|
+
search?: SearchOptions;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Extended query options with pagination metadata
|
|
99
|
+
* Used for paginated queries that need cursor tracking
|
|
100
|
+
*/
|
|
101
|
+
interface PaginatedQueryOptions extends QueryOptions {
|
|
102
|
+
/** Page number (1-indexed, for UI display) */
|
|
103
|
+
page?: number;
|
|
104
|
+
/** Size of each page */
|
|
105
|
+
pageSize?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Query filter interface
|
|
109
|
+
*/
|
|
110
|
+
interface QueryFilter {
|
|
111
|
+
field: string;
|
|
112
|
+
operator: '==' | '!=' | '<' | '<=' | '>' | '>=' | 'array-contains' | 'array-contains-any' | 'in' | 'not-in';
|
|
113
|
+
value: unknown;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sort direction type
|
|
117
|
+
*/
|
|
118
|
+
type QuerySortDirection = 'asc' | 'desc';
|
|
119
|
+
/**
|
|
120
|
+
* Query sort interface
|
|
121
|
+
*/
|
|
122
|
+
interface QuerySort {
|
|
123
|
+
field: string;
|
|
124
|
+
direction: QuerySortDirection;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Pagination parameters (offset-based) */
|
|
128
|
+
interface PaginationOptions {
|
|
129
|
+
page: number;
|
|
130
|
+
limit: number;
|
|
131
|
+
sortBy?: string;
|
|
132
|
+
sortOrder?: 'asc' | 'desc';
|
|
133
|
+
}
|
|
134
|
+
/** Cursor-based pagination parameters (more efficient for Firestore) */
|
|
135
|
+
interface CursorPaginationOptions {
|
|
136
|
+
/** Number of items per page */
|
|
137
|
+
pageSize: number;
|
|
138
|
+
/** Field to sort by */
|
|
139
|
+
sortBy?: string;
|
|
140
|
+
/** Sort direction */
|
|
141
|
+
sortOrder?: 'asc' | 'desc';
|
|
142
|
+
/** Cursor to start after (for next page) */
|
|
143
|
+
startAfter?: CursorValue;
|
|
144
|
+
/** Cursor to end before (for previous page) */
|
|
145
|
+
endBefore?: CursorValue;
|
|
146
|
+
}
|
|
147
|
+
/** Pagination result */
|
|
148
|
+
interface PaginatedResult<T> {
|
|
149
|
+
items: T[];
|
|
150
|
+
totalItems: number;
|
|
151
|
+
totalPages: number;
|
|
152
|
+
currentPage: number;
|
|
153
|
+
hasNext: boolean;
|
|
154
|
+
hasPrevious: boolean;
|
|
155
|
+
}
|
|
156
|
+
/** Cursor-based pagination result (more efficient for Firestore) */
|
|
157
|
+
interface CursorPaginatedResult<T> {
|
|
158
|
+
/** The items for the current page */
|
|
159
|
+
items: T[];
|
|
160
|
+
/** Whether there are more items after this page */
|
|
161
|
+
hasNext: boolean;
|
|
162
|
+
/** Whether there are items before this page */
|
|
163
|
+
hasPrevious: boolean;
|
|
164
|
+
/** Cursor for the first item (for previous page navigation) */
|
|
165
|
+
firstCursor?: CursorValue;
|
|
166
|
+
/** Cursor for the last item (for next page navigation) */
|
|
167
|
+
lastCursor?: CursorValue;
|
|
168
|
+
/** Total count (optional - expensive operation in Firestore) */
|
|
169
|
+
totalItems?: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface SelectItem {
|
|
173
|
+
label?: string;
|
|
174
|
+
value: any;
|
|
175
|
+
styleClass?: string;
|
|
176
|
+
icon?: string;
|
|
177
|
+
title?: string;
|
|
178
|
+
disabled?: boolean;
|
|
179
|
+
}
|
|
180
|
+
interface SelectItemGroup {
|
|
181
|
+
label: string;
|
|
182
|
+
value?: any;
|
|
183
|
+
items: SelectItem[];
|
|
184
|
+
}
|
|
185
|
+
declare abstract class PermissionsService {
|
|
186
|
+
static permissions: SelectItemGroup[];
|
|
187
|
+
static addPermissions(permissions: SelectItemGroup): void;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Default pagination constants
|
|
192
|
+
*/
|
|
193
|
+
declare const DEFAULT_PAGE_SIZE = 10;
|
|
194
|
+
declare const MAX_PAGE_SIZE = 100;
|
|
195
|
+
/**
|
|
196
|
+
* Search constants
|
|
197
|
+
*/
|
|
198
|
+
declare const MIN_SEARCH_LENGTH = 3;
|
|
199
|
+
|
|
200
|
+
declare enum QueryOperatorEnum {
|
|
201
|
+
less = "<",
|
|
202
|
+
lessEqual = "<=",
|
|
203
|
+
equal = "==",
|
|
204
|
+
notEqual = "!=",
|
|
205
|
+
greaterEqual = ">=",
|
|
206
|
+
greater = ">",
|
|
207
|
+
arrayContains = "array-contains",
|
|
208
|
+
in = "in",
|
|
209
|
+
arrayContainsAny = "array-contains-any",
|
|
210
|
+
notIn = "not-in"
|
|
211
|
+
}
|
|
212
|
+
declare enum QueryConstraintTypeEnum {
|
|
213
|
+
where = "where",
|
|
214
|
+
orderBy = "orderBy",
|
|
215
|
+
limit = "limit",
|
|
216
|
+
limitToLast = "limitToLast",
|
|
217
|
+
startAt = "startAt",
|
|
218
|
+
startAfter = "startAfter",
|
|
219
|
+
endAt = "endAt",
|
|
220
|
+
endBefore = "endBefore"
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Validates if a search term meets minimum length requirement
|
|
225
|
+
*/
|
|
226
|
+
declare function isValidSearchTerm(term: string | undefined | null): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Normalizes a search term (trims and lowercases)
|
|
229
|
+
*/
|
|
230
|
+
declare function normalizeSearchTerm(term: string): string;
|
|
231
|
+
|
|
232
|
+
interface _Role {
|
|
233
|
+
editable?: boolean;
|
|
234
|
+
name: string;
|
|
235
|
+
permissions: string[];
|
|
236
|
+
}
|
|
237
|
+
type Role = _Role;
|
|
238
|
+
declare const RoleNames: {
|
|
239
|
+
ADMIN: string;
|
|
240
|
+
EDITOR: string;
|
|
241
|
+
OWNER: string;
|
|
242
|
+
USER: string;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
declare const enum EntityTypeEnum {
|
|
246
|
+
Document = "document",
|
|
247
|
+
Entity = "entity",
|
|
248
|
+
User = "user",
|
|
249
|
+
Role = "role"
|
|
250
|
+
}
|
|
251
|
+
interface Searchable {
|
|
252
|
+
searchParameters: string[];
|
|
253
|
+
}
|
|
254
|
+
interface SearchParam {
|
|
255
|
+
entityType: EntityTypeEnum;
|
|
256
|
+
query: ParamItem<unknown>;
|
|
257
|
+
}
|
|
258
|
+
interface ParamItem<T> {
|
|
259
|
+
field: string;
|
|
260
|
+
queryConstraint: QueryConstraintTypeEnum;
|
|
261
|
+
operation: QueryOperatorEnum;
|
|
262
|
+
value: T;
|
|
263
|
+
}
|
|
264
|
+
type SearchParams = SearchParam[];
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Common types used across entities
|
|
268
|
+
*/
|
|
269
|
+
/** Entity identifier type */
|
|
270
|
+
type EntityId = string;
|
|
271
|
+
/** User identifier type */
|
|
272
|
+
type UserId = string;
|
|
273
|
+
/** Email address type */
|
|
274
|
+
type Email = string;
|
|
275
|
+
/** Phone number type */
|
|
276
|
+
type Phone = string;
|
|
277
|
+
/** URL type */
|
|
278
|
+
type Url = string;
|
|
279
|
+
/** Money amount with currency */
|
|
280
|
+
interface Money {
|
|
281
|
+
amount: number;
|
|
282
|
+
currency: string;
|
|
283
|
+
}
|
|
284
|
+
/** Address information */
|
|
285
|
+
interface Address {
|
|
286
|
+
street: string;
|
|
287
|
+
city: string;
|
|
288
|
+
state?: string;
|
|
289
|
+
postalCode: string;
|
|
290
|
+
country: string;
|
|
291
|
+
}
|
|
292
|
+
/** Date range */
|
|
293
|
+
interface DateRange {
|
|
294
|
+
startDate: Date;
|
|
295
|
+
endDate: Date;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* User account status
|
|
299
|
+
*/
|
|
300
|
+
declare enum UserStatus {
|
|
301
|
+
ACTIVE = "ACTIVE",
|
|
302
|
+
INACTIVE = "INACTIVE",
|
|
303
|
+
SUSPENDED = "SUSPENDED",
|
|
304
|
+
PENDING = "PENDING"
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Common status enumeration
|
|
308
|
+
*/
|
|
309
|
+
declare enum Status {
|
|
310
|
+
ACTIVE = "ACTIVE",
|
|
311
|
+
INACTIVE = "INACTIVE",
|
|
312
|
+
PENDING = "PENDING",
|
|
313
|
+
ARCHIVED = "ARCHIVED"
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* User roles enumeration
|
|
317
|
+
*/
|
|
318
|
+
declare enum UserRole {
|
|
319
|
+
ADMIN = "ADMIN",
|
|
320
|
+
USER = "USER",
|
|
321
|
+
GUEST = "GUEST"
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Priority levels enumeration
|
|
325
|
+
*/
|
|
326
|
+
declare enum Priority {
|
|
327
|
+
LOW = "LOW",
|
|
328
|
+
MEDIUM = "MEDIUM",
|
|
329
|
+
HIGH = "HIGH",
|
|
330
|
+
URGENT = "URGENT"
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Common currency codes
|
|
334
|
+
*/
|
|
335
|
+
declare enum CurrencyCode {
|
|
336
|
+
USD = "USD",
|
|
337
|
+
EUR = "EUR",
|
|
338
|
+
GBP = "GBP",
|
|
339
|
+
HUF = "HUF"
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface _User {
|
|
343
|
+
displayName?: string | null;
|
|
344
|
+
email: string;
|
|
345
|
+
firstName?: string;
|
|
346
|
+
language?: string;
|
|
347
|
+
lastName?: string;
|
|
348
|
+
phone?: string;
|
|
349
|
+
photoURL?: string | null;
|
|
350
|
+
}
|
|
351
|
+
type User = _User & Identifiable;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Versioned entity interface for optimistic locking
|
|
355
|
+
*/
|
|
356
|
+
interface Versionable {
|
|
357
|
+
/** Version number */
|
|
358
|
+
version: number;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export { ActionEnum, CurrencyCode, CurrencyEnum, DEFAULT_PAGE_SIZE, EntityTypeEnum, MAX_PAGE_SIZE, MIN_SEARCH_LENGTH, PermissionsService, Priority, QueryConstraintTypeEnum, QueryOperatorEnum, RoleNames, Status, UserRole, UserStatus, currencies, isValidSearchTerm, normalizeSearchTerm };
|
|
362
|
+
export type { Action, Address, CursorPaginatedResult, CursorPaginationOptions, CursorValue, DateRange, Deletable, Email, EntityId, Identifiable, Message, Meta, Money, PaginatedQueryOptions, PaginatedResult, PaginationOptions, ParamItem, Phone, QueryFilter, QueryOptions, QuerySort, QuerySortDirection, Role, SearchOptions, SearchParam, SearchParams, Searchable, SelectItem, SelectItemGroup, Url, User, UserId, Versionable, _Role, _User };
|