@oktis-works/cms 1.0.0 → 1.0.2

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.
@@ -3,12 +3,12 @@
3
3
  // by `bun run build`. Used as the offline fallback for `okcms init` ranges
4
4
  // when the npm registry cannot be reached.
5
5
  export const APP_VERSIONS = {
6
- '@oktis-works/api': '0.19.4',
7
- '@oktis-works/admin': '1.0.0',
8
- '@oktis-works/web': '1.0.0',
9
- '@oktis-works/worker': '0.8.21',
10
- '@oktis-works/core': '1.0.0',
11
- '@oktis-works/plugin-runtime': '0.8.4',
12
- '@oktis-works/cms': '1.0.0',
6
+ '@oktis-works/api': '0.19.6',
7
+ '@oktis-works/admin': '1.0.2',
8
+ '@oktis-works/web': '1.0.2',
9
+ '@oktis-works/worker': '0.8.22',
10
+ '@oktis-works/core': '1.0.2',
11
+ '@oktis-works/plugin-runtime': '0.8.5',
12
+ '@oktis-works/cms': '1.0.2',
13
13
  };
14
14
  //# sourceMappingURL=app-versions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-assets.d.ts","sourceRoot":"","sources":["../../src/generated/theme-assets.ts"],"names":[],"mappings":"AAOA,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8wEtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAE7D,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,EAAE,MAAgD,CAAC;AAEtF,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,EAAE,MAAoD,CAAC;AAErF,0DAA0D;AAC1D,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAExD,CAAC"}
