All files index.js

70.17% Statements 40/57
40% Branches 2/5
20% Functions 1/5
70.17% Lines 40/57

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 581x 1x 1x 1x 1x 1x 1x 1x 1x         1x 1x       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x             1x     1x 1x 1x 1x 1x 1x 1x     1x 1x  
/**
 * @license
 * Copyright 2022 Open Ag Data Alliance
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 */
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _SchemaInfo_schema;
import { createRequire } from 'node:module';
import path from 'node:path';
import url from 'node:url';
import globP from 'glob-promise';
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
const schemas = await globP('/**/*.schema.{ts,js}', {
    cwd: dirname,
    root: dirname,
    nomount: true,
});
/**
 * Every .schema.ts file we have
 */
export const glob = schemas.map((key) => key.replace(/\/+/, '/').replace(/\.(?:ts|js)$/, '.json'));
export const requireSchema = createRequire(path.join(dirname, 'schemas'));
export class SchemaInfo {
    constructor(key) {
        _SchemaInfo_schema.set(this, void 0);
        this.path = path.join(dirname, key);
        this.key = key;
        const inFile = this.key.replace(/^\//, './').replace(/\.json$/, '');
        __classPrivateFieldSet(this, _SchemaInfo_schema, requireSchema(inFile), "f");
    }
    get schema() {
        return __classPrivateFieldGet(this, _SchemaInfo_schema, "f");
    }
}
_SchemaInfo_schema = new WeakMap();
/**
 * Load all the schemas
 */
function* loadAllFormats() {
    for (const key of glob) {
        yield new SchemaInfo(key);
    }
}
export default loadAllFormats;