@lowdefy/docs-content 6.1.0 → 7.0.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/README.md +1 -0
- package/content/actions/downloadcsv.md +1 -1
- package/content/actions/emailotpsend.md +58 -0
- package/content/actions/emailotpverify.md +79 -0
- package/content/actions/getlocalstorage.md +43 -0
- package/content/actions/link.md +47 -1
- package/content/actions/login.md +25 -5
- package/content/actions/logout.md +7 -5
- package/content/actions/magiclinkverify.md +117 -0
- package/content/actions/pdfmake.md +2 -2
- package/content/actions/posthogalias.md +29 -0
- package/content/actions/posthogcapture.md +49 -0
- package/content/actions/posthogcapturepageleave.md +38 -0
- package/content/actions/posthogfeatureflag.md +50 -0
- package/content/actions/posthoggroup.md +37 -0
- package/content/actions/posthogidentify.md +54 -0
- package/content/actions/posthoginit.md +96 -0
- package/content/actions/posthogoptin.md +29 -0
- package/content/actions/posthogoptout.md +29 -0
- package/content/actions/posthogpageview.md +37 -0
- package/content/actions/posthogreloadfeatureflags.md +47 -0
- package/content/actions/posthogreset.md +28 -0
- package/content/actions/posthogsetpersonproperties.md +36 -0
- package/content/actions/removelocalstorage.md +28 -0
- package/content/actions/resetvalidation.md +5 -3
- package/content/actions/setdarkmode.md +3 -3
- package/content/actions/setglobal.md +2 -0
- package/content/actions/setlocale.md +1 -1
- package/content/actions/setlocalstorage.md +34 -0
- package/content/actions/setstate.md +2 -0
- package/content/actions/validate.md +7 -4
- package/content/adapter-reference/mongodbauthadapter.md +46 -0
- package/content/agents/agent-endpoint-tools.md +24 -0
- package/content/agents/agent-properties.md +13 -3
- package/content/agents/agent-server-hooks.md +1 -1
- package/content/agents/agentchat.md +43 -7
- package/content/agents/agentconversations.md +42 -8
- package/content/agents/agents-introduction.md +107 -0
- package/content/callback-reference/auth0logoutcallback.md +54 -0
- package/content/concepts/ai-agent-docs.md +455 -106
- package/content/concepts/blocks.md +150 -0
- package/content/concepts/connections-and-requests.md +402 -0
- package/content/concepts/custom-html.md +42 -0
- package/content/concepts/custom-styling.md +50 -5
- package/content/concepts/dynamic-page-content.md +309 -0
- package/content/concepts/events-and-actions.md +154 -2
- package/content/concepts/four-primitives.md +31 -0
- package/content/concepts/html-attributes.md +293 -0
- package/content/concepts/i18n.md +8 -3
- package/content/concepts/keyboard-shortcuts.md +2 -2
- package/content/concepts/layout-overview.md +1 -1
- package/content/concepts/logger.md +99 -0
- package/content/concepts/lowdefy-api.md +1319 -0
- package/content/concepts/lowdefy-schema.md +136 -3
- package/content/concepts/menus.md +8 -7
- package/content/concepts/module-authoring.md +76 -5
- package/content/concepts/modules.md +3 -1
- package/content/concepts/notifications.md +180 -0
- package/content/concepts/operators.md +7 -0
- package/content/concepts/page-and-app-state.md +252 -0
- package/content/concepts/page-paths.md +209 -0
- package/content/concepts/theming.md +582 -0
- package/content/connections/aigateway.md +375 -0
- package/content/connections/anthropic.md +169 -2
- package/content/connections/awss3.md +178 -2
- package/content/connections/axioshttp.md +181 -0
- package/content/connections/google.md +169 -2
- package/content/connections/mongodb.md +1014 -3
- package/content/connections/openai-connection.md +169 -2
- package/content/connections/sendgridmail.md +2 -0
- package/content/connections/smtp.md +3 -1
- package/content/connections/treg.md +329 -0
- package/content/container-blocks/affix.md +47 -7
- package/content/container-blocks/alert.md +76 -24
- package/content/container-blocks/badge.md +100 -24
- package/content/container-blocks/box.md +9 -9
- package/content/container-blocks/card.md +132 -27
- package/content/container-blocks/carousel.md +60 -7
- package/content/container-blocks/collapse.md +153 -9
- package/content/container-blocks/configprovider.md +35 -13
- package/content/container-blocks/confirmmodal.md +69 -23
- package/content/container-blocks/content.md +62 -98
- package/content/container-blocks/descriptions.md +45 -4
- package/content/container-blocks/drawer.md +139 -28
- package/content/container-blocks/dropdownmenu.md +119 -31
- package/content/container-blocks/flex.md +40 -62
- package/content/container-blocks/footer.md +15 -11
- package/content/container-blocks/googlemapsheatmap.md +1 -1
- package/content/container-blocks/googlemapsscript.md +2 -2
- package/content/container-blocks/header.md +71 -36
- package/content/container-blocks/label.md +34 -7
- package/content/container-blocks/layout.md +52 -34
- package/content/container-blocks/masonry.md +17 -71
- package/content/container-blocks/mobilemenu.md +131 -88
- package/content/container-blocks/modal.md +161 -26
- package/content/container-blocks/pageheadermenu.md +138 -31
- package/content/container-blocks/pagesidebarlayout.md +230 -27
- package/content/container-blocks/pagesidermenu.md +153 -43
- package/content/container-blocks/popover.md +34 -31
- package/content/container-blocks/result.md +32 -21
- package/content/container-blocks/sider.md +85 -122
- package/content/container-blocks/span.md +7 -7
- package/content/container-blocks/spinner.md +3 -3
- package/content/container-blocks/splitter.md +150 -68
- package/content/container-blocks/tabs.md +64 -12
- package/content/container-blocks/tooltip.md +22 -46
- package/content/container-blocks/watermark.md +22 -4
- package/content/controls/parallel_for.md +21 -2
- package/content/controls/reject.md +24 -3
- package/content/controls/return.md +17 -1
- package/content/controls/throw.md +1 -0
- package/content/controls/try.md +4 -2
- package/content/controls/while.md +46 -0
- package/content/deployment/deployment-environments.md +10 -7
- package/content/deployment/docker.md +22 -7
- package/content/deployment/node-server.md +4 -0
- package/content/deployment/vercel.md +17 -6
- package/content/display-blocks/aggrid.md +33 -16
- package/content/display-blocks/anchor.md +16 -15
- package/content/display-blocks/avatar.md +57 -37
- package/content/display-blocks/breadcrumb.md +70 -21
- package/content/display-blocks/button.md +93 -19
- package/content/display-blocks/calendar.md +12 -0
- package/content/display-blocks/clickablehtml.md +239 -0
- package/content/display-blocks/dangeroushtml.md +1 -1
- package/content/display-blocks/difflist.md +1 -1
- package/content/display-blocks/difftimeline.md +1 -1
- package/content/display-blocks/divider.md +64 -3
- package/content/display-blocks/dropdownbutton.md +81 -30
- package/content/display-blocks/echart.md +35 -1
- package/content/display-blocks/eventlog.md +363 -0
- package/content/display-blocks/floatbutton.md +129 -42
- package/content/display-blocks/html.md +61 -1
- package/content/display-blocks/icon.md +250 -67
- package/content/display-blocks/img.md +2 -2
- package/content/display-blocks/menu.md +146 -73
- package/content/display-blocks/message.md +38 -124
- package/content/display-blocks/notification.md +94 -222
- package/content/display-blocks/paragraph.md +59 -9
- package/content/display-blocks/pollingtimer.md +263 -0
- package/content/display-blocks/progress.md +96 -17
- package/content/display-blocks/qrcode.md +19 -4
- package/content/display-blocks/s3download.md +1 -1
- package/content/display-blocks/search.md +19 -9
- package/content/display-blocks/skeletonbutton.md +1 -0
- package/content/display-blocks/skeletoninput.md +1 -0
- package/content/display-blocks/statistic.md +75 -17
- package/content/display-blocks/steps.md +58 -25
- package/content/display-blocks/table.md +2527 -0
- package/content/display-blocks/tablelight.md +621 -0
- package/content/display-blocks/tag.md +102 -17
- package/content/display-blocks/title.md +50 -11
- package/content/display-blocks/tour.md +33 -23
- package/content/input-blocks/autocomplete.md +81 -9
- package/content/input-blocks/buttonselector.md +45 -8
- package/content/input-blocks/captcha.md +40 -0
- package/content/input-blocks/checkboxselector.md +97 -7
- package/content/input-blocks/checkboxswitch.md +33 -3
- package/content/input-blocks/colorselector.md +63 -14
- package/content/input-blocks/daterangeselector.md +165 -45
- package/content/input-blocks/dateselector.md +139 -41
- package/content/input-blocks/datetimeselector.md +158 -49
- package/content/input-blocks/inputgallery.md +3 -3
- package/content/input-blocks/intentinput.md +207 -0
- package/content/input-blocks/monthselector.md +120 -52
- package/content/input-blocks/multipleselector.md +150 -39
- package/content/input-blocks/numberinput.md +98 -12
- package/content/input-blocks/pagination.md +70 -14
- package/content/input-blocks/paragraphinput.md +51 -37
- package/content/input-blocks/passwordinput.md +60 -6
- package/content/input-blocks/phonenumberinput.md +59 -26
- package/content/input-blocks/placesautocomplete.md +319 -0
- package/content/input-blocks/radioselector.md +83 -7
- package/content/input-blocks/ratingslider.md +57 -26
- package/content/input-blocks/s3uploadbutton.md +24 -24
- package/content/input-blocks/s3uploaddragger.md +3 -3
- package/content/input-blocks/s3uploadphoto.md +5 -5
- package/content/input-blocks/segmentedselector.md +72 -32
- package/content/input-blocks/selector.md +109 -21
- package/content/input-blocks/switch.md +65 -17
- package/content/input-blocks/tableinput.md +445 -0
- package/content/input-blocks/tagmultipleselector.md +114 -0
- package/content/input-blocks/tagselector.md +114 -0
- package/content/input-blocks/textarea.md +32 -3
- package/content/input-blocks/textinput.md +70 -29
- package/content/input-blocks/tiptapinput.md +1 -1
- package/content/input-blocks/tiptapmentioninput.md +2 -2
- package/content/input-blocks/titleinput.md +39 -12
- package/content/input-blocks/treeinput.md +49 -25
- package/content/input-blocks/treemultipleselector.md +127 -10
- package/content/input-blocks/treeselector.md +97 -9
- package/content/input-blocks/upload.md +64 -15
- package/content/input-blocks/uploaddragger.md +17 -1
- package/content/input-blocks/uploadphoto.md +18 -1
- package/content/input-blocks/weekselector.md +120 -55
- package/content/learn/introduction.md +27 -0
- package/content/learn/quickstart.md +53 -0
- package/content/learn/showcase.md +8 -0
- package/content/list-blocks/controlledlist.md +24 -15
- package/content/list-blocks/list.md +11 -11
- package/content/list-blocks/masonrylist.md +7 -34
- package/content/migration/auth-upgrade.md +337 -0
- package/content/migration/upgrade-guide.md +1 -0
- package/content/migration/v3-to-v4.md +417 -0
- package/content/migration/v6-to-v7.md +620 -0
- package/content/operators/_agent.md +155 -0
- package/content/operators/_app.md +2 -1
- package/content/operators/_array.md +122 -1
- package/content/operators/_build.md +1 -0
- package/content/operators/_credential.md +57 -0
- package/content/operators/_cron.md +292 -0
- package/content/operators/_date.md +2 -0
- package/content/operators/_error.md +24 -1
- package/content/operators/_get.md +6 -6
- package/content/operators/_hmac.md +78 -0
- package/content/operators/_js.md +2 -1
- package/content/operators/_location.md +1 -1
- package/content/operators/_media.md +13 -0
- package/content/operators/_module.md +56 -2
- package/content/operators/_operator.md +17 -3
- package/content/operators/_path_params.md +82 -0
- package/content/operators/_ref.md +258 -0
- package/content/operators/_request.md +1 -1
- package/content/operators/_request_details.md +6 -0
- package/content/operators/_type.md +14 -3
- package/content/operators/_url_query.md +2 -0
- package/content/operators/_user.md +3 -3
- package/content/plugins/plugins-actions.md +10 -0
- package/content/plugins/plugins-connections.md +25 -0
- package/content/plugins/plugins-dev.md +66 -0
- package/content/plugins/plugins-icon-sets.md +267 -0
- package/content/plugins/plugins-introduction.md +27 -1
- package/content/plugins/plugins.md +19 -0
- package/content/plugins/posthog.md +359 -0
- package/content/provider-reference/auth-js-providers.md +107 -0
- package/content/provider-reference/openidconnectprovider.md +44 -0
- package/content/recipes/recipes.md +16 -0
- package/content/reference/actions-reference.md +31 -0
- package/content/reference/blocks-reference.md +35 -0
- package/content/reference/cli.md +403 -0
- package/content/reference/connections-reference.md +23 -0
- package/content/reference/operators-reference.md +47 -0
- package/content/reference/reference.md +16 -0
- package/content/reference/schema-reference.md +12 -0
- package/content/testing/config-tests.md +677 -0
- package/content/testing/e2e-configuration.md +31 -1
- package/content/testing/e2e-getting-started.md +1 -1
- package/content/testing/e2e-introduction.md +1 -1
- package/content/testing/e2e-writing-tests.md +12 -1
- package/content/testing/explore-pull-request.md +136 -0
- package/content/testing/journey-data-sets.md +326 -0
- package/content/tutorial/tutorial-actions-operators.md +2 -2
- package/content/tutorial/tutorial-add-blocks.md +2 -2
- package/content/tutorial/tutorial-create-page.md +48 -2
- package/content/tutorial/tutorial-display-data-page.md +3 -3
- package/content/tutorial/tutorial-requests-api.md +155 -0
- package/content/tutorial/tutorial-requests-sql.md +153 -0
- package/content/tutorial/tutorial-start.md +66 -1
- package/content/user-authentication/auth-configuration.md +267 -0
- package/content/user-authentication/auth-providers.md +24 -0
- package/content/user-authentication/auth-steps.md +141 -0
- package/content/user-authentication/login-and-logout.md +160 -8
- package/content/user-authentication/mcp-oauth.md +424 -0
- package/content/user-authentication/organizations.md +246 -0
- package/content/user-authentication/protected-pages-apis.md +97 -0
- package/content/user-authentication/roles.md +49 -0
- package/content/user-authentication/two-factor.md +229 -0
- package/content/user-authentication/user-object.md +58 -0
- package/content/user-authentication/users-introduction.md +8 -0
- package/content/websockets/websocket-publish.md +105 -0
- package/content/websockets/websocket-subscriptions.md +136 -0
- package/content/websockets/websockets-introduction.md +101 -0
- package/hazards.json +56 -0
- package/index.json +3458 -14
- package/package.json +10 -1
- package/scripts/extractAgentDocs.js +41 -30
- package/scripts/hashDocSources.js +38 -0
- package/scripts/isRedirectPage.js +26 -0
- package/scripts/recordSourceHashes.js +97 -0
- package/scripts/resolvePageSections.js +42 -0
- package/scripts/sectionKind.js +27 -0
- package/content/concepts/cli.md +0 -223
- package/content/other/introduction.md +0 -39
- package/content/other/next-auth-providers.md +0 -3
- /package/content/{other → actions}/updatesession.md +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# _agent
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
(key: 'id' | 'conversationId'): string | null
|
|
5
|
+
(key: 'files'): { key: string, filename: string, mediaType: string }[] | null
|
|
6
|
+
(all: boolean): { id: string, conversationId: string | null, files: object[] } | null
|
|
7
|
+
(arguments: {
|
|
8
|
+
all?: boolean,
|
|
9
|
+
key?: 'id' | 'conversationId' | 'files',
|
|
10
|
+
default?: any,
|
|
11
|
+
}): any
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The `_agent` operator returns the [agent](/agents-introduction) that called the endpoint. Use it in an [endpoint tool](/agent-endpoint-tools) to tell agent work apart from a person's, for example to record who made a change.
|
|
15
|
+
|
|
16
|
+
- `_agent: id` returns the agent's `id` in the `agents` section.
|
|
17
|
+
- `_agent: conversationId` returns the id of the chat conversation the agent runs in. It is `null` for an agent run by a [`CallAgent`](/api) routine step, which has no conversation.
|
|
18
|
+
- `_agent: files` returns the files the person attached in the chat, as `[{ key, filename, mediaType }]`: every file the [`AgentChat`](/AgentChat) block uploaded to storage, from every message of the conversation the chat request carried, in message order. `key` is the file's storage key. Files pasted inline (no upload policy) have no key and are left out. It is `[]` for an agent run by a `CallAgent` step.
|
|
19
|
+
- `_agent: true` returns all three as `{ id, conversationId, files }`.
|
|
20
|
+
|
|
21
|
+
The model sees each attached file with its name (`Attached file: screenshot.png`), so it can pass the name to a tool. Have the tool take file names and look each one up in `_agent: files`, never a storage key from the tool's input: the model can then only reach files of its own conversation. The files come from the person's own chat request, so the browser decides what they hold; before reading one, check that its key is one the caller may read, for example that it starts with the prefix the upload policy gives the caller's uploads.
|
|
22
|
+
|
|
23
|
+
The value is set by Lowdefy when an agent calls the endpoint as a tool or a hook. Endpoints that endpoint calls in turn, through a `CallApi` step (including a `detached` one) or a connection's `callApi`, see the same agent. Nothing in the tool's payload or the chat request can set or change it, so the model cannot claim to be another agent or hide that it made the call.
|
|
24
|
+
|
|
25
|
+
On any call that did not come from an agent (a page request or `CallAPI` action, an MCP tool call, a scheduled or webhook run), `_agent` returns `null`, and reading a key returns `null` or the `default` when one is given. It never throws.
|
|
26
|
+
|
|
27
|
+
Tools that a sub-agent calls see the agent the chat or `CallAgent` step runs, not the sub-agent.
|
|
28
|
+
|
|
29
|
+
#### Arguments
|
|
30
|
+
|
|
31
|
+
###### string
|
|
32
|
+
The field of the calling agent to return: `id`, `conversationId` or `files`.
|
|
33
|
+
|
|
34
|
+
###### boolean
|
|
35
|
+
If `true`, returns the calling agent as `{ id, conversationId, files }`, or `null` when no agent called the endpoint.
|
|
36
|
+
|
|
37
|
+
###### object
|
|
38
|
+
- `key: string`: The field to return, `id`, `conversationId` or `files`.
|
|
39
|
+
- `default: any`: A value to return when no agent called the endpoint.
|
|
40
|
+
- `all: boolean`: If `true`, returns the calling agent as `{ id, conversationId, files }`.
|
|
41
|
+
|
|
42
|
+
#### Examples
|
|
43
|
+
|
|
44
|
+
###### Record whether an agent or a person made a change:
|
|
45
|
+
```yaml
|
|
46
|
+
api:
|
|
47
|
+
- id: update-ticket
|
|
48
|
+
type: Api
|
|
49
|
+
description: Update a support ticket's status.
|
|
50
|
+
payloadSchema:
|
|
51
|
+
type: object
|
|
52
|
+
properties:
|
|
53
|
+
ticketId:
|
|
54
|
+
type: string
|
|
55
|
+
status:
|
|
56
|
+
type: string
|
|
57
|
+
routine:
|
|
58
|
+
- id: update
|
|
59
|
+
type: MongoDBUpdateOne
|
|
60
|
+
connectionId: tickets
|
|
61
|
+
properties:
|
|
62
|
+
filter:
|
|
63
|
+
_id:
|
|
64
|
+
_payload: ticketId
|
|
65
|
+
update:
|
|
66
|
+
$set:
|
|
67
|
+
status:
|
|
68
|
+
_payload: status
|
|
69
|
+
updated:
|
|
70
|
+
userId:
|
|
71
|
+
_user: id
|
|
72
|
+
agentId:
|
|
73
|
+
_agent: id
|
|
74
|
+
conversationId:
|
|
75
|
+
_agent: conversationId
|
|
76
|
+
```
|
|
77
|
+
When the `support_agent` agent calls the endpoint from a chat, `agentId` is `support_agent` and `conversationId` is the chat's conversation id. When a person calls it from a page, both are `null`.
|
|
78
|
+
|
|
79
|
+
###### Attach a file from the chat by its name:
|
|
80
|
+
```yaml
|
|
81
|
+
api:
|
|
82
|
+
- id: attach-chat-file
|
|
83
|
+
type: Api
|
|
84
|
+
description: Attach a file from this chat to a ticket. Pass the file's name as it was attached.
|
|
85
|
+
payloadSchema:
|
|
86
|
+
type: object
|
|
87
|
+
properties:
|
|
88
|
+
ticketId:
|
|
89
|
+
type: string
|
|
90
|
+
filename:
|
|
91
|
+
type: string
|
|
92
|
+
routine:
|
|
93
|
+
- :set_state:
|
|
94
|
+
file:
|
|
95
|
+
_array.find:
|
|
96
|
+
on:
|
|
97
|
+
_agent:
|
|
98
|
+
key: files
|
|
99
|
+
default: []
|
|
100
|
+
callback:
|
|
101
|
+
_function:
|
|
102
|
+
__eq:
|
|
103
|
+
- __args: 0.filename
|
|
104
|
+
- _payload: filename
|
|
105
|
+
- :if:
|
|
106
|
+
_not:
|
|
107
|
+
_string.startsWith:
|
|
108
|
+
- _if_none:
|
|
109
|
+
- _state: file.key
|
|
110
|
+
- ''
|
|
111
|
+
- _string.concat:
|
|
112
|
+
- uploads/
|
|
113
|
+
- _user: id
|
|
114
|
+
- /
|
|
115
|
+
:then:
|
|
116
|
+
- :reject: No file of yours by that name in this chat.
|
|
117
|
+
- id: attach
|
|
118
|
+
type: MongoDBUpdateOne
|
|
119
|
+
connectionId: tickets
|
|
120
|
+
properties:
|
|
121
|
+
filter:
|
|
122
|
+
_id:
|
|
123
|
+
_payload: ticketId
|
|
124
|
+
update:
|
|
125
|
+
$push:
|
|
126
|
+
files:
|
|
127
|
+
key:
|
|
128
|
+
_state: file.key
|
|
129
|
+
filename:
|
|
130
|
+
_state: file.filename
|
|
131
|
+
mediaType:
|
|
132
|
+
_state: file.mediaType
|
|
133
|
+
```
|
|
134
|
+
The model names the file; the key comes from the chat request, and the endpoint checks that it is one of the caller's uploads.
|
|
135
|
+
|
|
136
|
+
###### Branch on whether an agent called the endpoint:
|
|
137
|
+
```yaml
|
|
138
|
+
routine:
|
|
139
|
+
- :if:
|
|
140
|
+
_ne:
|
|
141
|
+
- _agent: true
|
|
142
|
+
- null
|
|
143
|
+
:then:
|
|
144
|
+
- :return:
|
|
145
|
+
message: Changes made by agents are held for review.
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
###### Use a default when no agent called the endpoint:
|
|
149
|
+
```yaml
|
|
150
|
+
source:
|
|
151
|
+
_agent:
|
|
152
|
+
key: id
|
|
153
|
+
default: person
|
|
154
|
+
```
|
|
155
|
+
Returns: The agent id, or `person` when a person called the endpoint.
|
|
@@ -21,6 +21,7 @@ The metadata object has the following keys:
|
|
|
21
21
|
- `license`: From the root `license` field. Free-form string.
|
|
22
22
|
- `lowdefyVersion`: From the root `lowdefy` field — the framework version the app targets.
|
|
23
23
|
- `gitSha`: The build's git commit SHA. Resolved at build time in three steps: the `LOWDEFY_GIT_SHA` environment variable (when set non-empty) wins; otherwise the build runs `git rev-parse HEAD`; if both fail (no `.git`, no `git` binary, env unset), `gitSha` is `null`. The build does not error in any case. Build-time and runtime reads return the same value.
|
|
24
|
+
- `buildId`: A random identifier generated by each build, so two builds never share one. The production server sends it with every page config fetched during in-app navigation, and the client bundle carries the id of the build it came from; when the two differ the tab reloads once to pick up the new bundle instead of failing on functions or plugins it does not have. Useful in config as a cache-busting value that changes on every deploy.
|
|
24
25
|
|
|
25
26
|
Missing root fields yield `null` — every key in the metadata is always present. The sole exception is `slug`: referencing it fails the build when it is not set (see above).
|
|
26
27
|
|
|
@@ -85,7 +86,7 @@ _app: true
|
|
|
85
86
|
_app:
|
|
86
87
|
all: true
|
|
87
88
|
```
|
|
88
|
-
Returns: The full `{ slug, name, version, description, license, lowdefyVersion, gitSha }` object.
|
|
89
|
+
Returns: The full `{ slug, name, version, description, license, lowdefyVersion, gitSha, buildId }` object.
|
|
89
90
|
|
|
90
91
|
###### Return a default value if `gitSha` was not captured:
|
|
91
92
|
```yaml
|
|
@@ -6,6 +6,21 @@ The `_array` operator can be used to run javascript [`Array`](https://developer.
|
|
|
6
6
|
|
|
7
7
|
# Operator methods:
|
|
8
8
|
|
|
9
|
+
## _array.at
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
(arguments: {
|
|
13
|
+
on: any[],
|
|
14
|
+
index: number
|
|
15
|
+
}): any
|
|
16
|
+
(arguments: [
|
|
17
|
+
on: any[],
|
|
18
|
+
index: number
|
|
19
|
+
]): any
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The `_array.at` method returns [the item at an index](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at). A negative index counts back from the end of the array, so `-1` returns the last item.
|
|
23
|
+
|
|
9
24
|
## _array.concat
|
|
10
25
|
|
|
11
26
|
```
|
|
@@ -112,6 +127,36 @@ The `_array.find` method returns the value of the [first element in the provided
|
|
|
112
127
|
|
|
113
128
|
The `_array.findIndex` method returns [the index of the first element in the array that satisfies the provided testing function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex). Otherwise, it returns -1, indicating that no element passed the test.
|
|
114
129
|
|
|
130
|
+
## _array.findLast
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
(arguments: {
|
|
134
|
+
on: any[],
|
|
135
|
+
callback: function,
|
|
136
|
+
}): any
|
|
137
|
+
(arguments: [
|
|
138
|
+
on: any[],
|
|
139
|
+
callback: function,
|
|
140
|
+
]): any
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The `_array.findLast` method returns [the last element in the array that satisfies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast) the provided testing function.
|
|
144
|
+
|
|
145
|
+
## _array.findLastIndex
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
(arguments: {
|
|
149
|
+
on: any[],
|
|
150
|
+
callback: function,
|
|
151
|
+
}): number
|
|
152
|
+
(arguments: [
|
|
153
|
+
on: any[],
|
|
154
|
+
callback: function,
|
|
155
|
+
]): number
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The `_array.findLastIndex` method returns [the index of the last element in the array that satisfies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex) the provided testing function, or `-1` if no element passes.
|
|
159
|
+
|
|
115
160
|
## _array.flat
|
|
116
161
|
|
|
117
162
|
```
|
|
@@ -121,6 +166,36 @@ The `_array.findIndex` method returns [the index of the first element in the arr
|
|
|
121
166
|
|
|
122
167
|
The `_array.flat` method returns a array with all [sub-array elements concatenated into it recursively](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) up to the specified `depth`.
|
|
123
168
|
|
|
169
|
+
## _array.flatMap
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
(arguments: {
|
|
173
|
+
on: any[],
|
|
174
|
+
callback: function,
|
|
175
|
+
}): any[]
|
|
176
|
+
(arguments: [
|
|
177
|
+
on: any[],
|
|
178
|
+
callback: function,
|
|
179
|
+
]): any[]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The `_array.flatMap` method [maps each element with the callback and flattens the result](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap) by one level.
|
|
183
|
+
|
|
184
|
+
## _array.from
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
(arguments: {
|
|
188
|
+
on: any[] | string | { length: number },
|
|
189
|
+
callback?: function,
|
|
190
|
+
}): any[]
|
|
191
|
+
(arguments: [
|
|
192
|
+
on: any[] | string | { length: number },
|
|
193
|
+
callback?: function,
|
|
194
|
+
]): any[]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The `_array.from` method [creates a new array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) from an array, a string, or an object with a `length`. Use `on: { length: n }` to create an array with `n` items, and the optional `callback` (called with the item and its index) to set each item, for example `{ _function: { __args: 1 } }` creates `[0, 1, ..., n - 1]`. Combine it with `_array.fill` to create an array of `n` copies of a value.
|
|
198
|
+
|
|
124
199
|
## _array.includes
|
|
125
200
|
|
|
126
201
|
```
|
|
@@ -180,6 +255,29 @@ The `_array.length` method returns the [number of elements](https://developer.mo
|
|
|
180
255
|
|
|
181
256
|
The `_array.map` method returns an array populated with the results of [calling a provided function on every element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) in the provided array.
|
|
182
257
|
|
|
258
|
+
## _array.pop
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
(array: any[]): any[]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The `_array.pop` method returns the array [with its last item removed](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop). Unlike the JavaScript method, it returns the changed array, not the removed item; use `_array.at` with index `-1` to get the last item.
|
|
265
|
+
|
|
266
|
+
## _array.push
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
(arguments: {
|
|
270
|
+
on: any[],
|
|
271
|
+
items: any[]
|
|
272
|
+
}): any[]
|
|
273
|
+
(arguments: [
|
|
274
|
+
on: any[],
|
|
275
|
+
...items: any[]
|
|
276
|
+
]): any[]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The `_array.push` method returns the array [with the items added to the end](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push). Unlike the JavaScript method, it returns the changed array, not its new length.
|
|
280
|
+
|
|
183
281
|
## _array.reduce
|
|
184
282
|
|
|
185
283
|
```
|
|
@@ -271,6 +369,14 @@ The `_array.reduceRight` method [applies a function against an accumulator and e
|
|
|
271
369
|
|
|
272
370
|
The `_array.reverse` method [reverses](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) an array.
|
|
273
371
|
|
|
372
|
+
## _array.shift
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
(array: any[]): any[]
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
The `_array.shift` method returns the array [with its first item removed](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift). Unlike the JavaScript method, it returns the changed array, not the removed item; use `_array.at` with index `0` to get the first item.
|
|
379
|
+
|
|
274
380
|
## _array.slice
|
|
275
381
|
|
|
276
382
|
```
|
|
@@ -328,4 +434,19 @@ The `_array.sort` method [sorts](https://developer.mozilla.org/en-US/docs/Web/Ja
|
|
|
328
434
|
}): number
|
|
329
435
|
```
|
|
330
436
|
|
|
331
|
-
The `_array.
|
|
437
|
+
The `_array.splice` method [changes the contents of an array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) by removing or replacing existing elements and/or adding new elements.
|
|
438
|
+
|
|
439
|
+
## _array.unshift
|
|
440
|
+
|
|
441
|
+
```
|
|
442
|
+
(arguments: {
|
|
443
|
+
on: any[],
|
|
444
|
+
items: any[]
|
|
445
|
+
}): any[]
|
|
446
|
+
(arguments: [
|
|
447
|
+
on: any[],
|
|
448
|
+
...items: any[]
|
|
449
|
+
]): any[]
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
The `_array.unshift` method returns the array [with the items added to the start](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift). Unlike the JavaScript method, it returns the changed array, not its new length.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# _credential
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
(value: any): any
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The `_credential` operator marks a value a routine makes at runtime as a credential, and returns it unchanged. Use it for a new API key, a token, or a secret derived with [`_hmac`](/_hmac): values the server does not hold as a [`_secret`](/_secret), so the log scrub would not know them.
|
|
8
|
+
|
|
9
|
+
For the rest of the request, every server log line and Sentry event shows `[REDACTED]` in place of the value, including the debug lines that print `:set_state`, `:return`, step results and an error's `received`, and the request's Sentry transaction, which is sent after the response. An endpoint the routine calls through a `CallApi` step with `detached: true` runs as a new request, and its logs scrub the values the dispatcher marked before the call too. The routine still uses the real value, and the caller still gets it. Marked values are scrubbed on the development server too, which otherwise logs secrets in full.
|
|
10
|
+
|
|
11
|
+
Every string in the value is marked, so one `_credential` can wrap an object holding several. Strings shorter than 8 characters are not scrubbed, as with secrets. Wrap the value where it is made: a line logged before it is marked still holds it.
|
|
12
|
+
|
|
13
|
+
#### Arguments
|
|
14
|
+
|
|
15
|
+
###### any
|
|
16
|
+
The value to mark and return.
|
|
17
|
+
|
|
18
|
+
#### Examples
|
|
19
|
+
|
|
20
|
+
###### Return a new API key once, without it reaching the logs:
|
|
21
|
+
```yaml
|
|
22
|
+
- ':set_state':
|
|
23
|
+
key:
|
|
24
|
+
_credential:
|
|
25
|
+
_string.concat:
|
|
26
|
+
- sk_
|
|
27
|
+
- _uuid: true
|
|
28
|
+
- id: save_key_hash
|
|
29
|
+
type: MongoDBUpdateOne
|
|
30
|
+
connectionId: apps
|
|
31
|
+
properties:
|
|
32
|
+
filter:
|
|
33
|
+
_id:
|
|
34
|
+
_payload: app_id
|
|
35
|
+
update:
|
|
36
|
+
$set:
|
|
37
|
+
key_hash:
|
|
38
|
+
_hash.sha256:
|
|
39
|
+
_state: key
|
|
40
|
+
- ':return':
|
|
41
|
+
key:
|
|
42
|
+
_state: key
|
|
43
|
+
```
|
|
44
|
+
Returns: `{ key: "sk_..." }` to the caller. The debug lines for `:set_state` and `:return` show `[REDACTED]`.
|
|
45
|
+
|
|
46
|
+
###### Mark a secret derived from a root secret:
|
|
47
|
+
```yaml
|
|
48
|
+
_credential:
|
|
49
|
+
_hmac.sha256:
|
|
50
|
+
key:
|
|
51
|
+
_secret: SUPPORT_ROOT_SECRET
|
|
52
|
+
data:
|
|
53
|
+
_string.concat:
|
|
54
|
+
- 'app:'
|
|
55
|
+
- _payload: app_id
|
|
56
|
+
```
|
|
57
|
+
Returns: The hex HMAC, which the server logs as `[REDACTED]`.
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# _cron
|
|
2
|
+
|
|
3
|
+
The `_cron` operator works with [cron expressions](https://en.wikipedia.org/wiki/Cron#CRON_expression). It can calculate the next and previous occurrences of a schedule, describe a schedule in a human readable sentence, test if an expression is valid, and return the parsed fields of an expression.
|
|
4
|
+
|
|
5
|
+
A cron expression has five fields, `minute hour day-of-month month day-of-week`, and an optional leading seconds field. For example, `0 9 * * 1` is "At 09:00 AM, only on Monday".
|
|
6
|
+
|
|
7
|
+
The supported syntax is:
|
|
8
|
+
- `*` for any value, `?` as an alias of `*`, lists like `1,3,5`, ranges like `1-5` and steps like `*/15` or `0-30/10`.
|
|
9
|
+
- Month names (`JAN` to `DEC`) and day names (`SUN` to `SAT`). Day of week `0` and `7` are both Sunday.
|
|
10
|
+
- `L` for the last day of the month in the day-of-month field, and `5L` for the last Friday of the month in the day-of-week field.
|
|
11
|
+
- `#` for the nth weekday of the month, like `1#2` for the second Monday.
|
|
12
|
+
- The aliases `@yearly`, `@annually`, `@monthly`, `@weekly`, `@daily`, `@hourly`, `@minutely`, `@secondly`, `@weekdays` and `@weekends`.
|
|
13
|
+
|
|
14
|
+
The Jenkins style `H` hash token is not supported, since it would pick a different random time each time the operator is evaluated. `W` (nearest weekday), a year field and `@reboot` are not supported either. A blank expression (`""` or only whitespace) is treated as a missing expression.
|
|
15
|
+
|
|
16
|
+
When both day-of-month and day-of-week are restricted, an occurrence matches either of them, as in standard cron.
|
|
17
|
+
|
|
18
|
+
> `_cron` accepts a wider grammar than the `schedules` of [scheduled endpoints](/api#scheduled-endpoints-cron), which only accept five numeric fields and can not restrict day-of-month and day-of-week together. An expression that `_cron.validate` accepts is not always a valid endpoint schedule.
|
|
19
|
+
|
|
20
|
+
Every method takes the cron expression as a string, or as the `expression` property of an object when more arguments are needed:
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
_cron.next: 0 9 * * 1
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
_cron.next:
|
|
28
|
+
expression: 0 9 * * 1
|
|
29
|
+
timezone: Europe/London
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This operator is provided by the `@lowdefy/operators-cron` plugin package.
|
|
33
|
+
|
|
34
|
+
# Operator methods:
|
|
35
|
+
|
|
36
|
+
## _cron.next
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
(expression: string): date
|
|
40
|
+
(arguments: {
|
|
41
|
+
expression: string,
|
|
42
|
+
from?: date | string,
|
|
43
|
+
timezone?: string,
|
|
44
|
+
count?: integer
|
|
45
|
+
}): date | date[]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The `_cron.next` method returns the next occurrence of a cron expression after the `from` date. An occurrence exactly at `from` is not included. When `count` is greater than 1, an array of the next `count` occurrences is returned, in chronological order.
|
|
49
|
+
|
|
50
|
+
On a daylight saving time change in the evaluated `timezone`, a time that is skipped when the clocks go forward runs an hour later, and a time that repeats when the clocks go back runs once, at its first occurrence. Schedules that run every hour or more often run through both repeated hours.
|
|
51
|
+
|
|
52
|
+
An error is thrown if the cron expression is missing, is invalid, or never occurs (like `0 0 31 2 *`).
|
|
53
|
+
|
|
54
|
+
#### Arguments
|
|
55
|
+
|
|
56
|
+
###### expression
|
|
57
|
+
The cron expression, for example `0 9 * * 1`. Required.
|
|
58
|
+
|
|
59
|
+
###### from
|
|
60
|
+
The date to calculate the next occurrence from, as a date or an ISO 8601 date string like `2024-01-01` or `2024-01-01T09:00:00Z`. Other date strings are not accepted, since JavaScript engines parse them differently. Defaults to the current date and time.
|
|
61
|
+
|
|
62
|
+
###### timezone
|
|
63
|
+
The [IANA timezone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), for example `Europe/London`, that the cron expression is evaluated in. Defaults to the timezone of the environment that evaluates the operator.
|
|
64
|
+
|
|
65
|
+
###### count
|
|
66
|
+
The number of occurrences to return, an integer from 1 to 1000. A `count` of 1 returns a single date, a `count` greater than 1 returns an array of dates. Defaults to 1.
|
|
67
|
+
|
|
68
|
+
#### Examples
|
|
69
|
+
|
|
70
|
+
###### Next occurrence:
|
|
71
|
+
```yaml
|
|
72
|
+
_cron.next: 0 9 * * 1
|
|
73
|
+
```
|
|
74
|
+
Returns: The date of the next Monday at 09:00.
|
|
75
|
+
|
|
76
|
+
###### Next occurrence in a timezone, from a given date:
|
|
77
|
+
```yaml
|
|
78
|
+
_cron.next:
|
|
79
|
+
expression: 0 9 * * 1
|
|
80
|
+
from:
|
|
81
|
+
_date: 2024-01-01T00:00:00.000Z
|
|
82
|
+
timezone: UTC
|
|
83
|
+
```
|
|
84
|
+
Returns: `2024-01-01T09:00:00.000Z`
|
|
85
|
+
|
|
86
|
+
###### The next three occurrences:
|
|
87
|
+
```yaml
|
|
88
|
+
_cron.next:
|
|
89
|
+
expression: 0 9 * * 1
|
|
90
|
+
from:
|
|
91
|
+
_date: 2024-01-01T00:00:00.000Z
|
|
92
|
+
timezone: UTC
|
|
93
|
+
count: 3
|
|
94
|
+
```
|
|
95
|
+
Returns: `[2024-01-01T09:00:00.000Z, 2024-01-08T09:00:00.000Z, 2024-01-15T09:00:00.000Z]`
|
|
96
|
+
|
|
97
|
+
## _cron.previous
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
(expression: string): date
|
|
101
|
+
(arguments: {
|
|
102
|
+
expression: string,
|
|
103
|
+
from?: date | string,
|
|
104
|
+
timezone?: string,
|
|
105
|
+
count?: integer
|
|
106
|
+
}): date | date[]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `_cron.previous` method returns the previous occurrence of a cron expression before the `from` date. An occurrence exactly at `from` is not included. When `count` is greater than 1, an array of the previous `count` occurrences is returned, most recent first.
|
|
110
|
+
|
|
111
|
+
An error is thrown if the cron expression is missing, is invalid, or never occurs (like `0 0 31 2 *`).
|
|
112
|
+
|
|
113
|
+
#### Arguments
|
|
114
|
+
|
|
115
|
+
###### expression
|
|
116
|
+
The cron expression, for example `0 9 * * 1`. Required.
|
|
117
|
+
|
|
118
|
+
###### from
|
|
119
|
+
The date to calculate the previous occurrence from, as a date or an ISO 8601 date string like `2024-01-01` or `2024-01-01T09:00:00Z`. Other date strings are not accepted, since JavaScript engines parse them differently. Defaults to the current date and time.
|
|
120
|
+
|
|
121
|
+
###### timezone
|
|
122
|
+
The [IANA timezone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), for example `Europe/London`, that the cron expression is evaluated in. Defaults to the timezone of the environment that evaluates the operator.
|
|
123
|
+
|
|
124
|
+
###### count
|
|
125
|
+
The number of occurrences to return, an integer from 1 to 1000. A `count` of 1 returns a single date, a `count` greater than 1 returns an array of dates. Defaults to 1.
|
|
126
|
+
|
|
127
|
+
#### Examples
|
|
128
|
+
|
|
129
|
+
###### Previous occurrence:
|
|
130
|
+
```yaml
|
|
131
|
+
_cron.previous:
|
|
132
|
+
expression: 0 9 * * 1
|
|
133
|
+
from:
|
|
134
|
+
_date: 2024-01-01T00:00:00.000Z
|
|
135
|
+
timezone: UTC
|
|
136
|
+
```
|
|
137
|
+
Returns: `2023-12-25T09:00:00.000Z`
|
|
138
|
+
|
|
139
|
+
###### The previous three occurrences:
|
|
140
|
+
```yaml
|
|
141
|
+
_cron.previous:
|
|
142
|
+
expression: 0 9 * * 1
|
|
143
|
+
from:
|
|
144
|
+
_date: 2024-01-01T00:00:00.000Z
|
|
145
|
+
timezone: UTC
|
|
146
|
+
count: 3
|
|
147
|
+
```
|
|
148
|
+
Returns: `[2023-12-25T09:00:00.000Z, 2023-12-18T09:00:00.000Z, 2023-12-11T09:00:00.000Z]`
|
|
149
|
+
|
|
150
|
+
## _cron.describe
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
(expression: string): string
|
|
154
|
+
(arguments: {
|
|
155
|
+
expression: string,
|
|
156
|
+
locale?: string,
|
|
157
|
+
verbose?: boolean,
|
|
158
|
+
use24HourTimeFormat?: boolean
|
|
159
|
+
}): string
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The `_cron.describe` method returns a human readable description of a cron expression, like "At 09:00 AM, only on Monday".
|
|
163
|
+
|
|
164
|
+
An empty string is returned when the expression is `null`, `undefined`, `""` or only whitespace, so the method is safe to use in a label that might not have a schedule yet. Any other expression that `_cron.validate` would return `false` for throws an error, including expressions with the `H` hash token and expressions that never occur.
|
|
165
|
+
|
|
166
|
+
#### Arguments
|
|
167
|
+
|
|
168
|
+
###### expression
|
|
169
|
+
The cron expression, for example `0 9 * * 1`. Required.
|
|
170
|
+
|
|
171
|
+
###### locale
|
|
172
|
+
The locale to describe the expression in, for example `fr`. Defaults to `en`. The supported locale codes are the [cronstrue locales](https://github.com/bradymholt/cRonstrue#supported-locales): `af`, `ar`, `az`, `be`, `bg`, `ca`, `cs`, `da`, `de`, `en`, `es`, `fa`, `fi`, `fr`, `he`, `hr`, `hu`, `id`, `it`, `ja`, `ko`, `my`, `nb`, `nl`, `nn`, `pl`, `pt_BR`, `pt_PT`, `ro`, `ru`, `sk`, `sl`, `sr`, `sv`, `sw`, `tg`, `th`, `tr`, `uk`, `vi`, `zh_CN` and `zh_TW`. Regional codes can be written with a hyphen or an underscore, in any case, so `pt-BR` and `pt_br` are the same as `pt_BR`. An error is thrown for an unsupported locale.
|
|
173
|
+
|
|
174
|
+
All locales are included in the plugin, so there is nothing to install or configure to use them.
|
|
175
|
+
|
|
176
|
+
###### verbose
|
|
177
|
+
Describe the expression in a more verbose sentence. Defaults to `false`.
|
|
178
|
+
|
|
179
|
+
###### use24HourTimeFormat
|
|
180
|
+
Describe times in the 24 hour format. Defaults to the format used by the locale.
|
|
181
|
+
|
|
182
|
+
#### Examples
|
|
183
|
+
|
|
184
|
+
###### Describe a schedule:
|
|
185
|
+
```yaml
|
|
186
|
+
_cron.describe: 0 9 * * 1
|
|
187
|
+
```
|
|
188
|
+
Returns: `"At 09:00 AM, only on Monday"`.
|
|
189
|
+
|
|
190
|
+
###### Describe a schedule in the 24 hour format:
|
|
191
|
+
```yaml
|
|
192
|
+
_cron.describe:
|
|
193
|
+
expression: 0 9 * * 1
|
|
194
|
+
use24HourTimeFormat: true
|
|
195
|
+
```
|
|
196
|
+
Returns: `"At 09:00, only on Monday"`.
|
|
197
|
+
|
|
198
|
+
###### Describe a schedule in another locale:
|
|
199
|
+
```yaml
|
|
200
|
+
_cron.describe:
|
|
201
|
+
expression: 0 9 * * 1
|
|
202
|
+
locale: fr
|
|
203
|
+
```
|
|
204
|
+
Returns: `"À 09:00, uniquement le lundi"`.
|
|
205
|
+
|
|
206
|
+
###### Describe a schedule verbosely:
|
|
207
|
+
```yaml
|
|
208
|
+
_cron.describe:
|
|
209
|
+
expression: '*/5 * * * *'
|
|
210
|
+
verbose: true
|
|
211
|
+
```
|
|
212
|
+
Returns: `"Every 5 minutes, every hour, every day"`.
|
|
213
|
+
|
|
214
|
+
## _cron.validate
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
(expression: any): boolean
|
|
218
|
+
(arguments: { expression: any }): boolean
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The `_cron.validate` method returns `true` when the cron expression is valid, and `false` when it is not. A missing or blank expression, a value that is not a string, an expression with the `H` hash token and an expression that never occurs (like `0 0 31 2 *`) all return `false`. This method never throws, so it can be used to validate a cron expression captured by an input block.
|
|
222
|
+
|
|
223
|
+
`_cron.validate` checks the `_cron` grammar, which is wider than the `schedules` of [scheduled endpoints](/api#scheduled-endpoints-cron) accept.
|
|
224
|
+
|
|
225
|
+
#### Arguments
|
|
226
|
+
|
|
227
|
+
###### expression
|
|
228
|
+
The cron expression to validate. Any type is accepted.
|
|
229
|
+
|
|
230
|
+
#### Examples
|
|
231
|
+
|
|
232
|
+
###### Validate a schedule:
|
|
233
|
+
```yaml
|
|
234
|
+
_cron.validate: 0 9 * * 1
|
|
235
|
+
```
|
|
236
|
+
Returns: `true`.
|
|
237
|
+
|
|
238
|
+
###### Validate user input:
|
|
239
|
+
```yaml
|
|
240
|
+
- id: schedule
|
|
241
|
+
type: TextInput
|
|
242
|
+
validate:
|
|
243
|
+
- status: error
|
|
244
|
+
message: Not a valid cron expression.
|
|
245
|
+
pass:
|
|
246
|
+
_cron.validate:
|
|
247
|
+
_state: schedule
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## _cron.fields
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
(expression: string): object
|
|
254
|
+
(arguments: { expression: string }): object
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The `_cron.fields` method returns the parsed fields of a cron expression as an object with a `second`, `minute`, `hour`, `dayOfMonth`, `month` and `dayOfWeek` key. Each field has the list of `values` it matches, and a `wildcard` boolean that is `true` when the field was given as `*`.
|
|
258
|
+
|
|
259
|
+
An error is thrown if the cron expression is missing, is invalid, or never occurs.
|
|
260
|
+
|
|
261
|
+
#### Arguments
|
|
262
|
+
|
|
263
|
+
###### expression
|
|
264
|
+
The cron expression, for example `0 9 * * 1`. Required.
|
|
265
|
+
|
|
266
|
+
#### Examples
|
|
267
|
+
|
|
268
|
+
###### Fields of a schedule:
|
|
269
|
+
```yaml
|
|
270
|
+
_cron.fields: 0 9 * * 1
|
|
271
|
+
```
|
|
272
|
+
Returns:
|
|
273
|
+
```yaml
|
|
274
|
+
second:
|
|
275
|
+
wildcard: false
|
|
276
|
+
values: [0]
|
|
277
|
+
minute:
|
|
278
|
+
wildcard: false
|
|
279
|
+
values: [0]
|
|
280
|
+
hour:
|
|
281
|
+
wildcard: false
|
|
282
|
+
values: [9]
|
|
283
|
+
dayOfMonth:
|
|
284
|
+
wildcard: true
|
|
285
|
+
values: [1, 2, 3, '...', 31]
|
|
286
|
+
month:
|
|
287
|
+
wildcard: true
|
|
288
|
+
values: [1, 2, 3, '...', 12]
|
|
289
|
+
dayOfWeek:
|
|
290
|
+
wildcard: false
|
|
291
|
+
values: [1]
|
|
292
|
+
```
|