@drttix/drt-sdk 1.0.1 → 1.0.2
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/.claude/admin-auth/auth.middleware.ts.txt +149 -0
- package/.claude/admin-auth/superuser.middleware.ts.txt +41 -0
- package/dist/cjs/src/generated/portal/core/OpenAPI.js +1 -1
- package/dist/cjs/src/scripts/generate-definition.js +24 -0
- package/dist/cjs/src/staging/index.d.ts +4 -0
- package/dist/cjs/src/staging/portal.d.ts +8 -0
- package/dist/cjs/src/staging/portal.js +9 -1
- package/dist/esm/src/generated/portal/core/OpenAPI.js +1 -1
- package/dist/esm/src/scripts/generate-definition.js +24 -0
- package/dist/esm/src/staging/index.d.ts +4 -0
- package/dist/esm/src/staging/portal.d.ts +8 -0
- package/dist/esm/src/staging/portal.js +9 -1
- package/package.json +1 -1
- package/src/generated/portal/core/OpenAPI.ts +1 -1
- package/src/scripts/generate-definition.ts +29 -0
- package/src/staging/portal.ts +82 -73
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ForbiddenException,
|
|
3
|
+
Injectable,
|
|
4
|
+
Logger,
|
|
5
|
+
NestMiddleware,
|
|
6
|
+
UnauthorizedException,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { NextFunction, Request, Response } from 'express';
|
|
9
|
+
import { ErrorCode } from '../shared/consts/errorCodes';
|
|
10
|
+
import { EXCEPTION_PATHS, HEADER_STUDIO_KEY } from '../shared/consts/values';
|
|
11
|
+
import { MssqlService } from '../database/mssql/services/mssql.service';
|
|
12
|
+
import { CacheService } from '../shared/service/cache.service';
|
|
13
|
+
import { CommonService } from '../shared/service/common.service';
|
|
14
|
+
import { DRT } from '@drttix/drt-api';
|
|
15
|
+
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class AuthMiddleware implements NestMiddleware {
|
|
18
|
+
constructor(
|
|
19
|
+
private readonly msSqlService: MssqlService,
|
|
20
|
+
private readonly cacheService: CacheService,
|
|
21
|
+
private readonly commonService: CommonService,
|
|
22
|
+
private readonly logger: Logger,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
async use(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
26
|
+
const headerStudioId = Number(req.headers[HEADER_STUDIO_KEY]);
|
|
27
|
+
|
|
28
|
+
if (!headerStudioId) {
|
|
29
|
+
throw new UnauthorizedException(ErrorCode.MISSING_STUDIO_ID);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const shopperGuidKey =
|
|
33
|
+
this.commonService.formatShopperGuid(headerStudioId);
|
|
34
|
+
|
|
35
|
+
let shopperGuid = req.cookies[shopperGuidKey];
|
|
36
|
+
|
|
37
|
+
if (!shopperGuid) {
|
|
38
|
+
shopperGuid = this.commonService.getFormattedGuid();
|
|
39
|
+
this.logger.log(
|
|
40
|
+
`[Middleware] Generated NEW shopperGuid=${shopperGuid}`,
|
|
41
|
+
);
|
|
42
|
+
} else {
|
|
43
|
+
this.logger.log(
|
|
44
|
+
`[Middleware] Using EXISTING cookie shopperGuid=${shopperGuid}`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const clientIp = req.ip as string;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
await this.msSqlService.checkSession(
|
|
52
|
+
headerStudioId,
|
|
53
|
+
shopperGuid,
|
|
54
|
+
clientIp,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Call is here to seed the session service with the correct session.
|
|
58
|
+
// TODO: Replace this and the above checkSession
|
|
59
|
+
await DRT.session.getSession(shopperGuid, headerStudioId);
|
|
60
|
+
|
|
61
|
+
this.setCookie(res, shopperGuidKey, shopperGuid);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
this.logger.error(error);
|
|
64
|
+
throw new UnauthorizedException(ErrorCode.UNAUTHORIZED);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// If the route is not in the exceptions list, validate the session and permissions
|
|
68
|
+
this.logger.log(
|
|
69
|
+
`[Middleware] req.baseUrl="${req.baseUrl}", req.path="${req.path}", req.originalUrl="${req.originalUrl}"`,
|
|
70
|
+
);
|
|
71
|
+
if (!EXCEPTION_PATHS.includes(req.baseUrl)) {
|
|
72
|
+
const isValidLogin = await this.cacheService.checkStudioLogin(
|
|
73
|
+
shopperGuid,
|
|
74
|
+
Number(headerStudioId),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (!isValidLogin) {
|
|
78
|
+
throw new UnauthorizedException(ErrorCode.INVALID_LOGIN);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const isUserPrimary = await this.msSqlService.getPrimaryStatus(
|
|
82
|
+
shopperGuid,
|
|
83
|
+
Number(headerStudioId),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const isValid = await this.validateRoute(
|
|
87
|
+
req.baseUrl,
|
|
88
|
+
req.method,
|
|
89
|
+
shopperGuid,
|
|
90
|
+
isUserPrimary,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
if (!isValid) {
|
|
94
|
+
throw new ForbiddenException(ErrorCode.FORBIDDEN);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
req.cookies = { [`${shopperGuidKey}`]: shopperGuid };
|
|
99
|
+
next();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setCookie(res: Response, key: string, value: string | number): void {
|
|
103
|
+
res.cookie(key, value, {
|
|
104
|
+
httpOnly: true,
|
|
105
|
+
secure: true,
|
|
106
|
+
sameSite: 'lax',
|
|
107
|
+
path: '/',
|
|
108
|
+
// eslint-disable-next-line no-magic-numbers
|
|
109
|
+
maxAge: 60 * 60 * 24,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async validateRoute(
|
|
114
|
+
currentRoute: string,
|
|
115
|
+
currentMethod: string,
|
|
116
|
+
shopperGuid: string,
|
|
117
|
+
isUserPrimary: number,
|
|
118
|
+
): Promise<boolean> {
|
|
119
|
+
const cachedRoutes = await this.cacheService.getCachedRoutes();
|
|
120
|
+
// Replace numbers in the route with a generic 'id'
|
|
121
|
+
currentRoute = currentRoute.replace(/\d+/g, 'id');
|
|
122
|
+
|
|
123
|
+
const routeMatch = cachedRoutes.find(
|
|
124
|
+
route =>
|
|
125
|
+
route.route === currentRoute && route.method === currentMethod,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
if (!routeMatch) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (routeMatch.primaryUserOnly === 1 && isUserPrimary !== 1) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (routeMatch.rejectOnFail === 0) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const portalObjects =
|
|
141
|
+
await this.cacheService.getUserPermissions(shopperGuid);
|
|
142
|
+
|
|
143
|
+
if (portalObjects.some(item => item.id === routeMatch.portalObjectId)) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ForbiddenException,
|
|
3
|
+
Injectable,
|
|
4
|
+
Logger,
|
|
5
|
+
NestMiddleware,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { NextFunction, Request, Response } from 'express';
|
|
8
|
+
import { MssqlService } from '../database/mssql/services/mssql.service';
|
|
9
|
+
import { ErrorCode } from '../shared/consts/errorCodes';
|
|
10
|
+
import { HEADER_STUDIO_KEY } from '../shared/consts/values';
|
|
11
|
+
import { CommonService } from '../shared/service/common.service';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class SuperUserMiddleware implements NestMiddleware {
|
|
15
|
+
constructor(
|
|
16
|
+
private readonly msSqlService: MssqlService,
|
|
17
|
+
private readonly commonService: CommonService,
|
|
18
|
+
private readonly logger: Logger,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
async use(req: Request, res: Response, next: NextFunction): Promise<void> {
|
|
22
|
+
const headerStudioId = Number(req.headers[HEADER_STUDIO_KEY]);
|
|
23
|
+
|
|
24
|
+
const shopperGuidKey =
|
|
25
|
+
this.commonService.formatShopperGuid(headerStudioId);
|
|
26
|
+
|
|
27
|
+
let shopperGuid = req.cookies[shopperGuidKey];
|
|
28
|
+
|
|
29
|
+
const adminDetails =
|
|
30
|
+
await this.msSqlService.getAdminDetails(shopperGuid);
|
|
31
|
+
|
|
32
|
+
if (adminDetails.superuser !== 1) {
|
|
33
|
+
this.logger.log(
|
|
34
|
+
`Unauthorized access attempt to superuser route by shopperGuid: ${shopperGuid} on Studio: ${headerStudioId}`,
|
|
35
|
+
);
|
|
36
|
+
throw new ForbiddenException(ErrorCode.FORBIDDEN);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
next();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -68,3 +68,27 @@ output += `// Re-export all types as a namespace\n`;
|
|
|
68
68
|
output += `export * as ${typesNamespace} from "../generated/${serviceName}/types";\n`;
|
|
69
69
|
fs_1.default.writeFileSync(OUTPUT_FILE, output);
|
|
70
70
|
console.log(`✅ Wrote ${serviceName} definition to: ${OUTPUT_FILE}`);
|
|
71
|
+
// If generating the portal, also regenerate the staging portal definition
|
|
72
|
+
if (serviceName === 'portal') {
|
|
73
|
+
const STAGING_FILE = path_1.default.resolve('src/staging/portal.ts');
|
|
74
|
+
const stagingImports = [
|
|
75
|
+
`import { OpenAPI as PortalOpenAPI } from "../generated/portal/core/OpenAPI";`,
|
|
76
|
+
`import { wrapServiceForStaging, STAGING_URLS } from "./wrapService";`,
|
|
77
|
+
``,
|
|
78
|
+
...services.map((s) => `import { ${s} } from "../generated/portal";`),
|
|
79
|
+
];
|
|
80
|
+
const stagingKeys = services
|
|
81
|
+
.map((s) => `\t${s.replace('Service', '').toLowerCase()}: wrap(${s}),`)
|
|
82
|
+
.join('\n');
|
|
83
|
+
let stagingOutput = `// AUTO-GENERATED FILE – DO NOT EDIT\n\n`;
|
|
84
|
+
stagingOutput += stagingImports.join('\n') + '\n\n';
|
|
85
|
+
stagingOutput += `const wrap = <T extends object>(service: T) =>\n`;
|
|
86
|
+
stagingOutput += `\twrapServiceForStaging(service, PortalOpenAPI, STAGING_URLS.portal);\n\n`;
|
|
87
|
+
stagingOutput += `export const portalStaging = {\n`;
|
|
88
|
+
stagingOutput += stagingKeys + '\n';
|
|
89
|
+
stagingOutput += `};\n\n`;
|
|
90
|
+
stagingOutput += `// Re-export types\n`;
|
|
91
|
+
stagingOutput += `export * as PortalTypes from "../generated/portal/types";\n`;
|
|
92
|
+
fs_1.default.writeFileSync(STAGING_FILE, stagingOutput);
|
|
93
|
+
console.log(`✅ Wrote staging portal definition to: ${STAGING_FILE}`);
|
|
94
|
+
}
|
|
@@ -68,6 +68,10 @@ export declare const DRT: {
|
|
|
68
68
|
reports: typeof import("../generated/portal").ReportsService;
|
|
69
69
|
settings: typeof import("../generated/portal").SettingsService;
|
|
70
70
|
shows: typeof import("../generated/portal").ShowsService;
|
|
71
|
+
superuserabandonedcarts: typeof import("../generated/portal").SuperUserAbandonedCartsService;
|
|
72
|
+
superuserbuyerblacklist: typeof import("../generated/portal").SuperUserBuyerBlacklistService;
|
|
73
|
+
superuserreleasedtickets: typeof import("../generated/portal").SuperUserReleasedTicketsService;
|
|
74
|
+
superusersupporttickets: typeof import("../generated/portal").SuperUserSupportTicketsService;
|
|
71
75
|
};
|
|
72
76
|
init: typeof init;
|
|
73
77
|
isReady: typeof isReady;
|
|
@@ -28,6 +28,10 @@ import { OrderLookupService } from "../generated/portal";
|
|
|
28
28
|
import { ReportsService } from "../generated/portal";
|
|
29
29
|
import { SettingsService } from "../generated/portal";
|
|
30
30
|
import { ShowsService } from "../generated/portal";
|
|
31
|
+
import { SuperUserAbandonedCartsService } from "../generated/portal";
|
|
32
|
+
import { SuperUserBuyerBlacklistService } from "../generated/portal";
|
|
33
|
+
import { SuperUserReleasedTicketsService } from "../generated/portal";
|
|
34
|
+
import { SuperUserSupportTicketsService } from "../generated/portal";
|
|
31
35
|
export declare const portalStaging: {
|
|
32
36
|
account: typeof AccountService;
|
|
33
37
|
accounting: typeof AccountingService;
|
|
@@ -59,5 +63,9 @@ export declare const portalStaging: {
|
|
|
59
63
|
reports: typeof ReportsService;
|
|
60
64
|
settings: typeof SettingsService;
|
|
61
65
|
shows: typeof ShowsService;
|
|
66
|
+
superuserabandonedcarts: typeof SuperUserAbandonedCartsService;
|
|
67
|
+
superuserbuyerblacklist: typeof SuperUserBuyerBlacklistService;
|
|
68
|
+
superuserreleasedtickets: typeof SuperUserReleasedTicketsService;
|
|
69
|
+
superusersupporttickets: typeof SuperUserSupportTicketsService;
|
|
62
70
|
};
|
|
63
71
|
export * as PortalTypes from "../generated/portal/types";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// AUTO-GENERATED FILE – DO NOT EDIT
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -34,7 +35,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
35
|
})();
|
|
35
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
37
|
exports.PortalTypes = exports.portalStaging = void 0;
|
|
37
|
-
// Staging portal services - wraps all portal services to use staging API
|
|
38
38
|
const OpenAPI_1 = require("../generated/portal/core/OpenAPI");
|
|
39
39
|
const wrapService_1 = require("./wrapService");
|
|
40
40
|
const portal_1 = require("../generated/portal");
|
|
@@ -67,6 +67,10 @@ const portal_27 = require("../generated/portal");
|
|
|
67
67
|
const portal_28 = require("../generated/portal");
|
|
68
68
|
const portal_29 = require("../generated/portal");
|
|
69
69
|
const portal_30 = require("../generated/portal");
|
|
70
|
+
const portal_31 = require("../generated/portal");
|
|
71
|
+
const portal_32 = require("../generated/portal");
|
|
72
|
+
const portal_33 = require("../generated/portal");
|
|
73
|
+
const portal_34 = require("../generated/portal");
|
|
70
74
|
const wrap = (service) => (0, wrapService_1.wrapServiceForStaging)(service, OpenAPI_1.OpenAPI, wrapService_1.STAGING_URLS.portal);
|
|
71
75
|
exports.portalStaging = {
|
|
72
76
|
account: wrap(portal_1.AccountService),
|
|
@@ -99,6 +103,10 @@ exports.portalStaging = {
|
|
|
99
103
|
reports: wrap(portal_28.ReportsService),
|
|
100
104
|
settings: wrap(portal_29.SettingsService),
|
|
101
105
|
shows: wrap(portal_30.ShowsService),
|
|
106
|
+
superuserabandonedcarts: wrap(portal_31.SuperUserAbandonedCartsService),
|
|
107
|
+
superuserbuyerblacklist: wrap(portal_32.SuperUserBuyerBlacklistService),
|
|
108
|
+
superuserreleasedtickets: wrap(portal_33.SuperUserReleasedTicketsService),
|
|
109
|
+
superusersupporttickets: wrap(portal_34.SuperUserSupportTicketsService),
|
|
102
110
|
};
|
|
103
111
|
// Re-export types
|
|
104
112
|
exports.PortalTypes = __importStar(require("../generated/portal/types"));
|
|
@@ -63,3 +63,27 @@ output += `// Re-export all types as a namespace\n`;
|
|
|
63
63
|
output += `export * as ${typesNamespace} from "../generated/${serviceName}/types.js";\n`;
|
|
64
64
|
fs.writeFileSync(OUTPUT_FILE, output);
|
|
65
65
|
console.log(`✅ Wrote ${serviceName} definition to: ${OUTPUT_FILE}`);
|
|
66
|
+
// If generating the portal, also regenerate the staging portal definition
|
|
67
|
+
if (serviceName === 'portal') {
|
|
68
|
+
const STAGING_FILE = path.resolve('src/staging/portal.ts');
|
|
69
|
+
const stagingImports = [
|
|
70
|
+
`import { OpenAPI as PortalOpenAPI } from "../generated/portal/core/OpenAPI.js";`,
|
|
71
|
+
`import { wrapServiceForStaging, STAGING_URLS } from "./wrapService.js";`,
|
|
72
|
+
``,
|
|
73
|
+
...services.map((s) => `import { ${s} } from "../generated/portal/index.js";`),
|
|
74
|
+
];
|
|
75
|
+
const stagingKeys = services
|
|
76
|
+
.map((s) => `\t${s.replace('Service', '').toLowerCase()}: wrap(${s}),`)
|
|
77
|
+
.join('\n');
|
|
78
|
+
let stagingOutput = `// AUTO-GENERATED FILE – DO NOT EDIT\n\n`;
|
|
79
|
+
stagingOutput += stagingImports.join('\n') + '\n\n';
|
|
80
|
+
stagingOutput += `const wrap = <T extends object>(service: T) =>\n`;
|
|
81
|
+
stagingOutput += `\twrapServiceForStaging(service, PortalOpenAPI, STAGING_URLS.portal);\n\n`;
|
|
82
|
+
stagingOutput += `export const portalStaging = {\n`;
|
|
83
|
+
stagingOutput += stagingKeys + '\n';
|
|
84
|
+
stagingOutput += `};\n\n`;
|
|
85
|
+
stagingOutput += `// Re-export types\n`;
|
|
86
|
+
stagingOutput += `export * as PortalTypes from "../generated/portal/types.js";\n`;
|
|
87
|
+
fs.writeFileSync(STAGING_FILE, stagingOutput);
|
|
88
|
+
console.log(`✅ Wrote staging portal definition to: ${STAGING_FILE}`);
|
|
89
|
+
}
|
|
@@ -68,6 +68,10 @@ export declare const DRT: {
|
|
|
68
68
|
reports: typeof import("../generated/portal").ReportsService;
|
|
69
69
|
settings: typeof import("../generated/portal").SettingsService;
|
|
70
70
|
shows: typeof import("../generated/portal").ShowsService;
|
|
71
|
+
superuserabandonedcarts: typeof import("../generated/portal").SuperUserAbandonedCartsService;
|
|
72
|
+
superuserbuyerblacklist: typeof import("../generated/portal").SuperUserBuyerBlacklistService;
|
|
73
|
+
superuserreleasedtickets: typeof import("../generated/portal").SuperUserReleasedTicketsService;
|
|
74
|
+
superusersupporttickets: typeof import("../generated/portal").SuperUserSupportTicketsService;
|
|
71
75
|
};
|
|
72
76
|
init: typeof init;
|
|
73
77
|
isReady: typeof isReady;
|
|
@@ -28,6 +28,10 @@ import { OrderLookupService } from "../generated/portal";
|
|
|
28
28
|
import { ReportsService } from "../generated/portal";
|
|
29
29
|
import { SettingsService } from "../generated/portal";
|
|
30
30
|
import { ShowsService } from "../generated/portal";
|
|
31
|
+
import { SuperUserAbandonedCartsService } from "../generated/portal";
|
|
32
|
+
import { SuperUserBuyerBlacklistService } from "../generated/portal";
|
|
33
|
+
import { SuperUserReleasedTicketsService } from "../generated/portal";
|
|
34
|
+
import { SuperUserSupportTicketsService } from "../generated/portal";
|
|
31
35
|
export declare const portalStaging: {
|
|
32
36
|
account: typeof AccountService;
|
|
33
37
|
accounting: typeof AccountingService;
|
|
@@ -59,5 +63,9 @@ export declare const portalStaging: {
|
|
|
59
63
|
reports: typeof ReportsService;
|
|
60
64
|
settings: typeof SettingsService;
|
|
61
65
|
shows: typeof ShowsService;
|
|
66
|
+
superuserabandonedcarts: typeof SuperUserAbandonedCartsService;
|
|
67
|
+
superuserbuyerblacklist: typeof SuperUserBuyerBlacklistService;
|
|
68
|
+
superuserreleasedtickets: typeof SuperUserReleasedTicketsService;
|
|
69
|
+
superusersupporttickets: typeof SuperUserSupportTicketsService;
|
|
62
70
|
};
|
|
63
71
|
export * as PortalTypes from "../generated/portal/types";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// AUTO-GENERATED FILE – DO NOT EDIT
|
|
2
2
|
import { OpenAPI as PortalOpenAPI } from "../generated/portal/core/OpenAPI.js";
|
|
3
3
|
import { wrapServiceForStaging, STAGING_URLS } from "./wrapService.js";
|
|
4
4
|
import { AccountService } from "../generated/portal/index.js";
|
|
@@ -31,6 +31,10 @@ import { OrderLookupService } from "../generated/portal/index.js";
|
|
|
31
31
|
import { ReportsService } from "../generated/portal/index.js";
|
|
32
32
|
import { SettingsService } from "../generated/portal/index.js";
|
|
33
33
|
import { ShowsService } from "../generated/portal/index.js";
|
|
34
|
+
import { SuperUserAbandonedCartsService } from "../generated/portal/index.js";
|
|
35
|
+
import { SuperUserBuyerBlacklistService } from "../generated/portal/index.js";
|
|
36
|
+
import { SuperUserReleasedTicketsService } from "../generated/portal/index.js";
|
|
37
|
+
import { SuperUserSupportTicketsService } from "../generated/portal/index.js";
|
|
34
38
|
const wrap = (service) => wrapServiceForStaging(service, PortalOpenAPI, STAGING_URLS.portal);
|
|
35
39
|
export const portalStaging = {
|
|
36
40
|
account: wrap(AccountService),
|
|
@@ -63,6 +67,10 @@ export const portalStaging = {
|
|
|
63
67
|
reports: wrap(ReportsService),
|
|
64
68
|
settings: wrap(SettingsService),
|
|
65
69
|
shows: wrap(ShowsService),
|
|
70
|
+
superuserabandonedcarts: wrap(SuperUserAbandonedCartsService),
|
|
71
|
+
superuserbuyerblacklist: wrap(SuperUserBuyerBlacklistService),
|
|
72
|
+
superuserreleasedtickets: wrap(SuperUserReleasedTicketsService),
|
|
73
|
+
superusersupporttickets: wrap(SuperUserSupportTicketsService),
|
|
66
74
|
};
|
|
67
75
|
// Re-export types
|
|
68
76
|
export * as PortalTypes from "../generated/portal/types.js";
|
package/package.json
CHANGED
|
@@ -87,3 +87,32 @@ output += `export * as ${typesNamespace} from "../generated/${serviceName}/types
|
|
|
87
87
|
|
|
88
88
|
fs.writeFileSync(OUTPUT_FILE, output);
|
|
89
89
|
console.log(`✅ Wrote ${serviceName} definition to: ${OUTPUT_FILE}`);
|
|
90
|
+
|
|
91
|
+
// If generating the portal, also regenerate the staging portal definition
|
|
92
|
+
if (serviceName === 'portal') {
|
|
93
|
+
const STAGING_FILE = path.resolve('src/staging/portal.ts');
|
|
94
|
+
|
|
95
|
+
const stagingImports = [
|
|
96
|
+
`import { OpenAPI as PortalOpenAPI } from "../generated/portal/core/OpenAPI";`,
|
|
97
|
+
`import { wrapServiceForStaging, STAGING_URLS } from "./wrapService";`,
|
|
98
|
+
``,
|
|
99
|
+
...services.map((s) => `import { ${s} } from "../generated/portal";`),
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const stagingKeys = services
|
|
103
|
+
.map((s) => `\t${s.replace('Service', '').toLowerCase()}: wrap(${s}),`)
|
|
104
|
+
.join('\n');
|
|
105
|
+
|
|
106
|
+
let stagingOutput = `// AUTO-GENERATED FILE – DO NOT EDIT\n\n`;
|
|
107
|
+
stagingOutput += stagingImports.join('\n') + '\n\n';
|
|
108
|
+
stagingOutput += `const wrap = <T extends object>(service: T) =>\n`;
|
|
109
|
+
stagingOutput += `\twrapServiceForStaging(service, PortalOpenAPI, STAGING_URLS.portal);\n\n`;
|
|
110
|
+
stagingOutput += `export const portalStaging = {\n`;
|
|
111
|
+
stagingOutput += stagingKeys + '\n';
|
|
112
|
+
stagingOutput += `};\n\n`;
|
|
113
|
+
stagingOutput += `// Re-export types\n`;
|
|
114
|
+
stagingOutput += `export * as PortalTypes from "../generated/portal/types";\n`;
|
|
115
|
+
|
|
116
|
+
fs.writeFileSync(STAGING_FILE, stagingOutput);
|
|
117
|
+
console.log(`✅ Wrote staging portal definition to: ${STAGING_FILE}`);
|
|
118
|
+
}
|
package/src/staging/portal.ts
CHANGED
|
@@ -1,73 +1,82 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
// AUTO-GENERATED FILE – DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import { OpenAPI as PortalOpenAPI } from "../generated/portal/core/OpenAPI";
|
|
4
|
+
import { wrapServiceForStaging, STAGING_URLS } from "./wrapService";
|
|
5
|
+
|
|
6
|
+
import { AccountService } from "../generated/portal";
|
|
7
|
+
import { AccountingService } from "../generated/portal";
|
|
8
|
+
import { AppService } from "../generated/portal";
|
|
9
|
+
import { AuthService } from "../generated/portal";
|
|
10
|
+
import { BookmarkService } from "../generated/portal";
|
|
11
|
+
import { ClientToolsGeneratedEmailsService } from "../generated/portal";
|
|
12
|
+
import { ClientToolsParentLetterService } from "../generated/portal";
|
|
13
|
+
import { ClientToolsPatronDatabaseService } from "../generated/portal";
|
|
14
|
+
import { ClientToolsSeatAssignmentToolService } from "../generated/portal";
|
|
15
|
+
import { ClientToolsStripeOnboardingService } from "../generated/portal";
|
|
16
|
+
import { ClientToolsThemeBuilderService } from "../generated/portal";
|
|
17
|
+
import { ClientToolsThemesLibraryService } from "../generated/portal";
|
|
18
|
+
import { ClientToolsTicketingLinkService } from "../generated/portal";
|
|
19
|
+
import { ClientToolsTicketScanningService } from "../generated/portal";
|
|
20
|
+
import { ClientToolsUnapprovedOrdersService } from "../generated/portal";
|
|
21
|
+
import { ClientToolsWaitlistService } from "../generated/portal";
|
|
22
|
+
import { DashboardService } from "../generated/portal";
|
|
23
|
+
import { FeaturesBlockedSeatsService } from "../generated/portal";
|
|
24
|
+
import { FeaturesCheckoutQuestionsService } from "../generated/portal";
|
|
25
|
+
import { FeaturesDiscountsService } from "../generated/portal";
|
|
26
|
+
import { FeaturesDonationsService } from "../generated/portal";
|
|
27
|
+
import { FeaturesGiftCardsService } from "../generated/portal";
|
|
28
|
+
import { FeaturesGoldenTicketsService } from "../generated/portal";
|
|
29
|
+
import { FeaturesLandingPageService } from "../generated/portal";
|
|
30
|
+
import { FeaturesPriorityService } from "../generated/portal";
|
|
31
|
+
import { FeaturesProductsService } from "../generated/portal";
|
|
32
|
+
import { OrderLookupService } from "../generated/portal";
|
|
33
|
+
import { ReportsService } from "../generated/portal";
|
|
34
|
+
import { SettingsService } from "../generated/portal";
|
|
35
|
+
import { ShowsService } from "../generated/portal";
|
|
36
|
+
import { SuperUserAbandonedCartsService } from "../generated/portal";
|
|
37
|
+
import { SuperUserBuyerBlacklistService } from "../generated/portal";
|
|
38
|
+
import { SuperUserReleasedTicketsService } from "../generated/portal";
|
|
39
|
+
import { SuperUserSupportTicketsService } from "../generated/portal";
|
|
40
|
+
|
|
41
|
+
const wrap = <T extends object>(service: T) =>
|
|
42
|
+
wrapServiceForStaging(service, PortalOpenAPI, STAGING_URLS.portal);
|
|
43
|
+
|
|
44
|
+
export const portalStaging = {
|
|
45
|
+
account: wrap(AccountService),
|
|
46
|
+
accounting: wrap(AccountingService),
|
|
47
|
+
app: wrap(AppService),
|
|
48
|
+
auth: wrap(AuthService),
|
|
49
|
+
bookmark: wrap(BookmarkService),
|
|
50
|
+
clienttoolsgeneratedemails: wrap(ClientToolsGeneratedEmailsService),
|
|
51
|
+
clienttoolsparentletter: wrap(ClientToolsParentLetterService),
|
|
52
|
+
clienttoolspatrondatabase: wrap(ClientToolsPatronDatabaseService),
|
|
53
|
+
clienttoolsseatassignmenttool: wrap(ClientToolsSeatAssignmentToolService),
|
|
54
|
+
clienttoolsstripeonboarding: wrap(ClientToolsStripeOnboardingService),
|
|
55
|
+
clienttoolsthemebuilder: wrap(ClientToolsThemeBuilderService),
|
|
56
|
+
clienttoolsthemeslibrary: wrap(ClientToolsThemesLibraryService),
|
|
57
|
+
clienttoolsticketinglink: wrap(ClientToolsTicketingLinkService),
|
|
58
|
+
clienttoolsticketscanning: wrap(ClientToolsTicketScanningService),
|
|
59
|
+
clienttoolsunapprovedorders: wrap(ClientToolsUnapprovedOrdersService),
|
|
60
|
+
clienttoolswaitlist: wrap(ClientToolsWaitlistService),
|
|
61
|
+
dashboard: wrap(DashboardService),
|
|
62
|
+
featuresblockedseats: wrap(FeaturesBlockedSeatsService),
|
|
63
|
+
featurescheckoutquestions: wrap(FeaturesCheckoutQuestionsService),
|
|
64
|
+
featuresdiscounts: wrap(FeaturesDiscountsService),
|
|
65
|
+
featuresdonations: wrap(FeaturesDonationsService),
|
|
66
|
+
featuresgiftcards: wrap(FeaturesGiftCardsService),
|
|
67
|
+
featuresgoldentickets: wrap(FeaturesGoldenTicketsService),
|
|
68
|
+
featureslandingpage: wrap(FeaturesLandingPageService),
|
|
69
|
+
featurespriority: wrap(FeaturesPriorityService),
|
|
70
|
+
featuresproducts: wrap(FeaturesProductsService),
|
|
71
|
+
orderlookup: wrap(OrderLookupService),
|
|
72
|
+
reports: wrap(ReportsService),
|
|
73
|
+
settings: wrap(SettingsService),
|
|
74
|
+
shows: wrap(ShowsService),
|
|
75
|
+
superuserabandonedcarts: wrap(SuperUserAbandonedCartsService),
|
|
76
|
+
superuserbuyerblacklist: wrap(SuperUserBuyerBlacklistService),
|
|
77
|
+
superuserreleasedtickets: wrap(SuperUserReleasedTicketsService),
|
|
78
|
+
superusersupporttickets: wrap(SuperUserSupportTicketsService),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Re-export types
|
|
82
|
+
export * as PortalTypes from "../generated/portal/types";
|