@nexo-labs/payload-taxonomies 0.8.5 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1015 +1,4 @@
1
- // src/taxonomy.ts
2
- var COLLECTION_SLUG_TAXONOMY = "taxonomy";
3
- var taxonomiesCollection = (config) => ({
4
- ...config,
5
- slug: COLLECTION_SLUG_TAXONOMY,
6
- labels: {
7
- singular: "Taxonomia",
8
- plural: "Taxonomias"
9
- },
10
- admin: {
11
- useAsTitle: "singular_name",
12
- group: "Contenido"
13
- },
14
- fields: [
15
- {
16
- name: "singular_name",
17
- label: "Nombre singular",
18
- type: "text",
19
- localized: true,
20
- required: true
21
- },
22
- {
23
- name: "plural_name",
24
- label: "Nombre plural",
25
- type: "text",
26
- localized: true,
27
- required: false
28
- },
29
- {
30
- name: "payload",
31
- label: "Payload Adicional",
32
- type: "json",
33
- required: false
34
- },
35
- ...config.fields ?? []
36
- ]
37
- });
38
-
39
- // ../../node_modules/.pnpm/jsep@1.4.0/node_modules/jsep/dist/jsep.js
40
- var Hooks = class {
41
- /**
42
- * @callback HookCallback
43
- * @this {*|Jsep} this
44
- * @param {Jsep} env
45
- * @returns: void
46
- */
47
- /**
48
- * Adds the given callback to the list of callbacks for the given hook.
49
- *
50
- * The callback will be invoked when the hook it is registered for is run.
51
- *
52
- * One callback function can be registered to multiple hooks and the same hook multiple times.
53
- *
54
- * @param {string|object} name The name of the hook, or an object of callbacks keyed by name
55
- * @param {HookCallback|boolean} callback The callback function which is given environment variables.
56
- * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
57
- * @public
58
- */
59
- add(name, callback, first) {
60
- if (typeof arguments[0] != "string") {
61
- for (let name2 in arguments[0]) {
62
- this.add(name2, arguments[0][name2], arguments[1]);
63
- }
64
- } else {
65
- (Array.isArray(name) ? name : [name]).forEach(function(name2) {
66
- this[name2] = this[name2] || [];
67
- if (callback) {
68
- this[name2][first ? "unshift" : "push"](callback);
69
- }
70
- }, this);
71
- }
72
- }
73
- /**
74
- * Runs a hook invoking all registered callbacks with the given environment variables.
75
- *
76
- * Callbacks will be invoked synchronously and in the order in which they were registered.
77
- *
78
- * @param {string} name The name of the hook.
79
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
80
- * @public
81
- */
82
- run(name, env) {
83
- this[name] = this[name] || [];
84
- this[name].forEach(function(callback) {
85
- callback.call(env && env.context ? env.context : env, env);
86
- });
87
- }
88
- };
89
- var Plugins = class {
90
- constructor(jsep2) {
91
- this.jsep = jsep2;
92
- this.registered = {};
93
- }
94
- /**
95
- * @callback PluginSetup
96
- * @this {Jsep} jsep
97
- * @returns: void
98
- */
99
- /**
100
- * Adds the given plugin(s) to the registry
101
- *
102
- * @param {object} plugins
103
- * @param {string} plugins.name The name of the plugin
104
- * @param {PluginSetup} plugins.init The init function
105
- * @public
106
- */
107
- register(...plugins) {
108
- plugins.forEach((plugin) => {
109
- if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
110
- throw new Error("Invalid JSEP plugin format");
111
- }
112
- if (this.registered[plugin.name]) {
113
- return;
114
- }
115
- plugin.init(this.jsep);
116
- this.registered[plugin.name] = plugin;
117
- });
118
- }
119
- };
120
- var Jsep = class _Jsep {
121
- /**
122
- * @returns {string}
123
- */
124
- static get version() {
125
- return "1.4.0";
126
- }
127
- /**
128
- * @returns {string}
129
- */
130
- static toString() {
131
- return "JavaScript Expression Parser (JSEP) v" + _Jsep.version;
132
- }
133
- // ==================== CONFIG ================================
134
- /**
135
- * @method addUnaryOp
136
- * @param {string} op_name The name of the unary op to add
137
- * @returns {Jsep}
138
- */
139
- static addUnaryOp(op_name) {
140
- _Jsep.max_unop_len = Math.max(op_name.length, _Jsep.max_unop_len);
141
- _Jsep.unary_ops[op_name] = 1;
142
- return _Jsep;
143
- }
144
- /**
145
- * @method jsep.addBinaryOp
146
- * @param {string} op_name The name of the binary op to add
147
- * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
148
- * @param {boolean} [isRightAssociative=false] whether operator is right-associative
149
- * @returns {Jsep}
150
- */
151
- static addBinaryOp(op_name, precedence, isRightAssociative) {
152
- _Jsep.max_binop_len = Math.max(op_name.length, _Jsep.max_binop_len);
153
- _Jsep.binary_ops[op_name] = precedence;
154
- if (isRightAssociative) {
155
- _Jsep.right_associative.add(op_name);
156
- } else {
157
- _Jsep.right_associative.delete(op_name);
158
- }
159
- return _Jsep;
160
- }
161
- /**
162
- * @method addIdentifierChar
163
- * @param {string} char The additional character to treat as a valid part of an identifier
164
- * @returns {Jsep}
165
- */
166
- static addIdentifierChar(char) {
167
- _Jsep.additional_identifier_chars.add(char);
168
- return _Jsep;
169
- }
170
- /**
171
- * @method addLiteral
172
- * @param {string} literal_name The name of the literal to add
173
- * @param {*} literal_value The value of the literal
174
- * @returns {Jsep}
175
- */
176
- static addLiteral(literal_name, literal_value) {
177
- _Jsep.literals[literal_name] = literal_value;
178
- return _Jsep;
179
- }
180
- /**
181
- * @method removeUnaryOp
182
- * @param {string} op_name The name of the unary op to remove
183
- * @returns {Jsep}
184
- */
185
- static removeUnaryOp(op_name) {
186
- delete _Jsep.unary_ops[op_name];
187
- if (op_name.length === _Jsep.max_unop_len) {
188
- _Jsep.max_unop_len = _Jsep.getMaxKeyLen(_Jsep.unary_ops);
189
- }
190
- return _Jsep;
191
- }
192
- /**
193
- * @method removeAllUnaryOps
194
- * @returns {Jsep}
195
- */
196
- static removeAllUnaryOps() {
197
- _Jsep.unary_ops = {};
198
- _Jsep.max_unop_len = 0;
199
- return _Jsep;
200
- }
201
- /**
202
- * @method removeIdentifierChar
203
- * @param {string} char The additional character to stop treating as a valid part of an identifier
204
- * @returns {Jsep}
205
- */
206
- static removeIdentifierChar(char) {
207
- _Jsep.additional_identifier_chars.delete(char);
208
- return _Jsep;
209
- }
210
- /**
211
- * @method removeBinaryOp
212
- * @param {string} op_name The name of the binary op to remove
213
- * @returns {Jsep}
214
- */
215
- static removeBinaryOp(op_name) {
216
- delete _Jsep.binary_ops[op_name];
217
- if (op_name.length === _Jsep.max_binop_len) {
218
- _Jsep.max_binop_len = _Jsep.getMaxKeyLen(_Jsep.binary_ops);
219
- }
220
- _Jsep.right_associative.delete(op_name);
221
- return _Jsep;
222
- }
223
- /**
224
- * @method removeAllBinaryOps
225
- * @returns {Jsep}
226
- */
227
- static removeAllBinaryOps() {
228
- _Jsep.binary_ops = {};
229
- _Jsep.max_binop_len = 0;
230
- return _Jsep;
231
- }
232
- /**
233
- * @method removeLiteral
234
- * @param {string} literal_name The name of the literal to remove
235
- * @returns {Jsep}
236
- */
237
- static removeLiteral(literal_name) {
238
- delete _Jsep.literals[literal_name];
239
- return _Jsep;
240
- }
241
- /**
242
- * @method removeAllLiterals
243
- * @returns {Jsep}
244
- */
245
- static removeAllLiterals() {
246
- _Jsep.literals = {};
247
- return _Jsep;
248
- }
249
- // ==================== END CONFIG ============================
250
- /**
251
- * @returns {string}
252
- */
253
- get char() {
254
- return this.expr.charAt(this.index);
255
- }
256
- /**
257
- * @returns {number}
258
- */
259
- get code() {
260
- return this.expr.charCodeAt(this.index);
261
- }
262
- /**
263
- * @param {string} expr a string with the passed in express
264
- * @returns Jsep
265
- */
266
- constructor(expr) {
267
- this.expr = expr;
268
- this.index = 0;
269
- }
270
- /**
271
- * static top-level parser
272
- * @returns {jsep.Expression}
273
- */
274
- static parse(expr) {
275
- return new _Jsep(expr).parse();
276
- }
277
- /**
278
- * Get the longest key length of any object
279
- * @param {object} obj
280
- * @returns {number}
281
- */
282
- static getMaxKeyLen(obj) {
283
- return Math.max(0, ...Object.keys(obj).map((k) => k.length));
284
- }
285
- /**
286
- * `ch` is a character code in the next three functions
287
- * @param {number} ch
288
- * @returns {boolean}
289
- */
290
- static isDecimalDigit(ch) {
291
- return ch >= 48 && ch <= 57;
292
- }
293
- /**
294
- * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
295
- * @param {string} op_val
296
- * @returns {number}
297
- */
298
- static binaryPrecedence(op_val) {
299
- return _Jsep.binary_ops[op_val] || 0;
300
- }
301
- /**
302
- * Looks for start of identifier
303
- * @param {number} ch
304
- * @returns {boolean}
305
- */
306
- static isIdentifierStart(ch) {
307
- return ch >= 65 && ch <= 90 || // A...Z
308
- ch >= 97 && ch <= 122 || // a...z
309
- ch >= 128 && !_Jsep.binary_ops[String.fromCharCode(ch)] || // any non-ASCII that is not an operator
310
- _Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
311
- }
312
- /**
313
- * @param {number} ch
314
- * @returns {boolean}
315
- */
316
- static isIdentifierPart(ch) {
317
- return _Jsep.isIdentifierStart(ch) || _Jsep.isDecimalDigit(ch);
318
- }
319
- /**
320
- * throw error at index of the expression
321
- * @param {string} message
322
- * @throws
323
- */
324
- throwError(message) {
325
- const error = new Error(message + " at character " + this.index);
326
- error.index = this.index;
327
- error.description = message;
328
- throw error;
329
- }
330
- /**
331
- * Run a given hook
332
- * @param {string} name
333
- * @param {jsep.Expression|false} [node]
334
- * @returns {?jsep.Expression}
335
- */
336
- runHook(name, node) {
337
- if (_Jsep.hooks[name]) {
338
- const env = { context: this, node };
339
- _Jsep.hooks.run(name, env);
340
- return env.node;
341
- }
342
- return node;
343
- }
344
- /**
345
- * Runs a given hook until one returns a node
346
- * @param {string} name
347
- * @returns {?jsep.Expression}
348
- */
349
- searchHook(name) {
350
- if (_Jsep.hooks[name]) {
351
- const env = { context: this };
352
- _Jsep.hooks[name].find(function(callback) {
353
- callback.call(env.context, env);
354
- return env.node;
355
- });
356
- return env.node;
357
- }
358
- }
359
- /**
360
- * Push `index` up to the next non-space character
361
- */
362
- gobbleSpaces() {
363
- let ch = this.code;
364
- while (ch === _Jsep.SPACE_CODE || ch === _Jsep.TAB_CODE || ch === _Jsep.LF_CODE || ch === _Jsep.CR_CODE) {
365
- ch = this.expr.charCodeAt(++this.index);
366
- }
367
- this.runHook("gobble-spaces");
368
- }
369
- /**
370
- * Top-level method to parse all expressions and returns compound or single node
371
- * @returns {jsep.Expression}
372
- */
373
- parse() {
374
- this.runHook("before-all");
375
- const nodes = this.gobbleExpressions();
376
- const node = nodes.length === 1 ? nodes[0] : {
377
- type: _Jsep.COMPOUND,
378
- body: nodes
379
- };
380
- return this.runHook("after-all", node);
381
- }
382
- /**
383
- * top-level parser (but can be reused within as well)
384
- * @param {number} [untilICode]
385
- * @returns {jsep.Expression[]}
386
- */
387
- gobbleExpressions(untilICode) {
388
- let nodes = [], ch_i, node;
389
- while (this.index < this.expr.length) {
390
- ch_i = this.code;
391
- if (ch_i === _Jsep.SEMCOL_CODE || ch_i === _Jsep.COMMA_CODE) {
392
- this.index++;
393
- } else {
394
- if (node = this.gobbleExpression()) {
395
- nodes.push(node);
396
- } else if (this.index < this.expr.length) {
397
- if (ch_i === untilICode) {
398
- break;
399
- }
400
- this.throwError('Unexpected "' + this.char + '"');
401
- }
402
- }
403
- }
404
- return nodes;
405
- }
406
- /**
407
- * The main parsing function.
408
- * @returns {?jsep.Expression}
409
- */
410
- gobbleExpression() {
411
- const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
412
- this.gobbleSpaces();
413
- return this.runHook("after-expression", node);
414
- }
415
- /**
416
- * Search for the operation portion of the string (e.g. `+`, `===`)
417
- * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
418
- * and move down from 3 to 2 to 1 character until a matching binary operation is found
419
- * then, return that binary operation
420
- * @returns {string|boolean}
421
- */
422
- gobbleBinaryOp() {
423
- this.gobbleSpaces();
424
- let to_check = this.expr.substr(this.index, _Jsep.max_binop_len);
425
- let tc_len = to_check.length;
426
- while (tc_len > 0) {
427
- if (_Jsep.binary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
428
- this.index += tc_len;
429
- return to_check;
430
- }
431
- to_check = to_check.substr(0, --tc_len);
432
- }
433
- return false;
434
- }
435
- /**
436
- * This function is responsible for gobbling an individual expression,
437
- * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
438
- * @returns {?jsep.BinaryExpression}
439
- */
440
- gobbleBinaryExpression() {
441
- let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
442
- left = this.gobbleToken();
443
- if (!left) {
444
- return left;
445
- }
446
- biop = this.gobbleBinaryOp();
447
- if (!biop) {
448
- return left;
449
- }
450
- biop_info = { value: biop, prec: _Jsep.binaryPrecedence(biop), right_a: _Jsep.right_associative.has(biop) };
451
- right = this.gobbleToken();
452
- if (!right) {
453
- this.throwError("Expected expression after " + biop);
454
- }
455
- stack = [left, biop_info, right];
456
- while (biop = this.gobbleBinaryOp()) {
457
- prec = _Jsep.binaryPrecedence(biop);
458
- if (prec === 0) {
459
- this.index -= biop.length;
460
- break;
461
- }
462
- biop_info = { value: biop, prec, right_a: _Jsep.right_associative.has(biop) };
463
- cur_biop = biop;
464
- const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
465
- while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
466
- right = stack.pop();
467
- biop = stack.pop().value;
468
- left = stack.pop();
469
- node = {
470
- type: _Jsep.BINARY_EXP,
471
- operator: biop,
472
- left,
473
- right
474
- };
475
- stack.push(node);
476
- }
477
- node = this.gobbleToken();
478
- if (!node) {
479
- this.throwError("Expected expression after " + cur_biop);
480
- }
481
- stack.push(biop_info, node);
482
- }
483
- i = stack.length - 1;
484
- node = stack[i];
485
- while (i > 1) {
486
- node = {
487
- type: _Jsep.BINARY_EXP,
488
- operator: stack[i - 1].value,
489
- left: stack[i - 2],
490
- right: node
491
- };
492
- i -= 2;
493
- }
494
- return node;
495
- }
496
- /**
497
- * An individual part of a binary expression:
498
- * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
499
- * @returns {boolean|jsep.Expression}
500
- */
501
- gobbleToken() {
502
- let ch, to_check, tc_len, node;
503
- this.gobbleSpaces();
504
- node = this.searchHook("gobble-token");
505
- if (node) {
506
- return this.runHook("after-token", node);
507
- }
508
- ch = this.code;
509
- if (_Jsep.isDecimalDigit(ch) || ch === _Jsep.PERIOD_CODE) {
510
- return this.gobbleNumericLiteral();
511
- }
512
- if (ch === _Jsep.SQUOTE_CODE || ch === _Jsep.DQUOTE_CODE) {
513
- node = this.gobbleStringLiteral();
514
- } else if (ch === _Jsep.OBRACK_CODE) {
515
- node = this.gobbleArray();
516
- } else {
517
- to_check = this.expr.substr(this.index, _Jsep.max_unop_len);
518
- tc_len = to_check.length;
519
- while (tc_len > 0) {
520
- if (_Jsep.unary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
521
- this.index += tc_len;
522
- const argument = this.gobbleToken();
523
- if (!argument) {
524
- this.throwError("missing unaryOp argument");
525
- }
526
- return this.runHook("after-token", {
527
- type: _Jsep.UNARY_EXP,
528
- operator: to_check,
529
- argument,
530
- prefix: true
531
- });
532
- }
533
- to_check = to_check.substr(0, --tc_len);
534
- }
535
- if (_Jsep.isIdentifierStart(ch)) {
536
- node = this.gobbleIdentifier();
537
- if (_Jsep.literals.hasOwnProperty(node.name)) {
538
- node = {
539
- type: _Jsep.LITERAL,
540
- value: _Jsep.literals[node.name],
541
- raw: node.name
542
- };
543
- } else if (node.name === _Jsep.this_str) {
544
- node = { type: _Jsep.THIS_EXP };
545
- }
546
- } else if (ch === _Jsep.OPAREN_CODE) {
547
- node = this.gobbleGroup();
548
- }
549
- }
550
- if (!node) {
551
- return this.runHook("after-token", false);
552
- }
553
- node = this.gobbleTokenProperty(node);
554
- return this.runHook("after-token", node);
555
- }
556
- /**
557
- * Gobble properties of of identifiers/strings/arrays/groups.
558
- * e.g. `foo`, `bar.baz`, `foo['bar'].baz`
559
- * It also gobbles function calls:
560
- * e.g. `Math.acos(obj.angle)`
561
- * @param {jsep.Expression} node
562
- * @returns {jsep.Expression}
563
- */
564
- gobbleTokenProperty(node) {
565
- this.gobbleSpaces();
566
- let ch = this.code;
567
- while (ch === _Jsep.PERIOD_CODE || ch === _Jsep.OBRACK_CODE || ch === _Jsep.OPAREN_CODE || ch === _Jsep.QUMARK_CODE) {
568
- let optional;
569
- if (ch === _Jsep.QUMARK_CODE) {
570
- if (this.expr.charCodeAt(this.index + 1) !== _Jsep.PERIOD_CODE) {
571
- break;
572
- }
573
- optional = true;
574
- this.index += 2;
575
- this.gobbleSpaces();
576
- ch = this.code;
577
- }
578
- this.index++;
579
- if (ch === _Jsep.OBRACK_CODE) {
580
- node = {
581
- type: _Jsep.MEMBER_EXP,
582
- computed: true,
583
- object: node,
584
- property: this.gobbleExpression()
585
- };
586
- if (!node.property) {
587
- this.throwError('Unexpected "' + this.char + '"');
588
- }
589
- this.gobbleSpaces();
590
- ch = this.code;
591
- if (ch !== _Jsep.CBRACK_CODE) {
592
- this.throwError("Unclosed [");
593
- }
594
- this.index++;
595
- } else if (ch === _Jsep.OPAREN_CODE) {
596
- node = {
597
- type: _Jsep.CALL_EXP,
598
- "arguments": this.gobbleArguments(_Jsep.CPAREN_CODE),
599
- callee: node
600
- };
601
- } else if (ch === _Jsep.PERIOD_CODE || optional) {
602
- if (optional) {
603
- this.index--;
604
- }
605
- this.gobbleSpaces();
606
- node = {
607
- type: _Jsep.MEMBER_EXP,
608
- computed: false,
609
- object: node,
610
- property: this.gobbleIdentifier()
611
- };
612
- }
613
- if (optional) {
614
- node.optional = true;
615
- }
616
- this.gobbleSpaces();
617
- ch = this.code;
618
- }
619
- return node;
620
- }
621
- /**
622
- * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
623
- * keep track of everything in the numeric literal and then calling `parseFloat` on that string
624
- * @returns {jsep.Literal}
625
- */
626
- gobbleNumericLiteral() {
627
- let number = "", ch, chCode;
628
- while (_Jsep.isDecimalDigit(this.code)) {
629
- number += this.expr.charAt(this.index++);
630
- }
631
- if (this.code === _Jsep.PERIOD_CODE) {
632
- number += this.expr.charAt(this.index++);
633
- while (_Jsep.isDecimalDigit(this.code)) {
634
- number += this.expr.charAt(this.index++);
635
- }
636
- }
637
- ch = this.char;
638
- if (ch === "e" || ch === "E") {
639
- number += this.expr.charAt(this.index++);
640
- ch = this.char;
641
- if (ch === "+" || ch === "-") {
642
- number += this.expr.charAt(this.index++);
643
- }
644
- while (_Jsep.isDecimalDigit(this.code)) {
645
- number += this.expr.charAt(this.index++);
646
- }
647
- if (!_Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
648
- this.throwError("Expected exponent (" + number + this.char + ")");
649
- }
650
- }
651
- chCode = this.code;
652
- if (_Jsep.isIdentifierStart(chCode)) {
653
- this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
654
- } else if (chCode === _Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === _Jsep.PERIOD_CODE) {
655
- this.throwError("Unexpected period");
656
- }
657
- return {
658
- type: _Jsep.LITERAL,
659
- value: parseFloat(number),
660
- raw: number
661
- };
662
- }
663
- /**
664
- * Parses a string literal, staring with single or double quotes with basic support for escape codes
665
- * e.g. `"hello world"`, `'this is\nJSEP'`
666
- * @returns {jsep.Literal}
667
- */
668
- gobbleStringLiteral() {
669
- let str = "";
670
- const startIndex = this.index;
671
- const quote = this.expr.charAt(this.index++);
672
- let closed = false;
673
- while (this.index < this.expr.length) {
674
- let ch = this.expr.charAt(this.index++);
675
- if (ch === quote) {
676
- closed = true;
677
- break;
678
- } else if (ch === "\\") {
679
- ch = this.expr.charAt(this.index++);
680
- switch (ch) {
681
- case "n":
682
- str += "\n";
683
- break;
684
- case "r":
685
- str += "\r";
686
- break;
687
- case "t":
688
- str += " ";
689
- break;
690
- case "b":
691
- str += "\b";
692
- break;
693
- case "f":
694
- str += "\f";
695
- break;
696
- case "v":
697
- str += "\v";
698
- break;
699
- default:
700
- str += ch;
701
- }
702
- } else {
703
- str += ch;
704
- }
705
- }
706
- if (!closed) {
707
- this.throwError('Unclosed quote after "' + str + '"');
708
- }
709
- return {
710
- type: _Jsep.LITERAL,
711
- value: str,
712
- raw: this.expr.substring(startIndex, this.index)
713
- };
714
- }
715
- /**
716
- * Gobbles only identifiers
717
- * e.g.: `foo`, `_value`, `$x1`
718
- * Also, this function checks if that identifier is a literal:
719
- * (e.g. `true`, `false`, `null`) or `this`
720
- * @returns {jsep.Identifier}
721
- */
722
- gobbleIdentifier() {
723
- let ch = this.code, start = this.index;
724
- if (_Jsep.isIdentifierStart(ch)) {
725
- this.index++;
726
- } else {
727
- this.throwError("Unexpected " + this.char);
728
- }
729
- while (this.index < this.expr.length) {
730
- ch = this.code;
731
- if (_Jsep.isIdentifierPart(ch)) {
732
- this.index++;
733
- } else {
734
- break;
735
- }
736
- }
737
- return {
738
- type: _Jsep.IDENTIFIER,
739
- name: this.expr.slice(start, this.index)
740
- };
741
- }
742
- /**
743
- * Gobbles a list of arguments within the context of a function call
744
- * or array literal. This function also assumes that the opening character
745
- * `(` or `[` has already been gobbled, and gobbles expressions and commas
746
- * until the terminator character `)` or `]` is encountered.
747
- * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
748
- * @param {number} termination
749
- * @returns {jsep.Expression[]}
750
- */
751
- gobbleArguments(termination) {
752
- const args = [];
753
- let closed = false;
754
- let separator_count = 0;
755
- while (this.index < this.expr.length) {
756
- this.gobbleSpaces();
757
- let ch_i = this.code;
758
- if (ch_i === termination) {
759
- closed = true;
760
- this.index++;
761
- if (termination === _Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
762
- this.throwError("Unexpected token " + String.fromCharCode(termination));
763
- }
764
- break;
765
- } else if (ch_i === _Jsep.COMMA_CODE) {
766
- this.index++;
767
- separator_count++;
768
- if (separator_count !== args.length) {
769
- if (termination === _Jsep.CPAREN_CODE) {
770
- this.throwError("Unexpected token ,");
771
- } else if (termination === _Jsep.CBRACK_CODE) {
772
- for (let arg = args.length; arg < separator_count; arg++) {
773
- args.push(null);
774
- }
775
- }
776
- }
777
- } else if (args.length !== separator_count && separator_count !== 0) {
778
- this.throwError("Expected comma");
779
- } else {
780
- const node = this.gobbleExpression();
781
- if (!node || node.type === _Jsep.COMPOUND) {
782
- this.throwError("Expected comma");
783
- }
784
- args.push(node);
785
- }
786
- }
787
- if (!closed) {
788
- this.throwError("Expected " + String.fromCharCode(termination));
789
- }
790
- return args;
791
- }
792
- /**
793
- * Responsible for parsing a group of things within parentheses `()`
794
- * that have no identifier in front (so not a function call)
795
- * This function assumes that it needs to gobble the opening parenthesis
796
- * and then tries to gobble everything within that parenthesis, assuming
797
- * that the next thing it should see is the close parenthesis. If not,
798
- * then the expression probably doesn't have a `)`
799
- * @returns {boolean|jsep.Expression}
800
- */
801
- gobbleGroup() {
802
- this.index++;
803
- let nodes = this.gobbleExpressions(_Jsep.CPAREN_CODE);
804
- if (this.code === _Jsep.CPAREN_CODE) {
805
- this.index++;
806
- if (nodes.length === 1) {
807
- return nodes[0];
808
- } else if (!nodes.length) {
809
- return false;
810
- } else {
811
- return {
812
- type: _Jsep.SEQUENCE_EXP,
813
- expressions: nodes
814
- };
815
- }
816
- } else {
817
- this.throwError("Unclosed (");
818
- }
819
- }
820
- /**
821
- * Responsible for parsing Array literals `[1, 2, 3]`
822
- * This function assumes that it needs to gobble the opening bracket
823
- * and then tries to gobble the expressions as arguments.
824
- * @returns {jsep.ArrayExpression}
825
- */
826
- gobbleArray() {
827
- this.index++;
828
- return {
829
- type: _Jsep.ARRAY_EXP,
830
- elements: this.gobbleArguments(_Jsep.CBRACK_CODE)
831
- };
832
- }
833
- };
834
- var hooks = new Hooks();
835
- Object.assign(Jsep, {
836
- hooks,
837
- plugins: new Plugins(Jsep),
838
- // Node Types
839
- // ----------
840
- // This is the full set of types that any JSEP node can be.
841
- // Store them here to save space when minified
842
- COMPOUND: "Compound",
843
- SEQUENCE_EXP: "SequenceExpression",
844
- IDENTIFIER: "Identifier",
845
- MEMBER_EXP: "MemberExpression",
846
- LITERAL: "Literal",
847
- THIS_EXP: "ThisExpression",
848
- CALL_EXP: "CallExpression",
849
- UNARY_EXP: "UnaryExpression",
850
- BINARY_EXP: "BinaryExpression",
851
- ARRAY_EXP: "ArrayExpression",
852
- TAB_CODE: 9,
853
- LF_CODE: 10,
854
- CR_CODE: 13,
855
- SPACE_CODE: 32,
856
- PERIOD_CODE: 46,
857
- // '.'
858
- COMMA_CODE: 44,
859
- // ','
860
- SQUOTE_CODE: 39,
861
- // single quote
862
- DQUOTE_CODE: 34,
863
- // double quotes
864
- OPAREN_CODE: 40,
865
- // (
866
- CPAREN_CODE: 41,
867
- // )
868
- OBRACK_CODE: 91,
869
- // [
870
- CBRACK_CODE: 93,
871
- // ]
872
- QUMARK_CODE: 63,
873
- // ?
874
- SEMCOL_CODE: 59,
875
- // ;
876
- COLON_CODE: 58,
877
- // :
878
- // Operations
879
- // ----------
880
- // Use a quickly-accessible map to store all of the unary operators
881
- // Values are set to `1` (it really doesn't matter)
882
- unary_ops: {
883
- "-": 1,
884
- "!": 1,
885
- "~": 1,
886
- "+": 1
887
- },
888
- // Also use a map for the binary operations but set their values to their
889
- // binary precedence for quick reference (higher number = higher precedence)
890
- // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
891
- binary_ops: {
892
- "||": 1,
893
- "??": 1,
894
- "&&": 2,
895
- "|": 3,
896
- "^": 4,
897
- "&": 5,
898
- "==": 6,
899
- "!=": 6,
900
- "===": 6,
901
- "!==": 6,
902
- "<": 7,
903
- ">": 7,
904
- "<=": 7,
905
- ">=": 7,
906
- "<<": 8,
907
- ">>": 8,
908
- ">>>": 8,
909
- "+": 9,
910
- "-": 9,
911
- "*": 10,
912
- "/": 10,
913
- "%": 10,
914
- "**": 11
915
- },
916
- // sets specific binary_ops as right-associative
917
- right_associative: /* @__PURE__ */ new Set(["**"]),
918
- // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
919
- additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
920
- // Literals
921
- // ----------
922
- // Store the values to return for the various literals we may encounter
923
- literals: {
924
- "true": true,
925
- "false": false,
926
- "null": null
927
- },
928
- // Except for `this`, which is special. This could be changed to something like `'self'` as well
929
- this_str: "this"
930
- });
931
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
932
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
933
- var jsep = (expr) => new Jsep(expr).parse();
934
- var stdClassProps = Object.getOwnPropertyNames(class Test {
935
- });
936
- Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === void 0).forEach((m) => {
937
- jsep[m] = Jsep[m];
938
- });
939
- jsep.Jsep = Jsep;
940
- var CONDITIONAL_EXP = "ConditionalExpression";
941
- var ternary = {
942
- name: "ternary",
943
- init(jsep2) {
944
- jsep2.hooks.add("after-expression", function gobbleTernary(env) {
945
- if (env.node && this.code === jsep2.QUMARK_CODE) {
946
- this.index++;
947
- const test = env.node;
948
- const consequent = this.gobbleExpression();
949
- if (!consequent) {
950
- this.throwError("Expected expression");
951
- }
952
- this.gobbleSpaces();
953
- if (this.code === jsep2.COLON_CODE) {
954
- this.index++;
955
- const alternate = this.gobbleExpression();
956
- if (!alternate) {
957
- this.throwError("Expected expression");
958
- }
959
- env.node = {
960
- type: CONDITIONAL_EXP,
961
- test,
962
- consequent,
963
- alternate
964
- };
965
- if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
966
- let newTest = test;
967
- while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
968
- newTest = newTest.right;
969
- }
970
- env.node.test = newTest.right;
971
- newTest.right = env.node;
972
- env.node = test;
973
- }
974
- } else {
975
- this.throwError("Expected :");
976
- }
977
- }
978
- });
979
- }
980
- };
981
- jsep.plugins.register(ternary);
982
-
983
- // ../hegel/dist/index.js
984
- Array.prototype.mapNotNull = function(callback) {
985
- return this.map(callback).filter((item) => item != null);
986
- };
987
- Array.prototype.cast = function() {
988
- return this;
989
- };
990
-
991
- // src/taxonomiesRelationshipFields.ts
992
- var taxonomyRelationship = {
993
- name: "categories",
994
- label: "Categor\xEDas",
995
- type: "relationship",
996
- relationTo: COLLECTION_SLUG_TAXONOMY,
997
- defaultValue: [],
998
- hasMany: true,
999
- required: false
1000
- };
1001
-
1002
- // src/buildTaxonomizedCollection.ts
1003
- var buildTaxonomizedCollection = (config) => {
1004
- const protoConfigCollection = {
1005
- ...config,
1006
- fields: [taxonomyRelationship, ...config.fields]
1007
- };
1008
- return protoConfigCollection;
1009
- };
1010
- export {
1011
- COLLECTION_SLUG_TAXONOMY,
1012
- buildTaxonomizedCollection,
1013
- taxonomiesCollection,
1014
- taxonomyRelationship
1015
- };
1
+ export { taxonomiesCollection } from "./taxonomy";
2
+ export { COLLECTION_SLUG_TAXONOMY } from "./taxonomy";
3
+ export { buildTaxonomizedCollection } from "./buildTaxonomizedCollection";
4
+ export { taxonomyRelationship } from "./taxonomiesRelationshipFields";