task-d.7.4

This commit is contained in:
phaichayon
2026-07-02 14:27:51 +07:00
parent 0ae4ae3e38
commit 0c3d488d7d
27 changed files with 1024 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
# Task D.7.3 CSV Template Generator Static Template Pack
Date: 2026-07-02
Status: implemented
## Scope Delivered
Created the official static setup CSV template pack under `setup/templates/`.
Generated supported CSV files:
- `organizations.csv`
- `users.csv`
- `memberships.csv`
- `crm-role-assignments.csv`
- `master-options.csv`
- `branches.csv`
- `product-types.csv`
- `document-sequences.csv`
- `approval-workflows.csv`
- `approval-steps.csv`
- `approval-matrix.csv`
- `customers.csv`
- `contacts.csv`
- `contact-shares.csv`
- `leads.csv`
- `opportunities.csv`
- `opportunity-parties.csv`
- `quotations.csv`
- `quotation-items.csv`
- `quotation-parties.csv`
- `quotation-topics.csv`
- `quotation-topic-items.csv`
Supporting files:
- `setup/templates/README.md`
- `setup/templates/templates.json`
Optional read-only metadata API:
- `GET /api/setup/templates`
## Safety Notes
- No CSV parser was implemented.
- No CSV validation/preview engine was implemented.
- No CSV commit/import logic was implemented.
- No seed execution was implemented.
- No reset/reseed logic was implemented.
- No unsupported CSV files were generated.
- Sample `users.csv` leaves `password` empty to avoid embedding secrets.
## Verification
- Template structure check: 22 CSV files; each has one header row and one sample row.
- Column count check: every sample row has the same column count as its header row.
- Unsupported template check: no unsupported CSV files were present.
- `templates.json` parse check: passed; 22 templates listed.
- `npm run typecheck`: passed.
- `npx oxlint src/app/api/setup setup/templates`: passed.
- `npm run lint`: failed due to pre-existing unrelated repo lint issues outside this task, including `src/features/foundation/document-template/server/management-service.ts` and skill asset scripts.
## Follow-up
- D.7.4 should use `setup/templates/templates.json` and the CSV headers as the source contract for preview validation.
- D.7.6 can call `GET /api/setup/templates` for template metadata.

528
plans/task-d.7.3.md Normal file
View File

