@nocobase/plugin-workflow-custom-action-trigger 2.0.25 → 2.1.0-alpha.11

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.
Files changed (43) hide show
  1. package/dist/client/CustomActionTrigger.d.ts +39 -2
  2. package/dist/client/index.js +1 -1
  3. package/dist/externalVersion.js +10 -10
  4. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
  5. package/dist/node_modules/joi/lib/annotate.js +175 -0
  6. package/dist/node_modules/joi/lib/base.js +1069 -0
  7. package/dist/node_modules/joi/lib/cache.js +143 -0
  8. package/dist/node_modules/joi/lib/common.js +216 -0
  9. package/dist/node_modules/joi/lib/compile.js +283 -0
  10. package/dist/node_modules/joi/lib/errors.js +271 -0
  11. package/dist/node_modules/joi/lib/extend.js +312 -0
  12. package/dist/node_modules/joi/lib/index.d.ts +2365 -0
  13. package/dist/node_modules/joi/lib/index.js +1 -0
  14. package/dist/node_modules/joi/lib/manifest.js +476 -0
  15. package/dist/node_modules/joi/lib/messages.js +178 -0
  16. package/dist/node_modules/joi/lib/modify.js +267 -0
  17. package/dist/node_modules/joi/lib/ref.js +414 -0
  18. package/dist/node_modules/joi/lib/schemas.js +302 -0
  19. package/dist/node_modules/joi/lib/state.js +166 -0
  20. package/dist/node_modules/joi/lib/template.js +463 -0
  21. package/dist/node_modules/joi/lib/trace.js +346 -0
  22. package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
  23. package/dist/node_modules/joi/lib/types/any.js +174 -0
  24. package/dist/node_modules/joi/lib/types/array.js +809 -0
  25. package/dist/node_modules/joi/lib/types/binary.js +100 -0
  26. package/dist/node_modules/joi/lib/types/boolean.js +150 -0
  27. package/dist/node_modules/joi/lib/types/date.js +233 -0
  28. package/dist/node_modules/joi/lib/types/function.js +93 -0
  29. package/dist/node_modules/joi/lib/types/keys.js +1067 -0
  30. package/dist/node_modules/joi/lib/types/link.js +168 -0
  31. package/dist/node_modules/joi/lib/types/number.js +363 -0
  32. package/dist/node_modules/joi/lib/types/object.js +22 -0
  33. package/dist/node_modules/joi/lib/types/string.js +850 -0
  34. package/dist/node_modules/joi/lib/types/symbol.js +102 -0
  35. package/dist/node_modules/joi/lib/validator.js +750 -0
  36. package/dist/node_modules/joi/lib/values.js +263 -0
  37. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  38. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
  39. package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
  40. package/dist/node_modules/joi/package.json +1 -0
  41. package/dist/server/CustomActionTrigger.d.ts +11 -0
  42. package/dist/server/CustomActionTrigger.js +19 -0
  43. package/package.json +5 -2
