@diagonal-hq/cli 0.32.0 → 0.32.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.
- package/README.md +1 -0
- package/dist/cli.mjs +9 -4
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -346,6 +346,7 @@ export default defineWorkspaceField({
|
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
- `uid` is the identity of the field. See [Definition uids and slugs](#definition-uids-and-slugs). `diagonal check` writes a missing uid. A deploy finds the stored field by its uid, so a file rename or a key change keeps the field.
|
|
349
|
+
- `section` groups the field on the Settings page. It is optional and takes a string with at most 255 characters.
|
|
349
350
|
- `key` is the field key. It is optional: without it, the file name without `.ts` is the key. The build uses the file name as it is: `support-email.ts` does not give the key `support_email`. A key starts with a lowercase letter and contains only a-z, 0-9, and `_`. It cannot be the key of a built-in setting, such as `name` or `website`, or a record key, such as `id`. The file name gives the `WorkspaceFields` name, so it follows the same rule. The check reports a file name that breaks the rule at the file, and a `key` that breaks it at the `key`. A workspace field has no `slug` option: use `key`.
|
|
350
351
|
- The build reads only the `.ts` files directly in `workspace-fields/`. It reports any other file in the folder.
|
|
351
352
|
- `definition` is a `field.<type>({...})` builder. A workspace field takes `label`, `description`, `required`, `guard`, and `settings`. It cannot be a `relation`, and the builder has no `uid`, `unique`, `index`, `computed`, `getter`, or `setter`.
|
package/dist/cli.mjs
CHANGED
|
@@ -312882,7 +312882,7 @@ var RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
|
312882
312882
|
...Object.keys(workspace_settings_catalog_default.refused),
|
|
312883
312883
|
...FIELD_CATALOG.record_meta_fields
|
|
312884
312884
|
]);
|
|
312885
|
-
var ENTRY_KEYS = /* @__PURE__ */ new Set(["uid", "key", "definition", "value"]);
|
|
312885
|
+
var ENTRY_KEYS = /* @__PURE__ */ new Set(["uid", "key", "section", "definition", "value"]);
|
|
312886
312886
|
var RESOURCE_ONLY_OPTIONS = ["uid", "unique", "index", "computed", "getter", "setter", "setterWhenEmpty"];
|
|
312887
312887
|
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
312888
312888
|
var DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -312951,9 +312951,12 @@ function readWorkspaceField(path, argument, declared, diagnostics, generatedEntr
|
|
|
312951
312951
|
throw new SourceError('Remove "slug". A workspace field sets its key with "key"', nodes.slug);
|
|
312952
312952
|
}
|
|
312953
312953
|
if (!ENTRY_KEYS.has(option)) {
|
|
312954
|
-
throw new SourceError(`Unknown option "${option}". Use "uid", "key", "definition", and "value"`, nodes[option]);
|
|
312954
|
+
throw new SourceError(`Unknown option "${option}". Use "uid", "key", "section", "definition", and "value"`, nodes[option]);
|
|
312955
312955
|
}
|
|
312956
312956
|
}
|
|
312957
|
+
if (entry.section !== void 0 && (typeof entry.section !== "string" || entry.section.length > 255)) {
|
|
312958
|
+
throw new SourceError('"section" must be a string with at most 255 characters', nodes.section);
|
|
312959
|
+
}
|
|
312957
312960
|
const builder = entry.definition;
|
|
312958
312961
|
const { field: field2, metadata } = readWorkspaceFieldDefinition(key, builder, nodes.definition ?? argument);
|
|
312959
312962
|
if (!Object.hasOwn(entry, "value")) {
|
|
@@ -312977,6 +312980,7 @@ function readWorkspaceField(path, argument, declared, diagnostics, generatedEntr
|
|
|
312977
312980
|
path,
|
|
312978
312981
|
key,
|
|
312979
312982
|
...metadata,
|
|
312983
|
+
section: entry.section ?? null,
|
|
312980
312984
|
value: entry.value,
|
|
312981
312985
|
nodes: { definition: builder.node, value: nodes.value }
|
|
312982
312986
|
};
|
|
@@ -319880,17 +319884,18 @@ function hasResolver(value) {
|
|
|
319880
319884
|
}
|
|
319881
319885
|
return isResolver(value) || Object.values(value).some(hasResolver);
|
|
319882
319886
|
}
|
|
319883
|
-
function tipTapText(content, oneLine) {
|
|
319887
|
+
function tipTapText(content, oneLine, inlineSeparator = null) {
|
|
319884
319888
|
if (typeof content === "string") {
|
|
319885
319889
|
return content;
|
|
319886
319890
|
}
|
|
319887
319891
|
const separator = oneLine ? "" : "\n\n";
|
|
319892
|
+
const inline = inlineSeparator ?? separator;
|
|
319888
319893
|
const render = (node) => {
|
|
319889
319894
|
if (!isPlainObject2(node)) {
|
|
319890
319895
|
return "";
|
|
319891
319896
|
}
|
|
319892
319897
|
if (node.content !== void 0 && node.content !== null) {
|
|
319893
|
-
return Array.isArray(node.content) ? node.content.map(render).join(
|
|
319898
|
+
return Array.isArray(node.content) ? node.content.map(render).join(inline) : "";
|
|
319894
319899
|
}
|
|
319895
319900
|
return typeof node.text === "string" ? node.text : "";
|
|
319896
319901
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -262,6 +262,8 @@ export type WorkspaceFieldDefinition<T extends WorkspaceFieldType = WorkspaceFie
|
|
|
262
262
|
* name gives the `WorkspaceFields` name and follows the same rule.
|
|
263
263
|
*/
|
|
264
264
|
key?: string;
|
|
265
|
+
/** Groups the field on the Settings page. At most 255 characters. */
|
|
266
|
+
section?: string;
|
|
265
267
|
/**
|
|
266
268
|
* A `field.<type>({...})` call. A workspace field takes `label`,
|
|
267
269
|
* `description`, `required`, `guard`, and `settings`. `value` is its value:
|