includio-cms 0.36.6 → 0.36.8

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 (68) hide show
  1. package/API.md +8 -2
  2. package/CHANGELOG.md +30 -0
  3. package/DOCS.md +1 -1
  4. package/dist/admin/api/handler.js +2 -0
  5. package/dist/admin/api/media-jobs.d.ts +5 -0
  6. package/dist/admin/api/media-jobs.js +33 -0
  7. package/dist/admin/client/maintenance/maintenance-page.svelte +9 -0
  8. package/dist/admin/client/maintenance/media-jobs-panel.svelte +310 -0
  9. package/dist/admin/client/maintenance/media-jobs-panel.svelte.d.ts +3 -0
  10. package/dist/core/cms.js +7 -0
  11. package/dist/core/server/fields/utils/imageStyles.js +41 -4
  12. package/dist/core/server/index.d.ts +3 -0
  13. package/dist/core/server/index.js +3 -0
  14. package/dist/core/server/media/jobs/enqueue.d.ts +6 -0
  15. package/dist/core/server/media/jobs/enqueue.js +20 -0
  16. package/dist/core/server/media/jobs/processImageStyleJob.d.ts +19 -0
  17. package/dist/core/server/media/jobs/processImageStyleJob.js +23 -0
  18. package/dist/core/server/media/jobs/startWorker.d.ts +2 -0
  19. package/dist/core/server/media/jobs/startWorker.js +29 -0
  20. package/dist/core/server/media/jobs/worker.d.ts +29 -0
  21. package/dist/core/server/media/jobs/worker.js +54 -0
  22. package/dist/core/server/media/operations/replaceFile.js +2 -2
  23. package/dist/core/server/media/operations/uploadFile.js +10 -3
  24. package/dist/core/server/media/styles/buildStyleSpecs.d.ts +12 -0
  25. package/dist/core/server/media/styles/buildStyleSpecs.js +36 -0
  26. package/dist/core/server/media/styles/imagesConfig.d.ts +3 -0
  27. package/dist/core/server/media/styles/imagesConfig.js +16 -0
  28. package/dist/core/server/media/styles/operations/batchGenerateStyles.js +19 -41
  29. package/dist/core/server/media/styles/operations/generateFallbackVariant.d.ts +10 -0
  30. package/dist/core/server/media/styles/operations/generateFallbackVariant.js +21 -0
  31. package/dist/core/server/media/styles/operations/getImageStyle.js +12 -8
  32. package/dist/core/server/media/styles/sharp/sharpConfig.d.ts +7 -0
  33. package/dist/core/server/media/styles/sharp/sharpConfig.js +12 -0
  34. package/dist/db-postgres/index.js +113 -1
  35. package/dist/db-postgres/schema/imageStyle.js +1 -1
  36. package/dist/db-postgres/schema/index.d.ts +1 -0
  37. package/dist/db-postgres/schema/index.js +1 -0
  38. package/dist/db-postgres/schema/mediaFile.d.ts +17 -0
  39. package/dist/db-postgres/schema/mediaFile.js +1 -0
  40. package/dist/db-postgres/schema/mediaJob.d.ts +279 -0
  41. package/dist/db-postgres/schema/mediaJob.js +23 -0
  42. package/dist/paraglide/messages/_index.d.ts +36 -3
  43. package/dist/paraglide/messages/_index.js +71 -3
  44. package/dist/paraglide/messages/en.d.ts +5 -0
  45. package/dist/paraglide/messages/en.js +14 -0
  46. package/dist/paraglide/messages/pl.d.ts +5 -0
  47. package/dist/paraglide/messages/pl.js +14 -0
  48. package/dist/shop/adapters/fakturownia/payload.d.ts +2 -0
  49. package/dist/shop/adapters/fakturownia/payload.js +1 -0
  50. package/dist/shop/server/invoices.d.ts +16 -2
  51. package/dist/shop/server/invoices.js +86 -9
  52. package/dist/shop/types.d.ts +5 -0
  53. package/dist/sveltekit/components/image.svelte +1 -1
  54. package/dist/types/adapters/db.d.ts +51 -0
  55. package/dist/types/cms.d.ts +46 -0
  56. package/dist/types/media.d.ts +1 -0
  57. package/dist/updates/0.36.7/index.d.ts +2 -0
  58. package/dist/updates/0.36.7/index.js +13 -0
  59. package/dist/updates/0.36.8/index.d.ts +2 -0
  60. package/dist/updates/0.36.8/index.js +20 -0
  61. package/dist/updates/index.js +5 -1
  62. package/package.json +1 -1
  63. package/dist/paraglide/messages/hello_world.d.ts +0 -5
  64. package/dist/paraglide/messages/hello_world.js +0 -33
  65. package/dist/paraglide/messages/login_hello.d.ts +0 -16
  66. package/dist/paraglide/messages/login_hello.js +0 -34
  67. package/dist/paraglide/messages/login_please_login.d.ts +0 -16
  68. package/dist/paraglide/messages/login_please_login.js +0 -34
