@authenty/authapi-types 1.0.10 → 1.0.11
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/CLIENT_USAGE.md +317 -0
- package/README.md +85 -13
- package/dist/package.json +18 -0
- package/dist/src/index.d.ts +623 -0
- package/dist/src/index.js +425 -0
- package/dist/src/tools.d.ts +1 -0
- package/dist/src/tools.js +16 -0
- package/package.json +1 -1
- package/src/index.ts +918 -4
- package/src/tools.ts +12 -0
- package/tsconfig.json +3 -2
- package/src/admin.ts +0 -20
- package/src/cronjobs.ts +0 -9
- package/src/general.ts +0 -245
- package/src/payment-system.ts +0 -61
package/src/tools.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function safeStringify(obj: any): string {
|
|
2
|
+
const seen = new WeakSet();
|
|
3
|
+
return JSON.stringify(obj, (key, val) => {
|
|
4
|
+
if (val != null && typeof val === "object") {
|
|
5
|
+
if (seen.has(val)) {
|
|
6
|
+
return '[Circular]';
|
|
7
|
+
}
|
|
8
|
+
seen.add(val);
|
|
9
|
+
}
|
|
10
|
+
return val;
|
|
11
|
+
});
|
|
12
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
"declaration": true,
|
|
6
6
|
"outDir": "./dist",
|
|
7
7
|
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
8
|
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"esModuleInterop": true
|
|
11
12
|
},
|
|
12
13
|
"include": ["src"]
|
|
13
14
|
}
|
package/src/admin.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export enum Privilege {
|
|
2
|
-
NONE = 0,
|
|
3
|
-
READ = 1,
|
|
4
|
-
WRITE = 2
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type PrivilegeTable = {// ESTES PRIVILÉGIOS JÁ SÃO CONVERTIDOS NO `server.ts` para que quando é externo tenha que ter maior nível de acesso...
|
|
8
|
-
users: Privilege;
|
|
9
|
-
products: Privilege;
|
|
10
|
-
courses: Privilege;
|
|
11
|
-
consultancies: Privilege;
|
|
12
|
-
bundles: Privilege;
|
|
13
|
-
logs: Privilege;
|
|
14
|
-
support: Privilege;
|
|
15
|
-
leads: Privilege;
|
|
16
|
-
paymentSystem: Privilege;
|
|
17
|
-
adminMaster: Privilege;
|
|
18
|
-
activityTrakking: Privilege;
|
|
19
|
-
financial: Privilege;
|
|
20
|
-
}
|
package/src/cronjobs.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type CronJob = { //Também definido em ~/server/src/cronjobs.ts
|
|
2
|
-
startAt: Date|null //null se não está rodando
|
|
3
|
-
latestRunErrorCount: number //zero se não teve erro
|
|
4
|
-
latestCompletedAt: Date|null
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type CronjobsStatuses = {
|
|
8
|
-
purchasesStatusUpdate: CronJob
|
|
9
|
-
}
|
package/src/general.ts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { PrivilegeTable } from "./admin";
|
|
2
|
-
import { PG_PurchaseLicenseStatus, PG_PurchasePaymentStatus, PG_PurchaseType } from "./payment-system";
|
|
3
|
-
|
|
4
|
-
export enum BundleType {
|
|
5
|
-
BUNDLE = 0,
|
|
6
|
-
SYMBOLIC_PRODUCT = 1,
|
|
7
|
-
SYMBOLIC_COURSE = 2,
|
|
8
|
-
SYMBOLIC_CONSULTANCY = 3,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type Product = {
|
|
12
|
-
id: number;
|
|
13
|
-
title: string;
|
|
14
|
-
short: string;
|
|
15
|
-
resume: string;
|
|
16
|
-
video: string;
|
|
17
|
-
imgUrls: string | null;
|
|
18
|
-
logo: string;
|
|
19
|
-
themeImage: string;
|
|
20
|
-
themeColor: string;
|
|
21
|
-
themeVideo: string;
|
|
22
|
-
url: string;
|
|
23
|
-
type: number;
|
|
24
|
-
period_test: number;
|
|
25
|
-
created: string;
|
|
26
|
-
deletedAt?: string | null;
|
|
27
|
-
Levels?: ProductLevel[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type ProductLevel = {
|
|
31
|
-
id: number;
|
|
32
|
-
productID: number;
|
|
33
|
-
level: number;
|
|
34
|
-
short: string;
|
|
35
|
-
Product?: Product;
|
|
36
|
-
store_bundles_levels?: {
|
|
37
|
-
id: number,
|
|
38
|
-
bundleID: number,
|
|
39
|
-
levelID: number,
|
|
40
|
-
quantity: number,
|
|
41
|
-
Bundle?: Bundle
|
|
42
|
-
}[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type Course = {
|
|
46
|
-
id: number;
|
|
47
|
-
type: number;
|
|
48
|
-
name: string;
|
|
49
|
-
short: string;
|
|
50
|
-
resume: string;
|
|
51
|
-
img_landscape: string;
|
|
52
|
-
img_square: string;
|
|
53
|
-
workload: number;
|
|
54
|
-
langID: number;
|
|
55
|
-
num_classes?: number;
|
|
56
|
-
seats: number;
|
|
57
|
-
url?: string;
|
|
58
|
-
dates: string;
|
|
59
|
-
local: string;
|
|
60
|
-
local_url: string;
|
|
61
|
-
date_mat_s?: string;
|
|
62
|
-
date_mat_e?: string;
|
|
63
|
-
date_ends?: string;
|
|
64
|
-
email_enrollment?: string;
|
|
65
|
-
email_before?: string;
|
|
66
|
-
email_after?: string;
|
|
67
|
-
date_c: string;
|
|
68
|
-
date_r?: string | null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type Consultancy = {
|
|
72
|
-
id: number;
|
|
73
|
-
teacherID: number;
|
|
74
|
-
type: number;
|
|
75
|
-
name: string;
|
|
76
|
-
short: string;
|
|
77
|
-
resume: string;
|
|
78
|
-
img_landscape: string;
|
|
79
|
-
img_square: string;
|
|
80
|
-
workload: number;
|
|
81
|
-
langID: number;
|
|
82
|
-
url?: string;
|
|
83
|
-
datetime: string;
|
|
84
|
-
date_mat_s?: string;
|
|
85
|
-
date_mat_e?: string;
|
|
86
|
-
date_ends?: string;
|
|
87
|
-
email_enrollment: string;
|
|
88
|
-
email_before: string;
|
|
89
|
-
email_after: string;
|
|
90
|
-
date_c: string;
|
|
91
|
-
date_r?: string | null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type Bundle = {
|
|
95
|
-
id: number;
|
|
96
|
-
type: BundleType;
|
|
97
|
-
title?: string;
|
|
98
|
-
short?: string;
|
|
99
|
-
resume?: string;
|
|
100
|
-
img: string;
|
|
101
|
-
themeImage: string;
|
|
102
|
-
themeColor: string;
|
|
103
|
-
shareLimit: number;
|
|
104
|
-
created: string;
|
|
105
|
-
active: boolean;
|
|
106
|
-
showInSite: boolean;
|
|
107
|
-
defaultMetaArray: string;
|
|
108
|
-
deletedAt?: string | null;
|
|
109
|
-
Levels?: {
|
|
110
|
-
id: number;
|
|
111
|
-
bundleID: number;
|
|
112
|
-
levelID: number;
|
|
113
|
-
quantity: number;
|
|
114
|
-
Level: ProductLevel;
|
|
115
|
-
}[];
|
|
116
|
-
Courses?: {
|
|
117
|
-
id: number;
|
|
118
|
-
bundleID: number;
|
|
119
|
-
courseID: number;
|
|
120
|
-
quantity: number;
|
|
121
|
-
Course: Course;
|
|
122
|
-
}[];
|
|
123
|
-
Consultancies?: {
|
|
124
|
-
id: number;
|
|
125
|
-
bundleID: number;
|
|
126
|
-
consultancyID: number;
|
|
127
|
-
quantity: number;
|
|
128
|
-
Consultancy: Consultancy;
|
|
129
|
-
}[];
|
|
130
|
-
store_bundles_paymethod: PaymentMethod[];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export type PaymentMethod = {
|
|
134
|
-
id: number;
|
|
135
|
-
bundleID: number;
|
|
136
|
-
price: number;
|
|
137
|
-
fromprice: number;
|
|
138
|
-
period_renew: number;
|
|
139
|
-
period_grace: number;
|
|
140
|
-
gatewayHash: string;
|
|
141
|
-
allowBoleto: boolean;
|
|
142
|
-
gatewayID: number;
|
|
143
|
-
Bundle?: Bundle;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export type Purchase = {
|
|
147
|
-
paghash: string;
|
|
148
|
-
id: number;
|
|
149
|
-
price: number;
|
|
150
|
-
licenseStatus: PG_PurchaseLicenseStatus;
|
|
151
|
-
paymentStatus: PG_PurchasePaymentStatus,
|
|
152
|
-
type_step: PG_PurchaseType,
|
|
153
|
-
PaymentMethod: PaymentMethod;
|
|
154
|
-
Wallet?: Wallet;
|
|
155
|
-
walletID: number;
|
|
156
|
-
createdAt: string;
|
|
157
|
-
paymentDueAt: string | null;
|
|
158
|
-
owner: string;
|
|
159
|
-
invoiceUrl?: string;
|
|
160
|
-
nfUrl?: string;
|
|
161
|
-
isAdmin?: boolean;
|
|
162
|
-
meta_data?: Record<string, any>;
|
|
163
|
-
PurchaseShares?: PurchaseShare[];
|
|
164
|
-
Levels?: {
|
|
165
|
-
Level: ProductLevel
|
|
166
|
-
quant: number
|
|
167
|
-
}[]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export type Wallet = {
|
|
171
|
-
id: number;
|
|
172
|
-
userID: number;
|
|
173
|
-
balance?: number;
|
|
174
|
-
Purchases?: Purchase[];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export type PurchaseShare = {
|
|
178
|
-
id: number;
|
|
179
|
-
purchaseID: number;
|
|
180
|
-
userID: number;
|
|
181
|
-
Purchase: Purchase;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export type LocalUser = {
|
|
185
|
-
id: number,
|
|
186
|
-
fullname: string,
|
|
187
|
-
email: string,
|
|
188
|
-
lang: number,
|
|
189
|
-
avatar: string,
|
|
190
|
-
end_city?: number,
|
|
191
|
-
end_comp?: string,
|
|
192
|
-
end_country: number,
|
|
193
|
-
end_district?: string,
|
|
194
|
-
end_n?: string,
|
|
195
|
-
end_state?: number,
|
|
196
|
-
end_street?: string,
|
|
197
|
-
end_zip?: string,
|
|
198
|
-
|
|
199
|
-
email_verif: boolean,
|
|
200
|
-
fiscal_verif: boolean,
|
|
201
|
-
terms: boolean,
|
|
202
|
-
|
|
203
|
-
cpf?: string,
|
|
204
|
-
newslatter?: boolean,
|
|
205
|
-
allow_purchase?: boolean,
|
|
206
|
-
allow_license?: boolean,
|
|
207
|
-
date_c?: Date | string,
|
|
208
|
-
date_r?: Date | string | null,
|
|
209
|
-
|
|
210
|
-
Wallets?: Wallet[];
|
|
211
|
-
PurchasesShares?: PurchaseShare[];
|
|
212
|
-
|
|
213
|
-
Sys_admUser_config?: AdminUserConfig,
|
|
214
|
-
Sys_adminUser?: PrivilegeTable
|
|
215
|
-
}
|
|
216
|
-
export type AdminUserConfig = {
|
|
217
|
-
campaigns_blacklist:string,
|
|
218
|
-
deletedAt: Date | null,
|
|
219
|
-
userID: number
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export type availableSoftware_auxType = {
|
|
223
|
-
Level: ProductLevel,
|
|
224
|
-
quantity: number,//acessos simultâneos permitidos por esta COMPRA
|
|
225
|
-
purchaseId:number|null, //null when free
|
|
226
|
-
type: 'free'|'own'|'shared'
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Tipos para logs do sistema
|
|
230
|
-
export type LogEntry = {
|
|
231
|
-
appId: string;
|
|
232
|
-
logCode: number;
|
|
233
|
-
content: string;
|
|
234
|
-
timestamp?: string;
|
|
235
|
-
metadata?: {
|
|
236
|
-
requestId: string;
|
|
237
|
-
endpoint: string;
|
|
238
|
-
method: string;
|
|
239
|
-
userId?: number;
|
|
240
|
-
ip?: string;
|
|
241
|
-
browser?: string;
|
|
242
|
-
system?: string;
|
|
243
|
-
referer?: string;
|
|
244
|
-
};
|
|
245
|
-
}
|
package/src/payment-system.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export type PG_Customer = {
|
|
2
|
-
id: string,
|
|
3
|
-
email: string,
|
|
4
|
-
name: string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum PG_PurchaseLicenseStatus {
|
|
8
|
-
|
|
9
|
-
// Pagamentos ou Assinaturas
|
|
10
|
-
UNKNOWN = 0,//Nunca será atualizado automaticamente!!
|
|
11
|
-
OPEN = 3, //ABERTA - Aguardando pagamento
|
|
12
|
-
|
|
13
|
-
// Pagamentos
|
|
14
|
-
EXPIRED = 1, //VENCEU - Era PAGAMENTO, e acabou prazo pra uso acabou
|
|
15
|
-
PAID = 5, //PAGA - Pagamento realizado com sucesso - é pagamento único
|
|
16
|
-
|
|
17
|
-
// Assinaturas
|
|
18
|
-
ACTIVE = 6, //ATIVO - Assinatura ativa e em dia
|
|
19
|
-
RECYCLING = 4, //RETENTANDO - Tentativa de renovação automática falhou, mas ainda está no prazo para pagar manualmente
|
|
20
|
-
CANCELED = 2, //CANCELADA - Foi cancelada pelo usuário ou admin
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const PG_PurchaseLicenseStatus_GroupActive = [//quais são os Status que são considerados ATIVOS (aptos a usar a licença)
|
|
24
|
-
PG_PurchaseLicenseStatus.PAID,
|
|
25
|
-
PG_PurchaseLicenseStatus.ACTIVE,
|
|
26
|
-
PG_PurchaseLicenseStatus.RECYCLING,
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
export enum PG_PurchasePaymentStatus {
|
|
30
|
-
UNKNOWN = 0,//pendent or unknown
|
|
31
|
-
ACTIVE = 1,
|
|
32
|
-
CANCELED = 2,
|
|
33
|
-
REFUNDED = 3,
|
|
34
|
-
REMOVED = 4,// REMOVIDO DO GATEWAY - Não há mais registro do pagamento no gateway
|
|
35
|
-
PENDING = 5, //não paga ainda
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export enum PG_PurchaseType {
|
|
39
|
-
SESSION = 0, //o registro se trata de uma sessão de compra (ex: intenção de compra preparada para redirecionar o usuário ao gateway. Ainda não é um pagamento nem uma assinatura ativa)
|
|
40
|
-
STANDARD = 1, //Pagamento único
|
|
41
|
-
RECURRENT = 2, //Assinatura recorrente
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type PG_Purchase = {
|
|
45
|
-
id: string,
|
|
46
|
-
amount: number,
|
|
47
|
-
recurrent: boolean,
|
|
48
|
-
type: PG_PurchaseType,
|
|
49
|
-
// licenseStatus: PG_PurchaseLicenseStatus,
|
|
50
|
-
paymentStatus: PG_PurchasePaymentStatus,
|
|
51
|
-
url: string | null,
|
|
52
|
-
dueTime: Date|null
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export enum PG_RecurrenceType {
|
|
56
|
-
NONE = 0,
|
|
57
|
-
DAILY = 1,
|
|
58
|
-
WEEKLY = 2,
|
|
59
|
-
MONTHLY = 3,
|
|
60
|
-
YEARLY = 4
|
|
61
|
-
}
|