Compare commits
24 Commits
feature/ch
...
v1.15.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a796c83826 | ||
|
|
826aa6d379 | ||
|
|
087f3d2d86 | ||
|
|
74a9ac2eb1 | ||
|
|
28d63c10ba | ||
|
|
bb377639f4 | ||
|
|
4179194e6f | ||
|
|
f5e24f3bc3 | ||
|
|
5bdf87632a | ||
|
|
cbe53c5b6b | ||
|
|
0f7313b944 | ||
|
|
411d16e33d | ||
|
|
6d1b58ecf0 | ||
|
|
1767eff19b | ||
|
|
e30e93e00e | ||
|
|
2958262abf | ||
|
|
3b3a7b548c | ||
|
|
bdf7802a31 | ||
|
|
7b8890b1ff | ||
|
|
bb74c52267 | ||
|
|
3d749242aa | ||
|
|
d52f121a0b | ||
|
|
76cb2ef547 | ||
|
|
c41175cbb1 |
@@ -0,0 +1,33 @@
|
|||||||
|
PREFIX org: <http://www.w3.org/ns/org#>
|
||||||
|
PREFIX locn: <http://www.w3.org/ns/locn#>
|
||||||
|
PREFIX schema: <http://schema.org/>
|
||||||
|
|
||||||
|
DELETE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
?mandatarissen ?pMandatarissen ?oMandatarissen .
|
||||||
|
?contactPoint ?pContactPoint ?oContactPoint .
|
||||||
|
?address ?pAddress ?oAddress .
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WHERE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
VALUES ?mandatarissen {
|
||||||
|
<http://data.lblod.info/id/mandatarissen/62629ED7FEE49A5CF118F11D>
|
||||||
|
<http://data.lblod.info/id/mandatarissen/63D24E975410CAD909EF6CD0>
|
||||||
|
}
|
||||||
|
|
||||||
|
?mandatarissen ?pMandatarissen ?oMandatarissen .
|
||||||
|
|
||||||
|
OPTIONAL {
|
||||||
|
?mandatarissen schema:contactPoint ?contactPoint .
|
||||||
|
?contactPoint ?pContactPoint ?oContactPoint.
|
||||||
|
OPTIONAL {
|
||||||
|
?contactPoint locn:address ?address .
|
||||||
|
?address ?pAddress ?oAddress .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
PREFIX org: <http://www.w3.org/ns/org#>
|
||||||
|
PREFIX adms: <http://www.w3.org/ns/adms#>
|
||||||
|
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||||
|
PREFIX organisatie: <https://data.vlaanderen.be/ns/organisatie#>
|
||||||
|
|
||||||
|
DELETE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
?bestuur ?pbestuur ?obestuur .
|
||||||
|
?primarySite ?pprimarySite ?oprimarySite .
|
||||||
|
?address ?paddress ?oaddress .
|
||||||
|
?contactPoint ?pcontactPoint ?ocontactPoint .
|
||||||
|
?identifier ?pidentifier ?oidentifier .
|
||||||
|
?structuredIdentifier ?pstructuredIdentifier ?ostructuredIdentifier .
|
||||||
|
}
|
||||||
|
} WHERE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
BIND(<http://data.lblod.info/id/besturenVanDeEredienst/578bf96f86056e2260dc21cee91aa519> as ?bestuur)
|
||||||
|
|
||||||
|
?bestuur ?pbestuur ?obestuur .
|
||||||
|
|
||||||
|
OPTIONAL {
|
||||||
|
|
||||||
|
?bestuur org:hasPrimarySite ?primarySite .
|
||||||
|
|
||||||
|
OPTIONAL {
|
||||||
|
?primarySite organisatie:bestaatUit ?address .
|
||||||
|
?address ?paddress ?oaddress .
|
||||||
|
}
|
||||||
|
OPTIONAL {
|
||||||
|
?primarySite org:siteAddress ?contactPoint .
|
||||||
|
?contactPoint ?pcontactPoint ?ocontactPoint .
|
||||||
|
}
|
||||||
|
|
||||||
|
?primarySite ?pprimarySite ?oprimarySite .
|
||||||
|
|
||||||
|
}
|
||||||
|
OPTIONAL {
|
||||||
|
|
||||||
|
?bestuur adms:identifier ?identifier .
|
||||||
|
|
||||||
|
OPTIONAL {
|
||||||
|
?identifier generiek:gestructureerdeIdentificator ?structuredIdentifier .
|
||||||
|
?structuredIdentifier ?pstructuredIdentifier ?ostructuredIdentifier .
|
||||||
|
}
|
||||||
|
|
||||||
|
?identifier ?pidentifier ?oidentifier .
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
|
||||||
|
PREFIX schema: <http://schema.org/>
|
||||||
|
PREFIX locn: <http://www.w3.org/ns/locn#>
|
||||||
|
PREFIX org: <http://www.w3.org/ns/org#>
|
||||||
|
|
||||||
|
DELETE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
?mandatarissen ?pMandatarissen ?oMandatarissen .
|
||||||
|
?mandaat ?pMandaat ?oMandaat .
|
||||||
|
?person ?pPerson ?oPerson .
|
||||||
|
?contactPoint ?pContactPoint ?oContactPoint .
|
||||||
|
?address ?pAddress ?oAddress .
|
||||||
|
}
|
||||||
|
} WHERE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
VALUES ?mandatarissen {
|
||||||
|
<http://data.lblod.info/id/mandatarissen/807a3e07c95fe40962d64695069af946> #1
|
||||||
|
<http://data.lblod.info/id/mandatarissen/40ed3cb19f9fa33e47b39016780dce1d> #2
|
||||||
|
}
|
||||||
|
|
||||||
|
?mandatarissen org:holds ?mandaat ;
|
||||||
|
mandaat:isBestuurlijkeAliasVan ?person ;
|
||||||
|
?pMandatarissen ?oMandatarissen .
|
||||||
|
|
||||||
|
OPTIONAL {
|
||||||
|
?mandatarissen schema:contactPoint ?contactPoint .
|
||||||
|
OPTIONAL {
|
||||||
|
?contactPoint locn:address ?address ;
|
||||||
|
?pContactPoint ?oContactPoint .
|
||||||
|
?address ?pAddress ?oAddress .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?person ?pPerson ?oPerson .
|
||||||
|
?mandaat ?pMandaat ?oMandaat .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# An associated call to trigger a reindex is:
|
||||||
|
|
||||||
|
# curl --location --request POST '172.32.0.21/update' \
|
||||||
|
# --header 'Content-Type: application/vnd.api+json' \
|
||||||
|
# --data-raw ' [
|
||||||
|
# {
|
||||||
|
# "deletes": [
|
||||||
|
# {
|
||||||
|
# "subject": { "type": "uri", "value": "http://data.lblod.info/id/mandatarissen/807a3e07c95fe40962d64695069af946" },
|
||||||
|
# "predicate": { "type": "uri", "value": "http://data.vlaanderen.be/ns/mandaat#isBestuurlijkeAliasVan" },
|
||||||
|
# "object": { "type": "uri", "value": "http://data.lblod.info/id/personen/620523C451BFC225E4ECFA97" }
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# "subject": { "type": "uri", "value": "http://data.lblod.info/id/mandatarissen/40ed3cb19f9fa33e47b39016780dce1d" },
|
||||||
|
# "predicate": { "type": "uri", "value": "http://data.vlaanderen.be/ns/mandaat#isBestuurlijkeAliasVan" },
|
||||||
|
# "object": { "type": "uri", "value": "http://data.lblod.info/id/personen/620523C451BFC225E4ECFA97" }
|
||||||
|
# }
|
||||||
|
# ],
|
||||||
|
# "inserts": []
|
||||||
|
# }
|
||||||
|
# ]'
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
||||||
|
PREFIX org: <http://www.w3.org/ns/org#>
|
||||||
|
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
|
||||||
|
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||||
|
|
||||||
|
# OP-2070
|
||||||
|
INSERT DATA {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
<http://data.lblod.info/id/bestuursorganen/56c71a29-bff0-4b67-804d-2c98fd4bd10f> a <http://data.vlaanderen.be/ns/besluit#Bestuursorgaan>;
|
||||||
|
mu:uuid "56c71a29-bff0-4b67-804d-2c98fd4bd10f";
|
||||||
|
besluit:bestuurt <http://data.lblod.info/id/besturenVanDeEredienst/6232329df9377210c3576b17e116de8b>;
|
||||||
|
org:classification <http://data.vlaanderen.be/id/concept/BestuursorgaanClassificatieCode/b475fa47e17a8a05ae04a9e1fb9c9258>.
|
||||||
|
<http://data.lblod.info/id/bestuursorganen/54f16d44-2f2c-45df-83c1-5a9fbe4756ca> a <http://data.vlaanderen.be/ns/besluit#Bestuursorgaan>;
|
||||||
|
mu:uuid "54f16d44-2f2c-45df-83c1-5a9fbe4756ca";
|
||||||
|
generiek:isTijdspecialisatieVan <http://data.lblod.info/id/bestuursorganen/56c71a29-bff0-4b67-804d-2c98fd4bd10f> .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
# OP-2084
|
||||||
|
|
||||||
|
INSERT DATA {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
<http://data.lblod.info/id/bestuursorganen/1179426b-69d4-4974-8aa2-c4d46a22c9cc> a <http://data.vlaanderen.be/ns/besluit#Bestuursorgaan>;
|
||||||
|
mu:uuid "1179426b-69d4-4974-8aa2-c4d46a22c9cc";
|
||||||
|
besluit:bestuurt <http://data.lblod.info/id/besturenVanDeEredienst/88cc9ab83a5a94caeb2f4b04615b20f2>;
|
||||||
|
org:classification <http://data.vlaanderen.be/id/concept/BestuursorgaanClassificatieCode/b475fa47e17a8a05ae04a9e1fb9c9258>.
|
||||||
|
<http://data.lblod.info/id/bestuursorganen/b3db6a8d-d6cb-4b78-af87-b80dfda580c7> a <http://data.vlaanderen.be/ns/besluit#Bestuursorgaan>;
|
||||||
|
mu:uuid "b3db6a8d-d6cb-4b78-af87-b80dfda580c7";
|
||||||
|
generiek:isTijdspecialisatieVan <http://data.lblod.info/id/bestuursorganen/1179426b-69d4-4974-8aa2-c4d46a22c9cc> .
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX org: <http://www.w3.org/ns/org#>
|
||||||
|
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
||||||
|
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
|
||||||
|
PREFIX ch: <http://data.lblod.info/vocabularies/contacthub/>
|
||||||
|
PREFIX code: <http://lblod.data.gift/vocabularies/organisatie/>
|
||||||
|
|
||||||
|
INSERT DATA {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
<http://lblod.data.info/id/veranderingsgebeurtenis-resultaten/0b2f1b62-a15d-11ed-a8fc-0242ac120002>
|
||||||
|
rdf:type code:VeranderingsgebeurtenisResultaat;
|
||||||
|
mu:uuid "0b2f1b62-a15d-11ed-a8fc-0242ac120002" ;
|
||||||
|
code:resulterendeStatus <http://lblod.data.gift/concepts/d02c4e12bf88d2fdf5123b07f29c9311> ;
|
||||||
|
ext:resultingOrganization <http://data.lblod.info/id/bestuurseenheden/25b05f670144f166a485a1d0ac37faca672b36642cf1647d846010d6fe9cabb5> .
|
||||||
|
|
||||||
|
<http://data.lblod.info/id/veranderingsgebeurtenissen/63D7E7E07A8167ED439EC88E>
|
||||||
|
rdf:type org:ChangeEvent ;
|
||||||
|
mu:uuid "63D7E7E07A8167ED439EC88E" ;
|
||||||
|
ch:typeWijziging <http://lblod.data.gift/concepts/e4c3d1ef-a34d-43b0-a18c-f4e60e2c8af3> ;
|
||||||
|
org:resultingOrganization <http://data.lblod.info/id/bestuurseenheden/25b05f670144f166a485a1d0ac37faca672b36642cf1647d846010d6fe9cabb5> ;
|
||||||
|
org:originalOrganization <http://data.lblod.info/id/bestuurseenheden/25b05f670144f166a485a1d0ac37faca672b36642cf1647d846010d6fe9cabb5> ;
|
||||||
|
code:veranderingsgebeurtenisResultaat <http://lblod.data.info/id/veranderingsgebeurtenis-resultaten/0b2f1b62-a15d-11ed-a8fc-0242ac120002> .
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
25
config/migrations/2023/20230131172200-delete-region.sparql
Normal file
25
config/migrations/2023/20230131172200-delete-region.sparql
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
|
||||||
|
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
|
||||||
|
|
||||||
|
DELETE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
?werkingsgebied geo:sfWithin ?locatie .
|
||||||
|
|
||||||
|
}
|
||||||
|
} WHERE {
|
||||||
|
GRAPH <http://mu.semte.ch/graphs/organisatieportaal> {
|
||||||
|
|
||||||
|
VALUES ?bestuurseenheid {
|
||||||
|
<http://data.lblod.info/id/bestuurseenheden/9b93ff5308590c7d03c97c3b892910f912e695ad45c82465934996fb04dac859> # OP-2033
|
||||||
|
<http://data.lblod.info/id/bestuurseenheden/25b05f670144f166a485a1d0ac37faca672b36642cf1647d846010d6fe9cabb5> # OP-1994
|
||||||
|
}
|
||||||
|
|
||||||
|
?bestuurseenheid rdf:type besluit:Bestuurseenheid ;
|
||||||
|
besluit:werkingsgebied ?werkingsgebied .
|
||||||
|
|
||||||
|
?werkingsgebied geo:sfWithin ?locatie .
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||||
|
|
||||||
|
DELETE {
|
||||||
|
GRAPH ?g {
|
||||||
|
<http://data.lblod.info/id/gestructureerdeIdentificatoren/b4af7f119ea6a0b012e01ef8494c5f72>
|
||||||
|
generiek:lokaleIdentificator ?kbo .
|
||||||
|
}
|
||||||
|
} INSERT {
|
||||||
|
GRAPH ?g {
|
||||||
|
<http://data.lblod.info/id/gestructureerdeIdentificatoren/b4af7f119ea6a0b012e01ef8494c5f72>
|
||||||
|
generiek:lokaleIdentificator "0655698422" .
|
||||||
|
}
|
||||||
|
} WHERE {
|
||||||
|
GRAPH ?g {
|
||||||
|
<http://data.lblod.info/id/gestructureerdeIdentificatoren/b4af7f119ea6a0b012e01ef8494c5f72>
|
||||||
|
generiek:lokaleIdentificator ?kbo .
|
||||||
|
}
|
||||||
|
}
|
||||||
1
config/search-migrations/.gitignore
vendored
Normal file
1
config/search-migrations/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.migration_history
|
||||||
0
config/search-migrations/.gitkeep
Normal file
0
config/search-migrations/.gitkeep
Normal file
@@ -17,6 +17,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./config/dev-migrations:/data/migrations/dev/
|
- ./config/dev-migrations:/data/migrations/dev/
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
migrations-triggering-indexing:
|
||||||
|
restart: "no"
|
||||||
resource:
|
resource:
|
||||||
restart: "no"
|
restart: "no"
|
||||||
cache:
|
cache:
|
||||||
|
|||||||
@@ -59,6 +59,16 @@ services:
|
|||||||
- "logging=true"
|
- "logging=true"
|
||||||
restart: always
|
restart: always
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
|
migrations-triggering-indexing:
|
||||||
|
image: semtech/mu-migrations-service:0.8.0
|
||||||
|
links:
|
||||||
|
- db:database
|
||||||
|
volumes:
|
||||||
|
- ./config/migrations-triggering-indexing:/data/migrations
|
||||||
|
labels:
|
||||||
|
- "logging=true"
|
||||||
|
restart: always
|
||||||
|
logging: *default-logging
|
||||||
resource:
|
resource:
|
||||||
image: semtech/mu-cl-resources:1.21.1
|
image: semtech/mu-cl-resources:1.21.1
|
||||||
environment:
|
environment:
|
||||||
@@ -157,7 +167,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
frontend:
|
frontend:
|
||||||
image: lblod/frontend-organization-portal:1.14.0
|
image: lblod/frontend-organization-portal:1.15.0
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/frontend/add-x-frame-options-header.conf:/config/add-x-frame-options.conf
|
- ./config/frontend/add-x-frame-options-header.conf:/config/add-x-frame-options.conf
|
||||||
environment:
|
environment:
|
||||||
@@ -566,3 +576,13 @@ services:
|
|||||||
image: lblod/error-report-service:0.1.0
|
image: lblod/error-report-service:0.1.0
|
||||||
links:
|
links:
|
||||||
- db:database
|
- db:database
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
# MU SCRIPTS
|
||||||
|
# #################################################################################
|
||||||
|
project-scripts:
|
||||||
|
image: semtech/mu-scripts:1.0.0
|
||||||
|
volumes:
|
||||||
|
- ./scripts/project:/app/scripts/
|
||||||
|
restart: "no"
|
||||||
|
|||||||
21
scripts/project/config.json
Normal file
21
scripts/project/config.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1",
|
||||||
|
"scripts": [
|
||||||
|
{
|
||||||
|
"documentation": {
|
||||||
|
"command": "mu-search-delta",
|
||||||
|
"description": "produce delta for mu-search",
|
||||||
|
"arguments": []
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"image": "node:16",
|
||||||
|
"interactive": true,
|
||||||
|
"script": "mu-search-delta/build.sh",
|
||||||
|
"join_networks": true
|
||||||
|
},
|
||||||
|
"mounts": {
|
||||||
|
"app": "/data/app/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
1
scripts/project/mu-search-delta/.gitignore
vendored
Normal file
1
scripts/project/mu-search-delta/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
43
scripts/project/mu-search-delta/README.md
Normal file
43
scripts/project/mu-search-delta/README.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#### Scripts mu-search-delta
|
||||||
|
* make the script executable: `chmod a+x scripts/project/mu-search-delta/build.sh`
|
||||||
|
* add your delta messages in json format in `config/search-migrations`, e.g:
|
||||||
|
```js
|
||||||
|
// config/search-migrations/2023/001-delete-bedinaeren.json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"deletes": [
|
||||||
|
{
|
||||||
|
"subject": {
|
||||||
|
"type": "uri",
|
||||||
|
"value": "http://data.lblod.info/id/mandatarissen/807a3e07c95fe40962d64695069af946"
|
||||||
|
},
|
||||||
|
"predicate": {
|
||||||
|
"type": "uri",
|
||||||
|
"value": "http://data.vlaanderen.be/ns/mandaat#isBestuurlijkeAliasVan"
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "uri",
|
||||||
|
"value": "http://data.lblod.info/id/personen/620523C451BFC225E4ECFA97"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"subject": {
|
||||||
|
"type": "uri",
|
||||||
|
"value": "http://data.lblod.info/id/mandatarissen/40ed3cb19f9fa33e47b39016780dce1d"
|
||||||
|
},
|
||||||
|
"predicate": {
|
||||||
|
"type": "uri",
|
||||||
|
"value": "http://data.vlaanderen.be/ns/mandaat#isBestuurlijkeAliasVan"
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "uri",
|
||||||
|
"value": "http://data.lblod.info/id/personen/620523C451BFC225E4ECFA97"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inserts": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
* make sure virtuoso, mu-auth, elasticsearch & mu search are running
|
||||||
|
* run `mu script project-scripts mu-search-delta`
|
||||||
4
scripts/project/mu-search-delta/build.sh
Executable file
4
scripts/project/mu-search-delta/build.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
mkdir -p /data/app/config/search-migrations
|
||||||
|
npm i
|
||||||
|
node script.mjs
|
||||||
144
scripts/project/mu-search-delta/package-lock.json
generated
Normal file
144
scripts/project/mu-search-delta/package-lock.json
generated
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
{
|
||||||
|
"name": "mu-search-delta",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "mu-search-delta",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"node-fetch": "^3.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/data-uri-to-buffer": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fetch-blob": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/jimmywarting"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "paypal",
|
||||||
|
"url": "https://paypal.me/jimmywarting"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"node-domexception": "^1.0.0",
|
||||||
|
"web-streams-polyfill": "^3.0.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20 || >= 14.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/formdata-polyfill": {
|
||||||
|
"version": "4.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||||
|
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||||
|
"dependencies": {
|
||||||
|
"fetch-blob": "^3.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.20.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/node-domexception": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/jimmywarting"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://paypal.me/jimmywarting"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/node-fetch": {
|
||||||
|
"version": "3.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.0.tgz",
|
||||||
|
"integrity": "sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==",
|
||||||
|
"dependencies": {
|
||||||
|
"data-uri-to-buffer": "^4.0.0",
|
||||||
|
"fetch-blob": "^3.1.4",
|
||||||
|
"formdata-polyfill": "^4.0.10"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/node-fetch"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/web-streams-polyfill": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"data-uri-to-buffer": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="
|
||||||
|
},
|
||||||
|
"fetch-blob": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||||
|
"requires": {
|
||||||
|
"node-domexception": "^1.0.0",
|
||||||
|
"web-streams-polyfill": "^3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"formdata-polyfill": {
|
||||||
|
"version": "4.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||||
|
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||||
|
"requires": {
|
||||||
|
"fetch-blob": "^3.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node-domexception": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
|
||||||
|
},
|
||||||
|
"node-fetch": {
|
||||||
|
"version": "3.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.0.tgz",
|
||||||
|
"integrity": "sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==",
|
||||||
|
"requires": {
|
||||||
|
"data-uri-to-buffer": "^4.0.0",
|
||||||
|
"fetch-blob": "^3.1.4",
|
||||||
|
"formdata-polyfill": "^4.0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"web-streams-polyfill": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
scripts/project/mu-search-delta/package.json
Normal file
14
scripts/project/mu-search-delta/package.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "mu-search-delta",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "script.mjs",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Nordine Bittich",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"node-fetch": "^3.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
82
scripts/project/mu-search-delta/script.mjs
Normal file
82
scripts/project/mu-search-delta/script.mjs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const CONFIG_PATH = process.env.SEARCH_CONFIG_PATH || '/data/app/config/search-migrations';
|
||||||
|
const HISTORY_PATH = process.env.HISTORY_PATH || CONFIG_PATH + '/.migration_history';
|
||||||
|
const MU_SEARCH_DELTA_URL = process.env.MU_SEARCH_DELTA_URL || 'http://search/update';
|
||||||
|
const SEARCH_MIGRATIONS_DIR = process.env.SEARCH_MIGRATIONS_DIR || CONFIG_PATH;
|
||||||
|
const CONTENT_TYPE_JSON_API = { 'Content-Type': 'application/vnd.api+json' };
|
||||||
|
|
||||||
|
function read(fd, len) {
|
||||||
|
const buff = Buffer.alloc(len),
|
||||||
|
pos = 0, offset = 0;
|
||||||
|
fs.readSync(fd, buff, offset, len, pos);
|
||||||
|
return buff.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function readDirRecursive(dir, filterHistory = [], filterExtensions = ["json"]) {
|
||||||
|
const files = fs.readdirSync(dir);
|
||||||
|
|
||||||
|
const resultFiles = [];
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const filePath = path.join(dir, file);
|
||||||
|
const stat = fs.statSync(filePath);
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
resultFiles.push(...(readDirRecursive(`${dir}/${file}`, filterHistory)));
|
||||||
|
} else if (filterExtensions.some((ext) => filePath.endsWith(ext)) && !filterHistory.includes(filePath)) {
|
||||||
|
resultFiles.push({
|
||||||
|
time: stat.atimeMs,
|
||||||
|
file: filePath,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(`filter file ${filePath}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultFiles.sort((a, b) => a.time - b.time);
|
||||||
|
}
|
||||||
|
|
||||||
|
// main
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const historyFileDescriptor = fs.openSync(HISTORY_PATH, 'a+');
|
||||||
|
const historyFileLen = fs.statSync(HISTORY_PATH).size;
|
||||||
|
|
||||||
|
const history = read(historyFileDescriptor, historyFileLen)
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.map((f) => f.trim())
|
||||||
|
.filter((f) => f?.length);
|
||||||
|
|
||||||
|
const fileNames = readDirRecursive(SEARCH_MIGRATIONS_DIR, history);
|
||||||
|
console.log(`processing ${fileNames.length} migration(s)`);
|
||||||
|
for (const { file } of fileNames) {
|
||||||
|
console.log(`Current file: ${file}`);
|
||||||
|
const payload = fs.readFileSync(file);
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.parse(payload);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Verify your migration. Exit...");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const r = await fetch(MU_SEARCH_DELTA_URL, {
|
||||||
|
method: "post",
|
||||||
|
body: payload,
|
||||||
|
headers: CONTENT_TYPE_JSON_API,
|
||||||
|
});
|
||||||
|
console.log(`"[Delta]=> Status: ${r.status} `);
|
||||||
|
if (r.status == 200) {
|
||||||
|
const responseBody = await r.json();
|
||||||
|
console.log(`response ${JSON.stringify(responseBody)}`);
|
||||||
|
fs.appendFileSync(HISTORY_PATH, file + '\n');
|
||||||
|
} else {
|
||||||
|
console.error("an error occurred. check your migration, make sure mu search is running.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().then(() => console.log("Done."));
|
||||||
Reference in New Issue
Block a user