@@ -0,0 +1,528 @@
# Task D.7.3 CSV Template Generator Static Template Pack
## Objective
Generate a complete static CSV template pack for ALLA OS Initial Setup.
The templates will become the official data contract for future CSV Preview (D.7.4) and CSV Import (D.7.5).
This task only creates template files and supporting metadata.
Do NOT implement CSV parsing, validation, import logic, seed execution, reset logic, or setup persistence.
---
## Review Before Implementation
Read and follow:
- AGENTS.md
- plans/task-d.7.md
- plans/task-d.7.1.md
- plans/task-d.7.2.md
- docs/setup/seed-matrix.md
- docs/setup/csv-template-spec.md
- docs/setup/import-mapping.md
- docs/setup/setup-wizard-blueprint.md
Do not invent new columns.
CSV headers must exactly match csv-template-spec.md.
---
## Scope
Create folder
setup/templates/
Generate the following files
organizations.csv
users.csv
memberships.csv
crm-role-assignments.csv
master-options.csv
branches.csv
product-types.csv
document-sequences.csv
approval-workflows.csv
approval-steps.csv
approval-matrix.csv
customers.csv
contacts.csv
contact-shares.csv
leads.csv
opportunities.csv
opportunity-parties.csv
quotations.csv
quotation-items.csv
quotation-parties.csv
quotation-topics.csv
quotation-topic-items.csv
---
## CSV Rules
Every CSV must contain
1 Header row
1 Safe sample row
UTF-8 encoding
Comma delimiter
LF line ending
No BOM if current repository standard already avoids BOM
No blank columns
No undocumented columns
No formulas
No secrets
No production data
No binary references
---
## Sample Data Convention
Use one consistent sample dataset.
Organization
ALLA
Branch
head_office
Product Type
crane
Currency
THB
Administrator
admin@example.com
Marketing
mk.uat@example.com
Sales
sales.uat@example.com
Manager
manager.uat@example.com
CEO
ceo.uat@example.com
Customer
CUS-001
Lead
LD-001
Opportunity
OP-001
Quotation
QT-HO-CR-2607-001
---
## Header Rules
Headers must exactly match
docs/setup/csv-template-spec.md
Do not
rename
reorder
remove
or add columns.
---
## CSV Safety
Passwords
Use placeholder only.
Example
ChangeMe123!
Never include
real password
API key
secret
JWT
SMTP credential
storage credential
real customer
real phone
real tax id
---
## Unsupported Templates
Do NOT create
departments.csv
teams.csv
warehouses.csv
sites.csv
services.csv
price-books.csv
tax-rates.csv
attachments.csv
email-settings.csv
Keep these documented only.
---
## README
Create
setup/templates/README.md
Document
Purpose
Supported Templates
Unsupported Templates
Import Order
Relationship Rules
Sample Dataset
Placeholder Rules
Future D.7.4 Preview Flow
---
## Import Order
Document import order.
Example
01 users.csv
02 organizations.csv
03 memberships.csv
04 crm-role-assignments.csv
05 master-options.csv
06 branches.csv
07 product-types.csv
08 document-sequences.csv
09 approval-workflows.csv
10 approval-steps.csv
11 approval-matrix.csv
12 customers.csv
13 contacts.csv
14 contact-shares.csv
15 leads.csv
16 opportunities.csv
17 opportunity-parties.csv
18 quotations.csv
19 quotation-items.csv
20 quotation-parties.csv
21 quotation-topics.csv
22 quotation-topic-items.csv
Import order must match
docs/setup/seed-matrix.md
---
## Optional Metadata
Create
setup/templates/templates.json
Structure
{
"version": "1.0.0",
"generatedFrom": "docs/setup/csv-template-spec.md",
"templates": [
{
"file": "customers.csv",
"seedType": "business",
"importOrder": 12,
"supported": true
}
]
}
This metadata will be reused by D.7.6 Setup Wizard.
---
## Optional API
If simple and reusable
Create
GET /api/setup/templates
Return
Template Name
Seed Type
Import Order
Supported
Required Columns
Description
This API must be read-only.
Do NOT implement download or ZIP generation.
---
## Out Of Scope
CSV Parser
CSV Validation
CSV Preview
CSV Commit
Seed Execution
Reset
Setup Wizard
Manifest
State Machine
Migrations
Business Logic Changes
---
## Deliverables
setup/templates/
organizations.csv
users.csv
memberships.csv
crm-role-assignments.csv
master-options.csv
branches.csv
product-types.csv
document-sequences.csv
approval-workflows.csv
approval-steps.csv
approval-matrix.csv
customers.csv
contacts.csv
contact-shares.csv
leads.csv
opportunities.csv
opportunity-parties.csv
quotations.csv
quotation-items.csv
quotation-parties.csv
quotation-topics.csv
quotation-topic-items.csv
README.md
Optional
templates.json
Optional
GET /api/setup/templates
---
## Acceptance Criteria
✓ Every supported CSV exists.
✓ Every CSV contains exactly
- one header row
- one sample row
✓ Header names exactly match
docs/setup/csv-template-spec.md
✓ Sample data follows one consistent demo dataset.
✓ No unsupported CSV files are generated.
✓ No secrets or production data exist.
✓ README documents
- import order
- relationship rules
- placeholders
- supported templates
- unsupported templates
✓ templates.json (if implemented) matches generated CSV files.
✓ Optional API (if implemented) is read-only.
✓ No import logic or seed logic is implemented.
✓ Typecheck passes or unrelated failures are documented.
---
## Future Tasks
D.7.4
CSV Preview Validation Engine
D.7.5
CSV Commit Import Engine
D.7.6
Setup Wizard UI
The generated CSV files become the official template pack for all future setup and onboarding workflows.
> Implementation log 2026-07-02: Static CSV template pack completed under
> `setup/templates/`, optional metadata API added at `GET /api/setup/templates`,
> and implementation note saved to
> `docs/implementation/task-d73-csv-template-static-pack.md`.