@@ -46,6 +46,14 @@ export interface DatabaseAdapter {
46
46
  getImageStyle: GetImageStyle;
47
47
  getImageStylesBatch: GetImageStylesBatch;
48
48
  createImageStyle: CreateImageStyle;
49
+ enqueueMediaJob: EnqueueMediaJob;
50
+ claimNextMediaJob: ClaimNextMediaJob;
51
+ completeMediaJob: CompleteMediaJob;
52
+ failMediaJob: FailMediaJob;
53
+ resetStaleMediaJobs: ResetStaleMediaJobs;
54
+ listMediaJobs: ListMediaJobs;
55
+ countMediaJobs: CountMediaJobs;
56
+ retryMediaJob: RetryMediaJob;
49
57
  deleteImageStylesByMediaFileId: DeleteImageStylesByMediaFileId;
50
58
  getAllImageStyles: GetAllImageStyles;
51
59
  deleteAllImageStyles: DeleteAllImageStyles;
@@ -139,6 +147,49 @@ export type DeleteMediaTag = (id: string) => Promise<void>;
139
147
  export type SetMediaFileTags = (fileId: string, tagIds: string[]) => Promise<void>;
140
148
  export type BulkSetMediaFileTags = (fileIds: string[], tagIds: string[]) => Promise<void>;
141
149
  export type BulkDeleteMediaFiles = (ids: string[]) => Promise<void>;
150
+ export type MediaJobStatus = 'pending' | 'processing' | 'done' | 'failed' | 'skipped';
151
+ export interface MediaJob {
152
+ id: string;
153
+ type: string;
154
+ mediaFileId: string;
155
+ payload: string;
156
+ dedupeKey: string;
157
+ status: MediaJobStatus;
158
+ priority: number;
159
+ attempts: number;
160
+ maxAttempts: number;
161
+ lastError: string | null;
162
+ runAfter: Date;
163
+ lockedAt: Date | null;
164
+ lockedBy: string | null;
165
+ createdAt: Date;
166
+ updatedAt: Date;
167
+ completedAt: Date | null;
168
+ }
169
+ export interface EnqueueMediaJobInput {
170
+ type: string;
171
+ mediaFileId: string;
172
+ payload: string;
173
+ dedupeKey: string;
174
+ priority?: number;
175
+ maxAttempts?: number;
176
+ }
177
+ export type EnqueueMediaJob = (input: EnqueueMediaJobInput) => Promise<void>;
178
+ export type ClaimNextMediaJob = (lockedBy: string) => Promise<MediaJob | null>;
179
+ export type CompleteMediaJob = (id: string) => Promise<void>;
180
+ export type FailMediaJob = (id: string, error: string, opts: {
181
+ retry: boolean;
182
+ runAfter?: Date;
183
+ }) => Promise<void>;
184
+ export type ResetStaleMediaJobs = (olderThan: Date) => Promise<number>;
185
+ export type ListMediaJobs = (opts: {
186
+ status?: MediaJobStatus;
187
+ type?: string;
188
+ limit: number;
189
+ offset?: number;
190
+ }) => Promise<MediaJob[]>;
191
+ export type CountMediaJobs = () => Promise<Record<MediaJobStatus, number>>;
192
+ export type RetryMediaJob = (id: string) => Promise<void>;
142
193
  export type UpdateMediaFile = (data: {
143
194
  id: string;
144
195
  data: Partial<MediaFile>;
@@ -30,11 +30,57 @@ export interface MaintenanceConfig {
30
30
  /** Interval in hours between maintenance runs (default: 6) */
31
31
  intervalHours?: number;
32
32
  }
33
+ export interface ImagesConfig {
34
+ /** Formaty wariantów (default: ['avif','webp']). Oryginał zostaje jako plik/fallback. */
35
+ formats: ('avif' | 'webp' | 'jpeg' | 'png')[];
36
+ /** Szerokości srcset (default: [640,1024,1536,2560]). Bez wariantu bazowego pełno-res. */
37
+ widths: number[];
38
+ /** Jakość per format (default: avif 52 / webp 78 / jpeg 80) */
39
+ quality: {
40
+ avif: number;
41
+ webp: number;
42
+ jpeg: number;
43
+ };
44
+ /** Twardy cap wymiaru wariantu (default: 2560) */
45
+ maxDimension: number;
46
+ /** Lekki fallback generowany synchronicznie przy uploadzie (default: 1280 jpeg) */
47
+ fallback: {
48
+ width: number;
49
+ format: 'jpeg' | 'webp';
50
+ };
51
+ }
52
+ export interface ImagesConfigInput {
53
+ formats?: ('avif' | 'webp' | 'jpeg' | 'png')[];
54
+ widths?: number[];
55
+ quality?: Partial<ImagesConfig['quality']>;
56
+ maxDimension?: number;
57
+ fallback?: Partial<ImagesConfig['fallback']>;
58
+ }
59
+ export interface OptimizationConfig {
60
+ /** In-process worker generujący warianty w tle (default: true) */
61
+ worker?: boolean;
62
+ /** Ile jobów sharp naraz (default: 1) */
63
+ concurrency?: number;
64
+ /** Prób przed oznaczeniem failed (default: 3) */
65
+ maxAttempts?: number;
66
+ /** Baza backoffu wykładniczego w ms (default: 30000) */
67
+ backoffBaseMs?: number;
68
+ /** Po jakim czasie processing uznać za martwe i wrócić do pending (default: 300000) */
69
+ staleLockMs?: number;
70
+ /** Interwał pollingu kolejki gdy pusta (default: 2000) */
71
+ pollIntervalMs?: number;
72
+ /** Limit pikseli źródła — poison-guard „image bomb" (default: 100_000_000) */
73
+ limitPixels?: number;
74
+ /** sharp.cache memory MB (default: 50) */
75
+ cacheMemoryMB?: number;
76
+ }
33
77
  export interface MediaConfig {
34
78
  maxOriginalWidth?: number;
35
79
  maxOriginalHeight?: number;
36
80
  video?: VideoTranscodeConfig;
37
81
  maintenance?: MaintenanceConfig;
82
+ images?: ImagesConfigInput;
83
+ optimization?: OptimizationConfig;
38
84
  }
39
85
  export interface AuthAdapter {
40
86
  api: {
@@ -37,6 +37,7 @@ export interface MediaFile {
37
37
  posterUrl: string | null;
38
38
  mimeType: string | null;
39
39
  blurDataUrl: string | null;
40
+ fallbackUrl?: string | null;
40
41
  focalX: number | null;
41
42
  focalY: number | null;
42
43
  transcriptFileId: string | null;
@@ -0,0 +1,2 @@
1
+ import type { CmsUpdate } from '../index.js';
2
+ export declare const update: CmsUpdate;
@@ -0,0 +1,13 @@
1
+ export const update = {
2
+ version: '0.36.7',
3
+ date: '2026-06-24',
4
+ description: 'Faktura uwzględnia rabat z kuponu i koszt wysyłki. Pozycje są wystawiane w cenach po rabacie (finalna kwota = kwota zapłacona), a użyty kod rabatowy trafia do uwag faktury. Wcześniej faktura zawierała pełne ceny katalogowe i pomijała rabat.',
5
+ features: [
6
+ 'Rabat z kuponu na fakturze: ceny pozycji obniżone proporcjonalnie do udziału brutto (reszta zaokrąglenia do ostatniej pozycji), suma = `order.totalGross`. Kod rabatowy dopisywany do uwag faktury (Fakturownia: pole `description`), zlokalizowany PL/EN wg języka zamówienia.',
7
+ 'Koszt wysyłki dodawany jako pozycja „Wysyłka" gdy > 0 (VAT rekonstruowany z net/gross, fallback 23%).'
8
+ ],
9
+ fixes: [
10
+ 'Faktury z kuponem nie pomijają już rabatu — wartość faktury zgadza się z kwotą zapłaconą przez klienta.'
11
+ ],
12
+ breakingChanges: []
13
+ };
@@ -0,0 +1,2 @@
1
+ import type { CmsUpdate } from '../index.js';
2
+ export declare const update: CmsUpdate;
@@ -0,0 +1,20 @@
1
+ export const update = {
2
+ version: '0.36.8',
3
+ date: '2026-07-02',
4
+ description: 'Optymalizacja obrazów przeniesiona do tła: render nigdy nie odpala sharpa. Warianty generuje in-process worker zasilany trwałą kolejką media_job (concurrency=1, twarde limity sharp, retry/backoff, circuit-breaker). Lżejsza, konfigurowalna matryca (avif+webp, bez pełno-res bazy, cap 2560) tnie ~połowę plików/jobów i eliminuje bombę CPU pełno-res AVIF, która OOM-owała VPS.',
5
+ features: [
6
+ 'Kolejka `media_job` + in-process worker: claim `FOR UPDATE SKIP LOCKED`, backoff wykładniczy, circuit-breaker po N próbach, poison-guard `limitInputPixels`, reset stale-locków. Start w `initCMS`, wyłączalny `media.optimization.worker=false`.',
7
+ 'Render kolejkuje brakujące style zamiast generować synchronicznie — odpowiedź HTTP nigdy nie czeka na sharpa; frontend serwuje lekki fallback + blur do czasu gotowości wariantów.',
8
+ 'Konfigurowalna matryca `mediaConfig.images`: `formats` (domyślnie avif+webp), `widths` [640,1024,1536,2560], `quality`, `maxDimension` (2560), `fallback` (jpeg ~1280). Bez wariantu bazowego pełno-res i bez martwej drabiny w formacie oryginalnym (~15 → ~8 wariantów/obraz).',
9
+ 'Upload generuje synchronicznie lekki fallback (`media_file.fallback_url`) i kolejkuje warianty; sweep oraz `replaceFile` też kolejkują (nie generują inline).',
10
+ 'Admin `/admin/maintenance`: sekcja „Kolejka mediów / Logi" — liczniki pending/processing/failed, lista failed z akcjami Ponów/Pomiń.',
11
+ 'Globalne limity sharp (`sharp.concurrency`/`cache`) ustawiane raz przy init. Deduplikacja zadań po efektywnej specyfikacji (format+wymiary+crop+quality).',
12
+ 'Public API: `enqueueStyleSpecs`, `startMediaWorker`, `stopMediaWorker`, typy `MediaJob`/`MediaJobStatus`.'
13
+ ],
14
+ fixes: [
15
+ '`image_styles`: dodany `crop` do klucza unikalnego (koniec cichego nadpisywania wariantów różniących się tylko cropem) + spójny `ON CONFLICT`.'
16
+ ],
17
+ breakingChanges: [
18
+ 'Nowa tabela `media_job` i kolumna `media_file.fallback_url` — wymagana migracja (`drizzle-kit push`). Render nie generuje styli synchronicznie (dogeneruje worker w tle). Konsumenci, którzy wyłączyli auto-maintenance z powodu OOM, mogą usunąć `media.maintenance.autoRun=false` — nowy worker jest bezpieczny by-design.'
19
+ ]
20
+ };
@@ -72,6 +72,8 @@ import { update as update0362 } from './0.36.2/index.js';
72
72
  import { update as update0363 } from './0.36.3/index.js';
73
73
  import { update as update0364 } from './0.36.4/index.js';
74
74
  import { update as update0365 } from './0.36.5/index.js';
75
+ import { update as update0367 } from './0.36.7/index.js';
76
+ import { update as update0368 } from './0.36.8/index.js';
75
77
  export const updates = [
76
78
  update0065,
77
79
  update0066,
@@ -146,7 +148,9 @@ export const updates = [
146
148
  update0362,
147
149
  update0363,
148
150
  update0364,
149
- update0365
151
+ update0365,
152
+ update0367,
153
+ update0368
150
154
  ];
151
155
  export const getUpdatesFrom = (fromVersion) => {
152
156
  const fromParts = fromVersion.split('.').map(Number);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "includio-cms",
3
- "version": "0.36.6",
3
+ "version": "0.36.8",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",
@@ -1,5 +0,0 @@
1
- export function hello_world(inputs: {
2
- name: NonNullable<unknown>;
3
- }, options?: {
4
- locale?: "en" | "pl";
5
- }): string;
@@ -1,33 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from '../runtime.js';
3
-
4
- const en_hello_world = /** @type {(inputs: { name: NonNullable<unknown> }) => string} */ (i) => {
5
- return `Hello, ${i.name} from en!`
6
- };
7
-
8
- const pl_hello_world = /** @type {(inputs: { name: NonNullable<unknown> }) => string} */ (i) => {
9
- return `Hello, ${i.name} from pl!`
10
- };
11
-
12
- /**
13
- * This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
14
- *
15
- * - Changing this function will be over-written by the next build.
16
- *
17
- * - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
18
- * use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
19
- *
20
- * @param {{ name: NonNullable<unknown> }} inputs
21
- * @param {{ locale?: "en" | "pl" }} options
22
- * @returns {string}
23
- */
24
- /* @__NO_SIDE_EFFECTS__ */
25
- export const hello_world = (inputs, options = {}) => {
26
- if (experimentalMiddlewareLocaleSplitting && isServer === false) {
27
- return /** @type {any} */ (globalThis).__paraglide_ssr.hello_world(inputs)
28
- }
29
- const locale = options.locale ?? getLocale()
30
- trackMessageCall("hello_world", locale)
31
- if (locale === "en") return en_hello_world(inputs)
32
- return pl_hello_world(inputs)
33
- };
@@ -1,16 +0,0 @@
1
- export { login_hello as login.hello };
2
- /**
3
- * This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
4
- *
5
- * - Changing this function will be over-written by the next build.
6
- *
7
- * - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
8
- * use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
9
- *
10
- * @param {{}} inputs
11
- * @param {{ locale?: "en" | "pl" }} options
12
- * @returns {string}
13
- */
14
- declare function login_hello(inputs?: {}, options?: {
15
- locale?: "en" | "pl";
16
- }): string;
@@ -1,34 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from '../runtime.js';
3
-
4
- const en_login_hello = /** @type {(inputs: {}) => string} */ () => {
5
- return `Welcome back`
6
- };
7
-
8
- const pl_login_hello = /** @type {(inputs: {}) => string} */ () => {
9
- return `Witaj ponownie`
10
- };
11
-
12
- /**
13
- * This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
14
- *
15
- * - Changing this function will be over-written by the next build.
16
- *
17
- * - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
18
- * use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
19
- *
20
- * @param {{}} inputs
21
- * @param {{ locale?: "en" | "pl" }} options
22
- * @returns {string}
23
- */
24
- /* @__NO_SIDE_EFFECTS__ */
25
- const login_hello = (inputs = {}, options = {}) => {
26
- if (experimentalMiddlewareLocaleSplitting && isServer === false) {
27
- return /** @type {any} */ (globalThis).__paraglide_ssr.login_hello(inputs)
28
- }
29
- const locale = options.locale ?? getLocale()
30
- trackMessageCall("login_hello", locale)
31
- if (locale === "en") return en_login_hello(inputs)
32
- return pl_login_hello(inputs)
33
- };
34
- export { login_hello as "login.hello" }
@@ -1,16 +0,0 @@
1
- export { login_please_login as login.please_login };
2
- /**
3
- * This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
4
- *
5
- * - Changing this function will be over-written by the next build.
6
- *
7
- * - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
8
- * use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
9
- *
10
- * @param {{}} inputs
11
- * @param {{ locale?: "en" | "pl" }} options
12
- * @returns {string}
13
- */
14
- declare function login_please_login(inputs?: {}, options?: {
15
- locale?: "en" | "pl";
16
- }): string;
@@ -1,34 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from '../runtime.js';
3
-
4
- const en_login_please_login = /** @type {(inputs: {}) => string} */ () => {
5
- return `Login to your account`
6
- };
7
-
8
- const pl_login_please_login = /** @type {(inputs: {}) => string} */ () => {
9
- return `Zaloguj się na swoje konto`
10
- };
11
-
12
- /**
13
- * This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
14
- *
15
- * - Changing this function will be over-written by the next build.
16
- *
17
- * - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
18
- * use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
19
- *
20
- * @param {{}} inputs
21
- * @param {{ locale?: "en" | "pl" }} options
22
- * @returns {string}
23
- */
24
- /* @__NO_SIDE_EFFECTS__ */
25
- const login_please_login = (inputs = {}, options = {}) => {
26
- if (experimentalMiddlewareLocaleSplitting && isServer === false) {
27
- return /** @type {any} */ (globalThis).__paraglide_ssr.login_please_login(inputs)
28
- }
29
- const locale = options.locale ?? getLocale()
30
- trackMessageCall("login_please_login", locale)
31
- if (locale === "en") return en_login_please_login(inputs)
32
- return pl_login_please_login(inputs)
33
- };
34
- export { login_please_login as "login.please_login" }