| 115 | }; |
| 116 | |
| 117 | function isPrimaryKeyFlag(idInitializer) { |
| 118 | const kindName = syntaxKindName(idInitializer.kind); |
| 119 | |
| 120 | /* istanbul ignore if */ |
| 121 | if (debug.enabled) { |
| 122 | debug( |
| 123 | 'Checking primary key flag initializer, kind: %s node:', |
| 124 | kindName, |
| 125 | require('util').inspect( |
| 126 | {...idInitializer, parent: '[removed for brevity]'}, |
| 127 | {depth: null}, |
| 128 | ), |
| 129 | ); |
| 130 | } |
| 131 | |
| 132 | // {id: true} |
| 133 | if (kindName === 'TrueKeyword') return true; |
| 134 | |
| 135 | // {id: number} |
| 136 | if (kindName === 'NumericLiteral') { |
| 137 | const ix = +idInitializer.text; |
| 138 | // the value must be a non-zero number, e.g. {id: 1} |
| 139 | return ix !== 0 && !isNaN(ix); |
| 140 | } |
| 141 | |
| 142 | return false; |
| 143 | } |
| 144 | |
| 145 | exports.getDataSourceConfig = function (fileContent) { |
| 146 | const ast = tsquery.ast(fileContent); |