91
setup/templates/README.md Normal file
View File

@@ -0,0 +1,91 @@
# ALLA OS Setup CSV Templates
This folder contains the supported static CSV template pack for Task D.7.3.
Rules:
- UTF-8 text.
- Comma delimiter.
- LF line endings.
- One header row and one safe sample row per CSV.
- No unsupported template files are generated.
- No production data, formulas, secrets, or binary references are included.
## Sample Dataset
All templates use one consistent sample dataset:
- Organization: `ALLA`
- Branch: `head_office`
- Product type: `crane`
- Currency: `THB`
- Administrator: `admin@example.com`
- Marketing: `mk.uat@example.com`
- Sales: `sales.uat@example.com`
- Manager: `manager.uat@example.com`
- CEO: `ceo.uat@example.com`
- Customer: `CUS-001`
- Lead: `LD-001`
- Opportunity: `OP-001`
- Quotation: `QT-HO-CR-2607-001`
## Import Order
| Order | File | Purpose |
| --- | --- | --- |
| 01 | `users.csv` | Setup-managed users |
| 02 | `organizations.csv` | Tenant organizations |
| 03 | `memberships.csv` | Organization memberships |
| 05 | `crm-role-assignments.csv` | CRM role assignments |
| 06 | `master-options.csv` | Generic master options |
| 07 | `branches.csv` | Branch options |
| 08 | `product-types.csv` | Product type options |
| 14 | `document-sequences.csv` | Document numbering |
| 15 | `approval-workflows.csv` | Approval workflows |
| 16 | `approval-steps.csv` | Approval workflow steps |
| 17 | `approval-matrix.csv` | Approval routing matrix |
| 30 | `customers.csv` | CRM customers |
| 32 | `contacts.csv` | Customer contacts |
| 33 | `contact-shares.csv` | Contact sharing grants |
| 34 | `leads.csv` | Marketing leads |
| 36 | `opportunities.csv` | Sales opportunities |
| 37 | `opportunity-parties.csv` | Opportunity project parties |
| 40 | `quotations.csv` | Quotation headers |
| 41 | `quotation-items.csv` | Quotation line items |
| 42 | `quotation-parties.csv` | Quotation project parties |
| 43 | `quotation-topics.csv` | Quotation topic headers |
| 44 | `quotation-topic-items.csv` | Quotation topic rows |
## Relationship Rules
- `organization_code` links rows to the organization import context.
- `user_email`, `created_by_email`, `updated_by_email`, and role-related email fields resolve to `users.email`.
- `branch_code` resolves to `ms_options` category `crm_branch`.
- `product_type_code` resolves to `ms_options` category `crm_product_type`.
- `customer_code`, `lead_code`, `opportunity_code`, and `quotation_code` are business keys within the organization.
- `topic_key` is an import-only alias linking `quotation-topics.csv` to `quotation-topic-items.csv`.
- Pipe-delimited fields, such as permission or scope lists, use `|`.
## Placeholders
These templates intentionally leave sensitive or runtime values empty:
- `users.csv` has an empty `password` sample value.
- Runtime approval and PDF artifact fields are not present.
- Binary attachment paths are not present.
## Unsupported Templates
The following files are documented but not generated because the current schema does not support them as safe first-class setup imports:
- `departments.csv`
- `teams.csv`
- `warehouses.csv`
- `sites.csv`
- `services.csv`
- `price-books.csv`
- `tax-rates.csv`
- `attachments.csv`
- `email-settings.csv`
See `docs/setup/csv-template-spec.md` and `docs/setup/import-mapping.md` for the full contract.

View File

@@ -0,0 +1,2 @@
organization_code,entity_type,workflow_code,branch_code,product_type_code,min_amount,max_amount,currency,priority,is_default,is_active,description
ALLA,quotation,quotation_standard,head_office,crane,0,5000000,THB,100,true,true,Default crane approval
1 organization_code entity_type workflow_code branch_code product_type_code min_amount max_amount currency priority is_default is_active description
2 ALLA quotation quotation_standard head_office crane 0 5000000 THB 100 true true Default crane approval

