@jinshuju/cli 0.29.0 → 0.30.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/dist/commands/form.js +23 -2
- package/dist/commands/opensearch.js +14 -1
- package/dist/generated/operations.d.ts +1 -1
- package/dist/generated/operations.js +5 -0
- package/dist/spec.d.ts +6 -0
- package/dist/spec.js +13 -0
- package/package.json +1 -1
package/dist/commands/form.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { FILTER_OPTION, FILTERS_OPTION, JSON_OPTION, MINE_OPTION, PAGINATION_OPTIONS, SORT_OPTION, UsageError } from '../options.js';
|
|
2
2
|
import { FOLDER_OPTION, LISTING, PREVIEW_OPTION, YES_OPTION, confirmed, filters, given, keywords, overriding, paging, payload, refuseWithMine, requiredOption, sort, trash } from './shared.js';
|
|
3
3
|
import { validateContainerPayload } from '../payload.js';
|
|
4
|
-
import { bodyChoices, call } from '../spec.js';
|
|
4
|
+
import { bodyChoices, bodyKeys, call } from '../spec.js';
|
|
5
5
|
import { readableSize, upload, uploadedId, uploadFormImage } from './upload.js';
|
|
6
6
|
import { isRecord } from '../values.js';
|
|
7
|
+
/**
|
|
8
|
+
* Every key setting takes, from the spec. The paragraphs above explain a few;
|
|
9
|
+
* a key the help never names reads as one the CLI cannot write.
|
|
10
|
+
*/
|
|
11
|
+
function settingKeys() {
|
|
12
|
+
const keys = bodyKeys('createForm', 'setting');
|
|
13
|
+
if (!keys)
|
|
14
|
+
return [];
|
|
15
|
+
const lines = ['Every key setting takes, in `form create` and `form edit` alike:'];
|
|
16
|
+
for (const key of keys) {
|
|
17
|
+
const last = lines.length - 1;
|
|
18
|
+
const joined = `${lines[last]} ${key},`;
|
|
19
|
+
if (last > 0 && joined.length <= 78)
|
|
20
|
+
lines[last] = joined;
|
|
21
|
+
else
|
|
22
|
+
lines.push(`${key},`);
|
|
23
|
+
}
|
|
24
|
+
lines[lines.length - 1] = lines[lines.length - 1].replace(/,$/, '.');
|
|
25
|
+
return [...lines, ''];
|
|
26
|
+
}
|
|
7
27
|
/**
|
|
8
28
|
* The shape behind `--json` on a form, shown rather than described: `fields` is
|
|
9
29
|
* the part nothing else hints at, and one choice field carries more of the
|
|
@@ -47,6 +67,7 @@ const FORM_PAYLOAD = [
|
|
|
47
67
|
'not-open and fill-limit messages. A key left out keeps its text, and ""',
|
|
48
68
|
'puts the default back.',
|
|
49
69
|
'',
|
|
70
|
+
...settingKeys(),
|
|
50
71
|
'A form reads its fields back in the shape written here, each with the',
|
|
51
72
|
'api_code the backend assigned, and a field read goes back through',
|
|
52
73
|
'`field update` as it came. `field types` lists the types to write, and',
|
|
@@ -536,7 +557,7 @@ export const FORM = [
|
|
|
536
557
|
description: 'The payload carries the operations to apply: name, description, setting, layout, and fields as ' +
|
|
537
558
|
'{add, update, update_choices, remove}. Only what is named changes. Switching layout keeps every ' +
|
|
538
559
|
'field; the card layout hides the ones it cannot show and the classic layout shows them again. `form create --help` ' +
|
|
539
|
-
'
|
|
560
|
+
'lists every key setting takes and explains the close rules among them; `form setting edit` writes the few settings this ' +
|
|
540
561
|
'payload cannot, the WeChat share card among them. Display and redirect rules have commands of their ' +
|
|
541
562
|
'own: `form rule edit` and `form redirect-rule edit`.',
|
|
542
563
|
args: [{ name: 'form', required: true, description: 'Form token' }],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSON_OPTION, UsageError } from '../options.js';
|
|
2
2
|
import { call } from '../spec.js';
|
|
3
|
-
import { overriding, payload } from './shared.js';
|
|
3
|
+
import { YES_OPTION, confirmed, overriding, payload } from './shared.js';
|
|
4
4
|
import { uploadFormImage } from './upload.js';
|
|
5
5
|
export const OPENSEARCH = [
|
|
6
6
|
{
|
|
@@ -70,5 +70,18 @@ export const OPENSEARCH = [
|
|
|
70
70
|
return client.request(call('updateOpensearchQuery', { path: { query_token: input.args.query }, body }));
|
|
71
71
|
},
|
|
72
72
|
examples: ['jinshuju opensearch edit Qy7nR3 --disable', 'jinshuju opensearch edit Qy7nR3 --header ./banner.png']
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
path: ['opensearch', 'delete'],
|
|
76
|
+
summary: 'Delete a public query',
|
|
77
|
+
description: 'Its link stops working for good and nothing restores it. To close the link for now and keep ' +
|
|
78
|
+
'the query, `opensearch edit <query> --disable` instead.',
|
|
79
|
+
args: [{ name: 'query', required: true, description: 'Public query token' }],
|
|
80
|
+
options: [YES_OPTION],
|
|
81
|
+
request: (input) => {
|
|
82
|
+
confirmed(input, `Deleting public query ${input.args.query}`);
|
|
83
|
+
return call('deleteOpensearchQuery', { path: { query_token: input.args.query } });
|
|
84
|
+
},
|
|
85
|
+
examples: ['jinshuju opensearch delete Qy7nR3 --yes']
|
|
73
86
|
}
|
|
74
87
|
];
|
|
@@ -3,7 +3,7 @@ import type { Operation, Schema } from '../spec.js';
|
|
|
3
3
|
export declare const BASE_PATH = "/api/v1";
|
|
4
4
|
/** The day spec/openapi.yaml was fetched from the API, when scripts/fetch-spec.mjs recorded it. */
|
|
5
5
|
export declare const SPEC_DATE: string | undefined;
|
|
6
|
-
export type OperationId = 'aggregateEntries' | 'aggregateFormViewEntries' | 'aggregateTableEntries' | 'aggregateTableViewEntries' | 'aggregateTradeTransactions' | 'checkFormFieldData' | 'checkTableFieldData' | 'copyForm' | 'countEntries' | 'countEntriesAcrossForms' | 'countFormViewEntries' | 'countTableEntries' | 'countTableViewEntries' | 'createCheckinCampaign' | 'createEmailTask' | 'createEntriesBatch' | 'createEntry' | 'createEntryComment' | 'createEntryImport' | 'createEntryLegacy' | 'createFillFormEntry' | 'createFillPseudoFormEntry' | 'createFillViewEntry' | 'createFolder' | 'createForm' | 'createFormCooperators' | 'createFormView' | 'createFormWebhook' | 'createMemoryNote' | 'createMessageChannel' | 'createNotificationRule' | 'createOpenResult' | 'createOpensearchQuery' | 'createPseudoForm' | 'createPseudoFormsBatch' | 'createRoutine' | 'createSmsSignature' | 'createSmsTask' | 'createSmsTemplate' | 'createTable' | 'createTableEntry' | 'createTableEntryComment' | 'createTableView' | 'createTemplateUsage' | 'createWeixinOauthSession' | 'deleteCheckinCampaign' | 'deleteEntry' | 'deleteEntryComment' | 'deleteForm' | 'deleteFormView' | 'deleteFormWebhook' | 'deleteMemoryNotes' | 'deleteMessageChannel' | 'deleteNotificationRule' | 'deleteOpenResult' | 'deletePseudoForm' | 'deletePseudoFormsBatch' | 'deleteRoutine' | 'deleteSmsSignature' | 'deleteSmsTemplate' | 'deleteTable' | 'deleteTableEntry' | 'deleteTableEntryComment' | 'deleteTableView' | 'estimateEmailTask' | 'estimateEmailTaskResend' | 'estimateMessage' | 'estimateSmsTask' | 'estimateSmsTaskChange' | 'estimateSmsTaskResend' | 'exportRemainingVouchers' | 'getBillingAccount' | 'getCheckinCampaign' | 'getCurrentUser' | 'getEmailTask' | 'getEntry' | 'getEntryImport' | 'getEntryStateFlow' | 'getEntryStats' | 'getEvaluationSetting' | 'getExamSetting' | 'getFieldType' | 'getFillFormPage' | 'getFillPseudoFormPage' | 'getFillViewPage' | 'getFolder' | 'getForm' | 'getFormSetting' | 'getFormView' | 'getManuallyCloseRule' | 'getMemory' | 'getMessage' | 'getMessageChannel' | 'getNotificationRule' | 'getOpenResult' | 'getOpensearchQuery' | 'getPublishedArtifact' | 'getQuickpaySetting' | 'getRoutine' | 'getSmsTask' | 'getTable' | 'getTableEntry' | 'getTableView' | 'getTradeMerchant' | 'getUserFormSetting' | 'getWheelFortune' | 'listArtifactDataSources' | 'listArtifacts' | 'listBillingAccountInvoices' | 'listBillingAccountPaidFeatures' | 'listBillingAccountPaymentHistories' | 'listBillingAccountUsers' | 'listCheckinCampaigns' | 'listContacts' | 'listEmailTaskActivities' | 'listEmailTasks' | 'listEntries' | 'listEntryComments' | 'listExtendedAttributes' | 'listFieldRules' | 'listFieldTypes' | 'listFolders' | 'listFormConditionTriggerableFields' | 'listFormCooperators' | 'listFormPublishedArtifacts' | 'listFormViewEntries' | 'listFormViews' | 'listForms' | 'listMessageChannels' | 'listMessages' | 'listMyFilledForms' | 'listMySubmittedEntries' | 'listNotificationRuleNotifications' | 'listNotificationRules' | 'listOpenResults' | 'listOpensearchQueries' | 'listOpensearchQuerySuggestions' | 'listPseudoForms' | 'listRedirectRules' | 'listRoutineRuns' | 'listRoutines' | 'listSmsAuditStatuses' | 'listSmsSignatures' | 'listSmsTaskActivities' | 'listSmsTasks' | 'listSmsTemplates' | 'listSmtpAccounts' | 'listTableConditionTriggerableFields' | 'listTableEntries' | 'listTableEntryComments' | 'listTablePublishedArtifacts' | 'listTableViewEntries' | 'listTableViews' | 'listTables' | 'listTradePayouts' | 'listTradeRefunds' | 'listTradeTransactions' | 'moveFormToFolder' | 'moveTableToFolder' | 'patchEntriesBatch' | 'pauseRoutine' | 'prepareEntryAttachmentUpload' | 'prepareFormImageUpload' | 'prepareGoodsDeliverableAttachmentUpload' | 'prepareImportFileUpload' | 'previewFormDeletion' | 'previewFormFieldTypeChange' | 'previewTableDeletion' | 'previewTableFieldTypeChange' | 'replaceEntry' | 'replaceTableEntry' | 'resendEmailTask' | 'resendSmsTask' | 'restoreFormPublishedArtifactDataGrant' | 'restoreTablePublishedArtifactDataGrant' | 'resumeRoutine' | 'revokeFormPublishedArtifactDataGrant' | 'revokeTablePublishedArtifactDataGrant' | 'runRoutine' | 'searchEntriesAcrossForms' | 'searchMySubmittedEntries' | 'sendMessage' | 'sendSmsTask' | 'summarizeEntries' | 'summarizeFormViewEntries' | 'summarizeTableEntries' | 'summarizeTableViewEntries' | 'updateAccessPolicy' | 'updateCheckinCampaign' | 'updateEntry' | 'updateEntryComment' | 'updateEntryStateFlow' | 'updateEntryViaPost' | 'updateEvaluationSetting' | 'updateExamSetting' | 'updateForm' | 'updateFormSetting' | 'updateFormTheme' | 'updateFormView' | 'updateManuallyCloseRule' | 'updateMemoryNote' | 'updateNotificationRule' | 'updateOpenResult' | 'updateOpensearchQuery' | 'updatePseudoForm' | 'updatePublishedArtifact' | 'updateQuickpaySetting' | 'updateRoutine' | 'updateSmsSignature' | 'updateSmsTask' | 'updateSmsTemplate' | 'updateTable' | 'updateTableEntry' | 'updateTableEntryComment' | 'updateTableEntryViaPost' | 'updateTableView' | 'updateUserFormSetting' | 'updateWheelFortune' | 'uploadEntryAttachment' | 'uploadFormImage' | 'uploadGoodsDeliverableAttachment' | 'uploadImportFile' | 'uploadUserLicenseAttachment' | 'verifyRedirectParams';
|
|
6
|
+
export type OperationId = 'aggregateEntries' | 'aggregateFormViewEntries' | 'aggregateTableEntries' | 'aggregateTableViewEntries' | 'aggregateTradeTransactions' | 'checkFormFieldData' | 'checkTableFieldData' | 'copyForm' | 'countEntries' | 'countEntriesAcrossForms' | 'countFormViewEntries' | 'countTableEntries' | 'countTableViewEntries' | 'createCheckinCampaign' | 'createEmailTask' | 'createEntriesBatch' | 'createEntry' | 'createEntryComment' | 'createEntryImport' | 'createEntryLegacy' | 'createFillFormEntry' | 'createFillPseudoFormEntry' | 'createFillViewEntry' | 'createFolder' | 'createForm' | 'createFormCooperators' | 'createFormView' | 'createFormWebhook' | 'createMemoryNote' | 'createMessageChannel' | 'createNotificationRule' | 'createOpenResult' | 'createOpensearchQuery' | 'createPseudoForm' | 'createPseudoFormsBatch' | 'createRoutine' | 'createSmsSignature' | 'createSmsTask' | 'createSmsTemplate' | 'createTable' | 'createTableEntry' | 'createTableEntryComment' | 'createTableView' | 'createTemplateUsage' | 'createWeixinOauthSession' | 'deleteCheckinCampaign' | 'deleteEntry' | 'deleteEntryComment' | 'deleteForm' | 'deleteFormView' | 'deleteFormWebhook' | 'deleteMemoryNotes' | 'deleteMessageChannel' | 'deleteNotificationRule' | 'deleteOpenResult' | 'deleteOpensearchQuery' | 'deletePseudoForm' | 'deletePseudoFormsBatch' | 'deleteRoutine' | 'deleteSmsSignature' | 'deleteSmsTemplate' | 'deleteTable' | 'deleteTableEntry' | 'deleteTableEntryComment' | 'deleteTableView' | 'estimateEmailTask' | 'estimateEmailTaskResend' | 'estimateMessage' | 'estimateSmsTask' | 'estimateSmsTaskChange' | 'estimateSmsTaskResend' | 'exportRemainingVouchers' | 'getBillingAccount' | 'getCheckinCampaign' | 'getCurrentUser' | 'getEmailTask' | 'getEntry' | 'getEntryImport' | 'getEntryStateFlow' | 'getEntryStats' | 'getEvaluationSetting' | 'getExamSetting' | 'getFieldType' | 'getFillFormPage' | 'getFillPseudoFormPage' | 'getFillViewPage' | 'getFolder' | 'getForm' | 'getFormSetting' | 'getFormView' | 'getManuallyCloseRule' | 'getMemory' | 'getMessage' | 'getMessageChannel' | 'getNotificationRule' | 'getOpenResult' | 'getOpensearchQuery' | 'getPublishedArtifact' | 'getQuickpaySetting' | 'getRoutine' | 'getSmsTask' | 'getTable' | 'getTableEntry' | 'getTableView' | 'getTradeMerchant' | 'getUserFormSetting' | 'getWheelFortune' | 'listArtifactDataSources' | 'listArtifacts' | 'listBillingAccountInvoices' | 'listBillingAccountPaidFeatures' | 'listBillingAccountPaymentHistories' | 'listBillingAccountUsers' | 'listCheckinCampaigns' | 'listContacts' | 'listEmailTaskActivities' | 'listEmailTasks' | 'listEntries' | 'listEntryComments' | 'listExtendedAttributes' | 'listFieldRules' | 'listFieldTypes' | 'listFolders' | 'listFormConditionTriggerableFields' | 'listFormCooperators' | 'listFormPublishedArtifacts' | 'listFormViewEntries' | 'listFormViews' | 'listForms' | 'listMessageChannels' | 'listMessages' | 'listMyFilledForms' | 'listMySubmittedEntries' | 'listNotificationRuleNotifications' | 'listNotificationRules' | 'listOpenResults' | 'listOpensearchQueries' | 'listOpensearchQuerySuggestions' | 'listPseudoForms' | 'listRedirectRules' | 'listRoutineRuns' | 'listRoutines' | 'listSmsAuditStatuses' | 'listSmsSignatures' | 'listSmsTaskActivities' | 'listSmsTasks' | 'listSmsTemplates' | 'listSmtpAccounts' | 'listTableConditionTriggerableFields' | 'listTableEntries' | 'listTableEntryComments' | 'listTablePublishedArtifacts' | 'listTableViewEntries' | 'listTableViews' | 'listTables' | 'listTradePayouts' | 'listTradeRefunds' | 'listTradeTransactions' | 'moveFormToFolder' | 'moveTableToFolder' | 'patchEntriesBatch' | 'pauseRoutine' | 'prepareEntryAttachmentUpload' | 'prepareFormImageUpload' | 'prepareGoodsDeliverableAttachmentUpload' | 'prepareImportFileUpload' | 'previewFormDeletion' | 'previewFormFieldTypeChange' | 'previewTableDeletion' | 'previewTableFieldTypeChange' | 'replaceEntry' | 'replaceTableEntry' | 'resendEmailTask' | 'resendSmsTask' | 'restoreFormPublishedArtifactDataGrant' | 'restoreTablePublishedArtifactDataGrant' | 'resumeRoutine' | 'revokeFormPublishedArtifactDataGrant' | 'revokeTablePublishedArtifactDataGrant' | 'runRoutine' | 'searchEntriesAcrossForms' | 'searchMySubmittedEntries' | 'sendMessage' | 'sendSmsTask' | 'summarizeEntries' | 'summarizeFormViewEntries' | 'summarizeTableEntries' | 'summarizeTableViewEntries' | 'updateAccessPolicy' | 'updateCheckinCampaign' | 'updateEntry' | 'updateEntryComment' | 'updateEntryStateFlow' | 'updateEntryViaPost' | 'updateEvaluationSetting' | 'updateExamSetting' | 'updateForm' | 'updateFormSetting' | 'updateFormTheme' | 'updateFormView' | 'updateManuallyCloseRule' | 'updateMemoryNote' | 'updateNotificationRule' | 'updateOpenResult' | 'updateOpensearchQuery' | 'updatePseudoForm' | 'updatePublishedArtifact' | 'updateQuickpaySetting' | 'updateRoutine' | 'updateSmsSignature' | 'updateSmsTask' | 'updateSmsTemplate' | 'updateTable' | 'updateTableEntry' | 'updateTableEntryComment' | 'updateTableEntryViaPost' | 'updateTableView' | 'updateUserFormSetting' | 'updateWheelFortune' | 'uploadEntryAttachment' | 'uploadFormImage' | 'uploadGoodsDeliverableAttachment' | 'uploadImportFile' | 'uploadUserLicenseAttachment' | 'verifyRedirectParams';
|
|
7
7
|
export declare const OPERATIONS: {
|
|
8
8
|
readonly [id in OperationId]: Operation;
|
|
9
9
|
};
|
|
@@ -597,6 +597,11 @@ export const OPERATIONS = {
|
|
|
597
597
|
{ name: 'token', in: 'path', required: true, schema: { type: 'string' } }
|
|
598
598
|
]
|
|
599
599
|
},
|
|
600
|
+
deleteOpensearchQuery: {
|
|
601
|
+
method: 'DELETE',
|
|
602
|
+
path: '/opensearch/queries/{query_token}',
|
|
603
|
+
parameters: [{ name: 'query_token', in: 'path', required: true, schema: { type: 'string' } }]
|
|
604
|
+
},
|
|
600
605
|
deletePseudoForm: {
|
|
601
606
|
method: 'DELETE',
|
|
602
607
|
path: '/forms/{form_token}/pseudo_forms/{pseudo_form_token}',
|
package/dist/spec.d.ts
CHANGED
|
@@ -135,3 +135,9 @@ export declare function choices(id: OperationId, path: string): readonly string[
|
|
|
135
135
|
* dots and steps into a list's items with `[]`: `fields[].type`.
|
|
136
136
|
*/
|
|
137
137
|
export declare function bodyChoices(id: OperationId, path: string): readonly string[] | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* The keys an object in a JSON body takes, walked to as `bodyChoices` walks:
|
|
140
|
+
* `setting`. For help that has to name every key, which a hand-kept list
|
|
141
|
+
* would name fewer of as the API learns more.
|
|
142
|
+
*/
|
|
143
|
+
export declare function bodyKeys(id: OperationId, path: string): readonly string[] | undefined;
|
package/dist/spec.js
CHANGED
|
@@ -208,6 +208,19 @@ export function choices(id, path) {
|
|
|
208
208
|
export function bodyChoices(id, path) {
|
|
209
209
|
return enumOf(walk(OPERATIONS[id].body?.content['application/json'], path.split('.')), `${id} ${path}`);
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* The keys an object in a JSON body takes, walked to as `bodyChoices` walks:
|
|
213
|
+
* `setting`. For help that has to name every key, which a hand-kept list
|
|
214
|
+
* would name fewer of as the API learns more.
|
|
215
|
+
*/
|
|
216
|
+
export function bodyKeys(id, path) {
|
|
217
|
+
const schema = walk(OPERATIONS[id].body?.content['application/json'], path.split('.'));
|
|
218
|
+
const keys = Object.keys((schema && resolved(schema).properties) ?? {});
|
|
219
|
+
if (keys.length > 0)
|
|
220
|
+
return keys;
|
|
221
|
+
unanswered.push(`${id} ${path}`);
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
211
224
|
/** The schema the steps lead to: each names a property, and `[]` steps into a list's items. */
|
|
212
225
|
function walk(from, steps) {
|
|
213
226
|
let schema = from;
|