keycloakify 11.5.2 → 11.5.4

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.
Files changed (29) hide show
  1. package/bin/{682.index.js → 153.index.js} +220 -25
  2. package/bin/main.js +1 -1
  3. package/bin/start-keycloak/realmConfig/{ParsedRealmJson.d.ts → ParsedRealmJson/ParsedRealmJson.d.ts} +2 -3
  4. package/bin/start-keycloak/realmConfig/ParsedRealmJson/index.d.ts +3 -0
  5. package/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.d.ts +4 -0
  6. package/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.d.ts +6 -0
  7. package/bin/start-keycloak/realmConfig/defaultConfig/defaultConfig.d.ts +1 -4
  8. package/bin/tools/Stringifyable.d.ts +13 -0
  9. package/bin/tools/canonicalStringify.d.ts +5 -0
  10. package/package.json +14 -4
  11. package/src/bin/start-keycloak/realmConfig/{ParsedRealmJson.ts → ParsedRealmJson/ParsedRealmJson.ts} +1 -19
  12. package/src/bin/start-keycloak/realmConfig/ParsedRealmJson/index.ts +3 -0
  13. package/src/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.ts +20 -0
  14. package/src/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.ts +29 -0
  15. package/src/bin/start-keycloak/realmConfig/defaultConfig/defaultConfig.ts +3 -4
  16. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-18.json +51 -33
  17. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-19.json +48 -30
  18. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-20.json +50 -32
  19. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-21.json +29 -11
  20. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-23.json +25 -7
  21. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-24.json +26 -8
  22. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-25.json +26 -8
  23. package/src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-26.json +11 -11
  24. package/src/bin/start-keycloak/realmConfig/dumpContainerConfig.ts +1 -1
  25. package/src/bin/start-keycloak/realmConfig/prepareRealmConfig.ts +1 -1
  26. package/src/bin/start-keycloak/realmConfig/realmConfig.ts +15 -19
  27. package/src/bin/tools/Stringifyable.ts +99 -0
  28. package/src/bin/tools/canonicalStringify.ts +164 -0
  29. package/tools/vendor/dompurify.js +1 -1
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- exports.id = 682;
3
- exports.ids = [682];
2
+ exports.id = 153;
3
+ exports.ids = [153];
4
4
  exports.modules = {
5
5
 
6
- /***/ 6682:
6
+ /***/ 43153:
7
7
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
8
 
9
9
  // ESM COMPAT FLAG
@@ -271,9 +271,7 @@ function startViteDevServer(params) {
271
271
  //# sourceMappingURL=startViteDevServer.js.map
272
272
  // EXTERNAL MODULE: ./node_modules/tsafe/esm/is.mjs
273
273
  var is = __webpack_require__(16453);
274
- ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson.js
275
-
276
-
274
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/ParsedRealmJson.js
277
275
 
278
276
 
279
277
 
@@ -325,6 +323,12 @@ const zParsedRealmJson = (() => {
325
323
  assert/* assert */.h;
326
324
  return (0,id.id)(zTargetType);
327
325
  })();
326
+ //# sourceMappingURL=ParsedRealmJson.js.map
327
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.js
328
+
329
+
330
+
331
+
328
332
  function readRealmJsonFile(params) {
329
333
  const { realmJsonFilePath } = params;
330
334
  const parsedRealmJson = JSON.parse(external_fs_.readFileSync(realmJsonFilePath).toString("utf8"));
@@ -332,7 +336,7 @@ function readRealmJsonFile(params) {
332
336
  (0,assert/* assert */.h)((0,is.is)(parsedRealmJson));
333
337
  return parsedRealmJson;
334
338
  }
335
- //# sourceMappingURL=ParsedRealmJson.js.map
339
+ //# sourceMappingURL=readRealmJsonFile.js.map
336
340
  ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/defaultConfig/defaultConfig.js
337
341
 
338
342
 
@@ -556,8 +560,6 @@ const { getCachedValue, setCachedValue } = (() => {
556
560
  };
557
561
  })();
558
562
  //# sourceMappingURL=getSupportedDockerImageTags.js.map
559
- // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
560
- var runPrettier = __webpack_require__(48433);
561
563
  // EXTERNAL MODULE: ./node_modules/tsafe/esm/objectKeys.mjs
562
564
  var objectKeys = __webpack_require__(23483);
563
565
  // EXTERNAL MODULE: ./node_modules/evt/tools/inDepth/same.js
@@ -774,7 +776,7 @@ function editAccountConsoleAndSecurityAdminConsole(params) {
774
776
  "claim.value": '["*"]',
775
777
  "userinfo.token.claim": "true",
776
778
  "id.token.claim": "false",
777
- "lightweight.claim": "false",
779
+ "lightweight.claim": "true",
778
780
  "access.token.claim": "true",
779
781
  "claim.name": "allowed-origins",
780
782
  "jsonType.label": "JSON",
@@ -802,6 +804,203 @@ function editAccountConsoleAndSecurityAdminConsole(params) {
802
804
  }
803
805
  }
804
806
  //# sourceMappingURL=prepareRealmConfig.js.map
807
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
808
+ var runPrettier = __webpack_require__(48433);
809
+ ;// CONCATENATED MODULE: ./dist/bin/tools/Stringifyable.js
810
+
811
+
812
+
813
+
814
+ const zStringifyableAtomic = (() => {
815
+ const zTargetType = lib.z.union([lib.z.string(), lib.z.number(), lib.z.boolean(), lib.z["null"]()]);
816
+ (0,assert/* assert */.h)();
817
+ return (0,id.id)(zTargetType);
818
+ })();
819
+ const zStringifyable = lib.z.any()
820
+ .superRefine((val, ctx) => {
821
+ const isStringifyable = (0,same.same)(JSON.parse(JSON.stringify(val)), val);
822
+ if (!isStringifyable) {
823
+ ctx.addIssue({
824
+ code: lib.z.ZodIssueCode.custom,
825
+ message: "Not stringifyable"
826
+ });
827
+ }
828
+ });
829
+ function getIsAtomic(stringifyable) {
830
+ return (["string", "number", "boolean"].includes(typeof stringifyable) ||
831
+ stringifyable === null);
832
+ }
833
+ const { getValueAtPath } = (() => {
834
+ function getValueAtPath_rec(stringifyable, path) {
835
+ if (path.length === 0) {
836
+ return stringifyable;
837
+ }
838
+ if (getIsAtomic(stringifyable)) {
839
+ return undefined;
840
+ }
841
+ const [first, ...rest] = path;
842
+ let dereferenced;
843
+ if (stringifyable instanceof Array) {
844
+ if (typeof first !== "number") {
845
+ return undefined;
846
+ }
847
+ dereferenced = stringifyable[first];
848
+ }
849
+ else {
850
+ if (typeof first !== "string") {
851
+ return undefined;
852
+ }
853
+ dereferenced = stringifyable[first];
854
+ }
855
+ if (dereferenced === undefined) {
856
+ return undefined;
857
+ }
858
+ return getValueAtPath_rec(dereferenced, rest);
859
+ }
860
+ function getValueAtPath(stringifyableObjectOrArray, path) {
861
+ return getValueAtPath_rec(stringifyableObjectOrArray, path);
862
+ }
863
+ return { getValueAtPath };
864
+ })();
865
+ //# sourceMappingURL=Stringifyable.js.map
866
+ ;// CONCATENATED MODULE: ./dist/bin/tools/canonicalStringify.js
867
+
868
+ function canonicalStringify(params) {
869
+ const { data, referenceData } = params;
870
+ return JSON.stringify(makeDeterministicCopy({
871
+ path: [],
872
+ data,
873
+ getCanonicalKeys: path => {
874
+ const referenceValue = (() => {
875
+ const path_patched = [];
876
+ for (let i = 0; i < path.length; i++) {
877
+ let value_i = getValueAtPath(referenceData, [
878
+ ...path_patched,
879
+ path[i]
880
+ ]);
881
+ if (value_i !== undefined) {
882
+ path_patched.push(path[i]);
883
+ continue;
884
+ }
885
+ if (typeof path[i] !== "number") {
886
+ return undefined;
887
+ }
888
+ value_i = getValueAtPath(referenceData, [...path_patched, 0]);
889
+ if (value_i !== undefined) {
890
+ path_patched.push(0);
891
+ continue;
892
+ }
893
+ return undefined;
894
+ }
895
+ return getValueAtPath(referenceData, path_patched);
896
+ })();
897
+ if (referenceValue === undefined) {
898
+ return undefined;
899
+ }
900
+ if (getIsAtomic(referenceValue)) {
901
+ return undefined;
902
+ }
903
+ if (referenceValue instanceof Array) {
904
+ return undefined;
905
+ }
906
+ return Object.keys(referenceValue);
907
+ }
908
+ }), null, 2);
909
+ }
910
+ function makeDeterministicCopy(params) {
911
+ const { path, data, getCanonicalKeys } = params;
912
+ if (getIsAtomic(data)) {
913
+ return data;
914
+ }
915
+ if (data instanceof Array) {
916
+ return makeDeterministicCopy_array({
917
+ path,
918
+ data,
919
+ getCanonicalKeys
920
+ });
921
+ }
922
+ return makeDeterministicCopy_record({
923
+ path,
924
+ data,
925
+ getCanonicalKeys
926
+ });
927
+ }
928
+ function makeDeterministicCopy_record(params) {
929
+ const { path, data, getCanonicalKeys } = params;
930
+ const keysOfAtomicValues = [];
931
+ const keysOfNonAtomicValues = [];
932
+ for (const [key, value] of Object.entries(data)) {
933
+ if (getIsAtomic(value)) {
934
+ keysOfAtomicValues.push(key);
935
+ }
936
+ else {
937
+ keysOfNonAtomicValues.push(key);
938
+ }
939
+ }
940
+ keysOfAtomicValues.sort();
941
+ keysOfNonAtomicValues.sort();
942
+ const keys = [...keysOfAtomicValues, ...keysOfNonAtomicValues];
943
+ reorder_according_to_canonical: {
944
+ const canonicalKeys = getCanonicalKeys(path);
945
+ if (canonicalKeys === undefined) {
946
+ break reorder_according_to_canonical;
947
+ }
948
+ const keys_toPrepend = [];
949
+ for (const key of canonicalKeys) {
950
+ const indexOfKey = keys.indexOf(key);
951
+ if (indexOfKey === -1) {
952
+ continue;
953
+ }
954
+ keys.splice(indexOfKey, 1);
955
+ keys_toPrepend.push(key);
956
+ }
957
+ keys.unshift(...keys_toPrepend);
958
+ }
959
+ const result = {};
960
+ for (const key of keys) {
961
+ result[key] = makeDeterministicCopy({
962
+ path: [...path, key],
963
+ data: data[key],
964
+ getCanonicalKeys
965
+ });
966
+ }
967
+ return result;
968
+ }
969
+ function makeDeterministicCopy_array(params) {
970
+ const { path, data, getCanonicalKeys } = params;
971
+ return [...data].map((entry, i) => makeDeterministicCopy({
972
+ path: [...path, i],
973
+ data: entry,
974
+ getCanonicalKeys
975
+ }));
976
+ }
977
+ //# sourceMappingURL=canonicalStringify.js.map
978
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.js
979
+
980
+
981
+
982
+
983
+ async function writeRealmJsonFile(params) {
984
+ const { realmJsonFilePath, parsedRealmJson, keycloakMajorVersionNumber } = params;
985
+ let sourceCode = canonicalStringify({
986
+ data: parsedRealmJson,
987
+ referenceData: getDefaultConfig({
988
+ keycloakMajorVersionNumber
989
+ })
990
+ });
991
+ if (await (0,runPrettier/* getIsPrettierAvailable */.MT)()) {
992
+ sourceCode = await (0,runPrettier/* runPrettier */.eY)({
993
+ sourceCode: sourceCode,
994
+ filePath: realmJsonFilePath
995
+ });
996
+ }
997
+ await promises_.writeFile(realmJsonFilePath, Buffer.from(sourceCode, "utf8"));
998
+ }
999
+ //# sourceMappingURL=writeRealmJsonFile.js.map
1000
+ ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/index.js
1001
+
1002
+
1003
+ //# sourceMappingURL=index.js.map
805
1004
  ;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/dumpContainerConfig.js
806
1005
 
807
1006
 
@@ -849,7 +1048,7 @@ async function dumpContainerConfig(params) {
849
1048
  ...["--db", "dev-file"],
850
1049
  ...[
851
1050
  "--db-url",
852
- "'jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE'"
1051
+ '"jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE"'
853
1052
  ]
854
1053
  ])
855
1054
  ], { shell: true });
