@enterprisestandard/react 0.0.5-beta.20260115.3 → 0.0.5-beta.20260115.4

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 (77) hide show
  1. package/dist/index.d.ts +2573 -41
  2. package/dist/index.js +3732 -144
  3. package/dist/index.js.map +1 -0
  4. package/package.json +3 -1
  5. package/dist/group-store.d.ts +0 -164
  6. package/dist/group-store.d.ts.map +0 -1
  7. package/dist/group-store.js +0 -127
  8. package/dist/iam.d.ts +0 -206
  9. package/dist/iam.d.ts.map +0 -1
  10. package/dist/iam.js +0 -680
  11. package/dist/index.d.ts.map +0 -1
  12. package/dist/session-store.d.ts +0 -179
  13. package/dist/session-store.d.ts.map +0 -1
  14. package/dist/session-store.js +0 -105
  15. package/dist/sso-server.d.ts +0 -13
  16. package/dist/sso-server.d.ts.map +0 -1
  17. package/dist/sso-server.js +0 -46
  18. package/dist/sso.d.ts +0 -104
  19. package/dist/sso.d.ts.map +0 -1
  20. package/dist/sso.js +0 -820
  21. package/dist/tenant-server.d.ts +0 -8
  22. package/dist/tenant-server.d.ts.map +0 -1
  23. package/dist/tenant-server.js +0 -6
  24. package/dist/tenant.d.ts +0 -280
  25. package/dist/tenant.d.ts.map +0 -1
  26. package/dist/tenant.js +0 -324
  27. package/dist/types/base-user.d.ts +0 -27
  28. package/dist/types/base-user.d.ts.map +0 -1
  29. package/dist/types/base-user.js +0 -1
  30. package/dist/types/enterprise-user.d.ts +0 -158
  31. package/dist/types/enterprise-user.d.ts.map +0 -1
  32. package/dist/types/enterprise-user.js +0 -1
  33. package/dist/types/oidc-schema.d.ts +0 -86
  34. package/dist/types/oidc-schema.d.ts.map +0 -1
  35. package/dist/types/oidc-schema.js +0 -328
  36. package/dist/types/scim-schema.d.ts +0 -419
  37. package/dist/types/scim-schema.d.ts.map +0 -1
  38. package/dist/types/scim-schema.js +0 -519
  39. package/dist/types/standard-schema.d.ts +0 -56
  40. package/dist/types/standard-schema.d.ts.map +0 -1
  41. package/dist/types/standard-schema.js +0 -1
  42. package/dist/types/user.d.ts +0 -41
  43. package/dist/types/user.d.ts.map +0 -1
  44. package/dist/types/user.js +0 -1
  45. package/dist/types/workload-schema.d.ts +0 -106
  46. package/dist/types/workload-schema.d.ts.map +0 -1
  47. package/dist/types/workload-schema.js +0 -208
  48. package/dist/ui/sign-in-loading.d.ts +0 -5
  49. package/dist/ui/sign-in-loading.d.ts.map +0 -1
  50. package/dist/ui/sign-in-loading.js +0 -8
  51. package/dist/ui/signed-in.d.ts +0 -3
  52. package/dist/ui/signed-in.d.ts.map +0 -1
  53. package/dist/ui/signed-in.js +0 -8
  54. package/dist/ui/signed-out.d.ts +0 -3
  55. package/dist/ui/signed-out.d.ts.map +0 -1
  56. package/dist/ui/signed-out.js +0 -8
  57. package/dist/ui/sso-provider.d.ts +0 -35
  58. package/dist/ui/sso-provider.d.ts.map +0 -1
  59. package/dist/ui/sso-provider.js +0 -275
  60. package/dist/user-store.d.ts +0 -161
  61. package/dist/user-store.d.ts.map +0 -1
  62. package/dist/user-store.js +0 -114
  63. package/dist/utils.d.ts +0 -9
  64. package/dist/utils.d.ts.map +0 -1
  65. package/dist/utils.js +0 -23
  66. package/dist/vault.d.ts +0 -18
  67. package/dist/vault.d.ts.map +0 -1
  68. package/dist/vault.js +0 -22
  69. package/dist/workload-server.d.ts +0 -127
  70. package/dist/workload-server.d.ts.map +0 -1
  71. package/dist/workload-server.js +0 -167
  72. package/dist/workload-token-store.d.ts +0 -187
  73. package/dist/workload-token-store.d.ts.map +0 -1
  74. package/dist/workload-token-store.js +0 -95
  75. package/dist/workload.d.ts +0 -227
  76. package/dist/workload.d.ts.map +0 -1
  77. package/dist/workload.js +0 -691
