ztechno_core 0.0.105 → 0.0.108

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.
Files changed (63) hide show
  1. package/lib/core/crypto_service.d.ts +23 -0
  2. package/lib/core/crypto_service.js +100 -0
  3. package/lib/core/engine_base.d.ts +11 -0
  4. package/lib/core/engine_base.js +9 -0
  5. package/lib/core/index.d.ts +14 -0
  6. package/lib/core/index.js +101 -0
  7. package/lib/core/mail_service.d.ts +85 -0
  8. package/lib/core/mail_service.js +156 -0
  9. package/lib/core/orm/mail_blacklist_orm.d.ts +21 -0
  10. package/lib/core/orm/mail_blacklist_orm.js +79 -0
  11. package/lib/core/orm/orm.d.ts +27 -0
  12. package/lib/core/orm/orm.js +67 -0
  13. package/lib/core/sql_service.d.ts +195 -0
  14. package/lib/core/sql_service.js +333 -0
  15. package/lib/core/translate_service.d.ts +48 -0
  16. package/lib/core/translate_service.js +913 -0
  17. package/lib/core/types/crypto_types.d.ts +4 -0
  18. package/lib/core/types/crypto_types.js +2 -0
  19. package/lib/core/types/mail_types.d.ts +95 -0
  20. package/lib/core/types/mail_types.js +2 -0
  21. package/lib/core/types/site_config.d.ts +46 -0
  22. package/lib/core/types/site_config.js +2 -0
  23. package/lib/core/types/translate_types.d.ts +69 -0
  24. package/lib/core/types/translate_types.js +46 -0
  25. package/lib/core/types/user_types.d.ts +41 -0
  26. package/lib/core/types/user_types.js +2 -0
  27. package/lib/core/user_service.d.ts +87 -0
  28. package/lib/core/user_service.js +216 -0
  29. package/lib/express/index.d.ts +1 -0
  30. package/lib/express/index.js +18 -0
  31. package/lib/index.d.ts +17 -8
  32. package/lib/index.js +60 -16
  33. package/lib/mollie/index.d.ts +5 -0
  34. package/lib/mollie/index.js +62 -0
  35. package/lib/mollie/orm/customers_orm.d.ts +16 -0
  36. package/lib/mollie/orm/customers_orm.js +115 -0
  37. package/lib/mollie/orm/invoice_items_orm.d.ts +9 -0
  38. package/lib/mollie/orm/invoice_items_orm.js +71 -0
  39. package/lib/mollie/orm/invoice_payments_orm.d.ts +10 -0
  40. package/lib/mollie/orm/invoice_payments_orm.js +70 -0
  41. package/lib/mollie/orm/invoices_orm.d.ts +40 -0
  42. package/lib/mollie/orm/invoices_orm.js +172 -0
  43. package/lib/mollie/orm/subscription_items_orm.d.ts +9 -0
  44. package/lib/mollie/orm/subscription_items_orm.js +45 -0
  45. package/lib/mollie/orm/subscriptions_orm.d.ts +17 -0
  46. package/lib/mollie/orm/subscriptions_orm.js +122 -0
  47. package/lib/mollie/services/customer_service.d.ts +14 -0
  48. package/lib/mollie/services/customer_service.js +53 -0
  49. package/lib/mollie/services/invoice_service.d.ts +102 -0
  50. package/lib/mollie/services/invoice_service.js +866 -0
  51. package/lib/mollie/services/mollie_service.d.ts +42 -0
  52. package/lib/mollie/services/mollie_service.js +370 -0
  53. package/lib/mollie/services/subscription_service.d.ts +32 -0
  54. package/lib/mollie/services/subscription_service.js +134 -0
  55. package/lib/mollie/types/internal_types.d.ts +19 -0
  56. package/lib/mollie/types/internal_types.js +2 -0
  57. package/lib/mollie/types/mollie_types.d.ts +187 -0
  58. package/lib/mollie/types/mollie_types.js +3 -0
  59. package/lib/mollie/util/subscription_utils.d.ts +8 -0
  60. package/lib/mollie/util/subscription_utils.js +37 -0
  61. package/lib/schema/MySQLSchemaExtractor.d.ts +1 -1
  62. package/lib/schema/MySQLSchemaImporter.d.ts +1 -1
  63. package/package.json +3 -1