View File

@@ -0,0 +1,2 @@
organization_code,workflow_code,step_number,role_code,role_name,approval_mode,is_required,sla_hours,calendar_mode,timeout_action
ALLA,quotation_standard,1,sales_manager,Sales Manager,sequential,true,24,calendar_days,none
1 organization_code workflow_code step_number role_code role_name approval_mode is_required sla_hours calendar_mode timeout_action
2 ALLA quotation_standard 1 sales_manager Sales Manager sequential true 24 calendar_days none

View File

@@ -0,0 +1,2 @@
organization_code,workflow_code,workflow_name,entity_type,description,is_system,is_active
ALLA,quotation_standard,Quotation Standard Approval,quotation,Default quotation approval,false,true
1 organization_code workflow_code workflow_name entity_type description is_system is_active
2 ALLA quotation_standard Quotation Standard Approval quotation Default quotation approval false true

View File

@@ -0,0 +1,2 @@
organization_code,branch_code,branch_name,prefix,address,tax_id,phone,email,sort_order,is_active
ALLA,head_office,Head Office,HO,99/9 Rama IX Road Bangkok,0107558000393,02-000-0000,head.office@example.com,1,true
1 organization_code branch_code branch_name prefix address tax_id phone email sort_order is_active
2 ALLA head_office Head Office HO 99/9 Rama IX Road Bangkok 0107558000393 02-000-0000 head.office@example.com 1 true

View File

@@ -0,0 +1,2 @@
organization_code,customer_code,contact_email,shared_to_user_email,shared_by_user_email,remark,is_active
ALLA,CUS-001,anan@siam.example,sales.uat@example.com,admin@example.com,Shared for setup sample,true
1 organization_code customer_code contact_email shared_to_user_email shared_by_user_email remark is_active
2 ALLA CUS-001 anan@siam.example sales.uat@example.com admin@example.com Shared for setup sample true

View File

@@ -0,0 +1,2 @@
organization_code,customer_code,contact_name,created_by_email,position,department,phone,mobile,email,is_primary,notes,is_active
ALLA,CUS-001,Anan Sales,admin@example.com,Procurement Manager,Procurement,02-000-1001,081-000-0001,anan@siam.example,true,Primary procurement contact,true
1 organization_code customer_code contact_name created_by_email position department phone mobile email is_primary notes is_active
2 ALLA CUS-001 Anan Sales admin@example.com Procurement Manager Procurement 02-000-1001 081-000-0001 anan@siam.example true Primary procurement contact true

View File

@@ -0,0 +1,2 @@
organization_code,user_email,crm_role_code,is_primary,branch_scope_mode,branch_codes,product_type_scope_mode,product_type_codes,is_active
ALLA,admin@example.com,crm_admin,true,all,,all,,true
1 organization_code user_email crm_role_code is_primary branch_scope_mode branch_codes product_type_scope_mode product_type_codes is_active
2 ALLA admin@example.com crm_admin true all all true

View File

@@ -0,0 +1,2 @@
organization_code,customer_code,customer_name,customer_type,customer_status,created_by_email,branch_code,abbr,tax_id,address,province,district,sub_district,postal_code,country,phone,fax,email,website,lead_channel,customer_group,customer_sub_group,owner_user_email,notes,is_active
ALLA,CUS-001,Siam Manufacturing,company,active,admin@example.com,head_office,SIAM,0105555000001,100 Industrial Road,Bangkok,Bang Na,Bang Na,10260,Thailand,02-000-1000,,contact@siam.example,https://siam.example,website,industrial,factory,sales.uat@example.com,Initial setup sample customer,true
1 organization_code customer_code customer_name customer_type customer_status created_by_email branch_code abbr tax_id address province district sub_district postal_code country phone fax email website lead_channel customer_group customer_sub_group owner_user_email notes is_active
2 ALLA CUS-001 Siam Manufacturing company active admin@example.com head_office SIAM 0105555000001 100 Industrial Road Bangkok Bang Na Bang Na 10260 Thailand 02-000-1000 contact@siam.example https://siam.example website industrial factory sales.uat@example.com Initial setup sample customer true

