Skip to content

Commit b95fb6a

Browse files
committed
restart
1 parent 6a626fa commit b95fb6a

File tree

7 files changed

+208
-153
lines changed

7 files changed

+208
-153
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Schemes and kinds
4040
- phone
4141
- regid - ičo
4242
- vatid - dič
43+
- name
44+
- kind:natural
45+
- kind:legal
4346
- vat_payer - současný stav + historie
4447
- payroll
4548
- object:nationality (string - countrycode)
@@ -229,3 +232,18 @@ SELECT JSON_OBJECTAGG(uuid,data) as data from (
229232
As of current (MySQL v 8.0.31), the database builtin function `JSON_REMOVE` will
230233
not accept a wildcard in the jsonpath. Hence, removing metadata to lighten the
231234
json response is done PHP side via https://github.com/Galbar/JsonPath-PHP.
235+
236+
## Sample data
237+
238+
```sql
239+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "uri", "_v": 1, "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/t1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "website", "uuid": "17c9eb5c-d9d0-4701-aec5-9c25a5c1d020", "value": "https://vaizard.org"}');
240+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "name", "_v": 1, "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/t1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "natural", "uuid": "9a4d54b3-d7c1-46dd-9ba3-acfb19537bad", "given": "Igor", "label": null, "value": "Mgr. Igor Hnizdo, MSc.", "family": "Hnizdo", "prefix": "Mgr.", "suffix": "MSc."}');
241+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "name", "_v": 1, "_iat": 1673721912, "_iss": "https://wwwinfo.mfcr.cz/ares/ares_es.html.cz", "_sub": "bac72087-73e4-48ed-9f27-e51c531e42bb", "kind": "legal", "uuid": "bacd54b3-d7c1-46dd-9ba3-acfb19537bad", "value": "Bauhaus, k.s."}');
242+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "email", "_v": 1, "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/t1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "uuid": "fd2f47b6-ae0a-46ec-91f6-8dcbd7294ff4", "label": null, "value": "igor@example.com", "_primary": 1}');
243+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "phone", "_v": 1, "_iat": 1673721512, "_iss": "https://example.com/", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "uuid": "fd2f47b6-ae0a-46ec-91f6-8dcbd7294ff4", "label": null, "value": "+4207123456"}');
244+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "service", "_v": 1, "uri": "https://id.example.com/auth/realms/example1", "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/example1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "oidc", "uuid": "3d2c1354-9931-4af4-a2e4-02257d4f7e1c", "value": "https://id.example.com/auth/realms/example1/igorh", "handle": "igorh"}');
245+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "address", "_v": 1, "cc": "CZ", "zip": "61500", "_iat": 1673721512, "_iss": "https://glued.example.com/api/users/v1/pupen", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "main", "unit": "Studio 13", "uuid": "432c1aaa-1131-abf4-b2eb-537b7d4f7111", "extra": "Béžová budova naproti výtopně", "floor": "1", "pobox": "123", "value": "Studio 13, 1. podlaží, Budova č. 76 - Industra Labs, Lazaretní 1/7, Brno-Židenice, Brno-Město, Jihomoravský kraj, 61500, CZ", "region": "Jihomoravský kraj", "street": "Lazaretní", "quarter": "Židenice", "district": "Brno-Město", "locacity": "Brno", "conscr_no": "1", "street_no": "7", "building_no": "76", "building_name": "Industra Labs"}');
246+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "natid", "_v": 1, "icc": "CZ", "num": "901111/3452", "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/t1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "CZ", "uuid": "fabd07f8-5005-43d6-9fd2-0a71511478c9", "value": "901111/3452"}');
247+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "vatid", "_v": 1, "icc": "CZ", "num": "CZ29228107", "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/t1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "CZ", "uuid": "e974af5c-afb0-4817-9f33-9a9d25839ab2", "value": "CZ29228107"}');
248+
INSERT INTO glued.t_contacts_atoms (c_data) VALUES ('{"_s": "regid", "_v": 1, "icc": "CZ", "num": "29228107", "_iat": 1673721512, "_iss": "https://id.example.com/auth/realms/t1", "_sub": "7e172087-73e4-48ed-9f27-e51c531e42bb", "kind": "CZ", "uuid": "af5ce974-fbb0-4817-339f-d25839ab29a9", "value": "29228107"}');
249+
```

composer.json

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"php": "^8.1",
12+
"php": "^8.2",
1313
"ext-apcu": "*",
1414
"ext-bcmath": "*",
1515
"ext-curl": "*",
@@ -21,54 +21,44 @@
2121
"ext-mysqli": "*",
2222
"ext-readline": "*",
2323
"ext-soap": "*",
24+
"ext-sodium": "*",
2425
"ext-xml": "*",
26+
"casbin/database-adapter": "^1",
2527
"facile-it/php-openid-client": "dev-master",
26-
"foxy/foxy": "^v1.2.1",
28+
"galbar/jsonpath": "^3",
2729
"geocoder-php/geoip2-provider": "^4",
28-
"guzzlehttp/psr7": "^1",
30+
"grasmash/yaml-expander": "^3",
31+
"guzzlehttp/psr7": "^2",
2932
"http-interop/http-factory-guzzle": "^1",
33+
"keiko/uuid-shortener": "^1",
3034
"league/flysystem": "^3",
3135
"middlewares/trailing-slash": "^2",
32-
"monolog/monolog": "^2",
36+
"monolog/monolog": "^3",
3337
"nyholm/psr7": "^1",
3438
"opis/json-schema": "^2",
35-
"php-di/php-di": "^6",
39+
"php-di/php-di": "^7",
3640
"php-http/guzzle7-adapter": "^1",
3741
"php-http/message": "^1",
3842
"phpfastcache/phpfastcache": "^9",
39-
"sabre/event": "^5",
43+
"ramsey/uuid": "^4",
44+
"sabre/event": "^6",
45+
"selective/transformer": "^1",
46+
"shuchkin/simplexlsxgen": "^1.2",
4047
"slim/http": "^1",
4148
"slim/slim": "^4",
49+
"symfony/config": "^6",
4250
"symfony/mailer": "^6",
43-
"symfony/yaml": "^5",
51+
"symfony/yaml": "^6",
4452
"thingengineer/mysqli-database-class": "dev-master#42116651a88b57b03fd967bc57dd38f5094565d9",
45-
"tuupola/slim-jwt-auth": "^3",
46-
"voku/anti-xss": "^4",
47-
"zeuxisoo/slim-whoops": "^0.7",
48-
"symfony/config": "^5",
49-
"selective/transformer": "^1",
50-
"casbin/database-adapter": "^1",
51-
"ramsey/uuid": "^4",
5253
"vaizard/glued-lib": "dev-main",
53-
"grasmash/yaml-expander": "^3",
5454
"vlucas/phpdotenv": "^5",
55-
"keiko/uuid-shortener": "^0.6.1",
56-
"shuchkin/simplexlsxgen": "^1.2",
57-
"youthweb/urllinker": "^1.4",
58-
"galbar/jsonpath": "^2.1"
59-
},
60-
"suggest": {
61-
"ext-xdebug": "For dev only"
55+
"zeuxisoo/slim-whoops": "^0.7"
6256
},
6357
"require-dev": {
6458
"ergebnis/composer-normalize": "^2"
6559
},
66-
"autoload": {
67-
"psr-4": {
68-
"Glued\\": "glued/"
69-
},
70-
"files": [
71-
]
60+
"suggest": {
61+
"ext-xdebug": "For dev only"
7262
},
7363
"repositories": [
7464
{
@@ -79,7 +69,30 @@
7969
],
8070
"minimum-stability": "beta",
8171
"prefer-stable": true,
72+
"autoload": {
73+
"psr-4": {
74+
"Glued\\": "glued/"
75+
},
76+
"files": []
77+
},
78+
"config": {
79+
"allow-plugins": {
80+
"ergebnis/composer-normalize": true,
81+
"foxy/foxy": true,
82+
"php-http/discovery": true
83+
}
84+
},
8285
"scripts": {
86+
"post-install-cmd": [
87+
"composer configure || echo \"[FAIL] Failed to configure glued. Please make sure all env variables are set. Rerun composer configure.\"",
88+
"composer migrate",
89+
"echo \"Run 'composer nginx' manually to pick restart this microservice\""
90+
],
91+
"post-update-cmd": [
92+
"composer configure || echo \"[FAIL] Failed to configure glued. Please make sure all env variables are set. Rerun composer configure.\"",
93+
"composer migrate",
94+
"echo \"Run 'composer nginx' manually to pick restart this microservice\""
95+
],
8396
"backup": [
8497
"vendor/vaizard/glued-lib/src/Scripts/backup.sh"
8598
],
@@ -95,29 +108,18 @@
95108
"vendor/vaizard/glued-lib/src/Scripts/migrate.sh"
96109
],
97110
"nginx": [
111+
"patch -s --reject-file=/dev/null -p1 vendor/monolog/monolog/src/Monolog/Logger.php < vendor/vaizard/glued-lib/src/Patches/Logger.patch",
98112
"vendor/vaizard/glued-lib/src/Scripts/nginx.sh",
99113
"Glued\\Lib\\ComposerHooks::generateNginx",
100-
"vendor/vaizard/glued-lib/src/Scripts/nginx-reload.sh"
101-
],
102-
"post-install-cmd": [
103-
"composer configure || echo \"[FAIL] Failed to configure glued. Please make sure all env variables are set. Rerun composer configure.\"",
104-
"composer migrate",
105-
"echo \"Run 'composer nginx' manually to pick restart this microservice\""
106-
],
107-
"post-update-cmd": [
108-
"composer configure || echo \"[FAIL] Failed to configure glued. Please make sure all env variables are set. Rerun composer configure.\"",
109-
"composer migrate",
110-
"echo \"Run 'composer nginx' manually to pick restart this microservice\""
114+
"vendor/vaizard/glued-lib/src/Scripts/nginx-reload.sh",
115+
"vendor/vaizard/glued-lib/src/Scripts/php-fpm.sh",
116+
"Glued\\Lib\\ComposerHooks::generatePHPFPM",
117+
"vendor/vaizard/glued-lib/src/Scripts/php-fpm-reload.sh",
118+
"patch -Rs --reject-file=/dev/null -p1 vendor/monolog/monolog/src/Monolog/Logger.php < vendor/vaizard/glued-lib/src/Patches/Logger.patch"
111119
],
112120
"settings": [
113121
"Glued\\Lib\\ComposerHooks::PrintSettings"
114122
],
115123
"start": "php -S localhost:8080 -t public"
116-
},
117-
"config": {
118-
"allow-plugins": {
119-
"ergebnis/composer-normalize": true,
120-
"foxy/foxy": true
121-
}
122124
}
123125
}