@@ -947,7 +1146,6 @@ async function dumpContainerConfig(params) {
947
1146
 
948
1147
 
949
1148
 
950
-
951
1149
  assert/* assert */.h;
952
1150
  async function getRealmConfig(params) {
953
1151
  const { keycloakMajorVersionNumber, realmJsonFilePath_userProvided, buildContext } = params;
@@ -976,18 +1174,11 @@ async function getRealmConfig(params) {
976
1174
  external_fs_.mkdirSync(dirPath, { recursive: true });
977
1175
  }
978
1176
  }
979
- const writeRealmJsonFile = async (params) => {
980
- const { parsedRealmJson } = params;
981
- let sourceCode = JSON.stringify(parsedRealmJson, null, 2);
982
- if (await (0,runPrettier/* getIsPrettierAvailable */.MT)()) {
983
- sourceCode = await (0,runPrettier/* runPrettier */.eY)({
984
- sourceCode,
985
- filePath: realmJsonFilePath
986
- });
987
- }
988
- external_fs_.writeFileSync(realmJsonFilePath, sourceCode);
989
- };
990
- await writeRealmJsonFile({ parsedRealmJson });
1177
+ await writeRealmJsonFile({
1178
+ realmJsonFilePath,
1179
+ parsedRealmJson,
1180
+ keycloakMajorVersionNumber
1181
+ });
991
1182
  const { onRealmConfigChange } = (() => {
992
1183
  const run = runExclusive.build(async () => {
993
1184
  const start = Date.now();
@@ -1004,7 +1195,11 @@ async function getRealmConfig(params) {
1004
1195
  console.log(source_default().red(`Failed to backup '${realmName}' config:`));
1005
1196
  return;
1006
1197
  }
1007
- await writeRealmJsonFile({ parsedRealmJson });
1198
+ await writeRealmJsonFile({
1199
+ realmJsonFilePath,
1200
+ parsedRealmJson,
1201
+ keycloakMajorVersionNumber
1202
+ });
1008
1203
  console.log([
1009
1204
  source_default().grey(`Save changed to \`.${external_path_.sep}${(0,external_path_.relative)(buildContext.projectDirPath, realmJsonFilePath)}\``),
1010
1205
  source_default().grey(`Next time you'll be running \`keycloakify start-keycloak\`, the realm '${realmName}' will be restored to this state.`),
package/bin/main.js CHANGED
@@ -16201,7 +16201,7 @@ program
16201
16201
  .task({
16202
16202
  skip,
16203
16203
  handler: async ({ projectDirPath, keycloakVersion, port, realmJsonFilePath }) => {
16204
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(805), __nccwpck_require__.e(525), __nccwpck_require__.e(33), __nccwpck_require__.e(503), __nccwpck_require__.e(682)]).then(__nccwpck_require__.bind(__nccwpck_require__, 6682));
16204
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(805), __nccwpck_require__.e(525), __nccwpck_require__.e(33), __nccwpck_require__.e(503), __nccwpck_require__.e(153)]).then(__nccwpck_require__.bind(__nccwpck_require__, 43153));
16205
16205
  await command({
16206
16206
  buildContext: getBuildContext({ projectDirPath }),
16207
16207
  cliCommandOptions: {
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  export type ParsedRealmJson = {
2
3
  realm: string;
3
4
  loginTheme?: string;
@@ -40,6 +41,4 @@ export type ParsedRealmJson = {
40
41
  }[];
41
42
  }[];
42
43
  };
43
- export declare function readRealmJsonFile(params: {
44
- realmJsonFilePath: string;
45
- }): ParsedRealmJson;
44
+ export declare const zParsedRealmJson: z.ZodType<ParsedRealmJson, z.ZodTypeDef, ParsedRealmJson>;
@@ -0,0 +1,3 @@
1
+ export type { ParsedRealmJson } from "./ParsedRealmJson";
2
+ export { readRealmJsonFile } from "./readRealmJsonFile";
3
+ export { writeRealmJsonFile } from "./writeRealmJsonFile";
@@ -0,0 +1,4 @@
1
+ import { type ParsedRealmJson } from "./ParsedRealmJson";
2
+ export declare function readRealmJsonFile(params: {
3
+ realmJsonFilePath: string;
4
+ }): ParsedRealmJson;
@@ -0,0 +1,6 @@
1
+ import type { ParsedRealmJson } from "./ParsedRealmJson";
2
+ export declare function writeRealmJsonFile(params: {
3
+ realmJsonFilePath: string;
4
+ parsedRealmJson: ParsedRealmJson;
5
+ keycloakMajorVersionNumber: number;
6
+ }): Promise<void>;
@@ -1,7 +1,4 @@
1
- import { type ParsedRealmJson } from "../ParsedRealmJson";
2
- export declare function getDefaultRealmJsonFilePath(params: {
3
- keycloakMajorVersionNumber: number;
4
- }): string;
1
+ import type { ParsedRealmJson } from "../ParsedRealmJson/ParsedRealmJson";
5
2
  export declare const getSupportedKeycloakMajorVersions: () => number[];
6
3
  export declare function getDefaultConfig(params: {
7
4
  keycloakMajorVersionNumber: number;
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export type Stringifyable = StringifyableAtomic | StringifyableObject | StringifyableArray;
3
+ export type StringifyableAtomic = string | number | boolean | null;
4
+ interface StringifyableObject {
5
+ [key: string]: Stringifyable;
6
+ }
7
+ interface StringifyableArray extends Array<Stringifyable> {
8
+ }
9
+ export declare const zStringifyableAtomic: z.ZodType<StringifyableAtomic, z.ZodTypeDef, StringifyableAtomic>;
10
+ export declare const zStringifyable: z.ZodType<Stringifyable>;
11
+ export declare function getIsAtomic(stringifyable: Stringifyable): stringifyable is StringifyableAtomic;
12
+ export declare const getValueAtPath: (stringifyableObjectOrArray: Record<string, Stringifyable> | Stringifyable[], path: (string | number)[]) => Stringifyable | undefined;
13
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type Stringifyable } from "./Stringifyable";
2
+ export declare function canonicalStringify(params: {
3
+ data: Record<string, Stringifyable> | Stringifyable[];
4
+ referenceData: Record<string, Stringifyable> | Stringifyable[];
5
+ }): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.5.2",
3
+ "version": "11.5.4",
4
4
  "description": "Framework to create custom Keycloak UIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -704,7 +704,10 @@
704
704
  "src/bin/start-keycloak/index.ts",
705
705
  "src/bin/start-keycloak/keycloakify-logging-1.0.3.jar",
706
706
  "src/bin/start-keycloak/keycloakifyBuild.ts",
707
- "src/bin/start-keycloak/realmConfig/ParsedRealmJson.ts",
707
+ "src/bin/start-keycloak/realmConfig/ParsedRealmJson/ParsedRealmJson.ts",
708
+ "src/bin/start-keycloak/realmConfig/ParsedRealmJson/index.ts",
709
+ "src/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.ts",
710
+ "src/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.ts",
708
711
  "src/bin/start-keycloak/realmConfig/defaultConfig/defaultConfig.ts",
709
712
  "src/bin/start-keycloak/realmConfig/defaultConfig/index.ts",
710
713
  "src/bin/start-keycloak/realmConfig/defaultConfig/realm-kc-18.json",
@@ -724,7 +727,9 @@
724
727
  "src/bin/tools/OptionalIfCanBeUndefined.ts",
725
728
  "src/bin/tools/SemVer.ts",
726
729
  "src/bin/tools/String.prototype.replaceAll.ts",
730
+ "src/bin/tools/Stringifyable.ts",
727
731
  "src/bin/tools/assertNoPnpmDlx.ts",
732
+ "src/bin/tools/canonicalStringify.ts",
728
733
  "src/bin/tools/crawl.ts",
729
734
  "src/bin/tools/crawlAsync.ts",
730
735
  "src/bin/tools/crc32.ts",
@@ -1080,12 +1085,16 @@
1080
1085
  "bin/start-keycloak/realmConfig/defaultConfig/index.d.ts",
1081
1086
  "bin/start-keycloak/realmConfig/dumpContainerConfig.d.ts",
1082
1087
  "bin/start-keycloak/realmConfig/index.d.ts",
1083
- "bin/start-keycloak/realmConfig/ParsedRealmJson.d.ts",
1088
+ "bin/start-keycloak/realmConfig/ParsedRealmJson/index.d.ts",
1089
+ "bin/start-keycloak/realmConfig/ParsedRealmJson/ParsedRealmJson.d.ts",
1090
+ "bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.d.ts",
1091
+ "bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.d.ts",
1084
1092
  "bin/start-keycloak/realmConfig/prepareRealmConfig.d.ts",
1085
1093
  "bin/start-keycloak/realmConfig/realmConfig.d.ts",
1086
1094
  "bin/start-keycloak/start-keycloak.d.ts",
1087
1095
  "bin/start-keycloak/startViteDevServer.d.ts",
1088
1096
  "bin/tools/assertNoPnpmDlx.d.ts",
1097
+ "bin/tools/canonicalStringify.d.ts",
1089
1098
  "bin/tools/crawl.d.ts",
1090
1099
  "bin/tools/crawlAsync.d.ts",
1091
1100
  "bin/tools/crc32.d.ts",
@@ -1114,12 +1123,14 @@
1114
1123
  "bin/tools/runPrettier.d.ts",
1115
1124
  "bin/tools/SemVer.d.ts",
1116
1125
  "bin/tools/String.prototype.replaceAll.d.ts",
1126
+ "bin/tools/Stringifyable.d.ts",
1117
1127
  "bin/tools/tee.d.ts",
1118
1128
  "bin/tools/transformCodebase.d.ts",
1119
1129
  "bin/tools/trimIndent.d.ts",
1120
1130
  "bin/tools/untrackFromGit.d.ts",
1121
1131
  "bin/update-kc-gen.d.ts",
1122
1132
  "bin/main.js",
1133
+ "bin/153.index.js",
1123
1134
  "bin/266.index.js",
1124
1135
  "bin/304.index.js",
1125
1136
  "bin/33.index.js",
@@ -1133,7 +1144,6 @@
1133
1144
  "bin/573.index.js",
1134
1145
  "bin/653.index.js",
1135
1146
  "bin/658.index.js",
1136
- "bin/682.index.js",
1137
1147
  "bin/720.index.js",
1138
1148
  "bin/735.index.js",
1139
1149
  "bin/743.index.js",
@@ -1,8 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { assert, type Equals } from "tsafe/assert";
3
- import { is } from "tsafe/is";
4
3
  import { id } from "tsafe/id";
5
- import * as fs from "fs";
6
4
 
7
5
  export type ParsedRealmJson = {
8
6
  realm: string;
@@ -50,7 +48,7 @@ export type ParsedRealmJson = {
50
48
  }[];
51
49
  };
52
50
 
53
- const zParsedRealmJson = (() => {
51
+ export const zParsedRealmJson = (() => {
54
52
  type TargetType = ParsedRealmJson;
55
53
 
56
54
  const zTargetType = z.object({
@@ -118,19 +116,3 @@ const zParsedRealmJson = (() => {
118
116
 
119
117
  return id<z.ZodType<TargetType>>(zTargetType);
120
118
  })();
121
-
122
- export function readRealmJsonFile(params: {
123
- realmJsonFilePath: string;
124
- }): ParsedRealmJson {
125
- const { realmJsonFilePath } = params;
126
-
127
- const parsedRealmJson = JSON.parse(
128
- fs.readFileSync(realmJsonFilePath).toString("utf8")
129
- ) as unknown;
130
-
131
- zParsedRealmJson.parse(parsedRealmJson);
132
-
133
- assert(is<ParsedRealmJson>(parsedRealmJson));
134
-
135
- return parsedRealmJson;
136
- }
@@ -0,0 +1,3 @@
1
+ export type { ParsedRealmJson } from "./ParsedRealmJson";
2
+ export { readRealmJsonFile } from "./readRealmJsonFile";
3
+ export { writeRealmJsonFile } from "./writeRealmJsonFile";
@@ -0,0 +1,20 @@
1
+ import { assert } from "tsafe/assert";
2
+ import { is } from "tsafe/is";
3
+ import * as fs from "fs";
4
+ import { type ParsedRealmJson, zParsedRealmJson } from "./ParsedRealmJson";
5
+
6
+ export function readRealmJsonFile(params: {
7
+ realmJsonFilePath: string;
8
+ }): ParsedRealmJson {
9
+ const { realmJsonFilePath } = params;
10
+
11
+ const parsedRealmJson = JSON.parse(
12
+ fs.readFileSync(realmJsonFilePath).toString("utf8")
13
+ ) as unknown;
14
+
15
+ zParsedRealmJson.parse(parsedRealmJson);
16
+
17
+ assert(is<ParsedRealmJson>(parsedRealmJson));
18
+
19
+ return parsedRealmJson;
20
+ }
@@ -0,0 +1,29 @@
1
+ import * as fsPr from "fs/promises";
2
+ import { getIsPrettierAvailable, runPrettier } from "../../../tools/runPrettier";
3
+ import { canonicalStringify } from "../../../tools/canonicalStringify";
4
+ import type { ParsedRealmJson } from "./ParsedRealmJson";
5
+ import { getDefaultConfig } from "../defaultConfig";
6
+
7
+ export async function writeRealmJsonFile(params: {
8
+ realmJsonFilePath: string;
9
+ parsedRealmJson: ParsedRealmJson;
10
+ keycloakMajorVersionNumber: number;
11
+ }): Promise<void> {
12
+ const { realmJsonFilePath, parsedRealmJson, keycloakMajorVersionNumber } = params;
13
+
14
+ let sourceCode = canonicalStringify({
15
+ data: parsedRealmJson,
16
+ referenceData: getDefaultConfig({
17
+ keycloakMajorVersionNumber
18
+ })
19
+ });
20
+
21
+ if (await getIsPrettierAvailable()) {
22
+ sourceCode = await runPrettier({
23
+ sourceCode: sourceCode,
24
+ filePath: realmJsonFilePath
25
+ });
26
+ }
27
+
28
+ await fsPr.writeFile(realmJsonFilePath, Buffer.from(sourceCode, "utf8"));
29
+ }
@@ -3,11 +3,10 @@ import { getThisCodebaseRootDirPath } from "../../../tools/getThisCodebaseRootDi
3
3
  import * as fs from "fs";
4
4
  import { exclude } from "tsafe/exclude";
5
5
  import { assert } from "tsafe/assert";
6
- import { type ParsedRealmJson, readRealmJsonFile } from "../ParsedRealmJson";
6
+ import { readRealmJsonFile } from "../ParsedRealmJson/readRealmJsonFile";
7
+ import type { ParsedRealmJson } from "../ParsedRealmJson/ParsedRealmJson";
7
8
 
8
- export function getDefaultRealmJsonFilePath(params: {
9
- keycloakMajorVersionNumber: number;
10
- }) {
9
+ function getDefaultRealmJsonFilePath(params: { keycloakMajorVersionNumber: number }) {
11
10
  const { keycloakMajorVersionNumber } = params;
12
11
 
13
12
  return pathJoin(