@@ -0,0 +1,187 @@
1
+ export type ZCustomer = {
2
+ id?: number;
3
+ mollie_customer_id?: string;
4
+ email: string;
5
+ name: string;
6
+ company?: string | null;
7
+ phone?: string | null;
8
+ /** VAT number for B2B invoices (Dutch law requirement) */
9
+ btw_nummer?: string | null;
10
+ address_line1?: string | null;
11
+ address_line2?: string | null;
12
+ postal_code?: string | null;
13
+ city?: string | null;
14
+ country?: string | null;
15
+ locale?: string | null;
16
+ metadata?: any;
17
+ created_at?: string | Date;
18
+ updated_at?: string | Date;
19
+ };
20
+ export type ZInvoiceItemType = 'service' | 'subsidy';
21
+ export type ZInvoiceItem = {
22
+ id?: number;
23
+ invoice_id: number;
24
+ item_type?: ZInvoiceItemType;
25
+ description: string;
26
+ quantity: number;
27
+ unit_price: number;
28
+ vat_rate: number;
29
+ total_ex_vat: number;
30
+ total_inc_vat: number;
31
+ sort_order?: number;
32
+ };
33
+ export type CreateInvoiceInput = {
34
+ customer_id: number;
35
+ description?: string;
36
+ currency?: string;
37
+ payment_terms?: string;
38
+ due_date?: string;
39
+ items: (Pick<ZInvoiceItem, 'description' | 'quantity' | 'unit_price' | 'vat_rate'> & {
40
+ sort_order?: number;
41
+ item_type?: ZInvoiceItemType;
42
+ })[];
43
+ metadata?: any;
44
+ };
45
+ export type CreateInvoiceOverrides = {
46
+ status?: ZInvoiceStatus;
47
+ paid_at?: string | null;
48
+ amount_paid?: number | null;
49
+ subscription_id?: number | null;
50
+ subscription_period_start?: string | null;
51
+ subscription_period_end?: string | null;
52
+ issuePayToken?: boolean;
53
+ mollie_payment_id?: string | null;
54
+ checkout_url?: string | null;
55
+ };
56
+ export type ZInvoiceStatus = 'draft' | 'pending' | 'paid' | 'failed' | 'canceled' | 'expired' | 'refunded';
57
+ export type ZInvoice = {
58
+ id?: number;
59
+ invoice_number: string;
60
+ customer_id: number;
61
+ subscription_id?: number | null;
62
+ subscription_period_start?: string | null;
63
+ subscription_period_end?: string | null;
64
+ mollie_customer_id?: string | null;
65
+ mollie_payment_id?: string | null;
66
+ pay_token_hash?: string | null;
67
+ pay_token_expires_at?: string | null;
68
+ pay_token_finalized_at?: string | null;
69
+ status: ZInvoiceStatus;
70
+ amount_due: number;
71
+ amount_paid: number;
72
+ currency: string;
73
+ description?: string | null;
74
+ payment_terms?: string | null;
75
+ due_date?: string | null;
76
+ issued_at?: string | null;
77
+ paid_at?: string | null;
78
+ checkout_url?: string | null;
79
+ metadata?: any;
80
+ created_at?: string | Date;
81
+ updated_at?: string | Date;
82
+ };
83
+ export type ZInvoicePaymentStatus =
84
+ | 'open'
85
+ | 'pending'
86
+ | 'authorized'
87
+ | 'paid'
88
+ | 'canceled'
89
+ | 'expired'
90
+ | 'failed'
91
+ | 'refunded';
92
+ export type ZInvoicePayment = {
93
+ id?: number;
94
+ invoice_id: number;
95
+ mollie_payment_id: string;
96
+ status: ZInvoicePaymentStatus;
97
+ sequence_type?: 'oneoff' | 'first' | 'recurring' | null;
98
+ mollie_subscription_id?: string | null;
99
+ method?: string | null;
100
+ amount: number;
101
+ currency: string;
102
+ checkout_url?: string | null;
103
+ paid_at?: string | null;
104
+ expires_at?: string | null;
105
+ mandate_id?: string | null;
106
+ created_at?: string | Date;
107
+ updated_at?: string | Date;
108
+ };
109
+ export type ZSubscriptionItem = {
110
+ id?: number;
111
+ subscription_id: number;
112
+ description: string;
113
+ quantity: number;
114
+ unit_price: number;
115
+ vat_rate: number;
116
+ total_ex_vat: number;
117
+ total_inc_vat: number;
118
+ sort_order?: number;
119
+ };
120
+ export type CreateSubscriptionInput = {
121
+ customer_id: number;
122
+ interval: string;
123
+ description?: string;
124
+ currency?: string;
125
+ items: (Pick<ZSubscriptionItem, 'description' | 'quantity' | 'unit_price' | 'vat_rate'> & {
126
+ sort_order?: number;
127
+ })[];
128
+ metadata?: any;
129
+ };
130
+ export type ZSubscriptionStatus = 'setup_pending' | 'pending' | 'active' | 'canceled' | 'suspended' | 'completed';
131
+ export type ZSubscription = {
132
+ id?: number;
133
+ customer_id: number;
134
+ mollie_customer_id?: string | null;
135
+ mollie_subscription_id?: string | null;
136
+ status: ZSubscriptionStatus;
137
+ interval: string;
138
+ description?: string | null;
139
+ amount: number;
140
+ currency: string;
141
+ mandate_id?: string | null;
142
+ next_payment_date?: string | null;
143
+ canceled_at?: string | null;
144
+ metadata?: any;
145
+ created_at?: string | Date;
146
+ updated_at?: string | Date;
147
+ };
148
+ export type ZIssuedPayToken = {
149
+ token: string;
150
+ expiresAt: string;
151
+ payUrl: string;
152
+ };
153
+ export type ZPayResolveResult =
154
+ | {
155
+ action: 'redirect';
156
+ checkoutUrl: string;
157
+ invoice: ZInvoice;
158
+ }
159
+ | {
160
+ action: 'paid';
161
+ invoice: ZInvoice;
162
+ };
163
+ export type RecoveryStats = {
164
+ dryRun: boolean;
165
+ startedAt: string;
166
+ durationMs: number;
167
+ customers: {
168
+ recovered: number;
169
+ skipped: number;
170
+ };
171
+ subscriptions: {
172
+ recovered: number;
173
+ };
174
+ invoices: {
175
+ recovered: number;
176
+ skippedExisting: number;
177
+ };
178
+ payments: {
179
+ recovered: number;
180
+ skippedNoCustomer: number;
181
+ };
182
+ errors: {
183
+ entity: string;
184
+ mollieId: string;
185
+ error: string;
186
+ }[];
187
+ };
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ // ============================== // Customers
3
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,8 @@
1
+ export type SubscriptionIntervalUnit = 'day' | 'week' | 'month';
2
+ export type ParsedSubscriptionInterval = {
3
+ count: number;
4
+ unit: SubscriptionIntervalUnit;
5
+ };
6
+ export declare function parseSubscriptionInterval(input: string): ParsedSubscriptionInterval;
7
+ export declare function addSubscriptionInterval(date: Date, interval: ParsedSubscriptionInterval): Date;
8
+ export declare function formatDateOnly(date: Date): string;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.formatDateOnly = exports.addSubscriptionInterval = exports.parseSubscriptionInterval = void 0;
4
+ const pad = (value) => (value < 10 ? `0${value}` : String(value));
5
+ function parseSubscriptionInterval(input) {
6
+ const normalized = String(input || '')
7
+ .trim()
8
+ .toLowerCase();
9
+ const match = normalized.match(/^(\d+)\s*(day|days|week|weeks|month|months)$/);
10
+ if (!match) {
11
+ throw new Error(`Invalid interval "${input}". Expected "N days", "N weeks" or "N months".`);
12
+ }
13
+ const count = Number(match[1]);
14
+ if (!Number.isFinite(count) || count <= 0) {
15
+ throw new Error(`Invalid interval count "${match[1]}".`);
16
+ }
17
+ const unitRaw = match[2];
18
+ const unit = unitRaw.startsWith('day') ? 'day' : unitRaw.startsWith('week') ? 'week' : 'month';
19
+ return { count, unit };
20
+ }
21
+ exports.parseSubscriptionInterval = parseSubscriptionInterval;
22
+ function addSubscriptionInterval(date, interval) {
23
+ const out = new Date(date.getTime());
24
+ if (interval.unit === 'day') {
25
+ out.setUTCDate(out.getUTCDate() + interval.count);
26
+ } else if (interval.unit === 'week') {
27
+ out.setUTCDate(out.getUTCDate() + interval.count * 7);
28
+ } else {
29
+ out.setUTCMonth(out.getUTCMonth() + interval.count);
30
+ }
31
+ return out;
32
+ }
33
+ exports.addSubscriptionInterval = addSubscriptionInterval;
34
+ function formatDateOnly(date) {
35
+ return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
36
+ }
37
+ exports.formatDateOnly = formatDateOnly;
@@ -1,4 +1,4 @@
1
- import { ZSQLService } from '../sql_service';
1
+ import { ZSQLService } from '../core/sql_service';
2
2
  import type {
3
3
  DatabaseSchema,
4
4
  EventDefinition,
@@ -1,4 +1,4 @@
1
- import { ZSQLService } from '../sql_service';
1
+ import { ZSQLService } from '../core/sql_service';
2
2
  import type { DatabaseSchema, SchemaImportOptions, SchemaImportResult } from './types';
3
3
  /**
4
4
  * MySQL Schema Importer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.105",
3
+ "version": "0.0.108",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -38,11 +38,13 @@
38
38
  "typescript": "^4.9.3"
39
39
  },
40
40
  "dependencies": {
41
+ "@mollie/api-client": "^4.4.0",
41
42
  "@types/express": "^5.0.0",
42
43
  "dom-parser": "^1.1.5",
43
44
  "dotenv": "^17.3.1",
44
45
  "mysql": "^2.18.1",
45
46
  "nodemailer": "^6.8.0",
47
+ "pdfkit": "^0.17.2",
46
48
  "translate": "^1.4.1"
47
49
  }
48
50
  }