(input: string, now: Date)
| 116 | } |
| 117 | |
| 118 | export function convert(input: string, now: Date) { |
| 119 | const tree = parser.parse(input) |
| 120 | const context = new Context(now) |
| 121 | tree.cursor().iterate( |
| 122 | (node) => astEnter(input, node, context), |
| 123 | (node) => { |
| 124 | astLeave(input, node, context) |
| 125 | }, |
| 126 | ) |
| 127 | serialize(context.root, context) |
| 128 | return { |
| 129 | sql: |
| 130 | context.sql.length === 0 |
| 131 | ? null |
| 132 | : (sql.join(context.sql, sql``) as RawBuilder<SqlBool>), |
| 133 | joinCardTag: context.joinCardTag, |
| 134 | joinNoteTag: context.joinNoteTag, |
| 135 | cardTagCount: context.cardTagCount, |
| 136 | noteTagCount: context.noteTagCount, |
| 137 | joinCardTagFts: context.joinCardTagsFts, |
| 138 | joinNoteTagFts: context.joinNoteTagsFts, |
| 139 | joinNoteValueFts: context.joinNoteValueFts, |
| 140 | joinNoteFieldValue: context.joinNoteFieldValue, |
| 141 | joinCardSettingNameFts: context.joinCardSettingNameFts, |
| 142 | joinTemplateNameFts: context.joinTemplateNameFts, |
| 143 | joinLatestReview: context.joinLatestReview, |
| 144 | joinReview: context.joinReview, |
| 145 | joinFirstReview: context.joinFirstReview, |
| 146 | fieldValueHighlight: context.fieldValueHighlight, |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // https://stackoverflow.com/a/28798479 |
| 151 | export function unique(str: string) { |
no test coverage detected