@capybara-hq/kernel 0.1.0-rc.53 → 0.1.0-rc.54
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.
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +29 -0
- package/dist/db/kernel-schema.d.ts +10 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +19 -0
- package/dist/http/api.module.js +8 -0
- package/dist/http/app.js +9 -0
- package/dist/http/meta.controller.d.ts +33 -0
- package/dist/http/meta.controller.js +72 -0
- package/dist/identity/app-auth.controller.d.ts +25 -0
- package/dist/identity/app-auth.controller.js +64 -0
- package/dist/identity/app-auth.d.ts +66 -0
- package/dist/identity/app-auth.js +203 -0
- package/dist/identity/app-auth.schemas.d.ts +47 -0
- package/dist/identity/app-auth.schemas.js +43 -0
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -1
- package/dist/infra/config/kernel-config.service.js +2 -0
- package/dist/infra/outbox/registry.d.ts +14 -0
- package/dist/infra/outbox/registry.js +15 -0
- package/dist/infra/throttler/named-throttlers.d.ts +3 -2
- package/dist/infra/throttler/named-throttlers.js +14 -2
- package/dist/platform/exclusions.js +23 -0
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/platform-icons.ops.d.ts +14 -0
- package/dist/platform/ops/platform-icons.ops.js +117 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +3 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/runtime/maintenance.d.ts +5 -2
- package/dist/runtime/maintenance.js +15 -4
- package/dist/themes/platform-icon-objects.d.ts +51 -0
- package/dist/themes/platform-icon-objects.js +113 -0
- package/dist/themes/platform-icon-public.controller.d.ts +17 -0
- package/dist/themes/platform-icon-public.controller.js +58 -0
- package/dist/themes/platform-icon.controller.d.ts +22 -0
- package/dist/themes/platform-icon.controller.js +65 -0
- package/dist/themes/platform-icon.schemas.d.ts +48 -0
- package/dist/themes/platform-icon.schemas.js +53 -0
- package/dist/themes/platform-icon.service.d.ts +83 -0
- package/dist/themes/platform-icon.service.js +301 -0
- package/dist/themes/themes.module.d.ts +4 -1
- package/dist/themes/themes.module.js +9 -4
- package/package.json +3 -3
- package/src/migrations/0164_platform_icons.sql +10 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import { crc32 } from "node:zlib";
|
|
12
|
+
import { sanitizeThemeSvg, THEME_LIMITS } from "@capybara-hq/plugin-sdk";
|
|
13
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
14
|
+
import { ApiError } from "../errors.js";
|
|
15
|
+
import { audit } from "../identity/audit.js";
|
|
16
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
17
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
18
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
19
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
|
+
import { LockService } from "../infra/lock/lock.service.js";
|
|
21
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
22
|
+
import { isStorageUnavailable, StorageService } from "../storage/storage.service.js";
|
|
23
|
+
import { PLATFORM_ICON_MAX_BYTES, PLATFORM_ICON_PNG_SIZE, } from "./platform-icon.schemas.js";
|
|
24
|
+
import { owePlatformIconDelete, PLATFORM_ICON_LOCK, platformIconKey, platformIconLockKey, } from "./platform-icon-objects.js";
|
|
25
|
+
/** The type each purpose is stored and served as (fixed by the purpose, never by the upload). */
|
|
26
|
+
const CONTENT_TYPE = {
|
|
27
|
+
app: "image/png",
|
|
28
|
+
maskable: "image/png",
|
|
29
|
+
favicon: "image/svg+xml",
|
|
30
|
+
};
|
|
31
|
+
const PNG_SIG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
32
|
+
const IHDR = [0x49, 0x48, 0x44, 0x52];
|
|
33
|
+
/** The IEND chunk every complete PNG ends with: length 0, type, CRC-32. */
|
|
34
|
+
const IEND = [0, 0, 0, 0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82];
|
|
35
|
+
/** The largest SVG favicon: the theme logo sanitizer's limit (128 KiB). */
|
|
36
|
+
const SVG_MAX_BYTES = THEME_LIMITS.svgBytes;
|
|
37
|
+
/** The public URL of an icon: the hash in `v` changes on upload, so it is cached as immutable. */
|
|
38
|
+
export const platformIconUrl = (purpose, sha256) => `/api/v1/platform/icon/${purpose}?v=${sha256}`;
|
|
39
|
+
/**
|
|
40
|
+
* Checks an upload (nothing is rendered or resized): at most 1 MiB; `app` and `maskable` a PNG
|
|
41
|
+
* (signature, an `IHDR` first chunk with a valid CRC-32, ending with `IEND`) of exactly 512 × 512;
|
|
42
|
+
* `favicon` an SVG of at most 128 KiB, parsed with the theme
|
|
43
|
+
* logo sanitizer (a strict XML parser, an `<svg>` root in the SVG namespace with a viewBox, no
|
|
44
|
+
* script, style element, event handler or external reference) and stored as its sanitized output.
|
|
45
|
+
* Throws the refusal as `platform_icon.*`.
|
|
46
|
+
*/
|
|
47
|
+
export function checkPlatformIcon(purpose, declared, dataBase64) {
|
|
48
|
+
const data = Buffer.from(dataBase64, "base64");
|
|
49
|
+
if (data.byteLength > PLATFORM_ICON_MAX_BYTES) {
|
|
50
|
+
throw new ApiError("platform_icon.too_large", `The icon is ${data.byteLength} bytes; an icon file is at most 1 MiB (${PLATFORM_ICON_MAX_BYTES} bytes)`);
|
|
51
|
+
}
|
|
52
|
+
const expected = CONTENT_TYPE[purpose];
|
|
53
|
+
if (declared !== expected) {
|
|
54
|
+
throw new ApiError("platform_icon.invalid_type", purpose === "favicon"
|
|
55
|
+
? "The favicon must be an SVG (image/svg+xml)"
|
|
56
|
+
: `The ${purpose} icon must be a PNG (image/png) of ${PLATFORM_ICON_PNG_SIZE} × ${PLATFORM_ICON_PNG_SIZE} pixels; an SVG is accepted only as the favicon`);
|
|
57
|
+
}
|
|
58
|
+
let bytes = data;
|
|
59
|
+
if (expected === "image/png") {
|
|
60
|
+
checkPng(purpose, data);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (data.byteLength > SVG_MAX_BYTES) {
|
|
64
|
+
throw new ApiError("platform_icon.too_large", `The favicon is ${data.byteLength} bytes; an SVG favicon is at most 128 KiB (${SVG_MAX_BYTES} bytes)`);
|
|
65
|
+
}
|
|
66
|
+
const r = sanitizeThemeSvg(data);
|
|
67
|
+
if ("error" in r) {
|
|
68
|
+
throw new ApiError("platform_icon.invalid_type", `The favicon is not a usable SVG: ${r.error}`);
|
|
69
|
+
}
|
|
70
|
+
bytes = new TextEncoder().encode(r.svg);
|
|
71
|
+
}
|
|
72
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
73
|
+
return { purpose, contentType: expected, bytes, sha256 };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A PNG of exactly 512 × 512 by its signature, its `IHDR` first chunk (with a valid CRC-32) and
|
|
77
|
+
* its width and height, ending with the `IEND` chunk; throws the refusal.
|
|
78
|
+
*/
|
|
79
|
+
function checkPng(purpose, data) {
|
|
80
|
+
const isPng = data.byteLength >= 33 &&
|
|
81
|
+
PNG_SIG.every((b, i) => data[i] === b) &&
|
|
82
|
+
data.readUInt32BE(8) === 13 &&
|
|
83
|
+
IHDR.every((b, i) => data[12 + i] === b);
|
|
84
|
+
if (!isPng) {
|
|
85
|
+
throw new ApiError("platform_icon.invalid_type", `The ${purpose} icon is not a PNG file (no PNG signature and IHDR header); upload a ${PLATFORM_ICON_PNG_SIZE} × ${PLATFORM_ICON_PNG_SIZE} PNG`);
|
|
86
|
+
}
|
|
87
|
+
// the IHDR CRC covers its type and data (bytes 12..28); a complete PNG ends with IEND
|
|
88
|
+
const ihdrIntact = crc32(data.subarray(12, 29)) === data.readUInt32BE(29);
|
|
89
|
+
const ended = data.byteLength >= 33 + IEND.length &&
|
|
90
|
+
IEND.every((b, i) => data[data.byteLength - IEND.length + i] === b);
|
|
91
|
+
if (!ihdrIntact || !ended) {
|
|
92
|
+
throw new ApiError("platform_icon.invalid_type", `The ${purpose} PNG is truncated or damaged (no intact IHDR chunk or no IEND chunk at the end); export it again as a ${PLATFORM_ICON_PNG_SIZE} × ${PLATFORM_ICON_PNG_SIZE} PNG`);
|
|
93
|
+
}
|
|
94
|
+
const width = data.readUInt32BE(16);
|
|
95
|
+
const height = data.readUInt32BE(20);
|
|
96
|
+
if (width !== PLATFORM_ICON_PNG_SIZE || height !== PLATFORM_ICON_PNG_SIZE) {
|
|
97
|
+
throw new ApiError("platform_icon.invalid_size", `The ${purpose} icon is ${width} × ${height} pixels; it must be exactly ${PLATFORM_ICON_PNG_SIZE} × ${PLATFORM_ICON_PNG_SIZE}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const storageUnavailable = () => new ApiError("platform_icon.storage_unavailable", "Object storage is not available in this deployment, so the platform icon cannot be stored or served; install and configure an object-store plugin");
|
|
101
|
+
/**
|
|
102
|
+
* The platform icon setting (mobile layout spec §10.2.1): the super admin's uploads (the app icon,
|
|
103
|
+
* its maskable variant, the SVG favicon), stored in object storage under the kernel's
|
|
104
|
+
* `deployment/` prefix with a row per purpose in `capybara.platform_icons`; the public read the
|
|
105
|
+
* manifest, favicons and native clients use. Writes are audited (`platform.icon.updated`,
|
|
106
|
+
* `platform.icon.cleared`) and serialized per purpose (see `platform-icon-objects.ts`).
|
|
107
|
+
*/
|
|
108
|
+
let PlatformIconService = class PlatformIconService {
|
|
109
|
+
db;
|
|
110
|
+
txHost;
|
|
111
|
+
outbox;
|
|
112
|
+
adminLock;
|
|
113
|
+
locks;
|
|
114
|
+
storage;
|
|
115
|
+
constructor(db, txHost, outbox, adminLock, locks, storage) {
|
|
116
|
+
this.db = db;
|
|
117
|
+
this.txHost = txHost;
|
|
118
|
+
this.outbox = outbox;
|
|
119
|
+
this.adminLock = adminLock;
|
|
120
|
+
this.locks = locks;
|
|
121
|
+
this.storage = storage;
|
|
122
|
+
}
|
|
123
|
+
/** Every uploaded icon, in purpose order (`app`, `maskable`, `favicon`). */
|
|
124
|
+
async list() {
|
|
125
|
+
const rows = await this.db
|
|
126
|
+
.selectFrom("platform_icons")
|
|
127
|
+
.select(["purpose", "sha256", "updated_at"])
|
|
128
|
+
.execute();
|
|
129
|
+
const order = ["app", "maskable", "favicon"];
|
|
130
|
+
rows.sort((a, b) => order.indexOf(a.purpose) - order.indexOf(b.purpose));
|
|
131
|
+
return { icons: rows.map((r) => viewOf(r.purpose, r.sha256, r.updated_at)) };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The icon of a purpose now, `{ purpose, sha256, url }`, or null when the default is in use:
|
|
135
|
+
* what other features (the meta document, the manifest) build the icon URL from.
|
|
136
|
+
*/
|
|
137
|
+
async current(purpose) {
|
|
138
|
+
const row = await this.db
|
|
139
|
+
.selectFrom("platform_icons")
|
|
140
|
+
.select("sha256")
|
|
141
|
+
.where("purpose", "=", purpose)
|
|
142
|
+
.executeTakeFirst();
|
|
143
|
+
return row ? { purpose, sha256: row.sha256, url: platformIconUrl(purpose, row.sha256) } : null;
|
|
144
|
+
}
|
|
145
|
+
/** The upload's checks alone (the Platform operation's precheck); throws the write's refusal. */
|
|
146
|
+
async check(purpose, contentType, dataBase64) {
|
|
147
|
+
checkPlatformIcon(purpose, contentType, dataBase64);
|
|
148
|
+
if (!this.storage.available)
|
|
149
|
+
throw storageUnavailable();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Sets the icon of a purpose. Under the purpose's lock: first the orphan check of the new object
|
|
153
|
+
* is owed (a committed intent), then the object is written, then the row in a transaction that
|
|
154
|
+
* also owes the deletion of the object the row named before (none when the bytes are the same).
|
|
155
|
+
*/
|
|
156
|
+
async set(purpose, contentType, dataBase64, actor, auditDetail = {}) {
|
|
157
|
+
const file = checkPlatformIcon(purpose, contentType, dataBase64);
|
|
158
|
+
if (!this.storage.available)
|
|
159
|
+
throw storageUnavailable();
|
|
160
|
+
return this.locks.run(platformIconLockKey(purpose), PLATFORM_ICON_LOCK, async () => {
|
|
161
|
+
await this.oweOrphanCheck(file, actor);
|
|
162
|
+
try {
|
|
163
|
+
await this.storage.deployment().put(platformIconKey(purpose, file.sha256), file.bytes, {
|
|
164
|
+
contentType: file.contentType,
|
|
165
|
+
size: file.bytes.byteLength,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
if (isStorageUnavailable(e))
|
|
170
|
+
throw storageUnavailable();
|
|
171
|
+
throw e;
|
|
172
|
+
}
|
|
173
|
+
return this.commit(file, actor, auditDetail);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** The intent: the new object's delayed orphan check, owed before the object is written. */
|
|
177
|
+
async oweOrphanCheck(file, actor) {
|
|
178
|
+
await this.adminLock.lockAndAuthorize(actor.accountId);
|
|
179
|
+
await owePlatformIconDelete(this.outbox, file.purpose, file.sha256, { orphanCheck: true });
|
|
180
|
+
}
|
|
181
|
+
/** The row naming the written object, the old object's deletion and the audit event. */
|
|
182
|
+
async commit(file, actor, auditDetail) {
|
|
183
|
+
await this.adminLock.lockAndAuthorize(actor.accountId);
|
|
184
|
+
const old = await this.db
|
|
185
|
+
.selectFrom("platform_icons")
|
|
186
|
+
.select("sha256")
|
|
187
|
+
.where("purpose", "=", file.purpose)
|
|
188
|
+
.forUpdate()
|
|
189
|
+
.executeTakeFirst();
|
|
190
|
+
const objectKey = platformIconKey(file.purpose, file.sha256);
|
|
191
|
+
const row = await this.db
|
|
192
|
+
.insertInto("platform_icons")
|
|
193
|
+
.values({
|
|
194
|
+
purpose: file.purpose,
|
|
195
|
+
object_key: objectKey,
|
|
196
|
+
sha256: file.sha256,
|
|
197
|
+
content_type: file.contentType,
|
|
198
|
+
})
|
|
199
|
+
.onConflict((oc) => oc.column("purpose").doUpdateSet({
|
|
200
|
+
object_key: objectKey,
|
|
201
|
+
sha256: file.sha256,
|
|
202
|
+
content_type: file.contentType,
|
|
203
|
+
updated_at: new Date(),
|
|
204
|
+
}))
|
|
205
|
+
.returning(["updated_at"])
|
|
206
|
+
.executeTakeFirstOrThrow();
|
|
207
|
+
if (old && old.sha256 !== file.sha256) {
|
|
208
|
+
await owePlatformIconDelete(this.outbox, file.purpose, old.sha256);
|
|
209
|
+
}
|
|
210
|
+
await audit(this.db.db, {
|
|
211
|
+
actorAccountId: actor.accountId,
|
|
212
|
+
...(actor.tokenId !== undefined && { actorTokenId: actor.tokenId }),
|
|
213
|
+
action: "platform.icon.updated",
|
|
214
|
+
target: file.purpose,
|
|
215
|
+
detail: { purpose: file.purpose, sha256: file.sha256, ...auditDetail },
|
|
216
|
+
});
|
|
217
|
+
return viewOf(file.purpose, file.sha256, row.updated_at);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Restores the default of a purpose: the row goes and its object's deletion is owed. Clearing a
|
|
221
|
+
* purpose with no upload changes nothing; returns whether a row was removed.
|
|
222
|
+
*/
|
|
223
|
+
async clear(purpose, actor, auditDetail = {}) {
|
|
224
|
+
return this.locks.run(platformIconLockKey(purpose), PLATFORM_ICON_LOCK, () => this.remove(purpose, actor, auditDetail));
|
|
225
|
+
}
|
|
226
|
+
async remove(purpose, actor, auditDetail) {
|
|
227
|
+
await this.adminLock.lockAndAuthorize(actor.accountId);
|
|
228
|
+
const gone = await this.db
|
|
229
|
+
.deleteFrom("platform_icons")
|
|
230
|
+
.where("purpose", "=", purpose)
|
|
231
|
+
.returning("sha256")
|
|
232
|
+
.executeTakeFirst();
|
|
233
|
+
if (!gone)
|
|
234
|
+
return false;
|
|
235
|
+
await owePlatformIconDelete(this.outbox, purpose, gone.sha256);
|
|
236
|
+
await audit(this.db.db, {
|
|
237
|
+
actorAccountId: actor.accountId,
|
|
238
|
+
...(actor.tokenId !== undefined && { actorTokenId: actor.tokenId }),
|
|
239
|
+
action: "platform.icon.cleared",
|
|
240
|
+
target: purpose,
|
|
241
|
+
detail: { purpose, sha256: gone.sha256, ...auditDetail },
|
|
242
|
+
});
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The stored bytes of a purpose for the public route, or `platform_icon.not_found` when the
|
|
247
|
+
* default is in use, `v` names another upload, or the object is missing. `immutable` is true
|
|
248
|
+
* when `v` is the current hash (the URL then never changes meaning).
|
|
249
|
+
*/
|
|
250
|
+
async read(purpose, v) {
|
|
251
|
+
const row = await this.db
|
|
252
|
+
.selectFrom("platform_icons")
|
|
253
|
+
.select(["object_key", "sha256"])
|
|
254
|
+
.where("purpose", "=", purpose)
|
|
255
|
+
.executeTakeFirst();
|
|
256
|
+
const notFound = () => new ApiError("platform_icon.not_found", v === undefined || row === undefined
|
|
257
|
+
? `No ${purpose} icon is uploaded; the built-in Capybara icon applies`
|
|
258
|
+
: `The ${purpose} icon was replaced; read the current URL from the platform icon settings`);
|
|
259
|
+
if (!row || (v !== undefined && v !== row.sha256))
|
|
260
|
+
throw notFound();
|
|
261
|
+
let obj;
|
|
262
|
+
try {
|
|
263
|
+
obj = await this.storage.deployment().get(row.object_key);
|
|
264
|
+
}
|
|
265
|
+
catch (e) {
|
|
266
|
+
if (isStorageUnavailable(e))
|
|
267
|
+
throw storageUnavailable();
|
|
268
|
+
throw e;
|
|
269
|
+
}
|
|
270
|
+
if (!obj)
|
|
271
|
+
throw notFound();
|
|
272
|
+
const bytes = new Uint8Array(await new Response(obj.body).arrayBuffer());
|
|
273
|
+
// the type is the purpose's, never the store's metadata
|
|
274
|
+
return { contentType: CONTENT_TYPE[purpose], bytes, immutable: v !== undefined };
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
__decorate([
|
|
278
|
+
Transactional()
|
|
279
|
+
], PlatformIconService.prototype, "oweOrphanCheck", null);
|
|
280
|
+
__decorate([
|
|
281
|
+
Transactional()
|
|
282
|
+
], PlatformIconService.prototype, "commit", null);
|
|
283
|
+
__decorate([
|
|
284
|
+
Transactional()
|
|
285
|
+
], PlatformIconService.prototype, "remove", null);
|
|
286
|
+
PlatformIconService = __decorate([
|
|
287
|
+
Injectable(),
|
|
288
|
+
__param(0, Inject(KernelDb)),
|
|
289
|
+
__param(1, Inject(TransactionHost)),
|
|
290
|
+
__param(2, Inject(OutboxService)),
|
|
291
|
+
__param(3, Inject(SuperAdminLock)),
|
|
292
|
+
__param(4, Inject(LockService)),
|
|
293
|
+
__param(5, Inject(StorageService))
|
|
294
|
+
], PlatformIconService);
|
|
295
|
+
export { PlatformIconService };
|
|
296
|
+
const viewOf = (purpose, sha256, at) => ({
|
|
297
|
+
purpose,
|
|
298
|
+
url: platformIconUrl(purpose, sha256),
|
|
299
|
+
sha256,
|
|
300
|
+
updatedAt: at.toISOString(),
|
|
301
|
+
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Themes (themes spec §7-§9): resolution, the org's theme listing and delivery; and the platform
|
|
3
|
+
* icon setting (mobile layout spec §10.2.1).
|
|
4
|
+
*/
|
|
2
5
|
export declare class ThemesModule {
|
|
3
6
|
}
|
|
@@ -5,17 +5,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
|
+
import { SuperAdminLockModule } from "../identity/super-admin.js";
|
|
8
9
|
import { StorageModule } from "../storage/storage.module.js";
|
|
10
|
+
import { PlatformIconService } from "./platform-icon.service.js";
|
|
9
11
|
import { ThemeDeliveryService } from "./theme-delivery.service.js";
|
|
10
12
|
import { ThemesService } from "./themes.service.js";
|
|
11
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Themes (themes spec §7-§9): resolution, the org's theme listing and delivery; and the platform
|
|
15
|
+
* icon setting (mobile layout spec §10.2.1).
|
|
16
|
+
*/
|
|
12
17
|
let ThemesModule = class ThemesModule {
|
|
13
18
|
};
|
|
14
19
|
ThemesModule = __decorate([
|
|
15
20
|
Module({
|
|
16
|
-
imports: [StorageModule],
|
|
17
|
-
providers: [ThemesService, ThemeDeliveryService],
|
|
18
|
-
exports: [ThemesService, ThemeDeliveryService],
|
|
21
|
+
imports: [StorageModule, SuperAdminLockModule],
|
|
22
|
+
providers: [ThemesService, ThemeDeliveryService, PlatformIconService],
|
|
23
|
+
exports: [ThemesService, ThemeDeliveryService, PlatformIconService],
|
|
19
24
|
})
|
|
20
25
|
], ThemesModule);
|
|
21
26
|
export { ThemesModule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.54",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.38"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
78
|
"@capybara-hq/testing": "0.1.0-rc.28",
|
|
79
|
-
"@capybara-hq/device": "0.1.0-rc.
|
|
79
|
+
"@capybara-hq/device": "0.1.0-rc.18"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "tsc -b"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- The platform icon setting (mobile layout spec §10.2.1): one row per uploaded purpose (the app
|
|
2
|
+
-- icon, its maskable variant, the SVG favicon), naming its object under the kernel's deployment/
|
|
3
|
+
-- prefix and the SHA-256 the public URL carries. No row: the web's built-in Capybara icon.
|
|
4
|
+
CREATE TABLE IF NOT EXISTS capybara.platform_icons (
|
|
5
|
+
purpose text PRIMARY KEY CHECK (purpose IN ('app', 'maskable', 'favicon')),
|
|
6
|
+
object_key text NOT NULL,
|
|
7
|
+
sha256 text NOT NULL,
|
|
8
|
+
content_type text NOT NULL,
|
|
9
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
10
|
+
);
|