Refactor: Replace organization ID with customer ID in data models and access methods.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/55bdac1c-eb79-41e7-a716-be82bfbdddcd.jpg
This commit is contained in:
alphaeusmote
2025-04-12 00:27:48 +00:00
parent 2164b0bf74
commit 4e63296a65
+12 -6
View File
@@ -342,9 +342,9 @@ export class MemStorage implements IStorage {
return this.domainsMap.get(parseInt(id));
}
async getDomainsByOrganization(organizationId: string): Promise<Domain[]> {
async getDomainsByCustomer(customerId: string): Promise<Domain[]> {
return Array.from(this.domainsMap.values())
.filter(domain => domain.organizationId === organizationId);
.filter(domain => domain.customerId === customerId);
}
async getAllDomains(): Promise<Domain[]> {
@@ -358,7 +358,7 @@ export class MemStorage implements IStorage {
const newDomain: Domain = {
id: numId.toString(),
name: domain.name,
organizationId: domain.organizationId!,
customerId: domain.customerId,
providerId: domain.providerId || "1", // Default to the first provider if not specified
isActive: domain.isActive ?? true,
lastUpdated,
@@ -502,9 +502,15 @@ export class MemStorage implements IStorage {
.find(apiToken => apiToken.token === token);
}
async getApiTokensByOrganization(organizationId: string): Promise<ApiToken[]> {
async getApiTokensByCustomer(customerId: string): Promise<ApiToken[]> {
// Get all token-customer access records for this customer
const customerAccess = Array.from(this.apiTokenCustomerAccessMap.values())
.filter(access => access.customerId === customerId);
// Get the tokens with access to this customer
const tokenIds = customerAccess.map(access => access.tokenId);
return Array.from(this.apiTokensMap.values())
.filter(token => token.organizationId === organizationId);
.filter(token => tokenIds.includes(token.id));
}
async createApiToken(token: any): Promise<ApiToken> {
@@ -568,7 +574,7 @@ export class MemStorage implements IStorage {
id: numId.toString(),
name: token.name || "Unnamed Token",
token: token.token || "test_token_" + numId,
organizationId: token.organizationId || "1",
customerId: token.customerId || "1",
permissions: permissions,
role: token.role || 'readonly',
createdBy: token.createdBy || "1",