@adaptware/eagles-db 0.5.35 → 0.5.36
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/client/edge.js +12 -311
- package/client/index-browser.js +5 -305
- package/client/index.d.ts +87573 -113130
- package/client/index.js +12 -311
- package/client/package.json +1 -1
- package/client/schema.prisma +118 -583
- package/client/wasm.js +12 -311
- package/package.json +1 -1
- package/prisma/.DS_Store +0 -0
- package/prisma/schema/.DS_Store +0 -0
- package/prisma/schema/applications.prisma +34 -29
- package/prisma/schema/department.prisma +2 -3
- package/prisma/schema/document.prisma +1 -0
- package/prisma/schema/integration.prisma +0 -1
- package/prisma/schema/jobDescription.prisma +0 -1
- package/prisma/schema/migrations/.DS_Store +0 -0
- package/prisma/schema/migrations/20260826160000_add_application_fit_check_report_document/.DS_Store +0 -0
- package/prisma/schema/migrations/20260826160000_add_application_fit_check_report_document/migration.sql +13 -0
- package/prisma/schema/organisation.prisma +58 -66
- package/prisma/schema/schema.prisma +1 -1
- package/client/libquery_engine-darwin.dylib.node +0 -0
- package/prisma/migrations/20260519120000_migrate_shortlisted_to_selected/migration.sql +0 -2
- package/prisma/schema/licensing/aiCostLedger.prisma +0 -34
- package/prisma/schema/licensing/assignmentHistory.prisma +0 -19
- package/prisma/schema/licensing/licensePackageCatalog.prisma +0 -62
- package/prisma/schema/licensing/licensingEnums.prisma +0 -80
- package/prisma/schema/licensing/licensingLedger.prisma +0 -32
- package/prisma/schema/licensing/purchasedLicense.prisma +0 -74
- package/prisma/schema/licensing/purchasedTopUp.prisma +0 -39
- package/prisma/schema/migrations/20260519120000_add_analytics_schema/migration.sql +0 -84
- package/prisma/schema/migrations/20260625120000_add_interviewer_analytics/migration.sql +0 -26
- package/prisma/schema/migrations/20260629120000_add_user_lifecycle_activity_events/migration.sql +0 -13
- package/prisma/schema/migrations/20260629140000_drop_organisation_org_code/migration.sql +0 -2
- package/prisma/schema/migrations/20260629160000_employee_codes_dual_interviewer_analytics/migration.sql +0 -87
- package/prisma/schema/migrations/20260630120000_add_application_sources/migration.sql +0 -38
- package/prisma/schema/migrations/20260701120000_add_source_effectiveness_analytics/migration.sql +0 -40
- package/prisma/schema/migrations/20260702120000_add_analytics_daily_tables/migration.sql +0 -232
- package/prisma/schema/migrations/20260716120000_evaluation_category_four_values/migration.sql +0 -204
- package/prisma/schema/migrations/20260716130000_application_withdrawn_analytics/migration.sql +0 -31
- package/prisma/schema/migrations/20260804120000_contact_us_optional_website_subject/migration.sql +0 -3
- package/prisma/schema/migrations/20260810120000_add_licensing_schema/migration.sql +0 -237
- package/prisma/schema/migrations/20260814153000_add_licensing_ledger/migration.sql +0 -236
- package/prisma/schema/migrations/20260828120000_license_package_orgs_cost_price_ai_cost_ledger/migration.sql +0 -74
- package/prisma/schema/migrations/20260831120000_ai_cost_ledger_purchase_reason/migration.sql +0 -2
- package/prisma/schema/migrations/20260831140000_ai_cost_ledger_nullable_hiring_unit/migration.sql +0 -3
- package/prisma/schema/payment/billingTransaction.prisma +0 -83
- package/prisma/schema/payment/paymentWebhookEvent.prisma +0 -28
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
-- CreateEnum
|
|
2
|
-
CREATE TYPE "licensing"."LicensingLedgerEntitlementType" AS ENUM (
|
|
3
|
-
'INTERVIEW_AI_ASSISTED_HOURS',
|
|
4
|
-
'INTERVIEW_FULL_AI_HOURS',
|
|
5
|
-
'INTERVIEW_NON_AI_HOURS',
|
|
6
|
-
'ASSIGNMENT_COUNT',
|
|
7
|
-
'TEST_COUNT',
|
|
8
|
-
'RESUME_COUNT',
|
|
9
|
-
'CREDITS'
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
-- CreateEnum
|
|
13
|
-
CREATE TYPE "licensing"."LicensingLedgerDirection" AS ENUM ('CREDIT', 'DEBIT');
|
|
14
|
-
|
|
15
|
-
-- CreateEnum
|
|
16
|
-
CREATE TYPE "licensing"."LicensingLedgerReason" AS ENUM (
|
|
17
|
-
'PURCHASE',
|
|
18
|
-
'TOP_UP',
|
|
19
|
-
'USAGE',
|
|
20
|
-
'ADJUSTMENT',
|
|
21
|
-
'REFUND',
|
|
22
|
-
'EXPIRY'
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
-- CreateTable
|
|
26
|
-
CREATE TABLE "licensing"."licensing_ledger" (
|
|
27
|
-
"id" TEXT NOT NULL,
|
|
28
|
-
"organisation_id" TEXT NOT NULL,
|
|
29
|
-
"purchased_hiring_unit_id" TEXT,
|
|
30
|
-
"entitlement_type" "licensing"."LicensingLedgerEntitlementType" NOT NULL,
|
|
31
|
-
"direction" "licensing"."LicensingLedgerDirection" NOT NULL,
|
|
32
|
-
"amount" DECIMAL(20,4) NOT NULL,
|
|
33
|
-
"reason" "licensing"."LicensingLedgerReason" NOT NULL,
|
|
34
|
-
"occurred_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
35
|
-
"source_type" TEXT,
|
|
36
|
-
"source_id" TEXT,
|
|
37
|
-
"description" TEXT,
|
|
38
|
-
"idempotency_key" TEXT NOT NULL,
|
|
39
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
40
|
-
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
41
|
-
"created_by" TEXT NOT NULL,
|
|
42
|
-
"updated_by" TEXT NOT NULL,
|
|
43
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
44
|
-
|
|
45
|
-
CONSTRAINT "licensing_ledger_pkey" PRIMARY KEY ("id"),
|
|
46
|
-
CONSTRAINT "licensing_ledger_amount_non_negative" CHECK ("amount" >= 0)
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
-- CreateIndex
|
|
50
|
-
CREATE UNIQUE INDEX "licensing_ledger_idempotency_key_key" ON "licensing"."licensing_ledger"("idempotency_key");
|
|
51
|
-
|
|
52
|
-
-- CreateIndex
|
|
53
|
-
CREATE INDEX "licensing_ledger_unit_type_occurred_idx" ON "licensing"."licensing_ledger"("purchased_hiring_unit_id", "entitlement_type", "occurred_at");
|
|
54
|
-
|
|
55
|
-
-- CreateIndex
|
|
56
|
-
CREATE INDEX "licensing_ledger_org_type_occurred_idx" ON "licensing"."licensing_ledger"("organisation_id", "entitlement_type", "occurred_at");
|
|
57
|
-
|
|
58
|
-
-- AddForeignKey
|
|
59
|
-
ALTER TABLE "licensing"."licensing_ledger" ADD CONSTRAINT "licensing_ledger_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
60
|
-
|
|
61
|
-
-- AddForeignKey
|
|
62
|
-
ALTER TABLE "licensing"."licensing_ledger" ADD CONSTRAINT "licensing_ledger_purchased_hiring_unit_id_fkey" FOREIGN KEY ("purchased_hiring_unit_id") REFERENCES "licensing"."purchased_hiring_units"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
63
|
-
|
|
64
|
-
-- Backfill PURCHASE credits from COALESCE(updated, base) when not null.
|
|
65
|
-
INSERT INTO "licensing"."licensing_ledger" (
|
|
66
|
-
"id",
|
|
67
|
-
"organisation_id",
|
|
68
|
-
"purchased_hiring_unit_id",
|
|
69
|
-
"entitlement_type",
|
|
70
|
-
"direction",
|
|
71
|
-
"amount",
|
|
72
|
-
"reason",
|
|
73
|
-
"occurred_at",
|
|
74
|
-
"source_type",
|
|
75
|
-
"source_id",
|
|
76
|
-
"idempotency_key",
|
|
77
|
-
"created_at",
|
|
78
|
-
"updated_at",
|
|
79
|
-
"created_by",
|
|
80
|
-
"updated_by",
|
|
81
|
-
"is_active"
|
|
82
|
-
)
|
|
83
|
-
SELECT
|
|
84
|
-
gen_random_uuid()::text,
|
|
85
|
-
u."organisation_id",
|
|
86
|
-
u."id",
|
|
87
|
-
stem.entitlement_type::"licensing"."LicensingLedgerEntitlementType",
|
|
88
|
-
'CREDIT'::"licensing"."LicensingLedgerDirection",
|
|
89
|
-
COALESCE(stem.updated_amount, stem.base_amount),
|
|
90
|
-
'PURCHASE'::"licensing"."LicensingLedgerReason",
|
|
91
|
-
u."created_at",
|
|
92
|
-
'purchased_license_package',
|
|
93
|
-
u."purchased_license_package_id",
|
|
94
|
-
'purchase:' || u."id" || ':' || stem.entitlement_type,
|
|
95
|
-
u."created_at",
|
|
96
|
-
u."updated_at",
|
|
97
|
-
u."created_by",
|
|
98
|
-
u."updated_by",
|
|
99
|
-
true
|
|
100
|
-
FROM "licensing"."purchased_hiring_units" u
|
|
101
|
-
CROSS JOIN LATERAL (
|
|
102
|
-
VALUES
|
|
103
|
-
('INTERVIEW_AI_ASSISTED_HOURS', u."interview_ai_assisted_hours", u."interview_ai_assisted_hours_updated"),
|
|
104
|
-
('INTERVIEW_FULL_AI_HOURS', u."interview_full_ai_hours", u."interview_full_ai_hours_updated"),
|
|
105
|
-
('INTERVIEW_NON_AI_HOURS', u."interview_non_ai_hours", u."interview_non_ai_hours_updated"),
|
|
106
|
-
('ASSIGNMENT_COUNT', u."assignment_count", u."assignment_count_updated"),
|
|
107
|
-
('TEST_COUNT', u."test_count", u."test_count_updated"),
|
|
108
|
-
('RESUME_COUNT', u."resume_count", u."resume_count_updated"),
|
|
109
|
-
('CREDITS', u."credits", u."credits_updated")
|
|
110
|
-
) AS stem(entitlement_type, base_amount, updated_amount)
|
|
111
|
-
WHERE COALESCE(stem.updated_amount, stem.base_amount) IS NOT NULL;
|
|
112
|
-
|
|
113
|
-
-- Backfill TOP_UP credits when allocated top-up is greater than zero.
|
|
114
|
-
INSERT INTO "licensing"."licensing_ledger" (
|
|
115
|
-
"id",
|
|
116
|
-
"organisation_id",
|
|
117
|
-
"purchased_hiring_unit_id",
|
|
118
|
-
"entitlement_type",
|
|
119
|
-
"direction",
|
|
120
|
-
"amount",
|
|
121
|
-
"reason",
|
|
122
|
-
"occurred_at",
|
|
123
|
-
"source_type",
|
|
124
|
-
"idempotency_key",
|
|
125
|
-
"created_at",
|
|
126
|
-
"updated_at",
|
|
127
|
-
"created_by",
|
|
128
|
-
"updated_by",
|
|
129
|
-
"is_active"
|
|
130
|
-
)
|
|
131
|
-
SELECT
|
|
132
|
-
gen_random_uuid()::text,
|
|
133
|
-
u."organisation_id",
|
|
134
|
-
u."id",
|
|
135
|
-
stem.entitlement_type::"licensing"."LicensingLedgerEntitlementType",
|
|
136
|
-
'CREDIT'::"licensing"."LicensingLedgerDirection",
|
|
137
|
-
stem.topup_amount,
|
|
138
|
-
'TOP_UP'::"licensing"."LicensingLedgerReason",
|
|
139
|
-
u."updated_at",
|
|
140
|
-
'purchased_top_up',
|
|
141
|
-
'topup-backfill:' || u."id" || ':' || stem.entitlement_type,
|
|
142
|
-
u."created_at",
|
|
143
|
-
u."updated_at",
|
|
144
|
-
u."created_by",
|
|
145
|
-
u."updated_by",
|
|
146
|
-
true
|
|
147
|
-
FROM "licensing"."purchased_hiring_units" u
|
|
148
|
-
CROSS JOIN LATERAL (
|
|
149
|
-
VALUES
|
|
150
|
-
('INTERVIEW_AI_ASSISTED_HOURS', u."interview_ai_assisted_hours_topup"),
|
|
151
|
-
('INTERVIEW_FULL_AI_HOURS', u."interview_full_ai_hours_topup"),
|
|
152
|
-
('INTERVIEW_NON_AI_HOURS', u."interview_non_ai_hours_topup"),
|
|
153
|
-
('ASSIGNMENT_COUNT', u."assignment_count_topup"),
|
|
154
|
-
('TEST_COUNT', u."test_count_topup"),
|
|
155
|
-
('RESUME_COUNT', u."resume_count_topup"),
|
|
156
|
-
('CREDITS', u."credits_topup")
|
|
157
|
-
) AS stem(entitlement_type, topup_amount)
|
|
158
|
-
WHERE stem.topup_amount IS NOT NULL AND stem.topup_amount > 0;
|
|
159
|
-
|
|
160
|
-
-- Backfill USAGE debits when consumed is greater than zero.
|
|
161
|
-
INSERT INTO "licensing"."licensing_ledger" (
|
|
162
|
-
"id",
|
|
163
|
-
"organisation_id",
|
|
164
|
-
"purchased_hiring_unit_id",
|
|
165
|
-
"entitlement_type",
|
|
166
|
-
"direction",
|
|
167
|
-
"amount",
|
|
168
|
-
"reason",
|
|
169
|
-
"occurred_at",
|
|
170
|
-
"source_type",
|
|
171
|
-
"idempotency_key",
|
|
172
|
-
"created_at",
|
|
173
|
-
"updated_at",
|
|
174
|
-
"created_by",
|
|
175
|
-
"updated_by",
|
|
176
|
-
"is_active"
|
|
177
|
-
)
|
|
178
|
-
SELECT
|
|
179
|
-
gen_random_uuid()::text,
|
|
180
|
-
u."organisation_id",
|
|
181
|
-
u."id",
|
|
182
|
-
stem.entitlement_type::"licensing"."LicensingLedgerEntitlementType",
|
|
183
|
-
'DEBIT'::"licensing"."LicensingLedgerDirection",
|
|
184
|
-
stem.consumed_amount,
|
|
185
|
-
'USAGE'::"licensing"."LicensingLedgerReason",
|
|
186
|
-
u."updated_at",
|
|
187
|
-
'usage_ledger',
|
|
188
|
-
'usage-backfill:' || u."id" || ':' || stem.entitlement_type,
|
|
189
|
-
u."created_at",
|
|
190
|
-
u."updated_at",
|
|
191
|
-
u."created_by",
|
|
192
|
-
u."updated_by",
|
|
193
|
-
true
|
|
194
|
-
FROM "licensing"."purchased_hiring_units" u
|
|
195
|
-
CROSS JOIN LATERAL (
|
|
196
|
-
VALUES
|
|
197
|
-
('INTERVIEW_AI_ASSISTED_HOURS', u."interview_ai_assisted_hours_consumed"),
|
|
198
|
-
('INTERVIEW_FULL_AI_HOURS', u."interview_full_ai_hours_consumed"),
|
|
199
|
-
('INTERVIEW_NON_AI_HOURS', u."interview_non_ai_hours_consumed"),
|
|
200
|
-
('ASSIGNMENT_COUNT', u."assignment_count_consumed"),
|
|
201
|
-
('TEST_COUNT', u."test_count_consumed"),
|
|
202
|
-
('RESUME_COUNT', u."resume_count_consumed"),
|
|
203
|
-
('CREDITS', u."credits_consumed")
|
|
204
|
-
) AS stem(entitlement_type, consumed_amount)
|
|
205
|
-
WHERE stem.consumed_amount IS NOT NULL AND stem.consumed_amount > 0;
|
|
206
|
-
|
|
207
|
-
-- Drop the wide balance columns from purchased_hiring_units.
|
|
208
|
-
ALTER TABLE "licensing"."purchased_hiring_units"
|
|
209
|
-
DROP COLUMN "interview_ai_assisted_hours",
|
|
210
|
-
DROP COLUMN "interview_full_ai_hours",
|
|
211
|
-
DROP COLUMN "interview_non_ai_hours",
|
|
212
|
-
DROP COLUMN "assignment_count",
|
|
213
|
-
DROP COLUMN "test_count",
|
|
214
|
-
DROP COLUMN "resume_count",
|
|
215
|
-
DROP COLUMN "credits",
|
|
216
|
-
DROP COLUMN "interview_ai_assisted_hours_consumed",
|
|
217
|
-
DROP COLUMN "interview_full_ai_hours_consumed",
|
|
218
|
-
DROP COLUMN "interview_non_ai_hours_consumed",
|
|
219
|
-
DROP COLUMN "assignment_count_consumed",
|
|
220
|
-
DROP COLUMN "test_count_consumed",
|
|
221
|
-
DROP COLUMN "resume_count_consumed",
|
|
222
|
-
DROP COLUMN "credits_consumed",
|
|
223
|
-
DROP COLUMN "interview_ai_assisted_hours_topup",
|
|
224
|
-
DROP COLUMN "interview_full_ai_hours_topup",
|
|
225
|
-
DROP COLUMN "interview_non_ai_hours_topup",
|
|
226
|
-
DROP COLUMN "assignment_count_topup",
|
|
227
|
-
DROP COLUMN "test_count_topup",
|
|
228
|
-
DROP COLUMN "resume_count_topup",
|
|
229
|
-
DROP COLUMN "credits_topup",
|
|
230
|
-
DROP COLUMN "interview_ai_assisted_hours_updated",
|
|
231
|
-
DROP COLUMN "interview_full_ai_hours_updated",
|
|
232
|
-
DROP COLUMN "interview_non_ai_hours_updated",
|
|
233
|
-
DROP COLUMN "assignment_count_updated",
|
|
234
|
-
DROP COLUMN "test_count_updated",
|
|
235
|
-
DROP COLUMN "resume_count_updated",
|
|
236
|
-
DROP COLUMN "credits_updated";
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
-- AlterTable
|
|
2
|
-
ALTER TABLE "licensing"."license_packages"
|
|
3
|
-
ADD COLUMN "cost_price" DECIMAL(18,2) NOT NULL DEFAULT 0;
|
|
4
|
-
|
|
5
|
-
-- CreateEnum
|
|
6
|
-
CREATE TYPE "licensing"."AiCostLedgerReason" AS ENUM ('USAGE', 'ADJUSTMENT', 'REFUND');
|
|
7
|
-
|
|
8
|
-
-- CreateTable
|
|
9
|
-
CREATE TABLE "licensing"."license_package_organisations" (
|
|
10
|
-
"id" TEXT NOT NULL,
|
|
11
|
-
"license_package_id" TEXT NOT NULL,
|
|
12
|
-
"organisation_id" TEXT NOT NULL,
|
|
13
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
14
|
-
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
15
|
-
"created_by" TEXT NOT NULL,
|
|
16
|
-
"updated_by" TEXT NOT NULL,
|
|
17
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
18
|
-
|
|
19
|
-
CONSTRAINT "license_package_organisations_pkey" PRIMARY KEY ("id")
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
-- CreateTable
|
|
23
|
-
CREATE TABLE "licensing"."ai_cost_ledger" (
|
|
24
|
-
"id" TEXT NOT NULL,
|
|
25
|
-
"organisation_id" TEXT NOT NULL,
|
|
26
|
-
"purchased_hiring_unit_id" TEXT NOT NULL,
|
|
27
|
-
"workflow_name" TEXT NOT NULL,
|
|
28
|
-
"direction" "licensing"."LicensingLedgerDirection" NOT NULL,
|
|
29
|
-
"amount" DECIMAL(20,4) NOT NULL,
|
|
30
|
-
"reason" "licensing"."AiCostLedgerReason" NOT NULL,
|
|
31
|
-
"occurred_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
32
|
-
"source_type" TEXT,
|
|
33
|
-
"source_id" TEXT,
|
|
34
|
-
"description" TEXT,
|
|
35
|
-
"idempotency_key" TEXT NOT NULL,
|
|
36
|
-
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
37
|
-
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
-
"created_by" TEXT NOT NULL,
|
|
39
|
-
"updated_by" TEXT NOT NULL,
|
|
40
|
-
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
41
|
-
|
|
42
|
-
CONSTRAINT "ai_cost_ledger_pkey" PRIMARY KEY ("id"),
|
|
43
|
-
CONSTRAINT "ai_cost_ledger_amount_non_negative" CHECK ("amount" >= 0)
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
-- CreateIndex
|
|
47
|
-
CREATE UNIQUE INDEX "license_package_orgs_pkg_org_key" ON "licensing"."license_package_organisations"("license_package_id", "organisation_id");
|
|
48
|
-
|
|
49
|
-
-- CreateIndex
|
|
50
|
-
CREATE INDEX "license_package_organisations_organisation_id_idx" ON "licensing"."license_package_organisations"("organisation_id");
|
|
51
|
-
|
|
52
|
-
-- CreateIndex
|
|
53
|
-
CREATE UNIQUE INDEX "ai_cost_ledger_idempotency_key_key" ON "licensing"."ai_cost_ledger"("idempotency_key");
|
|
54
|
-
|
|
55
|
-
-- CreateIndex
|
|
56
|
-
CREATE INDEX "ai_cost_ledger_unit_occurred_idx" ON "licensing"."ai_cost_ledger"("purchased_hiring_unit_id", "occurred_at");
|
|
57
|
-
|
|
58
|
-
-- CreateIndex
|
|
59
|
-
CREATE INDEX "ai_cost_ledger_unit_workflow_occurred_idx" ON "licensing"."ai_cost_ledger"("purchased_hiring_unit_id", "workflow_name", "occurred_at");
|
|
60
|
-
|
|
61
|
-
-- CreateIndex
|
|
62
|
-
CREATE INDEX "ai_cost_ledger_org_occurred_idx" ON "licensing"."ai_cost_ledger"("organisation_id", "occurred_at");
|
|
63
|
-
|
|
64
|
-
-- AddForeignKey
|
|
65
|
-
ALTER TABLE "licensing"."license_package_organisations" ADD CONSTRAINT "license_package_organisations_license_package_id_fkey" FOREIGN KEY ("license_package_id") REFERENCES "licensing"."license_packages"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
66
|
-
|
|
67
|
-
-- AddForeignKey
|
|
68
|
-
ALTER TABLE "licensing"."license_package_organisations" ADD CONSTRAINT "license_package_organisations_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
69
|
-
|
|
70
|
-
-- AddForeignKey
|
|
71
|
-
ALTER TABLE "licensing"."ai_cost_ledger" ADD CONSTRAINT "ai_cost_ledger_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
72
|
-
|
|
73
|
-
-- AddForeignKey
|
|
74
|
-
ALTER TABLE "licensing"."ai_cost_ledger" ADD CONSTRAINT "ai_cost_ledger_purchased_hiring_unit_id_fkey" FOREIGN KEY ("purchased_hiring_unit_id") REFERENCES "licensing"."purchased_hiring_units"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// PAYMENT SERVICE boundary — portable payment microservice owns these enums/columns.
|
|
2
|
-
|
|
3
|
-
enum BillingTransactionStatus {
|
|
4
|
-
INITIATED
|
|
5
|
-
ORDER_CREATED
|
|
6
|
-
PAYMENT_PENDING
|
|
7
|
-
SUCCESS
|
|
8
|
-
FAILED
|
|
9
|
-
CANCELLED
|
|
10
|
-
REFUND_PENDING
|
|
11
|
-
REFUND_FAILED
|
|
12
|
-
REFUNDED
|
|
13
|
-
|
|
14
|
-
@@schema("public")
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
enum BillingTransactionType {
|
|
18
|
-
PURCHASE
|
|
19
|
-
TOP_UP
|
|
20
|
-
REFUND
|
|
21
|
-
|
|
22
|
-
@@schema("public")
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
enum BillingTransactionFailureCategory {
|
|
26
|
-
RAZORPAY_ORDER
|
|
27
|
-
RAZORPAY_PAYMENT
|
|
28
|
-
REFUND
|
|
29
|
-
INTERNAL
|
|
30
|
-
|
|
31
|
-
@@schema("public")
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/// Payment reconciliation state when Treadspace status is FAILED but Razorpay captured payment.
|
|
35
|
-
enum BillingPaymentMismatchStatus {
|
|
36
|
-
DETECTED
|
|
37
|
-
UNFULFILLED
|
|
38
|
-
|
|
39
|
-
@@schema("public")
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/// Financial transaction lifecycle for organisation billing purchases.
|
|
43
|
-
model BillingTransaction {
|
|
44
|
-
id String @id @default(uuid())
|
|
45
|
-
organisation_id String
|
|
46
|
-
/// Opaque plan/product identity supplied at checkout. Not a catalog FK.
|
|
47
|
-
purchase_reference String
|
|
48
|
-
/// Human-readable snapshot captured at checkout for invoices and receipts.
|
|
49
|
-
purchase_display_name String?
|
|
50
|
-
transaction_type BillingTransactionType
|
|
51
|
-
status BillingTransactionStatus @default(INITIATED)
|
|
52
|
-
failure_category BillingTransactionFailureCategory?
|
|
53
|
-
/// Human-readable or provider detail (e.g. Razorpay error_description).
|
|
54
|
-
failure_reason String?
|
|
55
|
-
amount Int
|
|
56
|
-
currency String @default("INR")
|
|
57
|
-
razorpay_order_id String?
|
|
58
|
-
razorpay_payment_id String? @unique
|
|
59
|
-
/// Razorpay payment method at capture (card, netbanking, upi, wallet, etc.).
|
|
60
|
-
payment_method String?
|
|
61
|
-
razorpay_subscription_id String?
|
|
62
|
-
razorpay_refund_id String?
|
|
63
|
-
refund_reason String?
|
|
64
|
-
refund_amount Int?
|
|
65
|
-
idempotency_key String @unique
|
|
66
|
-
invoice_number String? @unique
|
|
67
|
-
/// Email of the org Admin who initiated checkout (bill-to).
|
|
68
|
-
purchaser_email String?
|
|
69
|
-
/// Set when FAILED but Razorpay order/payment is captured (reconciliation path).
|
|
70
|
-
payment_mismatch_status BillingPaymentMismatchStatus?
|
|
71
|
-
/// Strict same-intent SUCCESS transaction that fulfilled the purchase (UNFULFILLED only).
|
|
72
|
-
payment_mismatch_fulfilled_by_id String?
|
|
73
|
-
created_at DateTime @default(now())
|
|
74
|
-
updated_at DateTime @updatedAt
|
|
75
|
-
|
|
76
|
-
organisation Organisation @relation(fields: [organisation_id], references: [id])
|
|
77
|
-
|
|
78
|
-
@@index([organisation_id, status])
|
|
79
|
-
@@index([purchase_reference])
|
|
80
|
-
@@index([razorpay_order_id])
|
|
81
|
-
@@map("billing_transactions")
|
|
82
|
-
@@schema("public")
|
|
83
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
enum PaymentWebhookEventStatus {
|
|
2
|
-
RECEIVED
|
|
3
|
-
PROCESSED
|
|
4
|
-
FAILED
|
|
5
|
-
|
|
6
|
-
@@schema("public")
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/// Idempotent record of payment provider webhook deliveries.
|
|
10
|
-
model PaymentWebhookEvent {
|
|
11
|
-
id String @id @default(uuid())
|
|
12
|
-
organisation_id String?
|
|
13
|
-
provider String
|
|
14
|
-
provider_event_id String
|
|
15
|
-
event_type String
|
|
16
|
-
status PaymentWebhookEventStatus @default(RECEIVED)
|
|
17
|
-
billing_transaction_id String?
|
|
18
|
-
error_message String?
|
|
19
|
-
processed_at DateTime?
|
|
20
|
-
created_at DateTime @default(now())
|
|
21
|
-
|
|
22
|
-
organisation Organisation? @relation(fields: [organisation_id], references: [id])
|
|
23
|
-
|
|
24
|
-
@@unique([provider, provider_event_id])
|
|
25
|
-
@@index([status, created_at])
|
|
26
|
-
@@map("payment_webhook_events")
|
|
27
|
-
@@schema("public")
|
|
28
|
-
}
|