@@ -1,8 +0,0 @@
1
- /**
2
- * Server-side helper functions for tenant management.
3
- * These functions provide a convenient way to parse tenant requests
4
- * and send webhook updates.
5
- */
6
- export type { CreateTenantRequest, CreateTenantResponse, EnvironmentType, TenantStatus, TenantWebhookPayload, } from './tenant';
7
- export { parseTenantRequest, sendTenantWebhook, TenantRequestError } from './tenant';
8
- //# sourceMappingURL=tenant-server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tenant-server.d.ts","sourceRoot":"","sources":["../src/tenant-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Server-side helper functions for tenant management.
3
- * These functions provide a convenient way to parse tenant requests
4
- * and send webhook updates.
5
- */
6
- export { parseTenantRequest, sendTenantWebhook, TenantRequestError } from './tenant.js';
package/dist/tenant.d.ts DELETED
@@ -1,280 +0,0 @@
1
- /**
2
- * Tenant Management SDK
3
- *
4
- * Provides helper functions for applications to implement tenant creation endpoints
5
- * that ESVS can test. Supports both synchronous (201) and asynchronous (202)
6
- * tenant creation with webhook-based status updates.
7
- */
8
- /**
9
- * Environment type for tenant creation
10
- */
11
- export type EnvironmentType = 'POC' | 'DEV' | 'QA' | 'PROD';
12
- /**
13
- * Status of tenant creation process
14
- */
15
- export type TenantStatus = 'pending' | 'processing' | 'completed' | 'failed';
16
- /**
17
- * Request payload from ESVS for creating a tenant
18
- */
19
- export interface CreateTenantRequest {
20
- /**
21
- * Required app identifier to use when initializing EnterpriseStandard for this tenant.
22
- * This is the primary identifier for tenant management. A company can have multiple
23
- * applications (e.g., one instance on the east coast, one on the west coast).
24
- */
25
- appId: string;
26
- /**
27
- * Company ID (used for reporting purposes only, not for tenant identification)
28
- */
29
- companyId: string;
30
- /**
31
- * Company Name
32
- */
33
- companyName: string;
34
- /**
35
- * Environment Type (POC, DEV, QA, PROD)
36
- */
37
- environmentType: EnvironmentType;
38
- /**
39
- * Email (The email or distribution list used to communicate to the team)
40
- */
41
- email: string;
42
- /**
43
- * Webhook URL where the application can send updates around the creation of the tenant
44
- */
45
- webhookUrl: string;
46
- }
47
- /**
48
- * Response payload for tenant creation
49
- */
50
- export interface CreateTenantResponse {
51
- /**
52
- * URL that the tenant will be available at
53
- */
54
- tenantUrl: string;
55
- /**
56
- * Current status of tenant creation
57
- */
58
- status: TenantStatus;
59
- }
60
- /**
61
- * Payload sent to webhook URL for status updates
62
- */
63
- export interface TenantWebhookPayload {
64
- /**
65
- * Company ID
66
- */
67
- companyId: string;
68
- /**
69
- * Current status of tenant creation
70
- */
71
- status: TenantStatus;
72
- /**
73
- * URL that the tenant will be available at (provided once creation completes)
74
- */
75
- tenantUrl?: string;
76
- /**
77
- * Error message (only present if status is "failed")
78
- */
79
- error?: string;
80
- }
81
- /**
82
- * Error thrown when tenant request validation fails
83
- */
84
- export declare class TenantRequestError extends Error {
85
- constructor(message: string);
86
- }
87
- /**
88
- * Serializes an ESConfig or EnterpriseStandard instance to a JSON-serializable format
89
- * by removing non-serializable properties like stores, validators, and functions.
90
- *
91
- * Since EnterpriseStandard now extends ESConfig, the config (including handler URLs)
92
- * is accessible directly from the instance.
93
- *
94
- * @param configOrES - The ESConfig object or EnterpriseStandard instance to serialize
95
- * @returns A JSON-serializable version of the config
96
- */
97
- export declare function serializeESConfig(configOrES: any): any;
98
- /**
99
- * Parse and validate a tenant creation request from an HTTP request.
100
- *
101
- * @param request - The HTTP request containing the tenant creation data
102
- * @returns The validated tenant creation request
103
- * @throws {TenantRequestError} If the request is invalid or missing required fields
104
- *
105
- * @example
106
- * ```typescript
107
- * app.post('/api/tenant', async (c) => {
108
- * try {
109
- * const tenantRequest = await parseTenantRequest(c.req.raw);
110
- * // Create tenant...
111
- * } catch (error) {
112
- * if (error instanceof TenantRequestError) {
113
- * return c.json({ error: error.message }, 400);
114
- * }
115
- * throw error;
116
- * }
117
- * });
118
- * ```
119
- */
120
- export declare function parseTenantRequest(request: Request): Promise<CreateTenantRequest>;
121
- /**
122
- * Send a webhook update to ESVS with tenant creation status.
123
- *
124
- * @param webhookUrl - The webhook URL provided in the tenant creation request
125
- * @param payload - The webhook payload with status and tenant information
126
- * @throws Never throws - errors are logged but not propagated to avoid breaking tenant creation
127
- *
128
- * @example
129
- * ```typescript
130
- * // Send initial status
131
- * await sendTenantWebhook(tenantRequest.webhookUrl, {
132
- * companyId: tenantRequest.companyId,
133
- * status: 'processing',
134
- * });
135
- *
136
- * // Send completion status
137
- * await sendTenantWebhook(tenantRequest.webhookUrl, {
138
- * companyId: tenantRequest.companyId,
139
- * status: 'completed',
140
- * tenantUrl: 'https://app.example.com/tenants/tenant-123',
141
- * });
142
- * ```
143
- */
144
- export declare function sendTenantWebhook(webhookUrl: string, payload: TenantWebhookPayload): Promise<void>;
145
- /**
146
- * Stored tenant data with required appId and tracking metadata.
147
- *
148
- * @template TExtended - Type-safe custom data that consumers can add to tenants
149
- */
150
- export type StoredTenant<TExtended = {}> = {
151
- /**
152
- * Required app identifier used to initialize EnterpriseStandard for this tenant.
153
- * This is the primary key for tenant storage. A company can have multiple
154
- * applications (e.g., one instance on the east coast, one on the west coast).
155
- */
156
- appId: string;
157
- /**
158
- * Company ID (used for reporting purposes only, not for tenant identification)
159
- */
160
- companyId: string;
161
- /**
162
- * Company Name
163
- */
164
- companyName: string;
165
- /**
166
- * Environment Type (POC, DEV, QA, PROD)
167
- */
168
- environmentType: EnvironmentType;
169
- /**
170
- * Email (The email or distribution list used to communicate to the team)
171
- */
172
- email: string;
173
- /**
174
- * Webhook URL where the application can send updates around the creation of the tenant
175
- */
176
- webhookUrl: string;
177
- /**
178
- * URL that the tenant will be available at
179
- */
180
- tenantUrl?: string;
181
- /**
182
- * Current status of tenant creation
183
- */
184
- status: TenantStatus;
185
- /**
186
- * Error message (only present if status is "failed")
187
- */
188
- error?: string;
189
- /**
190
- * Timestamp when the tenant was first stored.
191
- */
192
- createdAt: Date;
193
- /**
194
- * Timestamp when the tenant was last updated.
195
- */
196
- updatedAt: Date;
197
- /**
198
- * Serialized Enterprise Standard configuration.
199
- * This is a JSON-serializable version of the ESConfig with non-serializable items excluded.
200
- */
201
- config?: any;
202
- } & TExtended;
203
- /**
204
- * Abstract interface for tenant storage backends.
205
- *
206
- * Consumers can implement this interface to use different storage backends:
207
- * - In-memory (for development/testing)
208
- * - Redis (for production with fast lookups)
209
- * - Database (PostgreSQL, MySQL, etc.)
210
- *
211
- * @template TExtended - Type-safe custom data that consumers can add to tenants
212
- */
213
- export interface TenantStore<TExtended = {}> {
214
- /**
215
- * Retrieve a tenant by its app identifier.
216
- *
217
- * @param appId - The tenant's app identifier (primary key)
218
- * @returns The tenant if found, null otherwise
219
- */
220
- get(appId: string): Promise<StoredTenant<TExtended> | null>;
221
- /**
222
- * Retrieve all tenants for a company ID.
223
- * Since a company can have multiple applications, this returns an array.
224
- *
225
- * @param companyId - The company ID (used for reporting, not primary identification)
226
- * @returns Array of tenants for the company, empty array if none found
227
- */
228
- getByCompanyId(companyId: string): Promise<StoredTenant<TExtended>[]>;
229
- /**
230
- * List all tenants in the store.
231
- *
232
- * @returns Array of all stored tenants
233
- */
234
- list(): Promise<StoredTenant<TExtended>[]>;
235
- /**
236
- * Create or update a tenant in the store.
237
- *
238
- * If a tenant with the same `appId` exists, it will be updated.
239
- * Otherwise, a new tenant will be created.
240
- *
241
- * @param tenant - The tenant data to store
242
- * @returns The stored tenant
243
- */
244
- upsert(tenant: StoredTenant<TExtended>): Promise<StoredTenant<TExtended>>;
245
- /**
246
- * Delete a tenant by its app identifier.
247
- *
248
- * @param appId - The tenant's app identifier to delete
249
- */
250
- delete(appId: string): Promise<void>;
251
- }
252
- /**
253
- * In-memory tenant store implementation using Maps.
254
- *
255
- * Suitable for:
256
- * - Development and testing
257
- * - Single-server deployments
258
- * - Applications without high availability requirements
259
- *
260
- * NOT suitable for:
261
- * - Multi-server deployments (tenants not shared)
262
- * - High availability scenarios (tenants lost on restart)
263
- * - Production applications with distributed architecture
264
- *
265
- * For production, implement TenantStore with Redis or a database.
266
- *
267
- * @template TExtended - Type-safe custom data that consumers can add to tenants
268
- */
269
- export declare class InMemoryTenantStore<TExtended = {}> implements TenantStore<TExtended> {
270
- /** Primary storage: appId -> tenant */
271
- private tenants;
272
- /** Secondary index: companyId -> Set of appIds (since one company can have multiple apps) */
273
- private companyIdIndex;
274
- get(appId: string): Promise<StoredTenant<TExtended> | null>;
275
- getByCompanyId(companyId: string): Promise<StoredTenant<TExtended>[]>;
276
- list(): Promise<StoredTenant<TExtended>[]>;
277
- upsert(tenant: StoredTenant<TExtended>): Promise<StoredTenant<TExtended>>;
278
- delete(appId: string): Promise<void>;
279
- }
280
- //# sourceMappingURL=tenant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;IAEjC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAE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@@ -1,324 +0,0 @@
1
- /**
2
- * Tenant Management SDK
3
- *
4
- * Provides helper functions for applications to implement tenant creation endpoints
5
- * that ESVS can test. Supports both synchronous (201) and asynchronous (202)
6
- * tenant creation with webhook-based status updates.
7
- */
8
- /**
9
- * Error thrown when tenant request validation fails
10
- */
11
- export class TenantRequestError extends Error {
12
- constructor(message) {
13
- super(message);
14
- this.name = 'TenantRequestError';
15
- }
16
- }
17
- /**
18
- * Serializes an ESConfig or EnterpriseStandard instance to a JSON-serializable format
19
- * by removing non-serializable properties like stores, validators, and functions.
20
- *
21
- * Since EnterpriseStandard now extends ESConfig, the config (including handler URLs)
22
- * is accessible directly from the instance.
23
- *
24
- * @param configOrES - The ESConfig object or EnterpriseStandard instance to serialize
25
- * @returns A JSON-serializable version of the config
26
- */
27
- export function serializeESConfig(configOrES) {
28
- // EnterpriseStandard now extends ESConfig, so we can access config directly
29
- // Extract the config properties (sso, iam, workload, validation, defaultInstance)
30
- // and exclude the service instances (vault, sso instance, iam instance, workload instance)
31
- if (configOrES &&
32
- typeof configOrES === 'object' &&
33
- 'sso' in configOrES &&
34
- 'workload' in configOrES &&
35
- 'iam' in configOrES) {
36
- // It's an EnterpriseStandard instance
37
- // Extract config from the service instances (they now extend their configs)
38
- const config = {
39
- defaultInstance: configOrES.defaultInstance,
40
- sso: configOrES.sso ? serializeESConfig(configOrES.sso) : undefined,
41
- iam: configOrES.iam ? serializeESConfig(configOrES.iam) : undefined,
42
- workload: configOrES.workload ? serializeESConfig(configOrES.workload) : undefined,
43
- validation: configOrES.validation,
44
- };
45
- return config;
46
- }
47
- // Otherwise, treat it as an ESConfig or service config
48
- const config = configOrES;
49
- if (config === null || config === undefined) {
50
- return config;
51
- }
52
- // Handle primitives
53
- if (typeof config !== 'object') {
54
- return config;
55
- }
56
- // Handle arrays
57
- if (Array.isArray(config)) {
58
- return config.map((item) => serializeESConfig(item));
59
- }
60
- // Check if it's a store instance (has methods like get, set, create, delete, etc.)
61
- const isStore = typeof config.get === 'function' ||
62
- typeof config.set === 'function' ||
63
- typeof config.create === 'function' ||
64
- typeof config.delete === 'function' ||
65
- typeof config.upsert === 'function' ||
66
- typeof config.list === 'function';
67
- // Check if it's a StandardSchemaV1 validator (has '~standard' property)
68
- const isValidator = config['~standard'] !== undefined;
69
- // Check if it's a function
70
- if (typeof config === 'function' || isStore || isValidator) {
71
- return undefined;
72
- }
73
- // Handle Date objects
74
- if (config instanceof Date) {
75
- return config.toISOString();
76
- }
77
- // Recursively serialize object properties
78
- const serialized = {};
79
- for (const key in config) {
80
- if (Object.hasOwn(config, key)) {
81
- // Skip non-serializable properties
82
- if (key === 'session_store' ||
83
- key === 'user_store' ||
84
- key === 'token_store' ||
85
- key === 'group_store' ||
86
- key === 'validation' ||
87
- key === 'vault' || // Skip vault instance
88
- // Skip method properties from service instances
89
- key === 'getUser' ||
90
- key === 'getRequiredUser' ||
91
- key === 'getJwt' ||
92
- key === 'initiateLogin' ||
93
- key === 'logout' ||
94
- key === 'callbackHandler' ||
95
- key === 'handler' ||
96
- key === 'getToken' ||
97
- key === 'refreshToken' ||
98
- key === 'generateJWTAssertion' ||
99
- key === 'revokeToken' ||
100
- key === 'validateToken' ||
101
- key === 'getWorkload' ||
102
- key === 'parseJWT' ||
103
- key === 'createUser' ||
104
- key === 'getBaseUrl' ||
105
- key === 'groups_outbound' ||
106
- key === 'groups_inbound') {
107
- continue;
108
- }
109
- const value = serializeESConfig(config[key]);
110
- // Only include defined values
111
- if (value !== undefined) {
112
- serialized[key] = value;
113
- }
114
- }
115
- }
116
- return serialized;
117
- }
118
- /**
119
- * Parse and validate a tenant creation request from an HTTP request.
120
- *
121
- * @param request - The HTTP request containing the tenant creation data
122
- * @returns The validated tenant creation request
123
- * @throws {TenantRequestError} If the request is invalid or missing required fields
124
- *
125
- * @example
126
- * ```typescript
127
- * app.post('/api/tenant', async (c) => {
128
- * try {
129
- * const tenantRequest = await parseTenantRequest(c.req.raw);
130
- * // Create tenant...
131
- * } catch (error) {
132
- * if (error instanceof TenantRequestError) {
133
- * return c.json({ error: error.message }, 400);
134
- * }
135
- * throw error;
136
- * }
137
- * });
138
- * ```
139
- */
140
- export async function parseTenantRequest(request) {
141
- if (request.method !== 'POST') {
142
- throw new TenantRequestError('Only POST method is supported');
143
- }
144
- let body;
145
- try {
146
- body = await request.json();
147
- }
148
- catch (_error) {
149
- throw new TenantRequestError('Invalid JSON in request body');
150
- }
151
- if (typeof body !== 'object' || body === null) {
152
- throw new TenantRequestError('Request body must be an object');
153
- }
154
- const tenantRequest = body;
155
- // Validate required fields
156
- if (!tenantRequest.appId) {
157
- throw new TenantRequestError('Missing required field: appId');
158
- }
159
- if (!tenantRequest.companyId) {
160
- throw new TenantRequestError('Missing required field: companyId');
161
- }
162
- if (!tenantRequest.companyName) {
163
- throw new TenantRequestError('Missing required field: companyName');
164
- }
165
- if (!tenantRequest.environmentType) {
166
- throw new TenantRequestError('Missing required field: environmentType');
167
- }
168
- if (!tenantRequest.email) {
169
- throw new TenantRequestError('Missing required field: email');
170
- }
171
- if (!tenantRequest.webhookUrl) {
172
- throw new TenantRequestError('Missing required field: webhookUrl');
173
- }
174
- // Validate environmentType enum
175
- const validEnvironmentTypes = ['POC', 'DEV', 'QA', 'PROD'];
176
- if (!validEnvironmentTypes.includes(tenantRequest.environmentType)) {
177
- throw new TenantRequestError(`Invalid environmentType: ${tenantRequest.environmentType}. Must be one of: ${validEnvironmentTypes.join(', ')}`);
178
- }
179
- // Validate webhookUrl is a valid URL
180
- try {
181
- new URL(tenantRequest.webhookUrl);
182
- }
183
- catch {
184
- throw new TenantRequestError('Invalid webhookUrl: must be a valid URL');
185
- }
186
- // At this point, all required fields are validated and non-null
187
- // Extract them to satisfy TypeScript's type narrowing
188
- const appId = tenantRequest.appId;
189
- const companyId = tenantRequest.companyId;
190
- const companyName = tenantRequest.companyName;
191
- const environmentType = tenantRequest.environmentType;
192
- const email = tenantRequest.email;
193
- const webhookUrl = tenantRequest.webhookUrl;
194
- return {
195
- appId,
196
- companyId,
197
- companyName,
198
- environmentType,
199
- email,
200
- webhookUrl,
201
- };
202
- }
203
- /**
204
- * Send a webhook update to ESVS with tenant creation status.
205
- *
206
- * @param webhookUrl - The webhook URL provided in the tenant creation request
207
- * @param payload - The webhook payload with status and tenant information
208
- * @throws Never throws - errors are logged but not propagated to avoid breaking tenant creation
209
- *
210
- * @example
211
- * ```typescript
212
- * // Send initial status
213
- * await sendTenantWebhook(tenantRequest.webhookUrl, {
214
- * companyId: tenantRequest.companyId,
215
- * status: 'processing',
216
- * });
217
- *
218
- * // Send completion status
219
- * await sendTenantWebhook(tenantRequest.webhookUrl, {
220
- * companyId: tenantRequest.companyId,
221
- * status: 'completed',
222
- * tenantUrl: 'https://app.example.com/tenants/tenant-123',
223
- * });
224
- * ```
225
- */
226
- export async function sendTenantWebhook(webhookUrl, payload) {
227
- try {
228
- const response = await fetch(webhookUrl, {
229
- method: 'POST',
230
- headers: {
231
- 'Content-Type': 'application/json',
232
- },
233
- body: JSON.stringify(payload),
234
- });
235
- if (!response.ok) {
236
- console.error(`Failed to send webhook update: ${response.status} ${response.statusText}`);
237
- }
238
- }
239
- catch (error) {
240
- console.error('Failed to send webhook update:', error);
241
- // Don't throw - webhook failures shouldn't break tenant creation
242
- }
243
- }
244
- /**
245
- * In-memory tenant store implementation using Maps.
246
- *
247
- * Suitable for:
248
- * - Development and testing
249
- * - Single-server deployments
250
- * - Applications without high availability requirements
251
- *
252
- * NOT suitable for:
253
- * - Multi-server deployments (tenants not shared)
254
- * - High availability scenarios (tenants lost on restart)
255
- * - Production applications with distributed architecture
256
- *
257
- * For production, implement TenantStore with Redis or a database.
258
- *
259
- * @template TExtended - Type-safe custom data that consumers can add to tenants
260
- */
261
- export class InMemoryTenantStore {
262
- constructor() {
263
- /** Primary storage: appId -> tenant */
264
- this.tenants = new Map();
265
- /** Secondary index: companyId -> Set of appIds (since one company can have multiple apps) */
266
- this.companyIdIndex = new Map();
267
- }
268
- async get(appId) {
269
- return this.tenants.get(appId) ?? null;
270
- }
271
- async getByCompanyId(companyId) {
272
- const appIds = this.companyIdIndex.get(companyId);
273
- if (!appIds || appIds.size === 0)
274
- return [];
275
- const tenants = [];
276
- for (const appId of appIds) {
277
- const tenant = this.tenants.get(appId);
278
- if (tenant) {
279
- tenants.push(tenant);
280
- }
281
- }
282
- return tenants;
283
- }
284
- async list() {
285
- return Array.from(this.tenants.values());
286
- }
287
- async upsert(tenant) {
288
- const existing = this.tenants.get(tenant.appId);
289
- // Clean up old index if companyId changed
290
- if (existing && existing.companyId !== tenant.companyId) {
291
- const oldAppIds = this.companyIdIndex.get(existing.companyId);
292
- if (oldAppIds) {
293
- oldAppIds.delete(tenant.appId);
294
- if (oldAppIds.size === 0) {
295
- this.companyIdIndex.delete(existing.companyId);
296
- }
297
- }
298
- }
299
- // Store the tenant
300
- this.tenants.set(tenant.appId, tenant);
301
- // Update index (companyId -> Set of appIds)
302
- let appIds = this.companyIdIndex.get(tenant.companyId);
303
- if (!appIds) {
304
- appIds = new Set();
305
- this.companyIdIndex.set(tenant.companyId, appIds);
306
- }
307
- appIds.add(tenant.appId);
308
- return tenant;
309
- }
310
- async delete(appId) {
311
- const tenant = this.tenants.get(appId);
312
- if (tenant) {
313
- // Clean up index
314
- const appIds = this.companyIdIndex.get(tenant.companyId);
315
- if (appIds) {
316
- appIds.delete(appId);
317
- if (appIds.size === 0) {
318
- this.companyIdIndex.delete(tenant.companyId);
319
- }
320
- }
321
- }
322
- this.tenants.delete(appId);
323
- }
324
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Base user with simple, developer-friendly attributes.
3
- * Extended by User (SSO) and EnterpriseUser (SCIM).
4
- */
5
- export interface BaseUser {
6
- /**
7
- * Unique identifier for the user
8
- */
9
- id?: string;
10
- /**
11
- * REQUIRED. Unique identifier for login
12
- */
13
- userName: string;
14
- /**
15
- * REQUIRED. Simple display name
16
- */
17
- name: string;
18
- /**
19
- * REQUIRED. Primary email address
20
- */
21
- email: string;
22
- /**
23
- * URL to user's avatar/profile picture
24
- */
25
- avatarUrl?: string;
26
- }
27
- //# sourceMappingURL=base-user.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-user.d.ts","sourceRoot":"","sources":["../../src/types/base-user.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1 +0,0 @@
1
- export {};