@budibase/server 2.3.17-alpha.0 → 2.3.17-alpha.1

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.
@@ -1,234 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.basicEnvironmentVariable = exports.basicWebhook = exports.basicLayout = exports.basicScreen = exports.basicUser = exports.basicQuery = exports.basicDatasource = exports.basicRole = exports.basicLinkedRow = exports.basicRow = exports.loopAutomation = exports.basicAutomation = exports.newAutomation = exports.automationTrigger = exports.automationStep = exports.view = exports.calculationView = exports.filterView = exports.basicView = exports.basicTable = exports.TENANT_ID = void 0;
4
- const backend_core_1 = require("@budibase/backend-core");
5
- const screens_1 = require("../../constants/screens");
6
- const layouts_1 = require("../../constants/layouts");
7
- const fp_1 = require("lodash/fp");
8
- const automations_1 = require("../../automations");
9
- const types_1 = require("@budibase/types");
10
- const { v4: uuidv4 } = require("uuid");
11
- exports.TENANT_ID = "default";
12
- function basicTable() {
13
- return {
14
- name: "TestTable",
15
- type: "table",
16
- key: "name",
17
- schema: {
18
- name: {
19
- type: "string",
20
- constraints: {
21
- type: "string",
22
- },
23
- },
24
- description: {
25
- type: "string",
26
- constraints: {
27
- type: "string",
28
- },
29
- },
30
- },
31
- };
32
- }
33
- exports.basicTable = basicTable;
34
- function basicView(tableId) {
35
- return {
36
- tableId,
37
- name: "ViewTest",
38
- };
39
- }
40
- exports.basicView = basicView;
41
- function filterView(tableId) {
42
- return Object.assign(Object.assign({}, basicView(tableId)), { filters: [
43
- {
44
- value: 0,
45
- condition: "MT",
46
- key: "count",
47
- },
48
- ] });
49
- }
50
- exports.filterView = filterView;
51
- function calculationView(tableId) {
52
- return Object.assign(Object.assign({}, basicView(tableId)), { field: "count", calculation: "sum" });
53
- }
54
- exports.calculationView = calculationView;
55
- function view(tableId) {
56
- return Object.assign(Object.assign({}, filterView(tableId)), calculationView(tableId));
57
- }
58
- exports.view = view;
59
- function automationStep(actionDefinition = automations_1.ACTION_DEFINITIONS.CREATE_ROW) {
60
- return Object.assign({ id: uuidv4() }, actionDefinition);
61
- }
62
- exports.automationStep = automationStep;
63
- function automationTrigger(triggerDefinition = automations_1.TRIGGER_DEFINITIONS.ROW_SAVED) {
64
- return Object.assign({ id: uuidv4() }, triggerDefinition);
65
- }
66
- exports.automationTrigger = automationTrigger;
67
- function newAutomation({ steps, trigger } = {}) {
68
- const automation = basicAutomation();
69
- if (trigger) {
70
- automation.definition.trigger = trigger;
71
- }
72
- else {
73
- automation.definition.trigger = automationTrigger();
74
- }
75
- if (steps) {
76
- automation.definition.steps = steps;
77
- }
78
- else {
79
- automation.definition.steps = [automationStep()];
80
- }
81
- return automation;
82
- }
83
- exports.newAutomation = newAutomation;
84
- function basicAutomation() {
85
- return {
86
- name: "My Automation",
87
- screenId: "kasdkfldsafkl",
88
- live: true,
89
- uiTree: {},
90
- definition: {
91
- trigger: {
92
- inputs: {},
93
- },
94
- steps: [],
95
- },
96
- type: "automation",
97
- };
98
- }
99
- exports.basicAutomation = basicAutomation;
100
- function loopAutomation(tableId, loopOpts) {
101
- if (!loopOpts) {
102
- loopOpts = {
103
- option: "Array",
104
- binding: "{{ steps.1.rows }}",
105
- };
106
- }
107
- const automation = {
108
- name: "looping",
109
- type: "automation",
110
- definition: {
111
- steps: [
112
- {
113
- id: "b",
114
- type: "ACTION",
115
- stepId: types_1.AutomationActionStepId.QUERY_ROWS,
116
- internal: true,
117
- inputs: {
118
- tableId,
119
- },
120
- schema: automations_1.ACTION_DEFINITIONS.QUERY_ROWS.schema,
121
- },
122
- {
123
- id: "c",
124
- type: "ACTION",
125
- stepId: types_1.AutomationActionStepId.LOOP,
126
- internal: true,
127
- inputs: loopOpts,
128
- blockToLoop: "d",
129
- schema: automations_1.ACTION_DEFINITIONS.LOOP.schema,
130
- },
131
- {
132
- id: "d",
133
- type: "ACTION",
134
- internal: true,
135
- stepId: types_1.AutomationActionStepId.SERVER_LOG,
136
- inputs: {
137
- text: "log statement",
138
- },
139
- schema: automations_1.ACTION_DEFINITIONS.SERVER_LOG.schema,
140
- },
141
- ],
142
- trigger: {
143
- id: "a",
144
- type: "TRIGGER",
145
- event: "row:save",
146
- stepId: types_1.AutomationTriggerStepId.ROW_SAVED,
147
- inputs: {
148
- tableId,
149
- },
150
- schema: automations_1.TRIGGER_DEFINITIONS.ROW_SAVED.schema,
151
- },
152
- },
153
- };
154
- return automation;
155
- }
156
- exports.loopAutomation = loopAutomation;
157
- function basicRow(tableId) {
158
- return {
159
- name: "Test Contact",
160
- description: "original description",
161
- tableId: tableId,
162
- };
163
- }
164
- exports.basicRow = basicRow;
165
- function basicLinkedRow(tableId, linkedRowId, linkField = "link") {
166
- // this is based on the basic linked tables you get from the test configuration
167
- return Object.assign(Object.assign({}, basicRow(tableId)), { [linkField]: [linkedRowId] });
168
- }
169
- exports.basicLinkedRow = basicLinkedRow;
170
- function basicRole() {
171
- return {
172
- name: "NewRole",
173
- inherits: backend_core_1.roles.BUILTIN_ROLE_IDS.BASIC,
174
- permissionId: backend_core_1.permissions.BuiltinPermissionID.READ_ONLY,
175
- };
176
- }
177
- exports.basicRole = basicRole;
178
- function basicDatasource() {
179
- return {
180
- datasource: {
181
- type: "datasource",
182
- name: "Test",
183
- source: types_1.SourceName.POSTGRES,
184
- config: {},
185
- },
186
- };
187
- }
188
- exports.basicDatasource = basicDatasource;
189
- function basicQuery(datasourceId) {
190
- return {
191
- datasourceId: datasourceId,
192
- name: "New Query",
193
- parameters: [],
194
- fields: {},
195
- schema: {},
196
- queryVerb: "read",
197
- };
198
- }
199
- exports.basicQuery = basicQuery;
200
- function basicUser(role) {
201
- return {
202
- email: "bill@bill.com",
203
- password: "yeeooo",
204
- roleId: role,
205
- };
206
- }
207
- exports.basicUser = basicUser;
208
- function basicScreen() {
209
- return (0, screens_1.createHomeScreen)();
210
- }
211
- exports.basicScreen = basicScreen;
212
- function basicLayout() {
213
- return (0, fp_1.cloneDeep)(layouts_1.EMPTY_LAYOUT);
214
- }
215
- exports.basicLayout = basicLayout;
216
- function basicWebhook(automationId) {
217
- return {
218
- live: true,
219
- name: "webhook",
220
- action: {
221
- type: "automation",
222
- target: automationId,
223
- },
224
- };
225
- }
226
- exports.basicWebhook = basicWebhook;
227
- function basicEnvironmentVariable(name, prod, dev) {
228
- return {
229
- name,
230
- production: prod,
231
- development: dev || prod,
232
- };
233
- }
234
- exports.basicEnvironmentVariable = basicEnvironmentVariable;