@softr/cli 0.1.6-se21219.17 → 0.1.6
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 +21 -21
- package/dist/cli.mjs +93 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,27 +226,27 @@ crm/
|
|
|
226
226
|
.softr-db/views/<tableId>.json # the views of a table, once views list read them
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
| Command
|
|
230
|
-
|
|
|
231
|
-
| `db list`
|
|
232
|
-
| `db get [<database>] [--dir <path>]`
|
|
233
|
-
| `db create <name> [--description <text>] [--workspace <id>] [--dir <path>]`
|
|
234
|
-
| `db update [<databaseId>] [--name <name>] [--description <text>] [--dir <path>]`
|
|
235
|
-
| `db delete [<databaseId>] [--force] [--dir <path>]`
|
|
236
|
-
| `db tables list` / `get <table>`
|
|
237
|
-
| `db tables create <name> [--field <name:TYPE>]... [--primary-field <name>]`
|
|
238
|
-
| `db tables update <table> [--name] [--description]` / `delete <table> [--force]`
|
|
239
|
-
| `db fields get <table> <field>`
|
|
240
|
-
| `db fields add <table> <name> --type <TYPE> [--options <json>] [--multiple]`
|
|
241
|
-
| `db fields update <table> <field> [--name] [--type] [--options <json>] [--[no-]multiple]`
|
|
242
|
-
| `db fields delete <table> <field>`
|
|
243
|
-
| `db views list <table>`
|
|
244
|
-
| `db records list <table> [--view <view>] [--limit <n>] [--offset <n>] [--all]`
|
|
245
|
-
| `db records search <table> [--filter <json>] [--sort <field[:desc]>]...`
|
|
246
|
-
| `db records get <table> <recordId>`
|
|
247
|
-
| `db records create <table> --fields <json>` / `update <table> <recordId> --fields <json>`
|
|
248
|
-
| `db records delete <table> <recordId>`
|
|
249
|
-
| `db records upload <table> <recordId> <field> <file> [--name <fileName>]`
|
|
229
|
+
| Command | What it does |
|
|
230
|
+
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
231
|
+
| `db list` | The databases the token reaches, across all workspaces, with their workspace and number of tables. |
|
|
232
|
+
| `db get [<database>] [--dir <path>]` | One database with its tables, by id or exact name. Outside a database directory it creates `./<name-slug>/`; inside one it refreshes the cache, and a different database is an error. |
|
|
233
|
+
| `db create <name> [--description <text>] [--workspace <id>] [--dir <path>]` | Create an empty database and its directory. The workspace defaults to `SOFTR_WORKSPACE_ID`, else to your only or default workspace among those where the token grants `databases.schema:write`. |
|
|
234
|
+
| `db update [<databaseId>] [--name <name>] [--description <text>] [--dir <path>]` | Change the name, the description or both. |
|
|
235
|
+
| `db delete [<databaseId>] [--force] [--dir <path>]` | Delete a database. One that still has tables needs `--force`, which also deletes the tables and all their records. The directory keeps its `softr-db.jsonc`; the cache goes. |
|
|
236
|
+
| `db tables list` / `get <table>` | The tables of the database; one table with its fields (ids, types, primary/required/read-only). |
|
|
237
|
+
| `db tables create <name> [--field <name:TYPE>]... [--fields <json>] [--primary-field <name>]` | Create a table with at least one field: `--field` for types without options, `--fields` (a JSON array, `@<file>` or `-`) for any; the first one names a record. |
|
|
238
|
+
| `db tables update <table> [--name] [--description]` / `delete <table> [--force]` | Rename or describe a table; delete it (`--force` when it still has records). |
|
|
239
|
+
| `db fields get <table> <field>` | One field with its options. |
|
|
240
|
+
| `db fields add <table> <name> --type <TYPE> [--options <json>] [--multiple]` | Add a field. The types and their options: [field reference](https://docs.softr.io/softr-api/softr-database-api/table-fields/add-table-field). |
|
|
241
|
+
| `db fields update <table> <field> [--name] [--type] [--options <json>] [--[no-]multiple]` | Change a field; what is not passed stays as it is, `--options` replaces the options as a whole. |
|
|
242
|
+
| `db fields delete <table> <field>` | Delete a field and its values in every record. |
|
|
243
|
+
| `db views list <table>` | The views of a table (the API reads views only). |
|
|
244
|
+
| `db records list <table> [--view <view>] [--limit <n>] [--offset <n>] [--all]` | Records through a view, the table's default view unless `--view`; one page or `--all` in pages of 200. |
|
|
245
|
+
| `db records search <table> [--filter <json>] [--sort <field[:desc]>]...` | Records by a filter ([operators](https://docs.softr.io/softr-api/softr-database-api/records/search-records)); without `--filter`, every record. |
|
|
246
|
+
| `db records get <table> <recordId>` | One record. |
|
|
247
|
+
| `db records create <table> --fields <json>` / `update <table> <recordId> --fields <json>` | Create a record, or change some of its fields. `--fields` is inline JSON, `@<file>` or `-`. |
|
|
248
|
+
| `db records delete <table> <recordId>` | Delete a record. |
|
|
249
|
+
| `db records upload <table> <recordId> <field> <file> [--name <fileName>]` | Add a local file to an attachment field, stored under the local file name unless `--name`. |
|
|
250
250
|
|
|
251
251
|
Tables and fields take an id or an exact name; a name two items share is an error that lists their ids. The table,
|
|
252
252
|
field and view commands take the database from `--database <id>`, else `SOFTR_DATABASE_ID`, else the database
|
package/dist/cli.mjs
CHANGED
|
@@ -15697,7 +15697,11 @@ async function readJsonArgument(value, option, hint) {
|
|
|
15697
15697
|
}
|
|
15698
15698
|
text = Buffer.concat(chunks).toString("utf8");
|
|
15699
15699
|
} else if (value.startsWith("@")) {
|
|
15700
|
-
|
|
15700
|
+
try {
|
|
15701
|
+
text = await readFile8(value.slice(1), "utf8");
|
|
15702
|
+
} catch {
|
|
15703
|
+
throw new CliError(`Cannot read ${value.slice(1)} for ${option}.`);
|
|
15704
|
+
}
|
|
15701
15705
|
}
|
|
15702
15706
|
try {
|
|
15703
15707
|
return JSON.parse(text);
|
|
@@ -15730,8 +15734,8 @@ async function currentTables(context, fresh) {
|
|
|
15730
15734
|
context.cache = await refreshSchemaCache(context.client, context.dir, context.databaseId);
|
|
15731
15735
|
return context.cache.tables;
|
|
15732
15736
|
}
|
|
15733
|
-
|
|
15734
|
-
const table = byIdOrName(
|
|
15737
|
+
function tableIn(context, tables, reference) {
|
|
15738
|
+
const table = byIdOrName(tables, reference, "table");
|
|
15735
15739
|
if (!table) {
|
|
15736
15740
|
throw new CliError(
|
|
15737
15741
|
`Database ${context.databaseId} has no table with the id or name "${reference}".`,
|
|
@@ -15740,7 +15744,14 @@ async function findTable(context, reference, fresh = false) {
|
|
|
15740
15744
|
}
|
|
15741
15745
|
return table;
|
|
15742
15746
|
}
|
|
15743
|
-
async function
|
|
15747
|
+
async function findTableOnServer(context, reference) {
|
|
15748
|
+
return tableIn(context, await currentTables(context, true), reference);
|
|
15749
|
+
}
|
|
15750
|
+
async function findTableCached(context, reference) {
|
|
15751
|
+
const cached = context.dir && context.cache ? byIdOrName(context.cache.tables, reference, "table") : void 0;
|
|
15752
|
+
return cached ?? findTableOnServer(context, reference);
|
|
15753
|
+
}
|
|
15754
|
+
async function findFields(context, table, references) {
|
|
15744
15755
|
const resolve = (current3) => {
|
|
15745
15756
|
const fields2 = /* @__PURE__ */ new Map();
|
|
15746
15757
|
for (const reference of references) {
|
|
@@ -15753,8 +15764,8 @@ async function findFields(context, table, references, fresh = false) {
|
|
|
15753
15764
|
};
|
|
15754
15765
|
let current2 = table;
|
|
15755
15766
|
let fields = resolve(current2);
|
|
15756
|
-
if (fields.size < new Set(references).size && context.dir
|
|
15757
|
-
current2 = await
|
|
15767
|
+
if (fields.size < new Set(references).size && context.dir) {
|
|
15768
|
+
current2 = await findTableOnServer(context, table.id);
|
|
15758
15769
|
fields = resolve(current2);
|
|
15759
15770
|
}
|
|
15760
15771
|
const missing = references.filter((reference) => !fields.has(reference));
|
|
@@ -15766,9 +15777,34 @@ async function findFields(context, table, references, fresh = false) {
|
|
|
15766
15777
|
}
|
|
15767
15778
|
return { table: current2, fields };
|
|
15768
15779
|
}
|
|
15769
|
-
async function
|
|
15770
|
-
const
|
|
15771
|
-
|
|
15780
|
+
async function readViews(context, table) {
|
|
15781
|
+
const views = await listViews(context.client, context.databaseId, table.id);
|
|
15782
|
+
if (context.dir) {
|
|
15783
|
+
await writeViewsCache(context.dir, table.id, views);
|
|
15784
|
+
}
|
|
15785
|
+
return views;
|
|
15786
|
+
}
|
|
15787
|
+
async function findView(context, table, reference) {
|
|
15788
|
+
const cached = context.dir ? (await readViewsCache(context.dir, table.id))?.views : void 0;
|
|
15789
|
+
const view = (cached ? byIdOrName(cached, reference, "view") : void 0) ?? byIdOrName(await readViews(context, table), reference, "view");
|
|
15790
|
+
if (!view) {
|
|
15791
|
+
throw new CliError(
|
|
15792
|
+
`Table ${table.name} has no view with the id or name "${reference}".`,
|
|
15793
|
+
`"softr db views list ${table.id}" shows its views.`
|
|
15794
|
+
);
|
|
15795
|
+
}
|
|
15796
|
+
return view;
|
|
15797
|
+
}
|
|
15798
|
+
async function findField(context, tableReference, reference) {
|
|
15799
|
+
const table = await findTableOnServer(context, tableReference);
|
|
15800
|
+
const field = byIdOrName(table.fields, reference, "field");
|
|
15801
|
+
if (!field) {
|
|
15802
|
+
throw new CliError(
|
|
15803
|
+
`Table ${table.name} has no field with the id or name "${reference}".`,
|
|
15804
|
+
`"softr db tables get ${table.id}" shows its fields.`
|
|
15805
|
+
);
|
|
15806
|
+
}
|
|
15807
|
+
return { table, field };
|
|
15772
15808
|
}
|
|
15773
15809
|
async function afterSchemaWrite(context) {
|
|
15774
15810
|
if (context.dir) {
|
|
@@ -15787,6 +15823,21 @@ function parseFieldSpec(spec) {
|
|
|
15787
15823
|
}
|
|
15788
15824
|
return { name, type };
|
|
15789
15825
|
}
|
|
15826
|
+
function parseFieldList(value) {
|
|
15827
|
+
if (!Array.isArray(value)) {
|
|
15828
|
+
throw new CliError(
|
|
15829
|
+
"--fields must be a JSON array of fields.",
|
|
15830
|
+
`For example: [{"name": "Stage", "type": "SELECT", "options": {...}}]`
|
|
15831
|
+
);
|
|
15832
|
+
}
|
|
15833
|
+
return value.map((item, index) => {
|
|
15834
|
+
const field = item;
|
|
15835
|
+
if (!field || typeof field !== "object" || typeof field.name !== "string" || !field.name || typeof field.type !== "string" || !field.type) {
|
|
15836
|
+
throw new CliError(`--fields item ${index + 1} needs a "name" and a "type".`);
|
|
15837
|
+
}
|
|
15838
|
+
return { ...field, name: field.name, type: field.type.toUpperCase() };
|
|
15839
|
+
});
|
|
15840
|
+
}
|
|
15790
15841
|
function renderTables(tables) {
|
|
15791
15842
|
if (!tables.length) {
|
|
15792
15843
|
return "The database has no tables. Create one with: softr db tables create <name>";
|
|
@@ -15849,7 +15900,7 @@ function registerTables(db2) {
|
|
|
15849
15900
|
).action(async (reference, opts, command) => {
|
|
15850
15901
|
const options = globalOptions(command);
|
|
15851
15902
|
const context = await schemaContext(opts);
|
|
15852
|
-
const table = await
|
|
15903
|
+
const table = await findTableOnServer(context, reference);
|
|
15853
15904
|
emit(options, renderTable(table), { table });
|
|
15854
15905
|
});
|
|
15855
15906
|
withDatabaseOptions(
|
|
@@ -15857,22 +15908,28 @@ function registerTables(db2) {
|
|
|
15857
15908
|
"Create a table with at least one field; the first one names a record unless --primary-field says otherwise"
|
|
15858
15909
|
).argument("<name>", "the table name").option("--description <text>", "what the table holds").option(
|
|
15859
15910
|
"--field <name:TYPE>",
|
|
15860
|
-
|
|
15911
|
+
"a field of a type without options, repeatable",
|
|
15861
15912
|
(value, previous) => [...previous, value],
|
|
15862
15913
|
[]
|
|
15914
|
+
).option(
|
|
15915
|
+
"--fields <json>",
|
|
15916
|
+
`fields as a JSON array of {name, type, options?, description?, allowMultipleEntries?}, @<file> or - for stdin; they follow the --field ones (types and options: ${FIELD_REFERENCE_URL})`
|
|
15863
15917
|
).option("--primary-field <name>", "the field that names a record (default: the first field)")
|
|
15864
15918
|
).action(
|
|
15865
15919
|
async (name, opts, command) => {
|
|
15866
15920
|
const options = globalOptions(command);
|
|
15867
|
-
|
|
15921
|
+
const fields = [
|
|
15922
|
+
...opts.field.map(parseFieldSpec),
|
|
15923
|
+
...opts.fields === void 0 ? [] : parseFieldList(await readJsonArgument(opts.fields, "--fields"))
|
|
15924
|
+
];
|
|
15925
|
+
if (!fields.length) {
|
|
15868
15926
|
throw new CliError(
|
|
15869
|
-
'A table needs at least one field: pass --field <name>:<TYPE>, for example --field "Name:SINGLE_LINE_TEXT".',
|
|
15870
|
-
"
|
|
15927
|
+
'A table needs at least one field: pass --field <name>:<TYPE>, for example --field "Name:SINGLE_LINE_TEXT", or --fields with a JSON array.',
|
|
15928
|
+
"The first field names a record unless --primary-field names another."
|
|
15871
15929
|
);
|
|
15872
15930
|
}
|
|
15873
|
-
const fields = opts.field.map(parseFieldSpec);
|
|
15874
15931
|
if (opts.primaryField && !fields.some((field) => field.name === opts.primaryField)) {
|
|
15875
|
-
throw new CliError(`--primary-field "${opts.primaryField}" is not one of the
|
|
15932
|
+
throw new CliError(`--primary-field "${opts.primaryField}" is not one of the fields' names.`);
|
|
15876
15933
|
}
|
|
15877
15934
|
const context = await schemaContext(opts);
|
|
15878
15935
|
const table = await createTable(context.client, context.databaseId, {
|
|
@@ -15894,7 +15951,7 @@ function registerTables(db2) {
|
|
|
15894
15951
|
}
|
|
15895
15952
|
const options = globalOptions(command);
|
|
15896
15953
|
const context = await schemaContext(opts);
|
|
15897
|
-
const current2 = await
|
|
15954
|
+
const current2 = await findTableOnServer(context, reference);
|
|
15898
15955
|
const table = await updateTable(context.client, context.databaseId, current2.id, {
|
|
15899
15956
|
name: opts.name ?? current2.name,
|
|
15900
15957
|
description: opts.description ?? current2.description
|
|
@@ -15908,7 +15965,7 @@ function registerTables(db2) {
|
|
|
15908
15965
|
).action(async (reference, opts, command) => {
|
|
15909
15966
|
const options = globalOptions(command);
|
|
15910
15967
|
const context = await schemaContext(opts);
|
|
15911
|
-
const table = await
|
|
15968
|
+
const table = await findTableOnServer(context, reference);
|
|
15912
15969
|
await deleteTable(context.client, context.databaseId, table.id, opts.force === true);
|
|
15913
15970
|
await afterSchemaWrite(context);
|
|
15914
15971
|
emit(options, `Deleted table ${table.name} (${table.id}).`, { deleted: table.id });
|
|
@@ -15921,7 +15978,7 @@ function registerFields(db2) {
|
|
|
15921
15978
|
).action(async (tableReference, reference, opts, command) => {
|
|
15922
15979
|
const options = globalOptions(command);
|
|
15923
15980
|
const context = await schemaContext(opts);
|
|
15924
|
-
const { table, field } = await findField(context, tableReference, reference
|
|
15981
|
+
const { table, field } = await findField(context, tableReference, reference);
|
|
15925
15982
|
emit(options, renderField(table, field), { tableId: table.id, field });
|
|
15926
15983
|
});
|
|
15927
15984
|
withDatabaseOptions(
|
|
@@ -15931,7 +15988,7 @@ function registerFields(db2) {
|
|
|
15931
15988
|
const options = globalOptions(command);
|
|
15932
15989
|
const fieldOptions = await parseOptions(opts.options);
|
|
15933
15990
|
const context = await schemaContext(opts);
|
|
15934
|
-
const table = await
|
|
15991
|
+
const table = await findTableCached(context, tableReference);
|
|
15935
15992
|
const field = await addField(context.client, context.databaseId, table.id, {
|
|
15936
15993
|
name,
|
|
15937
15994
|
type: opts.type.toUpperCase(),
|
|
@@ -15959,7 +16016,7 @@ function registerFields(db2) {
|
|
|
15959
16016
|
}
|
|
15960
16017
|
const options = globalOptions(command);
|
|
15961
16018
|
const context = await schemaContext(opts);
|
|
15962
|
-
const { table, field: current2 } = await findField(context, tableReference, reference
|
|
16019
|
+
const { table, field: current2 } = await findField(context, tableReference, reference);
|
|
15963
16020
|
const field = await updateField(context.client, context.databaseId, table.id, current2.id, {
|
|
15964
16021
|
name: opts.name ?? current2.name,
|
|
15965
16022
|
type: opts.type?.toUpperCase() ?? current2.type,
|
|
@@ -15981,7 +16038,7 @@ function registerFields(db2) {
|
|
|
15981
16038
|
).action(async (tableReference, reference, opts, command) => {
|
|
15982
16039
|
const options = globalOptions(command);
|
|
15983
16040
|
const context = await schemaContext(opts);
|
|
15984
|
-
const { table, field } = await findField(context, tableReference, reference
|
|
16041
|
+
const { table, field } = await findField(context, tableReference, reference);
|
|
15985
16042
|
await deleteField(context.client, context.databaseId, table.id, field.id);
|
|
15986
16043
|
await afterSchemaWrite(context);
|
|
15987
16044
|
emit(options, `Deleted field ${field.name} (${field.id}) from ${table.name}.`, {
|
|
@@ -15997,11 +16054,8 @@ function registerViews(db2) {
|
|
|
15997
16054
|
).action(async (reference, opts, command) => {
|
|
15998
16055
|
const options = globalOptions(command);
|
|
15999
16056
|
const context = await schemaContext(opts);
|
|
16000
|
-
const table = await
|
|
16001
|
-
const items = await
|
|
16002
|
-
if (context.dir) {
|
|
16003
|
-
await writeViewsCache(context.dir, table.id, items);
|
|
16004
|
-
}
|
|
16057
|
+
const table = await findTableOnServer(context, reference);
|
|
16058
|
+
const items = await readViews(context, table);
|
|
16005
16059
|
emit(options, renderViews(items), { tableId: table.id, views: items });
|
|
16006
16060
|
});
|
|
16007
16061
|
}
|
|
@@ -16101,24 +16155,6 @@ function parseSort(spec) {
|
|
|
16101
16155
|
}
|
|
16102
16156
|
return { field: spec.trim(), sortType: "ASC" };
|
|
16103
16157
|
}
|
|
16104
|
-
async function findView(context, table, reference) {
|
|
16105
|
-
const fresh = async () => {
|
|
16106
|
-
const views = await listViews(context.client, context.databaseId, table.id);
|
|
16107
|
-
if (context.dir) {
|
|
16108
|
-
await writeViewsCache(context.dir, table.id, views);
|
|
16109
|
-
}
|
|
16110
|
-
return views;
|
|
16111
|
-
};
|
|
16112
|
-
const cached = context.dir ? (await readViewsCache(context.dir, table.id))?.views : void 0;
|
|
16113
|
-
const view = (cached ? byIdOrName(cached, reference, "view") : void 0) ?? byIdOrName(await fresh(), reference, "view");
|
|
16114
|
-
if (!view) {
|
|
16115
|
-
throw new CliError(
|
|
16116
|
-
`Table ${table.name} has no view with the id or name "${reference}".`,
|
|
16117
|
-
`"softr db views list ${table.id}" shows its views.`
|
|
16118
|
-
);
|
|
16119
|
-
}
|
|
16120
|
-
return view;
|
|
16121
|
-
}
|
|
16122
16158
|
function withFieldNames(record, table) {
|
|
16123
16159
|
const names2 = new Map(table.fields.map((field) => [field.id, field.name]));
|
|
16124
16160
|
return {
|
|
@@ -16158,7 +16194,7 @@ function registerRecords(db2) {
|
|
|
16158
16194
|
const options = globalOptions(command);
|
|
16159
16195
|
const pages = paging(opts);
|
|
16160
16196
|
const context = await schemaContext(opts);
|
|
16161
|
-
const table = await
|
|
16197
|
+
const table = await findTableCached(context, reference);
|
|
16162
16198
|
const viewId = opts.view ? (await findView(context, table, opts.view)).id : void 0;
|
|
16163
16199
|
const page = await readPages(
|
|
16164
16200
|
pages,
|
|
@@ -16196,7 +16232,7 @@ function registerRecords(db2) {
|
|
|
16196
16232
|
const context = await schemaContext(opts);
|
|
16197
16233
|
const references = new Set(sorts.map((sort) => sort.field));
|
|
16198
16234
|
fieldReferences(condition, references);
|
|
16199
|
-
const { table, ids } = await fieldIdsFor(context, await
|
|
16235
|
+
const { table, ids } = await fieldIdsFor(context, await findTableCached(context, reference), [...references]);
|
|
16200
16236
|
const search = (offset2, limit) => ({
|
|
16201
16237
|
paging: { offset: offset2, limit },
|
|
16202
16238
|
...sorts.length ? { sorting: sorts.map((sort) => ({ sortingField: ids.get(sort.field), sortType: sort.sortType })) } : {},
|
|
@@ -16216,7 +16252,7 @@ function registerRecords(db2) {
|
|
|
16216
16252
|
).action(async (reference, recordId, opts, command) => {
|
|
16217
16253
|
const options = globalOptions(command);
|
|
16218
16254
|
const context = await schemaContext(opts);
|
|
16219
|
-
const table = await
|
|
16255
|
+
const table = await findTableCached(context, reference);
|
|
16220
16256
|
const record = await getRecord(context.client, context.databaseId, table.id, recordId, !opts.fieldIds);
|
|
16221
16257
|
emit(options, renderRecord(record), { tableId: table.id, record });
|
|
16222
16258
|
});
|
|
@@ -16231,7 +16267,7 @@ function registerRecords(db2) {
|
|
|
16231
16267
|
const options = globalOptions(command);
|
|
16232
16268
|
const fields = asObject(await readJsonArgument(opts.fields, "--fields"), "--fields");
|
|
16233
16269
|
const context = await schemaContext(opts);
|
|
16234
|
-
const table = await
|
|
16270
|
+
const table = await findTableCached(context, reference);
|
|
16235
16271
|
const record = await createRecord(
|
|
16236
16272
|
context.client,
|
|
16237
16273
|
context.databaseId,
|
|
@@ -16256,7 +16292,7 @@ function registerRecords(db2) {
|
|
|
16256
16292
|
throw new CliError("Nothing to change: --fields is an empty object.");
|
|
16257
16293
|
}
|
|
16258
16294
|
const context = await schemaContext(opts);
|
|
16259
|
-
const table = await
|
|
16295
|
+
const table = await findTableCached(context, reference);
|
|
16260
16296
|
const record = await updateRecord(
|
|
16261
16297
|
context.client,
|
|
16262
16298
|
context.databaseId,
|
|
@@ -16273,7 +16309,7 @@ function registerRecords(db2) {
|
|
|
16273
16309
|
).action(async (reference, recordId, opts, command) => {
|
|
16274
16310
|
const options = globalOptions(command);
|
|
16275
16311
|
const context = await schemaContext(opts);
|
|
16276
|
-
const table = await
|
|
16312
|
+
const table = await findTableOnServer(context, reference);
|
|
16277
16313
|
await deleteRecord(context.client, context.databaseId, table.id, recordId);
|
|
16278
16314
|
emit(options, `Deleted record ${recordId} from ${table.name}.`, { tableId: table.id, deleted: recordId });
|
|
16279
16315
|
});
|
|
@@ -16291,13 +16327,12 @@ function registerRecords(db2) {
|
|
|
16291
16327
|
throw new CliError(`Cannot read ${file}.`);
|
|
16292
16328
|
}
|
|
16293
16329
|
const context = await schemaContext(opts);
|
|
16294
|
-
const found = await
|
|
16295
|
-
const
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
throw new CliError(`Field "${fieldReference}" has the type ${fieldType}; upload needs an ATTACHMENT field.`);
|
|
16330
|
+
const found = await findFields(context, await findTableCached(context, reference), [fieldReference]);
|
|
16331
|
+
const field = found.fields.get(fieldReference);
|
|
16332
|
+
if (field.type !== "ATTACHMENT") {
|
|
16333
|
+
throw new CliError(`Field "${fieldReference}" has the type ${field.type}; upload needs an ATTACHMENT field.`);
|
|
16299
16334
|
}
|
|
16300
|
-
const uploaded = await uploadAttachment(context.client, context.databaseId, found.table.id, recordId,
|
|
16335
|
+
const uploaded = await uploadAttachment(context.client, context.databaseId, found.table.id, recordId, field.id, {
|
|
16301
16336
|
name: opts.name ?? path12.basename(file),
|
|
16302
16337
|
content
|
|
16303
16338
|
});
|
|
@@ -17963,7 +17998,7 @@ Pass --workspace <id> to a command, or set SOFTR_WORKSPACE_ID, to work in one of
|
|
|
17963
17998
|
// package.json
|
|
17964
17999
|
var package_default = {
|
|
17965
18000
|
name: "@softr/cli",
|
|
17966
|
-
version: "0.1.6
|
|
18001
|
+
version: "0.1.6",
|
|
17967
18002
|
description: "The Softr command line: build, test and publish Softr workflows from local files, manage Softr Databases; more Softr APIs to come",
|
|
17968
18003
|
keywords: [
|
|
17969
18004
|
"softr",
|
package/package.json
CHANGED