glued/Config/Migrations/20230121131601_contacts_atoms.sql

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- migrate:up
2+
3+
CREATE TABLE `t_contacts_objects` (
4+
`c_uuid` binary(16) NOT NULL COMMENT 'Object UUID',
5+
`c_rev` int unsigned NOT NULL DEFAULT '0' COMMENT 'Object revision',
6+
`c_data` json DEFAULT NULL COMMENT 'Object data as JSON',
7+
`c_private` bit(1) NOT NULL DEFAULT b'0' COMMENT 'Exclude private data from ft search',
8+
`c_ts` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Timestamp column',
9+
`c_ft` text COMMENT 'Fulltext search',
10+
`c_hash` binary(16) GENERATED ALWAYS AS (unhex(md5(`c_data`))) STORED,
11+
PRIMARY KEY (`c_uuid`),
12+
UNIQUE KEY `idx_c_hash` (`c_hash`),
13+
FULLTEXT KEY `idx_c_ft` (`c_ft`)
14+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
15+
16+
17+
CREATE TABLE `t_contacts_objects_refs` (
18+
`obj` binary(16) NOT NULL COMMENT 'Object UUID',
19+
`ref_label` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '_' COMMENT 'Reference label',
20+
`ref_val` binary(16) NOT NULL COMMENT 'Reference UUID',
21+
`ref_kind` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Reference kind',
22+
`ref_from` timestamp NULL DEFAULT NULL COMMENT 'Reference valid from',
23+
`ref_until` timestamp NULL DEFAULT NULL COMMENT 'Reference valid until',
24+
PRIMARY KEY (`obj`,`ref_label`,`ref_kind`,`ref_val`),
25+
KEY `obj` (`obj`),
26+
KEY `obj_obj_generation` (`obj`)
27+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='References between objects';
28+
29+
-- migrate:down
30+
31+
DROP TABLE IF EXISTS `t_contacts_objects`;
32+
DROP TABLE IF EXISTS `t_contacts_objects_refs`;

glued/Config/routes.yaml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ routes:
1717
#########################################################
1818

1919
be_contacts_health_v1:
20-
pattern: ${routes.be_contacts.path}/health/v1
21-
path: ${routes.be_contacts.path}/health/v1
20+
pattern: ${routes.be_contacts.path}/v1/health
21+
path: ${routes.be_contacts.path}/v1/health
2222
label: contacts health
2323
dscr: A healthcheck endpoint for the microservice.
2424
service: contacts
@@ -31,32 +31,29 @@ routes:
3131
#########################################################
3232

3333
be_contacts_v1:
34-
pattern: ${routes.be_contacts.path}/v1
35-
path: ${routes.be_contacts.path}/v1
34+
pattern: ${routes.be_contacts.path}/v1/objects[/{uuid}]
35+
path: ${routes.be_contacts.path}/v1/objects
3636
label: Contacts
3737
dscr: Address book.
3838
service: contacts
3939
methods:
4040
get: Glued\Controllers\ServiceController:contacts_r1
41-
post: Glued\Controllers\ServiceController:contacts_cu1
42-
put: Glued\Controllers\ServiceController:contacts_cu1
43-
patch: Glued\Controllers\ServiceController:contacts_cu1
44-
delete: Glued\Controllers\ServiceController:contacts_d1
45-
46-
be_contacts_rels_v1:
47-
pattern: ${routes.be_contacts.path}/rels/v1
48-
path: ${routes.be_contacts.path}/rels/v1
49-
label: Relationships
50-
dscr: Relationships between persons.
41+
post: Glued\Controllers\ServiceController:contacts_p1
42+
43+
be_contacts_refs_v1:
44+
pattern: ${routes.be_contacts.path}/v1/{uuid}/refs
45+
path: ${routes.be_contacts.path}/v1/refs
46+
label: References
47+
dscr: Relationship references between contact objects.
5148
service: contacts
5249
methods:
53-
get: Glued\Controllers\ServiceController:rels_r1
50+
get: Glued\Controllers\ServiceController:refs_r1
5451

55-
be_contacts_regs_v1:
56-
pattern: ${routes.be_contacts.path}/regs/v1
57-
path: ${routes.be_contacts.path}/regs/v1
58-
label: Registers
59-
dscr: Fetching data from registers.
52+
be_contacts_import_v1:
53+
pattern: ${routes.be_contacts.path}/v1/import/{act}/{key}
54+
path: ${routes.be_contacts.path}/v1/import
55+
label: Import
56+
dscr: Address book.
6057
service: contacts
6158
methods:
62-
get: Glued\Controllers\ServiceController:regs_r1
59+
get: Glued\Controllers\ServiceController:import_r1

0 commit comments

Comments
 (0)