feat: delete file trash

This commit is contained in:
hanif salafi 2025-10-01 21:59:51 +07:00
parent 0ea29e444d
commit fa01056f51
28 changed files with 0 additions and 1663 deletions

View File

@ -1,66 +0,0 @@
# PowerShell script to add clientId extraction logic to service methods
# Usage: .\add_clientid_extraction.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Adding clientId extraction logic to: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Pattern to find method definitions that need clientId extraction
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\)'
# Find all method matches
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Processing method: $MethodName"
# Skip methods that already have clientId extraction logic
if ($Content -match "func \(_i \*${ServiceName}Service\) ${MethodName}\(authToken string, ${Parameters}\) \{[^}]*Extract clientId from authToken") {
Write-Host " Skipping $MethodName - already has clientId extraction"
continue
}
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "ClientId extraction logic added to service methods."

View File

@ -1,59 +0,0 @@
# PowerShell script to add clientId extraction to remaining methods
# Usage: .\add_clientid_to_remaining.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Adding clientId extraction to remaining methods in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Adding clientId extraction to method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "ClientId extraction added to remaining methods."

View File

@ -1,95 +0,0 @@
-- Debug script untuk mengecek masalah approval flow
-- 1. Cek user level 5
SELECT
id,
level_name,
level_number,
is_approval_active,
client_id
FROM user_levels
WHERE id = 5;
-- 2. Cek user dengan level 5
SELECT
u.id,
u.name,
u.user_level_id,
ul.level_name,
ul.level_number,
ul.is_approval_active
FROM users u
JOIN user_levels ul ON u.user_level_id = ul.id
WHERE u.user_level_id = 5;
-- 3. Cek default workflow
SELECT
id,
name,
is_active,
is_default,
client_id
FROM approval_workflows
WHERE is_default = true
AND is_active = true;
-- 4. Cek workflow steps
SELECT
aws.id,
aws.workflow_id,
aws.step_order,
aws.step_name,
aws.required_user_level_id,
aws.condition_type,
aws.condition_value,
aws.branch_name,
aw.name as workflow_name
FROM approval_workflow_steps aws
JOIN approval_workflows aw ON aws.workflow_id = aw.id
WHERE aw.is_default = true
ORDER BY aws.step_order, aws.branch_order;
-- 5. Cek artikel yang baru dibuat
SELECT
id,
title,
created_by_id,
workflow_id,
current_approval_step,
status_id,
bypass_approval,
approval_exempt,
created_at
FROM articles
WHERE title = 'Test Tni Artikel 1'
ORDER BY created_at DESC;
-- 6. Cek approval flows
SELECT
aaf.id,
aaf.article_id,
aaf.workflow_id,
aaf.current_step,
aaf.current_branch,
aaf.status_id,
aaf.submitted_by_id,
aaf.submitted_at,
a.title as article_title
FROM article_approval_flows aaf
JOIN articles a ON aaf.article_id = a.id
WHERE a.title = 'Test Tni Artikel 1'
ORDER BY aaf.created_at DESC;
-- 7. Cek legacy approval records
SELECT
aa.id,
aa.article_id,
aa.approval_by,
aa.status_id,
aa.message,
aa.approval_at_level,
a.title as article_title
FROM article_approvals aa
JOIN articles a ON aa.article_id = a.id
WHERE a.title = 'Test Tni Artikel 1'
ORDER BY aa.created_at DESC;

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final10.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final11.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final12.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final13.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final14.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final15.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final16.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final2.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final3.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final4.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final5.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final6.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final7.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final8.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_all_article_approval_flows_final9.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All remaining clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues
# Usage: .\fix_all_clientid.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All clientId issues fixed."

View File

@ -1,85 +0,0 @@
-- Script untuk memperbaiki masalah approval flow
-- 1. Pastikan user level 5 memiliki is_approval_active = true
UPDATE user_levels
SET is_approval_active = true
WHERE id = 5;
-- 2. Pastikan workflow yang dibuat adalah default workflow
UPDATE approval_workflows
SET is_default = true, is_active = true
WHERE name = 'Multi-Branch Article Approval';
-- 3. Cek apakah ada workflow default
SELECT
id,
name,
is_active,
is_default,
client_id
FROM approval_workflows
WHERE is_default = true
AND is_active = true;
-- 4. Jika tidak ada default workflow, buat satu
-- (Gunakan ID workflow yang sudah dibuat)
-- UPDATE approval_workflows
-- SET is_default = true
-- WHERE id = YOUR_WORKFLOW_ID;
-- 5. Cek user level 5 setelah update
SELECT
id,
level_name,
level_number,
is_approval_active,
client_id
FROM user_levels
WHERE id = 5;
-- 6. Cek user dengan level 5
SELECT
u.id,
u.name,
u.user_level_id,
ul.level_name,
ul.level_number,
ul.is_approval_active
FROM users u
JOIN user_levels ul ON u.user_level_id = ul.id
WHERE u.user_level_id = 5;
-- 7. Test: Buat artikel baru untuk test
-- Gunakan API atau aplikasi untuk membuat artikel baru
-- dengan user level 5
-- 8. Cek hasil setelah test
SELECT
id,
title,
created_by_id,
workflow_id,
current_approval_step,
status_id,
bypass_approval,
approval_exempt,
created_at
FROM articles
ORDER BY created_at DESC
LIMIT 5;
-- 9. Cek approval flows yang baru dibuat
SELECT
aaf.id,
aaf.article_id,
aaf.workflow_id,
aaf.current_step,
aaf.current_branch,
aaf.status_id,
aaf.submitted_by_id,
aaf.submitted_at,
a.title as article_title
FROM article_approval_flows aaf
JOIN articles a ON aaf.article_id = a.id
ORDER BY aaf.created_at DESC
LIMIT 5;

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all clientId issues in article_approval_flows
# Usage: .\fix_article_approval_flows_clientid.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing all clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "All clientId issues fixed."