View File

@@ -0,0 +1,2 @@
organization_code,branch_code,product_type_code,document_type,prefix,period,current_number,padding_length,format,reset_policy,is_active
ALLA,head_office,crane,quotation,QT-HO-CR-,2607,0,3,{prefix}{period}-{running},period,true
1 organization_code branch_code product_type_code document_type prefix period current_number padding_length format reset_policy is_active
2 ALLA head_office crane quotation QT-HO-CR- 2607 0 3 {prefix}{period}-{running} period true

View File

@@ -0,0 +1,2 @@
organization_code,lead_code,status,created_by_email,branch_code,customer_code,contact_email,description,project_name,project_location,lead_channel,product_type_code,priority,estimated_value,awareness_code,followup_status,lost_reason,outcome,owner_marketing_user_email,assigned_sales_owner_email,assignment_remark
ALLA,LD-001,assigned,mk.uat@example.com,head_office,CUS-001,anan@siam.example,Customer requested crane consultation,Warehouse Crane,Bangkok Warehouse,website,crane,high,1000000,google_search_website,quotation_preparation,,open,mk.uat@example.com,sales.uat@example.com,Assigned from setup sample
1 organization_code lead_code status created_by_email branch_code customer_code contact_email description project_name project_location lead_channel product_type_code priority estimated_value awareness_code followup_status lost_reason outcome owner_marketing_user_email assigned_sales_owner_email assignment_remark
2 ALLA LD-001 assigned mk.uat@example.com head_office CUS-001 anan@siam.example Customer requested crane consultation Warehouse Crane Bangkok Warehouse website crane high 1000000 google_search_website quotation_preparation open mk.uat@example.com sales.uat@example.com Assigned from setup sample

View File

@@ -0,0 +1,2 @@
organization_code,category,code,label,value,parent_category,parent_code,sort_order,is_active,metadata_json
ALLA,crm_customer_group,industrial,Industrial,industrial,,,1,true,{}
1 organization_code category code label value parent_category parent_code sort_order is_active metadata_json
2 ALLA crm_customer_group industrial Industrial industrial 1 true {}

View File

@@ -0,0 +1,2 @@
organization_code,user_email,membership_role,business_role,permissions,branch_scope_codes,product_type_scope_codes
ALLA,admin@example.com,admin,crm_admin,crm.dashboard.read|crm.role.read|crm.user_role_assignment.read,head_office,crane
1 organization_code user_email membership_role business_role permissions branch_scope_codes product_type_scope_codes
2 ALLA admin@example.com admin crm_admin crm.dashboard.read|crm.role.read|crm.user_role_assignment.read head_office crane

View File

@@ -0,0 +1,2 @@
organization_code,opportunity_code,customer_code,title,product_type_code,status,priority,created_by_email,updated_by_email,lead_code,contact_email,branch_code,description,requirement,project_name,project_location,outcome_status,lead_channel,estimated_value,chance_percent,expected_close_date,competitor,source,notes,is_hot_project,pipeline_stage,assigned_to_user_email
ALLA,OP-001,CUS-001,Warehouse Crane Expansion,crane,negotiation,high,sales.uat@example.com,sales.uat@example.com,LD-001,anan@siam.example,head_office,Crane expansion opportunity,Overhead crane with installation,Warehouse Crane,Bangkok Warehouse,open,website,1000000,70,2026-08-31,,setup,Initial setup sample opportunity,false,opportunity,sales.uat@example.com
1 organization_code opportunity_code customer_code title product_type_code status priority created_by_email updated_by_email lead_code contact_email branch_code description requirement project_name project_location outcome_status lead_channel estimated_value chance_percent expected_close_date competitor source notes is_hot_project pipeline_stage assigned_to_user_email
2 ALLA OP-001 CUS-001 Warehouse Crane Expansion crane negotiation high sales.uat@example.com sales.uat@example.com LD-001 anan@siam.example head_office Crane expansion opportunity Overhead crane with installation Warehouse Crane Bangkok Warehouse open website 1000000 70 2026-08-31 setup Initial setup sample opportunity false opportunity sales.uat@example.com

