@plume-press/cli 0.5.0 → 0.6.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.
- package/README.md +1 -1
- package/dist/cli.mjs +181 -445
- package/dist/local.mjs +7 -37
- package/dist/schema.d.ts +1 -7
- package/dist/schema.mjs +6 -19
- package/package.json +1 -1
package/dist/local.mjs
CHANGED
|
@@ -33315,13 +33315,6 @@ function named(value, path) {
|
|
|
33315
33315
|
);
|
|
33316
33316
|
}
|
|
33317
33317
|
function defineSchema(schema2) {
|
|
33318
|
-
return checkSchema(schema2);
|
|
33319
|
-
}
|
|
33320
|
-
function readStoredSchema(schema2, ignored = () => {
|
|
33321
|
-
}) {
|
|
33322
|
-
return checkSchema(schema2, ignored);
|
|
33323
|
-
}
|
|
33324
|
-
function checkSchema(schema2, ignoredPreviewPath) {
|
|
33325
33318
|
canonicalJson(schema2);
|
|
33326
33319
|
assert2(object2(schema2), "expected object");
|
|
33327
33320
|
allowedKeys(schema2, ["collections", "singletons"], "schema");
|
|
@@ -33455,16 +33448,11 @@ function checkSchema(schema2, ignoredPreviewPath) {
|
|
|
33455
33448
|
entities.add(entityName);
|
|
33456
33449
|
validateFields2(entity2.fields, entityName, false);
|
|
33457
33450
|
if ("previewPath" in entity2)
|
|
33458
|
-
|
|
33459
|
-
|
|
33460
|
-
|
|
33461
|
-
|
|
33462
|
-
|
|
33463
|
-
);
|
|
33464
|
-
} catch (error62) {
|
|
33465
|
-
if (!ignoredPreviewPath) throw error62;
|
|
33466
|
-
ignoredPreviewPath(error62.message);
|
|
33467
|
-
}
|
|
33451
|
+
validatePreviewPath(
|
|
33452
|
+
entityName,
|
|
33453
|
+
entity2.previewPath,
|
|
33454
|
+
isCollection ? entity2.fields : null
|
|
33455
|
+
);
|
|
33468
33456
|
}
|
|
33469
33457
|
return schema2;
|
|
33470
33458
|
}
|
|
@@ -33502,7 +33490,7 @@ function validatePreviewPath(entity2, path, fields) {
|
|
|
33502
33490
|
);
|
|
33503
33491
|
}
|
|
33504
33492
|
async function schemaHash(schema2) {
|
|
33505
|
-
|
|
33493
|
+
defineSchema(schema2);
|
|
33506
33494
|
const bytes2 = new TextEncoder().encode(
|
|
33507
33495
|
canonicalJson(schema2)
|
|
33508
33496
|
);
|
|
@@ -34222,23 +34210,6 @@ async function safePath(cwd, create2) {
|
|
|
34222
34210
|
);
|
|
34223
34211
|
return path;
|
|
34224
34212
|
}
|
|
34225
|
-
function addTimestamps(db) {
|
|
34226
|
-
const missing = () => !db.prepare("PRAGMA table_info(local_records)").all().some((column) => column.name === "created_at");
|
|
34227
|
-
if (!missing() && !db.prepare(
|
|
34228
|
-
"SELECT 1 FROM local_records WHERE created_at IS NULL OR updated_at IS NULL LIMIT 1"
|
|
34229
|
-
).get())
|
|
34230
|
-
return;
|
|
34231
|
-
transaction(db, () => {
|
|
34232
|
-
if (missing()) {
|
|
34233
|
-
db.exec("ALTER TABLE local_records ADD COLUMN created_at INTEGER");
|
|
34234
|
-
db.exec("ALTER TABLE local_records ADD COLUMN updated_at INTEGER");
|
|
34235
|
-
}
|
|
34236
|
-
const now = Date.now();
|
|
34237
|
-
db.prepare(
|
|
34238
|
-
"UPDATE local_records SET created_at = coalesce(created_at, ?), updated_at = coalesce(updated_at, created_at, ?) WHERE created_at IS NULL OR updated_at IS NULL"
|
|
34239
|
-
).run(now, now);
|
|
34240
|
-
});
|
|
34241
|
-
}
|
|
34242
34213
|
function meta3(db) {
|
|
34243
34214
|
return db.prepare("SELECT schema, revision FROM local_meta WHERE id = 1").get();
|
|
34244
34215
|
}
|
|
@@ -34444,7 +34415,6 @@ async function open2(path, expected) {
|
|
|
34444
34415
|
db.exec("PRAGMA busy_timeout = 5000");
|
|
34445
34416
|
const stored = meta3(db);
|
|
34446
34417
|
if (!stored) throw new Error("Local content database is not initialized.");
|
|
34447
|
-
addTimestamps(db);
|
|
34448
34418
|
let schema2 = defineSchema(JSON.parse(stored.schema));
|
|
34449
34419
|
if (expected && canonicalJson(schema2) !== canonicalJson(expected))
|
|
34450
34420
|
throw new Error(
|
|
@@ -34633,7 +34603,7 @@ async function openLocalStore(input2) {
|
|
|
34633
34603
|
"CREATE TABLE local_meta (id INTEGER PRIMARY KEY CHECK(id = 1), schema TEXT NOT NULL, revision INTEGER NOT NULL)"
|
|
34634
34604
|
);
|
|
34635
34605
|
db.exec(
|
|
34636
|
-
"CREATE TABLE local_records (collection TEXT NOT NULL, record_id TEXT NOT NULL, data TEXT NOT NULL, visibility TEXT NOT NULL CHECK(visibility IN ('draft', 'public')), created_at INTEGER, updated_at INTEGER, PRIMARY KEY(collection, record_id))"
|
|
34606
|
+
"CREATE TABLE local_records (collection TEXT NOT NULL, record_id TEXT NOT NULL, data TEXT NOT NULL, visibility TEXT NOT NULL CHECK(visibility IN ('draft', 'public')), created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, PRIMARY KEY(collection, record_id))"
|
|
34637
34607
|
);
|
|
34638
34608
|
db.prepare(
|
|
34639
34609
|
"INSERT INTO local_meta (id, schema, revision) VALUES (1, ?, 0)"
|
package/dist/schema.d.ts
CHANGED
|
@@ -187,11 +187,6 @@ export type FieldIssue = {
|
|
|
187
187
|
export declare function canonicalJson(value: JsonValue): string;
|
|
188
188
|
/** Schema configuration is data only. Executable validators/transforms are unsupported. */
|
|
189
189
|
export declare function defineSchema<const S extends SchemaDefinition>(schema: S): S;
|
|
190
|
-
/** A schema stored with content, which an older Plume accepted: checked like
|
|
191
|
-
* `defineSchema`, except that a `previewPath` this version's grammar rejects is reported
|
|
192
|
-
* to `ignored` and left inert (`resolvePreviewPath` gives it no path), so that content
|
|
193
|
-
* stays readable. Defining or registering a schema stays strict. */
|
|
194
|
-
export declare function readStoredSchema(schema: unknown, ignored?: (problem: string) => void): SchemaDefinition;
|
|
195
190
|
/** A path on the Site's own website: one leading `/`, no backslash, whitespace or control
|
|
196
191
|
* character, at most 2048 characters, and still a path of the same site once a URL parser
|
|
197
192
|
* normalises it (`/./`, `..`), so no browser or parser reads it as another host. */
|
|
@@ -201,8 +196,7 @@ export declare function isLocalPath(path: unknown): path is string;
|
|
|
201
196
|
* Item ID (even when a Field is named `id`), `{<field>}` that text or slug Field's value,
|
|
202
197
|
* each trimmed and URL-encoded. The result is always an `isLocalPath`. */
|
|
203
198
|
export declare function resolvePreviewPath(entity: Collection | Singleton, recordId: string, data: JsonValue | undefined): string | null;
|
|
204
|
-
/** Hashes a schema
|
|
205
|
-
* block its identity (see `readStoredSchema`). */
|
|
199
|
+
/** Hashes a valid schema using its canonical JSON representation. */
|
|
206
200
|
export declare function schemaHash(schema: SchemaDefinition): Promise<string>;
|
|
207
201
|
/** Validates shape only; richText HTML requires sanitization at the write/render boundary.
|
|
208
202
|
* Slug uniqueness, reference targets and media `accept` need the whole content and are
|
package/dist/schema.mjs
CHANGED
|
@@ -83,13 +83,6 @@ function named(value, path) {
|
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
function defineSchema(schema) {
|
|
86
|
-
return checkSchema(schema);
|
|
87
|
-
}
|
|
88
|
-
function readStoredSchema(schema, ignored = () => {
|
|
89
|
-
}) {
|
|
90
|
-
return checkSchema(schema, ignored);
|
|
91
|
-
}
|
|
92
|
-
function checkSchema(schema, ignoredPreviewPath) {
|
|
93
86
|
canonicalJson(schema);
|
|
94
87
|
assert(object(schema), "expected object");
|
|
95
88
|
allowedKeys(schema, ["collections", "singletons"], "schema");
|
|
@@ -223,16 +216,11 @@ function checkSchema(schema, ignoredPreviewPath) {
|
|
|
223
216
|
entities.add(entityName);
|
|
224
217
|
validateFields2(entity.fields, entityName, false);
|
|
225
218
|
if ("previewPath" in entity)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
);
|
|
232
|
-
} catch (error) {
|
|
233
|
-
if (!ignoredPreviewPath) throw error;
|
|
234
|
-
ignoredPreviewPath(error.message);
|
|
235
|
-
}
|
|
219
|
+
validatePreviewPath(
|
|
220
|
+
entityName,
|
|
221
|
+
entity.previewPath,
|
|
222
|
+
isCollection ? entity.fields : null
|
|
223
|
+
);
|
|
236
224
|
}
|
|
237
225
|
return schema;
|
|
238
226
|
}
|
|
@@ -296,7 +284,7 @@ function resolvePreviewPath(entity, recordId, data) {
|
|
|
296
284
|
return !missing && isLocalPath(path) ? path : null;
|
|
297
285
|
}
|
|
298
286
|
async function schemaHash(schema) {
|
|
299
|
-
|
|
287
|
+
defineSchema(schema);
|
|
300
288
|
const bytes = new TextEncoder().encode(
|
|
301
289
|
canonicalJson(schema)
|
|
302
290
|
);
|
|
@@ -574,7 +562,6 @@ export {
|
|
|
574
562
|
dropMissingReferences,
|
|
575
563
|
isLocalPath,
|
|
576
564
|
mediaAccepted,
|
|
577
|
-
readStoredSchema,
|
|
578
565
|
referenceIds,
|
|
579
566
|
resolvePreviewPath,
|
|
580
567
|
schemaHash,
|