@s-hirano-ist/s-scripts 1.26.7 → 4.0.0

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 (180) hide show
  1. package/README.md +2 -0
  2. package/dist/chunk-5OXUZW2Q.js +590 -0
  3. package/dist/chunk-7PVU2Z32.js +71 -0
  4. package/dist/chunk-AJMTRCPJ.js +15 -0
  5. package/dist/chunk-AZF2R2BF.js +85 -0
  6. package/dist/chunk-F4J6JBR4.js +115 -0
  7. package/dist/chunk-HDYQV2Y2.js +58 -0
  8. package/dist/chunk-HIK7SX34.js +85 -0
  9. package/dist/chunk-IWNZQXDG.js +7660 -0
  10. package/dist/chunk-J4VLH4VA.js +267 -0
  11. package/dist/chunk-JZOR5GA2.js +42 -0
  12. package/dist/chunk-KKZP7ZF3.js +77 -0
  13. package/dist/chunk-N6TZF755.js +102 -0
  14. package/dist/chunk-S5WJ5VXW.js +85 -0
  15. package/dist/chunk-UXGLXHQ6.js +40 -0
  16. package/dist/cleanup-minio-images.js +115 -92
  17. package/dist/enrich-books.js +87 -78
  18. package/dist/fetch-articles.js +101 -90
  19. package/dist/fetch-books.js +147 -128
  20. package/dist/fetch-images.js +88 -72
  21. package/dist/fetch-notes.js +66 -54
  22. package/dist/find-duplicate-json-articles.js +100 -97
  23. package/dist/fix-book-frontmatter.js +111 -99
  24. package/dist/fix-image-formats.js +81 -65
  25. package/dist/ingest-articles.js +30 -249
  26. package/dist/ingest-books.js +61 -318
  27. package/dist/ingest-images.js +33 -184
  28. package/dist/ingest-notes.js +41 -171
  29. package/dist/rag/delete-collection.js +32 -22
  30. package/dist/rag/ingest.js +371 -92
  31. package/dist/rag/search.js +80 -76
  32. package/dist/reset-articles.js +57 -60
  33. package/dist/reset-books.js +57 -59
  34. package/dist/reset-images.js +57 -59
  35. package/dist/reset-notes.js +57 -59
  36. package/dist/revert-articles.js +53 -55
  37. package/dist/revert-books.js +53 -53
  38. package/dist/revert-images.js +53 -53
  39. package/dist/revert-notes.js +53 -53
  40. package/dist/s-content-format.js +103 -13
  41. package/dist/update-json-articles.js +101 -97
  42. package/dist/update-raw-articles.js +130 -130
  43. package/dist/validate-json-articles.js +129 -130
  44. package/package.json +14 -51
  45. package/dist/cleanup-minio-images.d.ts +0 -3
  46. package/dist/cleanup-minio-images.d.ts.map +0 -1
  47. package/dist/cleanup-minio-images.js.map +0 -1
  48. package/dist/enrich-books.d.ts +0 -3
  49. package/dist/enrich-books.d.ts.map +0 -1
  50. package/dist/enrich-books.js.map +0 -1
  51. package/dist/fetch-articles.d.ts +0 -3
  52. package/dist/fetch-articles.d.ts.map +0 -1
  53. package/dist/fetch-articles.js.map +0 -1
  54. package/dist/fetch-books.d.ts +0 -3
  55. package/dist/fetch-books.d.ts.map +0 -1
  56. package/dist/fetch-books.js.map +0 -1
  57. package/dist/fetch-images.d.ts +0 -3
  58. package/dist/fetch-images.d.ts.map +0 -1
  59. package/dist/fetch-images.js.map +0 -1
  60. package/dist/fetch-notes.d.ts +0 -3
  61. package/dist/fetch-notes.d.ts.map +0 -1
  62. package/dist/fetch-notes.js.map +0 -1
  63. package/dist/find-duplicate-json-articles.d.ts +0 -3
  64. package/dist/find-duplicate-json-articles.d.ts.map +0 -1
  65. package/dist/find-duplicate-json-articles.js.map +0 -1
  66. package/dist/fix-book-frontmatter.d.ts +0 -3
  67. package/dist/fix-book-frontmatter.d.ts.map +0 -1
  68. package/dist/fix-book-frontmatter.js.map +0 -1
  69. package/dist/fix-image-formats.d.ts +0 -3
  70. package/dist/fix-image-formats.d.ts.map +0 -1
  71. package/dist/fix-image-formats.js.map +0 -1
  72. package/dist/infrastructures/articles-command-repository.d.ts +0 -57
  73. package/dist/infrastructures/articles-command-repository.d.ts.map +0 -1
  74. package/dist/infrastructures/articles-command-repository.js +0 -68
  75. package/dist/infrastructures/articles-command-repository.js.map +0 -1
  76. package/dist/infrastructures/books-command-repository.d.ts +0 -34
  77. package/dist/infrastructures/books-command-repository.d.ts.map +0 -1
  78. package/dist/infrastructures/books-command-repository.js +0 -53
  79. package/dist/infrastructures/books-command-repository.js.map +0 -1
  80. package/dist/infrastructures/cache-invalidation-client.d.ts +0 -9
  81. package/dist/infrastructures/cache-invalidation-client.d.ts.map +0 -1
  82. package/dist/infrastructures/cache-invalidation-client.js +0 -21
  83. package/dist/infrastructures/cache-invalidation-client.js.map +0 -1
  84. package/dist/infrastructures/cache-invalidation-client.test.d.ts +0 -2
  85. package/dist/infrastructures/cache-invalidation-client.test.d.ts.map +0 -1
  86. package/dist/infrastructures/cache-invalidation-client.test.js +0 -25
  87. package/dist/infrastructures/cache-invalidation-client.test.js.map +0 -1
  88. package/dist/infrastructures/images-command-repository.d.ts +0 -34
  89. package/dist/infrastructures/images-command-repository.d.ts.map +0 -1
  90. package/dist/infrastructures/images-command-repository.js +0 -53
  91. package/dist/infrastructures/images-command-repository.js.map +0 -1
  92. package/dist/infrastructures/notes-command-repository.d.ts +0 -34
  93. package/dist/infrastructures/notes-command-repository.d.ts.map +0 -1
  94. package/dist/infrastructures/notes-command-repository.js +0 -53
  95. package/dist/infrastructures/notes-command-repository.js.map +0 -1
  96. package/dist/ingest-articles.d.ts +0 -3
  97. package/dist/ingest-articles.d.ts.map +0 -1
  98. package/dist/ingest-articles.js.map +0 -1
  99. package/dist/ingest-books.d.ts +0 -3
  100. package/dist/ingest-books.d.ts.map +0 -1
  101. package/dist/ingest-books.js.map +0 -1
  102. package/dist/ingest-images.d.ts +0 -3
  103. package/dist/ingest-images.d.ts.map +0 -1
  104. package/dist/ingest-images.js.map +0 -1
  105. package/dist/ingest-notes.d.ts +0 -3
  106. package/dist/ingest-notes.d.ts.map +0 -1
  107. package/dist/ingest-notes.js.map +0 -1
  108. package/dist/lib/glob-paths.d.ts +0 -6
  109. package/dist/lib/glob-paths.d.ts.map +0 -1
  110. package/dist/lib/glob-paths.js +0 -9
  111. package/dist/lib/glob-paths.js.map +0 -1
  112. package/dist/lib/glob-paths.test.d.ts +0 -2
  113. package/dist/lib/glob-paths.test.d.ts.map +0 -1
  114. package/dist/lib/glob-paths.test.js +0 -30
  115. package/dist/lib/glob-paths.test.js.map +0 -1
  116. package/dist/lib/html-charset.d.ts +0 -4
  117. package/dist/lib/html-charset.d.ts.map +0 -1
  118. package/dist/lib/html-charset.js +0 -33
  119. package/dist/lib/html-charset.js.map +0 -1
  120. package/dist/lib/html-charset.test.d.ts +0 -2
  121. package/dist/lib/html-charset.test.d.ts.map +0 -1
  122. package/dist/lib/html-charset.test.js +0 -27
  123. package/dist/lib/html-charset.test.js.map +0 -1
  124. package/dist/rag/delete-collection.d.ts +0 -3
  125. package/dist/rag/delete-collection.d.ts.map +0 -1
  126. package/dist/rag/delete-collection.js.map +0 -1
  127. package/dist/rag/ingest-config.d.ts +0 -8
  128. package/dist/rag/ingest-config.d.ts.map +0 -1
  129. package/dist/rag/ingest-config.js +0 -8
  130. package/dist/rag/ingest-config.js.map +0 -1
  131. package/dist/rag/ingest.d.ts +0 -3
  132. package/dist/rag/ingest.d.ts.map +0 -1
  133. package/dist/rag/ingest.js.map +0 -1
  134. package/dist/rag/search.d.ts +0 -3
  135. package/dist/rag/search.d.ts.map +0 -1
  136. package/dist/rag/search.js.map +0 -1
  137. package/dist/reset-articles.d.ts +0 -3
  138. package/dist/reset-articles.d.ts.map +0 -1
  139. package/dist/reset-articles.js.map +0 -1
  140. package/dist/reset-books.d.ts +0 -3
  141. package/dist/reset-books.d.ts.map +0 -1
  142. package/dist/reset-books.js.map +0 -1
  143. package/dist/reset-images.d.ts +0 -3
  144. package/dist/reset-images.d.ts.map +0 -1
  145. package/dist/reset-images.js.map +0 -1
  146. package/dist/reset-notes.d.ts +0 -3
  147. package/dist/reset-notes.d.ts.map +0 -1
  148. package/dist/reset-notes.js.map +0 -1
  149. package/dist/revert-articles.d.ts +0 -3
  150. package/dist/revert-articles.d.ts.map +0 -1
  151. package/dist/revert-articles.js.map +0 -1
  152. package/dist/revert-books.d.ts +0 -3
  153. package/dist/revert-books.d.ts.map +0 -1
  154. package/dist/revert-books.js.map +0 -1
  155. package/dist/revert-images.d.ts +0 -3
  156. package/dist/revert-images.d.ts.map +0 -1
  157. package/dist/revert-images.js.map +0 -1
  158. package/dist/revert-notes.d.ts +0 -3
  159. package/dist/revert-notes.d.ts.map +0 -1
  160. package/dist/revert-notes.js.map +0 -1
  161. package/dist/s-content-format-runner.d.ts +0 -10
  162. package/dist/s-content-format-runner.d.ts.map +0 -1
  163. package/dist/s-content-format-runner.js +0 -76
  164. package/dist/s-content-format-runner.js.map +0 -1
  165. package/dist/s-content-format.d.ts +0 -3
  166. package/dist/s-content-format.d.ts.map +0 -1
  167. package/dist/s-content-format.js.map +0 -1
  168. package/dist/s-content-format.test.d.ts +0 -2
  169. package/dist/s-content-format.test.d.ts.map +0 -1
  170. package/dist/s-content-format.test.js +0 -99
  171. package/dist/s-content-format.test.js.map +0 -1
  172. package/dist/update-json-articles.d.ts +0 -3
  173. package/dist/update-json-articles.d.ts.map +0 -1
  174. package/dist/update-json-articles.js.map +0 -1
  175. package/dist/update-raw-articles.d.ts +0 -3
  176. package/dist/update-raw-articles.d.ts.map +0 -1
  177. package/dist/update-raw-articles.js.map +0 -1
  178. package/dist/validate-json-articles.d.ts +0 -3
  179. package/dist/validate-json-articles.d.ts.map +0 -1
  180. package/dist/validate-json-articles.js.map +0 -1
