Skip to content

Commit 36b1250

Browse files
committed
fuck it up
1 parent 4660481 commit 36b1250

20 files changed

+596
-778
lines changed

.env.dist

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
1-
datapath="/var/www/html/data"
2-
3-
mysql_hostname="localhost"
4-
mysql_database="glued"
5-
mysql_username="glued"
6-
mysql_password="glued-pw"
7-
8-
# see crypto lib, key must be of specific size
9-
crypto_secret_mail="..."
10-
crypto_secret_reqparams="..."
11-
12-
smtp_host="mail.example.com"
13-
smtp_user="me@example.com"
14-
smtp_pass="pass"
15-
smtp_from="FROM TEXT"
16-
17-
identity="id.example.com"
18-
identity_realm="my-glued-realm"
19-
identity_admin_id="admin-cli"
20-
identity_admin_user="user"
21-
identity_admin_pass="pass"
22-
identity_confidential_id="new-client"
23-
identity_confidential_secret="some-secret"
24-
identity_public_id="new-client-2"
25-
26-
sqlsrv_hostname="localhot"
27-
sqlsrv_database="database"
28-
sqlsrv_username="login"
29-
sqlsrv_password="pass"
30-
1+
DATAPATH="/var/www/html/data"
2+
HOSTNAME=""
3+
4+
MYSQL_HOSTNAME="127.0.0.1"
5+
MYSQL_DATABASE="glued"
6+
MYSQL_USERNAME="glued"
7+
MYSQL_PASSWORD="glued-pw"
8+
9+
SMTP_HOST="mail.example.com"
10+
SMTP_USER="me@example.com"
11+
SMTP_PASS="pass"
12+
SMTP_FROM="FROM TEXT"
13+
14+
GEOIP=""
15+
16+
IDENTITY="id.example.com"
17+
IDENTITY_REALM="my-glued-realm"
18+
IDENTITY_ADMIN_ID="admin-cli"
19+
IDENTITY_ADMIN_USER="user"
20+
IDENTITY_ADMIN_PASS="pass"
21+
IDENTITY_CONFIDENTIAL_ID="oidc-confidential"
22+
IDENTITY_CONFIDENTIAL_SECRET="some-secret"
23+
IDENTITY_PUBLIC_ID="oidc-public"
24+
25+
# REACT
26+
27+
REACT_APP_ENDPOINT="https://${HOSTNAME}"
28+
REACT_APP_AUTH_TOKEN_ENDPOINT="https://${IDENTITY}/auth/realms/${IDENTITY_REALM}/protocol/openid-connect/token"
29+
REACT_APP_AUTH_ENDPOINT="https://${IDENTITY}/auth/realms/${IDENTITY_REALM}/protocol/openid-connect/auth"
30+
REACT_APP_AUTH_ENDSESSION_ENDPOINT="https://${IDENTITY}/auth/realms/${IDENTITY_REALM}/protocol/openid-connect/logout"
31+
REACT_APP_AUTH_CLIENT_ID="${IDENTITY_PUBLIC_ID}"
32+
CONFIG_NAME="dev"
3133

3234
###
3335
### Generated stuff
3436
###
3537

