(args)
| 76 | Partial<Flags> |
| 77 | |
| 78 | export const makeSource: core.MakeSourcePlugin<Args> = (args) => async (sourceKey) => { |
| 79 | const { |
| 80 | options, |
| 81 | extensions, |
| 82 | restArgs: { |
| 83 | documentTypes, |
| 84 | contentDirPath: contentDirPath_, |
| 85 | contentDirInclude: contentDirInclude_, |
| 86 | contentDirExclude: contentDirExclude_, |
| 87 | onUnknownDocuments = 'skip-warn', |
| 88 | onMissingOrIncompatibleData = 'skip-warn', |
| 89 | onExtraFieldData = 'warn', |
| 90 | }, |
| 91 | } = await processArgs(args, sourceKey) |
| 92 | |
| 93 | const flags: Flags = { onUnknownDocuments, onExtraFieldData, onMissingOrIncompatibleData } |
| 94 | |
| 95 | const documentTypeDefs = (Array.isArray(documentTypes) ? documentTypes : Object.values(documentTypes)).map((_) => |
| 96 | _.def(), |
| 97 | ) |
| 98 | |
| 99 | return { |
| 100 | type: 'local', |
| 101 | extensions: extensions ?? {}, |
| 102 | options, |
| 103 | provideSchema: (esbuildHash) => |
| 104 | pipe( |
| 105 | makeCoreSchema({ documentTypeDefs, options, esbuildHash }), |
| 106 | T.mapError((error) => new SourceProvideSchemaError({ error })), |
| 107 | ), |
| 108 | fetchData: ({ schemaDef, verbose, skipCachePersistence }) => |
| 109 | pipe( |
| 110 | S.fromEffect(core.getCwd), |
| 111 | S.chain((cwd) => { |
| 112 | const contentDirPath = unknownToAbsolutePosixFilePath(contentDirPath_, cwd) |
| 113 | const contentDirExclude = (contentDirExclude_ ?? contentDirExcludeDefault).map((_) => |
| 114 | unknownToRelativePosixFilePath(_, contentDirPath), |
| 115 | ) |
| 116 | const contentDirInclude = (contentDirInclude_ ?? []).map((_) => |
| 117 | unknownToRelativePosixFilePath(_, contentDirPath), |
| 118 | ) |
| 119 | |
| 120 | return fetchData({ |
| 121 | coreSchemaDef: schemaDef, |
| 122 | documentTypeDefs, |
| 123 | flags, |
| 124 | options, |
| 125 | contentDirPath, |
| 126 | contentDirExclude, |
| 127 | contentDirInclude, |
| 128 | verbose, |
| 129 | skipCachePersistence, |
| 130 | }) |
| 131 | }), |
| 132 | ), |
| 133 | } |
| 134 | } |
| 135 |
searching dependent graphs…