@opencard-dev/core 0.1.8 → 0.1.9
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.
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
-- Initial OpenCard database schema
|
|
2
|
+
CREATE TABLE IF NOT EXISTS migrations (
|
|
3
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
name TEXT NOT NULL UNIQUE,
|
|
5
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
CREATE TABLE IF NOT EXISTS rules (
|
|
9
|
+
id TEXT PRIMARY KEY,
|
|
10
|
+
card_id TEXT,
|
|
11
|
+
name TEXT,
|
|
12
|
+
type TEXT,
|
|
13
|
+
config TEXT NOT NULL,
|
|
14
|
+
enabled INTEGER DEFAULT 1,
|
|
15
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
16
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_rules_card_id ON rules(card_id);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_rules_created_at ON rules(created_at);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE IF NOT EXISTS transactions (
|
|
23
|
+
id TEXT PRIMARY KEY,
|
|
24
|
+
stripe_id TEXT NOT NULL UNIQUE,
|
|
25
|
+
card_id TEXT NOT NULL,
|
|
26
|
+
amount INTEGER NOT NULL,
|
|
27
|
+
currency TEXT DEFAULT 'usd',
|
|
28
|
+
merchant_name TEXT,
|
|
29
|
+
merchant_category TEXT,
|
|
30
|
+
status TEXT DEFAULT 'completed',
|
|
31
|
+
stripe_created_at DATETIME,
|
|
32
|
+
recorded_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE INDEX IF NOT EXISTS idx_transactions_card_id ON transactions(card_id);
|
|
36
|
+
CREATE INDEX IF NOT EXISTS idx_transactions_stripe_id ON transactions(stripe_id);
|
|
37
|
+
CREATE INDEX IF NOT EXISTS idx_transactions_status ON transactions(status);
|
|
38
|
+
CREATE INDEX IF NOT EXISTS idx_transactions_created_at ON transactions(stripe_created_at);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE IF NOT EXISTS authorizations (
|
|
41
|
+
id TEXT PRIMARY KEY,
|
|
42
|
+
stripe_id TEXT NOT NULL UNIQUE,
|
|
43
|
+
card_id TEXT NOT NULL,
|
|
44
|
+
amount INTEGER NOT NULL,
|
|
45
|
+
currency TEXT DEFAULT 'usd',
|
|
46
|
+
merchant_name TEXT,
|
|
47
|
+
merchant_category TEXT,
|
|
48
|
+
status TEXT DEFAULT 'pending',
|
|
49
|
+
decision_reason TEXT,
|
|
50
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
51
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
CREATE INDEX IF NOT EXISTS idx_authorizations_card_id ON authorizations(card_id);
|
|
55
|
+
CREATE INDEX IF NOT EXISTS idx_authorizations_stripe_id ON authorizations(stripe_id);
|
|
56
|
+
CREATE INDEX IF NOT EXISTS idx_authorizations_status ON authorizations(status);
|
|
57
|
+
CREATE INDEX IF NOT EXISTS idx_authorizations_created_at ON authorizations(created_at);
|
|
58
|
+
|
|
59
|
+
CREATE TABLE IF NOT EXISTS rule_versions (
|
|
60
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
61
|
+
rule_id TEXT NOT NULL,
|
|
62
|
+
version INTEGER NOT NULL,
|
|
63
|
+
config TEXT NOT NULL,
|
|
64
|
+
changed_by TEXT,
|
|
65
|
+
changed_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
66
|
+
change_type TEXT NOT NULL,
|
|
67
|
+
UNIQUE(rule_id, version)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
CREATE INDEX IF NOT EXISTS idx_rule_versions_rule_id ON rule_versions(rule_id);
|
|
71
|
+
CREATE INDEX IF NOT EXISTS idx_rule_versions_changed_at ON rule_versions(changed_at);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- Approval requests table: human-in-the-loop spending approval
|
|
2
|
+
CREATE TABLE IF NOT EXISTS approval_requests (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
card_id TEXT NOT NULL,
|
|
5
|
+
amount INTEGER NOT NULL,
|
|
6
|
+
currency TEXT DEFAULT 'usd',
|
|
7
|
+
merchant_name TEXT NOT NULL,
|
|
8
|
+
merchant_category TEXT,
|
|
9
|
+
reason TEXT NOT NULL,
|
|
10
|
+
status TEXT DEFAULT 'pending', -- pending | approved | denied | expired
|
|
11
|
+
decided_by TEXT, -- who approved/denied
|
|
12
|
+
decided_at DATETIME,
|
|
13
|
+
decision_note TEXT, -- optional note from approver
|
|
14
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
expires_at DATETIME NOT NULL
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_approval_requests_status ON approval_requests(status);
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_approval_requests_card_id ON approval_requests(card_id);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_approval_requests_created_at ON approval_requests(created_at);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_approval_requests_expires_at ON approval_requests(expires_at);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencard-dev/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Stripe Issuing wrapper with rules engine for AI agent spending",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"migrations"
|
|
32
33
|
],
|
|
33
34
|
"keywords": [
|
|
34
35
|
"stripe",
|