@@ -0,0 +1,267 @@
1
+ 'use strict';
2
+
3
+ const Assert = require('@hapi/hoek/lib/assert');
4
+
5
+ const Common = require('./common');
6
+ const Ref = require('./ref');
7
+
8
+
9
+ const internals = {};
10
+
11
+
12
+
13
+ exports.Ids = internals.Ids = class {
14
+
15
+ constructor() {
16
+
17
+ this._byId = new Map();
18
+ this._byKey = new Map();
19
+ this._schemaChain = false;
20
+ }
21
+
22
+ clone() {
23
+
24
+ const clone = new internals.Ids();
25
+ clone._byId = new Map(this._byId);
26
+ clone._byKey = new Map(this._byKey);
27
+ clone._schemaChain = this._schemaChain;
28
+ return clone;
29
+ }
30
+
31
+ concat(source) {
32
+
33
+ if (source._schemaChain) {
34
+ this._schemaChain = true;
35
+ }
36
+
37
+ for (const [id, value] of source._byId.entries()) {
38
+ Assert(!this._byKey.has(id), 'Schema id conflicts with existing key:', id);
39
+ this._byId.set(id, value);
40
+ }
41
+
42
+ for (const [key, value] of source._byKey.entries()) {
43
+ Assert(!this._byId.has(key), 'Schema key conflicts with existing id:', key);
44
+ this._byKey.set(key, value);
45
+ }
46
+ }
47
+
48
+ fork(path, adjuster, root) {
49
+
50
+ const chain = this._collect(path);
51
+ chain.push({ schema: root });
52
+ const tail = chain.shift();
53
+ let adjusted = { id: tail.id, schema: adjuster(tail.schema) };
54
+
55
+ Assert(Common.isSchema(adjusted.schema), 'adjuster function failed to return a joi schema type');
56
+
57
+ for (const node of chain) {
58
+ adjusted = { id: node.id, schema: internals.fork(node.schema, adjusted.id, adjusted.schema) };
59
+ }
60
+
61
+ return adjusted.schema;
62
+ }
63
+
64
+ labels(path, behind = []) {
65
+
66
+ const current = path[0];
67
+ const node = this._get(current);
68
+ if (!node) {
69
+ return [...behind, ...path].join('.');
70
+ }
71
+
72
+ const forward = path.slice(1);
73
+ behind = [...behind, node.schema._flags.label || current];
74
+ if (!forward.length) {
75
+ return behind.join('.');
76
+ }
77
+
78
+ return node.schema._ids.labels(forward, behind);
79
+ }
80
+
81
+ reach(path, behind = []) {
82
+
83
+ const current = path[0];
84
+ const node = this._get(current);
85
+ Assert(node, 'Schema does not contain path', [...behind, ...path].join('.'));
86
+
87
+ const forward = path.slice(1);
88
+ if (!forward.length) {
89
+ return node.schema;
90
+ }
91
+
92
+ return node.schema._ids.reach(forward, [...behind, current]);
93
+ }
94
+
95
+ register(schema, { key } = {}) {
96
+
97
+ if (!schema ||
98
+ !Common.isSchema(schema)) {
99
+
100
+ return;
101
+ }
102
+
103
+ if (schema.$_property('schemaChain') ||
104
+ schema._ids._schemaChain) {
105
+
106
+ this._schemaChain = true;
107
+ }
108
+
109
+ const id = schema._flags.id;
110
+ if (id) {
111
+ const existing = this._byId.get(id);
112
+ Assert(!existing || existing.schema === schema, 'Cannot add different schemas with the same id:', id);
113
+ Assert(!this._byKey.has(id), 'Schema id conflicts with existing key:', id);
114
+
115
+ this._byId.set(id, { schema, id });
116
+ }
117
+
118
+ if (key) {
119
+ Assert(!this._byKey.has(key), 'Schema already contains key:', key);
120
+ Assert(!this._byId.has(key), 'Schema key conflicts with existing id:', key);
121
+
122
+ this._byKey.set(key, { schema, id: key });
123
+ }
124
+ }
125
+
126
+ reset() {
127
+
128
+ this._byId = new Map();
129
+ this._byKey = new Map();
130
+ this._schemaChain = false;
131
+ }
132
+
133
+ _collect(path, behind = [], nodes = []) {
134
+
135
+ const current = path[0];
136
+ const node = this._get(current);
137
+ Assert(node, 'Schema does not contain path', [...behind, ...path].join('.'));
138
+
139
+ nodes = [node, ...nodes];
140
+
141
+ const forward = path.slice(1);
142
+ if (!forward.length) {
143
+ return nodes;
144
+ }
145
+
146
+ return node.schema._ids._collect(forward, [...behind, current], nodes);
147
+ }
148
+
149
+ _get(id) {
150
+
151
+ return this._byId.get(id) || this._byKey.get(id);
152
+ }
153
+ };
154
+
155
+
156
+ internals.fork = function (schema, id, replacement) {
157
+
158
+ const each = (item, { key }) => {
159
+
160
+ if (id === (item._flags.id || key)) {
161
+ return replacement;
162
+ }
163
+ };
164
+
165
+ const obj = exports.schema(schema, { each, ref: false });
166
+ return obj ? obj.$_mutateRebuild() : schema;
167
+ };
168
+
169
+
170
+ exports.schema = function (schema, options) {
171
+
172
+ let obj;
173
+
174
+ for (const name in schema._flags) {
175
+ if (name[0] === '_') {
176
+ continue;
177
+ }
178
+
179
+ const result = internals.scan(schema._flags[name], { source: 'flags', name }, options);
180
+ if (result !== undefined) {
181
+ obj = obj || schema.clone();
182
+ obj._flags[name] = result;
183
+ }
184
+ }
185
+
186
+ for (let i = 0; i < schema._rules.length; ++i) {
187
+ const rule = schema._rules[i];
188
+ const result = internals.scan(rule.args, { source: 'rules', name: rule.name }, options);
189
+ if (result !== undefined) {
190
+ obj = obj || schema.clone();
191
+ const clone = Object.assign({}, rule);
192
+ clone.args = result;
193
+ obj._rules[i] = clone;
194
+
195
+ const existingUnique = obj._singleRules.get(rule.name);
196
+ if (existingUnique === rule) {
197
+ obj._singleRules.set(rule.name, clone);
198
+ }
199
+ }
200
+ }
201
+
202
+ for (const name in schema.$_terms) {
203
+ if (name[0] === '_') {
204
+ continue;
205
+ }
206
+
207
+ const result = internals.scan(schema.$_terms[name], { source: 'terms', name }, options);
208
+ if (result !== undefined) {
209
+ obj = obj || schema.clone();
210
+ obj.$_terms[name] = result;
211
+ }
212
+ }
213
+
214
+ return obj;
215
+ };
216
+
217
+
218
+ internals.scan = function (item, source, options, _path, _key) {
219
+
220
+ const path = _path || [];
221
+
222
+ if (item === null ||
223
+ typeof item !== 'object') {
224
+
225
+ return;
226
+ }
227
+
228
+ let clone;
229
+
230
+ if (Array.isArray(item)) {
231
+ for (let i = 0; i < item.length; ++i) {
232
+ const key = source.source === 'terms' && source.name === 'keys' && item[i].key;
233
+ const result = internals.scan(item[i], source, options, [i, ...path], key);
234
+ if (result !== undefined) {
235
+ clone = clone || item.slice();
236
+ clone[i] = result;
237
+ }
238
+ }
239
+
240
+ return clone;
241
+ }
242
+
243
+ if (options.schema !== false && Common.isSchema(item) ||
244
+ options.ref !== false && Ref.isRef(item)) {
245
+
246
+ const result = options.each(item, { ...source, path, key: _key });
247
+ if (result === item) {
248
+ return;
249
+ }
250
+
251
+ return result;
252
+ }
253
+
254
+ for (const key in item) {
255
+ if (key[0] === '_') {
256
+ continue;
257
+ }
258
+
259
+ const result = internals.scan(item[key], source, options, [key, ...path], _key);
260
+ if (result !== undefined) {
261
+ clone = clone || Object.assign({}, item);
262
+ clone[key] = result;
263
+ }
264
+ }
265
+
266
+ return clone;
267
+ };
@@ -0,0 +1,414 @@
1
+ 'use strict';
2
+
3
+ const Assert = require('@hapi/hoek/lib/assert');
4
+ const Clone = require('@hapi/hoek/lib/clone');
5
+ const Reach = require('@hapi/hoek/lib/reach');
6
+
7
+ const Common = require('./common');
8
+
9
+ let Template;
10
+
11
+
12
+ const internals = {
13
+ symbol: Symbol('ref'), // Used to internally identify references (shared with other joi versions)
14
+ defaults: {
15
+ adjust: null,
16
+ in: false,
17
+ iterables: null,
18
+ map: null,
19
+ separator: '.',
20
+ type: 'value'
21
+ }
22
+ };
23
+
24
+
25
+ exports.create = function (key, options = {}) {
26
+
27
+ Assert(typeof key === 'string', 'Invalid reference key:', key);
28
+ Common.assertOptions(options, ['adjust', 'ancestor', 'in', 'iterables', 'map', 'prefix', 'render', 'separator']);
29
+ Assert(!options.prefix || typeof options.prefix === 'object', 'options.prefix must be of type object');
30
+
31
+ const ref = Object.assign({}, internals.defaults, options);
32
+ delete ref.prefix;
33
+
34
+ const separator = ref.separator;
35
+ const context = internals.context(key, separator, options.prefix);
36
+ ref.type = context.type;
37
+ key = context.key;
38
+
39
+ if (ref.type === 'value') {
40
+ if (context.root) {
41
+ Assert(!separator || key[0] !== separator, 'Cannot specify relative path with root prefix');
42
+ ref.ancestor = 'root';
43
+ if (!key) {
44
+ key = null;
45
+ }
46
+ }
47
+
48
+ if (separator &&
49
+ separator === key) {
50
+
51
+ key = null;
52
+ ref.ancestor = 0;
53
+ }
54
+ else {
55
+ if (ref.ancestor !== undefined) {
56
+ Assert(!separator || !key || key[0] !== separator, 'Cannot combine prefix with ancestor option');
57
+ }
58
+ else {
59
+ const [ancestor, slice] = internals.ancestor(key, separator);
60
+ if (slice) {
61
+ key = key.slice(slice);
62
+ if (key === '') {
63
+ key = null;
64
+ }
65
+ }
66
+
67
+ ref.ancestor = ancestor;
68
+ }
69
+ }
70
+ }
71
+
72
+ ref.path = separator ? (key === null ? [] : key.split(separator)) : [key];
73
+
74
+ return new internals.Ref(ref);
75
+ };
76
+
77
+
78
+ exports.in = function (key, options = {}) {
79
+
80
+ return exports.create(key, { ...options, in: true });
81
+ };
82
+
83
+
84
+ exports.isRef = function (ref) {
85
+
86
+ return ref ? !!ref[Common.symbols.ref] : false;
87
+ };
88
+
89
+
90
+ internals.Ref = class {
91
+
92
+ constructor(options) {
93
+
94
+ Assert(typeof options === 'object', 'Invalid reference construction');
95
+ Common.assertOptions(options, [
96
+ 'adjust', 'ancestor', 'in', 'iterables', 'map', 'path', 'render', 'separator', 'type', // Copied
97
+ 'depth', 'key', 'root', 'display' // Overridden
98
+ ]);
99
+
100
+ Assert([false, undefined].includes(options.separator) || typeof options.separator === 'string' && options.separator.length === 1, 'Invalid separator');
101
+ Assert(!options.adjust || typeof options.adjust === 'function', 'options.adjust must be a function');
102
+ Assert(!options.map || Array.isArray(options.map), 'options.map must be an array');
103
+ Assert(!options.map || !options.adjust, 'Cannot set both map and adjust options');
104
+
105
+ Object.assign(this, internals.defaults, options);
106
+
107
+ Assert(this.type === 'value' || this.ancestor === undefined, 'Non-value references cannot reference ancestors');
108
+
109
+ if (Array.isArray(this.map)) {
110
+ this.map = new Map(this.map);
111
+ }
112
+
113
+ this.depth = this.path.length;
114
+ this.key = this.path.length ? this.path.join(this.separator) : null;
115
+ this.root = this.path[0];
116
+
117
+ this.updateDisplay();
118
+ }
119
+
120
+ resolve(value, state, prefs, local, options = {}) {
121
+
122
+ Assert(!this.in || options.in, 'Invalid in() reference usage');
123
+
124
+ if (this.type === 'global') {
125
+ return this._resolve(prefs.context, state, options);
126
+ }
127
+
128
+ if (this.type === 'local') {
129
+ return this._resolve(local, state, options);
130
+ }
131
+
132
+ if (!this.ancestor) {
133
+ return this._resolve(value, state, options);
134
+ }
135
+
136
+ if (this.ancestor === 'root') {
137
+ return this._resolve(state.ancestors[state.ancestors.length - 1], state, options);
138
+ }
139
+
140
+ Assert(this.ancestor <= state.ancestors.length, 'Invalid reference exceeds the schema root:', this.display);
141
+ return this._resolve(state.ancestors[this.ancestor - 1], state, options);
142
+ }
143
+
144
+ _resolve(target, state, options) {
145
+
146
+ let resolved;
147
+
148
+ if (this.type === 'value' &&
149
+ state.mainstay.shadow &&
150
+ options.shadow !== false) {
151
+
152
+ resolved = state.mainstay.shadow.get(this.absolute(state));
153
+ }
154
+
155
+ if (resolved === undefined) {
156
+ resolved = Reach(target, this.path, { iterables: this.iterables, functions: true });
157
+ }
158
+
159
+ if (this.adjust) {
160
+ resolved = this.adjust(resolved);
161
+ }
162
+
163
+ if (this.map) {
164
+ const mapped = this.map.get(resolved);
165
+ if (mapped !== undefined) {
166
+ resolved = mapped;
167
+ }
168
+ }
169
+
170
+ if (state.mainstay) {
171
+ state.mainstay.tracer.resolve(state, this, resolved);
172
+ }
173
+
174
+ return resolved;
175
+ }
176
+
177
+ toString() {
178
+
179
+ return this.display;
180
+ }
181
+
182
+ absolute(state) {
183
+
184
+ return [...state.path.slice(0, -this.ancestor), ...this.path];
185
+ }
186
+
187
+ clone() {
188
+
189
+ return new internals.Ref(this);
190
+ }
191
+
192
+ describe() {
193
+
194
+ const ref = { path: this.path };
195
+
196
+ if (this.type !== 'value') {
197
+ ref.type = this.type;
198
+ }
199
+
200
+ if (this.separator !== '.') {
201
+ ref.separator = this.separator;
202
+ }
203
+
204
+ if (this.type === 'value' &&
205
+ this.ancestor !== 1) {
206
+
207
+ ref.ancestor = this.ancestor;
208
+ }
209
+
210
+ if (this.map) {
211
+ ref.map = [...this.map];
212
+ }
213
+
214
+ for (const key of ['adjust', 'iterables', 'render']) {
215
+ if (this[key] !== null &&
216
+ this[key] !== undefined) {
217
+
218
+ ref[key] = this[key];
219
+ }
220
+ }
221
+
222
+ if (this.in !== false) {
223
+ ref.in = true;
224
+ }
225
+
226
+ return { ref };
227
+ }
228
+
229
+ updateDisplay() {
230
+
231
+ const key = this.key !== null ? this.key : '';
232
+ if (this.type !== 'value') {
233
+ this.display = `ref:${this.type}:${key}`;
234
+ return;
235
+ }
236
+
237
+ if (!this.separator) {
238
+ this.display = `ref:${key}`;
239
+ return;
240
+ }
241
+
242
+ if (!this.ancestor) {
243
+ this.display = `ref:${this.separator}${key}`;
244
+ return;
245
+ }
246
+
247
+ if (this.ancestor === 'root') {
248
+ this.display = `ref:root:${key}`;
249
+ return;
250
+ }
251
+
252
+ if (this.ancestor === 1) {
253
+ this.display = `ref:${key || '..'}`;
254
+ return;
255
+ }
256
+
257
+ const lead = new Array(this.ancestor + 1).fill(this.separator).join('');
258
+ this.display = `ref:${lead}${key || ''}`;
259
+ }
260
+ };
261
+
262
+
263
+ internals.Ref.prototype[Common.symbols.ref] = true;
264
+
265
+
266
+ exports.build = function (desc) {
267
+
268
+ desc = Object.assign({}, internals.defaults, desc);
269
+ if (desc.type === 'value' &&
270
+ desc.ancestor === undefined) {
271
+
272
+ desc.ancestor = 1;
273
+ }
274
+
275
+ return new internals.Ref(desc);
276
+ };
277
+
278
+
279
+ internals.context = function (key, separator, prefix = {}) {
280
+
281
+ key = key.trim();
282
+
283
+ if (prefix) {
284
+ const globalp = prefix.global === undefined ? '$' : prefix.global;
285
+ if (globalp !== separator &&
286
+ key.startsWith(globalp)) {
287
+
288
+ return { key: key.slice(globalp.length), type: 'global' };
289
+ }
290
+
291
+ const local = prefix.local === undefined ? '#' : prefix.local;
292
+ if (local !== separator &&
293
+ key.startsWith(local)) {
294
+
295
+ return { key: key.slice(local.length), type: 'local' };
296
+ }
297
+
298
+ const root = prefix.root === undefined ? '/' : prefix.root;
299
+ if (root !== separator &&
300
+ key.startsWith(root)) {
301
+
302
+ return { key: key.slice(root.length), type: 'value', root: true };
303
+ }
304
+ }
305
+
306
+ return { key, type: 'value' };
307
+ };
308
+
309
+
310
+ internals.ancestor = function (key, separator) {
311
+
312
+ if (!separator) {
313
+ return [1, 0]; // 'a_b' -> 1 (parent)
314
+ }
315
+
316
+ if (key[0] !== separator) { // 'a.b' -> 1 (parent)
317
+ return [1, 0];
318
+ }
319
+
320
+ if (key[1] !== separator) { // '.a.b' -> 0 (self)
321
+ return [0, 1];
322
+ }
323
+
324
+ let i = 2;
325
+ while (key[i] === separator) {
326
+ ++i;
327
+ }
328
+
329
+ return [i - 1, i]; // '...a.b.' -> 2 (grandparent)
330
+ };
331
+
332
+
333
+ exports.toSibling = 0;
334
+
335
+ exports.toParent = 1;
336
+
337
+
338
+ exports.Manager = class {
339
+
340
+ constructor() {
341
+
342
+ this.refs = []; // 0: [self refs], 1: [parent refs], 2: [grandparent refs], ...
343
+ }
344
+
345
+ register(source, target) {
346
+
347
+ if (!source) {
348
+ return;
349
+ }
350
+
351
+ target = target === undefined ? exports.toParent : target;
352
+
353
+ // Array
354
+
355
+ if (Array.isArray(source)) {
356
+ for (const ref of source) {
357
+ this.register(ref, target);
358
+ }
359
+
360
+ return;
361
+ }
362
+
363
+ // Schema
364
+
365
+ if (Common.isSchema(source)) {
366
+ for (const item of source._refs.refs) {
367
+ if (item.ancestor - target >= 0) {
368
+ this.refs.push({ ancestor: item.ancestor - target, root: item.root });
369
+ }
370
+ }
371
+
372
+ return;
373
+ }
374
+
375
+ // Reference
376
+
377
+ if (exports.isRef(source) &&
378
+ source.type === 'value' &&
379
+ source.ancestor - target >= 0) {
380
+
381
+ this.refs.push({ ancestor: source.ancestor - target, root: source.root });
382
+ }
383
+
384
+ // Template
385
+
386
+ Template = Template || require('./template');
387
+
388
+ if (Template.isTemplate(source)) {
389
+ this.register(source.refs(), target);
390
+ }
391
+ }
392
+
393
+ get length() {
394
+
395
+ return this.refs.length;
396
+ }
397
+
398
+ clone() {
399
+
400
+ const copy = new exports.Manager();
401
+ copy.refs = Clone(this.refs);
402
+ return copy;
403
+ }
404
+
405
+ reset() {
406
+
407
+ this.refs = [];
408
+ }
409
+
410
+ roots() {
411
+
412
+ return this.refs.filter((ref) => !ref.ancestor).map((ref) => ref.root);
413
+ }
414
+ };