@qelos/global-types 4.1.1 → 4.2.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/ai-models.ts +301 -0
- package/dist/ai-models.d.ts +32 -0
- package/dist/ai-models.js +279 -0
- package/dist/ai-models.js.map +1 -0
- package/dist/app-configuration-metadata.d.ts +18 -0
- package/dist/app-configuration-metadata.js +3 -0
- package/dist/app-configuration-metadata.js.map +1 -0
- package/dist/auth-configuration-metadata.d.ts +41 -0
- package/dist/auth-configuration-metadata.js +3 -0
- package/dist/auth-configuration-metadata.js.map +1 -0
- package/dist/blueprint.d.ts +74 -0
- package/dist/blueprint.js +33 -0
- package/dist/blueprint.js.map +1 -0
- package/dist/event-subscriber.d.ts +6 -0
- package/dist/event-subscriber.js +3 -0
- package/dist/event-subscriber.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/injectable.d.ts +6 -0
- package/dist/injectable.js +3 -0
- package/dist/injectable.js.map +1 -0
- package/dist/integration-source-status.d.ts +20 -0
- package/dist/integration-source-status.js +21 -0
- package/dist/integration-source-status.js.map +1 -0
- package/dist/integration-sources.d.ts +351 -0
- package/dist/integration-sources.js +141 -0
- package/dist/integration-sources.js.map +1 -0
- package/dist/integration-targets.d.ts +58 -0
- package/dist/integration-targets.js +3 -0
- package/dist/integration-targets.js.map +1 -0
- package/dist/integration.d.ts +39 -0
- package/dist/integration.js +12 -0
- package/dist/integration.js.map +1 -0
- package/dist/mcp-configuration-metadata.d.ts +19 -0
- package/dist/mcp-configuration-metadata.js +14 -0
- package/dist/mcp-configuration-metadata.js.map +1 -0
- package/dist/mcp-endpoint.d.ts +5 -0
- package/dist/mcp-endpoint.js +13 -0
- package/dist/mcp-endpoint.js.map +1 -0
- package/dist/micro-frontend.d.ts +43 -0
- package/dist/micro-frontend.js +3 -0
- package/dist/micro-frontend.js.map +1 -0
- package/dist/navbar-group.d.ts +7 -0
- package/dist/navbar-group.js +3 -0
- package/dist/navbar-group.js.map +1 -0
- package/dist/no-code-components.d.ts +34 -0
- package/dist/no-code-components.js +3 -0
- package/dist/no-code-components.js.map +1 -0
- package/dist/payment-event-resolution.d.ts +31 -0
- package/dist/payment-event-resolution.js +302 -0
- package/dist/payment-event-resolution.js.map +1 -0
- package/dist/payments.d.ts +165 -0
- package/dist/payments.js +3 -0
- package/dist/payments.js.map +1 -0
- package/dist/plugin-crud.d.ts +11 -0
- package/dist/plugin-crud.js +3 -0
- package/dist/plugin-crud.js.map +1 -0
- package/dist/plugin.d.ts +30 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/dist/qelos-integrator.d.ts +112 -0
- package/dist/qelos-integrator.js +14 -0
- package/dist/qelos-integrator.js.map +1 -0
- package/dist/query-filters.d.ts +7 -0
- package/dist/query-filters.js +3 -0
- package/dist/query-filters.js.map +1 -0
- package/dist/screen-requirement.d.ts +22 -0
- package/dist/screen-requirement.js +3 -0
- package/dist/screen-requirement.js.map +1 -0
- package/dist/workspace-configuration-metadata.d.ts +17 -0
- package/dist/workspace-configuration-metadata.js +3 -0
- package/dist/workspace-configuration-metadata.js.map +1 -0
- package/index.ts +5 -0
- package/integration-source-status.ts +38 -0
- package/integration-sources.ts +11 -0
- package/integration.ts +1 -0
- package/mcp-configuration-metadata.ts +33 -0
- package/mcp-endpoint.ts +12 -0
- package/package.json +11 -5
- package/payment-event-resolution.ts +388 -0
- package/payments.ts +34 -0
- package/tsconfig.json +17 -0
- package/LICENSE +0 -20
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYMENTS_DOCS_BASE_URL = void 0;
|
|
4
|
+
exports.resolvePaymentEventDocsUrl = resolvePaymentEventDocsUrl;
|
|
5
|
+
exports.sanitizeProviderErrorBody = sanitizeProviderErrorBody;
|
|
6
|
+
exports.extractSumitProviderError = extractSumitProviderError;
|
|
7
|
+
exports.resolvePaymentProviderPublicContext = resolvePaymentProviderPublicContext;
|
|
8
|
+
exports.appendPaymentProviderContext = appendPaymentProviderContext;
|
|
9
|
+
exports.buildPaymentAdminSuggestions = buildPaymentAdminSuggestions;
|
|
10
|
+
exports.buildPaymentEventDescription = buildPaymentEventDescription;
|
|
11
|
+
exports.PAYMENTS_DOCS_BASE_URL = 'https://docs.qelos.io/payments';
|
|
12
|
+
const TROUBLESHOOTING_ERROR_CODES = new Set([
|
|
13
|
+
'PAYMENTS_NOT_CONFIGURED',
|
|
14
|
+
'ACTIVE_SUBSCRIPTION_EXISTS',
|
|
15
|
+
'DYNAMIC_AMOUNT_NOT_SET',
|
|
16
|
+
'DYNAMIC_PLAN_REQUIRES_SUBSCRIPTION',
|
|
17
|
+
'DYNAMIC_PLAN_UNSUPPORTED_PROVIDER',
|
|
18
|
+
'MISSING_REDIRECT_URLS',
|
|
19
|
+
'INVALID_CHECKOUT_AMOUNT',
|
|
20
|
+
'INVALID_SUMIT_COMPANY_ID',
|
|
21
|
+
'MISSING_SUMIT_CREDENTIALS',
|
|
22
|
+
'UNSUPPORTED_SUMIT_CURRENCY',
|
|
23
|
+
'INTEGRATION_SOURCE_NOT_FOUND',
|
|
24
|
+
'MISSING_EXTERNAL_PRICE_ID',
|
|
25
|
+
'PLAN_NOT_ACTIVE',
|
|
26
|
+
'SUBSCRIPTION_NOT_PENDING',
|
|
27
|
+
'INVALID_SIGNATURE',
|
|
28
|
+
'WEBHOOK_SECRET_NOT_CONFIGURED',
|
|
29
|
+
'TENANT_NOT_FOUND',
|
|
30
|
+
]);
|
|
31
|
+
function troubleshootingCodeAnchor(code) {
|
|
32
|
+
return code.toLowerCase().replace(/_/g, '-');
|
|
33
|
+
}
|
|
34
|
+
function resolveProviderEventDocsUrl(providerKind, eventName) {
|
|
35
|
+
const provider = providerKind.toLowerCase();
|
|
36
|
+
if (eventName === 'payment-method-save-failed') {
|
|
37
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#failed-credit-card-capture-payment-method-save-failed`;
|
|
38
|
+
}
|
|
39
|
+
if (eventName === 'payment-failed' || eventName === 'webhook-processing-failed') {
|
|
40
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#${provider}-troubleshooting`;
|
|
41
|
+
}
|
|
42
|
+
if (eventName === 'checkout-failed' || eventName === 'provider-call-failed') {
|
|
43
|
+
switch (provider) {
|
|
44
|
+
case 'sumit':
|
|
45
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#checkout-initiation-failure-checkout-failed-or-provider-call-failed`;
|
|
46
|
+
case 'paddle':
|
|
47
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#checkout-validation-failure-checkout-failed`;
|
|
48
|
+
case 'paypal':
|
|
49
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#checkout-and-subscription-setup-failure-checkout-failed-or-provider-call-failed`;
|
|
50
|
+
case 'dodopayments':
|
|
51
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#checkout-failure-checkout-failed-or-provider-call-failed`;
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
switch (provider) {
|
|
57
|
+
case 'sumit':
|
|
58
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#sumit-troubleshooting`;
|
|
59
|
+
case 'paddle':
|
|
60
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#paddle-troubleshooting`;
|
|
61
|
+
case 'paypal':
|
|
62
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#paypal-troubleshooting`;
|
|
63
|
+
case 'dodopayments':
|
|
64
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/events#dodopayments-troubleshooting`;
|
|
65
|
+
default:
|
|
66
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/troubleshooting`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function resolvePaymentEventDocsUrl(context) {
|
|
70
|
+
const code = context.code?.toUpperCase();
|
|
71
|
+
if (code && TROUBLESHOOTING_ERROR_CODES.has(code)) {
|
|
72
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/troubleshooting#${troubleshootingCodeAnchor(code)}`;
|
|
73
|
+
}
|
|
74
|
+
if (context.providerKind) {
|
|
75
|
+
return resolveProviderEventDocsUrl(context.providerKind, context.eventName);
|
|
76
|
+
}
|
|
77
|
+
return `${exports.PAYMENTS_DOCS_BASE_URL}/troubleshooting`;
|
|
78
|
+
}
|
|
79
|
+
function pushUnique(suggestions, suggestion) {
|
|
80
|
+
if (suggestions.some((s) => s.summary === suggestion.summary)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
suggestions.push(suggestion);
|
|
84
|
+
}
|
|
85
|
+
function sumitCredentialsSuggestions(suggestions, message, providerError) {
|
|
86
|
+
const combined = [
|
|
87
|
+
message,
|
|
88
|
+
providerError?.UserErrorMessage,
|
|
89
|
+
providerError?.TechnicalErrorDetails,
|
|
90
|
+
]
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.join(' ')
|
|
93
|
+
.toLowerCase();
|
|
94
|
+
if (combined.includes('credential')
|
|
95
|
+
|| combined.includes('apikey')
|
|
96
|
+
|| combined.includes('api key')
|
|
97
|
+
|| combined.includes('companyid')
|
|
98
|
+
|| combined.includes('company id')
|
|
99
|
+
|| combined.includes('unauthorized')
|
|
100
|
+
|| combined.includes('authentication')) {
|
|
101
|
+
pushUnique(suggestions, {
|
|
102
|
+
summary: 'Verify Sumit API credentials',
|
|
103
|
+
action: 'Open Admin → Integrations → Sumit, confirm Company ID matches https://app.sumit.co.il/developers/keys/ and re-save a freshly generated API key.',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function sanitizeProviderErrorBody(value) {
|
|
108
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const sanitized = {};
|
|
112
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
113
|
+
const normalized = key.replace(/[_-]/g, '').toLowerCase();
|
|
114
|
+
if (normalized === 'credentials'
|
|
115
|
+
|| normalized === 'apikey'
|
|
116
|
+
|| normalized === 'companyid'
|
|
117
|
+
|| normalized === 'singleusetoken'
|
|
118
|
+
|| normalized === 'cardnumber'
|
|
119
|
+
|| normalized === 'creditcardnumber'
|
|
120
|
+
|| normalized === 'cvv'
|
|
121
|
+
|| normalized === 'cvc'
|
|
122
|
+
|| normalized === 'password'
|
|
123
|
+
|| normalized === 'secret') {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
sanitized[key] = nestedValue;
|
|
127
|
+
}
|
|
128
|
+
return sanitized;
|
|
129
|
+
}
|
|
130
|
+
function extractSumitProviderError(responseBody) {
|
|
131
|
+
const sanitized = sanitizeProviderErrorBody(responseBody);
|
|
132
|
+
if (!sanitized) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
if (sanitized.providerError && typeof sanitized.providerError === 'object') {
|
|
136
|
+
return sanitizeProviderErrorBody(sanitized.providerError);
|
|
137
|
+
}
|
|
138
|
+
if (sanitized.UserErrorMessage
|
|
139
|
+
|| sanitized.TechnicalErrorDetails
|
|
140
|
+
|| sanitized.Status) {
|
|
141
|
+
return sanitized;
|
|
142
|
+
}
|
|
143
|
+
if (sanitized.Data && typeof sanitized.Data === 'object') {
|
|
144
|
+
return sanitizeProviderErrorBody(sanitized.Data);
|
|
145
|
+
}
|
|
146
|
+
return sanitized;
|
|
147
|
+
}
|
|
148
|
+
function resolvePaymentProviderPublicContext(providerKind, metadata, providerSourceId) {
|
|
149
|
+
const context = {};
|
|
150
|
+
if (providerSourceId) {
|
|
151
|
+
context.providerSourceId = providerSourceId;
|
|
152
|
+
}
|
|
153
|
+
if (!providerKind || !metadata) {
|
|
154
|
+
return context;
|
|
155
|
+
}
|
|
156
|
+
switch (providerKind) {
|
|
157
|
+
case 'sumit':
|
|
158
|
+
if (metadata.companyId != null && metadata.companyId !== '') {
|
|
159
|
+
context.providerPublicAccountId = String(metadata.companyId);
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
case 'paypal':
|
|
163
|
+
if (typeof metadata.clientId === 'string' && metadata.clientId) {
|
|
164
|
+
context.providerPublicAccountId = metadata.clientId;
|
|
165
|
+
}
|
|
166
|
+
if (typeof metadata.environment === 'string' && metadata.environment) {
|
|
167
|
+
context.providerEnvironment = metadata.environment;
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
case 'paddle':
|
|
171
|
+
if (typeof metadata.environment === 'string' && metadata.environment) {
|
|
172
|
+
context.providerEnvironment = metadata.environment;
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
case 'dodopayments':
|
|
176
|
+
if (typeof metadata.environment === 'string' && metadata.environment) {
|
|
177
|
+
context.providerEnvironment = metadata.environment;
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
return context;
|
|
184
|
+
}
|
|
185
|
+
function appendPaymentProviderContext(metadata, providerContext) {
|
|
186
|
+
if (!providerContext) {
|
|
187
|
+
return metadata;
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
...metadata,
|
|
191
|
+
...(providerContext.providerSourceId ? { providerSourceId: providerContext.providerSourceId } : {}),
|
|
192
|
+
...(providerContext.providerPublicAccountId ? { providerPublicAccountId: providerContext.providerPublicAccountId } : {}),
|
|
193
|
+
...(providerContext.providerEnvironment ? { providerEnvironment: providerContext.providerEnvironment } : {}),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function buildPaymentAdminSuggestions(context) {
|
|
197
|
+
const suggestions = [];
|
|
198
|
+
const code = context.code?.toUpperCase();
|
|
199
|
+
const message = context.message?.toLowerCase() || '';
|
|
200
|
+
const providerError = context.providerError;
|
|
201
|
+
if (code === 'PAYMENTS_NOT_CONFIGURED') {
|
|
202
|
+
pushUnique(suggestions, {
|
|
203
|
+
summary: 'Configure payments for this tenant',
|
|
204
|
+
action: 'Open Admin → Pricing Plans → Configuration, enable payments, and select a payment provider integration source.',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (code === 'ACTIVE_SUBSCRIPTION_EXISTS') {
|
|
208
|
+
pushUnique(suggestions, {
|
|
209
|
+
summary: 'Cancel the existing subscription before checkout',
|
|
210
|
+
action: 'The billable entity already has an active or trialing subscription. Cancel it with sdk.payments.cancelSubscription(existingSubscriptionId), or pass reset: true on checkout to cancel automatically and start a new subscription.',
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (code === 'DYNAMIC_AMOUNT_NOT_SET') {
|
|
214
|
+
pushUnique(suggestions, {
|
|
215
|
+
summary: 'Set the subscription amount before checkout',
|
|
216
|
+
action: 'This plan is dynamic-priced. An admin must set dynamicAmount on the pending subscription before the user can pay.',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (code === 'DYNAMIC_PLAN_REQUIRES_SUBSCRIPTION' || code === 'DYNAMIC_PLAN_UNSUPPORTED_PROVIDER') {
|
|
220
|
+
pushUnique(suggestions, {
|
|
221
|
+
summary: 'Use the dynamic-plan checkout flow',
|
|
222
|
+
action: 'Create a pending subscription first, set dynamicAmount (admin), then call checkout with subscriptionId. Dynamic plans require Sumit.',
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (code === 'MISSING_REDIRECT_URLS') {
|
|
226
|
+
pushUnique(suggestions, {
|
|
227
|
+
summary: 'Configure checkout redirect URLs',
|
|
228
|
+
action: 'Add successUrl and cancelUrl in Admin → Pricing Plans → Configuration, or pass them in the checkout request.',
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (code === 'INVALID_CHECKOUT_AMOUNT') {
|
|
232
|
+
pushUnique(suggestions, {
|
|
233
|
+
summary: 'Set a positive checkout amount',
|
|
234
|
+
action: 'For dynamic plans, an admin must set dynamicAmount on the pending subscription before checkout. Static plans need a non-zero monthly/yearly price.',
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
if (code === 'INVALID_SUMIT_COMPANY_ID' || code === 'MISSING_SUMIT_CREDENTIALS') {
|
|
238
|
+
pushUnique(suggestions, {
|
|
239
|
+
summary: 'Fix Sumit Company ID',
|
|
240
|
+
action: 'Open Admin → Integrations → Sumit and enter the numeric Company ID from https://app.sumit.co.il/developers/keys/.',
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (code === 'UNSUPPORTED_SUMIT_CURRENCY') {
|
|
244
|
+
pushUnique(suggestions, {
|
|
245
|
+
summary: 'Use a Sumit-supported plan currency',
|
|
246
|
+
action: 'Change the plan currency to ILS, USD, or EUR. Sumit does not support other currencies.',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (code === 'INTEGRATION_SOURCE_NOT_FOUND') {
|
|
250
|
+
pushUnique(suggestions, {
|
|
251
|
+
summary: 'Reconnect the payment provider',
|
|
252
|
+
action: 'The configured paymentSourceId no longer exists. Re-select the Sumit integration in Admin → Pricing Plans → Configuration.',
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (context.providerKind === 'sumit') {
|
|
256
|
+
sumitCredentialsSuggestions(suggestions, context.message, providerError);
|
|
257
|
+
if (context.operation === 'beginCheckoutRedirect') {
|
|
258
|
+
pushUnique(suggestions, {
|
|
259
|
+
summary: 'Confirm Sumit hosted checkout is enabled',
|
|
260
|
+
action: 'In the Sumit account, verify redirect/hosted checkout is enabled for the merchant and that the API key has billing permissions.',
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (message.includes('unsupported sumit currency')) {
|
|
264
|
+
pushUnique(suggestions, {
|
|
265
|
+
summary: 'Use a Sumit-supported plan currency',
|
|
266
|
+
action: 'Set the plan currency to ILS, USD, or EUR before retrying checkout.',
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (message.includes('missing api key or company id')) {
|
|
270
|
+
pushUnique(suggestions, {
|
|
271
|
+
summary: 'Complete the Sumit integration credentials',
|
|
272
|
+
action: 'Open Admin → Integrations → Sumit and save both Company ID and API key.',
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (context.status === 401
|
|
277
|
+
|| context.status === 403
|
|
278
|
+
|| message.includes('401')
|
|
279
|
+
|| message.includes('403')) {
|
|
280
|
+
pushUnique(suggestions, {
|
|
281
|
+
summary: 'Payment provider rejected the credentials',
|
|
282
|
+
action: 'Regenerate the provider API key/secret in the provider dashboard and update the integration source in Admin → Integrations.',
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
if (code === 'INTEGRATION_TARGET_FAILED'
|
|
286
|
+
&& suggestions.length === 0
|
|
287
|
+
&& context.providerKind === 'sumit') {
|
|
288
|
+
pushUnique(suggestions, {
|
|
289
|
+
summary: 'Review Sumit account configuration',
|
|
290
|
+
action: 'Verify Company ID and API key in Admin → Integrations → Sumit, then retry checkout. If it still fails, check Sumit developer logs for the rejected beginredirect request.',
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return suggestions;
|
|
294
|
+
}
|
|
295
|
+
function buildPaymentEventDescription(baseDescription, providerError) {
|
|
296
|
+
const userMessage = providerError?.UserErrorMessage;
|
|
297
|
+
if (typeof userMessage === 'string' && userMessage.trim()) {
|
|
298
|
+
return `${baseDescription}: ${userMessage.trim()}`;
|
|
299
|
+
}
|
|
300
|
+
return baseDescription;
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=payment-event-resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-event-resolution.js","sourceRoot":"","sources":["../payment-event-resolution.ts"],"names":[],"mappings":";;;AA6FA,gEAYC;AAuCD,8DAyBC;AAED,8DAuBC;AAED,kFA4CC;AAED,oEAcC;AAED,oEAsHC;AAED,oEASC;AAxWY,QAAA,sBAAsB,GAAG,gCAAgC,CAAC;AAEvE,MAAM,2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E,OAAO,CAAC,MAAM,KAAK,GAAG;WACnB,OAAO,CAAC,MAAM,KAAK,GAAG;WACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;WACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC1B,CAAC;QACD,UAAU,CAAC,WAAW,EAAE;YACtB,OAAO,EAAE,2CAA2C;YACpD,MAAM,EAAE,6HAA6H;SACtI,CAAC,CAAC;IACL,CAAC;IAED,IACE,IAAI,KAAK,2BAA2B;WACjC,WAAW,CAAC,MAAM,KAAK,CAAC;WACxB,OAAO,CAAC,YAAY,KAAK,OAAO,EACnC,CAAC;QACD,UAAU,CAAC,WAAW,EAAE;YACtB,OAAO,EAAE,oCAAoC;YAC7C,MAAM,EAAE,2KAA2K;SACpL,CAAC,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAgB,4BAA4B,CAC1C,eAAuB,EACvB,aAA8C;IAE9C,MAAM,WAAW,GAAG,aAAa,EAAE,gBAAgB,CAAC;IACpD,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1D,OAAO,GAAG,eAAe,KAAK,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;IACrD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/** Determines whether billing is tied to individual users (B2C) or workspaces (B2B). */
|
|
2
|
+
export type BillableEntityType = 'user' | 'workspace';
|
|
3
|
+
/** Lifecycle states of a subscription. */
|
|
4
|
+
export type SubscriptionStatus = 'pending' | 'active' | 'canceled' | 'past_due' | 'trialing' | 'expired';
|
|
5
|
+
/** Supported billing intervals. */
|
|
6
|
+
export type BillingCycle = 'monthly' | 'yearly';
|
|
7
|
+
/** Payment status of an invoice. */
|
|
8
|
+
export type InvoiceStatus = 'paid' | 'pending' | 'failed' | 'refunded';
|
|
9
|
+
/** Type of discount a coupon provides. */
|
|
10
|
+
export type CouponDiscountType = 'percentage' | 'fixed';
|
|
11
|
+
/**
|
|
12
|
+
* Real-world identity of the billable entity, passed through checkout so payment
|
|
13
|
+
* providers (e.g. Sumit) can create a properly-named customer record instead of
|
|
14
|
+
* falling back to the raw billable entity ID.
|
|
15
|
+
*/
|
|
16
|
+
export interface CheckoutCustomer {
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Legal/invoice name, e.g. a company name distinct from the contact's personal name. */
|
|
19
|
+
nameForInvoice?: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
phone?: string;
|
|
22
|
+
address?: string;
|
|
23
|
+
city?: string;
|
|
24
|
+
/** Company tax/VAT identifier. */
|
|
25
|
+
taxId?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Tenant payments settings stored in the `payments-configuration` configuration key. */
|
|
28
|
+
export interface IPaymentsConfigurationMetadata {
|
|
29
|
+
isEnabled?: boolean;
|
|
30
|
+
/** Integration source `_id` (admin UI field name). */
|
|
31
|
+
paymentSourceId?: string;
|
|
32
|
+
/** Same as `paymentSourceId`; normalized by the payments service when loading config. */
|
|
33
|
+
providerSourceId?: string;
|
|
34
|
+
providerKind?: 'paddle' | 'paypal' | 'sumit' | 'dodopayments' | string;
|
|
35
|
+
defaultCurrency?: string;
|
|
36
|
+
gracePeriodDays?: number;
|
|
37
|
+
/** Default redirect URL after successful checkout (required for Sumit unless overridden per checkout). */
|
|
38
|
+
successUrl?: string;
|
|
39
|
+
/** Default redirect URL when the user cancels checkout (required for Sumit unless overridden per checkout). */
|
|
40
|
+
cancelUrl?: string;
|
|
41
|
+
webhookSecret?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Arbitrary limits associated with a plan (e.g. max users, storage quota).
|
|
45
|
+
* Keys are limit names; values can be numbers, booleans, or strings.
|
|
46
|
+
*/
|
|
47
|
+
export interface IPlanLimits {
|
|
48
|
+
[key: string]: number | boolean | string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Maps payment provider kinds to their external product/price identifiers.
|
|
52
|
+
* Used to link internal plans to provider-specific entities.
|
|
53
|
+
*/
|
|
54
|
+
export interface IPlanExternalIds {
|
|
55
|
+
[providerKind: string]: {
|
|
56
|
+
productId?: string;
|
|
57
|
+
monthlyPriceId?: string;
|
|
58
|
+
yearlyPriceId?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** A pricing plan that users or workspaces can subscribe to. */
|
|
62
|
+
export interface IPlan {
|
|
63
|
+
_id?: string;
|
|
64
|
+
/** Tenant identifier for multi-tenant isolation. */
|
|
65
|
+
tenant: string;
|
|
66
|
+
name: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
/** Human-readable feature descriptions displayed on pricing pages. */
|
|
69
|
+
features: string[];
|
|
70
|
+
monthlyPrice: number;
|
|
71
|
+
yearlyPrice: number;
|
|
72
|
+
/** ISO 4217 currency code (e.g. "USD", "EUR"). */
|
|
73
|
+
currency: string;
|
|
74
|
+
isActive: boolean;
|
|
75
|
+
/** Controls display order — lower numbers appear first. */
|
|
76
|
+
sortOrder: number;
|
|
77
|
+
/**
|
|
78
|
+
* When `true`, the price is not fixed — it is calculated at checkout time
|
|
79
|
+
* (e.g. per-user, per-item, or otherwise variable). `monthlyPrice` /
|
|
80
|
+
* `yearlyPrice` are ignored for dynamic plans; the caller must supply an
|
|
81
|
+
* `amount` at checkout instead.
|
|
82
|
+
*/
|
|
83
|
+
dynamic?: boolean;
|
|
84
|
+
limits?: IPlanLimits;
|
|
85
|
+
externalIds?: IPlanExternalIds;
|
|
86
|
+
metadata?: Record<string, any>;
|
|
87
|
+
created?: Date;
|
|
88
|
+
}
|
|
89
|
+
/** A subscription linking a billable entity to a plan. */
|
|
90
|
+
export interface ISubscription {
|
|
91
|
+
_id?: string;
|
|
92
|
+
tenant: string;
|
|
93
|
+
/** Reference to the subscribed plan. */
|
|
94
|
+
planId: string;
|
|
95
|
+
billableEntityType: BillableEntityType;
|
|
96
|
+
billableEntityId: string;
|
|
97
|
+
status: SubscriptionStatus;
|
|
98
|
+
billingCycle: BillingCycle;
|
|
99
|
+
currentPeriodStart?: Date;
|
|
100
|
+
currentPeriodEnd?: Date;
|
|
101
|
+
/** Provider-side subscription identifier for reconciliation. */
|
|
102
|
+
externalSubscriptionId?: string;
|
|
103
|
+
/** Integration source ID used for this subscription's provider calls. */
|
|
104
|
+
providerId?: string;
|
|
105
|
+
/** Payment provider kind (e.g. "paddle", "paypal", "sumit"). */
|
|
106
|
+
providerKind?: string;
|
|
107
|
+
couponId?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Admin-configured charge amount for dynamic-priced plans. Only admins may
|
|
110
|
+
* set this field; it is read by the checkout service when `IPlan.dynamic` is
|
|
111
|
+
* `true`. Must be set before checkout can proceed on a dynamic plan.
|
|
112
|
+
*/
|
|
113
|
+
dynamicAmount?: number;
|
|
114
|
+
metadata?: Record<string, any>;
|
|
115
|
+
created?: Date;
|
|
116
|
+
}
|
|
117
|
+
/** A single line item within an invoice. */
|
|
118
|
+
export interface IInvoiceItem {
|
|
119
|
+
description: string;
|
|
120
|
+
amount: number;
|
|
121
|
+
quantity: number;
|
|
122
|
+
}
|
|
123
|
+
/** An invoice record for a payment event. */
|
|
124
|
+
export interface IInvoice {
|
|
125
|
+
_id?: string;
|
|
126
|
+
tenant: string;
|
|
127
|
+
subscriptionId?: string;
|
|
128
|
+
billableEntityType: BillableEntityType;
|
|
129
|
+
billableEntityId: string;
|
|
130
|
+
amount: number;
|
|
131
|
+
/** ISO 4217 currency code. */
|
|
132
|
+
currency: string;
|
|
133
|
+
status: InvoiceStatus;
|
|
134
|
+
/** Provider-side invoice identifier. */
|
|
135
|
+
externalInvoiceId?: string;
|
|
136
|
+
providerKind?: string;
|
|
137
|
+
/** URL to download/view the invoice from the provider. */
|
|
138
|
+
invoiceUrl?: string;
|
|
139
|
+
paidAt?: Date;
|
|
140
|
+
periodStart?: Date;
|
|
141
|
+
periodEnd?: Date;
|
|
142
|
+
items: IInvoiceItem[];
|
|
143
|
+
created?: Date;
|
|
144
|
+
}
|
|
145
|
+
/** A discount coupon that can be applied during checkout. */
|
|
146
|
+
export interface ICoupon {
|
|
147
|
+
_id?: string;
|
|
148
|
+
tenant: string;
|
|
149
|
+
/** Unique coupon code entered by users. */
|
|
150
|
+
code: string;
|
|
151
|
+
discountType: CouponDiscountType;
|
|
152
|
+
/** For percentage: 0–100. For fixed: absolute amount in the coupon's currency. */
|
|
153
|
+
discountValue: number;
|
|
154
|
+
/** ISO 4217 currency code — relevant for fixed-amount discounts. */
|
|
155
|
+
currency?: string;
|
|
156
|
+
/** `null` or `undefined` means unlimited redemptions. */
|
|
157
|
+
maxRedemptions?: number;
|
|
158
|
+
currentRedemptions: number;
|
|
159
|
+
validFrom?: Date;
|
|
160
|
+
validUntil?: Date;
|
|
161
|
+
/** Empty array means the coupon applies to all plans. */
|
|
162
|
+
applicablePlanIds: string[];
|
|
163
|
+
isActive: boolean;
|
|
164
|
+
created?: Date;
|
|
165
|
+
}
|
package/dist/payments.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../payments.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-crud.js","sourceRoot":"","sources":["../plugin-crud.ts"],"names":[],"mappings":""}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IMicroFrontend } from './micro-frontend';
|
|
2
|
+
import { IEventSubscriber } from './event-subscriber';
|
|
3
|
+
import { IPluginCrud } from './plugin-crud';
|
|
4
|
+
import { IInjectable } from './injectable';
|
|
5
|
+
import { INavbarGroup } from './navbar-group';
|
|
6
|
+
export interface IPlugin {
|
|
7
|
+
tenant: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
apiPath: string;
|
|
11
|
+
registerUrl: string;
|
|
12
|
+
user: string;
|
|
13
|
+
token: string;
|
|
14
|
+
proxyUrl: string;
|
|
15
|
+
authAcquire: {
|
|
16
|
+
refreshTokenUrl: string;
|
|
17
|
+
refreshTokenKey: string;
|
|
18
|
+
accessTokenKey: string;
|
|
19
|
+
};
|
|
20
|
+
auth: {
|
|
21
|
+
refreshTokenIdentifier?: string;
|
|
22
|
+
};
|
|
23
|
+
manifestUrl: string;
|
|
24
|
+
callbackUrl?: string;
|
|
25
|
+
subscribedEvents: IEventSubscriber[];
|
|
26
|
+
microFrontends: IMicroFrontend[];
|
|
27
|
+
cruds: IPluginCrud[];
|
|
28
|
+
injectables: IInjectable[];
|
|
29
|
+
navBarGroups?: INavbarGroup[];
|
|
30
|
+
}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../plugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contracts every Qelos framework integrator (`@qelos/integrator-*`)
|
|
3
|
+
* builds upon. Defined here — rather than in each integrator — so the
|
|
4
|
+
* per-request shape and configuration surface are guaranteed identical across
|
|
5
|
+
* frameworks.
|
|
6
|
+
*
|
|
7
|
+
* `@qelos/sdk` depends on `@qelos/global-types`, so this file deliberately
|
|
8
|
+
* avoids importing from the SDK; instead, {@link QelosContext} is generic over
|
|
9
|
+
* the SDK instance type and integrators specialize it with the concrete
|
|
10
|
+
* `QelosSDK` / `IUser` / `IWorkspace` types from `@qelos/sdk`.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Tokens read from an inbound request. Integrators mutate this object in place
|
|
14
|
+
* when a refresh occurs so later code can read the current pair.
|
|
15
|
+
*/
|
|
16
|
+
export interface QelosTokenPair {
|
|
17
|
+
accessToken?: string;
|
|
18
|
+
refreshToken?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of a successful token refresh.
|
|
22
|
+
*/
|
|
23
|
+
export interface ResolvedTokens {
|
|
24
|
+
accessToken: string;
|
|
25
|
+
refreshToken?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Minimal user contract shared by all integrators. The SDK's `IUser` (rich,
|
|
29
|
+
* with first/last name, metadata, etc.) is assignable to this and is what
|
|
30
|
+
* integrators actually plug in via the `TUser` parameter on
|
|
31
|
+
* {@link QelosContext}.
|
|
32
|
+
*/
|
|
33
|
+
export interface IQelosUser {
|
|
34
|
+
_id: string;
|
|
35
|
+
username: string;
|
|
36
|
+
email: string;
|
|
37
|
+
roles: string[];
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Minimal workspace contract shared by all integrators. The SDK's `IWorkspace`
|
|
42
|
+
* is assignable to this.
|
|
43
|
+
*/
|
|
44
|
+
export interface IQelosWorkspace {
|
|
45
|
+
name: string;
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Base configuration contract every framework integrator builds upon.
|
|
50
|
+
* Framework-specific configs (e.g. `QelosExpressConfig`, `QelosNextConfig`)
|
|
51
|
+
* extend this with transport-specific options such as `sdkOptions`.
|
|
52
|
+
*/
|
|
53
|
+
export interface QelosConfig {
|
|
54
|
+
/**
|
|
55
|
+
* Base URL of the Qelos backend (e.g. https://yourdomain.com).
|
|
56
|
+
*/
|
|
57
|
+
appUrl: string;
|
|
58
|
+
/**
|
|
59
|
+
* Static API token used for service-to-service calls. When provided, no
|
|
60
|
+
* cookie/refresh-token handling is performed.
|
|
61
|
+
*/
|
|
62
|
+
apiToken?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Cookie name carrying the Qelos access token. Defaults to `q_access_token`.
|
|
65
|
+
*/
|
|
66
|
+
accessTokenCookie?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Cookie name carrying the Qelos refresh token. Defaults to `q_refresh_token`.
|
|
69
|
+
*/
|
|
70
|
+
refreshTokenCookie?: string;
|
|
71
|
+
/**
|
|
72
|
+
* If true, the integrator rejects requests (401) when the user cannot be
|
|
73
|
+
* resolved. Defaults to `false` — anonymous requests pass through with
|
|
74
|
+
* `qelos.user = null`.
|
|
75
|
+
*/
|
|
76
|
+
requireAuth?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Skip the integrator entirely for requests whose path starts with any of
|
|
79
|
+
* these prefixes. Useful for `/health`, `/_next`, `/api/_auth`, etc.
|
|
80
|
+
*/
|
|
81
|
+
skipPaths?: string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Per-request Qelos context every integrator produces. Generic over the SDK
|
|
85
|
+
* instance type and the user/workspace shape so framework integrators narrow
|
|
86
|
+
* these to the SDK's concrete types (`QelosSDK`, `IUser`, `IWorkspace`)
|
|
87
|
+
* without dragging the SDK into `@qelos/global-types`.
|
|
88
|
+
*/
|
|
89
|
+
export interface QelosContext<TSdk = unknown, TUser extends IQelosUser = IQelosUser, TWorkspace extends IQelosWorkspace = IQelosWorkspace> {
|
|
90
|
+
/**
|
|
91
|
+
* The authenticated user, or `null` when anonymous.
|
|
92
|
+
*/
|
|
93
|
+
user: TUser | null;
|
|
94
|
+
/**
|
|
95
|
+
* The active workspace for the request, or `null` when none is active /
|
|
96
|
+
* the user is anonymous.
|
|
97
|
+
*/
|
|
98
|
+
workspace: TWorkspace | null;
|
|
99
|
+
/**
|
|
100
|
+
* The full list of workspaces the user has access to.
|
|
101
|
+
*/
|
|
102
|
+
workspaces: TWorkspace[];
|
|
103
|
+
/**
|
|
104
|
+
* SDK instance bound to the current request's tokens.
|
|
105
|
+
*/
|
|
106
|
+
sdk: TSdk;
|
|
107
|
+
/**
|
|
108
|
+
* Tokens read from the request. Mutated in place when a refresh occurs so
|
|
109
|
+
* later code can read the current pair.
|
|
110
|
+
*/
|
|
111
|
+
tokens: QelosTokenPair;
|
|
112
|
+
}
|