36-
DATABASE_URL="mysql://${mysql_username}:${mysql_password}@${mysql_hostname}:3306/${mysql_database}"
38+
DATABASE_URL="mysql://${MYSQL_USERNAME}:${MYSQL_PASSWORD}@${MYSQL_HOSTNAME}:3306/${MYSQL_DATABASE}"
3739
GLUED_PROD=1 # this has no meaning here. Will only work when set from environment (disables loading of this file)

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"php": "^8.2",
12+
"php": "^8.3",
1313
"ext-apcu": "*",
1414
"ext-bcmath": "*",
1515
"ext-curl": "*",
@@ -98,8 +98,8 @@
9898
],
9999
"configure": [
100100
"vendor/vaizard/glued-lib/src/Scripts/initpaths.sh",
101-
"Glued\\Lib\\ComposerHooks::configTool",
102-
"vendor/vaizard/glued-lib/src/Scripts/cacheroutes.sh"
101+
"vendor/vaizard/glued-lib/src/Scripts/rebuild-datacache.sh",
102+
"Glued\\Lib\\ComposerHooks::configTool"
103103
],
104104
"genkey": [
105105
"Glued\\Lib\\ComposerHooks::genKey"

glued/Config/Nginx/sites-available/glued-contacts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ server {
88
##########################
99

1010
root /var/www/html/glued-contacts/public;
11-
listen 8010 ssl http2 default_server;
12-
listen [::]:8010 ssl http2 default_server;
11+
listen 8010 ssl default_server;
12+
listen [::]:8010 ssl default_server;
13+
http2 on;
1314
include snippets/server/common.conf;
1415

1516
##########################
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
-- migrate:up
2+
3+
CREATE TABLE contacts_cards (
4+
uuid UUID GENERATED ALWAYS AS ((doc->>'uuid')::UUID) STORED PRIMARY KEY,
5+
doc JSONB DEFAULT NULL,
6+
ft TEXT,
7+
private BOOLEAN GENERATED ALWAYS AS (COALESCE((doc->>'props.private')::INTEGER, 0) = 1) STORED,
8+
nonce bytea generated always as ( decode( md5((doc - 'uuid')::text), 'hex')) stored,
9+
created_at timestamp with time zone default CURRENT_TIMESTAMP,
10+
updated_at timestamp with time zone default CURRENT_TIMESTAMP,
11+
UNIQUE (nonce)
12+
);
13+
14+
COMMENT ON COLUMN contacts_cards.uuid IS 'Card UUID';
15+
COMMENT ON COLUMN contacts_cards.doc IS 'Card data as JSON';
16+
COMMENT ON COLUMN contacts_cards.created_at IS 'Created at';
17+
COMMENT ON COLUMN contacts_cards.updated_at IS 'Updated at';
18+
COMMENT ON COLUMN contacts_cards.ft IS 'Fulltext search';
19+
COMMENT ON COLUMN contacts_cards.private IS 'Exclude private data from ft search';
20+
COMMENT ON COLUMN contacts_cards.nonce IS 'Generated MD5 hash of the doc JSON';
21+
22+
-- Create full-text search GIN index using the simple configuration
23+
CREATE INDEX idx_ft ON contacts_cards USING GIN (to_tsvector('simple', ft));
24+
25+
CREATE TABLE contacts_refs (
26+
uuid1 UUID NOT NULL,
27+
uuid2 UUID NOT NULL,
28+
label TEXT NOT NULL DEFAULT '_',
29+
kind TEXT NOT NULL,
30+
bind_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL,
31+
part_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL,
32+
PRIMARY KEY (uuid1, uuid2, label, kind)
33+
);
34+
35+
COMMENT ON COLUMN contacts_refs.uuid1 IS 'Card UUID 1';
36+
COMMENT ON COLUMN contacts_refs.uuid2 IS 'Card UUID 2';
37+
COMMENT ON COLUMN contacts_refs.label IS 'Reference label';
38+
COMMENT ON COLUMN contacts_refs.kind IS 'Reference kind';
39+
COMMENT ON COLUMN contacts_refs.bind_at IS 'Connection bound at';
40+
COMMENT ON COLUMN contacts_refs.part_at IS 'Connection parted at';
41+
42+
CREATE INDEX idx_uuid1 ON contacts_refs (uuid1);
43+
CREATE INDEX idx_uuid2 ON contacts_refs (uuid2);
44+
45+
CREATE TABLE contacts_cards_audit (
46+
uuid UUID NOT NULL,
47+
nonce BYTEA GENERATED ALWAYS AS (decode(md5(doc::TEXT), 'hex')) STORED,
48+
doc JSONB DEFAULT NULL,
49+
updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP
50+
);
51+
52+
COMMENT ON COLUMN contacts_cards_audit.uuid IS 'Card UUID';
53+
COMMENT ON COLUMN contacts_cards_audit.nonce IS 'Generated MD5 hash of the doc JSON';
54+
COMMENT ON COLUMN contacts_cards_audit.doc IS 'Card data as JSON';
55+
COMMENT ON COLUMN contacts_cards_audit.updated_at IS 'Timestamp updated at';
56+
57+
CREATE OR REPLACE VIEW v_contacts_cards_audit AS
58+
SELECT
59+
t.*,
60+
ROW_NUMBER() OVER (PARTITION BY t.uuid ORDER BY t.updated_at) AS rev,
61+
COUNT(*) OVER (PARTITION BY t.uuid) AS rev_count
62+
FROM contacts_cards_audit t;
63+
64+
CREATE OR REPLACE FUNCTION before_update_contacts_cards()
65+
RETURNS TRIGGER AS $$
66+
BEGIN
67+
IF (OLD.nonce <> NEW.nonce) THEN
68+
INSERT INTO contacts_cards_audit (uuid, doc, updated_at)
69+
VALUES (OLD.uuid, OLD.doc, NOW());
70+
END IF;
71+
RETURN NEW;
72+
END;
73+
$$ LANGUAGE plpgsql;
74+
75+
CREATE TRIGGER before_update_contacts_cards
76+
BEFORE UPDATE ON contacts_cards
77+
FOR EACH ROW
78+
EXECUTE FUNCTION before_update_contacts_cards();
79+
80+
81+
-- migrate:down
82+
83+
DROP TABLE IF EXISTS contacts_cards;
84+
DROP TABLE IF EXISTS contacts_refs;
85+
86+
DROP VIEW IF EXISTS v_contacts_cards_audit;
87+
DROP TABLE IF EXISTS contacts_cards_audit;
88+
89+
DROP TRIGGER IF EXISTS before_update_contacts_cards ON contacts_cards;
90+
DROP FUNCTION IF EXISTS before_update_contacts_cards;

glued/Config/openapi.yaml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Glued Contacts Api
4+
description: Contacts APIs for Glued services, including health checks, address book management, and relationship references.
5+
version: 1.0.0
6+
x-glued-service: contacts
7+
servers:
8+
- url: /api/contacts
9+
paths:
10+
/:
11+
x-glued-pathname: be_contacts
12+
x-glued-provides: openapi
13+
get:
14+
x-glued-method: Glued\Controllers\ServiceController:getOpenapi
15+
summary: Contacts OpenAPI specs / Ingress
16+
description: Returns the OpenAPI YAML specification for the contacts API.
17+
operationId: contactsIngress
18+
responses:
19+
'200':
20+
description: Ok
21+
content:
22+
application/yaml:
23+
schema:
24+
type: string
25+
/v1/health:
26+
x-glued-pathname: be_contacts_health
27+
x-glued-provides: health
28+
get:
29+
x-glued-method: Glued\Controllers\ServiceController:getHealth
30+
summary: Healthcheck
31+
description: A healthcheck endpoint.
32+
operationId: contactsGetHealth
33+
responses:
34+
'200':
35+
description: Ok
36+
/v1/cards:
37+
x-glued-pathname: be_contacts_cards
38+
x-glued-provides: service
39+
get:
40+
x-glued-method: Glued\Controllers\ServiceController:getCards
41+
summary: Retrieve Contacts Cards
42+
description: Retrieve contacts from the address book.
43+
operationId: getContactsCards
44+
parameters:
45+
- name: q
46+
in: query
47+
required: false
48+
schema:
49+
type: string
50+
responses:
51+
'200':
52+
description: Ok
53+
post:
54+
x-glued-method: Glued\Controllers\ServiceController:postCards
55+
summary: Add Contacts Cards
56+
description: Add new contacts to the address book.
57+
operationId: postContactsCards
58+
responses:
59+
'200':
60+
description: Ok
61+
/v1/cards/{uuid}:
62+
x-glued-pathname: be_contacts_card
63+
x-glued-provides: service
64+
get:
65+
x-glued-method: Glued\Controllers\ServiceController:getCard
66+
summary: Retrieve Contacts Card
67+
description: Retrieve a specific contact from the address book.
68+
operationId: getContactsCard
69+
parameters:
70+
- name: uuid
71+
in: path
72+
required: true
73+
schema:
74+
type: string
75+
responses:
76+
'200':
77+
description: Ok
78+
post:
79+
x-glued-method: Glued\Controllers\ServiceController:postCard
80+
summary: Update Contacts Card
81+
description: Update a specific contact in the address book.
82+
operationId: postContactsCard
83+
responses:
84+
'200':
85+
description: Ok
86+
/v1/cards/{uuid}/refs:
87+
x-glued-pathname: be_contacts_refs
88+
x-glued-provides: service
89+
get:
90+
x-glued-method: Glued\Controllers\ServiceController:getRefs
91+
summary: Retrieve References
92+
description: Retrieve relationship references between contact objects.
93+
operationId: getReferences
94+
parameters:
95+
- name: uuid
96+
in: path
97+
required: true
98+
schema:
99+
type: string
100+
responses:
101+
'200':
102+
description: Ok
103+
post:
104+
x-glued-method: Glued\Controllers\ServiceController:postRefs
105+
summary: Add References
106+
description: Add relationship references between contact objects.
107+
operationId: postReferences
108+
parameters:
109+
- name: uuid
110+
in: path
111+
required: true
112+
schema:
113+
type: string
114+
responses:
115+
'200':
116+
description: Ok
117+
/v1/import/{act}/{key}:
118+
x-glued-pathname: be_contacts_import
119+
x-glued-provides: service
120+
get:
121+
x-glued-method: Glued\Controllers\ServiceController:importFromCache
122+
summary: Import Contacts
123+
description: Import contacts into the address book.
124+
operationId: importContacts
125+
parameters:
126+
- name: act
127+
in: path
128+
required: true
129+
schema:
130+
type: string
131+
- name: key
132+
in: path
133+
required: true
134+
schema:
135+
type: string
136+
responses:
137+
'200':
138+
description: Ok

glued/Config/routes.yaml

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)