@open-mercato/core 0.4.6-develop-015a34b6dd → 0.4.6-develop-755a2e63db
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,52 @@
|
|
|
1
|
+
import { Migration } from "@mikro-orm/migrations";
|
|
2
|
+
class Migration20260227120000 extends Migration {
|
|
3
|
+
async up() {
|
|
4
|
+
this.addSql(`
|
|
5
|
+
update "role_acls" as ra
|
|
6
|
+
set
|
|
7
|
+
"features_json" = case
|
|
8
|
+
when ra."features_json" is null or jsonb_typeof(ra."features_json") <> 'array'
|
|
9
|
+
then '["messages.view"]'::jsonb
|
|
10
|
+
else ra."features_json" || '"messages.view"'::jsonb
|
|
11
|
+
end,
|
|
12
|
+
"updated_at" = now()
|
|
13
|
+
from "roles" as r
|
|
14
|
+
where ra."role_id" = r."id"
|
|
15
|
+
and ra."deleted_at" is null
|
|
16
|
+
and r."deleted_at" is null
|
|
17
|
+
and r."name" in ('admin', 'employee')
|
|
18
|
+
and (
|
|
19
|
+
ra."features_json" is null
|
|
20
|
+
or jsonb_typeof(ra."features_json") <> 'array'
|
|
21
|
+
or not (ra."features_json" ? 'messages.view')
|
|
22
|
+
);
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
async down() {
|
|
26
|
+
this.addSql(`
|
|
27
|
+
update "role_acls" as ra
|
|
28
|
+
set
|
|
29
|
+
"features_json" = coalesce(
|
|
30
|
+
(
|
|
31
|
+
select jsonb_agg(feature)
|
|
32
|
+
from jsonb_array_elements_text(ra."features_json") as feature
|
|
33
|
+
where feature <> 'messages.view'
|
|
34
|
+
),
|
|
35
|
+
'[]'::jsonb
|
|
36
|
+
),
|
|
37
|
+
"updated_at" = now()
|
|
38
|
+
from "roles" as r
|
|
39
|
+
where ra."role_id" = r."id"
|
|
40
|
+
and ra."deleted_at" is null
|
|
41
|
+
and r."deleted_at" is null
|
|
42
|
+
and r."name" in ('admin', 'employee')
|
|
43
|
+
and ra."features_json" is not null
|
|
44
|
+
and jsonb_typeof(ra."features_json") = 'array'
|
|
45
|
+
and ra."features_json" ? 'messages.view';
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
Migration20260227120000
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=Migration20260227120000.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/messages/migrations/Migration20260227120000.ts"],
|
|
4
|
+
"sourcesContent": ["import { Migration } from '@mikro-orm/migrations';\n\nexport class Migration20260227120000 extends Migration {\n\n override async up(): Promise<void> {\n this.addSql(`\n update \"role_acls\" as ra\n set\n \"features_json\" = case\n when ra.\"features_json\" is null or jsonb_typeof(ra.\"features_json\") <> 'array'\n then '[\"messages.view\"]'::jsonb\n else ra.\"features_json\" || '\"messages.view\"'::jsonb\n end,\n \"updated_at\" = now()\n from \"roles\" as r\n where ra.\"role_id\" = r.\"id\"\n and ra.\"deleted_at\" is null\n and r.\"deleted_at\" is null\n and r.\"name\" in ('admin', 'employee')\n and (\n ra.\"features_json\" is null\n or jsonb_typeof(ra.\"features_json\") <> 'array'\n or not (ra.\"features_json\" ? 'messages.view')\n );\n `);\n }\n\n override async down(): Promise<void> {\n this.addSql(`\n update \"role_acls\" as ra\n set\n \"features_json\" = coalesce(\n (\n select jsonb_agg(feature)\n from jsonb_array_elements_text(ra.\"features_json\") as feature\n where feature <> 'messages.view'\n ),\n '[]'::jsonb\n ),\n \"updated_at\" = now()\n from \"roles\" as r\n where ra.\"role_id\" = r.\"id\"\n and ra.\"deleted_at\" is null\n and r.\"deleted_at\" is null\n and r.\"name\" in ('admin', 'employee')\n and ra.\"features_json\" is not null\n and jsonb_typeof(ra.\"features_json\") = 'array'\n and ra.\"features_json\" ? 'messages.view';\n `);\n }\n\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAEnB,MAAM,gCAAgC,UAAU;AAAA,EAErD,MAAe,KAAoB;AACjC,SAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAmBX;AAAA,EACH;AAAA,EAEA,MAAe,OAAsB;AACnC,SAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAoBX;AAAA,EACH;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.4.6-develop-
|
|
3
|
+
"version": "0.4.6-develop-755a2e63db",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
209
|
"dependencies": {
|
|
210
|
-
"@open-mercato/shared": "0.4.6-develop-
|
|
210
|
+
"@open-mercato/shared": "0.4.6-develop-755a2e63db",
|
|
211
211
|
"@types/html-to-text": "^9.0.4",
|
|
212
212
|
"@types/semver": "^7.5.8",
|
|
213
213
|
"@xyflow/react": "^12.6.0",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20260227120000 extends Migration {
|
|
4
|
+
|
|
5
|
+
override async up(): Promise<void> {
|
|
6
|
+
this.addSql(`
|
|
7
|
+
update "role_acls" as ra
|
|
8
|
+
set
|
|
9
|
+
"features_json" = case
|
|
10
|
+
when ra."features_json" is null or jsonb_typeof(ra."features_json") <> 'array'
|
|
11
|
+
then '["messages.view"]'::jsonb
|
|
12
|
+
else ra."features_json" || '"messages.view"'::jsonb
|
|
13
|
+
end,
|
|
14
|
+
"updated_at" = now()
|
|
15
|
+
from "roles" as r
|
|
16
|
+
where ra."role_id" = r."id"
|
|
17
|
+
and ra."deleted_at" is null
|
|
18
|
+
and r."deleted_at" is null
|
|
19
|
+
and r."name" in ('admin', 'employee')
|
|
20
|
+
and (
|
|
21
|
+
ra."features_json" is null
|
|
22
|
+
or jsonb_typeof(ra."features_json") <> 'array'
|
|
23
|
+
or not (ra."features_json" ? 'messages.view')
|
|
24
|
+
);
|
|
25
|
+
`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override async down(): Promise<void> {
|
|
29
|
+
this.addSql(`
|
|
30
|
+
update "role_acls" as ra
|
|
31
|
+
set
|
|
32
|
+
"features_json" = coalesce(
|
|
33
|
+
(
|
|
34
|
+
select jsonb_agg(feature)
|
|
35
|
+
from jsonb_array_elements_text(ra."features_json") as feature
|
|
36
|
+
where feature <> 'messages.view'
|
|
37
|
+
),
|
|
38
|
+
'[]'::jsonb
|
|
39
|
+
),
|
|
40
|
+
"updated_at" = now()
|
|
41
|
+
from "roles" as r
|
|
42
|
+
where ra."role_id" = r."id"
|
|
43
|
+
and ra."deleted_at" is null
|
|
44
|
+
and r."deleted_at" is null
|
|
45
|
+
and r."name" in ('admin', 'employee')
|
|
46
|
+
and ra."features_json" is not null
|
|
47
|
+
and jsonb_typeof(ra."features_json") = 'array'
|
|
48
|
+
and ra."features_json" ? 'messages.view';
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|