Compare commits

..

21 Commits

Author SHA1 Message Date
Claire Lovisa
826aa6d379 Bump frontend 2023-02-08 17:09:38 +01:00
Claire Lovisa
087f3d2d86 Bump frontend 2023-02-08 14:15:49 +01:00
Claire Lovisa
74a9ac2eb1 Bump frontend 2023-02-08 12:23:52 +01:00
Claire Lovisa
28d63c10ba Merge branch 'development' 2023-02-08 12:23:27 +01:00
Claire Lovisa
bb377639f4 Merge pull request #232 from lblod/hotfix-delete-mandatarissen
migration to delete mandatarissen
2023-02-07 15:18:20 +01:00
Claire Lovisa
4179194e6f Moving migration to trigger reindex 2023-02-07 15:05:26 +01:00
Claire Lovisa
f5e24f3bc3 Merge branch 'development' into hotfix-delete-mandatarissen 2023-02-07 15:02:10 +01:00
Claire Lovisa
5bdf87632a Merge pull request #235 from lblod/internal/migrations-triggering-reindex
Migrations triggering reindex
2023-02-07 14:48:39 +01:00
Claire Lovisa
cbe53c5b6b Merge pull request #233 from lblod/change-kbo-number
Change kbo number
2023-02-07 14:47:22 +01:00
Claire Lovisa
0f7313b944 Add option to create migrations triggering index 2023-02-06 14:37:26 +01:00
iurianu
411d16e33d migration to remove dummy worship sewrvice 2023-02-03 15:49:53 +02:00
iurianu
6d1b58ecf0 migration to change kbo 2023-02-03 13:18:52 +02:00
Boris De Vloed
1767eff19b Do not delete mandate 2023-02-02 16:18:20 +01:00
Boris De Vloed
e30e93e00e Change to delete secondary contact point 2023-02-02 15:59:27 +01:00
iurianu
2958262abf migration to delete mandatarissen 2023-02-02 13:08:03 +02:00
Iulian Andriescu
3b3a7b548c Migration to remove region (#231)
migration to remove region
2023-02-01 13:21:01 +02:00
Iulian Andriescu
bdf7802a31 Add city change event (#230)
add-city-change-event
2023-02-01 10:17:55 +02:00
Nordine Bittich
7b8890b1ff mu search delta script (#229) 2023-01-31 11:33:53 +01:00
Boris De Vloed
bb74c52267 typo in target 2023-01-27 15:42:25 +01:00
Boris De Vloed
3d749242aa removed comma 2023-01-27 15:42:25 +01:00
Claire Lovisa
d52f121a0b Enable local involvements for central worship services
I had to deactivate parts of the cache, causing the frontend to have
very weird behaviours when the data was correct
2023-01-27 15:42:25 +01:00
22 changed files with 3595 additions and 24 deletions

View File

@@ -18,6 +18,7 @@ defmodule Acl.UserGroups.Config do
"https://data.vlaanderen.be/ns/besluitvorming#Beslissingsactiviteit",
"http://data.vlaanderen.be/ns/besluit#Bestuurseenheid",
"http://data.lblod.info/vocabularies/erediensten/BestuurVanDeEredienst",
"http://data.lblod.info/vocabularies/erediensten/EredienstBestuurseenheid",
"http://data.vlaanderen.be/ns/besluit#Bestuursorgaan",
"http://data.lblod.info/vocabularies/erediensten/RolBedienaar",
"http://data.lblod.info/vocabularies/erediensten/VoorwaardenBedienaar",

View File

@@ -97,7 +97,7 @@ defmodule Dispatcher do
end
match "/central-worship-services/*path", %{ accept: [:json], layer: :api} do
Proxy.forward conn, path, "http://cache/central-worship-services/"
Proxy.forward conn, path, "http://resource/central-worship-services/"
end
match "/representative-bodies/*path", %{ accept: [:json], layer: :api} do
@@ -113,7 +113,7 @@ defmodule Dispatcher do
end
match "/local-involvements/*path", %{ accept: [:json], layer: :api} do
Proxy.forward conn, path, "http://cache/local-involvements/"
Proxy.forward conn, path, "http://resource/local-involvements/"
end
match "/identifiers/*path", %{ accept: [:json], layer: :api} do

View File

@@ -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 .
}
}
}
}

View File

@@ -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 .
}
}
}

View File

@@ -0,0 +1,19 @@
# We already had betrokken lokale besturen entered for some CB.
# Too keep data aligned with the other applications (Loket, CVP etc), we first flush them
# before re-adding only the necessary ones
DELETE {
GRAPH ?g {
?localInvolvement ?plocalInvolvement ?olocalInvolvement .
?bestuur <http://data.lblod.info/vocabularies/erediensten/betrokkenBestuur> ?localInvolvement .
}
} WHERE {
GRAPH ?g {
?centraalBestuur a <http://data.lblod.info/vocabularies/erediensten/CentraalBestuurVanDeEredienst> .
?localInvolvement <http://www.w3.org/ns/org#organization> ?centraalBestuur ;
?plocalInvolvement ?olocalInvolvement .
?bestuur <http://data.lblod.info/vocabularies/erediensten/betrokkenBestuur> ?localInvolvement .
}
}