@@ -1,65 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import { ArticlesBatchDomainService } from "@s-hirano-ist/s-core/articles/services/articles-batch-domain-service";
3
- import { makeUserId, } from "@s-hirano-ist/s-core/shared-kernel/entities/common-entity";
4
- import { createPrismaClient } from "@s-hirano-ist/s-database";
5
- import { createPushoverService } from "@s-hirano-ist/s-notification";
6
- import { createArticlesCommandRepository } from "./infrastructures/articles-command-repository.js";
7
- import { invalidateContentCache } from "./infrastructures/cache-invalidation-client.js";
2
+ import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
+ import {
4
+ ArticlesBatchApplicationService,
5
+ createArticlesCommandRepository
6
+ } from "./chunk-N6TZF755.js";
7
+ import {
8
+ createPrismaClient,
9
+ makeUserId
10
+ } from "./chunk-IWNZQXDG.js";
11
+ import {
12
+ createPushoverService
13
+ } from "./chunk-7PVU2Z32.js";
14
+ import "./chunk-JZOR5GA2.js";
15
+
16
+ // src/reset-articles.ts
8
17
  async function main() {
9
- const env = {
10
- CACHE_INVALIDATION_SECRET: process.env.CACHE_INVALIDATION_SECRET,
11
- CACHE_INVALIDATION_URL: process.env.CACHE_INVALIDATION_URL,
12
- DATABASE_URL: process.env.DATABASE_URL,
13
- PUSHOVER_URL: process.env.PUSHOVER_URL,
14
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
15
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
16
- USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
17
- };
18
- if (Object.values(env).some((v) => !v)) {
19
- throw new Error("Required environment variables are not set.");
20
- }
21
- const prisma = createPrismaClient(env.DATABASE_URL ?? "");
22
- const notificationService = createPushoverService({
23
- url: env.PUSHOVER_URL ?? "",
24
- userKey: env.PUSHOVER_USER_KEY ?? "",
25
- appToken: env.PUSHOVER_APP_TOKEN ?? "",
26
- });
27
- const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
28
- async function resetArticles() {
29
- // DDD: Create repository and domain service
30
- // Transaction is handled internally by repository's resetStatus method
31
- const commandRepository = createArticlesCommandRepository(prisma);
32
- const batchService = new ArticlesBatchDomainService(commandRepository);
33
- // Execute batch reset through domain service
34
- const result = await batchService.resetArticles(userId);
35
- // The database transaction has committed at this point. A cache failure is
36
- // treated as a failed batch run so it is logged and sent to Pushover.
37
- await invalidateContentCache({
38
- url: env.CACHE_INVALIDATION_URL ?? "",
39
- secret: env.CACHE_INVALIDATION_SECRET ?? "",
40
- }, "articles", userId);
41
- console.log(`💾 LAST_UPDATEDの記事をEXPORTEDに変更しました(${result.finalized.count}件)`);
42
- console.log(`💾 ${result.marked.count}件の記事をリセットしました`);
43
- }
44
- try {
45
- await resetArticles();
46
- await notificationService.notifyInfo("reset-articles completed", {
47
- caller: "reset-articles",
48
- });
49
- }
50
- catch (error) {
51
- console.error("❌ エラーが発生しました:", error);
52
- await notificationService.notifyError(`reset-articles failed: ${String(error)}`, {
53
- caller: "reset-articles",
54
- });
55
- process.exit(1);
56
- }
57
- finally {
58
- await prisma.$disconnect();
59
- }
18
+ const env = {
19
+ DATABASE_URL: process.env.DATABASE_URL,
20
+ PUSHOVER_URL: process.env.PUSHOVER_URL,
21
+ PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
22
+ PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
23
+ USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
24
+ };
25
+ if (Object.values(env).some((v) => !v)) {
26
+ throw new Error("Required environment variables are not set.");
27
+ }
28
+ const prisma = createPrismaClient(env.DATABASE_URL ?? "");
29
+ const notificationService = createPushoverService({
30
+ url: env.PUSHOVER_URL ?? "",
31
+ userKey: env.PUSHOVER_USER_KEY ?? "",
32
+ appToken: env.PUSHOVER_APP_TOKEN ?? ""
33
+ });
34
+ const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
35
+ async function resetArticles() {
36
+ const commandRepository = createArticlesCommandRepository(prisma);
37
+ const batchService = new ArticlesBatchApplicationService(commandRepository);
38
+ const result = await batchService.resetArticles(userId);
39
+ console.log(
40
+ `\u{1F4BE} LAST_UPDATED\u306E\u8A18\u4E8B\u3092EXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.finalized.count}\u4EF6\uFF09`
41
+ );
42
+ console.log(`\u{1F4BE} ${result.marked.count}\u4EF6\u306E\u8A18\u4E8B\u3092\u30EA\u30BB\u30C3\u30C8\u3057\u307E\u3057\u305F`);
43
+ }
44
+ try {
45
+ await resetArticles();
46
+ await notificationService.notifyInfo("reset-articles completed", {
47
+ caller: "reset-articles"
48
+ }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
+ } catch (error) {
50
+ console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
+ await notificationService.notifyError(`reset-articles failed: ${String(error)}`, {
52
+ caller: "reset-articles"
53
+ }).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
54
+ process.exitCode = 1;
55
+ } finally {
56
+ await prisma.$disconnect();
57
+ }
60
58
  }
61
59
  main().catch((error) => {
62
- console.error(error);
63
- process.exit(1);
60
+ console.error(error);
61
+ process.exit(1);
64
62
  });
65
- //# sourceMappingURL=reset-articles.js.map
@@ -1,64 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import { BooksBatchDomainService } from "@s-hirano-ist/s-core/books/services/books-batch-domain-service";
3
- import { makeUserId, } from "@s-hirano-ist/s-core/shared-kernel/entities/common-entity";
4
- import { createPrismaClient } from "@s-hirano-ist/s-database";
5
- import { createPushoverService } from "@s-hirano-ist/s-notification";
6
- import { createBooksCommandRepository } from "./infrastructures/books-command-repository.js";
7
- import { invalidateContentCache } from "./infrastructures/cache-invalidation-client.js";
2
+ import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
+ import {
4
+ BooksBatchApplicationService,
5
+ createBooksCommandRepository
6
+ } from "./chunk-AZF2R2BF.js";
7
+ import {
8
+ createPrismaClient,
9
+ makeUserId
10
+ } from "./chunk-IWNZQXDG.js";
11
+ import {
12
+ createPushoverService
13
+ } from "./chunk-7PVU2Z32.js";
14
+ import "./chunk-JZOR5GA2.js";
15
+
16
+ // src/reset-books.ts
8
17
  async function main() {
9
- const env = {
10
- CACHE_INVALIDATION_SECRET: process.env.CACHE_INVALIDATION_SECRET,
11
- CACHE_INVALIDATION_URL: process.env.CACHE_INVALIDATION_URL,
12
- DATABASE_URL: process.env.DATABASE_URL,
13
- PUSHOVER_URL: process.env.PUSHOVER_URL,
14
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
15
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
16
- USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
17
- };
18
- if (Object.values(env).some((v) => !v)) {
19
- throw new Error("Required environment variables are not set.");
20
- }
21
- const prisma = createPrismaClient(env.DATABASE_URL ?? "");
22
- const notificationService = createPushoverService({
23
- url: env.PUSHOVER_URL ?? "",
24
- userKey: env.PUSHOVER_USER_KEY ?? "",
25
- appToken: env.PUSHOVER_APP_TOKEN ?? "",
26
- });
27
- const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
28
- async function resetBooks() {
29
- // DDD: Create repository and domain service
30
- // Transaction is handled internally by repository's resetStatus method
31
- const commandRepository = createBooksCommandRepository(prisma);
32
- const batchService = new BooksBatchDomainService(commandRepository);
33
- const result = await batchService.resetBooks(userId);
34
- // The database transaction has committed at this point. A cache failure is
35
- // treated as a failed batch run so it is logged and sent to Pushover.
36
- await invalidateContentCache({
37
- url: env.CACHE_INVALIDATION_URL ?? "",
38
- secret: env.CACHE_INVALIDATION_SECRET ?? "",
39
- }, "books", userId);
40
- console.log(`💾 LAST_UPDATEDの本をEXPORTEDに変更しました(${result.finalized.count}件)`);
41
- console.log(`💾 ${result.marked.count}件の本をリセットしました`);
42
- }
43
- try {
44
- await resetBooks();
45
- await notificationService.notifyInfo("reset-books completed", {
46
- caller: "reset-books",
47
- });
48
- }
49
- catch (error) {
50
- console.error("❌ エラーが発生しました:", error);
51
- await notificationService.notifyError(`reset-books failed: ${String(error)}`, {
52
- caller: "reset-books",
53
- });
54
- process.exit(1);
55
- }
56
- finally {
57
- await prisma.$disconnect();
58
- }
18
+ const env = {
19
+ DATABASE_URL: process.env.DATABASE_URL,
20
+ PUSHOVER_URL: process.env.PUSHOVER_URL,
21
+ PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
22
+ PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
23
+ USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
24
+ };
25
+ if (Object.values(env).some((v) => !v)) {
26
+ throw new Error("Required environment variables are not set.");
27
+ }
28
+ const prisma = createPrismaClient(env.DATABASE_URL ?? "");
29
+ const notificationService = createPushoverService({
30
+ url: env.PUSHOVER_URL ?? "",
31
+ userKey: env.PUSHOVER_USER_KEY ?? "",
32
+ appToken: env.PUSHOVER_APP_TOKEN ?? ""
33
+ });
34
+ const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
35
+ async function resetBooks() {
36
+ const commandRepository = createBooksCommandRepository(prisma);
37
+ const batchService = new BooksBatchApplicationService(commandRepository);
38
+ const result = await batchService.resetBooks(userId);
39
+ console.log(
40
+ `\u{1F4BE} LAST_UPDATED\u306E\u672C\u3092EXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.finalized.count}\u4EF6\uFF09`
41
+ );
42
+ console.log(`\u{1F4BE} ${result.marked.count}\u4EF6\u306E\u672C\u3092\u30EA\u30BB\u30C3\u30C8\u3057\u307E\u3057\u305F`);
43
+ }
44
+ try {
45
+ await resetBooks();
46
+ await notificationService.notifyInfo("reset-books completed", {
47
+ caller: "reset-books"
48
+ }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
+ } catch (error) {
50
+ console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
+ await notificationService.notifyError(`reset-books failed: ${String(error)}`, {
52
+ caller: "reset-books"
53
+ }).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
54
+ process.exitCode = 1;
55
+ } finally {
56
+ await prisma.$disconnect();
57
+ }
59
58
  }
60
59
  main().catch((error) => {
61
- console.error(error);
62
- process.exit(1);
60
+ console.error(error);
61
+ process.exit(1);
63
62
  });
64
- //# sourceMappingURL=reset-books.js.map
@@ -1,64 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import { ImagesBatchDomainService } from "@s-hirano-ist/s-core/images/services/images-batch-domain-service";
3
- import { makeUserId, } from "@s-hirano-ist/s-core/shared-kernel/entities/common-entity";
4
- import { createPrismaClient } from "@s-hirano-ist/s-database";
5
- import { createPushoverService } from "@s-hirano-ist/s-notification";
6
- import { invalidateContentCache } from "./infrastructures/cache-invalidation-client.js";
7
- import { createImagesCommandRepository } from "./infrastructures/images-command-repository.js";
2
+ import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
+ import {
4
+ ImagesBatchApplicationService,
5
+ createImagesCommandRepository
6
+ } from "./chunk-HIK7SX34.js";
7
+ import {
8
+ createPrismaClient,
9
+ makeUserId
10
+ } from "./chunk-IWNZQXDG.js";
11
+ import {
12
+ createPushoverService
13
+ } from "./chunk-7PVU2Z32.js";
14
+ import "./chunk-JZOR5GA2.js";
15
+
16
+ // src/reset-images.ts
8
17
  async function main() {
9
- const env = {
10
- CACHE_INVALIDATION_SECRET: process.env.CACHE_INVALIDATION_SECRET,
11
- CACHE_INVALIDATION_URL: process.env.CACHE_INVALIDATION_URL,
12
- DATABASE_URL: process.env.DATABASE_URL,
13
- PUSHOVER_URL: process.env.PUSHOVER_URL,
14
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
15
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
16
- USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
17
- };
18
- if (Object.values(env).some((v) => !v)) {
19
- throw new Error("Required environment variables are not set.");
20
- }
21
- const prisma = createPrismaClient(env.DATABASE_URL ?? "");
22
- const notificationService = createPushoverService({
23
- url: env.PUSHOVER_URL ?? "",
24
- userKey: env.PUSHOVER_USER_KEY ?? "",
25
- appToken: env.PUSHOVER_APP_TOKEN ?? "",
26
- });
27
- const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
28
- async function resetImages() {
29
- // DDD: Create repository and domain service
30
- // Transaction is handled internally by repository's resetStatus method
31
- const commandRepository = createImagesCommandRepository(prisma);
32
- const batchService = new ImagesBatchDomainService(commandRepository);
33
- const result = await batchService.resetImages(userId);
34
- // The database transaction has committed at this point. A cache failure is
35
- // treated as a failed batch run so it is logged and sent to Pushover.
36
- await invalidateContentCache({
37
- url: env.CACHE_INVALIDATION_URL ?? "",
38
- secret: env.CACHE_INVALIDATION_SECRET ?? "",
39
- }, "images", userId);
40
- console.log(`💾 LAST_UPDATEDの画像をEXPORTEDに変更しました(${result.finalized.count}件)`);
41
- console.log(`💾 ${result.marked.count}件の画像をリセットしました`);
42
- }
43
- try {
44
- await resetImages();
45
- await notificationService.notifyInfo("reset-images completed", {
46
- caller: "reset-images",
47
- });
48
- }
49
- catch (error) {
50
- console.error("❌ エラーが発生しました:", error);
51
- await notificationService.notifyError(`reset-images failed: ${String(error)}`, {
52
- caller: "reset-images",
53
- });
54
- process.exit(1);
55
- }
56
- finally {
57
- await prisma.$disconnect();
58
- }
18
+ const env = {
19
+ DATABASE_URL: process.env.DATABASE_URL,
20
+ PUSHOVER_URL: process.env.PUSHOVER_URL,
21
+ PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
22
+ PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
23
+ USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
24
+ };
25
+ if (Object.values(env).some((v) => !v)) {
26
+ throw new Error("Required environment variables are not set.");
27
+ }
28
+ const prisma = createPrismaClient(env.DATABASE_URL ?? "");
29
+ const notificationService = createPushoverService({
30
+ url: env.PUSHOVER_URL ?? "",
31
+ userKey: env.PUSHOVER_USER_KEY ?? "",
32
+ appToken: env.PUSHOVER_APP_TOKEN ?? ""
33
+ });
34
+ const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
35
+ async function resetImages() {
36
+ const commandRepository = createImagesCommandRepository(prisma);
37
+ const batchService = new ImagesBatchApplicationService(commandRepository);
38
+ const result = await batchService.resetImages(userId);
39
+ console.log(
40
+ `\u{1F4BE} LAST_UPDATED\u306E\u753B\u50CF\u3092EXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.finalized.count}\u4EF6\uFF09`
41
+ );
42
+ console.log(`\u{1F4BE} ${result.marked.count}\u4EF6\u306E\u753B\u50CF\u3092\u30EA\u30BB\u30C3\u30C8\u3057\u307E\u3057\u305F`);
43
+ }
44
+ try {
45
+ await resetImages();
46
+ await notificationService.notifyInfo("reset-images completed", {
47
+ caller: "reset-images"
48
+ }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
+ } catch (error) {
50
+ console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
+ await notificationService.notifyError(`reset-images failed: ${String(error)}`, {
52
+ caller: "reset-images"
53
+ }).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
54
+ process.exitCode = 1;
55
+ } finally {
56
+ await prisma.$disconnect();
57
+ }
59
58
  }
60
59
  main().catch((error) => {
61
- console.error(error);
62
- process.exit(1);
60
+ console.error(error);
61
+ process.exit(1);
63
62
  });
64
- //# sourceMappingURL=reset-images.js.map
@@ -1,64 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import { NotesBatchDomainService } from "@s-hirano-ist/s-core/notes/services/notes-batch-domain-service";
3
- import { makeUserId, } from "@s-hirano-ist/s-core/shared-kernel/entities/common-entity";
4
- import { createPrismaClient } from "@s-hirano-ist/s-database";
5
- import { createPushoverService } from "@s-hirano-ist/s-notification";
6
- import { invalidateContentCache } from "./infrastructures/cache-invalidation-client.js";
7
- import { createNotesCommandRepository } from "./infrastructures/notes-command-repository.js";
2
+ import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
+ import {
4
+ NotesBatchApplicationService,
5
+ createNotesCommandRepository
6
+ } from "./chunk-S5WJ5VXW.js";
7
+ import {
8
+ createPrismaClient,
9
+ makeUserId
10
+ } from "./chunk-IWNZQXDG.js";
11
+ import {
12
+ createPushoverService
13
+ } from "./chunk-7PVU2Z32.js";
14
+ import "./chunk-JZOR5GA2.js";
15
+
16
+ // src/reset-notes.ts
8
17
  async function main() {
9
- const env = {
10
- CACHE_INVALIDATION_SECRET: process.env.CACHE_INVALIDATION_SECRET,
11
- CACHE_INVALIDATION_URL: process.env.CACHE_INVALIDATION_URL,
12
- DATABASE_URL: process.env.DATABASE_URL,
13
- PUSHOVER_URL: process.env.PUSHOVER_URL,
14
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
15
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
16
- USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
17
- };
18
- if (Object.values(env).some((v) => !v)) {
19
- throw new Error("Required environment variables are not set.");
20
- }
21
- const prisma = createPrismaClient(env.DATABASE_URL ?? "");
22
- const notificationService = createPushoverService({
23
- url: env.PUSHOVER_URL ?? "",
24
- userKey: env.PUSHOVER_USER_KEY ?? "",
25
- appToken: env.PUSHOVER_APP_TOKEN ?? "",
26
- });
27
- const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
28
- async function resetNotes() {
29
- // DDD: Create repository and domain service
30
- // Transaction is handled internally by repository's resetStatus method
31
- const commandRepository = createNotesCommandRepository(prisma);
32
- const batchService = new NotesBatchDomainService(commandRepository);
33
- const result = await batchService.resetNotes(userId);
34
- // The database transaction has committed at this point. A cache failure is
35
- // treated as a failed batch run so it is logged and sent to Pushover.
36
- await invalidateContentCache({
37
- url: env.CACHE_INVALIDATION_URL ?? "",
38
- secret: env.CACHE_INVALIDATION_SECRET ?? "",
39
- }, "notes", userId);
40
- console.log(`💾 LAST_UPDATEDのノートをEXPORTEDに変更しました(${result.finalized.count}件)`);
41
- console.log(`💾 ${result.marked.count}件のノートをリセットしました`);
42
- }
43
- try {
44
- await resetNotes();
45
- await notificationService.notifyInfo("reset-notes completed", {
46
- caller: "reset-notes",
47
- });
48
- }
49
- catch (error) {
50
- console.error("❌ エラーが発生しました:", error);
51
- await notificationService.notifyError(`reset-notes failed: ${String(error)}`, {
52
- caller: "reset-notes",
53
- });
54
- process.exit(1);
55
- }
56
- finally {
57
- await prisma.$disconnect();
58
- }
18
+ const env = {
19
+ DATABASE_URL: process.env.DATABASE_URL,
20
+ PUSHOVER_URL: process.env.PUSHOVER_URL,
21
+ PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
22
+ PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
23
+ USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
24
+ };
25
+ if (Object.values(env).some((v) => !v)) {
26
+ throw new Error("Required environment variables are not set.");
27
+ }
28
+ const prisma = createPrismaClient(env.DATABASE_URL ?? "");
29
+ const notificationService = createPushoverService({
30
+ url: env.PUSHOVER_URL ?? "",
31
+ userKey: env.PUSHOVER_USER_KEY ?? "",
32
+ appToken: env.PUSHOVER_APP_TOKEN ?? ""
33
+ });
34
+ const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
35
+ async function resetNotes() {
36
+ const commandRepository = createNotesCommandRepository(prisma);
37
+ const batchService = new NotesBatchApplicationService(commandRepository);
38
+ const result = await batchService.resetNotes(userId);
39
+ console.log(
40
+ `\u{1F4BE} LAST_UPDATED\u306E\u30CE\u30FC\u30C8\u3092EXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.finalized.count}\u4EF6\uFF09`
41
+ );
42
+ console.log(`\u{1F4BE} ${result.marked.count}\u4EF6\u306E\u30CE\u30FC\u30C8\u3092\u30EA\u30BB\u30C3\u30C8\u3057\u307E\u3057\u305F`);
43
+ }
44
+ try {
45
+ await resetNotes();
46
+ await notificationService.notifyInfo("reset-notes completed", {
47
+ caller: "reset-notes"
48
+ }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
+ } catch (error) {
50
+ console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
+ await notificationService.notifyError(`reset-notes failed: ${String(error)}`, {
52
+ caller: "reset-notes"
53
+ }).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
54
+ process.exitCode = 1;
55
+ } finally {
56
+ await prisma.$disconnect();
57
+ }
59
58
  }
60
59
  main().catch((error) => {
61
- console.error(error);
62
- process.exit(1);
60
+ console.error(error);
61
+ process.exit(1);
63
62
  });
64
- //# sourceMappingURL=reset-notes.js.map
@@ -1,60 +1,58 @@
1
1
  #!/usr/bin/env node
2
- import { ArticlesBatchDomainService } from "@s-hirano-ist/s-core/articles/services/articles-batch-domain-service";
3
- import { makeUserId, } from "@s-hirano-ist/s-core/shared-kernel/entities/common-entity";
4
- import { createPrismaClient } from "@s-hirano-ist/s-database";
5
- import { createPushoverService } from "@s-hirano-ist/s-notification";
6
- import { createArticlesCommandRepository } from "./infrastructures/articles-command-repository.js";
7
- import { invalidateContentCache } from "./infrastructures/cache-invalidation-client.js";
2
+ import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
+ import {
4
+ ArticlesBatchApplicationService,
5
+ createArticlesCommandRepository
6
+ } from "./chunk-N6TZF755.js";
7
+ import {
8
+ createPrismaClient,
9
+ makeUserId
10
+ } from "./chunk-IWNZQXDG.js";
11
+ import {
12
+ createPushoverService
13
+ } from "./chunk-7PVU2Z32.js";
14
+ import "./chunk-JZOR5GA2.js";
15
+
16
+ // src/revert-articles.ts
8
17
  async function main() {
9
- const env = {
10
- CACHE_INVALIDATION_SECRET: process.env.CACHE_INVALIDATION_SECRET,
11
- CACHE_INVALIDATION_URL: process.env.CACHE_INVALIDATION_URL,
12
- DATABASE_URL: process.env.DATABASE_URL,
13
- PUSHOVER_URL: process.env.PUSHOVER_URL,
14
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
15
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
16
- USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
17
- };
18
- if (Object.values(env).some((v) => !v)) {
19
- throw new Error("Required environment variables are not set.");
20
- }
21
- const prisma = createPrismaClient(env.DATABASE_URL ?? "");
22
- const notificationService = createPushoverService({
23
- url: env.PUSHOVER_URL ?? "",
24
- userKey: env.PUSHOVER_USER_KEY ?? "",
25
- appToken: env.PUSHOVER_APP_TOKEN ?? "",
26
- });
27
- const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
28
- try {
29
- // DDD: Create repository and domain service
30
- const commandRepository = createArticlesCommandRepository(prisma);
31
- const batchService = new ArticlesBatchDomainService(commandRepository);
32
- // Execute batch revert through domain service
33
- const result = await batchService.revertArticles(userId);
34
- // The database transaction has committed at this point. A cache failure is
35
- // treated as a failed batch run so it is logged and sent to Pushover.
36
- await invalidateContentCache({
37
- url: env.CACHE_INVALIDATION_URL ?? "",
38
- secret: env.CACHE_INVALIDATION_SECRET ?? "",
39
- }, "articles", userId);
40
- console.log(`💾 LAST_UPDATEDの記事をUNEXPORTEDに変更しました(${result.count}件)`);
41
- await notificationService.notifyInfo("revert-articles completed", {
42
- caller: "revert-articles",
43
- });
44
- }
45
- catch (error) {
46
- console.error("❌ エラーが発生しました:", error);
47
- await notificationService.notifyError(`revert-articles failed: ${String(error)}`, {
48
- caller: "revert-articles",
49
- });
50
- process.exit(1);
51
- }
52
- finally {
53
- await prisma.$disconnect();
54
- }
18
+ const env = {
19
+ DATABASE_URL: process.env.DATABASE_URL,
20
+ PUSHOVER_URL: process.env.PUSHOVER_URL,
21
+ PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
22
+ PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
23
+ USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
24
+ };
25
+ if (Object.values(env).some((v) => !v)) {
26
+ throw new Error("Required environment variables are not set.");
27
+ }
28
+ const prisma = createPrismaClient(env.DATABASE_URL ?? "");
29
+ const notificationService = createPushoverService({
30
+ url: env.PUSHOVER_URL ?? "",
31
+ userKey: env.PUSHOVER_USER_KEY ?? "",
32
+ appToken: env.PUSHOVER_APP_TOKEN ?? ""
33
+ });
34
+ const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
35
+ try {
36
+ const commandRepository = createArticlesCommandRepository(prisma);
37
+ const batchService = new ArticlesBatchApplicationService(commandRepository);
38
+ const result = await batchService.revertArticles(userId);
39
+ console.log(
40
+ `\u{1F4BE} LAST_UPDATED\u306E\u8A18\u4E8B\u3092UNEXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.count}\u4EF6\uFF09`
41
+ );
42
+ await notificationService.notifyInfo("revert-articles completed", {
43
+ caller: "revert-articles"
44
+ }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
45
+ } catch (error) {
46
+ console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
47
+ await notificationService.notifyError(`revert-articles failed: ${String(error)}`, {
48
+ caller: "revert-articles"
49
+ }).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
50
+ process.exitCode = 1;
51
+ } finally {
52
+ await prisma.$disconnect();
53
+ }
55
54
  }
56
55
  main().catch((error) => {
57
- console.error(error);
58
- process.exit(1);
56
+ console.error(error);
57
+ process.exit(1);
59
58
  });
60
- //# sourceMappingURL=revert-articles.js.map