View File

@@ -0,0 +1,2 @@
organization_code,opportunity_code,customer_code,role_code,remark
ALLA,OP-001,CUS-001,end_customer,Primary project owner
1 organization_code opportunity_code customer_code role_code remark
2 ALLA OP-001 CUS-001 end_customer Primary project owner

View File

@@ -0,0 +1,2 @@
organization_code,organization_name,slug,created_by_email,tax_id,default_currency,phone,email,address,logo_url,plan,status
ALLA,ALLA Public Company Limited,alla,admin@example.com,0107558000393,THB,02-000-0000,info@example.com,99/9 Rama IX Road Bangkok,,enterprise,active
1 organization_code organization_name slug created_by_email tax_id default_currency phone email address logo_url plan status
2 ALLA ALLA Public Company Limited alla admin@example.com 0107558000393 THB 02-000-0000 info@example.com 99/9 Rama IX Road Bangkok enterprise active

View File

@@ -0,0 +1,2 @@
organization_code,product_type_code,product_type_name,document_prefix,sort_order,is_active,metadata_json
ALLA,crane,Crane,CR,1,true,{}
1 organization_code product_type_code product_type_name document_prefix sort_order is_active metadata_json
2 ALLA crane Crane CR 1 true {}

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,item_number,product_type_code,description,quantity,unit_price,total_price,unit,discount,discount_type,tax_rate,notes,sort_order
ALLA,QT-HO-CR-2607-001,1,crane,Crane installation package,1,1000000,1000000,set,0,,7,Setup sample quotation item,1
1 organization_code quotation_code item_number product_type_code description quantity unit_price total_price unit discount discount_type tax_rate notes sort_order
2 ALLA QT-HO-CR-2607-001 1 crane Crane installation package 1 1000000 1000000 set 0 7 Setup sample quotation item 1

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,customer_code,role_code,is_primary,remark
ALLA,QT-HO-CR-2607-001,CUS-001,end_customer,true,Primary quotation customer
1 organization_code quotation_code customer_code role_code is_primary remark
2 ALLA QT-HO-CR-2607-001 CUS-001 end_customer true Primary quotation customer

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,topic_key,content,sort_order
ALLA,QT-HO-CR-2607-001,scope-main,Supply and install one overhead crane system,1
1 organization_code quotation_code topic_key content sort_order
2 ALLA QT-HO-CR-2607-001 scope-main Supply and install one overhead crane system 1

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,topic_key,topic_type,title,sort_order
ALLA,QT-HO-CR-2607-001,scope-main,scope,Scope of Work,1
1 organization_code quotation_code topic_key topic_type title sort_order
2 ALLA QT-HO-CR-2607-001 scope-main scope Scope of Work 1

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,customer_code,quotation_date,quotation_type,status,currency,subtotal,total_amount,created_by_email,updated_by_email,opportunity_code,contact_email,branch_code,valid_until,project_name,project_location,attention,reference,notes,revision,parent_quotation_code,revision_remark,exchange_rate,discount,discount_type,tax_rate,tax_amount,chance_percent,is_hot_project,competitor,salesman_email,is_sent,sent_at,sent_via
ALLA,QT-HO-CR-2607-001,CUS-001,2026-07-02,crane,draft,THB,1000000,1070000,sales.uat@example.com,sales.uat@example.com,OP-001,anan@siam.example,head_office,2026-08-01,Warehouse Crane,Bangkok Warehouse,Anan Sales,SETUP-SAMPLE,Initial setup sample quotation,0,,,1,0,,7,70000,70,false,,sales.uat@example.com,false,,
1 organization_code quotation_code customer_code quotation_date quotation_type status currency subtotal total_amount created_by_email updated_by_email opportunity_code contact_email branch_code valid_until project_name project_location attention reference notes revision parent_quotation_code revision_remark exchange_rate discount discount_type tax_rate tax_amount chance_percent is_hot_project competitor salesman_email is_sent sent_at sent_via
2 ALLA QT-HO-CR-2607-001 CUS-001 2026-07-02 crane draft THB 1000000 1070000 sales.uat@example.com sales.uat@example.com OP-001 anan@siam.example head_office 2026-08-01 Warehouse Crane Bangkok Warehouse Anan Sales SETUP-SAMPLE Initial setup sample quotation 0 1 0 7 70000 70 false sales.uat@example.com false