1
+ {"version":3,"file":"theme-assets.d.ts","sourceRoot":"","sources":["../../src/generated/theme-assets.ts"],"names":[],"mappings":"AAOA,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2zEtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAE7D,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,EAAE,MAAgD,CAAC;AAEtF,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,EAAE,MAAoD,CAAC;AAErF,0DAA0D;AAC1D,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAExD,CAAC"}
@@ -26,6 +26,15 @@ export const DEFAULT_THEME_FILES = {
26
26
  `,
27
27
  "archive.tsx": `import type { ThemePageData } from '@oktis-works/theme-sdk';
28
28
 
29
+ function itemUrl(item: Record<string, unknown>): string {
30
+ return typeof item.url === 'string' && item.url ? item.url : \`/\${String(item.slug ?? '')}\`;
31
+ }
32
+
33
+ function itemDate(item: Record<string, unknown>): string | undefined {
34
+ const value = item.publishedAt ?? item.published_at;
35
+ return typeof value === 'string' || value instanceof Date ? String(value) : undefined;
36
+ }
37
+
29
38
  export default function Archive({ page, items }: ThemePageData) {
30
39
  return (
31
40
  <main className="site archive">
@@ -42,13 +51,13 @@ export default function Archive({ page, items }: ThemePageData) {
42
51
  <article className="post-card" key={String(item.slug)}>
43
52
  <div className="post-card__content">
44
53
  <div className="post-card__header">
45
- <time className="post-card__date">{item.publishedAt ? new Date(item.publishedAt).toLocaleDateString() : ''}</time>
54
+ <time className="post-card__date">{itemDate(item) ? new Date(itemDate(item)!).toLocaleDateString() : ''}</time>
46
55
  </div>
47
56
  <h2 className="post-card__title">
48
- <a href={\`/\${String(item.slug)}\`}>{String(item.title ?? '')}</a>
57
+ <a href={itemUrl(item)}>{String(item.title ?? '')}</a>
49
58
  </h2>
50
59
  {item.excerpt ? <p className="post-card__excerpt">{String(item.excerpt)}</p> : null}
51
- <a href={\`/\${String(item.slug)}\`} className="btn btn-outline">Read More</a>
60
+ <a href={itemUrl(item)} className="btn btn-outline">Read More</a>
52
61
  </div>
53
62
  </article>
54
63
  ))}
@@ -57,7 +66,8 @@ export default function Archive({ page, items }: ThemePageData) {
57
66
  </div>
58
67
  </main>
59
68
  );
60
- }`,
69
+ }
70
+ `,
61
71
  "dist/theme.css": `/**
62
72
  * Tema Default do OkCMS — Design System CSS
63
73
  * Engine: css | Isolation: manual
@@ -1076,19 +1086,27 @@ export default function Archive({ page, items }: ThemePageData) {
1076
1086
  `,
1077
1087
  "home.tsx": `import type { ThemePageData } from '@oktis-works/theme-sdk';
1078
1088
 
1079
- export default function Home({ site, items, settings }: ThemePageData) {
1080
- const theme = (settings.theme ?? {}) as Record<string, unknown>;
1089
+ function itemUrl(item: Record<string, unknown>): string {
1090
+ return typeof item.url === 'string' && item.url ? item.url : \`/\${String(item.slug ?? '')}\`;
1091
+ }
1092
+
1093
+ function itemDate(item: Record<string, unknown>): string | undefined {
1094
+ const value = item.publishedAt ?? item.published_at;
1095
+ return typeof value === 'string' || value instanceof Date ? String(value) : undefined;
1096
+ }
1097
+
1098
+ export default function Home({ site, items }: ThemePageData) {
1081
1099
  return (
1082
1100
  <main className="site">
1083
1101
  <header className="site-header">
1084
1102
  <div className="container">
1085
- <h1>{String(theme.siteTitle ?? site.title)}</h1>
1103
+ <h1>{site.title}</h1>
1086
1104
  <p>{site.description}</p>
1087
1105
  </div>
1088
1106
  </header>
1089
1107
  <section className="hero">
1090
1108
  <div className="hero-content">
1091
- <h1>Welcome to {String(theme.siteTitle ?? site.title)}</h1>
1109
+ <h1>Welcome to {site.title}</h1>
1092
1110
  <p className="hero-subtitle">{site.description || 'A modern CMS built with React and TypeScript.'}</p>
1093
1111
  <a href="/blog" className="btn btn-primary">Read the Blog</a>
1094
1112
  </div>
@@ -1112,13 +1130,13 @@ export default function Home({ site, items, settings }: ThemePageData) {
1112
1130
  <article className="post-card" key={String(item.slug)}>
1113
1131
  <div className="post-card__content">
1114
1132
  <div className="post-card__header">
1115
- <time className="post-card__date">{item.publishedAt ? new Date(item.publishedAt).toLocaleDateString() : ''}</time>
1133
+ <time className="post-card__date">{itemDate(item) ? new Date(itemDate(item)!).toLocaleDateString() : ''}</time>
1116
1134
  </div>
1117
1135
  <h2 className="post-card__title">
1118
- <a href={\`/\${String(item.slug)}\`}>{String(item.title ?? '')}</a>
1136
+ <a href={itemUrl(item)}>{String(item.title ?? '')}</a>
1119
1137
  </h2>
1120
1138
  {item.excerpt ? <p className="post-card__excerpt">{String(item.excerpt)}</p> : null}
1121
- <a href={\`/\${String(item.slug)}\`} className="btn btn-outline">Read More</a>
1139
+ <a href={itemUrl(item)} className="btn btn-outline">Read More</a>
1122
1140
  </div>
1123
1141
  </article>
1124
1142
  ))}
@@ -1127,7 +1145,8 @@ export default function Home({ site, items, settings }: ThemePageData) {
1127
1145
  </section>
1128
1146
  </main>
1129
1147
  );
1130
- }`,
1148
+ }
1149
+ `,
1131
1150
  "index.tsx": `import type { ThemePageData } from '@oktis-works/theme-sdk';
1132
1151
 
1133
1152
  export default function Index({ page, content }: ThemePageData) {
@@ -1187,6 +1206,10 @@ export default function Page({ page, content }: ThemePageData) {
1187
1206
  }`,
1188
1207
  "single.tsx": `import type { ThemePageData } from '@oktis-works/theme-sdk';
1189
1208
 
1209
+ function relatedUrl(item: Record<string, unknown>): string {
1210
+ return typeof item.url === 'string' && item.url ? item.url : \`/\${String(item.slug ?? '')}\`;
1211
+ }
1212
+
1190
1213
  export default function Single({ page, content }: ThemePageData) {
1191
1214
  return (
1192
1215
  <article className="site single post-single">
@@ -1201,13 +1224,13 @@ export default function Single({ page, content }: ThemePageData) {
1201
1224
  <footer className="post-footer">
1202
1225
  <nav className="post-nav" aria-label="Post navigation">
1203
1226
  {page.previous && (
1204
- <a href={\`/\${String(page.previous.slug)}\`} className="post-nav__prev">
1227
+ <a href={relatedUrl(page.previous as unknown as Record<string, unknown>)} className="post-nav__prev">
1205
1228
  <span className="post-nav__label">Previous</span>
1206
1229
  <span className="post-nav__title">{String(page.previous.title)}</span>
1207
1230
  </a>
1208
1231
  )}
1209
1232
  {page.next && (
1210
- <a href={\`/\${String(page.next.slug)}\`} className="post-nav__next">
1233
+ <a href={relatedUrl(page.next as unknown as Record<string, unknown>)} className="post-nav__next">
1211
1234
  <span className="post-nav__label">Next</span>
1212
1235
  <span className="post-nav__title">{String(page.next.title)}</span>
1213
1236
  </a>
@@ -1217,7 +1240,41 @@ export default function Single({ page, content }: ThemePageData) {
1217
1240
  </div>
1218
1241
  </article>
1219
1242
  );
1220
- }`,
1243
+ }
1244
+ `,
1245
+ "src/entry-client.tsx": `import { hydrateRoot } from 'react-dom/client';
1246
+ import { readThemeHydrationPayload } from '@oktis-works/theme-sdk';
1247
+ import Home from '../home';
1248
+ import Index from '../index';
1249
+ import Single from '../single';
1250
+ import Page from '../page';
1251
+ import Archive from '../archive';
1252
+ import NotFound from '../404';
1253
+ import type { ThemePageData } from '@oktis-works/theme-sdk';
1254
+
1255
+ const templates: Record<string, (props: ThemePageData) => JSX.Element> = {
1256
+ home: Home,
1257
+ index: Index,
1258
+ single: Single,
1259
+ page: Page,
1260
+ archive: Archive,
1261
+ 404: NotFound,
1262
+ };
1263
+
1264
+ const payload = readThemeHydrationPayload();
1265
+ if (!payload) {
1266
+ throw new Error('Theme hydration payload not found');
1267
+ }
1268
+
1269
+ const { templateKey, data } = payload;
1270
+ const Component = templates[templateKey] ?? templates['404'];
1271
+
1272
+ const root = document.getElementById('root');
1273
+ if (!root) {
1274
+ throw new Error('Root element not found');
1275
+ }
1276
+
1277
+ hydrateRoot(root, <Component {...data} />);`,
1221
1278
  "src/entry-server.tsx": `import Home from '../home';
1222
1279
  import Index from '../index';
1223
1280
  import Single from '../single';
@@ -2302,18 +2359,6 @@ export function render(
2302
2359
  ]
2303
2360
  },
2304
2361
  "settings": [
2305
- {
2306
- "name": "siteTitle",
2307
- "type": "text",
2308
- "label": "Site title",
2309
- "default": "OkCMS"
2310
- },
2311
- {
2312
- "name": "siteDescription",
2313
- "type": "text",
2314
- "label": "Site description",
2315
- "default": ""
2316
- },
2317
2362
  {
2318
2363
  "name": "contactText",
2319
2364
  "type": "textarea",
@@ -1 +1 @@
1
- {"version":3,"file":"theme-assets.js","sourceRoot":"","sources":["../../src/generated/theme-assets.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,6EAA6E;AAC7E,6CAA6C;AAE7C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,SAAS,EAAE;;;;;;;;;EASX;IACA,cAAc,EAAE;;;;;;;CAOjB;IACC,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCf;IACA,gBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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FAAk2F;CACr3F,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,sBAAsB,GAAW,mBAAmB,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;AAEtF,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAW,mBAAmB,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;AAErF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAA2B,MAAM,CAAC,WAAW,CAC7E,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAC9E,CAAC"}
@@ -1,5 +1,14 @@
1
1
  import type { ThemePageData } from '@oktis-works/theme-sdk';
2
2
 
3
+ function itemUrl(item: Record<string, unknown>): string {
4
+ return typeof item.url === 'string' && item.url ? item.url : `/${String(item.slug ?? '')}`;
5
+ }
6
+
7
+ function itemDate(item: Record<string, unknown>): string | undefined {
8
+ const value = item.publishedAt ?? item.published_at;
9
+ return typeof value === 'string' || value instanceof Date ? String(value) : undefined;
10
+ }
11
+
3
12
  export default function Archive({ page, items }: ThemePageData) {
4
13
  return (
5
14
  <main className="site archive">
@@ -16,13 +25,13 @@ export default function Archive({ page, items }: ThemePageData) {
16
25
  <article className="post-card" key={String(item.slug)}>
17
26
  <div className="post-card__content">
18
27
  <div className="post-card__header">
19
- <time className="post-card__date">{item.publishedAt ? new Date(item.publishedAt).toLocaleDateString() : ''}</time>
28
+ <time className="post-card__date">{itemDate(item) ? new Date(itemDate(item)!).toLocaleDateString() : ''}</time>
20
29
  </div>
21
30
  <h2 className="post-card__title">
22
- <a href={`/${String(item.slug)}`}>{String(item.title ?? '')}</a>
31
+ <a href={itemUrl(item)}>{String(item.title ?? '')}</a>
23
32
  </h2>
24
33
  {item.excerpt ? <p className="post-card__excerpt">{String(item.excerpt)}</p> : null}
25
- <a href={`/${String(item.slug)}`} className="btn btn-outline">Read More</a>
34
+ <a href={itemUrl(item)} className="btn btn-outline">Read More</a>
26
35
  </div>
27
36
  </article>
28
37
  ))}
@@ -31,4 +40,4 @@ export default function Archive({ page, items }: ThemePageData) {
31
40
  </div>
32
41
  </main>
33
42
  );
34
- }
43
+ }
@@ -1,18 +1,26 @@
1
1
  import type { ThemePageData } from '@oktis-works/theme-sdk';
2
2
 
3
- export default function Home({ site, items, settings }: ThemePageData) {
4
- const theme = (settings.theme ?? {}) as Record<string, unknown>;
3
+ function itemUrl(item: Record<string, unknown>): string {
4
+ return typeof item.url === 'string' && item.url ? item.url : `/${String(item.slug ?? '')}`;
5
+ }
6
+
7
+ function itemDate(item: Record<string, unknown>): string | undefined {
8
+ const value = item.publishedAt ?? item.published_at;
9
+ return typeof value === 'string' || value instanceof Date ? String(value) : undefined;
10
+ }
11
+
12
+ export default function Home({ site, items }: ThemePageData) {
5
13
  return (
6
14
  <main className="site">
7
15
  <header className="site-header">
8
16
  <div className="container">
9
- <h1>{String(theme.siteTitle ?? site.title)}</h1>
17
+ <h1>{site.title}</h1>
10
18
  <p>{site.description}</p>
11
19
  </div>
12
20
  </header>
13
21
  <section className="hero">
14
22
  <div className="hero-content">
15
- <h1>Welcome to {String(theme.siteTitle ?? site.title)}</h1>
23
+ <h1>Welcome to {site.title}</h1>
16
24
  <p className="hero-subtitle">{site.description || 'A modern CMS built with React and TypeScript.'}</p>
17
25
  <a href="/blog" className="btn btn-primary">Read the Blog</a>
18
26
  </div>
@@ -36,13 +44,13 @@ export default function Home({ site, items, settings }: ThemePageData) {
36
44
  <article className="post-card" key={String(item.slug)}>
37
45
  <div className="post-card__content">
38
46
  <div className="post-card__header">
39
- <time className="post-card__date">{item.publishedAt ? new Date(item.publishedAt).toLocaleDateString() : ''}</time>
47
+ <time className="post-card__date">{itemDate(item) ? new Date(itemDate(item)!).toLocaleDateString() : ''}</time>
40
48
  </div>
41
49
  <h2 className="post-card__title">
42
- <a href={`/${String(item.slug)}`}>{String(item.title ?? '')}</a>
50
+ <a href={itemUrl(item)}>{String(item.title ?? '')}</a>
43
51
  </h2>
44
52
  {item.excerpt ? <p className="post-card__excerpt">{String(item.excerpt)}</p> : null}
45
- <a href={`/${String(item.slug)}`} className="btn btn-outline">Read More</a>
53
+ <a href={itemUrl(item)} className="btn btn-outline">Read More</a>
46
54
  </div>
47
55
  </article>
48
56
  ))}
@@ -51,4 +59,4 @@ export default function Home({ site, items, settings }: ThemePageData) {
51
59
  </section>
52
60
  </main>
53
61
  );
54
- }
62
+ }
@@ -1,5 +1,9 @@
1
1
  import type { ThemePageData } from '@oktis-works/theme-sdk';
2
2
 
3
+ function relatedUrl(item: Record<string, unknown>): string {
4
+ return typeof item.url === 'string' && item.url ? item.url : `/${String(item.slug ?? '')}`;
5
+ }
6
+
3
7
  export default function Single({ page, content }: ThemePageData) {
4
8
  return (
5
9
  <article className="site single post-single">
@@ -14,13 +18,13 @@ export default function Single({ page, content }: ThemePageData) {
14
18
  <footer className="post-footer">
15
19
  <nav className="post-nav" aria-label="Post navigation">
16
20
  {page.previous && (
17
- <a href={`/${String(page.previous.slug)}`} className="post-nav__prev">
21
+ <a href={relatedUrl(page.previous as unknown as Record<string, unknown>)} className="post-nav__prev">
18
22
  <span className="post-nav__label">Previous</span>
19
23
  <span className="post-nav__title">{String(page.previous.title)}</span>
20
24
  </a>
21
25
  )}
22
26
  {page.next && (
23
- <a href={`/${String(page.next.slug)}`} className="post-nav__next">
27
+ <a href={relatedUrl(page.next as unknown as Record<string, unknown>)} className="post-nav__next">
24
28
  <span className="post-nav__label">Next</span>
25
29
  <span className="post-nav__title">{String(page.next.title)}</span>
26
30
  </a>
@@ -30,4 +34,4 @@ export default function Single({ page, content }: ThemePageData) {
30
34
  </div>
31
35
  </article>
32
36
  );
33
- }
37
+ }
@@ -0,0 +1,33 @@
1
+ import { hydrateRoot } from 'react-dom/client';
2
+ import { readThemeHydrationPayload } from '@oktis-works/theme-sdk';
3
+ import Home from '../home';
4
+ import Index from '../index';
5
+ import Single from '../single';
6
+ import Page from '../page';
7
+ import Archive from '../archive';
8
+ import NotFound from '../404';
9
+ import type { ThemePageData } from '@oktis-works/theme-sdk';
10
+
11
+ const templates: Record<string, (props: ThemePageData) => JSX.Element> = {
12
+ home: Home,
13
+ index: Index,
14
+ single: Single,
15
+ page: Page,
16
+ archive: Archive,
17
+ 404: NotFound,
18
+ };
19
+
20
+ const payload = readThemeHydrationPayload();
21
+ if (!payload) {
22
+ throw new Error('Theme hydration payload not found');
23
+ }
24
+
25
+ const { templateKey, data } = payload;
26
+ const Component = templates[templateKey] ?? templates['404'];
27
+
28
+ const root = document.getElementById('root');
29
+ if (!root) {
30
+ throw new Error('Root element not found');
31
+ }
32
+
33
+ hydrateRoot(root, <Component {...data} />);
@@ -36,18 +36,6 @@
36
36
  ]
37
37
  },
38
38
  "settings": [
39
- {
40
- "name": "siteTitle",
41
- "type": "text",
42
- "label": "Site title",
43
- "default": "OkCMS"
44
- },
45
- {
46
- "name": "siteDescription",
47
- "type": "text",
48
- "label": "Site description",
49
- "default": ""
50
- },
51
39
  {
52
40
  "name": "contactText",
53
41
  "type": "textarea",
@@ -19,6 +19,11 @@ ALTER TABLE taxonomy_terms FORCE ROW LEVEL SECURITY;
19
19
  ALTER TABLE content_taxonomy_terms ENABLE ROW LEVEL SECURITY;
20
20
  ALTER TABLE content_taxonomy_terms FORCE ROW LEVEL SECURITY;
21
21
 
22
+ DROP POLICY IF EXISTS tenant_isolation_settings ON settings;
23
+ CREATE POLICY tenant_isolation_settings ON settings
24
+ USING (tenant_id = current_setting('app.current_tenant_id', true)::uuid OR tenant_id IS NULL)
25
+ WITH CHECK (tenant_id = current_setting('app.current_tenant_id', true)::uuid OR tenant_id IS NULL);
26
+
22
27
  DO $$
23
28
  BEGIN
24
29
  IF NOT EXISTS (
@@ -52,3 +57,4 @@ ALTER TABLE taxonomy_terms NO FORCE ROW LEVEL SECURITY;
52
57
  ALTER TABLE content_taxonomy_terms NO FORCE ROW LEVEL SECURITY;
53
58
  DROP POLICY IF EXISTS tenant_isolation_taxonomy_terms ON taxonomy_terms;
54
59
  DROP POLICY IF EXISTS tenant_isolation_content_taxonomy_terms ON content_taxonomy_terms;
60
+ DROP POLICY IF EXISTS tenant_isolation_settings ON settings;
@@ -0,0 +1,25 @@
1
+ -- @okcms domain=tenant_data provider=postgres
2
+ -- +migrate Up
3
+ -- Move the legacy general.timezone key to the canonical reading timezone model.
4
+ UPDATE settings AS legacy
5
+ SET key = 'timezone_string', "group" = 'reading'
6
+ WHERE legacy.key = 'timezone'
7
+ AND legacy."group" = 'general'
8
+ AND NOT EXISTS (
9
+ SELECT 1 FROM settings AS current_setting
10
+ WHERE current_setting.tenant_id IS NOT DISTINCT FROM legacy.tenant_id
11
+ AND current_setting.key = 'timezone_string'
12
+ );
13
+
14
+ DELETE FROM settings
15
+ WHERE key = 'timezone' AND "group" = 'general';
16
+
17
+ -- +migrate Down
18
+ UPDATE settings
19
+ SET key = 'timezone', "group" = 'general'
20
+ WHERE key = 'timezone_string' AND "group" = 'reading'
21
+ AND NOT EXISTS (
22
+ SELECT 1 FROM settings AS legacy
23
+ WHERE legacy.tenant_id IS NOT DISTINCT FROM settings.tenant_id
24
+ AND legacy.key = 'timezone'
25
+ );
@@ -0,0 +1,22 @@
1
+ -- @okcms domain=tenant_data provider=mariadb
2
+ -- +migrate Up
3
+ UPDATE settings AS legacy
4
+ LEFT JOIN settings AS current_setting
5
+ ON ((current_setting.tenant_id = legacy.tenant_id) OR (current_setting.tenant_id IS NULL AND legacy.tenant_id IS NULL))
6
+ AND current_setting.key = 'timezone_string'
7
+ SET legacy.key = 'timezone_string', legacy."group" = 'reading'
8
+ WHERE legacy.key = 'timezone'
9
+ AND legacy."group" = 'general'
10
+ AND current_setting.id IS NULL;
11
+
12
+ DELETE FROM settings WHERE key = 'timezone' AND "group" = 'general';
13
+
14
+ -- +migrate Down
15
+ UPDATE settings AS current_setting
16
+ LEFT JOIN settings AS legacy
17
+ ON ((legacy.tenant_id = current_setting.tenant_id) OR (legacy.tenant_id IS NULL AND current_setting.tenant_id IS NULL))
18
+ AND legacy.key = 'timezone'
19
+ SET current_setting.key = 'timezone', current_setting."group" = 'general'
20
+ WHERE current_setting.key = 'timezone_string'
21
+ AND current_setting."group" = 'reading'
22
+ AND legacy.id IS NULL;
@@ -0,0 +1,22 @@
1
+ -- @okcms domain=tenant_data provider=mysql
2
+ -- +migrate Up
3
+ UPDATE settings AS legacy
4
+ LEFT JOIN settings AS current_setting
5
+ ON ((current_setting.tenant_id = legacy.tenant_id) OR (current_setting.tenant_id IS NULL AND legacy.tenant_id IS NULL))
6
+ AND current_setting.key = 'timezone_string'
7
+ SET legacy.key = 'timezone_string', legacy."group" = 'reading'
8
+ WHERE legacy.key = 'timezone'
9
+ AND legacy."group" = 'general'
10
+ AND current_setting.id IS NULL;
11
+
12
+ DELETE FROM settings WHERE key = 'timezone' AND "group" = 'general';
13
+
14
+ -- +migrate Down
15
+ UPDATE settings AS current_setting
16
+ LEFT JOIN settings AS legacy
17
+ ON ((legacy.tenant_id = current_setting.tenant_id) OR (legacy.tenant_id IS NULL AND current_setting.tenant_id IS NULL))
18
+ AND legacy.key = 'timezone'
19
+ SET current_setting.key = 'timezone', current_setting."group" = 'general'
20
+ WHERE current_setting.key = 'timezone_string'
21
+ AND current_setting."group" = 'reading'
22
+ AND legacy.id IS NULL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oktis-works/cms",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@clack/prompts": "1.8.1",
26
- "@oktis-works/auth": "^0.9.5",
27
- "@oktis-works/config": "^1.0.0",
28
- "@oktis-works/core": "^1.0.0",
29
- "@oktis-works/database": "^0.16.6",
30
- "@oktis-works/theme-runtime": "^1.0.0",
31
- "@oktis-works/theme-builder": "^1.0.0",
32
- "@oktis-works/validation": "^1.0.0",
26
+ "@oktis-works/auth": "^0.9.6",
27
+ "@oktis-works/config": "^1.0.1",
28
+ "@oktis-works/core": "^1.0.2",
29
+ "@oktis-works/database": "^0.16.8",
30
+ "@oktis-works/theme-runtime": "^1.0.1",
31
+ "@oktis-works/theme-builder": "^1.0.1",
32
+ "@oktis-works/validation": "^1.0.1",
33
33
  "mysql2": "^3.14.1"
34
34
  },
35
35
  "devDependencies": {