View File

@@ -0,0 +1 @@
http://mu.semte.ch/graphs/organisatieportaal

File diff suppressed because it is too large Load Diff

View File

@@ -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> .
}
}

View 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 .
}
}

View File

@@ -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 .
}
}

View File

@@ -23,7 +23,7 @@
"skos": "http://www.w3.org/2004/02/skos/core#",
"euvoc": "http://publications.europa.eu/ontology/euvoc#",
"ere": "http://data.lblod.info/vocabularies/erediensten/",
"ch": "http://data.lblod.info/vocabularies/contacthub/",
"ch": "http://data.lblod.info/vocabularies/contacthub/",
"code": "http://lblod.data.gift/vocabularies/organisatie/",
"ext": "http://mu.semte.ch/vocabularies/ext/",
"geo": "http://www.opengis.net/ont/geosparql#"
@@ -63,7 +63,7 @@
"target": "agents",
"cardinality": "many",
"inverse": true
},
}
},
"new-resource-base": "http://data.lblod.info/id/personen/"
},
@@ -108,7 +108,7 @@
},
"organization": {
"predicate": "org:postIn",
"target": "organization",
"target": "organizations",
"cardinality": "one"
},
"agents-in-position": {
@@ -223,7 +223,7 @@
"type": "string",
"predicate": "schema:contactType"
}
},
},
"relationships": {
"contact-address": {
"predicate": "locn:address",
@@ -269,7 +269,7 @@
"type": "datetime",
"predicate": "mandaat:einde"
}
},
},
"relationships": {
"board-position": {
"predicate": "org:holds",
@@ -358,7 +358,7 @@
"predicate": "skos:prefLabel"
},
"alternative-name": {
"type": "string",
"type": "string",
"predicate": "skos:altLabel"
}
},
@@ -492,10 +492,15 @@
"predicate": "ere:wordtBediendDoor",
"target": "minister-positions",
"cardinality": "many"
},
"involvements": {
"predicate": "org:organization",
"target": "local-involvements",
"cardinality": "many",
"inverse": true
}
},
"new-resource-base": "http://data.lblod.info/id/eredienstBestuurseenheden/"
},
"worship-services": {
"class": "ere:BestuurVanDeEredienst",
@@ -510,14 +515,6 @@
"predicate": "ere:grensoverschrijdend"
}
},
"relationships": {
"involvements": {
"predicate": "org:organization",
"target": "local-involvements",
"cardinality": "many",
"inverse": true
}
},
"new-resource-base": "http://data.lblod.info/id/besturenVanDeEredienst/"
},
"recognized-worship-types": {
@@ -631,9 +628,9 @@
"target": "involvement-types",
"cardinality": "one"
},
"worship-service": {
"worship-administrative-unit": {
"predicate": "org:organization",
"target": "worship-services",
"target": "worship-administrative-units",
"cardinality": "one"
},
"administrative-unit": {
@@ -711,7 +708,6 @@
"type": "url",
"predicate": "adres:verwijstNaar"
}
},
"relationships": {
"source": {
@@ -838,9 +834,9 @@
"predicate": "ere:voldoetAan",
"target": "minister-conditions",
"cardinality": "many"
}
}
},
"new-resource-base": "http://data.lblod.info/id/rollenBedienaar/"
"new-resource-base": "http://data.lblod.info/id/rollenBedienaar/"
},
"minister-conditions": {
"class": "ere:VoorwaardenBedienaar",
@@ -968,4 +964,4 @@
"new-resource-base": "http://lblod.data.gift/concepts/"
}
}
}
}

1
config/search-migrations/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.migration_history

View File

View File

@@ -17,6 +17,8 @@ services:
volumes:
- ./config/dev-migrations:/data/migrations/dev/
restart: "no"
migrations-triggering-indexing:
restart: "no"
resource:
restart: "no"
cache:

View File

@@ -59,6 +59,16 @@ services:
- "logging=true"
restart: always
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:
image: semtech/mu-cl-resources:1.21.1
environment:
@@ -157,7 +167,7 @@ services:
restart: always
logging: *default-logging
frontend:
image: lblod/frontend-organization-portal:1.14.0
image: lblod/frontend-organization-portal:1.15.0
volumes:
- ./config/frontend/add-x-frame-options-header.conf:/config/add-x-frame-options.conf
environment:
@@ -566,3 +576,13 @@ services:
image: lblod/error-report-service:0.1.0
links:
- db:database
###################################################################################
# MU SCRIPTS
# #################################################################################
project-scripts:
image: semtech/mu-scripts:1.0.0
volumes:
- ./scripts/project:/app/scripts/
restart: "no"

View 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/"
}
}
]
}

View File

@@ -0,0 +1 @@
node_modules

View 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`

View File

@@ -0,0 +1,4 @@
#!/bin/bash
mkdir -p /data/app/config/search-migrations
npm i
node script.mjs

View 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=="
}
}
}

View 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"
}
}

View 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."));