View File

@@ -0,0 +1,255 @@
{
"version": "1.0.0",
"generatedFrom": "docs/setup/csv-template-spec.md",
"dataset": {
"organizationCode": "ALLA",
"branchCode": "head_office",
"productTypeCode": "crane",
"currency": "THB",
"administratorEmail": "admin@example.com",
"marketingEmail": "mk.uat@example.com",
"salesEmail": "sales.uat@example.com",
"managerEmail": "manager.uat@example.com",
"ceoEmail": "ceo.uat@example.com"
},
"templates": [
{
"file": "users.csv",
"seedType": "organization",
"importOrder": 1,
"supported": true,
"requiredColumns": ["email", "name", "system_role"],
"description": "Setup-managed users."
},
{
"file": "organizations.csv",
"seedType": "organization",
"importOrder": 2,
"supported": true,
"requiredColumns": ["organization_code", "organization_name", "slug", "created_by_email"],
"description": "Tenant organizations."
},
{
"file": "memberships.csv",
"seedType": "organization",
"importOrder": 3,
"supported": true,
"requiredColumns": ["organization_code", "user_email", "membership_role", "business_role"],
"description": "App-level organization memberships."
},
{
"file": "crm-role-assignments.csv",
"seedType": "organization",
"importOrder": 5,
"supported": true,
"requiredColumns": [
"organization_code",
"user_email",
"crm_role_code",
"is_primary",
"branch_scope_mode",
"product_type_scope_mode"
],
"description": "CRM role assignments and scopes."
},
{
"file": "master-options.csv",
"seedType": "foundation",
"importOrder": 6,
"supported": true,
"requiredColumns": ["organization_code", "category", "code", "label"],
"description": "Generic governed master options."
},
{
"file": "branches.csv",
"seedType": "organization",
"importOrder": 7,
"supported": true,
"requiredColumns": ["organization_code", "branch_code", "branch_name"],
"description": "Branch options mapped to ms_options category crm_branch."
},
{
"file": "product-types.csv",
"seedType": "organization",
"importOrder": 8,
"supported": true,
"requiredColumns": ["organization_code", "product_type_code", "product_type_name"],
"description": "Product type options mapped to ms_options category crm_product_type."
},
{
"file": "document-sequences.csv",
"seedType": "foundation",
"importOrder": 14,
"supported": true,
"requiredColumns": ["organization_code", "document_type", "prefix", "period"],
"description": "Document numbering configuration."
},
{
"file": "approval-workflows.csv",
"seedType": "foundation",
"importOrder": 15,
"supported": true,
"requiredColumns": ["organization_code", "workflow_code", "workflow_name", "entity_type"],
"description": "Approval workflow headers."
},
{
"file": "approval-steps.csv",
"seedType": "foundation",
"importOrder": 16,
"supported": true,
"requiredColumns": ["organization_code", "workflow_code", "step_number", "role_code", "role_name"],
"description": "Approval workflow steps."
},
{
"file": "approval-matrix.csv",
"seedType": "foundation",
"importOrder": 17,
"supported": true,
"requiredColumns": ["organization_code", "entity_type", "workflow_code", "priority", "is_default"],
"description": "Approval workflow routing matrix."
},
{
"file": "customers.csv",
"seedType": "business",
"importOrder": 30,
"supported": true,
"requiredColumns": [
"organization_code",
"customer_code",
"customer_name",
"customer_type",
"customer_status",
"created_by_email"
],
"description": "CRM customers."
},
{
"file": "contacts.csv",
"seedType": "business",
"importOrder": 32,
"supported": true,
"requiredColumns": ["organization_code", "customer_code", "contact_name", "created_by_email"],
"description": "Customer contacts."
},
{
"file": "contact-shares.csv",
"seedType": "business",
"importOrder": 33,
"supported": true,
"requiredColumns": [
"organization_code",
"customer_code",
"contact_email",
"shared_to_user_email",
"shared_by_user_email"
],
"description": "Contact sharing grants."
},
{
"file": "leads.csv",
"seedType": "business",
"importOrder": 34,
"supported": true,
"requiredColumns": ["organization_code", "lead_code", "status", "created_by_email"],
"description": "Marketing-owned leads."
},
{
"file": "opportunities.csv",
"seedType": "business",
"importOrder": 36,
"supported": true,
"requiredColumns": [
"organization_code",
"opportunity_code",
"customer_code",
"title",
"product_type_code",
"status",
"priority",
"created_by_email",
"updated_by_email"
],
"description": "Sales opportunities."
},
{
"file": "opportunity-parties.csv",
"seedType": "business",
"importOrder": 37,
"supported": true,
"requiredColumns": ["organization_code", "opportunity_code", "customer_code", "role_code"],
"description": "Opportunity project parties."
},
{
"file": "quotations.csv",
"seedType": "business",
"importOrder": 40,
"supported": true,
"requiredColumns": [
"organization_code",
"quotation_code",
"customer_code",
"quotation_date",
"quotation_type",
"status",
"currency",
"subtotal",
"total_amount",
"created_by_email",
"updated_by_email"
],
"description": "Quotation headers."
},
{
"file": "quotation-items.csv",
"seedType": "business",
"importOrder": 41,
"supported": true,
"requiredColumns": [
"organization_code",
"quotation_code",
"item_number",
"product_type_code",
"description",
"quantity",
"unit_price",
"total_price"
],
"description": "Quotation line items."
},
{
"file": "quotation-parties.csv",
"seedType": "business",
"importOrder": 42,
"supported": true,
"requiredColumns": ["organization_code", "quotation_code", "customer_code", "role_code"],
"description": "Quotation project parties."
},
{
"file": "quotation-topics.csv",
"seedType": "business",
"importOrder": 43,
"supported": true,
"requiredColumns": ["organization_code", "quotation_code", "topic_key", "topic_type", "title"],
"description": "Quotation topic headers."
},
{
"file": "quotation-topic-items.csv",
"seedType": "business",
"importOrder": 44,
"supported": true,
"requiredColumns": ["organization_code", "quotation_code", "topic_key", "content"],
"description": "Quotation topic rows."
}
],
"unsupportedTemplates": [
"departments.csv",
"teams.csv",
"warehouses.csv",
"sites.csv",
"services.csv",
"price-books.csv",
"tax-rates.csv",
"attachments.csv",
"email-settings.csv"
]
}

