zinkee 0.1.8 → 0.1.10
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 +7 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/schemas.test.ts +136 -0
- package/src/commands/schemas.ts +31 -0
- package/src/index.test.ts +1 -0
- package/src/utils/examples.ts +16 -3
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ Simple field types use `--type`, `--slug`, `--label`:
|
|
|
131
131
|
|
|
132
132
|
```bash
|
|
133
133
|
zinkee schemas fields create projects --type text --slug name --label "Name"
|
|
134
|
-
zinkee schemas fields create projects --type number --slug budget --label "Budget"
|
|
134
|
+
zinkee schemas fields create projects --type number --slug budget --label "Budget" --required true --default 0
|
|
135
135
|
zinkee schemas fields create projects --type date --slug start-date --label "Start Date"
|
|
136
136
|
zinkee schemas fields create projects --type file --slug attachment --label "Attachment"
|
|
137
137
|
zinkee schemas fields create projects --type autoincremental --slug code --label "Code"
|
|
@@ -188,6 +188,12 @@ zinkee schemas fields create projects --raw '{
|
|
|
188
188
|
|
|
189
189
|
### Update field config
|
|
190
190
|
|
|
191
|
+
Use `--default <value>` for the common default-value case:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
zinkee schemas fields update projects budget --default 0
|
|
195
|
+
```
|
|
196
|
+
|
|
191
197
|
PATCH bodies are flat (no `set` / `unset` wrapper). Config properties must be wrapped inside a `config` key:
|
|
192
198
|
|
|
193
199
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -2858,7 +2858,7 @@ var specificExamples = {
|
|
|
2858
2858
|
"sort": [
|
|
2859
2859
|
{ "field": "id", "direction": "DESC" }
|
|
2860
2860
|
],
|
|
2861
|
-
"page": { "offset": 0, "
|
|
2861
|
+
"page": { "offset": 0, "limit": 10 }
|
|
2862
2862
|
}`,
|
|
2863
2863
|
response: `{
|
|
2864
2864
|
"records": [
|
|
@@ -2893,7 +2893,19 @@ var specificExamples = {
|
|
|
2893
2893
|
{ "field": "amount", "direction": "DESC" },
|
|
2894
2894
|
{ "field": "contact-name", "direction": "ASC" }
|
|
2895
2895
|
],
|
|
2896
|
-
"page": { "offset": 0, "
|
|
2896
|
+
"page": { "offset": 0, "limit": 25 }
|
|
2897
|
+
}`
|
|
2898
|
+
},
|
|
2899
|
+
{
|
|
2900
|
+
description: "Filter by status with a free-text search term.",
|
|
2901
|
+
command: `zinkee --json records query contacts --select id,contact-name,status --where "status in OPEN" --limit 25 --raw '{"search":{"term":"garcia"}}'`,
|
|
2902
|
+
raw: `{
|
|
2903
|
+
"select": ["id", "contact-name", "status"],
|
|
2904
|
+
"where": [
|
|
2905
|
+
{ "field": "status", "op": "in", "value": ["OPEN"] }
|
|
2906
|
+
],
|
|
2907
|
+
"search": { "term": "garcia" },
|
|
2908
|
+
"page": { "offset": 0, "limit": 25 }
|
|
2897
2909
|
}`
|
|
2898
2910
|
},
|
|
2899
2911
|
{
|
|
@@ -2904,7 +2916,7 @@ var specificExamples = {
|
|
|
2904
2916
|
"where": [
|
|
2905
2917
|
{ "field": "contact-name", "op": "contains", "value": "Lovelace" }
|
|
2906
2918
|
],
|
|
2907
|
-
"page": { "offset": 0, "
|
|
2919
|
+
"page": { "offset": 0, "limit": 50 }
|
|
2908
2920
|
}`
|
|
2909
2921
|
},
|
|
2910
2922
|
{
|
|
@@ -10292,6 +10304,22 @@ function buildSchemaUpdateInput(options) {
|
|
|
10292
10304
|
}
|
|
10293
10305
|
return input;
|
|
10294
10306
|
}
|
|
10307
|
+
function applyFieldDefaultValue(input, defaultValue) {
|
|
10308
|
+
if (defaultValue === void 0) {
|
|
10309
|
+
return;
|
|
10310
|
+
}
|
|
10311
|
+
const config = input.config;
|
|
10312
|
+
if (config !== void 0 && !isJsonObject6(config)) {
|
|
10313
|
+
throw new CliError(
|
|
10314
|
+
"invalid_cli_usage",
|
|
10315
|
+
'Expected field "config" to be a JSON object when using "--default".'
|
|
10316
|
+
);
|
|
10317
|
+
}
|
|
10318
|
+
input.config = {
|
|
10319
|
+
...config ?? {},
|
|
10320
|
+
defaultValue
|
|
10321
|
+
};
|
|
10322
|
+
}
|
|
10295
10323
|
function buildFieldCreateInput(options) {
|
|
10296
10324
|
const raw = normalizeSchemaFieldCreatePayload(readRawObject4(options.raw, options.rawFile));
|
|
10297
10325
|
const rawType = typeof raw.type === "string" ? raw.type : void 0;
|
|
@@ -10320,6 +10348,7 @@ function buildFieldCreateInput(options) {
|
|
|
10320
10348
|
if (options.required !== void 0) {
|
|
10321
10349
|
input.required = options.required;
|
|
10322
10350
|
}
|
|
10351
|
+
applyFieldDefaultValue(input, options.default);
|
|
10323
10352
|
if ("config" in input && isJsonObject6(input.config) && isEmptyObject5(input.config)) {
|
|
10324
10353
|
delete input.config;
|
|
10325
10354
|
}
|
|
@@ -10362,6 +10391,7 @@ function buildFieldUpdateInput(currentType, options) {
|
|
|
10362
10391
|
if (options.required !== void 0) {
|
|
10363
10392
|
input.required = options.required;
|
|
10364
10393
|
}
|
|
10394
|
+
applyFieldDefaultValue(input, options.default);
|
|
10365
10395
|
return input;
|
|
10366
10396
|
}
|
|
10367
10397
|
async function resolveSchemaSelector2(api, selector2) {
|
|
@@ -10489,7 +10519,7 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
10489
10519
|
}
|
|
10490
10520
|
emitFieldsTable(stdout, [data]);
|
|
10491
10521
|
});
|
|
10492
|
-
fields.command("create").description(`Create a field in a schema.${buildSchemaFieldCreateHelpText()}`).argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--type <type>", `field type (${formatSchemaFieldTypes()})`).option("--slug <slug>", "field slug").option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--raw <json>", "raw JSON object payload (see type-specific shapes in --help)").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
|
|
10522
|
+
fields.command("create").description(`Create a field in a schema.${buildSchemaFieldCreateHelpText()}`).argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--type <type>", `field type (${formatSchemaFieldTypes()})`).option("--slug <slug>", "field slug").option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload (see type-specific shapes in --help)").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
|
|
10493
10523
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
10494
10524
|
ensureWritable7("schemas fields create", readOnly, "write");
|
|
10495
10525
|
const input = buildFieldCreateInput(commandOptions);
|
|
@@ -10506,7 +10536,7 @@ function registerSchemasCommands(program, options = {}) {
|
|
|
10506
10536
|
}
|
|
10507
10537
|
writeLine10(stdout, `Created field "${data.slug ?? commandOptions.slug}".`);
|
|
10508
10538
|
});
|
|
10509
|
-
fields.command("update").description("Update a field in a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector8).option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, field, commandOptions) {
|
|
10539
|
+
fields.command("update").description("Update a field in a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector8).option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, field, commandOptions) {
|
|
10510
10540
|
const { api, json, readOnly } = createSchemasApi(this, filePath);
|
|
10511
10541
|
ensureWritable7("schemas fields update", readOnly, "write");
|
|
10512
10542
|
const resolvedSchema = await resolveSchemaSelector2(api, schema);
|