@qelos/global-types 3.11.11 → 4.1.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/index.ts +2 -1
- package/integration-sources.ts +33 -0
- package/package.json +1 -1
- package/payments.ts +13 -0
- package/qelos-integrator.ts +124 -0
package/index.ts
CHANGED
package/integration-sources.ts
CHANGED
|
@@ -14,6 +14,7 @@ export enum IntegrationSourceKind {
|
|
|
14
14
|
Sumit = 'sumit',
|
|
15
15
|
PayPal = 'paypal',
|
|
16
16
|
Paddle = 'paddle',
|
|
17
|
+
DodoPayments = 'dodopayments',
|
|
17
18
|
AWS = 'aws',
|
|
18
19
|
Cloudflare = 'cloudflare',
|
|
19
20
|
}
|
|
@@ -117,6 +118,27 @@ export const PaddleTargetOperation = {
|
|
|
117
118
|
listCustomers: 'listCustomers',
|
|
118
119
|
} as const;
|
|
119
120
|
|
|
121
|
+
export const DodoPaymentsTargetOperation = {
|
|
122
|
+
// Payments
|
|
123
|
+
createPayment: 'createPayment',
|
|
124
|
+
getPayment: 'getPayment',
|
|
125
|
+
listPayments: 'listPayments',
|
|
126
|
+
// Subscriptions
|
|
127
|
+
createSubscription: 'createSubscription',
|
|
128
|
+
getSubscription: 'getSubscription',
|
|
129
|
+
updateSubscription: 'updateSubscription',
|
|
130
|
+
cancelSubscription: 'cancelSubscription',
|
|
131
|
+
listSubscriptions: 'listSubscriptions',
|
|
132
|
+
// Products
|
|
133
|
+
createProduct: 'createProduct',
|
|
134
|
+
getProduct: 'getProduct',
|
|
135
|
+
listProducts: 'listProducts',
|
|
136
|
+
// Customers
|
|
137
|
+
createCustomer: 'createCustomer',
|
|
138
|
+
getCustomer: 'getCustomer',
|
|
139
|
+
listCustomers: 'listCustomers',
|
|
140
|
+
} as const;
|
|
141
|
+
|
|
120
142
|
export const AWSTargetOperation = {
|
|
121
143
|
callFunction: 'callFunction',
|
|
122
144
|
getFunction: 'getFunction',
|
|
@@ -203,6 +225,17 @@ export interface IPaddleSource extends IIntegrationSource {
|
|
|
203
225
|
};
|
|
204
226
|
}
|
|
205
227
|
|
|
228
|
+
export interface IDodoPaymentsSource extends IIntegrationSource {
|
|
229
|
+
_id?: string;
|
|
230
|
+
kind: IntegrationSourceKind.DodoPayments;
|
|
231
|
+
authentication: {
|
|
232
|
+
apiKey: string;
|
|
233
|
+
};
|
|
234
|
+
metadata: {
|
|
235
|
+
environment: 'test' | 'live';
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
206
239
|
export interface IQelosSource extends IIntegrationSource {
|
|
207
240
|
_id?: string;
|
|
208
241
|
kind: IntegrationSourceKind.Qelos;
|
package/package.json
CHANGED
package/payments.ts
CHANGED
|
@@ -49,6 +49,13 @@ export interface IPlan {
|
|
|
49
49
|
isActive: boolean;
|
|
50
50
|
/** Controls display order — lower numbers appear first. */
|
|
51
51
|
sortOrder: number;
|
|
52
|
+
/**
|
|
53
|
+
* When `true`, the price is not fixed — it is calculated at checkout time
|
|
54
|
+
* (e.g. per-user, per-item, or otherwise variable). `monthlyPrice` /
|
|
55
|
+
* `yearlyPrice` are ignored for dynamic plans; the caller must supply an
|
|
56
|
+
* `amount` at checkout instead.
|
|
57
|
+
*/
|
|
58
|
+
dynamic?: boolean;
|
|
52
59
|
limits?: IPlanLimits;
|
|
53
60
|
externalIds?: IPlanExternalIds;
|
|
54
61
|
metadata?: Record<string, any>;
|
|
@@ -74,6 +81,12 @@ export interface ISubscription {
|
|
|
74
81
|
/** Payment provider kind (e.g. "paddle", "paypal", "sumit"). */
|
|
75
82
|
providerKind?: string;
|
|
76
83
|
couponId?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Admin-configured charge amount for dynamic-priced plans. Only admins may
|
|
86
|
+
* set this field; it is read by the checkout service when `IPlan.dynamic` is
|
|
87
|
+
* `true`. Must be set before checkout can proceed on a dynamic plan.
|
|
88
|
+
*/
|
|
89
|
+
dynamicAmount?: number;
|
|
77
90
|
metadata?: Record<string, any>;
|
|
78
91
|
created?: Date;
|
|
79
92
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* Tokens read from an inbound request. Integrators mutate this object in place
|
|
15
|
+
* when a refresh occurs so later code can read the current pair.
|
|
16
|
+
*/
|
|
17
|
+
export interface QelosTokenPair {
|
|
18
|
+
accessToken?: string;
|
|
19
|
+
refreshToken?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Result of a successful token refresh.
|
|
24
|
+
*/
|
|
25
|
+
export interface ResolvedTokens {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Minimal user contract shared by all integrators. The SDK's `IUser` (rich,
|
|
32
|
+
* with first/last name, metadata, etc.) is assignable to this and is what
|
|
33
|
+
* integrators actually plug in via the `TUser` parameter on
|
|
34
|
+
* {@link QelosContext}.
|
|
35
|
+
*/
|
|
36
|
+
export interface IQelosUser {
|
|
37
|
+
_id: string;
|
|
38
|
+
username: string;
|
|
39
|
+
email: string;
|
|
40
|
+
roles: string[];
|
|
41
|
+
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Minimal workspace contract shared by all integrators. The SDK's `IWorkspace`
|
|
47
|
+
* is assignable to this.
|
|
48
|
+
*/
|
|
49
|
+
export interface IQelosWorkspace {
|
|
50
|
+
name: string;
|
|
51
|
+
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Base configuration contract every framework integrator builds upon.
|
|
57
|
+
* Framework-specific configs (e.g. `QelosExpressConfig`, `QelosNextConfig`)
|
|
58
|
+
* extend this with transport-specific options such as `sdkOptions`.
|
|
59
|
+
*/
|
|
60
|
+
export interface QelosConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Base URL of the Qelos backend (e.g. https://yourdomain.com).
|
|
63
|
+
*/
|
|
64
|
+
appUrl: string;
|
|
65
|
+
/**
|
|
66
|
+
* Static API token used for service-to-service calls. When provided, no
|
|
67
|
+
* cookie/refresh-token handling is performed.
|
|
68
|
+
*/
|
|
69
|
+
apiToken?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Cookie name carrying the Qelos access token. Defaults to `q_access_token`.
|
|
72
|
+
*/
|
|
73
|
+
accessTokenCookie?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Cookie name carrying the Qelos refresh token. Defaults to `q_refresh_token`.
|
|
76
|
+
*/
|
|
77
|
+
refreshTokenCookie?: string;
|
|
78
|
+
/**
|
|
79
|
+
* If true, the integrator rejects requests (401) when the user cannot be
|
|
80
|
+
* resolved. Defaults to `false` — anonymous requests pass through with
|
|
81
|
+
* `qelos.user = null`.
|
|
82
|
+
*/
|
|
83
|
+
requireAuth?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Skip the integrator entirely for requests whose path starts with any of
|
|
86
|
+
* these prefixes. Useful for `/health`, `/_next`, `/api/_auth`, etc.
|
|
87
|
+
*/
|
|
88
|
+
skipPaths?: string[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Per-request Qelos context every integrator produces. Generic over the SDK
|
|
93
|
+
* instance type and the user/workspace shape so framework integrators narrow
|
|
94
|
+
* these to the SDK's concrete types (`QelosSDK`, `IUser`, `IWorkspace`)
|
|
95
|
+
* without dragging the SDK into `@qelos/global-types`.
|
|
96
|
+
*/
|
|
97
|
+
export interface QelosContext<
|
|
98
|
+
TSdk = unknown,
|
|
99
|
+
TUser extends IQelosUser = IQelosUser,
|
|
100
|
+
TWorkspace extends IQelosWorkspace = IQelosWorkspace,
|
|
101
|
+
> {
|
|
102
|
+
/**
|
|
103
|
+
* The authenticated user, or `null` when anonymous.
|
|
104
|
+
*/
|
|
105
|
+
user: TUser | null;
|
|
106
|
+
/**
|
|
107
|
+
* The active workspace for the request, or `null` when none is active /
|
|
108
|
+
* the user is anonymous.
|
|
109
|
+
*/
|
|
110
|
+
workspace: TWorkspace | null;
|
|
111
|
+
/**
|
|
112
|
+
* The full list of workspaces the user has access to.
|
|
113
|
+
*/
|
|
114
|
+
workspaces: TWorkspace[];
|
|
115
|
+
/**
|
|
116
|
+
* SDK instance bound to the current request's tokens.
|
|
117
|
+
*/
|
|
118
|
+
sdk: TSdk;
|
|
119
|
+
/**
|
|
120
|
+
* Tokens read from the request. Mutated in place when a refresh occurs so
|
|
121
|
+
* later code can read the current pair.
|
|
122
|
+
*/
|
|
123
|
+
tokens: QelosTokenPair;
|
|
124
|
+
}
|