View File

@ -1,59 +0,0 @@
# PowerShell script to fix all remaining clientId issues in article_approval_flows
# Usage: .\fix_remaining_article_approval_flows.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find all methods that use clientId but don't have extraction logic
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "Remaining clientId issues fixed."

View File

@ -1,61 +0,0 @@
# PowerShell script to fix remaining clientId issues
# Usage: .\fix_remaining_clientid.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Fixing remaining clientId issues in: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Find methods that don't have clientId extraction logic but use clientId
$MethodPattern = 'func \(_i \*(\w+)Service\) (\w+)\(authToken string, ([^)]+)\) \{[^}]*return _i\.(\w+)Repository\.(\w+)\(clientId,'
$Matches = [regex]::Matches($Content, $MethodPattern)
foreach ($Match in $Matches) {
$ServiceName = $Match.Groups[1].Value
$MethodName = $Match.Groups[2].Value
$Parameters = $Match.Groups[3].Value
$RepositoryName = $Match.Groups[4].Value
$RepositoryMethod = $Match.Groups[5].Value
Write-Host "Fixing method: $MethodName"
# Create the clientId extraction logic
$ExtractionLogic = @"
// Extract clientId from authToken
var clientId *uuid.UUID
if authToken != "" {
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepository, authToken)
if user != nil && user.ClientId != nil {
clientId = user.ClientId
_i.Log.Info().Interface("clientId", clientId).Msg("Extracted clientId from auth token")
}
}
if clientId == nil {
return nil, errors.New("clientId not found in auth token")
}
"@
# Replace the method opening with extraction logic
$OldMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {"
$NewMethodStart = "func (_i *${ServiceName}Service) ${MethodName}(authToken string, ${Parameters}) {${ExtractionLogic}"
$Content = $Content -replace [regex]::Escape($OldMethodStart), $NewMethodStart
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "Remaining clientId issues fixed."

View File

@ -1,43 +0,0 @@
# PowerShell script to replace clientId with authToken in method calls
# Usage: .\replace_clientid_calls.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Replacing clientId with authToken in method calls: $FilePath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Replace patterns where clientId is used as parameter to other methods
$Replacements = @(
@{
Pattern = '_i\.ValidateStepOrder\(clientId, '
Replacement = '_i.ValidateStepOrder(authToken, '
},
@{
Pattern = '_i\.ValidateStep\(clientId, '
Replacement = '_i.ValidateStep(authToken, '
},
@{
Pattern = '_i\.CanDeleteStep\(clientId, '
Replacement = '_i.CanDeleteStep(authToken, '
}
)
foreach ($Replacement in $Replacements) {
$Content = $Content -replace $Replacement.Pattern, $Replacement.Replacement
Write-Host "Replaced: $($Replacement.Pattern)"
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "ClientId method calls replaced with authToken."

View File

@ -1,44 +0,0 @@
# PowerShell script to update service method signatures
# Usage: .\update_service_methods.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Updating service methods in: $FilePath"
# Create backup
$BackupPath = "$FilePath.backup"
Copy-Item $FilePath $BackupPath
Write-Host "Backup created at: $BackupPath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Update method signatures - replace clientId *uuid.UUID with authToken string
$Patterns = @(
@{
Pattern = 'func \(_i \*(\w+)Service\) (\w+)\(clientId \*uuid\.UUID, '
Replacement = 'func (_i *$1Service) $2(authToken string, '
},
@{
Pattern = 'func \(_i \*(\w+)Service\) (\w+)\(clientId \*uuid\.UUID\) '
Replacement = 'func (_i *$1Service) $2(authToken string) '
}
)
foreach ($Pattern in $Patterns) {
$Content = $Content -replace $Pattern.Pattern, $Pattern.Replacement
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "Service method signatures updated."
Write-Host "Please review the changes and add clientId extraction logic manually."

View File

@ -1,30 +0,0 @@
#!/bin/bash
# Script to update all service methods from clientId *uuid.UUID to authToken string
# Usage: ./update_service_methods.sh <file_path>
if [ $# -eq 0 ]; then
echo "Usage: ./update_service_methods.sh <file_path>"
exit 1
fi
FILE_PATH=$1
if [ ! -f "$FILE_PATH" ]; then
echo "File not found: $FILE_PATH"
exit 1
fi
echo "Updating service methods in: $FILE_PATH"
# Create backup
cp "$FILE_PATH" "${FILE_PATH}.backup"
# Update method signatures
sed -i 's/func (_i \*[a-zA-Z]*Service) \([A-Za-z]*\)(clientId \*uuid\.UUID, /func (_i *\1Service) \2(authToken string, /g' "$FILE_PATH"
# Add clientId extraction logic to each method
# This is a simplified approach - in practice, you'd need more sophisticated sed patterns
echo "Service methods updated. Please review the changes and add clientId extraction logic manually."
echo "Backup created at: ${FILE_PATH}.backup"