UNPKG

@silexlabs/grapesjs-data-source

Version:
196 lines 6.75 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.simpleQueryables = exports.simpleTypes = exports.simpleFilters = exports.testFields = exports.testTokens = exports.testDataSourceId = void 0; exports.importDataSource = importDataSource; const globals_1 = require("@jest/globals"); function importDataSource(datas) { return __awaiter(this, void 0, void 0, function* () { if (datas === null || datas === void 0 ? void 0 : datas.length) { global.fetch = globals_1.jest.fn(); datas === null || datas === void 0 ? void 0 : datas.forEach(data => { global.fetch .mockImplementationOnce(() => { return Promise.resolve({ ok: true, json: () => Promise.resolve(data), }); }); }); } return (yield Promise.resolve().then(() => __importStar(require('./datasources/GraphQL')))).default; }); } exports.testDataSourceId = 'testDataSourceId'; exports.testTokens = { rootField1: { type: 'property', propType: 'field', fieldId: 'rootField1', label: 'test', typeIds: ['rootTypeId1'], kind: 'object', dataSourceId: 'testDataSourceId', }, filter: { type: 'filter', id: 'filterId', label: 'filter name', validate: () => true, output: () => null, apply: () => null, options: {}, }, rootField2: { type: 'property', propType: 'field', fieldId: 'rootField2', label: 'test', typeIds: ['rootTypeId2'], kind: 'object', dataSourceId: 'testDataSourceId', }, childField1: { type: 'property', propType: 'field', fieldId: 'childField1', label: 'test', typeIds: ['childTypeId1'], kind: 'scalar', dataSourceId: 'testDataSourceId', }, childField2: { type: 'property', propType: 'field', fieldId: 'childField2', label: 'test', typeIds: ['childTypeId2'], kind: 'scalar', dataSourceId: 'testDataSourceId', }, childField3: { type: 'property', propType: 'field', fieldId: 'childField3', label: 'test', typeIds: ['childTypeId3'], kind: 'scalar', dataSourceId: 'testDataSourceId', }, }; exports.testFields = { stringField1: { id: 'stringField1', label: 'test', typeIds: ['String'], kind: 'scalar', dataSourceId: 'testDataSourceId', }, dateField1: { id: 'dateField1', label: 'test', typeIds: ['SomeType', 'date'], kind: 'scalar', dataSourceId: 'testDataSourceId', }, dateField2: { id: 'dateField2', label: 'test', typeIds: ['SomeType', 'Instant'], kind: 'list', dataSourceId: 'testDataSourceId', }, }; exports.simpleFilters = [{ type: 'filter', id: 'testFilterAnyInput', label: 'test filter any input', validate: type => !type, // Just for empty expressions output: () => null, options: {}, apply: globals_1.jest.fn(), }, { type: 'filter', id: 'testFilterId', label: 'test filter name', validate: type => !!(type === null || type === void 0 ? void 0 : type.typeIds.includes('testTypeId')), output: type => type, options: {}, apply: globals_1.jest.fn(), }, { type: 'filter', id: 'testFilterId2', label: 'test filter name 2', validate: type => !!(type === null || type === void 0 ? void 0 : type.typeIds.includes('testFieldTypeId')), output: () => null, options: {}, apply: globals_1.jest.fn(), }]; exports.simpleTypes = [{ id: 'testTypeId', label: 'test type name', fields: [ { id: 'testFieldId', label: 'test field name', typeIds: ['testFieldTypeId'], kind: 'scalar', dataSourceId: exports.testDataSourceId, } ], dataSourceId: exports.testDataSourceId, }, { id: 'testFieldTypeId', label: 'test field type name', fields: [], dataSourceId: exports.testDataSourceId, }]; exports.simpleQueryables = [{ id: 'testSimpleQueryableId', label: 'test queryable', typeIds: ['testTypeId'], kind: 'scalar', dataSourceId: exports.testDataSourceId, }]; //# sourceMappingURL=test-data.js.map