@nocobase/plugin-workflow-request-interceptor 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/RequestInterceptionTrigger.d.ts +10 -0
  2. package/dist/client/index.js +1 -1
  3. package/dist/externalVersion.js +6 -6
  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/RequestInterceptionTrigger.d.ts +3 -0
  42. package/dist/server/RequestInterceptionTrigger.js +11 -0
  43. package/package.json +5 -2
@@ -0,0 +1,143 @@
1
+ 'use strict';
2
+
3
+ const Assert = require('@hapi/hoek/lib/assert');
4
+ const Clone = require('@hapi/hoek/lib/clone');
5
+
6
+ const Common = require('./common');
7
+
8
+
9
+ const internals = {
10
+ max: 1000,
11
+ supported: new Set(['undefined', 'boolean', 'number', 'string'])
12
+ };
13
+
14
+
15
+ exports.provider = {
16
+
17
+ provision(options) {
18
+
19
+ return new internals.Cache(options);
20
+ }
21
+ };
22
+
23
+
24
+ // Least Recently Used (LRU) Cache
25
+
26
+ internals.Cache = class {
27
+
28
+ constructor(options = {}) {
29
+
30
+ Common.assertOptions(options, ['max']);
31
+ Assert(options.max === undefined || options.max && options.max > 0 && isFinite(options.max), 'Invalid max cache size');
32
+
33
+ this._max = options.max || internals.max;
34
+
35
+ this._map = new Map(); // Map of nodes by key
36
+ this._list = new internals.List(); // List of nodes (most recently used in head)
37
+ }
38
+
39
+ get length() {
40
+
41
+ return this._map.size;
42
+ }
43
+
44
+ set(key, value) {
45
+
46
+ if (key !== null &&
47
+ !internals.supported.has(typeof key)) {
48
+
49
+ return;
50
+ }
51
+
52
+ let node = this._map.get(key);
53
+ if (node) {
54
+ node.value = value;
55
+ this._list.first(node);
56
+ return;
57
+ }
58
+
59
+ node = this._list.unshift({ key, value });
60
+ this._map.set(key, node);
61
+ this._compact();
62
+ }
63
+
64
+ get(key) {
65
+
66
+ const node = this._map.get(key);
67
+ if (node) {
68
+ this._list.first(node);
69
+ return Clone(node.value);
70
+ }
71
+ }
72
+
73
+ _compact() {
74
+
75
+ if (this._map.size > this._max) {
76
+ const node = this._list.pop();
77
+ this._map.delete(node.key);
78
+ }
79
+ }
80
+ };
81
+
82
+
83
+ internals.List = class {
84
+
85
+ constructor() {
86
+
87
+ this.tail = null;
88
+ this.head = null;
89
+ }
90
+
91
+ unshift(node) {
92
+
93
+ node.next = null;
94
+ node.prev = this.head;
95
+
96
+ if (this.head) {
97
+ this.head.next = node;
98
+ }
99
+
100
+ this.head = node;
101
+
102
+ if (!this.tail) {
103
+ this.tail = node;
104
+ }
105
+
106
+ return node;
107
+ }
108
+
109
+ first(node) {
110
+
111
+ if (node === this.head) {
112
+ return;
113
+ }
114
+
115
+ this._remove(node);
116
+ this.unshift(node);
117
+ }
118
+
119
+ pop() {
120
+
121
+ return this._remove(this.tail);
122
+ }
123
+
124
+ _remove(node) {
125
+
126
+ const { next, prev } = node;
127
+
128
+ next.prev = prev;
129
+
130
+ if (prev) {
131
+ prev.next = next;
132
+ }
133
+
134
+ if (node === this.tail) {
135
+ this.tail = next;
136
+ }
137
+
138
+ node.prev = null;
139
+ node.next = null;
140
+
141
+ return node;
142
+ }
143
+ };
@@ -0,0 +1,216 @@
1
+ 'use strict';
2
+
3
+ const Assert = require('@hapi/hoek/lib/assert');
4
+ const AssertError = require('@hapi/hoek/lib/error');
5
+
6
+ const Pkg = require('../package.json');
7
+
8
+ let Messages;
9
+ let Schemas;
10
+
11
+
12
+ const internals = {
13
+ isoDate: /^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/
14
+ };
15
+
16
+
17
+ exports.version = Pkg.version;
18
+
19
+
20
+ exports.defaults = {
21
+ abortEarly: true,
22
+ allowUnknown: false,
23
+ artifacts: false,
24
+ cache: true,
25
+ context: null,
26
+ convert: true,
27
+ dateFormat: 'iso',
28
+ errors: {
29
+ escapeHtml: false,
30
+ label: 'path',
31
+ language: null,
32
+ render: true,
33
+ stack: false,
34
+ wrap: {
35
+ label: '"',
36
+ array: '[]'
37
+ }
38
+ },
39
+ externals: true,
40
+ messages: {},
41
+ nonEnumerables: false,
42
+ noDefaults: false,
43
+ presence: 'optional',
44
+ skipFunctions: false,
45
+ stripUnknown: false,
46
+ warnings: false
47
+ };
48
+
49
+
50
+ exports.symbols = {
51
+ any: Symbol.for('@hapi/joi/schema'), // Used to internally identify any-based types (shared with other joi versions)
52
+ arraySingle: Symbol('arraySingle'),
53
+ deepDefault: Symbol('deepDefault'),
54
+ errors: Symbol('errors'),
55
+ literal: Symbol('literal'),
56
+ override: Symbol('override'),
57
+ parent: Symbol('parent'),
58
+ prefs: Symbol('prefs'),
59
+ ref: Symbol('ref'),
60
+ template: Symbol('template'),
61
+ values: Symbol('values')
62
+ };
63
+
64
+
65
+ exports.assertOptions = function (options, keys, name = 'Options') {
66
+
67
+ Assert(options && typeof options === 'object' && !Array.isArray(options), 'Options must be of type object');
68
+ const unknownKeys = Object.keys(options).filter((k) => !keys.includes(k));
69
+ Assert(unknownKeys.length === 0, `${name} contain unknown keys: ${unknownKeys}`);
70
+ };
71
+
72
+
73
+ exports.checkPreferences = function (prefs) {
74
+
75
+ Schemas = Schemas || require('./schemas');
76
+
77
+ const result = Schemas.preferences.validate(prefs);
78
+
79
+ if (result.error) {
80
+ throw new AssertError([result.error.details[0].message]);
81
+ }
82
+ };
83
+
84
+
85
+ exports.compare = function (a, b, operator) {
86
+
87
+ switch (operator) {
88
+ case '=': return a === b;
89
+ case '>': return a > b;
90
+ case '<': return a < b;
91
+ case '>=': return a >= b;
92
+ case '<=': return a <= b;
93
+ }
94
+ };
95
+
96
+
97
+ exports.default = function (value, defaultValue) {
98
+
99
+ return value === undefined ? defaultValue : value;
100
+ };
101
+
102
+
103
+ exports.isIsoDate = function (date) {
104
+
105
+ return internals.isoDate.test(date);
106
+ };
107
+
108
+
109
+ exports.isNumber = function (value) {
110
+
111
+ return typeof value === 'number' && !isNaN(value);
112
+ };
113
+
114
+
115
+ exports.isResolvable = function (obj) {
116
+
117
+ if (!obj) {
118
+ return false;
119
+ }
120
+
121
+ return obj[exports.symbols.ref] || obj[exports.symbols.template];
122
+ };
123
+
124
+
125
+ exports.isSchema = function (schema, options = {}) {
126
+
127
+ const any = schema && schema[exports.symbols.any];
128
+ if (!any) {
129
+ return false;
130
+ }
131
+
132
+ Assert(options.legacy || any.version === exports.version, 'Cannot mix different versions of joi schemas');
133
+ return true;
134
+ };
135
+
136
+
137
+ exports.isValues = function (obj) {
138
+
139
+ return obj[exports.symbols.values];
140
+ };
141
+
142
+
143
+ exports.limit = function (value) {
144
+
145
+ return Number.isSafeInteger(value) && value >= 0;
146
+ };
147
+
148
+
149
+ exports.preferences = function (target, source) {
150
+
151
+ Messages = Messages || require('./messages');
152
+
153
+ target = target || {};
154
+ source = source || {};
155
+
156
+ const merged = Object.assign({}, target, source);
157
+ if (source.errors &&
158
+ target.errors) {
159
+
160
+ merged.errors = Object.assign({}, target.errors, source.errors);
161
+ merged.errors.wrap = Object.assign({}, target.errors.wrap, source.errors.wrap);
162
+ }
163
+
164
+ if (source.messages) {
165
+ merged.messages = Messages.compile(source.messages, target.messages);
166
+ }
167
+
168
+ delete merged[exports.symbols.prefs];
169
+ return merged;
170
+ };
171
+
172
+
173
+ exports.tryWithPath = function (fn, key, options = {}) {
174
+
175
+ try {
176
+ return fn();
177
+ }
178
+ catch (err) {
179
+ if (err.path !== undefined) {
180
+ err.path = key + '.' + err.path;
181
+ }
182
+ else {
183
+ err.path = key;
184
+ }
185
+
186
+ if (options.append) {
187
+ err.message = `${err.message} (${err.path})`;
188
+ }
189
+
190
+ throw err;
191
+ }
192
+ };
193
+
194
+
195
+ exports.validateArg = function (value, label, { assert, message }) {
196
+
197
+ if (exports.isSchema(assert)) {
198
+ const result = assert.validate(value);
199
+ if (!result.error) {
200
+ return;
201
+ }
202
+
203
+ return result.error.message;
204
+ }
205
+ else if (!assert(value)) {
206
+ return label ? `${label} ${message}` : message;
207
+ }
208
+ };
209
+
210
+
211
+ exports.verifyFlat = function (args, method) {
212
+
213
+ for (const arg of args) {
214
+ Assert(!Array.isArray(arg), 'Method no longer accepts array arguments:', method);
215
+ }
216
+ };
@@ -0,0 +1,283 @@
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
+ exports.schema = function (Joi, config, options = {}) {
13
+
14
+ Common.assertOptions(options, ['appendPath', 'override']);
15
+
16
+ try {
17
+ return internals.schema(Joi, config, options);
18
+ }
19
+ catch (err) {
20
+ if (options.appendPath &&
21
+ err.path !== undefined) {
22
+
23
+ err.message = `${err.message} (${err.path})`;
24
+ }
25
+
26
+ throw err;
27
+ }
28
+ };
29
+
30
+
31
+ internals.schema = function (Joi, config, options) {
32
+
33
+ Assert(config !== undefined, 'Invalid undefined schema');
34
+
35
+ if (Array.isArray(config)) {
36
+ Assert(config.length, 'Invalid empty array schema');
37
+
38
+ if (config.length === 1) {
39
+ config = config[0];
40
+ }
41
+ }
42
+
43
+ const valid = (base, ...values) => {
44
+
45
+ if (options.override !== false) {
46
+ return base.valid(Joi.override, ...values);
47
+ }
48
+
49
+ return base.valid(...values);
50
+ };
51
+
52
+ if (internals.simple(config)) {
53
+ return valid(Joi, config);
54
+ }
55
+
56
+ if (typeof config === 'function') {
57
+ return Joi.custom(config);
58
+ }
59
+
60
+ Assert(typeof config === 'object', 'Invalid schema content:', typeof config);
61
+
62
+ if (Common.isResolvable(config)) {
63
+ return valid(Joi, config);
64
+ }
65
+
66
+ if (Common.isSchema(config)) {
67
+ return config;
68
+ }
69
+
70
+ if (Array.isArray(config)) {
71
+ for (const item of config) {
72
+ if (!internals.simple(item)) {
73
+ return Joi.alternatives().try(...config);
74
+ }
75
+ }
76
+
77
+ return valid(Joi, ...config);
78
+ }
79
+
80
+ if (config instanceof RegExp) {
81
+ return Joi.string().regex(config);
82
+ }
83
+
84
+ if (config instanceof Date) {
85
+ return valid(Joi.date(), config);
86
+ }
87
+
88
+ Assert(Object.getPrototypeOf(config) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');
89
+
90
+ return Joi.object().keys(config);
91
+ };
92
+
93
+
94
+ exports.ref = function (id, options) {
95
+
96
+ return Ref.isRef(id) ? id : Ref.create(id, options);
97
+ };
98
+
99
+
100
+ exports.compile = function (root, schema, options = {}) {
101
+
102
+ Common.assertOptions(options, ['legacy']);
103
+
104
+ // Compiled by any supported version
105
+
106
+ const any = schema && schema[Common.symbols.any];
107
+ if (any) {
108
+ Assert(options.legacy || any.version === Common.version, 'Cannot mix different versions of joi schemas:', any.version, Common.version);
109
+ return schema;
110
+ }
111
+
112
+ // Uncompiled root
113
+
114
+ if (typeof schema !== 'object' ||
115
+ !options.legacy) {
116
+
117
+ return exports.schema(root, schema, { appendPath: true }); // Will error if schema contains other versions
118
+ }
119
+
120
+ // Scan schema for compiled parts
121
+
122
+ const compiler = internals.walk(schema);
123
+ if (!compiler) {
124
+ return exports.schema(root, schema, { appendPath: true });
125
+ }
126
+
127
+ return compiler.compile(compiler.root, schema);
128
+ };
129
+
130
+
131
+ internals.walk = function (schema) {
132
+
133
+ if (typeof schema !== 'object') {
134
+ return null;
135
+ }
136
+
137
+ if (Array.isArray(schema)) {
138
+ for (const item of schema) {
139
+ const compiler = internals.walk(item);
140
+ if (compiler) {
141
+ return compiler;
142
+ }
143
+ }
144
+
145
+ return null;
146
+ }
147
+
148
+ const any = schema[Common.symbols.any];
149
+ if (any) {
150
+ return { root: schema[any.root], compile: any.compile };
151
+ }
152
+
153
+ Assert(Object.getPrototypeOf(schema) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');
154
+
155
+ for (const key in schema) {
156
+ const compiler = internals.walk(schema[key]);
157
+ if (compiler) {
158
+ return compiler;
159
+ }
160
+ }
161
+
162
+ return null;
163
+ };
164
+
165
+
166
+ internals.simple = function (value) {
167
+
168
+ return value === null || ['boolean', 'string', 'number'].includes(typeof value);
169
+ };
170
+
171
+
172
+ exports.when = function (schema, condition, options) {
173
+
174
+ if (options === undefined) {
175
+ Assert(condition && typeof condition === 'object', 'Missing options');
176
+
177
+ options = condition;
178
+ condition = Ref.create('.');
179
+ }
180
+
181
+ if (Array.isArray(options)) {
182
+ options = { switch: options };
183
+ }
184
+
185
+ Common.assertOptions(options, ['is', 'not', 'then', 'otherwise', 'switch', 'break']);
186
+
187
+ // Schema condition
188
+
189
+ if (Common.isSchema(condition)) {
190
+ Assert(options.is === undefined, '"is" can not be used with a schema condition');
191
+ Assert(options.not === undefined, '"not" can not be used with a schema condition');
192
+ Assert(options.switch === undefined, '"switch" can not be used with a schema condition');
193
+
194
+ return internals.condition(schema, { is: condition, then: options.then, otherwise: options.otherwise, break: options.break });
195
+ }
196
+
197
+ // Single condition
198
+
199
+ Assert(Ref.isRef(condition) || typeof condition === 'string', 'Invalid condition:', condition);
200
+ Assert(options.not === undefined || options.is === undefined, 'Cannot combine "is" with "not"');
201
+
202
+ if (options.switch === undefined) {
203
+ let rule = options;
204
+ if (options.not !== undefined) {
205
+ rule = { is: options.not, then: options.otherwise, otherwise: options.then, break: options.break };
206
+ }
207
+
208
+ let is = rule.is !== undefined ? schema.$_compile(rule.is) : schema.$_root.invalid(null, false, 0, '').required();
209
+ Assert(rule.then !== undefined || rule.otherwise !== undefined, 'options must have at least one of "then", "otherwise", or "switch"');
210
+ Assert(rule.break === undefined || rule.then === undefined || rule.otherwise === undefined, 'Cannot specify then, otherwise, and break all together');
211
+
212
+ if (options.is !== undefined &&
213
+ !Ref.isRef(options.is) &&
214
+ !Common.isSchema(options.is)) {
215
+
216
+ is = is.required(); // Only apply required if this wasn't already a schema or a ref
217
+ }
218
+
219
+ return internals.condition(schema, { ref: exports.ref(condition), is, then: rule.then, otherwise: rule.otherwise, break: rule.break });
220
+ }
221
+
222
+ // Switch statement
223
+
224
+ Assert(Array.isArray(options.switch), '"switch" must be an array');
225
+ Assert(options.is === undefined, 'Cannot combine "switch" with "is"');
226
+ Assert(options.not === undefined, 'Cannot combine "switch" with "not"');
227
+ Assert(options.then === undefined, 'Cannot combine "switch" with "then"');
228
+
229
+ const rule = {
230
+ ref: exports.ref(condition),
231
+ switch: [],
232
+ break: options.break
233
+ };
234
+
235
+ for (let i = 0; i < options.switch.length; ++i) {
236
+ const test = options.switch[i];
237
+ const last = i === options.switch.length - 1;
238
+
239
+ Common.assertOptions(test, last ? ['is', 'then', 'otherwise'] : ['is', 'then']);
240
+
241
+ Assert(test.is !== undefined, 'Switch statement missing "is"');
242
+ Assert(test.then !== undefined, 'Switch statement missing "then"');
243
+
244
+ const item = {
245
+ is: schema.$_compile(test.is),
246
+ then: schema.$_compile(test.then)
247
+ };
248
+
249
+ if (!Ref.isRef(test.is) &&
250
+ !Common.isSchema(test.is)) {
251
+
252
+ item.is = item.is.required(); // Only apply required if this wasn't already a schema or a ref
253
+ }
254
+
255
+ if (last) {
256
+ Assert(options.otherwise === undefined || test.otherwise === undefined, 'Cannot specify "otherwise" inside and outside a "switch"');
257
+ const otherwise = options.otherwise !== undefined ? options.otherwise : test.otherwise;
258
+ if (otherwise !== undefined) {
259
+ Assert(rule.break === undefined, 'Cannot specify both otherwise and break');
260
+ item.otherwise = schema.$_compile(otherwise);
261
+ }
262
+ }
263
+
264
+ rule.switch.push(item);
265
+ }
266
+
267
+ return rule;
268
+ };
269
+
270
+
271
+ internals.condition = function (schema, condition) {
272
+
273
+ for (const key of ['then', 'otherwise']) {
274
+ if (condition[key] === undefined) {
275
+ delete condition[key];
276
+ }
277
+ else {
278
+ condition[key] = schema.$_compile(condition[key]);
279
+ }
280
+ }
281
+
282
+ return condition;
283
+ };