alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
102 lines (99 loc) • 2.59 kB
JavaScript
import {
ExprData,
column,
table
} from "../chunks/chunk-4JLFL6LD.js";
import "../chunks/chunk-U5RRZUYZ.js";
// node_modules/rado/dist/define/Index.js
var Index = class _Index {
constructor(data) {
this.data = data;
}
unique() {
return new _Index({ ...this.data, unique: true });
}
where(where) {
return new _Index({ ...this.data, where: ExprData.create(where) });
}
};
function index(...on) {
return new Index({ on: on.map(ExprData.create) });
}
// src/core/EntryRow.ts
import { createId } from "./Id.js";
var EntryPhase = /* @__PURE__ */ ((EntryPhase2) => {
EntryPhase2["Draft"] = "draft";
EntryPhase2["Published"] = "published";
EntryPhase2["Archived"] = "archived";
return EntryPhase2;
})(EntryPhase || {});
var ALT_STATUS = [
"draft" /* Draft */,
"archived" /* Archived */
];
var EntryTable = class {
// Entry data
entryId = column.string.default(createId);
phase = column.string();
title = column.string;
type = column.string;
seeded = column.boolean.default(false);
// Hierarchy
workspace = column.string;
root = column.string;
level = column.number;
// Amount of parents
filePath = column.string;
parentDir = column.string;
childrenDir = column.string;
index = column.string;
parent = column.string.nullable;
// I18n
i18nId = column.string;
locale = column.string.nullable;
// Version specific
get versionId() {
return this.entryId.concat(".").concat(this.phase);
}
/** @deprecated */
modifiedAt = column.number;
rowHash = column.string;
fileHash = column.string;
// Entries from which a new draft can be created are marked as active,
// there is only one active entry per entryId
active = column.boolean;
// Per entry there is one main entry, which is either published, archived or
// draft
main = column.boolean;
path = column.string;
url = column.string;
data = column.json();
searchableText = column.string;
};
var EntryRow = table({
Entry: EntryTable,
[table.primaryKey]() {
return [this.entryId, this.phase];
},
[table.indexes]() {
return {
rowHash: index(this.rowHash),
type: index(this.type),
parent: index(this.parent),
url: index(this.url),
path: index(this.path),
fileIdentifier: index(this.filePath, this.workspace, this.root),
parentDir: index(this.parentDir),
childrenDir: index(this.childrenDir),
versionId: index(this.versionId),
phase: index(this.phase),
i18nId: index(this.i18nId)
};
}
});
export {
ALT_STATUS,
EntryPhase,
EntryRow,
EntryTable
};