1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const DocumentList_1 = require("./DocumentList");
|
4 | const documentTypeListItems_1 = require("./documentTypeListItems");
|
5 |
|
6 |
|
7 | class DocumentTypeListBuilder extends DocumentList_1.DocumentListBuilder {
|
8 | constructor(spec) {
|
9 | super();
|
10 | this.spec = spec ? spec : {};
|
11 | }
|
12 | filter(filter) {
|
13 | return this.cloneWithoutDefaultIntentHandler({
|
14 | options: Object.assign({}, (this.spec.options || {}), { filter })
|
15 | });
|
16 | }
|
17 | params(params) {
|
18 | return this.cloneWithoutDefaultIntentHandler({
|
19 | options: Object.assign({}, (this.spec.options || { filter: '' }), { params })
|
20 | });
|
21 | }
|
22 | schemaType(type) {
|
23 | return this.cloneWithoutDefaultIntentHandler({
|
24 | schemaTypeName: typeof type === 'string' ? type : type.name
|
25 | });
|
26 | }
|
27 | child(child) {
|
28 | return this.cloneWithoutDefaultIntentHandler({ child });
|
29 | }
|
30 | clone(withSpec) {
|
31 | const builder = new DocumentTypeListBuilder();
|
32 | builder.spec = Object.assign({}, this.spec, (withSpec || {}));
|
33 | return builder;
|
34 | }
|
35 | cloneWithoutDefaultIntentHandler(withSpec) {
|
36 | const builder = new DocumentTypeListBuilder();
|
37 | const canHandleIntent = this.spec.canHandleIntent;
|
38 | const shouldOverride = canHandleIntent && canHandleIntent.identity === documentTypeListItems_1.DEFAULT_INTENT_HANDLER;
|
39 | const override = shouldOverride ? { canHandleIntent: undefined } : {};
|
40 | builder.spec = Object.assign({}, this.spec, (withSpec || {}), override);
|
41 | return builder;
|
42 | }
|
43 | }
|
44 | exports.DocumentTypeListBuilder = DocumentTypeListBuilder;
|
45 |
|
46 |
|