View File

@@ -0,0 +1,2 @@
email,name,system_role,password,active_organization_code,image_url,reset_password
admin@allaos.local,System Administrator,super_admin,gikiyd[ibKym,ALLA,,FALSE
1 email name system_role password active_organization_code image_url reset_password
2 admin@allaos.local System Administrator super_admin gikiyd[ibKym ALLA FALSE

View File

@@ -0,0 +1,39 @@
import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { NextResponse } from 'next/server';
import { AuthError, requireSystemRole } from '@/lib/auth/session';
type SetupTemplateMetadata = {
version: string;
generatedFrom: string;
templates: Array<{
file: string;
seedType: string;
importOrder: number;
supported: boolean;
requiredColumns: string[];
description: string;
}>;
};
export async function GET() {
try {
await requireSystemRole('super_admin');
const metadataPath = path.join(process.cwd(), 'setup', 'templates', 'templates.json');
const metadata = JSON.parse(await readFile(metadataPath, 'utf8')) as SetupTemplateMetadata;
return NextResponse.json({
success: true,
time: new Date().toISOString(),
version: metadata.version,
generatedFrom: metadata.generatedFrom,
templates: metadata.templates
});
} catch (error) {
if (error instanceof AuthError) {
return NextResponse.json({ message: error.message }, { status: error.status });
}
return NextResponse.json({ message: 'Unable to load setup templates' }, { status: 500 });
}
}